documentation.d.ts 2.9 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076
  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. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. let Epsilon: number;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts current color in rgb space to HSV values
  464. * @returns a new color3 representing the HSV values
  465. */
  466. toHSV(): Color3;
  467. /**
  468. * Converts current color in rgb space to HSV values
  469. * @param result defines the Color3 where to store the HSV values
  470. */
  471. toHSVToRef(result: Color3): void;
  472. /**
  473. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  474. * @param convertedColor defines the Color3 object where to store the linear space version
  475. * @returns the unmodified Color3
  476. */
  477. toLinearSpaceToRef(convertedColor: Color3): Color3;
  478. /**
  479. * Computes a new Color3 converted from the current one to gamma space
  480. * @returns a new Color3 object
  481. */
  482. toGammaSpace(): Color3;
  483. /**
  484. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  485. * @param convertedColor defines the Color3 object where to store the gamma space version
  486. * @returns the unmodified Color3
  487. */
  488. toGammaSpaceToRef(convertedColor: Color3): Color3;
  489. private static _BlackReadOnly;
  490. /**
  491. * Convert Hue, saturation and value to a Color3 (RGB)
  492. * @param hue defines the hue
  493. * @param saturation defines the saturation
  494. * @param value defines the value
  495. * @param result defines the Color3 where to store the RGB values
  496. */
  497. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  498. /**
  499. * Creates a new Color3 from the string containing valid hexadecimal values
  500. * @param hex defines a string containing valid hexadecimal values
  501. * @returns a new Color3 object
  502. */
  503. static FromHexString(hex: string): Color3;
  504. /**
  505. * Creates a new Color3 from the starting index of the given array
  506. * @param array defines the source array
  507. * @param offset defines an offset in the source array
  508. * @returns a new Color3 object
  509. */
  510. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  511. /**
  512. * Creates a new Color3 from integer values (< 256)
  513. * @param r defines the red component to read from (value between 0 and 255)
  514. * @param g defines the green component to read from (value between 0 and 255)
  515. * @param b defines the blue component to read from (value between 0 and 255)
  516. * @returns a new Color3 object
  517. */
  518. static FromInts(r: number, g: number, b: number): Color3;
  519. /**
  520. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  521. * @param start defines the start Color3 value
  522. * @param end defines the end Color3 value
  523. * @param amount defines the gradient value between start and end
  524. * @returns a new Color3 object
  525. */
  526. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  527. /**
  528. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  529. * @param left defines the start value
  530. * @param right defines the end value
  531. * @param amount defines the gradient factor
  532. * @param result defines the Color3 object where to store the result
  533. */
  534. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  535. /**
  536. * Returns a Color3 value containing a red color
  537. * @returns a new Color3 object
  538. */
  539. static Red(): Color3;
  540. /**
  541. * Returns a Color3 value containing a green color
  542. * @returns a new Color3 object
  543. */
  544. static Green(): Color3;
  545. /**
  546. * Returns a Color3 value containing a blue color
  547. * @returns a new Color3 object
  548. */
  549. static Blue(): Color3;
  550. /**
  551. * Returns a Color3 value containing a black color
  552. * @returns a new Color3 object
  553. */
  554. static Black(): Color3;
  555. /**
  556. * Gets a Color3 value containing a black color that must not be updated
  557. */
  558. static readonly BlackReadOnly: DeepImmutable<Color3>;
  559. /**
  560. * Returns a Color3 value containing a white color
  561. * @returns a new Color3 object
  562. */
  563. static White(): Color3;
  564. /**
  565. * Returns a Color3 value containing a purple color
  566. * @returns a new Color3 object
  567. */
  568. static Purple(): Color3;
  569. /**
  570. * Returns a Color3 value containing a magenta color
  571. * @returns a new Color3 object
  572. */
  573. static Magenta(): Color3;
  574. /**
  575. * Returns a Color3 value containing a yellow color
  576. * @returns a new Color3 object
  577. */
  578. static Yellow(): Color3;
  579. /**
  580. * Returns a Color3 value containing a gray color
  581. * @returns a new Color3 object
  582. */
  583. static Gray(): Color3;
  584. /**
  585. * Returns a Color3 value containing a teal color
  586. * @returns a new Color3 object
  587. */
  588. static Teal(): Color3;
  589. /**
  590. * Returns a Color3 value containing a random color
  591. * @returns a new Color3 object
  592. */
  593. static Random(): Color3;
  594. }
  595. /**
  596. * Class used to hold a RBGA color
  597. */
  598. export class Color4 {
  599. /**
  600. * Defines the red component (between 0 and 1, default is 0)
  601. */
  602. r: number;
  603. /**
  604. * Defines the green component (between 0 and 1, default is 0)
  605. */
  606. g: number;
  607. /**
  608. * Defines the blue component (between 0 and 1, default is 0)
  609. */
  610. b: number;
  611. /**
  612. * Defines the alpha component (between 0 and 1, default is 1)
  613. */
  614. a: number;
  615. /**
  616. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  617. * @param r defines the red component (between 0 and 1, default is 0)
  618. * @param g defines the green component (between 0 and 1, default is 0)
  619. * @param b defines the blue component (between 0 and 1, default is 0)
  620. * @param a defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. constructor(
  623. /**
  624. * Defines the red component (between 0 and 1, default is 0)
  625. */
  626. r?: number,
  627. /**
  628. * Defines the green component (between 0 and 1, default is 0)
  629. */
  630. g?: number,
  631. /**
  632. * Defines the blue component (between 0 and 1, default is 0)
  633. */
  634. b?: number,
  635. /**
  636. * Defines the alpha component (between 0 and 1, default is 1)
  637. */
  638. a?: number);
  639. /**
  640. * Adds in place the given Color4 values to the current Color4 object
  641. * @param right defines the second operand
  642. * @returns the current updated Color4 object
  643. */
  644. addInPlace(right: DeepImmutable<Color4>): Color4;
  645. /**
  646. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  647. * @returns the new array
  648. */
  649. asArray(): number[];
  650. /**
  651. * Stores from the starting index in the given array the Color4 successive values
  652. * @param array defines the array where to store the r,g,b components
  653. * @param index defines an optional index in the target array to define where to start storing values
  654. * @returns the current Color4 object
  655. */
  656. toArray(array: number[], index?: number): Color4;
  657. /**
  658. * Determines equality between Color4 objects
  659. * @param otherColor defines the second operand
  660. * @returns true if the rgba values are equal to the given ones
  661. */
  662. equals(otherColor: DeepImmutable<Color4>): boolean;
  663. /**
  664. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  665. * @param right defines the second operand
  666. * @returns a new Color4 object
  667. */
  668. add(right: DeepImmutable<Color4>): Color4;
  669. /**
  670. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  671. * @param right defines the second operand
  672. * @returns a new Color4 object
  673. */
  674. subtract(right: DeepImmutable<Color4>): Color4;
  675. /**
  676. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  677. * @param right defines the second operand
  678. * @param result defines the Color4 object where to store the result
  679. * @returns the current Color4 object
  680. */
  681. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  682. /**
  683. * Creates a new Color4 with the current Color4 values multiplied by scale
  684. * @param scale defines the scaling factor to apply
  685. * @returns a new Color4 object
  686. */
  687. scale(scale: number): Color4;
  688. /**
  689. * Multiplies the current Color4 values by scale and stores the result in "result"
  690. * @param scale defines the scaling factor to apply
  691. * @param result defines the Color4 object where to store the result
  692. * @returns the current unmodified Color4
  693. */
  694. scaleToRef(scale: number, result: Color4): Color4;
  695. /**
  696. * Scale the current Color4 values by a factor and add the result to a given Color4
  697. * @param scale defines the scale factor
  698. * @param result defines the Color4 object where to store the result
  699. * @returns the unmodified current Color4
  700. */
  701. scaleAndAddToRef(scale: number, result: Color4): Color4;
  702. /**
  703. * Clamps the rgb values by the min and max values and stores the result into "result"
  704. * @param min defines minimum clamping value (default is 0)
  705. * @param max defines maximum clamping value (default is 1)
  706. * @param result defines color to store the result into.
  707. * @returns the cuurent Color4
  708. */
  709. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  710. /**
  711. * Multipy an Color4 value by another and return a new Color4 object
  712. * @param color defines the Color4 value to multiply by
  713. * @returns a new Color4 object
  714. */
  715. multiply(color: Color4): Color4;
  716. /**
  717. * Multipy a Color4 value by another and push the result in a reference value
  718. * @param color defines the Color4 value to multiply by
  719. * @param result defines the Color4 to fill the result in
  720. * @returns the result Color4
  721. */
  722. multiplyToRef(color: Color4, result: Color4): Color4;
  723. /**
  724. * Creates a string with the Color4 current values
  725. * @returns the string representation of the Color4 object
  726. */
  727. toString(): string;
  728. /**
  729. * Returns the string "Color4"
  730. * @returns "Color4"
  731. */
  732. getClassName(): string;
  733. /**
  734. * Compute the Color4 hash code
  735. * @returns an unique number that can be used to hash Color4 objects
  736. */
  737. getHashCode(): number;
  738. /**
  739. * Creates a new Color4 copied from the current one
  740. * @returns a new Color4 object
  741. */
  742. clone(): Color4;
  743. /**
  744. * Copies the given Color4 values into the current one
  745. * @param source defines the source Color4 object
  746. * @returns the current updated Color4 object
  747. */
  748. copyFrom(source: Color4): Color4;
  749. /**
  750. * Copies the given float values into the current one
  751. * @param r defines the red component to read from
  752. * @param g defines the green component to read from
  753. * @param b defines the blue component to read from
  754. * @param a defines the alpha component to read from
  755. * @returns the current updated Color4 object
  756. */
  757. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  758. /**
  759. * Copies the given float values into the current one
  760. * @param r defines the red component to read from
  761. * @param g defines the green component to read from
  762. * @param b defines the blue component to read from
  763. * @param a defines the alpha component to read from
  764. * @returns the current updated Color4 object
  765. */
  766. set(r: number, g: number, b: number, a: number): Color4;
  767. /**
  768. * Compute the Color4 hexadecimal code as a string
  769. * @returns a string containing the hexadecimal representation of the Color4 object
  770. */
  771. toHexString(): string;
  772. /**
  773. * Computes a new Color4 converted from the current one to linear space
  774. * @returns a new Color4 object
  775. */
  776. toLinearSpace(): Color4;
  777. /**
  778. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  779. * @param convertedColor defines the Color4 object where to store the linear space version
  780. * @returns the unmodified Color4
  781. */
  782. toLinearSpaceToRef(convertedColor: Color4): Color4;
  783. /**
  784. * Computes a new Color4 converted from the current one to gamma space
  785. * @returns a new Color4 object
  786. */
  787. toGammaSpace(): Color4;
  788. /**
  789. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  790. * @param convertedColor defines the Color4 object where to store the gamma space version
  791. * @returns the unmodified Color4
  792. */
  793. toGammaSpaceToRef(convertedColor: Color4): Color4;
  794. /**
  795. * Creates a new Color4 from the string containing valid hexadecimal values
  796. * @param hex defines a string containing valid hexadecimal values
  797. * @returns a new Color4 object
  798. */
  799. static FromHexString(hex: string): Color4;
  800. /**
  801. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  802. * @param left defines the start value
  803. * @param right defines the end value
  804. * @param amount defines the gradient factor
  805. * @returns a new Color4 object
  806. */
  807. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  808. /**
  809. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  810. * @param left defines the start value
  811. * @param right defines the end value
  812. * @param amount defines the gradient factor
  813. * @param result defines the Color4 object where to store data
  814. */
  815. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  816. /**
  817. * Creates a new Color4 from a Color3 and an alpha value
  818. * @param color3 defines the source Color3 to read from
  819. * @param alpha defines the alpha component (1.0 by default)
  820. * @returns a new Color4 object
  821. */
  822. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  823. /**
  824. * Creates a new Color4 from the starting index element of the given array
  825. * @param array defines the source array to read from
  826. * @param offset defines the offset in the source array
  827. * @returns a new Color4 object
  828. */
  829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  830. /**
  831. * Creates a new Color3 from integer values (< 256)
  832. * @param r defines the red component to read from (value between 0 and 255)
  833. * @param g defines the green component to read from (value between 0 and 255)
  834. * @param b defines the blue component to read from (value between 0 and 255)
  835. * @param a defines the alpha component to read from (value between 0 and 255)
  836. * @returns a new Color3 object
  837. */
  838. static FromInts(r: number, g: number, b: number, a: number): Color4;
  839. /**
  840. * Check the content of a given array and convert it to an array containing RGBA data
  841. * If the original array was already containing count * 4 values then it is returned directly
  842. * @param colors defines the array to check
  843. * @param count defines the number of RGBA data to expect
  844. * @returns an array containing count * 4 values (RGBA)
  845. */
  846. static CheckColors4(colors: number[], count: number): number[];
  847. }
  848. /**
  849. * Class representing a vector containing 2 coordinates
  850. */
  851. export class Vector2 {
  852. /** defines the first coordinate */
  853. x: number;
  854. /** defines the second coordinate */
  855. y: number;
  856. /**
  857. * Creates a new Vector2 from the given x and y coordinates
  858. * @param x defines the first coordinate
  859. * @param y defines the second coordinate
  860. */
  861. constructor(
  862. /** defines the first coordinate */
  863. x?: number,
  864. /** defines the second coordinate */
  865. y?: number);
  866. /**
  867. * Gets a string with the Vector2 coordinates
  868. * @returns a string with the Vector2 coordinates
  869. */
  870. toString(): string;
  871. /**
  872. * Gets class name
  873. * @returns the string "Vector2"
  874. */
  875. getClassName(): string;
  876. /**
  877. * Gets current vector hash code
  878. * @returns the Vector2 hash code as a number
  879. */
  880. getHashCode(): number;
  881. /**
  882. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  883. * @param array defines the source array
  884. * @param index defines the offset in source array
  885. * @returns the current Vector2
  886. */
  887. toArray(array: FloatArray, index?: number): Vector2;
  888. /**
  889. * Copy the current vector to an array
  890. * @returns a new array with 2 elements: the Vector2 coordinates.
  891. */
  892. asArray(): number[];
  893. /**
  894. * Sets the Vector2 coordinates with the given Vector2 coordinates
  895. * @param source defines the source Vector2
  896. * @returns the current updated Vector2
  897. */
  898. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  899. /**
  900. * Sets the Vector2 coordinates with the given floats
  901. * @param x defines the first coordinate
  902. * @param y defines the second coordinate
  903. * @returns the current updated Vector2
  904. */
  905. copyFromFloats(x: number, y: number): Vector2;
  906. /**
  907. * Sets the Vector2 coordinates with the given floats
  908. * @param x defines the first coordinate
  909. * @param y defines the second coordinate
  910. * @returns the current updated Vector2
  911. */
  912. set(x: number, y: number): Vector2;
  913. /**
  914. * Add another vector with the current one
  915. * @param otherVector defines the other vector
  916. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  917. */
  918. add(otherVector: DeepImmutable<Vector2>): Vector2;
  919. /**
  920. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  921. * @param otherVector defines the other vector
  922. * @param result defines the target vector
  923. * @returns the unmodified current Vector2
  924. */
  925. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  926. /**
  927. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  928. * @param otherVector defines the other vector
  929. * @returns the current updated Vector2
  930. */
  931. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  932. /**
  933. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  934. * @param otherVector defines the other vector
  935. * @returns a new Vector2
  936. */
  937. addVector3(otherVector: Vector3): Vector2;
  938. /**
  939. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  940. * @param otherVector defines the other vector
  941. * @returns a new Vector2
  942. */
  943. subtract(otherVector: Vector2): Vector2;
  944. /**
  945. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  946. * @param otherVector defines the other vector
  947. * @param result defines the target vector
  948. * @returns the unmodified current Vector2
  949. */
  950. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  951. /**
  952. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @returns the current updated Vector2
  955. */
  956. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  957. /**
  958. * Multiplies in place the current Vector2 coordinates by the given ones
  959. * @param otherVector defines the other vector
  960. * @returns the current updated Vector2
  961. */
  962. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  963. /**
  964. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  965. * @param otherVector defines the other vector
  966. * @returns a new Vector2
  967. */
  968. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  969. /**
  970. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  971. * @param otherVector defines the other vector
  972. * @param result defines the target vector
  973. * @returns the unmodified current Vector2
  974. */
  975. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  976. /**
  977. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  978. * @param x defines the first coordinate
  979. * @param y defines the second coordinate
  980. * @returns a new Vector2
  981. */
  982. multiplyByFloats(x: number, y: number): Vector2;
  983. /**
  984. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  985. * @param otherVector defines the other vector
  986. * @returns a new Vector2
  987. */
  988. divide(otherVector: Vector2): Vector2;
  989. /**
  990. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  991. * @param otherVector defines the other vector
  992. * @param result defines the target vector
  993. * @returns the unmodified current Vector2
  994. */
  995. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  996. /**
  997. * Divides the current Vector2 coordinates by the given ones
  998. * @param otherVector defines the other vector
  999. * @returns the current updated Vector2
  1000. */
  1001. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1002. /**
  1003. * Gets a new Vector2 with current Vector2 negated coordinates
  1004. * @returns a new Vector2
  1005. */
  1006. negate(): Vector2;
  1007. /**
  1008. * Multiply the Vector2 coordinates by scale
  1009. * @param scale defines the scaling factor
  1010. * @returns the current updated Vector2
  1011. */
  1012. scaleInPlace(scale: number): Vector2;
  1013. /**
  1014. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1015. * @param scale defines the scaling factor
  1016. * @returns a new Vector2
  1017. */
  1018. scale(scale: number): Vector2;
  1019. /**
  1020. * Scale the current Vector2 values by a factor to a given Vector2
  1021. * @param scale defines the scale factor
  1022. * @param result defines the Vector2 object where to store the result
  1023. * @returns the unmodified current Vector2
  1024. */
  1025. scaleToRef(scale: number, result: Vector2): Vector2;
  1026. /**
  1027. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1028. * @param scale defines the scale factor
  1029. * @param result defines the Vector2 object where to store the result
  1030. * @returns the unmodified current Vector2
  1031. */
  1032. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1033. /**
  1034. * Gets a boolean if two vectors are equals
  1035. * @param otherVector defines the other vector
  1036. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1037. */
  1038. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1039. /**
  1040. * Gets a boolean if two vectors are equals (using an epsilon value)
  1041. * @param otherVector defines the other vector
  1042. * @param epsilon defines the minimal distance to consider equality
  1043. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1044. */
  1045. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1046. /**
  1047. * Gets a new Vector2 from current Vector2 floored values
  1048. * @returns a new Vector2
  1049. */
  1050. floor(): Vector2;
  1051. /**
  1052. * Gets a new Vector2 from current Vector2 floored values
  1053. * @returns a new Vector2
  1054. */
  1055. fract(): Vector2;
  1056. /**
  1057. * Gets the length of the vector
  1058. * @returns the vector length (float)
  1059. */
  1060. length(): number;
  1061. /**
  1062. * Gets the vector squared length
  1063. * @returns the vector squared length (float)
  1064. */
  1065. lengthSquared(): number;
  1066. /**
  1067. * Normalize the vector
  1068. * @returns the current updated Vector2
  1069. */
  1070. normalize(): Vector2;
  1071. /**
  1072. * Gets a new Vector2 copied from the Vector2
  1073. * @returns a new Vector2
  1074. */
  1075. clone(): Vector2;
  1076. /**
  1077. * Gets a new Vector2(0, 0)
  1078. * @returns a new Vector2
  1079. */
  1080. static Zero(): Vector2;
  1081. /**
  1082. * Gets a new Vector2(1, 1)
  1083. * @returns a new Vector2
  1084. */
  1085. static One(): Vector2;
  1086. /**
  1087. * Gets a new Vector2 set from the given index element of the given array
  1088. * @param array defines the data source
  1089. * @param offset defines the offset in the data source
  1090. * @returns a new Vector2
  1091. */
  1092. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1093. /**
  1094. * Sets "result" from the given index element of the given array
  1095. * @param array defines the data source
  1096. * @param offset defines the offset in the data source
  1097. * @param result defines the target vector
  1098. */
  1099. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1100. /**
  1101. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1102. * @param value1 defines 1st point of control
  1103. * @param value2 defines 2nd point of control
  1104. * @param value3 defines 3rd point of control
  1105. * @param value4 defines 4th point of control
  1106. * @param amount defines the interpolation factor
  1107. * @returns a new Vector2
  1108. */
  1109. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1110. /**
  1111. * 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".
  1112. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1113. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1114. * @param value defines the value to clamp
  1115. * @param min defines the lower limit
  1116. * @param max defines the upper limit
  1117. * @returns a new Vector2
  1118. */
  1119. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1120. /**
  1121. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1122. * @param value1 defines the 1st control point
  1123. * @param tangent1 defines the outgoing tangent
  1124. * @param value2 defines the 2nd control point
  1125. * @param tangent2 defines the incoming tangent
  1126. * @param amount defines the interpolation factor
  1127. * @returns a new Vector2
  1128. */
  1129. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1130. /**
  1131. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1132. * @param start defines the start vector
  1133. * @param end defines the end vector
  1134. * @param amount defines the interpolation factor
  1135. * @returns a new Vector2
  1136. */
  1137. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1138. /**
  1139. * Gets the dot product of the vector "left" and the vector "right"
  1140. * @param left defines first vector
  1141. * @param right defines second vector
  1142. * @returns the dot product (float)
  1143. */
  1144. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1145. /**
  1146. * Returns a new Vector2 equal to the normalized given vector
  1147. * @param vector defines the vector to normalize
  1148. * @returns a new Vector2
  1149. */
  1150. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1151. /**
  1152. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1153. * @param left defines 1st vector
  1154. * @param right defines 2nd vector
  1155. * @returns a new Vector2
  1156. */
  1157. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1158. /**
  1159. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1160. * @param left defines 1st vector
  1161. * @param right defines 2nd vector
  1162. * @returns a new Vector2
  1163. */
  1164. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1165. /**
  1166. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1167. * @param vector defines the vector to transform
  1168. * @param transformation defines the matrix to apply
  1169. * @returns a new Vector2
  1170. */
  1171. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1172. /**
  1173. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1174. * @param vector defines the vector to transform
  1175. * @param transformation defines the matrix to apply
  1176. * @param result defines the target vector
  1177. */
  1178. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1179. /**
  1180. * Determines if a given vector is included in a triangle
  1181. * @param p defines the vector to test
  1182. * @param p0 defines 1st triangle point
  1183. * @param p1 defines 2nd triangle point
  1184. * @param p2 defines 3rd triangle point
  1185. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1186. */
  1187. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1188. /**
  1189. * Gets the distance between the vectors "value1" and "value2"
  1190. * @param value1 defines first vector
  1191. * @param value2 defines second vector
  1192. * @returns the distance between vectors
  1193. */
  1194. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1195. /**
  1196. * Returns the squared distance between the vectors "value1" and "value2"
  1197. * @param value1 defines first vector
  1198. * @param value2 defines second vector
  1199. * @returns the squared distance between vectors
  1200. */
  1201. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1202. /**
  1203. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1204. * @param value1 defines first vector
  1205. * @param value2 defines second vector
  1206. * @returns a new Vector2
  1207. */
  1208. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1209. /**
  1210. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1211. * @param p defines the middle point
  1212. * @param segA defines one point of the segment
  1213. * @param segB defines the other point of the segment
  1214. * @returns the shortest distance
  1215. */
  1216. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1217. }
  1218. /**
  1219. * Classed used to store (x,y,z) vector representation
  1220. * A Vector3 is the main object used in 3D geometry
  1221. * It can represent etiher the coordinates of a point the space, either a direction
  1222. * Reminder: js uses a left handed forward facing system
  1223. */
  1224. export class Vector3 {
  1225. /**
  1226. * Defines the first coordinates (on X axis)
  1227. */
  1228. x: number;
  1229. /**
  1230. * Defines the second coordinates (on Y axis)
  1231. */
  1232. y: number;
  1233. /**
  1234. * Defines the third coordinates (on Z axis)
  1235. */
  1236. z: number;
  1237. private static _UpReadOnly;
  1238. private static _ZeroReadOnly;
  1239. /**
  1240. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1241. * @param x defines the first coordinates (on X axis)
  1242. * @param y defines the second coordinates (on Y axis)
  1243. * @param z defines the third coordinates (on Z axis)
  1244. */
  1245. constructor(
  1246. /**
  1247. * Defines the first coordinates (on X axis)
  1248. */
  1249. x?: number,
  1250. /**
  1251. * Defines the second coordinates (on Y axis)
  1252. */
  1253. y?: number,
  1254. /**
  1255. * Defines the third coordinates (on Z axis)
  1256. */
  1257. z?: number);
  1258. /**
  1259. * Creates a string representation of the Vector3
  1260. * @returns a string with the Vector3 coordinates.
  1261. */
  1262. toString(): string;
  1263. /**
  1264. * Gets the class name
  1265. * @returns the string "Vector3"
  1266. */
  1267. getClassName(): string;
  1268. /**
  1269. * Creates the Vector3 hash code
  1270. * @returns a number which tends to be unique between Vector3 instances
  1271. */
  1272. getHashCode(): number;
  1273. /**
  1274. * Creates an array containing three elements : the coordinates of the Vector3
  1275. * @returns a new array of numbers
  1276. */
  1277. asArray(): number[];
  1278. /**
  1279. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1280. * @param array defines the destination array
  1281. * @param index defines the offset in the destination array
  1282. * @returns the current Vector3
  1283. */
  1284. toArray(array: FloatArray, index?: number): Vector3;
  1285. /**
  1286. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1287. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1288. */
  1289. toQuaternion(): Quaternion;
  1290. /**
  1291. * Adds the given vector to the current Vector3
  1292. * @param otherVector defines the second operand
  1293. * @returns the current updated Vector3
  1294. */
  1295. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1296. /**
  1297. * Adds the given coordinates to the current Vector3
  1298. * @param x defines the x coordinate of the operand
  1299. * @param y defines the y coordinate of the operand
  1300. * @param z defines the z coordinate of the operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1304. /**
  1305. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Subtract the given vector from the current Vector3
  1319. * @param otherVector defines the second operand
  1320. * @returns the current updated Vector3
  1321. */
  1322. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1323. /**
  1324. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1325. * @param otherVector defines the second operand
  1326. * @returns the resulting Vector3
  1327. */
  1328. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1329. /**
  1330. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1331. * @param otherVector defines the second operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1336. /**
  1337. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1338. * @param x defines the x coordinate of the operand
  1339. * @param y defines the y coordinate of the operand
  1340. * @param z defines the z coordinate of the operand
  1341. * @returns the resulting Vector3
  1342. */
  1343. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1344. /**
  1345. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1346. * @param x defines the x coordinate of the operand
  1347. * @param y defines the y coordinate of the operand
  1348. * @param z defines the z coordinate of the operand
  1349. * @param result defines the Vector3 object where to store the result
  1350. * @returns the current Vector3
  1351. */
  1352. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1353. /**
  1354. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1355. * @returns a new Vector3
  1356. */
  1357. negate(): Vector3;
  1358. /**
  1359. * Multiplies the Vector3 coordinates by the float "scale"
  1360. * @param scale defines the multiplier factor
  1361. * @returns the current updated Vector3
  1362. */
  1363. scaleInPlace(scale: number): Vector3;
  1364. /**
  1365. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1366. * @param scale defines the multiplier factor
  1367. * @returns a new Vector3
  1368. */
  1369. scale(scale: number): Vector3;
  1370. /**
  1371. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1372. * @param scale defines the multiplier factor
  1373. * @param result defines the Vector3 object where to store the result
  1374. * @returns the current Vector3
  1375. */
  1376. scaleToRef(scale: number, result: Vector3): Vector3;
  1377. /**
  1378. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1379. * @param scale defines the scale factor
  1380. * @param result defines the Vector3 object where to store the result
  1381. * @returns the unmodified current Vector3
  1382. */
  1383. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1384. /**
  1385. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1386. * @param otherVector defines the second operand
  1387. * @returns true if both vectors are equals
  1388. */
  1389. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1390. /**
  1391. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1392. * @param otherVector defines the second operand
  1393. * @param epsilon defines the minimal distance to define values as equals
  1394. * @returns true if both vectors are distant less than epsilon
  1395. */
  1396. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1397. /**
  1398. * Returns true if the current Vector3 coordinates equals the given floats
  1399. * @param x defines the x coordinate of the operand
  1400. * @param y defines the y coordinate of the operand
  1401. * @param z defines the z coordinate of the operand
  1402. * @returns true if both vectors are equals
  1403. */
  1404. equalsToFloats(x: number, y: number, z: number): boolean;
  1405. /**
  1406. * Multiplies the current Vector3 coordinates by the given ones
  1407. * @param otherVector defines the second operand
  1408. * @returns the current updated Vector3
  1409. */
  1410. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1411. /**
  1412. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1413. * @param otherVector defines the second operand
  1414. * @returns the new Vector3
  1415. */
  1416. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1417. /**
  1418. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1419. * @param otherVector defines the second operand
  1420. * @param result defines the Vector3 object where to store the result
  1421. * @returns the current Vector3
  1422. */
  1423. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1424. /**
  1425. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1426. * @param x defines the x coordinate of the operand
  1427. * @param y defines the y coordinate of the operand
  1428. * @param z defines the z coordinate of the operand
  1429. * @returns the new Vector3
  1430. */
  1431. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1432. /**
  1433. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1434. * @param otherVector defines the second operand
  1435. * @returns the new Vector3
  1436. */
  1437. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1440. * @param otherVector defines the second operand
  1441. * @param result defines the Vector3 object where to store the result
  1442. * @returns the current Vector3
  1443. */
  1444. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1445. /**
  1446. * Divides the current Vector3 coordinates by the given ones.
  1447. * @param otherVector defines the second operand
  1448. * @returns the current updated Vector3
  1449. */
  1450. divideInPlace(otherVector: Vector3): Vector3;
  1451. /**
  1452. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1453. * @param other defines the second operand
  1454. * @returns the current updated Vector3
  1455. */
  1456. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1457. /**
  1458. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1459. * @param other defines the second operand
  1460. * @returns the current updated Vector3
  1461. */
  1462. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1463. /**
  1464. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1465. * @param x defines the x coordinate of the operand
  1466. * @param y defines the y coordinate of the operand
  1467. * @param z defines the z coordinate of the operand
  1468. * @returns the current updated Vector3
  1469. */
  1470. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1471. /**
  1472. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1473. * @param x defines the x coordinate of the operand
  1474. * @param y defines the y coordinate of the operand
  1475. * @param z defines the z coordinate of the operand
  1476. * @returns the current updated Vector3
  1477. */
  1478. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1479. /**
  1480. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1481. * Check if is non uniform within a certain amount of decimal places to account for this
  1482. * @param epsilon the amount the values can differ
  1483. * @returns if the the vector is non uniform to a certain number of decimal places
  1484. */
  1485. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1486. /**
  1487. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1488. */
  1489. readonly isNonUniform: boolean;
  1490. /**
  1491. * Gets a new Vector3 from current Vector3 floored values
  1492. * @returns a new Vector3
  1493. */
  1494. floor(): Vector3;
  1495. /**
  1496. * Gets a new Vector3 from current Vector3 floored values
  1497. * @returns a new Vector3
  1498. */
  1499. fract(): Vector3;
  1500. /**
  1501. * Gets the length of the Vector3
  1502. * @returns the length of the Vector3
  1503. */
  1504. length(): number;
  1505. /**
  1506. * Gets the squared length of the Vector3
  1507. * @returns squared length of the Vector3
  1508. */
  1509. lengthSquared(): number;
  1510. /**
  1511. * Normalize the current Vector3.
  1512. * Please note that this is an in place operation.
  1513. * @returns the current updated Vector3
  1514. */
  1515. normalize(): Vector3;
  1516. /**
  1517. * Reorders the x y z properties of the vector in place
  1518. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1519. * @returns the current updated vector
  1520. */
  1521. reorderInPlace(order: string): this;
  1522. /**
  1523. * Rotates the vector around 0,0,0 by a quaternion
  1524. * @param quaternion the rotation quaternion
  1525. * @param result vector to store the result
  1526. * @returns the resulting vector
  1527. */
  1528. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1529. /**
  1530. * Rotates a vector around a given point
  1531. * @param quaternion the rotation quaternion
  1532. * @param point the point to rotate around
  1533. * @param result vector to store the result
  1534. * @returns the resulting vector
  1535. */
  1536. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1537. /**
  1538. * Normalize the current Vector3 with the given input length.
  1539. * Please note that this is an in place operation.
  1540. * @param len the length of the vector
  1541. * @returns the current updated Vector3
  1542. */
  1543. normalizeFromLength(len: number): Vector3;
  1544. /**
  1545. * Normalize the current Vector3 to a new vector
  1546. * @returns the new Vector3
  1547. */
  1548. normalizeToNew(): Vector3;
  1549. /**
  1550. * Normalize the current Vector3 to the reference
  1551. * @param reference define the Vector3 to update
  1552. * @returns the updated Vector3
  1553. */
  1554. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1555. /**
  1556. * Creates a new Vector3 copied from the current Vector3
  1557. * @returns the new Vector3
  1558. */
  1559. clone(): Vector3;
  1560. /**
  1561. * Copies the given vector coordinates to the current Vector3 ones
  1562. * @param source defines the source Vector3
  1563. * @returns the current updated Vector3
  1564. */
  1565. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1566. /**
  1567. * Copies the given floats to the current Vector3 coordinates
  1568. * @param x defines the x coordinate of the operand
  1569. * @param y defines the y coordinate of the operand
  1570. * @param z defines the z coordinate of the operand
  1571. * @returns the current updated Vector3
  1572. */
  1573. copyFromFloats(x: number, y: number, z: number): Vector3;
  1574. /**
  1575. * Copies the given floats to the current Vector3 coordinates
  1576. * @param x defines the x coordinate of the operand
  1577. * @param y defines the y coordinate of the operand
  1578. * @param z defines the z coordinate of the operand
  1579. * @returns the current updated Vector3
  1580. */
  1581. set(x: number, y: number, z: number): Vector3;
  1582. /**
  1583. * Copies the given float to the current Vector3 coordinates
  1584. * @param v defines the x, y and z coordinates of the operand
  1585. * @returns the current updated Vector3
  1586. */
  1587. setAll(v: number): Vector3;
  1588. /**
  1589. * Get the clip factor between two vectors
  1590. * @param vector0 defines the first operand
  1591. * @param vector1 defines the second operand
  1592. * @param axis defines the axis to use
  1593. * @param size defines the size along the axis
  1594. * @returns the clip factor
  1595. */
  1596. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1597. /**
  1598. * Get angle between two vectors
  1599. * @param vector0 angle between vector0 and vector1
  1600. * @param vector1 angle between vector0 and vector1
  1601. * @param normal direction of the normal
  1602. * @return the angle between vector0 and vector1
  1603. */
  1604. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1605. /**
  1606. * Returns a new Vector3 set from the index "offset" of the given array
  1607. * @param array defines the source array
  1608. * @param offset defines the offset in the source array
  1609. * @returns the new Vector3
  1610. */
  1611. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1612. /**
  1613. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1614. * This function is deprecated. Use FromArray instead
  1615. * @param array defines the source array
  1616. * @param offset defines the offset in the source array
  1617. * @returns the new Vector3
  1618. */
  1619. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1620. /**
  1621. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1622. * @param array defines the source array
  1623. * @param offset defines the offset in the source array
  1624. * @param result defines the Vector3 where to store the result
  1625. */
  1626. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1627. /**
  1628. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1629. * This function is deprecated. Use FromArrayToRef instead.
  1630. * @param array defines the source array
  1631. * @param offset defines the offset in the source array
  1632. * @param result defines the Vector3 where to store the result
  1633. */
  1634. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1635. /**
  1636. * Sets the given vector "result" with the given floats.
  1637. * @param x defines the x coordinate of the source
  1638. * @param y defines the y coordinate of the source
  1639. * @param z defines the z coordinate of the source
  1640. * @param result defines the Vector3 where to store the result
  1641. */
  1642. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1645. * @returns a new empty Vector3
  1646. */
  1647. static Zero(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1650. * @returns a new unit Vector3
  1651. */
  1652. static One(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1655. * @returns a new up Vector3
  1656. */
  1657. static Up(): Vector3;
  1658. /**
  1659. * Gets a up Vector3 that must not be updated
  1660. */
  1661. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1662. /**
  1663. * Gets a zero Vector3 that must not be updated
  1664. */
  1665. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1666. /**
  1667. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1668. * @returns a new down Vector3
  1669. */
  1670. static Down(): Vector3;
  1671. /**
  1672. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1673. * @returns a new forward Vector3
  1674. */
  1675. static Forward(): Vector3;
  1676. /**
  1677. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1678. * @returns a new forward Vector3
  1679. */
  1680. static Backward(): Vector3;
  1681. /**
  1682. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1683. * @returns a new right Vector3
  1684. */
  1685. static Right(): Vector3;
  1686. /**
  1687. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1688. * @returns a new left Vector3
  1689. */
  1690. static Left(): Vector3;
  1691. /**
  1692. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1693. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1694. * @param vector defines the Vector3 to transform
  1695. * @param transformation defines the transformation matrix
  1696. * @returns the transformed Vector3
  1697. */
  1698. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1699. /**
  1700. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1701. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1702. * @param vector defines the Vector3 to transform
  1703. * @param transformation defines the transformation matrix
  1704. * @param result defines the Vector3 where to store the result
  1705. */
  1706. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1707. /**
  1708. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1709. * This method computes tranformed coordinates only, not transformed direction vectors
  1710. * @param x define the x coordinate of the source vector
  1711. * @param y define the y coordinate of the source vector
  1712. * @param z define the z coordinate of the source vector
  1713. * @param transformation defines the transformation matrix
  1714. * @param result defines the Vector3 where to store the result
  1715. */
  1716. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1717. /**
  1718. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1719. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1720. * @param vector defines the Vector3 to transform
  1721. * @param transformation defines the transformation matrix
  1722. * @returns the new Vector3
  1723. */
  1724. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1725. /**
  1726. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1727. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1728. * @param vector defines the Vector3 to transform
  1729. * @param transformation defines the transformation matrix
  1730. * @param result defines the Vector3 where to store the result
  1731. */
  1732. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1733. /**
  1734. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1735. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1736. * @param x define the x coordinate of the source vector
  1737. * @param y define the y coordinate of the source vector
  1738. * @param z define the z coordinate of the source vector
  1739. * @param transformation defines the transformation matrix
  1740. * @param result defines the Vector3 where to store the result
  1741. */
  1742. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1743. /**
  1744. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1745. * @param value1 defines the first control point
  1746. * @param value2 defines the second control point
  1747. * @param value3 defines the third control point
  1748. * @param value4 defines the fourth control point
  1749. * @param amount defines the amount on the spline to use
  1750. * @returns the new Vector3
  1751. */
  1752. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1753. /**
  1754. * 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"
  1755. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1756. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1757. * @param value defines the current value
  1758. * @param min defines the lower range value
  1759. * @param max defines the upper range value
  1760. * @returns the new Vector3
  1761. */
  1762. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1763. /**
  1764. * 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"
  1765. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1766. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1767. * @param value defines the current value
  1768. * @param min defines the lower range value
  1769. * @param max defines the upper range value
  1770. * @param result defines the Vector3 where to store the result
  1771. */
  1772. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1773. /**
  1774. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1775. * @param value1 defines the first control point
  1776. * @param tangent1 defines the first tangent vector
  1777. * @param value2 defines the second control point
  1778. * @param tangent2 defines the second tangent vector
  1779. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1780. * @returns the new Vector3
  1781. */
  1782. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1783. /**
  1784. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1785. * @param start defines the start value
  1786. * @param end defines the end value
  1787. * @param amount max defines amount between both (between 0 and 1)
  1788. * @returns the new Vector3
  1789. */
  1790. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1793. * @param start defines the start value
  1794. * @param end defines the end value
  1795. * @param amount max defines amount between both (between 0 and 1)
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1799. /**
  1800. * Returns the dot product (float) between the vectors "left" and "right"
  1801. * @param left defines the left operand
  1802. * @param right defines the right operand
  1803. * @returns the dot product
  1804. */
  1805. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1806. /**
  1807. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1808. * The cross product is then orthogonal to both "left" and "right"
  1809. * @param left defines the left operand
  1810. * @param right defines the right operand
  1811. * @returns the cross product
  1812. */
  1813. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1814. /**
  1815. * Sets the given vector "result" with the cross product of "left" and "right"
  1816. * The cross product is then orthogonal to both "left" and "right"
  1817. * @param left defines the left operand
  1818. * @param right defines the right operand
  1819. * @param result defines the Vector3 where to store the result
  1820. */
  1821. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1822. /**
  1823. * Returns a new Vector3 as the normalization of the given vector
  1824. * @param vector defines the Vector3 to normalize
  1825. * @returns the new Vector3
  1826. */
  1827. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1828. /**
  1829. * Sets the given vector "result" with the normalization of the given first vector
  1830. * @param vector defines the Vector3 to normalize
  1831. * @param result defines the Vector3 where to store the result
  1832. */
  1833. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1834. /**
  1835. * Project a Vector3 onto screen space
  1836. * @param vector defines the Vector3 to project
  1837. * @param world defines the world matrix to use
  1838. * @param transform defines the transform (view x projection) matrix to use
  1839. * @param viewport defines the screen viewport to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1843. /** @hidden */
  1844. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1845. /**
  1846. * Unproject from screen space to object space
  1847. * @param source defines the screen space Vector3 to use
  1848. * @param viewportWidth defines the current width of the viewport
  1849. * @param viewportHeight defines the current height of the viewport
  1850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1851. * @param transform defines the transform (view x projection) matrix to use
  1852. * @returns the new Vector3
  1853. */
  1854. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param source defines the screen space Vector3 to use
  1858. * @param viewportWidth defines the current width of the viewport
  1859. * @param viewportHeight defines the current height of the viewport
  1860. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1861. * @param view defines the view matrix to use
  1862. * @param projection defines the projection matrix to use
  1863. * @returns the new Vector3
  1864. */
  1865. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1866. /**
  1867. * Unproject from screen space to object space
  1868. * @param source defines the screen space Vector3 to use
  1869. * @param viewportWidth defines the current width of the viewport
  1870. * @param viewportHeight defines the current height of the viewport
  1871. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1872. * @param view defines the view matrix to use
  1873. * @param projection defines the projection matrix to use
  1874. * @param result defines the Vector3 where to store the result
  1875. */
  1876. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1877. /**
  1878. * Unproject from screen space to object space
  1879. * @param sourceX defines the screen space x coordinate to use
  1880. * @param sourceY defines the screen space y coordinate to use
  1881. * @param sourceZ defines the screen space z coordinate to use
  1882. * @param viewportWidth defines the current width of the viewport
  1883. * @param viewportHeight defines the current height of the viewport
  1884. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1885. * @param view defines the view matrix to use
  1886. * @param projection defines the projection matrix to use
  1887. * @param result defines the Vector3 where to store the result
  1888. */
  1889. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1890. /**
  1891. * Gets the minimal coordinate values between two Vector3
  1892. * @param left defines the first operand
  1893. * @param right defines the second operand
  1894. * @returns the new Vector3
  1895. */
  1896. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1897. /**
  1898. * Gets the maximal coordinate values between two Vector3
  1899. * @param left defines the first operand
  1900. * @param right defines the second operand
  1901. * @returns the new Vector3
  1902. */
  1903. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1904. /**
  1905. * Returns the distance between the vectors "value1" and "value2"
  1906. * @param value1 defines the first operand
  1907. * @param value2 defines the second operand
  1908. * @returns the distance
  1909. */
  1910. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1911. /**
  1912. * Returns the squared distance between the vectors "value1" and "value2"
  1913. * @param value1 defines the first operand
  1914. * @param value2 defines the second operand
  1915. * @returns the squared distance
  1916. */
  1917. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1918. /**
  1919. * Returns a new Vector3 located at the center between "value1" and "value2"
  1920. * @param value1 defines the first operand
  1921. * @param value2 defines the second operand
  1922. * @returns the new Vector3
  1923. */
  1924. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1925. /**
  1926. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1927. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1928. * to something in order to rotate it from its local system to the given target system
  1929. * Note: axis1, axis2 and axis3 are normalized during this operation
  1930. * @param axis1 defines the first axis
  1931. * @param axis2 defines the second axis
  1932. * @param axis3 defines the third axis
  1933. * @returns a new Vector3
  1934. */
  1935. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1936. /**
  1937. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1938. * @param axis1 defines the first axis
  1939. * @param axis2 defines the second axis
  1940. * @param axis3 defines the third axis
  1941. * @param ref defines the Vector3 where to store the result
  1942. */
  1943. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1944. }
  1945. /**
  1946. * Vector4 class created for EulerAngle class conversion to Quaternion
  1947. */
  1948. export class Vector4 {
  1949. /** x value of the vector */
  1950. x: number;
  1951. /** y value of the vector */
  1952. y: number;
  1953. /** z value of the vector */
  1954. z: number;
  1955. /** w value of the vector */
  1956. w: number;
  1957. /**
  1958. * Creates a Vector4 object from the given floats.
  1959. * @param x x value of the vector
  1960. * @param y y value of the vector
  1961. * @param z z value of the vector
  1962. * @param w w value of the vector
  1963. */
  1964. constructor(
  1965. /** x value of the vector */
  1966. x: number,
  1967. /** y value of the vector */
  1968. y: number,
  1969. /** z value of the vector */
  1970. z: number,
  1971. /** w value of the vector */
  1972. w: number);
  1973. /**
  1974. * Returns the string with the Vector4 coordinates.
  1975. * @returns a string containing all the vector values
  1976. */
  1977. toString(): string;
  1978. /**
  1979. * Returns the string "Vector4".
  1980. * @returns "Vector4"
  1981. */
  1982. getClassName(): string;
  1983. /**
  1984. * Returns the Vector4 hash code.
  1985. * @returns a unique hash code
  1986. */
  1987. getHashCode(): number;
  1988. /**
  1989. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1990. * @returns the resulting array
  1991. */
  1992. asArray(): number[];
  1993. /**
  1994. * Populates the given array from the given index with the Vector4 coordinates.
  1995. * @param array array to populate
  1996. * @param index index of the array to start at (default: 0)
  1997. * @returns the Vector4.
  1998. */
  1999. toArray(array: FloatArray, index?: number): Vector4;
  2000. /**
  2001. * Adds the given vector to the current Vector4.
  2002. * @param otherVector the vector to add
  2003. * @returns the updated Vector4.
  2004. */
  2005. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2006. /**
  2007. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2008. * @param otherVector the vector to add
  2009. * @returns the resulting vector
  2010. */
  2011. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2012. /**
  2013. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2014. * @param otherVector the vector to add
  2015. * @param result the vector to store the result
  2016. * @returns the current Vector4.
  2017. */
  2018. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2019. /**
  2020. * Subtract in place the given vector from the current Vector4.
  2021. * @param otherVector the vector to subtract
  2022. * @returns the updated Vector4.
  2023. */
  2024. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2025. /**
  2026. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2027. * @param otherVector the vector to add
  2028. * @returns the new vector with the result
  2029. */
  2030. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2031. /**
  2032. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2033. * @param otherVector the vector to subtract
  2034. * @param result the vector to store the result
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2040. */
  2041. /**
  2042. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2043. * @param x value to subtract
  2044. * @param y value to subtract
  2045. * @param z value to subtract
  2046. * @param w value to subtract
  2047. * @returns new vector containing the result
  2048. */
  2049. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2050. /**
  2051. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2052. * @param x value to subtract
  2053. * @param y value to subtract
  2054. * @param z value to subtract
  2055. * @param w value to subtract
  2056. * @param result the vector to store the result in
  2057. * @returns the current Vector4.
  2058. */
  2059. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2060. /**
  2061. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2062. * @returns a new vector with the negated values
  2063. */
  2064. negate(): Vector4;
  2065. /**
  2066. * Multiplies the current Vector4 coordinates by scale (float).
  2067. * @param scale the number to scale with
  2068. * @returns the updated Vector4.
  2069. */
  2070. scaleInPlace(scale: number): Vector4;
  2071. /**
  2072. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2073. * @param scale the number to scale with
  2074. * @returns a new vector with the result
  2075. */
  2076. scale(scale: number): Vector4;
  2077. /**
  2078. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2079. * @param scale the number to scale with
  2080. * @param result a vector to store the result in
  2081. * @returns the current Vector4.
  2082. */
  2083. scaleToRef(scale: number, result: Vector4): Vector4;
  2084. /**
  2085. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2086. * @param scale defines the scale factor
  2087. * @param result defines the Vector4 object where to store the result
  2088. * @returns the unmodified current Vector4
  2089. */
  2090. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2091. /**
  2092. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2093. * @param otherVector the vector to compare against
  2094. * @returns true if they are equal
  2095. */
  2096. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2097. /**
  2098. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2099. * @param otherVector vector to compare against
  2100. * @param epsilon (Default: very small number)
  2101. * @returns true if they are equal
  2102. */
  2103. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2104. /**
  2105. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2106. * @param x x value to compare against
  2107. * @param y y value to compare against
  2108. * @param z z value to compare against
  2109. * @param w w value to compare against
  2110. * @returns true if equal
  2111. */
  2112. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2113. /**
  2114. * Multiplies in place the current Vector4 by the given one.
  2115. * @param otherVector vector to multiple with
  2116. * @returns the updated Vector4.
  2117. */
  2118. multiplyInPlace(otherVector: Vector4): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2121. * @param otherVector vector to multiple with
  2122. * @returns resulting new vector
  2123. */
  2124. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2127. * @param otherVector vector to multiple with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2134. * @param x x value multiply with
  2135. * @param y y value multiply with
  2136. * @param z z value multiply with
  2137. * @param w w value multiply with
  2138. * @returns resulting new vector
  2139. */
  2140. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2141. /**
  2142. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2143. * @param otherVector vector to devide with
  2144. * @returns resulting new vector
  2145. */
  2146. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2147. /**
  2148. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2149. * @param otherVector vector to devide with
  2150. * @param result vector to store the result
  2151. * @returns the current Vector4.
  2152. */
  2153. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2154. /**
  2155. * Divides the current Vector3 coordinates by the given ones.
  2156. * @param otherVector vector to devide with
  2157. * @returns the updated Vector3.
  2158. */
  2159. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2160. /**
  2161. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2162. * @param other defines the second operand
  2163. * @returns the current updated Vector4
  2164. */
  2165. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2166. /**
  2167. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2168. * @param other defines the second operand
  2169. * @returns the current updated Vector4
  2170. */
  2171. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2172. /**
  2173. * Gets a new Vector4 from current Vector4 floored values
  2174. * @returns a new Vector4
  2175. */
  2176. floor(): Vector4;
  2177. /**
  2178. * Gets a new Vector4 from current Vector3 floored values
  2179. * @returns a new Vector4
  2180. */
  2181. fract(): Vector4;
  2182. /**
  2183. * Returns the Vector4 length (float).
  2184. * @returns the length
  2185. */
  2186. length(): number;
  2187. /**
  2188. * Returns the Vector4 squared length (float).
  2189. * @returns the length squared
  2190. */
  2191. lengthSquared(): number;
  2192. /**
  2193. * Normalizes in place the Vector4.
  2194. * @returns the updated Vector4.
  2195. */
  2196. normalize(): Vector4;
  2197. /**
  2198. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2199. * @returns this converted to a new vector3
  2200. */
  2201. toVector3(): Vector3;
  2202. /**
  2203. * Returns a new Vector4 copied from the current one.
  2204. * @returns the new cloned vector
  2205. */
  2206. clone(): Vector4;
  2207. /**
  2208. * Updates the current Vector4 with the given one coordinates.
  2209. * @param source the source vector to copy from
  2210. * @returns the updated Vector4.
  2211. */
  2212. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2213. /**
  2214. * Updates the current Vector4 coordinates with the given floats.
  2215. * @param x float to copy from
  2216. * @param y float to copy from
  2217. * @param z float to copy from
  2218. * @param w float to copy from
  2219. * @returns the updated Vector4.
  2220. */
  2221. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2222. /**
  2223. * Updates the current Vector4 coordinates with the given floats.
  2224. * @param x float to set from
  2225. * @param y float to set from
  2226. * @param z float to set from
  2227. * @param w float to set from
  2228. * @returns the updated Vector4.
  2229. */
  2230. set(x: number, y: number, z: number, w: number): Vector4;
  2231. /**
  2232. * Copies the given float to the current Vector3 coordinates
  2233. * @param v defines the x, y, z and w coordinates of the operand
  2234. * @returns the current updated Vector3
  2235. */
  2236. setAll(v: number): Vector4;
  2237. /**
  2238. * Returns a new Vector4 set from the starting index of the given array.
  2239. * @param array the array to pull values from
  2240. * @param offset the offset into the array to start at
  2241. * @returns the new vector
  2242. */
  2243. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2244. /**
  2245. * Updates the given vector "result" from the starting index of the given array.
  2246. * @param array the array to pull values from
  2247. * @param offset the offset into the array to start at
  2248. * @param result the vector to store the result in
  2249. */
  2250. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2251. /**
  2252. * Updates the given vector "result" from the starting index of the given Float32Array.
  2253. * @param array the array to pull values from
  2254. * @param offset the offset into the array to start at
  2255. * @param result the vector to store the result in
  2256. */
  2257. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2258. /**
  2259. * Updates the given vector "result" coordinates from the given floats.
  2260. * @param x float to set from
  2261. * @param y float to set from
  2262. * @param z float to set from
  2263. * @param w float to set from
  2264. * @param result the vector to the floats in
  2265. */
  2266. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2267. /**
  2268. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2269. * @returns the new vector
  2270. */
  2271. static Zero(): Vector4;
  2272. /**
  2273. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2274. * @returns the new vector
  2275. */
  2276. static One(): Vector4;
  2277. /**
  2278. * Returns a new normalized Vector4 from the given one.
  2279. * @param vector the vector to normalize
  2280. * @returns the vector
  2281. */
  2282. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2283. /**
  2284. * Updates the given vector "result" from the normalization of the given one.
  2285. * @param vector the vector to normalize
  2286. * @param result the vector to store the result in
  2287. */
  2288. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2289. /**
  2290. * Returns a vector with the minimum values from the left and right vectors
  2291. * @param left left vector to minimize
  2292. * @param right right vector to minimize
  2293. * @returns a new vector with the minimum of the left and right vector values
  2294. */
  2295. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2296. /**
  2297. * Returns a vector with the maximum values from the left and right vectors
  2298. * @param left left vector to maximize
  2299. * @param right right vector to maximize
  2300. * @returns a new vector with the maximum of the left and right vector values
  2301. */
  2302. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2303. /**
  2304. * Returns the distance (float) between the vectors "value1" and "value2".
  2305. * @param value1 value to calulate the distance between
  2306. * @param value2 value to calulate the distance between
  2307. * @return the distance between the two vectors
  2308. */
  2309. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2310. /**
  2311. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2312. * @param value1 value to calulate the distance between
  2313. * @param value2 value to calulate the distance between
  2314. * @return the distance between the two vectors squared
  2315. */
  2316. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2317. /**
  2318. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2319. * @param value1 value to calulate the center between
  2320. * @param value2 value to calulate the center between
  2321. * @return the center between the two vectors
  2322. */
  2323. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2324. /**
  2325. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2326. * This methods computes transformed normalized direction vectors only.
  2327. * @param vector the vector to transform
  2328. * @param transformation the transformation matrix to apply
  2329. * @returns the new vector
  2330. */
  2331. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2332. /**
  2333. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2334. * This methods computes transformed normalized direction vectors only.
  2335. * @param vector the vector to transform
  2336. * @param transformation the transformation matrix to apply
  2337. * @param result the vector to store the result in
  2338. */
  2339. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2340. /**
  2341. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2342. * This methods computes transformed normalized direction vectors only.
  2343. * @param x value to transform
  2344. * @param y value to transform
  2345. * @param z value to transform
  2346. * @param w value to transform
  2347. * @param transformation the transformation matrix to apply
  2348. * @param result the vector to store the results in
  2349. */
  2350. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2351. /**
  2352. * Creates a new Vector4 from a Vector3
  2353. * @param source defines the source data
  2354. * @param w defines the 4th component (default is 0)
  2355. * @returns a new Vector4
  2356. */
  2357. static FromVector3(source: Vector3, w?: number): Vector4;
  2358. }
  2359. /**
  2360. * Interface for the size containing width and height
  2361. */
  2362. export interface ISize {
  2363. /**
  2364. * Width
  2365. */
  2366. width: number;
  2367. /**
  2368. * Heighht
  2369. */
  2370. height: number;
  2371. }
  2372. /**
  2373. * Size containing widht and height
  2374. */
  2375. export class Size implements ISize {
  2376. /**
  2377. * Width
  2378. */
  2379. width: number;
  2380. /**
  2381. * Height
  2382. */
  2383. height: number;
  2384. /**
  2385. * Creates a Size object from the given width and height (floats).
  2386. * @param width width of the new size
  2387. * @param height height of the new size
  2388. */
  2389. constructor(width: number, height: number);
  2390. /**
  2391. * Returns a string with the Size width and height
  2392. * @returns a string with the Size width and height
  2393. */
  2394. toString(): string;
  2395. /**
  2396. * "Size"
  2397. * @returns the string "Size"
  2398. */
  2399. getClassName(): string;
  2400. /**
  2401. * Returns the Size hash code.
  2402. * @returns a hash code for a unique width and height
  2403. */
  2404. getHashCode(): number;
  2405. /**
  2406. * Updates the current size from the given one.
  2407. * @param src the given size
  2408. */
  2409. copyFrom(src: Size): void;
  2410. /**
  2411. * Updates in place the current Size from the given floats.
  2412. * @param width width of the new size
  2413. * @param height height of the new size
  2414. * @returns the updated Size.
  2415. */
  2416. copyFromFloats(width: number, height: number): Size;
  2417. /**
  2418. * Updates in place the current Size from the given floats.
  2419. * @param width width to set
  2420. * @param height height to set
  2421. * @returns the updated Size.
  2422. */
  2423. set(width: number, height: number): Size;
  2424. /**
  2425. * Multiplies the width and height by numbers
  2426. * @param w factor to multiple the width by
  2427. * @param h factor to multiple the height by
  2428. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2429. */
  2430. multiplyByFloats(w: number, h: number): Size;
  2431. /**
  2432. * Clones the size
  2433. * @returns a new Size copied from the given one.
  2434. */
  2435. clone(): Size;
  2436. /**
  2437. * True if the current Size and the given one width and height are strictly equal.
  2438. * @param other the other size to compare against
  2439. * @returns True if the current Size and the given one width and height are strictly equal.
  2440. */
  2441. equals(other: Size): boolean;
  2442. /**
  2443. * The surface of the Size : width * height (float).
  2444. */
  2445. readonly surface: number;
  2446. /**
  2447. * Create a new size of zero
  2448. * @returns a new Size set to (0.0, 0.0)
  2449. */
  2450. static Zero(): Size;
  2451. /**
  2452. * Sums the width and height of two sizes
  2453. * @param otherSize size to add to this size
  2454. * @returns a new Size set as the addition result of the current Size and the given one.
  2455. */
  2456. add(otherSize: Size): Size;
  2457. /**
  2458. * Subtracts the width and height of two
  2459. * @param otherSize size to subtract to this size
  2460. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2461. */
  2462. subtract(otherSize: Size): Size;
  2463. /**
  2464. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2465. * @param start starting size to lerp between
  2466. * @param end end size to lerp between
  2467. * @param amount amount to lerp between the start and end values
  2468. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2469. */
  2470. static Lerp(start: Size, end: Size, amount: number): Size;
  2471. }
  2472. /**
  2473. * Class used to store quaternion data
  2474. * @see https://en.wikipedia.org/wiki/Quaternion
  2475. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2476. */
  2477. export class Quaternion {
  2478. /** defines the first component (0 by default) */
  2479. x: number;
  2480. /** defines the second component (0 by default) */
  2481. y: number;
  2482. /** defines the third component (0 by default) */
  2483. z: number;
  2484. /** defines the fourth component (1.0 by default) */
  2485. w: number;
  2486. /**
  2487. * Creates a new Quaternion from the given floats
  2488. * @param x defines the first component (0 by default)
  2489. * @param y defines the second component (0 by default)
  2490. * @param z defines the third component (0 by default)
  2491. * @param w defines the fourth component (1.0 by default)
  2492. */
  2493. constructor(
  2494. /** defines the first component (0 by default) */
  2495. x?: number,
  2496. /** defines the second component (0 by default) */
  2497. y?: number,
  2498. /** defines the third component (0 by default) */
  2499. z?: number,
  2500. /** defines the fourth component (1.0 by default) */
  2501. w?: number);
  2502. /**
  2503. * Gets a string representation for the current quaternion
  2504. * @returns a string with the Quaternion coordinates
  2505. */
  2506. toString(): string;
  2507. /**
  2508. * Gets the class name of the quaternion
  2509. * @returns the string "Quaternion"
  2510. */
  2511. getClassName(): string;
  2512. /**
  2513. * Gets a hash code for this quaternion
  2514. * @returns the quaternion hash code
  2515. */
  2516. getHashCode(): number;
  2517. /**
  2518. * Copy the quaternion to an array
  2519. * @returns a new array populated with 4 elements from the quaternion coordinates
  2520. */
  2521. asArray(): number[];
  2522. /**
  2523. * Check if two quaternions are equals
  2524. * @param otherQuaternion defines the second operand
  2525. * @return true if the current quaternion and the given one coordinates are strictly equals
  2526. */
  2527. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2528. /**
  2529. * Clone the current quaternion
  2530. * @returns a new quaternion copied from the current one
  2531. */
  2532. clone(): Quaternion;
  2533. /**
  2534. * Copy a quaternion to the current one
  2535. * @param other defines the other quaternion
  2536. * @returns the updated current quaternion
  2537. */
  2538. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2539. /**
  2540. * Updates the current quaternion with the given float coordinates
  2541. * @param x defines the x coordinate
  2542. * @param y defines the y coordinate
  2543. * @param z defines the z coordinate
  2544. * @param w defines the w coordinate
  2545. * @returns the updated current quaternion
  2546. */
  2547. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2548. /**
  2549. * Updates the current quaternion from the given float coordinates
  2550. * @param x defines the x coordinate
  2551. * @param y defines the y coordinate
  2552. * @param z defines the z coordinate
  2553. * @param w defines the w coordinate
  2554. * @returns the updated current quaternion
  2555. */
  2556. set(x: number, y: number, z: number, w: number): Quaternion;
  2557. /**
  2558. * Adds two quaternions
  2559. * @param other defines the second operand
  2560. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2561. */
  2562. add(other: DeepImmutable<Quaternion>): Quaternion;
  2563. /**
  2564. * Add a quaternion to the current one
  2565. * @param other defines the quaternion to add
  2566. * @returns the current quaternion
  2567. */
  2568. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2569. /**
  2570. * Subtract two quaternions
  2571. * @param other defines the second operand
  2572. * @returns a new quaternion as the subtraction result of the given one from the current one
  2573. */
  2574. subtract(other: Quaternion): Quaternion;
  2575. /**
  2576. * Multiplies the current quaternion by a scale factor
  2577. * @param value defines the scale factor
  2578. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2579. */
  2580. scale(value: number): Quaternion;
  2581. /**
  2582. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2583. * @param scale defines the scale factor
  2584. * @param result defines the Quaternion object where to store the result
  2585. * @returns the unmodified current quaternion
  2586. */
  2587. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2588. /**
  2589. * Multiplies in place the current quaternion by a scale factor
  2590. * @param value defines the scale factor
  2591. * @returns the current modified quaternion
  2592. */
  2593. scaleInPlace(value: number): Quaternion;
  2594. /**
  2595. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2596. * @param scale defines the scale factor
  2597. * @param result defines the Quaternion object where to store the result
  2598. * @returns the unmodified current quaternion
  2599. */
  2600. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2601. /**
  2602. * Multiplies two quaternions
  2603. * @param q1 defines the second operand
  2604. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2605. */
  2606. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2607. /**
  2608. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2609. * @param q1 defines the second operand
  2610. * @param result defines the target quaternion
  2611. * @returns the current quaternion
  2612. */
  2613. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2614. /**
  2615. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2616. * @param q1 defines the second operand
  2617. * @returns the currentupdated quaternion
  2618. */
  2619. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2620. /**
  2621. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2622. * @param ref defines the target quaternion
  2623. * @returns the current quaternion
  2624. */
  2625. conjugateToRef(ref: Quaternion): Quaternion;
  2626. /**
  2627. * Conjugates in place (1-q) the current quaternion
  2628. * @returns the current updated quaternion
  2629. */
  2630. conjugateInPlace(): Quaternion;
  2631. /**
  2632. * Conjugates in place (1-q) the current quaternion
  2633. * @returns a new quaternion
  2634. */
  2635. conjugate(): Quaternion;
  2636. /**
  2637. * Gets length of current quaternion
  2638. * @returns the quaternion length (float)
  2639. */
  2640. length(): number;
  2641. /**
  2642. * Normalize in place the current quaternion
  2643. * @returns the current updated quaternion
  2644. */
  2645. normalize(): Quaternion;
  2646. /**
  2647. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2648. * @param order is a reserved parameter and is ignore for now
  2649. * @returns a new Vector3 containing the Euler angles
  2650. */
  2651. toEulerAngles(order?: string): Vector3;
  2652. /**
  2653. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2654. * @param result defines the vector which will be filled with the Euler angles
  2655. * @param order is a reserved parameter and is ignore for now
  2656. * @returns the current unchanged quaternion
  2657. */
  2658. toEulerAnglesToRef(result: Vector3): Quaternion;
  2659. /**
  2660. * Updates the given rotation matrix with the current quaternion values
  2661. * @param result defines the target matrix
  2662. * @returns the current unchanged quaternion
  2663. */
  2664. toRotationMatrix(result: Matrix): Quaternion;
  2665. /**
  2666. * Updates the current quaternion from the given rotation matrix values
  2667. * @param matrix defines the source matrix
  2668. * @returns the current updated quaternion
  2669. */
  2670. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2671. /**
  2672. * Creates a new quaternion from a rotation matrix
  2673. * @param matrix defines the source matrix
  2674. * @returns a new quaternion created from the given rotation matrix values
  2675. */
  2676. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2677. /**
  2678. * Updates the given quaternion with the given rotation matrix values
  2679. * @param matrix defines the source matrix
  2680. * @param result defines the target quaternion
  2681. */
  2682. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2683. /**
  2684. * Returns the dot product (float) between the quaternions "left" and "right"
  2685. * @param left defines the left operand
  2686. * @param right defines the right operand
  2687. * @returns the dot product
  2688. */
  2689. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2690. /**
  2691. * Checks if the two quaternions are close to each other
  2692. * @param quat0 defines the first quaternion to check
  2693. * @param quat1 defines the second quaternion to check
  2694. * @returns true if the two quaternions are close to each other
  2695. */
  2696. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2697. /**
  2698. * Creates an empty quaternion
  2699. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2700. */
  2701. static Zero(): Quaternion;
  2702. /**
  2703. * Inverse a given quaternion
  2704. * @param q defines the source quaternion
  2705. * @returns a new quaternion as the inverted current quaternion
  2706. */
  2707. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2708. /**
  2709. * Inverse a given quaternion
  2710. * @param q defines the source quaternion
  2711. * @param result the quaternion the result will be stored in
  2712. * @returns the result quaternion
  2713. */
  2714. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2715. /**
  2716. * Creates an identity quaternion
  2717. * @returns the identity quaternion
  2718. */
  2719. static Identity(): Quaternion;
  2720. /**
  2721. * Gets a boolean indicating if the given quaternion is identity
  2722. * @param quaternion defines the quaternion to check
  2723. * @returns true if the quaternion is identity
  2724. */
  2725. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2726. /**
  2727. * Creates a quaternion from a rotation around an axis
  2728. * @param axis defines the axis to use
  2729. * @param angle defines the angle to use
  2730. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2731. */
  2732. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2733. /**
  2734. * Creates a rotation around an axis and stores it into the given quaternion
  2735. * @param axis defines the axis to use
  2736. * @param angle defines the angle to use
  2737. * @param result defines the target quaternion
  2738. * @returns the target quaternion
  2739. */
  2740. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2741. /**
  2742. * Creates a new quaternion from data stored into an array
  2743. * @param array defines the data source
  2744. * @param offset defines the offset in the source array where the data starts
  2745. * @returns a new quaternion
  2746. */
  2747. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2748. /**
  2749. * Create a quaternion from Euler rotation angles
  2750. * @param x Pitch
  2751. * @param y Yaw
  2752. * @param z Roll
  2753. * @returns the new Quaternion
  2754. */
  2755. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2756. /**
  2757. * Updates a quaternion from Euler rotation angles
  2758. * @param x Pitch
  2759. * @param y Yaw
  2760. * @param z Roll
  2761. * @param result the quaternion to store the result
  2762. * @returns the updated quaternion
  2763. */
  2764. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2765. /**
  2766. * Create a quaternion from Euler rotation vector
  2767. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2768. * @returns the new Quaternion
  2769. */
  2770. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2771. /**
  2772. * Updates a quaternion from Euler rotation vector
  2773. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2774. * @param result the quaternion to store the result
  2775. * @returns the updated quaternion
  2776. */
  2777. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2778. /**
  2779. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2780. * @param yaw defines the rotation around Y axis
  2781. * @param pitch defines the rotation around X axis
  2782. * @param roll defines the rotation around Z axis
  2783. * @returns the new quaternion
  2784. */
  2785. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2786. /**
  2787. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2788. * @param yaw defines the rotation around Y axis
  2789. * @param pitch defines the rotation around X axis
  2790. * @param roll defines the rotation around Z axis
  2791. * @param result defines the target quaternion
  2792. */
  2793. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2794. /**
  2795. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2796. * @param alpha defines the rotation around first axis
  2797. * @param beta defines the rotation around second axis
  2798. * @param gamma defines the rotation around third axis
  2799. * @returns the new quaternion
  2800. */
  2801. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2802. /**
  2803. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2804. * @param alpha defines the rotation around first axis
  2805. * @param beta defines the rotation around second axis
  2806. * @param gamma defines the rotation around third axis
  2807. * @param result defines the target quaternion
  2808. */
  2809. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2810. /**
  2811. * 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)
  2812. * @param axis1 defines the first axis
  2813. * @param axis2 defines the second axis
  2814. * @param axis3 defines the third axis
  2815. * @returns the new quaternion
  2816. */
  2817. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2818. /**
  2819. * 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
  2820. * @param axis1 defines the first axis
  2821. * @param axis2 defines the second axis
  2822. * @param axis3 defines the third axis
  2823. * @param ref defines the target quaternion
  2824. */
  2825. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2826. /**
  2827. * Interpolates between two quaternions
  2828. * @param left defines first quaternion
  2829. * @param right defines second quaternion
  2830. * @param amount defines the gradient to use
  2831. * @returns the new interpolated quaternion
  2832. */
  2833. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2834. /**
  2835. * Interpolates between two quaternions and stores it into a target quaternion
  2836. * @param left defines first quaternion
  2837. * @param right defines second quaternion
  2838. * @param amount defines the gradient to use
  2839. * @param result defines the target quaternion
  2840. */
  2841. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2842. /**
  2843. * Interpolate between two quaternions using Hermite interpolation
  2844. * @param value1 defines first quaternion
  2845. * @param tangent1 defines the incoming tangent
  2846. * @param value2 defines second quaternion
  2847. * @param tangent2 defines the outgoing tangent
  2848. * @param amount defines the target quaternion
  2849. * @returns the new interpolated quaternion
  2850. */
  2851. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2852. }
  2853. /**
  2854. * Class used to store matrix data (4x4)
  2855. */
  2856. export class Matrix {
  2857. private static _updateFlagSeed;
  2858. private static _identityReadOnly;
  2859. private _isIdentity;
  2860. private _isIdentityDirty;
  2861. private _isIdentity3x2;
  2862. private _isIdentity3x2Dirty;
  2863. /**
  2864. * Gets the update flag of the matrix which is an unique number for the matrix.
  2865. * It will be incremented every time the matrix data change.
  2866. * You can use it to speed the comparison between two versions of the same matrix.
  2867. */
  2868. updateFlag: number;
  2869. private readonly _m;
  2870. /**
  2871. * Gets the internal data of the matrix
  2872. */
  2873. readonly m: DeepImmutable<Float32Array>;
  2874. /** @hidden */
  2875. _markAsUpdated(): void;
  2876. /** @hidden */
  2877. private _updateIdentityStatus;
  2878. /**
  2879. * Creates an empty matrix (filled with zeros)
  2880. */
  2881. constructor();
  2882. /**
  2883. * Check if the current matrix is identity
  2884. * @returns true is the matrix is the identity matrix
  2885. */
  2886. isIdentity(): boolean;
  2887. /**
  2888. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2889. * @returns true is the matrix is the identity matrix
  2890. */
  2891. isIdentityAs3x2(): boolean;
  2892. /**
  2893. * Gets the determinant of the matrix
  2894. * @returns the matrix determinant
  2895. */
  2896. determinant(): number;
  2897. /**
  2898. * Returns the matrix as a Float32Array
  2899. * @returns the matrix underlying array
  2900. */
  2901. toArray(): DeepImmutable<Float32Array>;
  2902. /**
  2903. * Returns the matrix as a Float32Array
  2904. * @returns the matrix underlying array.
  2905. */
  2906. asArray(): DeepImmutable<Float32Array>;
  2907. /**
  2908. * Inverts the current matrix in place
  2909. * @returns the current inverted matrix
  2910. */
  2911. invert(): Matrix;
  2912. /**
  2913. * Sets all the matrix elements to zero
  2914. * @returns the current matrix
  2915. */
  2916. reset(): Matrix;
  2917. /**
  2918. * Adds the current matrix with a second one
  2919. * @param other defines the matrix to add
  2920. * @returns a new matrix as the addition of the current matrix and the given one
  2921. */
  2922. add(other: DeepImmutable<Matrix>): Matrix;
  2923. /**
  2924. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2925. * @param other defines the matrix to add
  2926. * @param result defines the target matrix
  2927. * @returns the current matrix
  2928. */
  2929. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2930. /**
  2931. * Adds in place the given matrix to the current matrix
  2932. * @param other defines the second operand
  2933. * @returns the current updated matrix
  2934. */
  2935. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2936. /**
  2937. * Sets the given matrix to the current inverted Matrix
  2938. * @param other defines the target matrix
  2939. * @returns the unmodified current matrix
  2940. */
  2941. invertToRef(other: Matrix): Matrix;
  2942. /**
  2943. * add a value at the specified position in the current Matrix
  2944. * @param index the index of the value within the matrix. between 0 and 15.
  2945. * @param value the value to be added
  2946. * @returns the current updated matrix
  2947. */
  2948. addAtIndex(index: number, value: number): Matrix;
  2949. /**
  2950. * mutiply the specified position in the current Matrix by a value
  2951. * @param index the index of the value within the matrix. between 0 and 15.
  2952. * @param value the value to be added
  2953. * @returns the current updated matrix
  2954. */
  2955. multiplyAtIndex(index: number, value: number): Matrix;
  2956. /**
  2957. * Inserts the translation vector (using 3 floats) in the current matrix
  2958. * @param x defines the 1st component of the translation
  2959. * @param y defines the 2nd component of the translation
  2960. * @param z defines the 3rd component of the translation
  2961. * @returns the current updated matrix
  2962. */
  2963. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2964. /**
  2965. * Adds the translation vector (using 3 floats) in the current matrix
  2966. * @param x defines the 1st component of the translation
  2967. * @param y defines the 2nd component of the translation
  2968. * @param z defines the 3rd component of the translation
  2969. * @returns the current updated matrix
  2970. */
  2971. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2972. /**
  2973. * Inserts the translation vector in the current matrix
  2974. * @param vector3 defines the translation to insert
  2975. * @returns the current updated matrix
  2976. */
  2977. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2978. /**
  2979. * Gets the translation value of the current matrix
  2980. * @returns a new Vector3 as the extracted translation from the matrix
  2981. */
  2982. getTranslation(): Vector3;
  2983. /**
  2984. * Fill a Vector3 with the extracted translation from the matrix
  2985. * @param result defines the Vector3 where to store the translation
  2986. * @returns the current matrix
  2987. */
  2988. getTranslationToRef(result: Vector3): Matrix;
  2989. /**
  2990. * Remove rotation and scaling part from the matrix
  2991. * @returns the updated matrix
  2992. */
  2993. removeRotationAndScaling(): Matrix;
  2994. /**
  2995. * Multiply two matrices
  2996. * @param other defines the second operand
  2997. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2998. */
  2999. multiply(other: DeepImmutable<Matrix>): Matrix;
  3000. /**
  3001. * Copy the current matrix from the given one
  3002. * @param other defines the source matrix
  3003. * @returns the current updated matrix
  3004. */
  3005. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3006. /**
  3007. * Populates the given array from the starting index with the current matrix values
  3008. * @param array defines the target array
  3009. * @param offset defines the offset in the target array where to start storing values
  3010. * @returns the current matrix
  3011. */
  3012. copyToArray(array: Float32Array, offset?: number): Matrix;
  3013. /**
  3014. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3015. * @param other defines the second operand
  3016. * @param result defines the matrix where to store the multiplication
  3017. * @returns the current matrix
  3018. */
  3019. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3020. /**
  3021. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3022. * @param other defines the second operand
  3023. * @param result defines the array where to store the multiplication
  3024. * @param offset defines the offset in the target array where to start storing values
  3025. * @returns the current matrix
  3026. */
  3027. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3028. /**
  3029. * Check equality between this matrix and a second one
  3030. * @param value defines the second matrix to compare
  3031. * @returns true is the current matrix and the given one values are strictly equal
  3032. */
  3033. equals(value: DeepImmutable<Matrix>): boolean;
  3034. /**
  3035. * Clone the current matrix
  3036. * @returns a new matrix from the current matrix
  3037. */
  3038. clone(): Matrix;
  3039. /**
  3040. * Returns the name of the current matrix class
  3041. * @returns the string "Matrix"
  3042. */
  3043. getClassName(): string;
  3044. /**
  3045. * Gets the hash code of the current matrix
  3046. * @returns the hash code
  3047. */
  3048. getHashCode(): number;
  3049. /**
  3050. * Decomposes the current Matrix into a translation, rotation and scaling components
  3051. * @param scale defines the scale vector3 given as a reference to update
  3052. * @param rotation defines the rotation quaternion given as a reference to update
  3053. * @param translation defines the translation vector3 given as a reference to update
  3054. * @returns true if operation was successful
  3055. */
  3056. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3057. /**
  3058. * Gets specific row of the matrix
  3059. * @param index defines the number of the row to get
  3060. * @returns the index-th row of the current matrix as a new Vector4
  3061. */
  3062. getRow(index: number): Nullable<Vector4>;
  3063. /**
  3064. * Sets the index-th row of the current matrix to the vector4 values
  3065. * @param index defines the number of the row to set
  3066. * @param row defines the target vector4
  3067. * @returns the updated current matrix
  3068. */
  3069. setRow(index: number, row: Vector4): Matrix;
  3070. /**
  3071. * Compute the transpose of the matrix
  3072. * @returns the new transposed matrix
  3073. */
  3074. transpose(): Matrix;
  3075. /**
  3076. * Compute the transpose of the matrix and store it in a given matrix
  3077. * @param result defines the target matrix
  3078. * @returns the current matrix
  3079. */
  3080. transposeToRef(result: Matrix): Matrix;
  3081. /**
  3082. * Sets the index-th row of the current matrix with the given 4 x float values
  3083. * @param index defines the row index
  3084. * @param x defines the x component to set
  3085. * @param y defines the y component to set
  3086. * @param z defines the z component to set
  3087. * @param w defines the w component to set
  3088. * @returns the updated current matrix
  3089. */
  3090. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3091. /**
  3092. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3093. * @param scale defines the scale factor
  3094. * @returns a new matrix
  3095. */
  3096. scale(scale: number): Matrix;
  3097. /**
  3098. * Scale the current matrix values by a factor to a given result matrix
  3099. * @param scale defines the scale factor
  3100. * @param result defines the matrix to store the result
  3101. * @returns the current matrix
  3102. */
  3103. scaleToRef(scale: number, result: Matrix): Matrix;
  3104. /**
  3105. * Scale the current matrix values by a factor and add the result to a given matrix
  3106. * @param scale defines the scale factor
  3107. * @param result defines the Matrix to store the result
  3108. * @returns the current matrix
  3109. */
  3110. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3111. /**
  3112. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3113. * @param ref matrix to store the result
  3114. */
  3115. toNormalMatrix(ref: Matrix): void;
  3116. /**
  3117. * Gets only rotation part of the current matrix
  3118. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3119. */
  3120. getRotationMatrix(): Matrix;
  3121. /**
  3122. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3123. * @param result defines the target matrix to store data to
  3124. * @returns the current matrix
  3125. */
  3126. getRotationMatrixToRef(result: Matrix): Matrix;
  3127. /**
  3128. * Toggles model matrix from being right handed to left handed in place and vice versa
  3129. */
  3130. toggleModelMatrixHandInPlace(): void;
  3131. /**
  3132. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3133. */
  3134. toggleProjectionMatrixHandInPlace(): void;
  3135. /**
  3136. * Creates a matrix from an array
  3137. * @param array defines the source array
  3138. * @param offset defines an offset in the source array
  3139. * @returns a new Matrix set from the starting index of the given array
  3140. */
  3141. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3142. /**
  3143. * Copy the content of an array into a given matrix
  3144. * @param array defines the source array
  3145. * @param offset defines an offset in the source array
  3146. * @param result defines the target matrix
  3147. */
  3148. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3149. /**
  3150. * Stores an array into a matrix after having multiplied each component by a given factor
  3151. * @param array defines the source array
  3152. * @param offset defines the offset in the source array
  3153. * @param scale defines the scaling factor
  3154. * @param result defines the target matrix
  3155. */
  3156. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3157. /**
  3158. * Gets an identity matrix that must not be updated
  3159. */
  3160. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3161. /**
  3162. * Stores a list of values (16) inside a given matrix
  3163. * @param initialM11 defines 1st value of 1st row
  3164. * @param initialM12 defines 2nd value of 1st row
  3165. * @param initialM13 defines 3rd value of 1st row
  3166. * @param initialM14 defines 4th value of 1st row
  3167. * @param initialM21 defines 1st value of 2nd row
  3168. * @param initialM22 defines 2nd value of 2nd row
  3169. * @param initialM23 defines 3rd value of 2nd row
  3170. * @param initialM24 defines 4th value of 2nd row
  3171. * @param initialM31 defines 1st value of 3rd row
  3172. * @param initialM32 defines 2nd value of 3rd row
  3173. * @param initialM33 defines 3rd value of 3rd row
  3174. * @param initialM34 defines 4th value of 3rd row
  3175. * @param initialM41 defines 1st value of 4th row
  3176. * @param initialM42 defines 2nd value of 4th row
  3177. * @param initialM43 defines 3rd value of 4th row
  3178. * @param initialM44 defines 4th value of 4th row
  3179. * @param result defines the target matrix
  3180. */
  3181. 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;
  3182. /**
  3183. * Creates new matrix from a list of values (16)
  3184. * @param initialM11 defines 1st value of 1st row
  3185. * @param initialM12 defines 2nd value of 1st row
  3186. * @param initialM13 defines 3rd value of 1st row
  3187. * @param initialM14 defines 4th value of 1st row
  3188. * @param initialM21 defines 1st value of 2nd row
  3189. * @param initialM22 defines 2nd value of 2nd row
  3190. * @param initialM23 defines 3rd value of 2nd row
  3191. * @param initialM24 defines 4th value of 2nd row
  3192. * @param initialM31 defines 1st value of 3rd row
  3193. * @param initialM32 defines 2nd value of 3rd row
  3194. * @param initialM33 defines 3rd value of 3rd row
  3195. * @param initialM34 defines 4th value of 3rd row
  3196. * @param initialM41 defines 1st value of 4th row
  3197. * @param initialM42 defines 2nd value of 4th row
  3198. * @param initialM43 defines 3rd value of 4th row
  3199. * @param initialM44 defines 4th value of 4th row
  3200. * @returns the new matrix
  3201. */
  3202. 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;
  3203. /**
  3204. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3205. * @param scale defines the scale vector3
  3206. * @param rotation defines the rotation quaternion
  3207. * @param translation defines the translation vector3
  3208. * @returns a new matrix
  3209. */
  3210. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3211. /**
  3212. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3213. * @param scale defines the scale vector3
  3214. * @param rotation defines the rotation quaternion
  3215. * @param translation defines the translation vector3
  3216. * @param result defines the target matrix
  3217. */
  3218. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3219. /**
  3220. * Creates a new identity matrix
  3221. * @returns a new identity matrix
  3222. */
  3223. static Identity(): Matrix;
  3224. /**
  3225. * Creates a new identity matrix and stores the result in a given matrix
  3226. * @param result defines the target matrix
  3227. */
  3228. static IdentityToRef(result: Matrix): void;
  3229. /**
  3230. * Creates a new zero matrix
  3231. * @returns a new zero matrix
  3232. */
  3233. static Zero(): Matrix;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the X axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationX(angle: number): Matrix;
  3240. /**
  3241. * Creates a new matrix as the invert of a given matrix
  3242. * @param source defines the source matrix
  3243. * @returns the new matrix
  3244. */
  3245. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3248. * @param angle defines the angle (in radians) to use
  3249. * @param result defines the target matrix
  3250. */
  3251. static RotationXToRef(angle: number, result: Matrix): void;
  3252. /**
  3253. * Creates a new rotation matrix for "angle" radians around the Y axis
  3254. * @param angle defines the angle (in radians) to use
  3255. * @return the new matrix
  3256. */
  3257. static RotationY(angle: number): Matrix;
  3258. /**
  3259. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3260. * @param angle defines the angle (in radians) to use
  3261. * @param result defines the target matrix
  3262. */
  3263. static RotationYToRef(angle: number, result: Matrix): void;
  3264. /**
  3265. * Creates a new rotation matrix for "angle" radians around the Z axis
  3266. * @param angle defines the angle (in radians) to use
  3267. * @return the new matrix
  3268. */
  3269. static RotationZ(angle: number): Matrix;
  3270. /**
  3271. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3272. * @param angle defines the angle (in radians) to use
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationZToRef(angle: number, result: Matrix): void;
  3276. /**
  3277. * Creates a new rotation matrix for "angle" radians around the given axis
  3278. * @param axis defines the axis to use
  3279. * @param angle defines the angle (in radians) to use
  3280. * @return the new matrix
  3281. */
  3282. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3283. /**
  3284. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3285. * @param axis defines the axis to use
  3286. * @param angle defines the angle (in radians) to use
  3287. * @param result defines the target matrix
  3288. */
  3289. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3290. /**
  3291. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3292. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3293. * @param from defines the vector to align
  3294. * @param to defines the vector to align to
  3295. * @param result defines the target matrix
  3296. */
  3297. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3298. /**
  3299. * Creates a rotation matrix
  3300. * @param yaw defines the yaw angle in radians (Y axis)
  3301. * @param pitch defines the pitch angle in radians (X axis)
  3302. * @param roll defines the roll angle in radians (X axis)
  3303. * @returns the new rotation matrix
  3304. */
  3305. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3306. /**
  3307. * Creates a rotation matrix and stores it in a given matrix
  3308. * @param yaw defines the yaw angle in radians (Y axis)
  3309. * @param pitch defines the pitch angle in radians (X axis)
  3310. * @param roll defines the roll angle in radians (X axis)
  3311. * @param result defines the target matrix
  3312. */
  3313. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3314. /**
  3315. * Creates a scaling matrix
  3316. * @param x defines the scale factor on X axis
  3317. * @param y defines the scale factor on Y axis
  3318. * @param z defines the scale factor on Z axis
  3319. * @returns the new matrix
  3320. */
  3321. static Scaling(x: number, y: number, z: number): Matrix;
  3322. /**
  3323. * Creates a scaling matrix and stores it in a given matrix
  3324. * @param x defines the scale factor on X axis
  3325. * @param y defines the scale factor on Y axis
  3326. * @param z defines the scale factor on Z axis
  3327. * @param result defines the target matrix
  3328. */
  3329. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3330. /**
  3331. * Creates a translation matrix
  3332. * @param x defines the translation on X axis
  3333. * @param y defines the translation on Y axis
  3334. * @param z defines the translationon Z axis
  3335. * @returns the new matrix
  3336. */
  3337. static Translation(x: number, y: number, z: number): Matrix;
  3338. /**
  3339. * Creates a translation matrix and stores it in a given matrix
  3340. * @param x defines the translation on X axis
  3341. * @param y defines the translation on Y axis
  3342. * @param z defines the translationon Z axis
  3343. * @param result defines the target matrix
  3344. */
  3345. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3346. /**
  3347. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3348. * @param startValue defines the start value
  3349. * @param endValue defines the end value
  3350. * @param gradient defines the gradient factor
  3351. * @returns the new matrix
  3352. */
  3353. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3354. /**
  3355. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3356. * @param startValue defines the start value
  3357. * @param endValue defines the end value
  3358. * @param gradient defines the gradient factor
  3359. * @param result defines the Matrix object where to store data
  3360. */
  3361. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3362. /**
  3363. * Builds a new matrix whose values are computed by:
  3364. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3365. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3366. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3367. * @param startValue defines the first matrix
  3368. * @param endValue defines the second matrix
  3369. * @param gradient defines the gradient between the two matrices
  3370. * @returns the new matrix
  3371. */
  3372. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3373. /**
  3374. * Update a matrix to values which are computed by:
  3375. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3376. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3377. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3378. * @param startValue defines the first matrix
  3379. * @param endValue defines the second matrix
  3380. * @param gradient defines the gradient between the two matrices
  3381. * @param result defines the target matrix
  3382. */
  3383. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3384. /**
  3385. * 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"
  3386. * This function works in left handed mode
  3387. * @param eye defines the final position of the entity
  3388. * @param target defines where the entity should look at
  3389. * @param up defines the up vector for the entity
  3390. * @returns the new matrix
  3391. */
  3392. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3393. /**
  3394. * 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".
  3395. * This function works in left handed mode
  3396. * @param eye defines the final position of the entity
  3397. * @param target defines where the entity should look at
  3398. * @param up defines the up vector for the entity
  3399. * @param result defines the target matrix
  3400. */
  3401. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3402. /**
  3403. * 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"
  3404. * This function works in right handed mode
  3405. * @param eye defines the final position of the entity
  3406. * @param target defines where the entity should look at
  3407. * @param up defines the up vector for the entity
  3408. * @returns the new matrix
  3409. */
  3410. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3411. /**
  3412. * 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".
  3413. * This function works in right handed mode
  3414. * @param eye defines the final position of the entity
  3415. * @param target defines where the entity should look at
  3416. * @param up defines the up vector for the entity
  3417. * @param result defines the target matrix
  3418. */
  3419. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3420. /**
  3421. * Create a left-handed orthographic projection matrix
  3422. * @param width defines the viewport width
  3423. * @param height defines the viewport height
  3424. * @param znear defines the near clip plane
  3425. * @param zfar defines the far clip plane
  3426. * @returns a new matrix as a left-handed orthographic projection matrix
  3427. */
  3428. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3429. /**
  3430. * Store a left-handed orthographic projection to a given matrix
  3431. * @param width defines the viewport width
  3432. * @param height defines the viewport height
  3433. * @param znear defines the near clip plane
  3434. * @param zfar defines the far clip plane
  3435. * @param result defines the target matrix
  3436. */
  3437. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3438. /**
  3439. * Create a left-handed orthographic projection matrix
  3440. * @param left defines the viewport left coordinate
  3441. * @param right defines the viewport right coordinate
  3442. * @param bottom defines the viewport bottom coordinate
  3443. * @param top defines the viewport top coordinate
  3444. * @param znear defines the near clip plane
  3445. * @param zfar defines the far clip plane
  3446. * @returns a new matrix as a left-handed orthographic projection matrix
  3447. */
  3448. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3449. /**
  3450. * Stores a left-handed orthographic projection into a given matrix
  3451. * @param left defines the viewport left coordinate
  3452. * @param right defines the viewport right coordinate
  3453. * @param bottom defines the viewport bottom coordinate
  3454. * @param top defines the viewport top coordinate
  3455. * @param znear defines the near clip plane
  3456. * @param zfar defines the far clip plane
  3457. * @param result defines the target matrix
  3458. */
  3459. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3460. /**
  3461. * Creates a right-handed orthographic projection matrix
  3462. * @param left defines the viewport left coordinate
  3463. * @param right defines the viewport right coordinate
  3464. * @param bottom defines the viewport bottom coordinate
  3465. * @param top defines the viewport top coordinate
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @returns a new matrix as a right-handed orthographic projection matrix
  3469. */
  3470. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3471. /**
  3472. * Stores a right-handed orthographic projection into a given matrix
  3473. * @param left defines the viewport left coordinate
  3474. * @param right defines the viewport right coordinate
  3475. * @param bottom defines the viewport bottom coordinate
  3476. * @param top defines the viewport top coordinate
  3477. * @param znear defines the near clip plane
  3478. * @param zfar defines the far clip plane
  3479. * @param result defines the target matrix
  3480. */
  3481. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3482. /**
  3483. * Creates a left-handed perspective projection matrix
  3484. * @param width defines the viewport width
  3485. * @param height defines the viewport height
  3486. * @param znear defines the near clip plane
  3487. * @param zfar defines the far clip plane
  3488. * @returns a new matrix as a left-handed perspective projection matrix
  3489. */
  3490. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3491. /**
  3492. * Creates a left-handed perspective projection matrix
  3493. * @param fov defines the horizontal field of view
  3494. * @param aspect defines the aspect ratio
  3495. * @param znear defines the near clip plane
  3496. * @param zfar defines the far clip plane
  3497. * @returns a new matrix as a left-handed perspective projection matrix
  3498. */
  3499. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3500. /**
  3501. * Stores a left-handed perspective projection into a given matrix
  3502. * @param fov defines the horizontal field of view
  3503. * @param aspect defines the aspect ratio
  3504. * @param znear defines the near clip plane
  3505. * @param zfar defines the far clip plane
  3506. * @param result defines the target matrix
  3507. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3508. */
  3509. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3510. /**
  3511. * Creates a right-handed perspective projection matrix
  3512. * @param fov defines the horizontal field of view
  3513. * @param aspect defines the aspect ratio
  3514. * @param znear defines the near clip plane
  3515. * @param zfar defines the far clip plane
  3516. * @returns a new matrix as a right-handed perspective projection matrix
  3517. */
  3518. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3519. /**
  3520. * Stores a right-handed perspective projection into a given matrix
  3521. * @param fov defines the horizontal field of view
  3522. * @param aspect defines the aspect ratio
  3523. * @param znear defines the near clip plane
  3524. * @param zfar defines the far clip plane
  3525. * @param result defines the target matrix
  3526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3527. */
  3528. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3529. /**
  3530. * Stores a perspective projection for WebVR info a given matrix
  3531. * @param fov defines the field of view
  3532. * @param znear defines the near clip plane
  3533. * @param zfar defines the far clip plane
  3534. * @param result defines the target matrix
  3535. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3536. */
  3537. static PerspectiveFovWebVRToRef(fov: {
  3538. upDegrees: number;
  3539. downDegrees: number;
  3540. leftDegrees: number;
  3541. rightDegrees: number;
  3542. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3543. /**
  3544. * Computes a complete transformation matrix
  3545. * @param viewport defines the viewport to use
  3546. * @param world defines the world matrix
  3547. * @param view defines the view matrix
  3548. * @param projection defines the projection matrix
  3549. * @param zmin defines the near clip plane
  3550. * @param zmax defines the far clip plane
  3551. * @returns the transformation matrix
  3552. */
  3553. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3554. /**
  3555. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3556. * @param matrix defines the matrix to use
  3557. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3558. */
  3559. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3560. /**
  3561. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3562. * @param matrix defines the matrix to use
  3563. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3564. */
  3565. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3566. /**
  3567. * Compute the transpose of a given matrix
  3568. * @param matrix defines the matrix to transpose
  3569. * @returns the new matrix
  3570. */
  3571. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3572. /**
  3573. * Compute the transpose of a matrix and store it in a target matrix
  3574. * @param matrix defines the matrix to transpose
  3575. * @param result defines the target matrix
  3576. */
  3577. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3578. /**
  3579. * Computes a reflection matrix from a plane
  3580. * @param plane defines the reflection plane
  3581. * @returns a new matrix
  3582. */
  3583. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3584. /**
  3585. * Computes a reflection matrix from a plane
  3586. * @param plane defines the reflection plane
  3587. * @param result defines the target matrix
  3588. */
  3589. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3590. /**
  3591. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3592. * @param xaxis defines the value of the 1st axis
  3593. * @param yaxis defines the value of the 2nd axis
  3594. * @param zaxis defines the value of the 3rd axis
  3595. * @param result defines the target matrix
  3596. */
  3597. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3598. /**
  3599. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3600. * @param quat defines the quaternion to use
  3601. * @param result defines the target matrix
  3602. */
  3603. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3604. }
  3605. /**
  3606. * Represens a plane by the equation ax + by + cz + d = 0
  3607. */
  3608. export class Plane {
  3609. /**
  3610. * Normal of the plane (a,b,c)
  3611. */
  3612. normal: Vector3;
  3613. /**
  3614. * d component of the plane
  3615. */
  3616. d: number;
  3617. /**
  3618. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3619. * @param a a component of the plane
  3620. * @param b b component of the plane
  3621. * @param c c component of the plane
  3622. * @param d d component of the plane
  3623. */
  3624. constructor(a: number, b: number, c: number, d: number);
  3625. /**
  3626. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3627. */
  3628. asArray(): number[];
  3629. /**
  3630. * @returns a new plane copied from the current Plane.
  3631. */
  3632. clone(): Plane;
  3633. /**
  3634. * @returns the string "Plane".
  3635. */
  3636. getClassName(): string;
  3637. /**
  3638. * @returns the Plane hash code.
  3639. */
  3640. getHashCode(): number;
  3641. /**
  3642. * Normalize the current Plane in place.
  3643. * @returns the updated Plane.
  3644. */
  3645. normalize(): Plane;
  3646. /**
  3647. * Applies a transformation the plane and returns the result
  3648. * @param transformation the transformation matrix to be applied to the plane
  3649. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3650. */
  3651. transform(transformation: DeepImmutable<Matrix>): Plane;
  3652. /**
  3653. * Calcualtte the dot product between the point and the plane normal
  3654. * @param point point to calculate the dot product with
  3655. * @returns the dot product (float) of the point coordinates and the plane normal.
  3656. */
  3657. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3658. /**
  3659. * Updates the current Plane from the plane defined by the three given points.
  3660. * @param point1 one of the points used to contruct the plane
  3661. * @param point2 one of the points used to contruct the plane
  3662. * @param point3 one of the points used to contruct the plane
  3663. * @returns the updated Plane.
  3664. */
  3665. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3666. /**
  3667. * Checks if the plane is facing a given direction
  3668. * @param direction the direction to check if the plane is facing
  3669. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3670. * @returns True is the vector "direction" is the same side than the plane normal.
  3671. */
  3672. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3673. /**
  3674. * Calculates the distance to a point
  3675. * @param point point to calculate distance to
  3676. * @returns the signed distance (float) from the given point to the Plane.
  3677. */
  3678. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3679. /**
  3680. * Creates a plane from an array
  3681. * @param array the array to create a plane from
  3682. * @returns a new Plane from the given array.
  3683. */
  3684. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3685. /**
  3686. * Creates a plane from three points
  3687. * @param point1 point used to create the plane
  3688. * @param point2 point used to create the plane
  3689. * @param point3 point used to create the plane
  3690. * @returns a new Plane defined by the three given points.
  3691. */
  3692. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3693. /**
  3694. * Creates a plane from an origin point and a normal
  3695. * @param origin origin of the plane to be constructed
  3696. * @param normal normal of the plane to be constructed
  3697. * @returns a new Plane the normal vector to this plane at the given origin point.
  3698. * Note : the vector "normal" is updated because normalized.
  3699. */
  3700. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3701. /**
  3702. * Calculates the distance from a plane and a point
  3703. * @param origin origin of the plane to be constructed
  3704. * @param normal normal of the plane to be constructed
  3705. * @param point point to calculate distance to
  3706. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3707. */
  3708. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3709. }
  3710. /**
  3711. * Class used to represent a viewport on screen
  3712. */
  3713. export class Viewport {
  3714. /** viewport left coordinate */
  3715. x: number;
  3716. /** viewport top coordinate */
  3717. y: number;
  3718. /**viewport width */
  3719. width: number;
  3720. /** viewport height */
  3721. height: number;
  3722. /**
  3723. * Creates a Viewport object located at (x, y) and sized (width, height)
  3724. * @param x defines viewport left coordinate
  3725. * @param y defines viewport top coordinate
  3726. * @param width defines the viewport width
  3727. * @param height defines the viewport height
  3728. */
  3729. constructor(
  3730. /** viewport left coordinate */
  3731. x: number,
  3732. /** viewport top coordinate */
  3733. y: number,
  3734. /**viewport width */
  3735. width: number,
  3736. /** viewport height */
  3737. height: number);
  3738. /**
  3739. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3740. * @param renderWidth defines the rendering width
  3741. * @param renderHeight defines the rendering height
  3742. * @returns a new Viewport
  3743. */
  3744. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3745. /**
  3746. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3747. * @param renderWidth defines the rendering width
  3748. * @param renderHeight defines the rendering height
  3749. * @param ref defines the target viewport
  3750. * @returns the current viewport
  3751. */
  3752. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3753. /**
  3754. * Returns a new Viewport copied from the current one
  3755. * @returns a new Viewport
  3756. */
  3757. clone(): Viewport;
  3758. }
  3759. /**
  3760. * Reprasents a camera frustum
  3761. */
  3762. export class Frustum {
  3763. /**
  3764. * Gets the planes representing the frustum
  3765. * @param transform matrix to be applied to the returned planes
  3766. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3767. */
  3768. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3769. /**
  3770. * Gets the near frustum plane transformed by the transform matrix
  3771. * @param transform transformation matrix to be applied to the resulting frustum plane
  3772. * @param frustumPlane the resuling frustum plane
  3773. */
  3774. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3775. /**
  3776. * Gets the far frustum plane transformed by the transform matrix
  3777. * @param transform transformation matrix to be applied to the resulting frustum plane
  3778. * @param frustumPlane the resuling frustum plane
  3779. */
  3780. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3781. /**
  3782. * Gets the left frustum plane transformed by the transform matrix
  3783. * @param transform transformation matrix to be applied to the resulting frustum plane
  3784. * @param frustumPlane the resuling frustum plane
  3785. */
  3786. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3787. /**
  3788. * Gets the right frustum plane transformed by the transform matrix
  3789. * @param transform transformation matrix to be applied to the resulting frustum plane
  3790. * @param frustumPlane the resuling frustum plane
  3791. */
  3792. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3793. /**
  3794. * Gets the top frustum plane transformed by the transform matrix
  3795. * @param transform transformation matrix to be applied to the resulting frustum plane
  3796. * @param frustumPlane the resuling frustum plane
  3797. */
  3798. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3799. /**
  3800. * Gets the bottom frustum plane transformed by the transform matrix
  3801. * @param transform transformation matrix to be applied to the resulting frustum plane
  3802. * @param frustumPlane the resuling frustum plane
  3803. */
  3804. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3805. /**
  3806. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3807. * @param transform transformation matrix to be applied to the resulting frustum planes
  3808. * @param frustumPlanes the resuling frustum planes
  3809. */
  3810. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3811. }
  3812. /** Defines supported spaces */
  3813. export enum Space {
  3814. /** Local (object) space */
  3815. LOCAL = 0,
  3816. /** World space */
  3817. WORLD = 1,
  3818. /** Bone space */
  3819. BONE = 2
  3820. }
  3821. /** Defines the 3 main axes */
  3822. export class Axis {
  3823. /** X axis */
  3824. static X: Vector3;
  3825. /** Y axis */
  3826. static Y: Vector3;
  3827. /** Z axis */
  3828. static Z: Vector3;
  3829. }
  3830. /** Class used to represent a Bezier curve */
  3831. export class BezierCurve {
  3832. /**
  3833. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3834. * @param t defines the time
  3835. * @param x1 defines the left coordinate on X axis
  3836. * @param y1 defines the left coordinate on Y axis
  3837. * @param x2 defines the right coordinate on X axis
  3838. * @param y2 defines the right coordinate on Y axis
  3839. * @returns the interpolated value
  3840. */
  3841. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3842. }
  3843. /**
  3844. * Defines potential orientation for back face culling
  3845. */
  3846. export enum Orientation {
  3847. /**
  3848. * Clockwise
  3849. */
  3850. CW = 0,
  3851. /** Counter clockwise */
  3852. CCW = 1
  3853. }
  3854. /**
  3855. * Defines angle representation
  3856. */
  3857. export class Angle {
  3858. private _radians;
  3859. /**
  3860. * Creates an Angle object of "radians" radians (float).
  3861. * @param radians the angle in radians
  3862. */
  3863. constructor(radians: number);
  3864. /**
  3865. * Get value in degrees
  3866. * @returns the Angle value in degrees (float)
  3867. */
  3868. degrees(): number;
  3869. /**
  3870. * Get value in radians
  3871. * @returns the Angle value in radians (float)
  3872. */
  3873. radians(): number;
  3874. /**
  3875. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3876. * @param a defines first vector
  3877. * @param b defines second vector
  3878. * @returns a new Angle
  3879. */
  3880. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3881. /**
  3882. * Gets a new Angle object from the given float in radians
  3883. * @param radians defines the angle value in radians
  3884. * @returns a new Angle
  3885. */
  3886. static FromRadians(radians: number): Angle;
  3887. /**
  3888. * Gets a new Angle object from the given float in degrees
  3889. * @param degrees defines the angle value in degrees
  3890. * @returns a new Angle
  3891. */
  3892. static FromDegrees(degrees: number): Angle;
  3893. }
  3894. /**
  3895. * This represents an arc in a 2d space.
  3896. */
  3897. export class Arc2 {
  3898. /** Defines the start point of the arc */
  3899. startPoint: Vector2;
  3900. /** Defines the mid point of the arc */
  3901. midPoint: Vector2;
  3902. /** Defines the end point of the arc */
  3903. endPoint: Vector2;
  3904. /**
  3905. * Defines the center point of the arc.
  3906. */
  3907. centerPoint: Vector2;
  3908. /**
  3909. * Defines the radius of the arc.
  3910. */
  3911. radius: number;
  3912. /**
  3913. * Defines the angle of the arc (from mid point to end point).
  3914. */
  3915. angle: Angle;
  3916. /**
  3917. * Defines the start angle of the arc (from start point to middle point).
  3918. */
  3919. startAngle: Angle;
  3920. /**
  3921. * Defines the orientation of the arc (clock wise/counter clock wise).
  3922. */
  3923. orientation: Orientation;
  3924. /**
  3925. * Creates an Arc object from the three given points : start, middle and end.
  3926. * @param startPoint Defines the start point of the arc
  3927. * @param midPoint Defines the midlle point of the arc
  3928. * @param endPoint Defines the end point of the arc
  3929. */
  3930. constructor(
  3931. /** Defines the start point of the arc */
  3932. startPoint: Vector2,
  3933. /** Defines the mid point of the arc */
  3934. midPoint: Vector2,
  3935. /** Defines the end point of the arc */
  3936. endPoint: Vector2);
  3937. }
  3938. /**
  3939. * Represents a 2D path made up of multiple 2D points
  3940. */
  3941. export class Path2 {
  3942. private _points;
  3943. private _length;
  3944. /**
  3945. * If the path start and end point are the same
  3946. */
  3947. closed: boolean;
  3948. /**
  3949. * Creates a Path2 object from the starting 2D coordinates x and y.
  3950. * @param x the starting points x value
  3951. * @param y the starting points y value
  3952. */
  3953. constructor(x: number, y: number);
  3954. /**
  3955. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3956. * @param x the added points x value
  3957. * @param y the added points y value
  3958. * @returns the updated Path2.
  3959. */
  3960. addLineTo(x: number, y: number): Path2;
  3961. /**
  3962. * 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.
  3963. * @param midX middle point x value
  3964. * @param midY middle point y value
  3965. * @param endX end point x value
  3966. * @param endY end point y value
  3967. * @param numberOfSegments (default: 36)
  3968. * @returns the updated Path2.
  3969. */
  3970. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3971. /**
  3972. * Closes the Path2.
  3973. * @returns the Path2.
  3974. */
  3975. close(): Path2;
  3976. /**
  3977. * Gets the sum of the distance between each sequential point in the path
  3978. * @returns the Path2 total length (float).
  3979. */
  3980. length(): number;
  3981. /**
  3982. * Gets the points which construct the path
  3983. * @returns the Path2 internal array of points.
  3984. */
  3985. getPoints(): Vector2[];
  3986. /**
  3987. * Retreives the point at the distance aways from the starting point
  3988. * @param normalizedLengthPosition the length along the path to retreive the point from
  3989. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3990. */
  3991. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3992. /**
  3993. * Creates a new path starting from an x and y position
  3994. * @param x starting x value
  3995. * @param y starting y value
  3996. * @returns a new Path2 starting at the coordinates (x, y).
  3997. */
  3998. static StartingAt(x: number, y: number): Path2;
  3999. }
  4000. /**
  4001. * Represents a 3D path made up of multiple 3D points
  4002. */
  4003. export class Path3D {
  4004. /**
  4005. * an array of Vector3, the curve axis of the Path3D
  4006. */
  4007. path: Vector3[];
  4008. private _curve;
  4009. private _distances;
  4010. private _tangents;
  4011. private _normals;
  4012. private _binormals;
  4013. private _raw;
  4014. /**
  4015. * new Path3D(path, normal, raw)
  4016. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4017. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4018. * @param path an array of Vector3, the curve axis of the Path3D
  4019. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4020. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4021. */
  4022. constructor(
  4023. /**
  4024. * an array of Vector3, the curve axis of the Path3D
  4025. */
  4026. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4027. /**
  4028. * Returns the Path3D array of successive Vector3 designing its curve.
  4029. * @returns the Path3D array of successive Vector3 designing its curve.
  4030. */
  4031. getCurve(): Vector3[];
  4032. /**
  4033. * Returns an array populated with tangent vectors on each Path3D curve point.
  4034. * @returns an array populated with tangent vectors on each Path3D curve point.
  4035. */
  4036. getTangents(): Vector3[];
  4037. /**
  4038. * Returns an array populated with normal vectors on each Path3D curve point.
  4039. * @returns an array populated with normal vectors on each Path3D curve point.
  4040. */
  4041. getNormals(): Vector3[];
  4042. /**
  4043. * Returns an array populated with binormal vectors on each Path3D curve point.
  4044. * @returns an array populated with binormal vectors on each Path3D curve point.
  4045. */
  4046. getBinormals(): Vector3[];
  4047. /**
  4048. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4049. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4050. */
  4051. getDistances(): number[];
  4052. /**
  4053. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4054. * @param path path which all values are copied into the curves points
  4055. * @param firstNormal which should be projected onto the curve
  4056. * @returns the same object updated.
  4057. */
  4058. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4059. private _compute;
  4060. private _getFirstNonNullVector;
  4061. private _getLastNonNullVector;
  4062. private _normalVector;
  4063. }
  4064. /**
  4065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4066. * A Curve3 is designed from a series of successive Vector3.
  4067. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4068. */
  4069. export class Curve3 {
  4070. private _points;
  4071. private _length;
  4072. /**
  4073. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4074. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4075. * @param v1 (Vector3) the control point
  4076. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4077. * @param nbPoints (integer) the wanted number of points in the curve
  4078. * @returns the created Curve3
  4079. */
  4080. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4081. /**
  4082. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4083. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4084. * @param v1 (Vector3) the first control point
  4085. * @param v2 (Vector3) the second control point
  4086. * @param v3 (Vector3) the end point of the Cubic Bezier
  4087. * @param nbPoints (integer) the wanted number of points in the curve
  4088. * @returns the created Curve3
  4089. */
  4090. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4091. /**
  4092. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4093. * @param p1 (Vector3) the origin point of the Hermite Spline
  4094. * @param t1 (Vector3) the tangent vector at the origin point
  4095. * @param p2 (Vector3) the end point of the Hermite Spline
  4096. * @param t2 (Vector3) the tangent vector at the end point
  4097. * @param nbPoints (integer) the wanted number of points in the curve
  4098. * @returns the created Curve3
  4099. */
  4100. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4101. /**
  4102. * Returns a Curve3 object along a CatmullRom Spline curve :
  4103. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4104. * @param nbPoints (integer) the wanted number of points between each curve control points
  4105. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4106. * @returns the created Curve3
  4107. */
  4108. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4109. /**
  4110. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4111. * A Curve3 is designed from a series of successive Vector3.
  4112. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4113. * @param points points which make up the curve
  4114. */
  4115. constructor(points: Vector3[]);
  4116. /**
  4117. * @returns the Curve3 stored array of successive Vector3
  4118. */
  4119. getPoints(): Vector3[];
  4120. /**
  4121. * @returns the computed length (float) of the curve.
  4122. */
  4123. length(): number;
  4124. /**
  4125. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4126. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4127. * curveA and curveB keep unchanged.
  4128. * @param curve the curve to continue from this curve
  4129. * @returns the newly constructed curve
  4130. */
  4131. continue(curve: DeepImmutable<Curve3>): Curve3;
  4132. private _computeLength;
  4133. }
  4134. /**
  4135. * Contains position and normal vectors for a vertex
  4136. */
  4137. export class PositionNormalVertex {
  4138. /** the position of the vertex (defaut: 0,0,0) */
  4139. position: Vector3;
  4140. /** the normal of the vertex (defaut: 0,1,0) */
  4141. normal: Vector3;
  4142. /**
  4143. * Creates a PositionNormalVertex
  4144. * @param position the position of the vertex (defaut: 0,0,0)
  4145. * @param normal the normal of the vertex (defaut: 0,1,0)
  4146. */
  4147. constructor(
  4148. /** the position of the vertex (defaut: 0,0,0) */
  4149. position?: Vector3,
  4150. /** the normal of the vertex (defaut: 0,1,0) */
  4151. normal?: Vector3);
  4152. /**
  4153. * Clones the PositionNormalVertex
  4154. * @returns the cloned PositionNormalVertex
  4155. */
  4156. clone(): PositionNormalVertex;
  4157. }
  4158. /**
  4159. * Contains position, normal and uv vectors for a vertex
  4160. */
  4161. export class PositionNormalTextureVertex {
  4162. /** the position of the vertex (defaut: 0,0,0) */
  4163. position: Vector3;
  4164. /** the normal of the vertex (defaut: 0,1,0) */
  4165. normal: Vector3;
  4166. /** the uv of the vertex (default: 0,0) */
  4167. uv: Vector2;
  4168. /**
  4169. * Creates a PositionNormalTextureVertex
  4170. * @param position the position of the vertex (defaut: 0,0,0)
  4171. * @param normal the normal of the vertex (defaut: 0,1,0)
  4172. * @param uv the uv of the vertex (default: 0,0)
  4173. */
  4174. constructor(
  4175. /** the position of the vertex (defaut: 0,0,0) */
  4176. position?: Vector3,
  4177. /** the normal of the vertex (defaut: 0,1,0) */
  4178. normal?: Vector3,
  4179. /** the uv of the vertex (default: 0,0) */
  4180. uv?: Vector2);
  4181. /**
  4182. * Clones the PositionNormalTextureVertex
  4183. * @returns the cloned PositionNormalTextureVertex
  4184. */
  4185. clone(): PositionNormalTextureVertex;
  4186. }
  4187. /**
  4188. * @hidden
  4189. */
  4190. export class Tmp {
  4191. static Color3: Color3[];
  4192. static Color4: Color4[];
  4193. static Vector2: Vector2[];
  4194. static Vector3: Vector3[];
  4195. static Vector4: Vector4[];
  4196. static Quaternion: Quaternion[];
  4197. static Matrix: Matrix[];
  4198. }
  4199. }
  4200. declare module BABYLON {
  4201. /**
  4202. * Class used to enable access to offline support
  4203. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4204. */
  4205. export interface IOfflineProvider {
  4206. /**
  4207. * Gets a boolean indicating if scene must be saved in the database
  4208. */
  4209. enableSceneOffline: boolean;
  4210. /**
  4211. * Gets a boolean indicating if textures must be saved in the database
  4212. */
  4213. enableTexturesOffline: boolean;
  4214. /**
  4215. * Open the offline support and make it available
  4216. * @param successCallback defines the callback to call on success
  4217. * @param errorCallback defines the callback to call on error
  4218. */
  4219. open(successCallback: () => void, errorCallback: () => void): void;
  4220. /**
  4221. * Loads an image from the offline support
  4222. * @param url defines the url to load from
  4223. * @param image defines the target DOM image
  4224. */
  4225. loadImage(url: string, image: HTMLImageElement): void;
  4226. /**
  4227. * Loads a file from offline support
  4228. * @param url defines the URL to load from
  4229. * @param sceneLoaded defines a callback to call on success
  4230. * @param progressCallBack defines a callback to call when progress changed
  4231. * @param errorCallback defines a callback to call on error
  4232. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4233. */
  4234. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4235. }
  4236. }
  4237. declare module BABYLON {
  4238. /**
  4239. * A class serves as a medium between the observable and its observers
  4240. */
  4241. export class EventState {
  4242. /**
  4243. * Create a new EventState
  4244. * @param mask defines the mask associated with this state
  4245. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4246. * @param target defines the original target of the state
  4247. * @param currentTarget defines the current target of the state
  4248. */
  4249. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4250. /**
  4251. * Initialize the current event state
  4252. * @param mask defines the mask associated with this state
  4253. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4254. * @param target defines the original target of the state
  4255. * @param currentTarget defines the current target of the state
  4256. * @returns the current event state
  4257. */
  4258. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4259. /**
  4260. * An Observer can set this property to true to prevent subsequent observers of being notified
  4261. */
  4262. skipNextObservers: boolean;
  4263. /**
  4264. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4265. */
  4266. mask: number;
  4267. /**
  4268. * The object that originally notified the event
  4269. */
  4270. target?: any;
  4271. /**
  4272. * The current object in the bubbling phase
  4273. */
  4274. currentTarget?: any;
  4275. /**
  4276. * This will be populated with the return value of the last function that was executed.
  4277. * If it is the first function in the callback chain it will be the event data.
  4278. */
  4279. lastReturnValue?: any;
  4280. }
  4281. /**
  4282. * Represent an Observer registered to a given Observable object.
  4283. */
  4284. export class Observer<T> {
  4285. /**
  4286. * Defines the callback to call when the observer is notified
  4287. */
  4288. callback: (eventData: T, eventState: EventState) => void;
  4289. /**
  4290. * Defines the mask of the observer (used to filter notifications)
  4291. */
  4292. mask: number;
  4293. /**
  4294. * Defines the current scope used to restore the JS context
  4295. */
  4296. scope: any;
  4297. /** @hidden */
  4298. _willBeUnregistered: boolean;
  4299. /**
  4300. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4301. */
  4302. unregisterOnNextCall: boolean;
  4303. /**
  4304. * Creates a new observer
  4305. * @param callback defines the callback to call when the observer is notified
  4306. * @param mask defines the mask of the observer (used to filter notifications)
  4307. * @param scope defines the current scope used to restore the JS context
  4308. */
  4309. constructor(
  4310. /**
  4311. * Defines the callback to call when the observer is notified
  4312. */
  4313. callback: (eventData: T, eventState: EventState) => void,
  4314. /**
  4315. * Defines the mask of the observer (used to filter notifications)
  4316. */
  4317. mask: number,
  4318. /**
  4319. * Defines the current scope used to restore the JS context
  4320. */
  4321. scope?: any);
  4322. }
  4323. /**
  4324. * Represent a list of observers registered to multiple Observables object.
  4325. */
  4326. export class MultiObserver<T> {
  4327. private _observers;
  4328. private _observables;
  4329. /**
  4330. * Release associated resources
  4331. */
  4332. dispose(): void;
  4333. /**
  4334. * Raise a callback when one of the observable will notify
  4335. * @param observables defines a list of observables to watch
  4336. * @param callback defines the callback to call on notification
  4337. * @param mask defines the mask used to filter notifications
  4338. * @param scope defines the current scope used to restore the JS context
  4339. * @returns the new MultiObserver
  4340. */
  4341. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4342. }
  4343. /**
  4344. * The Observable class is a simple implementation of the Observable pattern.
  4345. *
  4346. * 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.
  4347. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4348. * 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).
  4349. * 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.
  4350. */
  4351. export class Observable<T> {
  4352. private _observers;
  4353. private _eventState;
  4354. private _onObserverAdded;
  4355. /**
  4356. * Creates a new observable
  4357. * @param onObserverAdded defines a callback to call when a new observer is added
  4358. */
  4359. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4360. /**
  4361. * Create a new Observer with the specified callback
  4362. * @param callback the callback that will be executed for that Observer
  4363. * @param mask the mask used to filter observers
  4364. * @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.
  4365. * @param scope optional scope for the callback to be called from
  4366. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4367. * @returns the new observer created for the callback
  4368. */
  4369. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4370. /**
  4371. * Create a new Observer with the specified callback and unregisters after the next notification
  4372. * @param callback the callback that will be executed for that Observer
  4373. * @returns the new observer created for the callback
  4374. */
  4375. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4376. /**
  4377. * Remove an Observer from the Observable object
  4378. * @param observer the instance of the Observer to remove
  4379. * @returns false if it doesn't belong to this Observable
  4380. */
  4381. remove(observer: Nullable<Observer<T>>): boolean;
  4382. /**
  4383. * Remove a callback from the Observable object
  4384. * @param callback the callback to remove
  4385. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4386. * @returns false if it doesn't belong to this Observable
  4387. */
  4388. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4389. private _deferUnregister;
  4390. private _remove;
  4391. /**
  4392. * Moves the observable to the top of the observer list making it get called first when notified
  4393. * @param observer the observer to move
  4394. */
  4395. makeObserverTopPriority(observer: Observer<T>): void;
  4396. /**
  4397. * Moves the observable to the bottom of the observer list making it get called last when notified
  4398. * @param observer the observer to move
  4399. */
  4400. makeObserverBottomPriority(observer: Observer<T>): void;
  4401. /**
  4402. * Notify all Observers by calling their respective callback with the given data
  4403. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4404. * @param eventData defines the data to send to all observers
  4405. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4406. * @param target defines the original target of the state
  4407. * @param currentTarget defines the current target of the state
  4408. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4409. */
  4410. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4411. /**
  4412. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4413. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4414. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4415. * and it is crucial that all callbacks will be executed.
  4416. * The order of the callbacks is kept, callbacks are not executed parallel.
  4417. *
  4418. * @param eventData The data to be sent to each callback
  4419. * @param mask is used to filter observers defaults to -1
  4420. * @param target defines the callback target (see EventState)
  4421. * @param currentTarget defines he current object in the bubbling phase
  4422. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4423. */
  4424. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4425. /**
  4426. * Notify a specific observer
  4427. * @param observer defines the observer to notify
  4428. * @param eventData defines the data to be sent to each callback
  4429. * @param mask is used to filter observers defaults to -1
  4430. */
  4431. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4432. /**
  4433. * Gets a boolean indicating if the observable has at least one observer
  4434. * @returns true is the Observable has at least one Observer registered
  4435. */
  4436. hasObservers(): boolean;
  4437. /**
  4438. * Clear the list of observers
  4439. */
  4440. clear(): void;
  4441. /**
  4442. * Clone the current observable
  4443. * @returns a new observable
  4444. */
  4445. clone(): Observable<T>;
  4446. /**
  4447. * Does this observable handles observer registered with a given mask
  4448. * @param mask defines the mask to be tested
  4449. * @return whether or not one observer registered with the given mask is handeled
  4450. **/
  4451. hasSpecificMask(mask?: number): boolean;
  4452. }
  4453. }
  4454. declare module BABYLON {
  4455. /**
  4456. * Class used to help managing file picking and drag'n'drop
  4457. * File Storage
  4458. */
  4459. export class FilesInputStore {
  4460. /**
  4461. * List of files ready to be loaded
  4462. */
  4463. static FilesToLoad: {
  4464. [key: string]: File;
  4465. };
  4466. }
  4467. }
  4468. declare module BABYLON {
  4469. /** Defines the cross module used constants to avoid circular dependncies */
  4470. export class Constants {
  4471. /** Defines that alpha blending is disabled */
  4472. static readonly ALPHA_DISABLE: number;
  4473. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4474. static readonly ALPHA_ADD: number;
  4475. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4476. static readonly ALPHA_COMBINE: number;
  4477. /** Defines that alpha blending to DEST - SRC * DEST */
  4478. static readonly ALPHA_SUBTRACT: number;
  4479. /** Defines that alpha blending to SRC * DEST */
  4480. static readonly ALPHA_MULTIPLY: number;
  4481. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4482. static readonly ALPHA_MAXIMIZED: number;
  4483. /** Defines that alpha blending to SRC + DEST */
  4484. static readonly ALPHA_ONEONE: number;
  4485. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4486. static readonly ALPHA_PREMULTIPLIED: number;
  4487. /**
  4488. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4489. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4490. */
  4491. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4492. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4493. static readonly ALPHA_INTERPOLATE: number;
  4494. /**
  4495. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4496. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4497. */
  4498. static readonly ALPHA_SCREENMODE: number;
  4499. /** Defines that the ressource is not delayed*/
  4500. static readonly DELAYLOADSTATE_NONE: number;
  4501. /** Defines that the ressource was successfully delay loaded */
  4502. static readonly DELAYLOADSTATE_LOADED: number;
  4503. /** Defines that the ressource is currently delay loading */
  4504. static readonly DELAYLOADSTATE_LOADING: number;
  4505. /** Defines that the ressource is delayed and has not started loading */
  4506. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4507. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4508. static readonly NEVER: number;
  4509. /** 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 */
  4510. static readonly ALWAYS: number;
  4511. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4512. static readonly LESS: number;
  4513. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4514. static readonly EQUAL: number;
  4515. /** 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 */
  4516. static readonly LEQUAL: number;
  4517. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4518. static readonly GREATER: number;
  4519. /** 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 */
  4520. static readonly GEQUAL: number;
  4521. /** 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 */
  4522. static readonly NOTEQUAL: number;
  4523. /** Passed to stencilOperation to specify that stencil value must be kept */
  4524. static readonly KEEP: number;
  4525. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4526. static readonly REPLACE: number;
  4527. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4528. static readonly INCR: number;
  4529. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4530. static readonly DECR: number;
  4531. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4532. static readonly INVERT: number;
  4533. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4534. static readonly INCR_WRAP: number;
  4535. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4536. static readonly DECR_WRAP: number;
  4537. /** Texture is not repeating outside of 0..1 UVs */
  4538. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4539. /** Texture is repeating outside of 0..1 UVs */
  4540. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4541. /** Texture is repeating and mirrored */
  4542. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4543. /** ALPHA */
  4544. static readonly TEXTUREFORMAT_ALPHA: number;
  4545. /** LUMINANCE */
  4546. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4547. /** LUMINANCE_ALPHA */
  4548. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4549. /** RGB */
  4550. static readonly TEXTUREFORMAT_RGB: number;
  4551. /** RGBA */
  4552. static readonly TEXTUREFORMAT_RGBA: number;
  4553. /** RED */
  4554. static readonly TEXTUREFORMAT_RED: number;
  4555. /** RED (2nd reference) */
  4556. static readonly TEXTUREFORMAT_R: number;
  4557. /** RG */
  4558. static readonly TEXTUREFORMAT_RG: number;
  4559. /** RED_INTEGER */
  4560. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4561. /** RED_INTEGER (2nd reference) */
  4562. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4563. /** RG_INTEGER */
  4564. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4565. /** RGB_INTEGER */
  4566. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4567. /** RGBA_INTEGER */
  4568. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4569. /** UNSIGNED_BYTE */
  4570. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4571. /** UNSIGNED_BYTE (2nd reference) */
  4572. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4573. /** FLOAT */
  4574. static readonly TEXTURETYPE_FLOAT: number;
  4575. /** HALF_FLOAT */
  4576. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4577. /** BYTE */
  4578. static readonly TEXTURETYPE_BYTE: number;
  4579. /** SHORT */
  4580. static readonly TEXTURETYPE_SHORT: number;
  4581. /** UNSIGNED_SHORT */
  4582. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4583. /** INT */
  4584. static readonly TEXTURETYPE_INT: number;
  4585. /** UNSIGNED_INT */
  4586. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4587. /** UNSIGNED_SHORT_4_4_4_4 */
  4588. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4589. /** UNSIGNED_SHORT_5_5_5_1 */
  4590. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4591. /** UNSIGNED_SHORT_5_6_5 */
  4592. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4593. /** UNSIGNED_INT_2_10_10_10_REV */
  4594. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4595. /** UNSIGNED_INT_24_8 */
  4596. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4597. /** UNSIGNED_INT_10F_11F_11F_REV */
  4598. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4599. /** UNSIGNED_INT_5_9_9_9_REV */
  4600. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4601. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4602. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4603. /** nearest is mag = nearest and min = nearest and mip = linear */
  4604. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4605. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4606. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4607. /** Trilinear is mag = linear and min = linear and mip = linear */
  4608. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4609. /** nearest is mag = nearest and min = nearest and mip = linear */
  4610. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4611. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4612. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4613. /** Trilinear is mag = linear and min = linear and mip = linear */
  4614. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4615. /** mag = nearest and min = nearest and mip = nearest */
  4616. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4617. /** mag = nearest and min = linear and mip = nearest */
  4618. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4619. /** mag = nearest and min = linear and mip = linear */
  4620. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4621. /** mag = nearest and min = linear and mip = none */
  4622. static readonly TEXTURE_NEAREST_LINEAR: number;
  4623. /** mag = nearest and min = nearest and mip = none */
  4624. static readonly TEXTURE_NEAREST_NEAREST: number;
  4625. /** mag = linear and min = nearest and mip = nearest */
  4626. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4627. /** mag = linear and min = nearest and mip = linear */
  4628. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4629. /** mag = linear and min = linear and mip = none */
  4630. static readonly TEXTURE_LINEAR_LINEAR: number;
  4631. /** mag = linear and min = nearest and mip = none */
  4632. static readonly TEXTURE_LINEAR_NEAREST: number;
  4633. /** Explicit coordinates mode */
  4634. static readonly TEXTURE_EXPLICIT_MODE: number;
  4635. /** Spherical coordinates mode */
  4636. static readonly TEXTURE_SPHERICAL_MODE: number;
  4637. /** Planar coordinates mode */
  4638. static readonly TEXTURE_PLANAR_MODE: number;
  4639. /** Cubic coordinates mode */
  4640. static readonly TEXTURE_CUBIC_MODE: number;
  4641. /** Projection coordinates mode */
  4642. static readonly TEXTURE_PROJECTION_MODE: number;
  4643. /** Skybox coordinates mode */
  4644. static readonly TEXTURE_SKYBOX_MODE: number;
  4645. /** Inverse Cubic coordinates mode */
  4646. static readonly TEXTURE_INVCUBIC_MODE: number;
  4647. /** Equirectangular coordinates mode */
  4648. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4649. /** Equirectangular Fixed coordinates mode */
  4650. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4651. /** Equirectangular Fixed Mirrored coordinates mode */
  4652. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4653. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4654. static readonly SCALEMODE_FLOOR: number;
  4655. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4656. static readonly SCALEMODE_NEAREST: number;
  4657. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4658. static readonly SCALEMODE_CEILING: number;
  4659. /**
  4660. * The dirty texture flag value
  4661. */
  4662. static readonly MATERIAL_TextureDirtyFlag: number;
  4663. /**
  4664. * The dirty light flag value
  4665. */
  4666. static readonly MATERIAL_LightDirtyFlag: number;
  4667. /**
  4668. * The dirty fresnel flag value
  4669. */
  4670. static readonly MATERIAL_FresnelDirtyFlag: number;
  4671. /**
  4672. * The dirty attribute flag value
  4673. */
  4674. static readonly MATERIAL_AttributesDirtyFlag: number;
  4675. /**
  4676. * The dirty misc flag value
  4677. */
  4678. static readonly MATERIAL_MiscDirtyFlag: number;
  4679. /**
  4680. * The all dirty flag value
  4681. */
  4682. static readonly MATERIAL_AllDirtyFlag: number;
  4683. /**
  4684. * Returns the triangle fill mode
  4685. */
  4686. static readonly MATERIAL_TriangleFillMode: number;
  4687. /**
  4688. * Returns the wireframe mode
  4689. */
  4690. static readonly MATERIAL_WireFrameFillMode: number;
  4691. /**
  4692. * Returns the point fill mode
  4693. */
  4694. static readonly MATERIAL_PointFillMode: number;
  4695. /**
  4696. * Returns the point list draw mode
  4697. */
  4698. static readonly MATERIAL_PointListDrawMode: number;
  4699. /**
  4700. * Returns the line list draw mode
  4701. */
  4702. static readonly MATERIAL_LineListDrawMode: number;
  4703. /**
  4704. * Returns the line loop draw mode
  4705. */
  4706. static readonly MATERIAL_LineLoopDrawMode: number;
  4707. /**
  4708. * Returns the line strip draw mode
  4709. */
  4710. static readonly MATERIAL_LineStripDrawMode: number;
  4711. /**
  4712. * Returns the triangle strip draw mode
  4713. */
  4714. static readonly MATERIAL_TriangleStripDrawMode: number;
  4715. /**
  4716. * Returns the triangle fan draw mode
  4717. */
  4718. static readonly MATERIAL_TriangleFanDrawMode: number;
  4719. /**
  4720. * Stores the clock-wise side orientation
  4721. */
  4722. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4723. /**
  4724. * Stores the counter clock-wise side orientation
  4725. */
  4726. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4727. /**
  4728. * Nothing
  4729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4730. */
  4731. static readonly ACTION_NothingTrigger: number;
  4732. /**
  4733. * On pick
  4734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4735. */
  4736. static readonly ACTION_OnPickTrigger: number;
  4737. /**
  4738. * On left pick
  4739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4740. */
  4741. static readonly ACTION_OnLeftPickTrigger: number;
  4742. /**
  4743. * On right pick
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnRightPickTrigger: number;
  4747. /**
  4748. * On center pick
  4749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4750. */
  4751. static readonly ACTION_OnCenterPickTrigger: number;
  4752. /**
  4753. * On pick down
  4754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4755. */
  4756. static readonly ACTION_OnPickDownTrigger: number;
  4757. /**
  4758. * On double pick
  4759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4760. */
  4761. static readonly ACTION_OnDoublePickTrigger: number;
  4762. /**
  4763. * On pick up
  4764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4765. */
  4766. static readonly ACTION_OnPickUpTrigger: number;
  4767. /**
  4768. * On pick out.
  4769. * This trigger will only be raised if you also declared a OnPickDown
  4770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4771. */
  4772. static readonly ACTION_OnPickOutTrigger: number;
  4773. /**
  4774. * On long press
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4776. */
  4777. static readonly ACTION_OnLongPressTrigger: number;
  4778. /**
  4779. * On pointer over
  4780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4781. */
  4782. static readonly ACTION_OnPointerOverTrigger: number;
  4783. /**
  4784. * On pointer out
  4785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4786. */
  4787. static readonly ACTION_OnPointerOutTrigger: number;
  4788. /**
  4789. * On every frame
  4790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4791. */
  4792. static readonly ACTION_OnEveryFrameTrigger: number;
  4793. /**
  4794. * On intersection enter
  4795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4796. */
  4797. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4798. /**
  4799. * On intersection exit
  4800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4801. */
  4802. static readonly ACTION_OnIntersectionExitTrigger: number;
  4803. /**
  4804. * On key down
  4805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4806. */
  4807. static readonly ACTION_OnKeyDownTrigger: number;
  4808. /**
  4809. * On key up
  4810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4811. */
  4812. static readonly ACTION_OnKeyUpTrigger: number;
  4813. /**
  4814. * Billboard mode will only apply to Y axis
  4815. */
  4816. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4817. /**
  4818. * Billboard mode will apply to all axes
  4819. */
  4820. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4821. /**
  4822. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4823. */
  4824. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4825. /**
  4826. * Gets or sets base Assets URL
  4827. */
  4828. static PARTICLES_BaseAssetsUrl: string;
  4829. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4830. * Test order :
  4831. * Is the bounding sphere outside the frustum ?
  4832. * If not, are the bounding box vertices outside the frustum ?
  4833. * It not, then the cullable object is in the frustum.
  4834. */
  4835. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4836. /** Culling strategy : Bounding Sphere Only.
  4837. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4838. * It's also less accurate than the standard because some not visible objects can still be selected.
  4839. * Test : is the bounding sphere outside the frustum ?
  4840. * If not, then the cullable object is in the frustum.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4843. /** Culling strategy : Optimistic Inclusion.
  4844. * This in an inclusion test first, then the standard exclusion test.
  4845. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4846. * 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.
  4847. * Anyway, it's as accurate as the standard strategy.
  4848. * Test :
  4849. * Is the cullable object bounding sphere center in the frustum ?
  4850. * If not, apply the default culling strategy.
  4851. */
  4852. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4853. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4854. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4855. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4856. * 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.
  4857. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4858. * Test :
  4859. * Is the cullable object bounding sphere center in the frustum ?
  4860. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4861. */
  4862. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4863. /**
  4864. * No logging while loading
  4865. */
  4866. static readonly SCENELOADER_NO_LOGGING: number;
  4867. /**
  4868. * Minimal logging while loading
  4869. */
  4870. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4871. /**
  4872. * Summary logging while loading
  4873. */
  4874. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4875. /**
  4876. * Detailled logging while loading
  4877. */
  4878. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4879. }
  4880. }
  4881. declare module BABYLON {
  4882. /**
  4883. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4884. * Babylon.js
  4885. */
  4886. export class DomManagement {
  4887. /**
  4888. * Checks if the window object exists
  4889. * @returns true if the window object exists
  4890. */
  4891. static IsWindowObjectExist(): boolean;
  4892. /**
  4893. * Extracts text content from a DOM element hierarchy
  4894. * @param element defines the root element
  4895. * @returns a string
  4896. */
  4897. static GetDOMTextContent(element: HTMLElement): string;
  4898. }
  4899. }
  4900. declare module BABYLON {
  4901. /**
  4902. * Logger used througouht the application to allow configuration of
  4903. * the log level required for the messages.
  4904. */
  4905. export class Logger {
  4906. /**
  4907. * No log
  4908. */
  4909. static readonly NoneLogLevel: number;
  4910. /**
  4911. * Only message logs
  4912. */
  4913. static readonly MessageLogLevel: number;
  4914. /**
  4915. * Only warning logs
  4916. */
  4917. static readonly WarningLogLevel: number;
  4918. /**
  4919. * Only error logs
  4920. */
  4921. static readonly ErrorLogLevel: number;
  4922. /**
  4923. * All logs
  4924. */
  4925. static readonly AllLogLevel: number;
  4926. private static _LogCache;
  4927. /**
  4928. * Gets a value indicating the number of loading errors
  4929. * @ignorenaming
  4930. */
  4931. static errorsCount: number;
  4932. /**
  4933. * Callback called when a new log is added
  4934. */
  4935. static OnNewCacheEntry: (entry: string) => void;
  4936. private static _AddLogEntry;
  4937. private static _FormatMessage;
  4938. private static _LogDisabled;
  4939. private static _LogEnabled;
  4940. private static _WarnDisabled;
  4941. private static _WarnEnabled;
  4942. private static _ErrorDisabled;
  4943. private static _ErrorEnabled;
  4944. /**
  4945. * Log a message to the console
  4946. */
  4947. static Log: (message: string) => void;
  4948. /**
  4949. * Write a warning message to the console
  4950. */
  4951. static Warn: (message: string) => void;
  4952. /**
  4953. * Write an error message to the console
  4954. */
  4955. static Error: (message: string) => void;
  4956. /**
  4957. * Gets current log cache (list of logs)
  4958. */
  4959. static readonly LogCache: string;
  4960. /**
  4961. * Clears the log cache
  4962. */
  4963. static ClearLogCache(): void;
  4964. /**
  4965. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4966. */
  4967. static LogLevels: number;
  4968. }
  4969. }
  4970. declare module BABYLON {
  4971. /** @hidden */
  4972. export class _TypeStore {
  4973. /** @hidden */
  4974. static RegisteredTypes: {
  4975. [key: string]: Object;
  4976. };
  4977. /** @hidden */
  4978. static GetClass(fqdn: string): any;
  4979. }
  4980. }
  4981. declare module BABYLON {
  4982. /**
  4983. * Class containing a set of static utilities functions for deep copy.
  4984. */
  4985. export class DeepCopier {
  4986. /**
  4987. * Tries to copy an object by duplicating every property
  4988. * @param source defines the source object
  4989. * @param destination defines the target object
  4990. * @param doNotCopyList defines a list of properties to avoid
  4991. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4992. */
  4993. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4994. }
  4995. }
  4996. declare module BABYLON {
  4997. /**
  4998. * Class containing a set of static utilities functions for precision date
  4999. */
  5000. export class PrecisionDate {
  5001. /**
  5002. * Gets either window.performance.now() if supported or Date.now() else
  5003. */
  5004. static readonly Now: number;
  5005. }
  5006. }
  5007. declare module BABYLON {
  5008. /** @hidden */
  5009. export class _DevTools {
  5010. static WarnImport(name: string): string;
  5011. }
  5012. }
  5013. declare module BABYLON {
  5014. /**
  5015. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5016. */
  5017. export class WebRequest {
  5018. private _xhr;
  5019. /**
  5020. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5021. * i.e. when loading files, where the server/service expects an Authorization header
  5022. */
  5023. static CustomRequestHeaders: {
  5024. [key: string]: string;
  5025. };
  5026. /**
  5027. * Add callback functions in this array to update all the requests before they get sent to the network
  5028. */
  5029. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5030. private _injectCustomRequestHeaders;
  5031. /**
  5032. * Gets or sets a function to be called when loading progress changes
  5033. */
  5034. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5035. /**
  5036. * Returns client's state
  5037. */
  5038. readonly readyState: number;
  5039. /**
  5040. * Returns client's status
  5041. */
  5042. readonly status: number;
  5043. /**
  5044. * Returns client's status as a text
  5045. */
  5046. readonly statusText: string;
  5047. /**
  5048. * Returns client's response
  5049. */
  5050. readonly response: any;
  5051. /**
  5052. * Returns client's response url
  5053. */
  5054. readonly responseURL: string;
  5055. /**
  5056. * Returns client's response as text
  5057. */
  5058. readonly responseText: string;
  5059. /**
  5060. * Gets or sets the expected response type
  5061. */
  5062. responseType: XMLHttpRequestResponseType;
  5063. /** @hidden */
  5064. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5065. /** @hidden */
  5066. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5067. /**
  5068. * Cancels any network activity
  5069. */
  5070. abort(): void;
  5071. /**
  5072. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5073. * @param body defines an optional request body
  5074. */
  5075. send(body?: Document | BodyInit | null): void;
  5076. /**
  5077. * Sets the request method, request URL
  5078. * @param method defines the method to use (GET, POST, etc..)
  5079. * @param url defines the url to connect with
  5080. */
  5081. open(method: string, url: string): void;
  5082. }
  5083. }
  5084. declare module BABYLON {
  5085. /**
  5086. * Class used to evalaute queries containing `and` and `or` operators
  5087. */
  5088. export class AndOrNotEvaluator {
  5089. /**
  5090. * Evaluate a query
  5091. * @param query defines the query to evaluate
  5092. * @param evaluateCallback defines the callback used to filter result
  5093. * @returns true if the query matches
  5094. */
  5095. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5096. private static _HandleParenthesisContent;
  5097. private static _SimplifyNegation;
  5098. }
  5099. }
  5100. declare module BABYLON {
  5101. /**
  5102. * Class used to store custom tags
  5103. */
  5104. export class Tags {
  5105. /**
  5106. * Adds support for tags on the given object
  5107. * @param obj defines the object to use
  5108. */
  5109. static EnableFor(obj: any): void;
  5110. /**
  5111. * Removes tags support
  5112. * @param obj defines the object to use
  5113. */
  5114. static DisableFor(obj: any): void;
  5115. /**
  5116. * Gets a boolean indicating if the given object has tags
  5117. * @param obj defines the object to use
  5118. * @returns a boolean
  5119. */
  5120. static HasTags(obj: any): boolean;
  5121. /**
  5122. * Gets the tags available on a given object
  5123. * @param obj defines the object to use
  5124. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5125. * @returns the tags
  5126. */
  5127. static GetTags(obj: any, asString?: boolean): any;
  5128. /**
  5129. * Adds tags to an object
  5130. * @param obj defines the object to use
  5131. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5132. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5133. */
  5134. static AddTagsTo(obj: any, tagsString: string): void;
  5135. /**
  5136. * @hidden
  5137. */
  5138. static _AddTagTo(obj: any, tag: string): void;
  5139. /**
  5140. * Removes specific tags from a specific object
  5141. * @param obj defines the object to use
  5142. * @param tagsString defines the tags to remove
  5143. */
  5144. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5145. /**
  5146. * @hidden
  5147. */
  5148. static _RemoveTagFrom(obj: any, tag: string): void;
  5149. /**
  5150. * Defines if tags hosted on an object match a given query
  5151. * @param obj defines the object to use
  5152. * @param tagsQuery defines the tag query
  5153. * @returns a boolean
  5154. */
  5155. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5156. }
  5157. }
  5158. declare module BABYLON {
  5159. /**
  5160. * Manages the defines for the Material
  5161. */
  5162. export class MaterialDefines {
  5163. /** @hidden */
  5164. protected _keys: string[];
  5165. private _isDirty;
  5166. /** @hidden */
  5167. _renderId: number;
  5168. /** @hidden */
  5169. _areLightsDirty: boolean;
  5170. /** @hidden */
  5171. _areAttributesDirty: boolean;
  5172. /** @hidden */
  5173. _areTexturesDirty: boolean;
  5174. /** @hidden */
  5175. _areFresnelDirty: boolean;
  5176. /** @hidden */
  5177. _areMiscDirty: boolean;
  5178. /** @hidden */
  5179. _areImageProcessingDirty: boolean;
  5180. /** @hidden */
  5181. _normals: boolean;
  5182. /** @hidden */
  5183. _uvs: boolean;
  5184. /** @hidden */
  5185. _needNormals: boolean;
  5186. /** @hidden */
  5187. _needUVs: boolean;
  5188. [id: string]: any;
  5189. /**
  5190. * Specifies if the material needs to be re-calculated
  5191. */
  5192. readonly isDirty: boolean;
  5193. /**
  5194. * Marks the material to indicate that it has been re-calculated
  5195. */
  5196. markAsProcessed(): void;
  5197. /**
  5198. * Marks the material to indicate that it needs to be re-calculated
  5199. */
  5200. markAsUnprocessed(): void;
  5201. /**
  5202. * Marks the material to indicate all of its defines need to be re-calculated
  5203. */
  5204. markAllAsDirty(): void;
  5205. /**
  5206. * Marks the material to indicate that image processing needs to be re-calculated
  5207. */
  5208. markAsImageProcessingDirty(): void;
  5209. /**
  5210. * Marks the material to indicate the lights need to be re-calculated
  5211. */
  5212. markAsLightDirty(): void;
  5213. /**
  5214. * Marks the attribute state as changed
  5215. */
  5216. markAsAttributesDirty(): void;
  5217. /**
  5218. * Marks the texture state as changed
  5219. */
  5220. markAsTexturesDirty(): void;
  5221. /**
  5222. * Marks the fresnel state as changed
  5223. */
  5224. markAsFresnelDirty(): void;
  5225. /**
  5226. * Marks the misc state as changed
  5227. */
  5228. markAsMiscDirty(): void;
  5229. /**
  5230. * Rebuilds the material defines
  5231. */
  5232. rebuild(): void;
  5233. /**
  5234. * Specifies if two material defines are equal
  5235. * @param other - A material define instance to compare to
  5236. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5237. */
  5238. isEqual(other: MaterialDefines): boolean;
  5239. /**
  5240. * Clones this instance's defines to another instance
  5241. * @param other - material defines to clone values to
  5242. */
  5243. cloneTo(other: MaterialDefines): void;
  5244. /**
  5245. * Resets the material define values
  5246. */
  5247. reset(): void;
  5248. /**
  5249. * Converts the material define values to a string
  5250. * @returns - String of material define information
  5251. */
  5252. toString(): string;
  5253. }
  5254. }
  5255. declare module BABYLON {
  5256. /**
  5257. * Class used to store and describe the pipeline context associated with an effect
  5258. */
  5259. export interface IPipelineContext {
  5260. /**
  5261. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5262. */
  5263. isAsync: boolean;
  5264. /**
  5265. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5266. */
  5267. isReady: boolean;
  5268. /** @hidden */
  5269. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5270. }
  5271. }
  5272. declare module BABYLON {
  5273. /**
  5274. * Class used to store gfx data (like WebGLBuffer)
  5275. */
  5276. export class DataBuffer {
  5277. /**
  5278. * Gets or sets the number of objects referencing this buffer
  5279. */
  5280. references: number;
  5281. /** Gets or sets the size of the underlying buffer */
  5282. capacity: number;
  5283. /**
  5284. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5285. */
  5286. is32Bits: boolean;
  5287. /**
  5288. * Gets the underlying buffer
  5289. */
  5290. readonly underlyingResource: any;
  5291. }
  5292. }
  5293. declare module BABYLON {
  5294. /** @hidden */
  5295. export interface IShaderProcessor {
  5296. attributeProcessor?: (attribute: string) => string;
  5297. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5298. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5299. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5300. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5301. lineProcessor?: (line: string, isFragment: boolean) => string;
  5302. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5303. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5304. }
  5305. }
  5306. declare module BABYLON {
  5307. /** @hidden */
  5308. export interface ProcessingOptions {
  5309. defines: string[];
  5310. indexParameters: any;
  5311. isFragment: boolean;
  5312. shouldUseHighPrecisionShader: boolean;
  5313. supportsUniformBuffers: boolean;
  5314. shadersRepository: string;
  5315. includesShadersStore: {
  5316. [key: string]: string;
  5317. };
  5318. processor?: IShaderProcessor;
  5319. version: string;
  5320. platformName: string;
  5321. lookForClosingBracketForUniformBuffer?: boolean;
  5322. }
  5323. }
  5324. declare module BABYLON {
  5325. /** @hidden */
  5326. export class ShaderCodeNode {
  5327. line: string;
  5328. children: ShaderCodeNode[];
  5329. additionalDefineKey?: string;
  5330. additionalDefineValue?: string;
  5331. isValid(preprocessors: {
  5332. [key: string]: string;
  5333. }): boolean;
  5334. process(preprocessors: {
  5335. [key: string]: string;
  5336. }, options: ProcessingOptions): string;
  5337. }
  5338. }
  5339. declare module BABYLON {
  5340. /** @hidden */
  5341. export class ShaderCodeCursor {
  5342. private _lines;
  5343. lineIndex: number;
  5344. readonly currentLine: string;
  5345. readonly canRead: boolean;
  5346. lines: string[];
  5347. }
  5348. }
  5349. declare module BABYLON {
  5350. /** @hidden */
  5351. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5352. process(preprocessors: {
  5353. [key: string]: string;
  5354. }, options: ProcessingOptions): string;
  5355. }
  5356. }
  5357. declare module BABYLON {
  5358. /** @hidden */
  5359. export class ShaderDefineExpression {
  5360. isTrue(preprocessors: {
  5361. [key: string]: string;
  5362. }): boolean;
  5363. }
  5364. }
  5365. declare module BABYLON {
  5366. /** @hidden */
  5367. export class ShaderCodeTestNode extends ShaderCodeNode {
  5368. testExpression: ShaderDefineExpression;
  5369. isValid(preprocessors: {
  5370. [key: string]: string;
  5371. }): boolean;
  5372. }
  5373. }
  5374. declare module BABYLON {
  5375. /** @hidden */
  5376. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5377. define: string;
  5378. not: boolean;
  5379. constructor(define: string, not?: boolean);
  5380. isTrue(preprocessors: {
  5381. [key: string]: string;
  5382. }): boolean;
  5383. }
  5384. }
  5385. declare module BABYLON {
  5386. /** @hidden */
  5387. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5388. leftOperand: ShaderDefineExpression;
  5389. rightOperand: ShaderDefineExpression;
  5390. isTrue(preprocessors: {
  5391. [key: string]: string;
  5392. }): boolean;
  5393. }
  5394. }
  5395. declare module BABYLON {
  5396. /** @hidden */
  5397. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5398. leftOperand: ShaderDefineExpression;
  5399. rightOperand: ShaderDefineExpression;
  5400. isTrue(preprocessors: {
  5401. [key: string]: string;
  5402. }): boolean;
  5403. }
  5404. }
  5405. declare module BABYLON {
  5406. /** @hidden */
  5407. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5408. define: string;
  5409. operand: string;
  5410. testValue: string;
  5411. constructor(define: string, operand: string, testValue: string);
  5412. isTrue(preprocessors: {
  5413. [key: string]: string;
  5414. }): boolean;
  5415. }
  5416. }
  5417. declare module BABYLON {
  5418. /** @hidden */
  5419. export class ShaderProcessor {
  5420. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5421. private static _ProcessPrecision;
  5422. private static _ExtractOperation;
  5423. private static _BuildSubExpression;
  5424. private static _BuildExpression;
  5425. private static _MoveCursorWithinIf;
  5426. private static _MoveCursor;
  5427. private static _EvaluatePreProcessors;
  5428. private static _PreparePreProcessors;
  5429. private static _ProcessShaderConversion;
  5430. private static _ProcessIncludes;
  5431. }
  5432. }
  5433. declare module BABYLON {
  5434. /**
  5435. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5436. */
  5437. export class PerformanceMonitor {
  5438. private _enabled;
  5439. private _rollingFrameTime;
  5440. private _lastFrameTimeMs;
  5441. /**
  5442. * constructor
  5443. * @param frameSampleSize The number of samples required to saturate the sliding window
  5444. */
  5445. constructor(frameSampleSize?: number);
  5446. /**
  5447. * Samples current frame
  5448. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5449. */
  5450. sampleFrame(timeMs?: number): void;
  5451. /**
  5452. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5453. */
  5454. readonly averageFrameTime: number;
  5455. /**
  5456. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5457. */
  5458. readonly averageFrameTimeVariance: number;
  5459. /**
  5460. * Returns the frame time of the most recent frame
  5461. */
  5462. readonly instantaneousFrameTime: number;
  5463. /**
  5464. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5465. */
  5466. readonly averageFPS: number;
  5467. /**
  5468. * Returns the average framerate in frames per second using the most recent frame time
  5469. */
  5470. readonly instantaneousFPS: number;
  5471. /**
  5472. * Returns true if enough samples have been taken to completely fill the sliding window
  5473. */
  5474. readonly isSaturated: boolean;
  5475. /**
  5476. * Enables contributions to the sliding window sample set
  5477. */
  5478. enable(): void;
  5479. /**
  5480. * Disables contributions to the sliding window sample set
  5481. * Samples will not be interpolated over the disabled period
  5482. */
  5483. disable(): void;
  5484. /**
  5485. * Returns true if sampling is enabled
  5486. */
  5487. readonly isEnabled: boolean;
  5488. /**
  5489. * Resets performance monitor
  5490. */
  5491. reset(): void;
  5492. }
  5493. /**
  5494. * RollingAverage
  5495. *
  5496. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5497. */
  5498. export class RollingAverage {
  5499. /**
  5500. * Current average
  5501. */
  5502. average: number;
  5503. /**
  5504. * Current variance
  5505. */
  5506. variance: number;
  5507. protected _samples: Array<number>;
  5508. protected _sampleCount: number;
  5509. protected _pos: number;
  5510. protected _m2: number;
  5511. /**
  5512. * constructor
  5513. * @param length The number of samples required to saturate the sliding window
  5514. */
  5515. constructor(length: number);
  5516. /**
  5517. * Adds a sample to the sample set
  5518. * @param v The sample value
  5519. */
  5520. add(v: number): void;
  5521. /**
  5522. * Returns previously added values or null if outside of history or outside the sliding window domain
  5523. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5524. * @return Value previously recorded with add() or null if outside of range
  5525. */
  5526. history(i: number): number;
  5527. /**
  5528. * Returns true if enough samples have been taken to completely fill the sliding window
  5529. * @return true if sample-set saturated
  5530. */
  5531. isSaturated(): boolean;
  5532. /**
  5533. * Resets the rolling average (equivalent to 0 samples taken so far)
  5534. */
  5535. reset(): void;
  5536. /**
  5537. * Wraps a value around the sample range boundaries
  5538. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5539. * @return Wrapped position in sample range
  5540. */
  5541. protected _wrapPosition(i: number): number;
  5542. }
  5543. }
  5544. declare module BABYLON {
  5545. /**
  5546. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5547. * The underlying implementation relies on an associative array to ensure the best performances.
  5548. * The value can be anything including 'null' but except 'undefined'
  5549. */
  5550. export class StringDictionary<T> {
  5551. /**
  5552. * This will clear this dictionary and copy the content from the 'source' one.
  5553. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5554. * @param source the dictionary to take the content from and copy to this dictionary
  5555. */
  5556. copyFrom(source: StringDictionary<T>): void;
  5557. /**
  5558. * Get a value based from its key
  5559. * @param key the given key to get the matching value from
  5560. * @return the value if found, otherwise undefined is returned
  5561. */
  5562. get(key: string): T | undefined;
  5563. /**
  5564. * Get a value from its key or add it if it doesn't exist.
  5565. * This method will ensure you that a given key/data will be present in the dictionary.
  5566. * @param key the given key to get the matching value from
  5567. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5568. * The factory will only be invoked if there's no data for the given key.
  5569. * @return the value corresponding to the key.
  5570. */
  5571. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5572. /**
  5573. * Get a value from its key if present in the dictionary otherwise add it
  5574. * @param key the key to get the value from
  5575. * @param val if there's no such key/value pair in the dictionary add it with this value
  5576. * @return the value corresponding to the key
  5577. */
  5578. getOrAdd(key: string, val: T): T;
  5579. /**
  5580. * Check if there's a given key in the dictionary
  5581. * @param key the key to check for
  5582. * @return true if the key is present, false otherwise
  5583. */
  5584. contains(key: string): boolean;
  5585. /**
  5586. * Add a new key and its corresponding value
  5587. * @param key the key to add
  5588. * @param value the value corresponding to the key
  5589. * @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
  5590. */
  5591. add(key: string, value: T): boolean;
  5592. /**
  5593. * Update a specific value associated to a key
  5594. * @param key defines the key to use
  5595. * @param value defines the value to store
  5596. * @returns true if the value was updated (or false if the key was not found)
  5597. */
  5598. set(key: string, value: T): boolean;
  5599. /**
  5600. * Get the element of the given key and remove it from the dictionary
  5601. * @param key defines the key to search
  5602. * @returns the value associated with the key or null if not found
  5603. */
  5604. getAndRemove(key: string): Nullable<T>;
  5605. /**
  5606. * Remove a key/value from the dictionary.
  5607. * @param key the key to remove
  5608. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5609. */
  5610. remove(key: string): boolean;
  5611. /**
  5612. * Clear the whole content of the dictionary
  5613. */
  5614. clear(): void;
  5615. /**
  5616. * Gets the current count
  5617. */
  5618. readonly count: number;
  5619. /**
  5620. * Execute a callback on each key/val of the dictionary.
  5621. * Note that you can remove any element in this dictionary in the callback implementation
  5622. * @param callback the callback to execute on a given key/value pair
  5623. */
  5624. forEach(callback: (key: string, val: T) => void): void;
  5625. /**
  5626. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5627. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5628. * Note that you can remove any element in this dictionary in the callback implementation
  5629. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5630. * @returns the first item
  5631. */
  5632. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5633. private _count;
  5634. private _data;
  5635. }
  5636. }
  5637. declare module BABYLON {
  5638. /**
  5639. * Helper class that provides a small promise polyfill
  5640. */
  5641. export class PromisePolyfill {
  5642. /**
  5643. * Static function used to check if the polyfill is required
  5644. * If this is the case then the function will inject the polyfill to window.Promise
  5645. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5646. */
  5647. static Apply(force?: boolean): void;
  5648. }
  5649. }
  5650. declare module BABYLON {
  5651. /**
  5652. * Class used to store data that will be store in GPU memory
  5653. */
  5654. export class Buffer {
  5655. private _engine;
  5656. private _buffer;
  5657. /** @hidden */
  5658. _data: Nullable<DataArray>;
  5659. private _updatable;
  5660. private _instanced;
  5661. /**
  5662. * Gets the byte stride.
  5663. */
  5664. readonly byteStride: number;
  5665. /**
  5666. * Constructor
  5667. * @param engine the engine
  5668. * @param data the data to use for this buffer
  5669. * @param updatable whether the data is updatable
  5670. * @param stride the stride (optional)
  5671. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5672. * @param instanced whether the buffer is instanced (optional)
  5673. * @param useBytes set to true if the stride in in bytes (optional)
  5674. */
  5675. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5676. /**
  5677. * Create a new VertexBuffer based on the current buffer
  5678. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5679. * @param offset defines offset in the buffer (0 by default)
  5680. * @param size defines the size in floats of attributes (position is 3 for instance)
  5681. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5682. * @param instanced defines if the vertex buffer contains indexed data
  5683. * @param useBytes defines if the offset and stride are in bytes
  5684. * @returns the new vertex buffer
  5685. */
  5686. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5687. /**
  5688. * Gets a boolean indicating if the Buffer is updatable?
  5689. * @returns true if the buffer is updatable
  5690. */
  5691. isUpdatable(): boolean;
  5692. /**
  5693. * Gets current buffer's data
  5694. * @returns a DataArray or null
  5695. */
  5696. getData(): Nullable<DataArray>;
  5697. /**
  5698. * Gets underlying native buffer
  5699. * @returns underlying native buffer
  5700. */
  5701. getBuffer(): Nullable<DataBuffer>;
  5702. /**
  5703. * Gets the stride in float32 units (i.e. byte stride / 4).
  5704. * May not be an integer if the byte stride is not divisible by 4.
  5705. * DEPRECATED. Use byteStride instead.
  5706. * @returns the stride in float32 units
  5707. */
  5708. getStrideSize(): number;
  5709. /**
  5710. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5711. * @param data defines the data to store
  5712. */
  5713. create(data?: Nullable<DataArray>): void;
  5714. /** @hidden */
  5715. _rebuild(): void;
  5716. /**
  5717. * Update current buffer data
  5718. * @param data defines the data to store
  5719. */
  5720. update(data: DataArray): void;
  5721. /**
  5722. * Updates the data directly.
  5723. * @param data the new data
  5724. * @param offset the new offset
  5725. * @param vertexCount the vertex count (optional)
  5726. * @param useBytes set to true if the offset is in bytes
  5727. */
  5728. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5729. /**
  5730. * Release all resources
  5731. */
  5732. dispose(): void;
  5733. }
  5734. /**
  5735. * Specialized buffer used to store vertex data
  5736. */
  5737. export class VertexBuffer {
  5738. /** @hidden */
  5739. _buffer: Buffer;
  5740. private _kind;
  5741. private _size;
  5742. private _ownsBuffer;
  5743. private _instanced;
  5744. private _instanceDivisor;
  5745. /**
  5746. * The byte type.
  5747. */
  5748. static readonly BYTE: number;
  5749. /**
  5750. * The unsigned byte type.
  5751. */
  5752. static readonly UNSIGNED_BYTE: number;
  5753. /**
  5754. * The short type.
  5755. */
  5756. static readonly SHORT: number;
  5757. /**
  5758. * The unsigned short type.
  5759. */
  5760. static readonly UNSIGNED_SHORT: number;
  5761. /**
  5762. * The integer type.
  5763. */
  5764. static readonly INT: number;
  5765. /**
  5766. * The unsigned integer type.
  5767. */
  5768. static readonly UNSIGNED_INT: number;
  5769. /**
  5770. * The float type.
  5771. */
  5772. static readonly FLOAT: number;
  5773. /**
  5774. * Gets or sets the instance divisor when in instanced mode
  5775. */
  5776. instanceDivisor: number;
  5777. /**
  5778. * Gets the byte stride.
  5779. */
  5780. readonly byteStride: number;
  5781. /**
  5782. * Gets the byte offset.
  5783. */
  5784. readonly byteOffset: number;
  5785. /**
  5786. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5787. */
  5788. readonly normalized: boolean;
  5789. /**
  5790. * Gets the data type of each component in the array.
  5791. */
  5792. readonly type: number;
  5793. /**
  5794. * Constructor
  5795. * @param engine the engine
  5796. * @param data the data to use for this vertex buffer
  5797. * @param kind the vertex buffer kind
  5798. * @param updatable whether the data is updatable
  5799. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5800. * @param stride the stride (optional)
  5801. * @param instanced whether the buffer is instanced (optional)
  5802. * @param offset the offset of the data (optional)
  5803. * @param size the number of components (optional)
  5804. * @param type the type of the component (optional)
  5805. * @param normalized whether the data contains normalized data (optional)
  5806. * @param useBytes set to true if stride and offset are in bytes (optional)
  5807. */
  5808. 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);
  5809. /** @hidden */
  5810. _rebuild(): void;
  5811. /**
  5812. * Returns the kind of the VertexBuffer (string)
  5813. * @returns a string
  5814. */
  5815. getKind(): string;
  5816. /**
  5817. * Gets a boolean indicating if the VertexBuffer is updatable?
  5818. * @returns true if the buffer is updatable
  5819. */
  5820. isUpdatable(): boolean;
  5821. /**
  5822. * Gets current buffer's data
  5823. * @returns a DataArray or null
  5824. */
  5825. getData(): Nullable<DataArray>;
  5826. /**
  5827. * Gets underlying native buffer
  5828. * @returns underlying native buffer
  5829. */
  5830. getBuffer(): Nullable<DataBuffer>;
  5831. /**
  5832. * Gets the stride in float32 units (i.e. byte stride / 4).
  5833. * May not be an integer if the byte stride is not divisible by 4.
  5834. * DEPRECATED. Use byteStride instead.
  5835. * @returns the stride in float32 units
  5836. */
  5837. getStrideSize(): number;
  5838. /**
  5839. * Returns the offset as a multiple of the type byte length.
  5840. * DEPRECATED. Use byteOffset instead.
  5841. * @returns the offset in bytes
  5842. */
  5843. getOffset(): number;
  5844. /**
  5845. * Returns the number of components per vertex attribute (integer)
  5846. * @returns the size in float
  5847. */
  5848. getSize(): number;
  5849. /**
  5850. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5851. * @returns true if this buffer is instanced
  5852. */
  5853. getIsInstanced(): boolean;
  5854. /**
  5855. * Returns the instancing divisor, zero for non-instanced (integer).
  5856. * @returns a number
  5857. */
  5858. getInstanceDivisor(): number;
  5859. /**
  5860. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5861. * @param data defines the data to store
  5862. */
  5863. create(data?: DataArray): void;
  5864. /**
  5865. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5866. * This function will create a new buffer if the current one is not updatable
  5867. * @param data defines the data to store
  5868. */
  5869. update(data: DataArray): void;
  5870. /**
  5871. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5872. * Returns the directly updated WebGLBuffer.
  5873. * @param data the new data
  5874. * @param offset the new offset
  5875. * @param useBytes set to true if the offset is in bytes
  5876. */
  5877. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5878. /**
  5879. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5880. */
  5881. dispose(): void;
  5882. /**
  5883. * Enumerates each value of this vertex buffer as numbers.
  5884. * @param count the number of values to enumerate
  5885. * @param callback the callback function called for each value
  5886. */
  5887. forEach(count: number, callback: (value: number, index: number) => void): void;
  5888. /**
  5889. * Positions
  5890. */
  5891. static readonly PositionKind: string;
  5892. /**
  5893. * Normals
  5894. */
  5895. static readonly NormalKind: string;
  5896. /**
  5897. * Tangents
  5898. */
  5899. static readonly TangentKind: string;
  5900. /**
  5901. * Texture coordinates
  5902. */
  5903. static readonly UVKind: string;
  5904. /**
  5905. * Texture coordinates 2
  5906. */
  5907. static readonly UV2Kind: string;
  5908. /**
  5909. * Texture coordinates 3
  5910. */
  5911. static readonly UV3Kind: string;
  5912. /**
  5913. * Texture coordinates 4
  5914. */
  5915. static readonly UV4Kind: string;
  5916. /**
  5917. * Texture coordinates 5
  5918. */
  5919. static readonly UV5Kind: string;
  5920. /**
  5921. * Texture coordinates 6
  5922. */
  5923. static readonly UV6Kind: string;
  5924. /**
  5925. * Colors
  5926. */
  5927. static readonly ColorKind: string;
  5928. /**
  5929. * Matrix indices (for bones)
  5930. */
  5931. static readonly MatricesIndicesKind: string;
  5932. /**
  5933. * Matrix weights (for bones)
  5934. */
  5935. static readonly MatricesWeightsKind: string;
  5936. /**
  5937. * Additional matrix indices (for bones)
  5938. */
  5939. static readonly MatricesIndicesExtraKind: string;
  5940. /**
  5941. * Additional matrix weights (for bones)
  5942. */
  5943. static readonly MatricesWeightsExtraKind: string;
  5944. /**
  5945. * Deduces the stride given a kind.
  5946. * @param kind The kind string to deduce
  5947. * @returns The deduced stride
  5948. */
  5949. static DeduceStride(kind: string): number;
  5950. /**
  5951. * Gets the byte length of the given type.
  5952. * @param type the type
  5953. * @returns the number of bytes
  5954. */
  5955. static GetTypeByteLength(type: number): number;
  5956. /**
  5957. * Enumerates each value of the given parameters as numbers.
  5958. * @param data the data to enumerate
  5959. * @param byteOffset the byte offset of the data
  5960. * @param byteStride the byte stride of the data
  5961. * @param componentCount the number of components per element
  5962. * @param componentType the type of the component
  5963. * @param count the number of values to enumerate
  5964. * @param normalized whether the data is normalized
  5965. * @param callback the callback function called for each value
  5966. */
  5967. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5968. private static _GetFloatValue;
  5969. }
  5970. }
  5971. declare module BABYLON {
  5972. /**
  5973. * Class representing spherical harmonics coefficients to the 3rd degree
  5974. */
  5975. export class SphericalHarmonics {
  5976. /**
  5977. * Defines whether or not the harmonics have been prescaled for rendering.
  5978. */
  5979. preScaled: boolean;
  5980. /**
  5981. * The l0,0 coefficients of the spherical harmonics
  5982. */
  5983. l00: Vector3;
  5984. /**
  5985. * The l1,-1 coefficients of the spherical harmonics
  5986. */
  5987. l1_1: Vector3;
  5988. /**
  5989. * The l1,0 coefficients of the spherical harmonics
  5990. */
  5991. l10: Vector3;
  5992. /**
  5993. * The l1,1 coefficients of the spherical harmonics
  5994. */
  5995. l11: Vector3;
  5996. /**
  5997. * The l2,-2 coefficients of the spherical harmonics
  5998. */
  5999. l2_2: Vector3;
  6000. /**
  6001. * The l2,-1 coefficients of the spherical harmonics
  6002. */
  6003. l2_1: Vector3;
  6004. /**
  6005. * The l2,0 coefficients of the spherical harmonics
  6006. */
  6007. l20: Vector3;
  6008. /**
  6009. * The l2,1 coefficients of the spherical harmonics
  6010. */
  6011. l21: Vector3;
  6012. /**
  6013. * The l2,2 coefficients of the spherical harmonics
  6014. */
  6015. l22: Vector3;
  6016. /**
  6017. * Adds a light to the spherical harmonics
  6018. * @param direction the direction of the light
  6019. * @param color the color of the light
  6020. * @param deltaSolidAngle the delta solid angle of the light
  6021. */
  6022. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6023. /**
  6024. * Scales the spherical harmonics by the given amount
  6025. * @param scale the amount to scale
  6026. */
  6027. scaleInPlace(scale: number): void;
  6028. /**
  6029. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6030. *
  6031. * ```
  6032. * E_lm = A_l * L_lm
  6033. * ```
  6034. *
  6035. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6036. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6037. * the scaling factors are given in equation 9.
  6038. */
  6039. convertIncidentRadianceToIrradiance(): void;
  6040. /**
  6041. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6042. *
  6043. * ```
  6044. * L = (1/pi) * E * rho
  6045. * ```
  6046. *
  6047. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6048. */
  6049. convertIrradianceToLambertianRadiance(): void;
  6050. /**
  6051. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6052. * required operations at run time.
  6053. *
  6054. * This is simply done by scaling back the SH with Ylm constants parameter.
  6055. * The trigonometric part being applied by the shader at run time.
  6056. */
  6057. preScaleForRendering(): void;
  6058. /**
  6059. * Constructs a spherical harmonics from an array.
  6060. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6061. * @returns the spherical harmonics
  6062. */
  6063. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6064. /**
  6065. * Gets the spherical harmonics from polynomial
  6066. * @param polynomial the spherical polynomial
  6067. * @returns the spherical harmonics
  6068. */
  6069. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6070. }
  6071. /**
  6072. * Class representing spherical polynomial coefficients to the 3rd degree
  6073. */
  6074. export class SphericalPolynomial {
  6075. private _harmonics;
  6076. /**
  6077. * The spherical harmonics used to create the polynomials.
  6078. */
  6079. readonly preScaledHarmonics: SphericalHarmonics;
  6080. /**
  6081. * The x coefficients of the spherical polynomial
  6082. */
  6083. x: Vector3;
  6084. /**
  6085. * The y coefficients of the spherical polynomial
  6086. */
  6087. y: Vector3;
  6088. /**
  6089. * The z coefficients of the spherical polynomial
  6090. */
  6091. z: Vector3;
  6092. /**
  6093. * The xx coefficients of the spherical polynomial
  6094. */
  6095. xx: Vector3;
  6096. /**
  6097. * The yy coefficients of the spherical polynomial
  6098. */
  6099. yy: Vector3;
  6100. /**
  6101. * The zz coefficients of the spherical polynomial
  6102. */
  6103. zz: Vector3;
  6104. /**
  6105. * The xy coefficients of the spherical polynomial
  6106. */
  6107. xy: Vector3;
  6108. /**
  6109. * The yz coefficients of the spherical polynomial
  6110. */
  6111. yz: Vector3;
  6112. /**
  6113. * The zx coefficients of the spherical polynomial
  6114. */
  6115. zx: Vector3;
  6116. /**
  6117. * Adds an ambient color to the spherical polynomial
  6118. * @param color the color to add
  6119. */
  6120. addAmbient(color: Color3): void;
  6121. /**
  6122. * Scales the spherical polynomial by the given amount
  6123. * @param scale the amount to scale
  6124. */
  6125. scaleInPlace(scale: number): void;
  6126. /**
  6127. * Gets the spherical polynomial from harmonics
  6128. * @param harmonics the spherical harmonics
  6129. * @returns the spherical polynomial
  6130. */
  6131. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6132. /**
  6133. * Constructs a spherical polynomial from an array.
  6134. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6135. * @returns the spherical polynomial
  6136. */
  6137. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6138. }
  6139. }
  6140. declare module BABYLON {
  6141. /**
  6142. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6143. */
  6144. export interface CubeMapInfo {
  6145. /**
  6146. * The pixel array for the front face.
  6147. * This is stored in format, left to right, up to down format.
  6148. */
  6149. front: Nullable<ArrayBufferView>;
  6150. /**
  6151. * The pixel array for the back face.
  6152. * This is stored in format, left to right, up to down format.
  6153. */
  6154. back: Nullable<ArrayBufferView>;
  6155. /**
  6156. * The pixel array for the left face.
  6157. * This is stored in format, left to right, up to down format.
  6158. */
  6159. left: Nullable<ArrayBufferView>;
  6160. /**
  6161. * The pixel array for the right face.
  6162. * This is stored in format, left to right, up to down format.
  6163. */
  6164. right: Nullable<ArrayBufferView>;
  6165. /**
  6166. * The pixel array for the up face.
  6167. * This is stored in format, left to right, up to down format.
  6168. */
  6169. up: Nullable<ArrayBufferView>;
  6170. /**
  6171. * The pixel array for the down face.
  6172. * This is stored in format, left to right, up to down format.
  6173. */
  6174. down: Nullable<ArrayBufferView>;
  6175. /**
  6176. * The size of the cubemap stored.
  6177. *
  6178. * Each faces will be size * size pixels.
  6179. */
  6180. size: number;
  6181. /**
  6182. * The format of the texture.
  6183. *
  6184. * RGBA, RGB.
  6185. */
  6186. format: number;
  6187. /**
  6188. * The type of the texture data.
  6189. *
  6190. * UNSIGNED_INT, FLOAT.
  6191. */
  6192. type: number;
  6193. /**
  6194. * Specifies whether the texture is in gamma space.
  6195. */
  6196. gammaSpace: boolean;
  6197. }
  6198. /**
  6199. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6200. */
  6201. export class PanoramaToCubeMapTools {
  6202. private static FACE_FRONT;
  6203. private static FACE_BACK;
  6204. private static FACE_RIGHT;
  6205. private static FACE_LEFT;
  6206. private static FACE_DOWN;
  6207. private static FACE_UP;
  6208. /**
  6209. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6210. *
  6211. * @param float32Array The source data.
  6212. * @param inputWidth The width of the input panorama.
  6213. * @param inputHeight The height of the input panorama.
  6214. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6215. * @return The cubemap data
  6216. */
  6217. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6218. private static CreateCubemapTexture;
  6219. private static CalcProjectionSpherical;
  6220. }
  6221. }
  6222. declare module BABYLON {
  6223. /**
  6224. * Helper class dealing with the extraction of spherical polynomial dataArray
  6225. * from a cube map.
  6226. */
  6227. export class CubeMapToSphericalPolynomialTools {
  6228. private static FileFaces;
  6229. /**
  6230. * Converts a texture to the according Spherical Polynomial data.
  6231. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6232. *
  6233. * @param texture The texture to extract the information from.
  6234. * @return The Spherical Polynomial data.
  6235. */
  6236. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6237. /**
  6238. * Converts a cubemap to the according Spherical Polynomial data.
  6239. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6240. *
  6241. * @param cubeInfo The Cube map to extract the information from.
  6242. * @return The Spherical Polynomial data.
  6243. */
  6244. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6245. }
  6246. }
  6247. declare module BABYLON {
  6248. /**
  6249. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6250. * during the life time of the application.
  6251. */
  6252. export class EngineStore {
  6253. /** Gets the list of created engines */
  6254. static Instances: Engine[];
  6255. /** @hidden */
  6256. static _LastCreatedScene: Nullable<Scene>;
  6257. /**
  6258. * Gets the latest created engine
  6259. */
  6260. static readonly LastCreatedEngine: Nullable<Engine>;
  6261. /**
  6262. * Gets the latest created scene
  6263. */
  6264. static readonly LastCreatedScene: Nullable<Scene>;
  6265. }
  6266. }
  6267. declare module BABYLON {
  6268. /**
  6269. * Define options used to create a render target texture
  6270. */
  6271. export class RenderTargetCreationOptions {
  6272. /**
  6273. * Specifies is mipmaps must be generated
  6274. */
  6275. generateMipMaps?: boolean;
  6276. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6277. generateDepthBuffer?: boolean;
  6278. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6279. generateStencilBuffer?: boolean;
  6280. /** Defines texture type (int by default) */
  6281. type?: number;
  6282. /** Defines sampling mode (trilinear by default) */
  6283. samplingMode?: number;
  6284. /** Defines format (RGBA by default) */
  6285. format?: number;
  6286. }
  6287. }
  6288. declare module BABYLON {
  6289. /**
  6290. * @hidden
  6291. **/
  6292. export class _AlphaState {
  6293. private _isAlphaBlendDirty;
  6294. private _isBlendFunctionParametersDirty;
  6295. private _isBlendEquationParametersDirty;
  6296. private _isBlendConstantsDirty;
  6297. private _alphaBlend;
  6298. private _blendFunctionParameters;
  6299. private _blendEquationParameters;
  6300. private _blendConstants;
  6301. /**
  6302. * Initializes the state.
  6303. */
  6304. constructor();
  6305. readonly isDirty: boolean;
  6306. alphaBlend: boolean;
  6307. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6308. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6309. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6310. reset(): void;
  6311. apply(gl: WebGLRenderingContext): void;
  6312. }
  6313. }
  6314. declare module BABYLON {
  6315. /**
  6316. * @hidden
  6317. **/
  6318. export class _DepthCullingState {
  6319. private _isDepthTestDirty;
  6320. private _isDepthMaskDirty;
  6321. private _isDepthFuncDirty;
  6322. private _isCullFaceDirty;
  6323. private _isCullDirty;
  6324. private _isZOffsetDirty;
  6325. private _isFrontFaceDirty;
  6326. private _depthTest;
  6327. private _depthMask;
  6328. private _depthFunc;
  6329. private _cull;
  6330. private _cullFace;
  6331. private _zOffset;
  6332. private _frontFace;
  6333. /**
  6334. * Initializes the state.
  6335. */
  6336. constructor();
  6337. readonly isDirty: boolean;
  6338. zOffset: number;
  6339. cullFace: Nullable<number>;
  6340. cull: Nullable<boolean>;
  6341. depthFunc: Nullable<number>;
  6342. depthMask: boolean;
  6343. depthTest: boolean;
  6344. frontFace: Nullable<number>;
  6345. reset(): void;
  6346. apply(gl: WebGLRenderingContext): void;
  6347. }
  6348. }
  6349. declare module BABYLON {
  6350. /**
  6351. * @hidden
  6352. **/
  6353. export class _StencilState {
  6354. /** 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 */
  6355. static readonly ALWAYS: number;
  6356. /** Passed to stencilOperation to specify that stencil value must be kept */
  6357. static readonly KEEP: number;
  6358. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6359. static readonly REPLACE: number;
  6360. private _isStencilTestDirty;
  6361. private _isStencilMaskDirty;
  6362. private _isStencilFuncDirty;
  6363. private _isStencilOpDirty;
  6364. private _stencilTest;
  6365. private _stencilMask;
  6366. private _stencilFunc;
  6367. private _stencilFuncRef;
  6368. private _stencilFuncMask;
  6369. private _stencilOpStencilFail;
  6370. private _stencilOpDepthFail;
  6371. private _stencilOpStencilDepthPass;
  6372. readonly isDirty: boolean;
  6373. stencilFunc: number;
  6374. stencilFuncRef: number;
  6375. stencilFuncMask: number;
  6376. stencilOpStencilFail: number;
  6377. stencilOpDepthFail: number;
  6378. stencilOpStencilDepthPass: number;
  6379. stencilMask: number;
  6380. stencilTest: boolean;
  6381. constructor();
  6382. reset(): void;
  6383. apply(gl: WebGLRenderingContext): void;
  6384. }
  6385. }
  6386. declare module BABYLON {
  6387. /**
  6388. * @hidden
  6389. **/
  6390. export class _TimeToken {
  6391. _startTimeQuery: Nullable<WebGLQuery>;
  6392. _endTimeQuery: Nullable<WebGLQuery>;
  6393. _timeElapsedQuery: Nullable<WebGLQuery>;
  6394. _timeElapsedQueryEnded: boolean;
  6395. }
  6396. }
  6397. declare module BABYLON {
  6398. /**
  6399. * Class used to store data associated with WebGL texture data for the engine
  6400. * This class should not be used directly
  6401. */
  6402. export class InternalTexture {
  6403. /** @hidden */
  6404. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6405. /**
  6406. * The source of the texture data is unknown
  6407. */
  6408. static DATASOURCE_UNKNOWN: number;
  6409. /**
  6410. * Texture data comes from an URL
  6411. */
  6412. static DATASOURCE_URL: number;
  6413. /**
  6414. * Texture data is only used for temporary storage
  6415. */
  6416. static DATASOURCE_TEMP: number;
  6417. /**
  6418. * Texture data comes from raw data (ArrayBuffer)
  6419. */
  6420. static DATASOURCE_RAW: number;
  6421. /**
  6422. * Texture content is dynamic (video or dynamic texture)
  6423. */
  6424. static DATASOURCE_DYNAMIC: number;
  6425. /**
  6426. * Texture content is generated by rendering to it
  6427. */
  6428. static DATASOURCE_RENDERTARGET: number;
  6429. /**
  6430. * Texture content is part of a multi render target process
  6431. */
  6432. static DATASOURCE_MULTIRENDERTARGET: number;
  6433. /**
  6434. * Texture data comes from a cube data file
  6435. */
  6436. static DATASOURCE_CUBE: number;
  6437. /**
  6438. * Texture data comes from a raw cube data
  6439. */
  6440. static DATASOURCE_CUBERAW: number;
  6441. /**
  6442. * Texture data come from a prefiltered cube data file
  6443. */
  6444. static DATASOURCE_CUBEPREFILTERED: number;
  6445. /**
  6446. * Texture content is raw 3D data
  6447. */
  6448. static DATASOURCE_RAW3D: number;
  6449. /**
  6450. * Texture content is a depth texture
  6451. */
  6452. static DATASOURCE_DEPTHTEXTURE: number;
  6453. /**
  6454. * Texture data comes from a raw cube data encoded with RGBD
  6455. */
  6456. static DATASOURCE_CUBERAW_RGBD: number;
  6457. /**
  6458. * Defines if the texture is ready
  6459. */
  6460. isReady: boolean;
  6461. /**
  6462. * Defines if the texture is a cube texture
  6463. */
  6464. isCube: boolean;
  6465. /**
  6466. * Defines if the texture contains 3D data
  6467. */
  6468. is3D: boolean;
  6469. /**
  6470. * Defines if the texture contains multiview data
  6471. */
  6472. isMultiview: boolean;
  6473. /**
  6474. * Gets the URL used to load this texture
  6475. */
  6476. url: string;
  6477. /**
  6478. * Gets the sampling mode of the texture
  6479. */
  6480. samplingMode: number;
  6481. /**
  6482. * Gets a boolean indicating if the texture needs mipmaps generation
  6483. */
  6484. generateMipMaps: boolean;
  6485. /**
  6486. * Gets the number of samples used by the texture (WebGL2+ only)
  6487. */
  6488. samples: number;
  6489. /**
  6490. * Gets the type of the texture (int, float...)
  6491. */
  6492. type: number;
  6493. /**
  6494. * Gets the format of the texture (RGB, RGBA...)
  6495. */
  6496. format: number;
  6497. /**
  6498. * Observable called when the texture is loaded
  6499. */
  6500. onLoadedObservable: Observable<InternalTexture>;
  6501. /**
  6502. * Gets the width of the texture
  6503. */
  6504. width: number;
  6505. /**
  6506. * Gets the height of the texture
  6507. */
  6508. height: number;
  6509. /**
  6510. * Gets the depth of the texture
  6511. */
  6512. depth: number;
  6513. /**
  6514. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6515. */
  6516. baseWidth: number;
  6517. /**
  6518. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6519. */
  6520. baseHeight: number;
  6521. /**
  6522. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6523. */
  6524. baseDepth: number;
  6525. /**
  6526. * Gets a boolean indicating if the texture is inverted on Y axis
  6527. */
  6528. invertY: boolean;
  6529. /** @hidden */
  6530. _invertVScale: boolean;
  6531. /** @hidden */
  6532. _associatedChannel: number;
  6533. /** @hidden */
  6534. _dataSource: number;
  6535. /** @hidden */
  6536. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6537. /** @hidden */
  6538. _bufferView: Nullable<ArrayBufferView>;
  6539. /** @hidden */
  6540. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6541. /** @hidden */
  6542. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6543. /** @hidden */
  6544. _size: number;
  6545. /** @hidden */
  6546. _extension: string;
  6547. /** @hidden */
  6548. _files: Nullable<string[]>;
  6549. /** @hidden */
  6550. _workingCanvas: Nullable<HTMLCanvasElement>;
  6551. /** @hidden */
  6552. _workingContext: Nullable<CanvasRenderingContext2D>;
  6553. /** @hidden */
  6554. _framebuffer: Nullable<WebGLFramebuffer>;
  6555. /** @hidden */
  6556. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6557. /** @hidden */
  6558. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6559. /** @hidden */
  6560. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6561. /** @hidden */
  6562. _attachments: Nullable<number[]>;
  6563. /** @hidden */
  6564. _cachedCoordinatesMode: Nullable<number>;
  6565. /** @hidden */
  6566. _cachedWrapU: Nullable<number>;
  6567. /** @hidden */
  6568. _cachedWrapV: Nullable<number>;
  6569. /** @hidden */
  6570. _cachedWrapR: Nullable<number>;
  6571. /** @hidden */
  6572. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6573. /** @hidden */
  6574. _isDisabled: boolean;
  6575. /** @hidden */
  6576. _compression: Nullable<string>;
  6577. /** @hidden */
  6578. _generateStencilBuffer: boolean;
  6579. /** @hidden */
  6580. _generateDepthBuffer: boolean;
  6581. /** @hidden */
  6582. _comparisonFunction: number;
  6583. /** @hidden */
  6584. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6585. /** @hidden */
  6586. _lodGenerationScale: number;
  6587. /** @hidden */
  6588. _lodGenerationOffset: number;
  6589. /** @hidden */
  6590. _colorTextureArray: Nullable<WebGLTexture>;
  6591. /** @hidden */
  6592. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6593. /** @hidden */
  6594. _lodTextureHigh: Nullable<BaseTexture>;
  6595. /** @hidden */
  6596. _lodTextureMid: Nullable<BaseTexture>;
  6597. /** @hidden */
  6598. _lodTextureLow: Nullable<BaseTexture>;
  6599. /** @hidden */
  6600. _isRGBD: boolean;
  6601. /** @hidden */
  6602. _linearSpecularLOD: boolean;
  6603. /** @hidden */
  6604. _irradianceTexture: Nullable<BaseTexture>;
  6605. /** @hidden */
  6606. _webGLTexture: Nullable<WebGLTexture>;
  6607. /** @hidden */
  6608. _references: number;
  6609. private _engine;
  6610. /**
  6611. * Gets the Engine the texture belongs to.
  6612. * @returns The babylon engine
  6613. */
  6614. getEngine(): Engine;
  6615. /**
  6616. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6617. */
  6618. readonly dataSource: number;
  6619. /**
  6620. * Creates a new InternalTexture
  6621. * @param engine defines the engine to use
  6622. * @param dataSource defines the type of data that will be used
  6623. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6624. */
  6625. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6626. /**
  6627. * Increments the number of references (ie. the number of Texture that point to it)
  6628. */
  6629. incrementReferences(): void;
  6630. /**
  6631. * Change the size of the texture (not the size of the content)
  6632. * @param width defines the new width
  6633. * @param height defines the new height
  6634. * @param depth defines the new depth (1 by default)
  6635. */
  6636. updateSize(width: int, height: int, depth?: int): void;
  6637. /** @hidden */
  6638. _rebuild(): void;
  6639. /** @hidden */
  6640. _swapAndDie(target: InternalTexture): void;
  6641. /**
  6642. * Dispose the current allocated resources
  6643. */
  6644. dispose(): void;
  6645. }
  6646. }
  6647. declare module BABYLON {
  6648. /**
  6649. * This represents the main contract an easing function should follow.
  6650. * Easing functions are used throughout the animation system.
  6651. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6652. */
  6653. export interface IEasingFunction {
  6654. /**
  6655. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6656. * of the easing function.
  6657. * The link below provides some of the most common examples of easing functions.
  6658. * @see https://easings.net/
  6659. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6660. * @returns the corresponding value on the curve defined by the easing function
  6661. */
  6662. ease(gradient: number): number;
  6663. }
  6664. /**
  6665. * Base class used for every default easing function.
  6666. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6667. */
  6668. export class EasingFunction implements IEasingFunction {
  6669. /**
  6670. * Interpolation follows the mathematical formula associated with the easing function.
  6671. */
  6672. static readonly EASINGMODE_EASEIN: number;
  6673. /**
  6674. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6675. */
  6676. static readonly EASINGMODE_EASEOUT: number;
  6677. /**
  6678. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6679. */
  6680. static readonly EASINGMODE_EASEINOUT: number;
  6681. private _easingMode;
  6682. /**
  6683. * Sets the easing mode of the current function.
  6684. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6685. */
  6686. setEasingMode(easingMode: number): void;
  6687. /**
  6688. * Gets the current easing mode.
  6689. * @returns the easing mode
  6690. */
  6691. getEasingMode(): number;
  6692. /**
  6693. * @hidden
  6694. */
  6695. easeInCore(gradient: number): number;
  6696. /**
  6697. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6698. * of the easing function.
  6699. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6700. * @returns the corresponding value on the curve defined by the easing function
  6701. */
  6702. ease(gradient: number): number;
  6703. }
  6704. /**
  6705. * Easing function with a circle shape (see link below).
  6706. * @see https://easings.net/#easeInCirc
  6707. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6708. */
  6709. export class CircleEase extends EasingFunction implements IEasingFunction {
  6710. /** @hidden */
  6711. easeInCore(gradient: number): number;
  6712. }
  6713. /**
  6714. * Easing function with a ease back shape (see link below).
  6715. * @see https://easings.net/#easeInBack
  6716. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6717. */
  6718. export class BackEase extends EasingFunction implements IEasingFunction {
  6719. /** Defines the amplitude of the function */
  6720. amplitude: number;
  6721. /**
  6722. * Instantiates a back ease easing
  6723. * @see https://easings.net/#easeInBack
  6724. * @param amplitude Defines the amplitude of the function
  6725. */
  6726. constructor(
  6727. /** Defines the amplitude of the function */
  6728. amplitude?: number);
  6729. /** @hidden */
  6730. easeInCore(gradient: number): number;
  6731. }
  6732. /**
  6733. * Easing function with a bouncing shape (see link below).
  6734. * @see https://easings.net/#easeInBounce
  6735. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6736. */
  6737. export class BounceEase extends EasingFunction implements IEasingFunction {
  6738. /** Defines the number of bounces */
  6739. bounces: number;
  6740. /** Defines the amplitude of the bounce */
  6741. bounciness: number;
  6742. /**
  6743. * Instantiates a bounce easing
  6744. * @see https://easings.net/#easeInBounce
  6745. * @param bounces Defines the number of bounces
  6746. * @param bounciness Defines the amplitude of the bounce
  6747. */
  6748. constructor(
  6749. /** Defines the number of bounces */
  6750. bounces?: number,
  6751. /** Defines the amplitude of the bounce */
  6752. bounciness?: number);
  6753. /** @hidden */
  6754. easeInCore(gradient: number): number;
  6755. }
  6756. /**
  6757. * Easing function with a power of 3 shape (see link below).
  6758. * @see https://easings.net/#easeInCubic
  6759. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6760. */
  6761. export class CubicEase extends EasingFunction implements IEasingFunction {
  6762. /** @hidden */
  6763. easeInCore(gradient: number): number;
  6764. }
  6765. /**
  6766. * Easing function with an elastic shape (see link below).
  6767. * @see https://easings.net/#easeInElastic
  6768. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6769. */
  6770. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6771. /** Defines the number of oscillations*/
  6772. oscillations: number;
  6773. /** Defines the amplitude of the oscillations*/
  6774. springiness: number;
  6775. /**
  6776. * Instantiates an elastic easing function
  6777. * @see https://easings.net/#easeInElastic
  6778. * @param oscillations Defines the number of oscillations
  6779. * @param springiness Defines the amplitude of the oscillations
  6780. */
  6781. constructor(
  6782. /** Defines the number of oscillations*/
  6783. oscillations?: number,
  6784. /** Defines the amplitude of the oscillations*/
  6785. springiness?: number);
  6786. /** @hidden */
  6787. easeInCore(gradient: number): number;
  6788. }
  6789. /**
  6790. * Easing function with an exponential shape (see link below).
  6791. * @see https://easings.net/#easeInExpo
  6792. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6793. */
  6794. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6795. /** Defines the exponent of the function */
  6796. exponent: number;
  6797. /**
  6798. * Instantiates an exponential easing function
  6799. * @see https://easings.net/#easeInExpo
  6800. * @param exponent Defines the exponent of the function
  6801. */
  6802. constructor(
  6803. /** Defines the exponent of the function */
  6804. exponent?: number);
  6805. /** @hidden */
  6806. easeInCore(gradient: number): number;
  6807. }
  6808. /**
  6809. * Easing function with a power shape (see link below).
  6810. * @see https://easings.net/#easeInQuad
  6811. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6812. */
  6813. export class PowerEase extends EasingFunction implements IEasingFunction {
  6814. /** Defines the power of the function */
  6815. power: number;
  6816. /**
  6817. * Instantiates an power base easing function
  6818. * @see https://easings.net/#easeInQuad
  6819. * @param power Defines the power of the function
  6820. */
  6821. constructor(
  6822. /** Defines the power of the function */
  6823. power?: number);
  6824. /** @hidden */
  6825. easeInCore(gradient: number): number;
  6826. }
  6827. /**
  6828. * Easing function with a power of 2 shape (see link below).
  6829. * @see https://easings.net/#easeInQuad
  6830. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6831. */
  6832. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6833. /** @hidden */
  6834. easeInCore(gradient: number): number;
  6835. }
  6836. /**
  6837. * Easing function with a power of 4 shape (see link below).
  6838. * @see https://easings.net/#easeInQuart
  6839. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6840. */
  6841. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6842. /** @hidden */
  6843. easeInCore(gradient: number): number;
  6844. }
  6845. /**
  6846. * Easing function with a power of 5 shape (see link below).
  6847. * @see https://easings.net/#easeInQuint
  6848. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6849. */
  6850. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6851. /** @hidden */
  6852. easeInCore(gradient: number): number;
  6853. }
  6854. /**
  6855. * Easing function with a sin shape (see link below).
  6856. * @see https://easings.net/#easeInSine
  6857. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6858. */
  6859. export class SineEase extends EasingFunction implements IEasingFunction {
  6860. /** @hidden */
  6861. easeInCore(gradient: number): number;
  6862. }
  6863. /**
  6864. * Easing function with a bezier shape (see link below).
  6865. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6866. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6867. */
  6868. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6869. /** Defines the x component of the start tangent in the bezier curve */
  6870. x1: number;
  6871. /** Defines the y component of the start tangent in the bezier curve */
  6872. y1: number;
  6873. /** Defines the x component of the end tangent in the bezier curve */
  6874. x2: number;
  6875. /** Defines the y component of the end tangent in the bezier curve */
  6876. y2: number;
  6877. /**
  6878. * Instantiates a bezier function
  6879. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6880. * @param x1 Defines the x component of the start tangent in the bezier curve
  6881. * @param y1 Defines the y component of the start tangent in the bezier curve
  6882. * @param x2 Defines the x component of the end tangent in the bezier curve
  6883. * @param y2 Defines the y component of the end tangent in the bezier curve
  6884. */
  6885. constructor(
  6886. /** Defines the x component of the start tangent in the bezier curve */
  6887. x1?: number,
  6888. /** Defines the y component of the start tangent in the bezier curve */
  6889. y1?: number,
  6890. /** Defines the x component of the end tangent in the bezier curve */
  6891. x2?: number,
  6892. /** Defines the y component of the end tangent in the bezier curve */
  6893. y2?: number);
  6894. /** @hidden */
  6895. easeInCore(gradient: number): number;
  6896. }
  6897. }
  6898. declare module BABYLON {
  6899. /**
  6900. * Defines an interface which represents an animation key frame
  6901. */
  6902. export interface IAnimationKey {
  6903. /**
  6904. * Frame of the key frame
  6905. */
  6906. frame: number;
  6907. /**
  6908. * Value at the specifies key frame
  6909. */
  6910. value: any;
  6911. /**
  6912. * The input tangent for the cubic hermite spline
  6913. */
  6914. inTangent?: any;
  6915. /**
  6916. * The output tangent for the cubic hermite spline
  6917. */
  6918. outTangent?: any;
  6919. /**
  6920. * The animation interpolation type
  6921. */
  6922. interpolation?: AnimationKeyInterpolation;
  6923. }
  6924. /**
  6925. * Enum for the animation key frame interpolation type
  6926. */
  6927. export enum AnimationKeyInterpolation {
  6928. /**
  6929. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6930. */
  6931. STEP = 1
  6932. }
  6933. }
  6934. declare module BABYLON {
  6935. /**
  6936. * Represents the range of an animation
  6937. */
  6938. export class AnimationRange {
  6939. /**The name of the animation range**/
  6940. name: string;
  6941. /**The starting frame of the animation */
  6942. from: number;
  6943. /**The ending frame of the animation*/
  6944. to: number;
  6945. /**
  6946. * Initializes the range of an animation
  6947. * @param name The name of the animation range
  6948. * @param from The starting frame of the animation
  6949. * @param to The ending frame of the animation
  6950. */
  6951. constructor(
  6952. /**The name of the animation range**/
  6953. name: string,
  6954. /**The starting frame of the animation */
  6955. from: number,
  6956. /**The ending frame of the animation*/
  6957. to: number);
  6958. /**
  6959. * Makes a copy of the animation range
  6960. * @returns A copy of the animation range
  6961. */
  6962. clone(): AnimationRange;
  6963. }
  6964. }
  6965. declare module BABYLON {
  6966. /**
  6967. * Composed of a frame, and an action function
  6968. */
  6969. export class AnimationEvent {
  6970. /** The frame for which the event is triggered **/
  6971. frame: number;
  6972. /** The event to perform when triggered **/
  6973. action: (currentFrame: number) => void;
  6974. /** Specifies if the event should be triggered only once**/
  6975. onlyOnce?: boolean | undefined;
  6976. /**
  6977. * Specifies if the animation event is done
  6978. */
  6979. isDone: boolean;
  6980. /**
  6981. * Initializes the animation event
  6982. * @param frame The frame for which the event is triggered
  6983. * @param action The event to perform when triggered
  6984. * @param onlyOnce Specifies if the event should be triggered only once
  6985. */
  6986. constructor(
  6987. /** The frame for which the event is triggered **/
  6988. frame: number,
  6989. /** The event to perform when triggered **/
  6990. action: (currentFrame: number) => void,
  6991. /** Specifies if the event should be triggered only once**/
  6992. onlyOnce?: boolean | undefined);
  6993. /** @hidden */
  6994. _clone(): AnimationEvent;
  6995. }
  6996. }
  6997. declare module BABYLON {
  6998. /**
  6999. * Interface used to define a behavior
  7000. */
  7001. export interface Behavior<T> {
  7002. /** gets or sets behavior's name */
  7003. name: string;
  7004. /**
  7005. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7006. */
  7007. init(): void;
  7008. /**
  7009. * Called when the behavior is attached to a target
  7010. * @param target defines the target where the behavior is attached to
  7011. */
  7012. attach(target: T): void;
  7013. /**
  7014. * Called when the behavior is detached from its target
  7015. */
  7016. detach(): void;
  7017. }
  7018. /**
  7019. * Interface implemented by classes supporting behaviors
  7020. */
  7021. export interface IBehaviorAware<T> {
  7022. /**
  7023. * Attach a behavior
  7024. * @param behavior defines the behavior to attach
  7025. * @returns the current host
  7026. */
  7027. addBehavior(behavior: Behavior<T>): T;
  7028. /**
  7029. * Remove a behavior from the current object
  7030. * @param behavior defines the behavior to detach
  7031. * @returns the current host
  7032. */
  7033. removeBehavior(behavior: Behavior<T>): T;
  7034. /**
  7035. * Gets a behavior using its name to search
  7036. * @param name defines the name to search
  7037. * @returns the behavior or null if not found
  7038. */
  7039. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7040. }
  7041. }
  7042. declare module BABYLON {
  7043. /**
  7044. * @hidden
  7045. */
  7046. export class IntersectionInfo {
  7047. bu: Nullable<number>;
  7048. bv: Nullable<number>;
  7049. distance: number;
  7050. faceId: number;
  7051. subMeshId: number;
  7052. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7053. }
  7054. }
  7055. declare module BABYLON {
  7056. /**
  7057. * Class used to store bounding sphere information
  7058. */
  7059. export class BoundingSphere {
  7060. /**
  7061. * Gets the center of the bounding sphere in local space
  7062. */
  7063. readonly center: Vector3;
  7064. /**
  7065. * Radius of the bounding sphere in local space
  7066. */
  7067. radius: number;
  7068. /**
  7069. * Gets the center of the bounding sphere in world space
  7070. */
  7071. readonly centerWorld: Vector3;
  7072. /**
  7073. * Radius of the bounding sphere in world space
  7074. */
  7075. radiusWorld: number;
  7076. /**
  7077. * Gets the minimum vector in local space
  7078. */
  7079. readonly minimum: Vector3;
  7080. /**
  7081. * Gets the maximum vector in local space
  7082. */
  7083. readonly maximum: Vector3;
  7084. private _worldMatrix;
  7085. private static readonly TmpVector3;
  7086. /**
  7087. * Creates a new bounding sphere
  7088. * @param min defines the minimum vector (in local space)
  7089. * @param max defines the maximum vector (in local space)
  7090. * @param worldMatrix defines the new world matrix
  7091. */
  7092. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7093. /**
  7094. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7095. * @param min defines the new minimum vector (in local space)
  7096. * @param max defines the new maximum vector (in local space)
  7097. * @param worldMatrix defines the new world matrix
  7098. */
  7099. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7100. /**
  7101. * Scale the current bounding sphere by applying a scale factor
  7102. * @param factor defines the scale factor to apply
  7103. * @returns the current bounding box
  7104. */
  7105. scale(factor: number): BoundingSphere;
  7106. /**
  7107. * Gets the world matrix of the bounding box
  7108. * @returns a matrix
  7109. */
  7110. getWorldMatrix(): DeepImmutable<Matrix>;
  7111. /** @hidden */
  7112. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7113. /**
  7114. * Tests if the bounding sphere is intersecting the frustum planes
  7115. * @param frustumPlanes defines the frustum planes to test
  7116. * @returns true if there is an intersection
  7117. */
  7118. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7119. /**
  7120. * Tests if the bounding sphere center is in between the frustum planes.
  7121. * Used for optimistic fast inclusion.
  7122. * @param frustumPlanes defines the frustum planes to test
  7123. * @returns true if the sphere center is in between the frustum planes
  7124. */
  7125. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7126. /**
  7127. * Tests if a point is inside the bounding sphere
  7128. * @param point defines the point to test
  7129. * @returns true if the point is inside the bounding sphere
  7130. */
  7131. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7132. /**
  7133. * Checks if two sphere intersct
  7134. * @param sphere0 sphere 0
  7135. * @param sphere1 sphere 1
  7136. * @returns true if the speres intersect
  7137. */
  7138. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7139. }
  7140. }
  7141. declare module BABYLON {
  7142. /**
  7143. * Class used to store bounding box information
  7144. */
  7145. export class BoundingBox implements ICullable {
  7146. /**
  7147. * Gets the 8 vectors representing the bounding box in local space
  7148. */
  7149. readonly vectors: Vector3[];
  7150. /**
  7151. * Gets the center of the bounding box in local space
  7152. */
  7153. readonly center: Vector3;
  7154. /**
  7155. * Gets the center of the bounding box in world space
  7156. */
  7157. readonly centerWorld: Vector3;
  7158. /**
  7159. * Gets the extend size in local space
  7160. */
  7161. readonly extendSize: Vector3;
  7162. /**
  7163. * Gets the extend size in world space
  7164. */
  7165. readonly extendSizeWorld: Vector3;
  7166. /**
  7167. * Gets the OBB (object bounding box) directions
  7168. */
  7169. readonly directions: Vector3[];
  7170. /**
  7171. * Gets the 8 vectors representing the bounding box in world space
  7172. */
  7173. readonly vectorsWorld: Vector3[];
  7174. /**
  7175. * Gets the minimum vector in world space
  7176. */
  7177. readonly minimumWorld: Vector3;
  7178. /**
  7179. * Gets the maximum vector in world space
  7180. */
  7181. readonly maximumWorld: Vector3;
  7182. /**
  7183. * Gets the minimum vector in local space
  7184. */
  7185. readonly minimum: Vector3;
  7186. /**
  7187. * Gets the maximum vector in local space
  7188. */
  7189. readonly maximum: Vector3;
  7190. private _worldMatrix;
  7191. private static readonly TmpVector3;
  7192. /**
  7193. * @hidden
  7194. */
  7195. _tag: number;
  7196. /**
  7197. * Creates a new bounding box
  7198. * @param min defines the minimum vector (in local space)
  7199. * @param max defines the maximum vector (in local space)
  7200. * @param worldMatrix defines the new world matrix
  7201. */
  7202. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7203. /**
  7204. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7205. * @param min defines the new minimum vector (in local space)
  7206. * @param max defines the new maximum vector (in local space)
  7207. * @param worldMatrix defines the new world matrix
  7208. */
  7209. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7210. /**
  7211. * Scale the current bounding box by applying a scale factor
  7212. * @param factor defines the scale factor to apply
  7213. * @returns the current bounding box
  7214. */
  7215. scale(factor: number): BoundingBox;
  7216. /**
  7217. * Gets the world matrix of the bounding box
  7218. * @returns a matrix
  7219. */
  7220. getWorldMatrix(): DeepImmutable<Matrix>;
  7221. /** @hidden */
  7222. _update(world: DeepImmutable<Matrix>): void;
  7223. /**
  7224. * Tests if the bounding box is intersecting the frustum planes
  7225. * @param frustumPlanes defines the frustum planes to test
  7226. * @returns true if there is an intersection
  7227. */
  7228. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7229. /**
  7230. * Tests if the bounding box is entirely inside the frustum planes
  7231. * @param frustumPlanes defines the frustum planes to test
  7232. * @returns true if there is an inclusion
  7233. */
  7234. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7235. /**
  7236. * Tests if a point is inside the bounding box
  7237. * @param point defines the point to test
  7238. * @returns true if the point is inside the bounding box
  7239. */
  7240. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7241. /**
  7242. * Tests if the bounding box intersects with a bounding sphere
  7243. * @param sphere defines the sphere to test
  7244. * @returns true if there is an intersection
  7245. */
  7246. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7247. /**
  7248. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7249. * @param min defines the min vector to use
  7250. * @param max defines the max vector to use
  7251. * @returns true if there is an intersection
  7252. */
  7253. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7254. /**
  7255. * Tests if two bounding boxes are intersections
  7256. * @param box0 defines the first box to test
  7257. * @param box1 defines the second box to test
  7258. * @returns true if there is an intersection
  7259. */
  7260. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7261. /**
  7262. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7263. * @param minPoint defines the minimum vector of the bounding box
  7264. * @param maxPoint defines the maximum vector of the bounding box
  7265. * @param sphereCenter defines the sphere center
  7266. * @param sphereRadius defines the sphere radius
  7267. * @returns true if there is an intersection
  7268. */
  7269. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7270. /**
  7271. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7272. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7273. * @param frustumPlanes defines the frustum planes to test
  7274. * @return true if there is an inclusion
  7275. */
  7276. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7277. /**
  7278. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7279. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7280. * @param frustumPlanes defines the frustum planes to test
  7281. * @return true if there is an intersection
  7282. */
  7283. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7284. }
  7285. }
  7286. declare module BABYLON {
  7287. /** @hidden */
  7288. export class Collider {
  7289. /** Define if a collision was found */
  7290. collisionFound: boolean;
  7291. /**
  7292. * Define last intersection point in local space
  7293. */
  7294. intersectionPoint: Vector3;
  7295. /**
  7296. * Define last collided mesh
  7297. */
  7298. collidedMesh: Nullable<AbstractMesh>;
  7299. private _collisionPoint;
  7300. private _planeIntersectionPoint;
  7301. private _tempVector;
  7302. private _tempVector2;
  7303. private _tempVector3;
  7304. private _tempVector4;
  7305. private _edge;
  7306. private _baseToVertex;
  7307. private _destinationPoint;
  7308. private _slidePlaneNormal;
  7309. private _displacementVector;
  7310. /** @hidden */
  7311. _radius: Vector3;
  7312. /** @hidden */
  7313. _retry: number;
  7314. private _velocity;
  7315. private _basePoint;
  7316. private _epsilon;
  7317. /** @hidden */
  7318. _velocityWorldLength: number;
  7319. /** @hidden */
  7320. _basePointWorld: Vector3;
  7321. private _velocityWorld;
  7322. private _normalizedVelocity;
  7323. /** @hidden */
  7324. _initialVelocity: Vector3;
  7325. /** @hidden */
  7326. _initialPosition: Vector3;
  7327. private _nearestDistance;
  7328. private _collisionMask;
  7329. collisionMask: number;
  7330. /**
  7331. * Gets the plane normal used to compute the sliding response (in local space)
  7332. */
  7333. readonly slidePlaneNormal: Vector3;
  7334. /** @hidden */
  7335. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7336. /** @hidden */
  7337. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7338. /** @hidden */
  7339. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7340. /** @hidden */
  7341. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7342. /** @hidden */
  7343. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7344. /** @hidden */
  7345. _getResponse(pos: Vector3, vel: Vector3): void;
  7346. }
  7347. }
  7348. declare module BABYLON {
  7349. /**
  7350. * Interface for cullable objects
  7351. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7352. */
  7353. export interface ICullable {
  7354. /**
  7355. * Checks if the object or part of the object is in the frustum
  7356. * @param frustumPlanes Camera near/planes
  7357. * @returns true if the object is in frustum otherwise false
  7358. */
  7359. isInFrustum(frustumPlanes: Plane[]): boolean;
  7360. /**
  7361. * Checks if a cullable object (mesh...) is in the camera frustum
  7362. * Unlike isInFrustum this cheks the full bounding box
  7363. * @param frustumPlanes Camera near/planes
  7364. * @returns true if the object is in frustum otherwise false
  7365. */
  7366. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7367. }
  7368. /**
  7369. * Info for a bounding data of a mesh
  7370. */
  7371. export class BoundingInfo implements ICullable {
  7372. /**
  7373. * Bounding box for the mesh
  7374. */
  7375. readonly boundingBox: BoundingBox;
  7376. /**
  7377. * Bounding sphere for the mesh
  7378. */
  7379. readonly boundingSphere: BoundingSphere;
  7380. private _isLocked;
  7381. private static readonly TmpVector3;
  7382. /**
  7383. * Constructs bounding info
  7384. * @param minimum min vector of the bounding box/sphere
  7385. * @param maximum max vector of the bounding box/sphere
  7386. * @param worldMatrix defines the new world matrix
  7387. */
  7388. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7389. /**
  7390. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7391. * @param min defines the new minimum vector (in local space)
  7392. * @param max defines the new maximum vector (in local space)
  7393. * @param worldMatrix defines the new world matrix
  7394. */
  7395. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7396. /**
  7397. * min vector of the bounding box/sphere
  7398. */
  7399. readonly minimum: Vector3;
  7400. /**
  7401. * max vector of the bounding box/sphere
  7402. */
  7403. readonly maximum: Vector3;
  7404. /**
  7405. * If the info is locked and won't be updated to avoid perf overhead
  7406. */
  7407. isLocked: boolean;
  7408. /**
  7409. * Updates the bounding sphere and box
  7410. * @param world world matrix to be used to update
  7411. */
  7412. update(world: DeepImmutable<Matrix>): void;
  7413. /**
  7414. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7415. * @param center New center of the bounding info
  7416. * @param extend New extend of the bounding info
  7417. * @returns the current bounding info
  7418. */
  7419. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7420. /**
  7421. * Scale the current bounding info by applying a scale factor
  7422. * @param factor defines the scale factor to apply
  7423. * @returns the current bounding info
  7424. */
  7425. scale(factor: number): BoundingInfo;
  7426. /**
  7427. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7428. * @param frustumPlanes defines the frustum to test
  7429. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7430. * @returns true if the bounding info is in the frustum planes
  7431. */
  7432. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7433. /**
  7434. * Gets the world distance between the min and max points of the bounding box
  7435. */
  7436. readonly diagonalLength: number;
  7437. /**
  7438. * Checks if a cullable object (mesh...) is in the camera frustum
  7439. * Unlike isInFrustum this cheks the full bounding box
  7440. * @param frustumPlanes Camera near/planes
  7441. * @returns true if the object is in frustum otherwise false
  7442. */
  7443. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7444. /** @hidden */
  7445. _checkCollision(collider: Collider): boolean;
  7446. /**
  7447. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7448. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7449. * @param point the point to check intersection with
  7450. * @returns if the point intersects
  7451. */
  7452. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7453. /**
  7454. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7455. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7456. * @param boundingInfo the bounding info to check intersection with
  7457. * @param precise if the intersection should be done using OBB
  7458. * @returns if the bounding info intersects
  7459. */
  7460. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7461. }
  7462. }
  7463. declare module BABYLON {
  7464. /**
  7465. * Defines an array and its length.
  7466. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7467. */
  7468. export interface ISmartArrayLike<T> {
  7469. /**
  7470. * The data of the array.
  7471. */
  7472. data: Array<T>;
  7473. /**
  7474. * The active length of the array.
  7475. */
  7476. length: number;
  7477. }
  7478. /**
  7479. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7480. */
  7481. export class SmartArray<T> implements ISmartArrayLike<T> {
  7482. /**
  7483. * The full set of data from the array.
  7484. */
  7485. data: Array<T>;
  7486. /**
  7487. * The active length of the array.
  7488. */
  7489. length: number;
  7490. protected _id: number;
  7491. /**
  7492. * Instantiates a Smart Array.
  7493. * @param capacity defines the default capacity of the array.
  7494. */
  7495. constructor(capacity: number);
  7496. /**
  7497. * Pushes a value at the end of the active data.
  7498. * @param value defines the object to push in the array.
  7499. */
  7500. push(value: T): void;
  7501. /**
  7502. * Iterates over the active data and apply the lambda to them.
  7503. * @param func defines the action to apply on each value.
  7504. */
  7505. forEach(func: (content: T) => void): void;
  7506. /**
  7507. * Sorts the full sets of data.
  7508. * @param compareFn defines the comparison function to apply.
  7509. */
  7510. sort(compareFn: (a: T, b: T) => number): void;
  7511. /**
  7512. * Resets the active data to an empty array.
  7513. */
  7514. reset(): void;
  7515. /**
  7516. * Releases all the data from the array as well as the array.
  7517. */
  7518. dispose(): void;
  7519. /**
  7520. * Concats the active data with a given array.
  7521. * @param array defines the data to concatenate with.
  7522. */
  7523. concat(array: any): void;
  7524. /**
  7525. * Returns the position of a value in the active data.
  7526. * @param value defines the value to find the index for
  7527. * @returns the index if found in the active data otherwise -1
  7528. */
  7529. indexOf(value: T): number;
  7530. /**
  7531. * Returns whether an element is part of the active data.
  7532. * @param value defines the value to look for
  7533. * @returns true if found in the active data otherwise false
  7534. */
  7535. contains(value: T): boolean;
  7536. private static _GlobalId;
  7537. }
  7538. /**
  7539. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7540. * The data in this array can only be present once
  7541. */
  7542. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7543. private _duplicateId;
  7544. /**
  7545. * Pushes a value at the end of the active data.
  7546. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7547. * @param value defines the object to push in the array.
  7548. */
  7549. push(value: T): void;
  7550. /**
  7551. * Pushes a value at the end of the active data.
  7552. * If the data is already present, it won t be added again
  7553. * @param value defines the object to push in the array.
  7554. * @returns true if added false if it was already present
  7555. */
  7556. pushNoDuplicate(value: T): boolean;
  7557. /**
  7558. * Resets the active data to an empty array.
  7559. */
  7560. reset(): void;
  7561. /**
  7562. * Concats the active data with a given array.
  7563. * This ensures no dupplicate will be present in the result.
  7564. * @param array defines the data to concatenate with.
  7565. */
  7566. concatWithNoDuplicate(array: any): void;
  7567. }
  7568. }
  7569. declare module BABYLON {
  7570. /**
  7571. * Enum that determines the text-wrapping mode to use.
  7572. */
  7573. export enum InspectableType {
  7574. /**
  7575. * Checkbox for booleans
  7576. */
  7577. Checkbox = 0,
  7578. /**
  7579. * Sliders for numbers
  7580. */
  7581. Slider = 1,
  7582. /**
  7583. * Vector3
  7584. */
  7585. Vector3 = 2,
  7586. /**
  7587. * Quaternions
  7588. */
  7589. Quaternion = 3,
  7590. /**
  7591. * Color3
  7592. */
  7593. Color3 = 4
  7594. }
  7595. /**
  7596. * Interface used to define custom inspectable properties.
  7597. * This interface is used by the inspector to display custom property grids
  7598. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7599. */
  7600. export interface IInspectable {
  7601. /**
  7602. * Gets the label to display
  7603. */
  7604. label: string;
  7605. /**
  7606. * Gets the name of the property to edit
  7607. */
  7608. propertyName: string;
  7609. /**
  7610. * Gets the type of the editor to use
  7611. */
  7612. type: InspectableType;
  7613. /**
  7614. * Gets the minimum value of the property when using in "slider" mode
  7615. */
  7616. min?: number;
  7617. /**
  7618. * Gets the maximum value of the property when using in "slider" mode
  7619. */
  7620. max?: number;
  7621. /**
  7622. * Gets the setp to use when using in "slider" mode
  7623. */
  7624. step?: number;
  7625. }
  7626. }
  7627. declare module BABYLON {
  7628. /**
  7629. * This represents the required contract to create a new type of texture loader.
  7630. */
  7631. export interface IInternalTextureLoader {
  7632. /**
  7633. * Defines wether the loader supports cascade loading the different faces.
  7634. */
  7635. supportCascades: boolean;
  7636. /**
  7637. * This returns if the loader support the current file information.
  7638. * @param extension defines the file extension of the file being loaded
  7639. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7640. * @param fallback defines the fallback internal texture if any
  7641. * @param isBase64 defines whether the texture is encoded as a base64
  7642. * @param isBuffer defines whether the texture data are stored as a buffer
  7643. * @returns true if the loader can load the specified file
  7644. */
  7645. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7646. /**
  7647. * Transform the url before loading if required.
  7648. * @param rootUrl the url of the texture
  7649. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7650. * @returns the transformed texture
  7651. */
  7652. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7653. /**
  7654. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7655. * @param rootUrl the url of the texture
  7656. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7657. * @returns the fallback texture
  7658. */
  7659. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7660. /**
  7661. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7662. * @param data contains the texture data
  7663. * @param texture defines the BabylonJS internal texture
  7664. * @param createPolynomials will be true if polynomials have been requested
  7665. * @param onLoad defines the callback to trigger once the texture is ready
  7666. * @param onError defines the callback to trigger in case of error
  7667. */
  7668. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7669. /**
  7670. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7671. * @param data contains the texture data
  7672. * @param texture defines the BabylonJS internal texture
  7673. * @param callback defines the method to call once ready to upload
  7674. */
  7675. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7676. }
  7677. }
  7678. declare module BABYLON {
  7679. interface Engine {
  7680. /**
  7681. * Creates a depth stencil cube texture.
  7682. * This is only available in WebGL 2.
  7683. * @param size The size of face edge in the cube texture.
  7684. * @param options The options defining the cube texture.
  7685. * @returns The cube texture
  7686. */
  7687. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7688. /**
  7689. * Creates a cube texture
  7690. * @param rootUrl defines the url where the files to load is located
  7691. * @param scene defines the current scene
  7692. * @param files defines the list of files to load (1 per face)
  7693. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7694. * @param onLoad defines an optional callback raised when the texture is loaded
  7695. * @param onError defines an optional callback raised if there is an issue to load the texture
  7696. * @param format defines the format of the data
  7697. * @param forcedExtension defines the extension to use to pick the right loader
  7698. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7699. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7700. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7701. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7702. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7703. * @returns the cube texture as an InternalTexture
  7704. */
  7705. 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;
  7706. /**
  7707. * Creates a cube texture
  7708. * @param rootUrl defines the url where the files to load is located
  7709. * @param scene defines the current scene
  7710. * @param files defines the list of files to load (1 per face)
  7711. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7712. * @param onLoad defines an optional callback raised when the texture is loaded
  7713. * @param onError defines an optional callback raised if there is an issue to load the texture
  7714. * @param format defines the format of the data
  7715. * @param forcedExtension defines the extension to use to pick the right loader
  7716. * @returns the cube texture as an InternalTexture
  7717. */
  7718. 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;
  7719. /**
  7720. * Creates a cube texture
  7721. * @param rootUrl defines the url where the files to load is located
  7722. * @param scene defines the current scene
  7723. * @param files defines the list of files to load (1 per face)
  7724. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7725. * @param onLoad defines an optional callback raised when the texture is loaded
  7726. * @param onError defines an optional callback raised if there is an issue to load the texture
  7727. * @param format defines the format of the data
  7728. * @param forcedExtension defines the extension to use to pick the right loader
  7729. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7730. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7731. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7732. * @returns the cube texture as an InternalTexture
  7733. */
  7734. 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;
  7735. /** @hidden */
  7736. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7737. /** @hidden */
  7738. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7739. /** @hidden */
  7740. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7741. /** @hidden */
  7742. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7743. }
  7744. }
  7745. declare module BABYLON {
  7746. /**
  7747. * Class for creating a cube texture
  7748. */
  7749. export class CubeTexture extends BaseTexture {
  7750. private _delayedOnLoad;
  7751. /**
  7752. * The url of the texture
  7753. */
  7754. url: string;
  7755. /**
  7756. * Gets or sets the center of the bounding box associated with the cube texture.
  7757. * It must define where the camera used to render the texture was set
  7758. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7759. */
  7760. boundingBoxPosition: Vector3;
  7761. private _boundingBoxSize;
  7762. /**
  7763. * Gets or sets the size of the bounding box associated with the cube texture
  7764. * When defined, the cubemap will switch to local mode
  7765. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7766. * @example https://www.babylonjs-playground.com/#RNASML
  7767. */
  7768. /**
  7769. * Returns the bounding box size
  7770. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7771. */
  7772. boundingBoxSize: Vector3;
  7773. protected _rotationY: number;
  7774. /**
  7775. * Sets texture matrix rotation angle around Y axis in radians.
  7776. */
  7777. /**
  7778. * Gets texture matrix rotation angle around Y axis radians.
  7779. */
  7780. rotationY: number;
  7781. /**
  7782. * Are mip maps generated for this texture or not.
  7783. */
  7784. readonly noMipmap: boolean;
  7785. private _noMipmap;
  7786. private _files;
  7787. private _extensions;
  7788. private _textureMatrix;
  7789. private _format;
  7790. private _createPolynomials;
  7791. /** @hidden */
  7792. _prefiltered: boolean;
  7793. /**
  7794. * Creates a cube texture from an array of image urls
  7795. * @param files defines an array of image urls
  7796. * @param scene defines the hosting scene
  7797. * @param noMipmap specifies if mip maps are not used
  7798. * @returns a cube texture
  7799. */
  7800. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7801. /**
  7802. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7803. * @param url defines the url of the prefiltered texture
  7804. * @param scene defines the scene the texture is attached to
  7805. * @param forcedExtension defines the extension of the file if different from the url
  7806. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7807. * @return the prefiltered texture
  7808. */
  7809. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7810. /**
  7811. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7812. * as prefiltered data.
  7813. * @param rootUrl defines the url of the texture or the root name of the six images
  7814. * @param scene defines the scene the texture is attached to
  7815. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7816. * @param noMipmap defines if mipmaps should be created or not
  7817. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7818. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7819. * @param onError defines a callback triggered in case of error during load
  7820. * @param format defines the internal format to use for the texture once loaded
  7821. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7822. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7823. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7824. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7825. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7826. * @return the cube texture
  7827. */
  7828. 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);
  7829. /**
  7830. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7831. */
  7832. readonly isPrefiltered: boolean;
  7833. /**
  7834. * Get the current class name of the texture useful for serialization or dynamic coding.
  7835. * @returns "CubeTexture"
  7836. */
  7837. getClassName(): string;
  7838. /**
  7839. * Update the url (and optional buffer) of this texture if url was null during construction.
  7840. * @param url the url of the texture
  7841. * @param forcedExtension defines the extension to use
  7842. * @param onLoad callback called when the texture is loaded (defaults to null)
  7843. */
  7844. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7845. /**
  7846. * Delays loading of the cube texture
  7847. * @param forcedExtension defines the extension to use
  7848. */
  7849. delayLoad(forcedExtension?: string): void;
  7850. /**
  7851. * Returns the reflection texture matrix
  7852. * @returns the reflection texture matrix
  7853. */
  7854. getReflectionTextureMatrix(): Matrix;
  7855. /**
  7856. * Sets the reflection texture matrix
  7857. * @param value Reflection texture matrix
  7858. */
  7859. setReflectionTextureMatrix(value: Matrix): void;
  7860. /**
  7861. * Parses text to create a cube texture
  7862. * @param parsedTexture define the serialized text to read from
  7863. * @param scene defines the hosting scene
  7864. * @param rootUrl defines the root url of the cube texture
  7865. * @returns a cube texture
  7866. */
  7867. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7868. /**
  7869. * Makes a clone, or deep copy, of the cube texture
  7870. * @returns a new cube texture
  7871. */
  7872. clone(): CubeTexture;
  7873. }
  7874. }
  7875. declare module BABYLON {
  7876. /** @hidden */
  7877. export var postprocessVertexShader: {
  7878. name: string;
  7879. shader: string;
  7880. };
  7881. }
  7882. declare module BABYLON {
  7883. /**
  7884. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7885. * This is the base of the follow, arc rotate cameras and Free camera
  7886. * @see http://doc.babylonjs.com/features/cameras
  7887. */
  7888. export class TargetCamera extends Camera {
  7889. private static _RigCamTransformMatrix;
  7890. private static _TargetTransformMatrix;
  7891. private static _TargetFocalPoint;
  7892. /**
  7893. * Define the current direction the camera is moving to
  7894. */
  7895. cameraDirection: Vector3;
  7896. /**
  7897. * Define the current rotation the camera is rotating to
  7898. */
  7899. cameraRotation: Vector2;
  7900. /**
  7901. * When set, the up vector of the camera will be updated by the rotation of the camera
  7902. */
  7903. updateUpVectorFromRotation: boolean;
  7904. private _tmpQuaternion;
  7905. /**
  7906. * Define the current rotation of the camera
  7907. */
  7908. rotation: Vector3;
  7909. /**
  7910. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7911. */
  7912. rotationQuaternion: Quaternion;
  7913. /**
  7914. * Define the current speed of the camera
  7915. */
  7916. speed: number;
  7917. /**
  7918. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7919. * around all axis.
  7920. */
  7921. noRotationConstraint: boolean;
  7922. /**
  7923. * Define the current target of the camera as an object or a position.
  7924. */
  7925. lockedTarget: any;
  7926. /** @hidden */
  7927. _currentTarget: Vector3;
  7928. /** @hidden */
  7929. _initialFocalDistance: number;
  7930. /** @hidden */
  7931. _viewMatrix: Matrix;
  7932. /** @hidden */
  7933. _camMatrix: Matrix;
  7934. /** @hidden */
  7935. _cameraTransformMatrix: Matrix;
  7936. /** @hidden */
  7937. _cameraRotationMatrix: Matrix;
  7938. /** @hidden */
  7939. _referencePoint: Vector3;
  7940. /** @hidden */
  7941. _transformedReferencePoint: Vector3;
  7942. protected _globalCurrentTarget: Vector3;
  7943. protected _globalCurrentUpVector: Vector3;
  7944. /** @hidden */
  7945. _reset: () => void;
  7946. private _defaultUp;
  7947. /**
  7948. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7949. * This is the base of the follow, arc rotate cameras and Free camera
  7950. * @see http://doc.babylonjs.com/features/cameras
  7951. * @param name Defines the name of the camera in the scene
  7952. * @param position Defines the start position of the camera in the scene
  7953. * @param scene Defines the scene the camera belongs to
  7954. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7955. */
  7956. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7957. /**
  7958. * Gets the position in front of the camera at a given distance.
  7959. * @param distance The distance from the camera we want the position to be
  7960. * @returns the position
  7961. */
  7962. getFrontPosition(distance: number): Vector3;
  7963. /** @hidden */
  7964. _getLockedTargetPosition(): Nullable<Vector3>;
  7965. private _storedPosition;
  7966. private _storedRotation;
  7967. private _storedRotationQuaternion;
  7968. /**
  7969. * Store current camera state of the camera (fov, position, rotation, etc..)
  7970. * @returns the camera
  7971. */
  7972. storeState(): Camera;
  7973. /**
  7974. * Restored camera state. You must call storeState() first
  7975. * @returns whether it was successful or not
  7976. * @hidden
  7977. */
  7978. _restoreStateValues(): boolean;
  7979. /** @hidden */
  7980. _initCache(): void;
  7981. /** @hidden */
  7982. _updateCache(ignoreParentClass?: boolean): void;
  7983. /** @hidden */
  7984. _isSynchronizedViewMatrix(): boolean;
  7985. /** @hidden */
  7986. _computeLocalCameraSpeed(): number;
  7987. /**
  7988. * Defines the target the camera should look at.
  7989. * This will automatically adapt alpha beta and radius to fit within the new target.
  7990. * @param target Defines the new target as a Vector or a mesh
  7991. */
  7992. setTarget(target: Vector3): void;
  7993. /**
  7994. * Return the current target position of the camera. This value is expressed in local space.
  7995. * @returns the target position
  7996. */
  7997. getTarget(): Vector3;
  7998. /** @hidden */
  7999. _decideIfNeedsToMove(): boolean;
  8000. /** @hidden */
  8001. _updatePosition(): void;
  8002. /** @hidden */
  8003. _checkInputs(): void;
  8004. protected _updateCameraRotationMatrix(): void;
  8005. /**
  8006. * 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)
  8007. * @returns the current camera
  8008. */
  8009. private _rotateUpVectorWithCameraRotationMatrix;
  8010. private _cachedRotationZ;
  8011. private _cachedQuaternionRotationZ;
  8012. /** @hidden */
  8013. _getViewMatrix(): Matrix;
  8014. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8015. /**
  8016. * @hidden
  8017. */
  8018. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8019. /**
  8020. * @hidden
  8021. */
  8022. _updateRigCameras(): void;
  8023. private _getRigCamPositionAndTarget;
  8024. /**
  8025. * Gets the current object class name.
  8026. * @return the class name
  8027. */
  8028. getClassName(): string;
  8029. }
  8030. }
  8031. declare module BABYLON {
  8032. /**
  8033. * @ignore
  8034. * This is a list of all the different input types that are available in the application.
  8035. * Fo instance: ArcRotateCameraGamepadInput...
  8036. */
  8037. export var CameraInputTypes: {};
  8038. /**
  8039. * This is the contract to implement in order to create a new input class.
  8040. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8041. */
  8042. export interface ICameraInput<TCamera extends Camera> {
  8043. /**
  8044. * Defines the camera the input is attached to.
  8045. */
  8046. camera: Nullable<TCamera>;
  8047. /**
  8048. * Gets the class name of the current intput.
  8049. * @returns the class name
  8050. */
  8051. getClassName(): string;
  8052. /**
  8053. * Get the friendly name associated with the input class.
  8054. * @returns the input friendly name
  8055. */
  8056. getSimpleName(): string;
  8057. /**
  8058. * Attach the input controls to a specific dom element to get the input from.
  8059. * @param element Defines the element the controls should be listened from
  8060. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8061. */
  8062. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8063. /**
  8064. * Detach the current controls from the specified dom element.
  8065. * @param element Defines the element to stop listening the inputs from
  8066. */
  8067. detachControl(element: Nullable<HTMLElement>): void;
  8068. /**
  8069. * Update the current camera state depending on the inputs that have been used this frame.
  8070. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8071. */
  8072. checkInputs?: () => void;
  8073. }
  8074. /**
  8075. * Represents a map of input types to input instance or input index to input instance.
  8076. */
  8077. export interface CameraInputsMap<TCamera extends Camera> {
  8078. /**
  8079. * Accessor to the input by input type.
  8080. */
  8081. [name: string]: ICameraInput<TCamera>;
  8082. /**
  8083. * Accessor to the input by input index.
  8084. */
  8085. [idx: number]: ICameraInput<TCamera>;
  8086. }
  8087. /**
  8088. * This represents the input manager used within a camera.
  8089. * It helps dealing with all the different kind of input attached to a camera.
  8090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8091. */
  8092. export class CameraInputsManager<TCamera extends Camera> {
  8093. /**
  8094. * Defines the list of inputs attahed to the camera.
  8095. */
  8096. attached: CameraInputsMap<TCamera>;
  8097. /**
  8098. * Defines the dom element the camera is collecting inputs from.
  8099. * This is null if the controls have not been attached.
  8100. */
  8101. attachedElement: Nullable<HTMLElement>;
  8102. /**
  8103. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8104. */
  8105. noPreventDefault: boolean;
  8106. /**
  8107. * Defined the camera the input manager belongs to.
  8108. */
  8109. camera: TCamera;
  8110. /**
  8111. * Update the current camera state depending on the inputs that have been used this frame.
  8112. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8113. */
  8114. checkInputs: () => void;
  8115. /**
  8116. * Instantiate a new Camera Input Manager.
  8117. * @param camera Defines the camera the input manager blongs to
  8118. */
  8119. constructor(camera: TCamera);
  8120. /**
  8121. * Add an input method to a camera
  8122. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8123. * @param input camera input method
  8124. */
  8125. add(input: ICameraInput<TCamera>): void;
  8126. /**
  8127. * Remove a specific input method from a camera
  8128. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8129. * @param inputToRemove camera input method
  8130. */
  8131. remove(inputToRemove: ICameraInput<TCamera>): void;
  8132. /**
  8133. * Remove a specific input type from a camera
  8134. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8135. * @param inputType the type of the input to remove
  8136. */
  8137. removeByType(inputType: string): void;
  8138. private _addCheckInputs;
  8139. /**
  8140. * Attach the input controls to the currently attached dom element to listen the events from.
  8141. * @param input Defines the input to attach
  8142. */
  8143. attachInput(input: ICameraInput<TCamera>): void;
  8144. /**
  8145. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8146. * @param element Defines the dom element to collect the events from
  8147. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8148. */
  8149. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8150. /**
  8151. * Detach the current manager inputs controls from a specific dom element.
  8152. * @param element Defines the dom element to collect the events from
  8153. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8154. */
  8155. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8156. /**
  8157. * Rebuild the dynamic inputCheck function from the current list of
  8158. * defined inputs in the manager.
  8159. */
  8160. rebuildInputCheck(): void;
  8161. /**
  8162. * Remove all attached input methods from a camera
  8163. */
  8164. clear(): void;
  8165. /**
  8166. * Serialize the current input manager attached to a camera.
  8167. * This ensures than once parsed,
  8168. * the input associated to the camera will be identical to the current ones
  8169. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8170. */
  8171. serialize(serializedCamera: any): void;
  8172. /**
  8173. * Parses an input manager serialized JSON to restore the previous list of inputs
  8174. * and states associated to a camera.
  8175. * @param parsedCamera Defines the JSON to parse
  8176. */
  8177. parse(parsedCamera: any): void;
  8178. }
  8179. }
  8180. declare module BABYLON {
  8181. /**
  8182. * Gather the list of keyboard event types as constants.
  8183. */
  8184. export class KeyboardEventTypes {
  8185. /**
  8186. * The keydown event is fired when a key becomes active (pressed).
  8187. */
  8188. static readonly KEYDOWN: number;
  8189. /**
  8190. * The keyup event is fired when a key has been released.
  8191. */
  8192. static readonly KEYUP: number;
  8193. }
  8194. /**
  8195. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8196. */
  8197. export class KeyboardInfo {
  8198. /**
  8199. * Defines the type of event (KeyboardEventTypes)
  8200. */
  8201. type: number;
  8202. /**
  8203. * Defines the related dom event
  8204. */
  8205. event: KeyboardEvent;
  8206. /**
  8207. * Instantiates a new keyboard info.
  8208. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8209. * @param type Defines the type of event (KeyboardEventTypes)
  8210. * @param event Defines the related dom event
  8211. */
  8212. constructor(
  8213. /**
  8214. * Defines the type of event (KeyboardEventTypes)
  8215. */
  8216. type: number,
  8217. /**
  8218. * Defines the related dom event
  8219. */
  8220. event: KeyboardEvent);
  8221. }
  8222. /**
  8223. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8224. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8225. */
  8226. export class KeyboardInfoPre extends KeyboardInfo {
  8227. /**
  8228. * Defines the type of event (KeyboardEventTypes)
  8229. */
  8230. type: number;
  8231. /**
  8232. * Defines the related dom event
  8233. */
  8234. event: KeyboardEvent;
  8235. /**
  8236. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8237. */
  8238. skipOnPointerObservable: boolean;
  8239. /**
  8240. * Instantiates a new keyboard pre info.
  8241. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8242. * @param type Defines the type of event (KeyboardEventTypes)
  8243. * @param event Defines the related dom event
  8244. */
  8245. constructor(
  8246. /**
  8247. * Defines the type of event (KeyboardEventTypes)
  8248. */
  8249. type: number,
  8250. /**
  8251. * Defines the related dom event
  8252. */
  8253. event: KeyboardEvent);
  8254. }
  8255. }
  8256. declare module BABYLON {
  8257. /**
  8258. * Manage the keyboard inputs to control the movement of a free camera.
  8259. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8260. */
  8261. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8262. /**
  8263. * Defines the camera the input is attached to.
  8264. */
  8265. camera: FreeCamera;
  8266. /**
  8267. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8268. */
  8269. keysUp: number[];
  8270. /**
  8271. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8272. */
  8273. keysDown: number[];
  8274. /**
  8275. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8276. */
  8277. keysLeft: number[];
  8278. /**
  8279. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8280. */
  8281. keysRight: number[];
  8282. private _keys;
  8283. private _onCanvasBlurObserver;
  8284. private _onKeyboardObserver;
  8285. private _engine;
  8286. private _scene;
  8287. /**
  8288. * Attach the input controls to a specific dom element to get the input from.
  8289. * @param element Defines the element the controls should be listened from
  8290. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8291. */
  8292. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8293. /**
  8294. * Detach the current controls from the specified dom element.
  8295. * @param element Defines the element to stop listening the inputs from
  8296. */
  8297. detachControl(element: Nullable<HTMLElement>): void;
  8298. /**
  8299. * Update the current camera state depending on the inputs that have been used this frame.
  8300. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8301. */
  8302. checkInputs(): void;
  8303. /**
  8304. * Gets the class name of the current intput.
  8305. * @returns the class name
  8306. */
  8307. getClassName(): string;
  8308. /** @hidden */
  8309. _onLostFocus(): void;
  8310. /**
  8311. * Get the friendly name associated with the input class.
  8312. * @returns the input friendly name
  8313. */
  8314. getSimpleName(): string;
  8315. }
  8316. }
  8317. declare module BABYLON {
  8318. /**
  8319. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8320. * separate meshes. This can be use to improve performances.
  8321. * @see http://doc.babylonjs.com/how_to/multi_materials
  8322. */
  8323. export class MultiMaterial extends Material {
  8324. private _subMaterials;
  8325. /**
  8326. * Gets or Sets the list of Materials used within the multi material.
  8327. * They need to be ordered according to the submeshes order in the associated mesh
  8328. */
  8329. subMaterials: Nullable<Material>[];
  8330. /**
  8331. * Function used to align with Node.getChildren()
  8332. * @returns the list of Materials used within the multi material
  8333. */
  8334. getChildren(): Nullable<Material>[];
  8335. /**
  8336. * Instantiates a new Multi Material
  8337. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8338. * separate meshes. This can be use to improve performances.
  8339. * @see http://doc.babylonjs.com/how_to/multi_materials
  8340. * @param name Define the name in the scene
  8341. * @param scene Define the scene the material belongs to
  8342. */
  8343. constructor(name: string, scene: Scene);
  8344. private _hookArray;
  8345. /**
  8346. * Get one of the submaterial by its index in the submaterials array
  8347. * @param index The index to look the sub material at
  8348. * @returns The Material if the index has been defined
  8349. */
  8350. getSubMaterial(index: number): Nullable<Material>;
  8351. /**
  8352. * Get the list of active textures for the whole sub materials list.
  8353. * @returns All the textures that will be used during the rendering
  8354. */
  8355. getActiveTextures(): BaseTexture[];
  8356. /**
  8357. * Gets the current class name of the material e.g. "MultiMaterial"
  8358. * Mainly use in serialization.
  8359. * @returns the class name
  8360. */
  8361. getClassName(): string;
  8362. /**
  8363. * Checks if the material is ready to render the requested sub mesh
  8364. * @param mesh Define the mesh the submesh belongs to
  8365. * @param subMesh Define the sub mesh to look readyness for
  8366. * @param useInstances Define whether or not the material is used with instances
  8367. * @returns true if ready, otherwise false
  8368. */
  8369. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8370. /**
  8371. * Clones the current material and its related sub materials
  8372. * @param name Define the name of the newly cloned material
  8373. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8374. * @returns the cloned material
  8375. */
  8376. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8377. /**
  8378. * Serializes the materials into a JSON representation.
  8379. * @returns the JSON representation
  8380. */
  8381. serialize(): any;
  8382. /**
  8383. * Dispose the material and release its associated resources
  8384. * @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)
  8385. * @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)
  8386. * @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)
  8387. */
  8388. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8389. /**
  8390. * Creates a MultiMaterial from parsed MultiMaterial data.
  8391. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8392. * @param scene defines the hosting scene
  8393. * @returns a new MultiMaterial
  8394. */
  8395. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8396. }
  8397. }
  8398. declare module BABYLON {
  8399. /**
  8400. * Class used to represent data loading progression
  8401. */
  8402. export class SceneLoaderFlags {
  8403. private static _ForceFullSceneLoadingForIncremental;
  8404. private static _ShowLoadingScreen;
  8405. private static _CleanBoneMatrixWeights;
  8406. private static _loggingLevel;
  8407. /**
  8408. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8409. */
  8410. static ForceFullSceneLoadingForIncremental: boolean;
  8411. /**
  8412. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8413. */
  8414. static ShowLoadingScreen: boolean;
  8415. /**
  8416. * Defines the current logging level (while loading the scene)
  8417. * @ignorenaming
  8418. */
  8419. static loggingLevel: number;
  8420. /**
  8421. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8422. */
  8423. static CleanBoneMatrixWeights: boolean;
  8424. }
  8425. }
  8426. declare module BABYLON {
  8427. /**
  8428. * 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.
  8429. * @see https://doc.babylonjs.com/how_to/transformnode
  8430. */
  8431. export class TransformNode extends Node {
  8432. /**
  8433. * Object will not rotate to face the camera
  8434. */
  8435. static BILLBOARDMODE_NONE: number;
  8436. /**
  8437. * Object will rotate to face the camera but only on the x axis
  8438. */
  8439. static BILLBOARDMODE_X: number;
  8440. /**
  8441. * Object will rotate to face the camera but only on the y axis
  8442. */
  8443. static BILLBOARDMODE_Y: number;
  8444. /**
  8445. * Object will rotate to face the camera but only on the z axis
  8446. */
  8447. static BILLBOARDMODE_Z: number;
  8448. /**
  8449. * Object will rotate to face the camera
  8450. */
  8451. static BILLBOARDMODE_ALL: number;
  8452. private _forward;
  8453. private _forwardInverted;
  8454. private _up;
  8455. private _right;
  8456. private _rightInverted;
  8457. private _position;
  8458. private _rotation;
  8459. private _rotationQuaternion;
  8460. protected _scaling: Vector3;
  8461. protected _isDirty: boolean;
  8462. private _transformToBoneReferal;
  8463. private _billboardMode;
  8464. /**
  8465. * Gets or sets the billboard mode. Default is 0.
  8466. *
  8467. * | Value | Type | Description |
  8468. * | --- | --- | --- |
  8469. * | 0 | BILLBOARDMODE_NONE | |
  8470. * | 1 | BILLBOARDMODE_X | |
  8471. * | 2 | BILLBOARDMODE_Y | |
  8472. * | 4 | BILLBOARDMODE_Z | |
  8473. * | 7 | BILLBOARDMODE_ALL | |
  8474. *
  8475. */
  8476. billboardMode: number;
  8477. private _preserveParentRotationForBillboard;
  8478. /**
  8479. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8480. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8481. */
  8482. preserveParentRotationForBillboard: boolean;
  8483. /**
  8484. * 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
  8485. */
  8486. scalingDeterminant: number;
  8487. private _infiniteDistance;
  8488. /**
  8489. * Gets or sets the distance of the object to max, often used by skybox
  8490. */
  8491. infiniteDistance: boolean;
  8492. /**
  8493. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8494. * By default the system will update normals to compensate
  8495. */
  8496. ignoreNonUniformScaling: boolean;
  8497. /**
  8498. * 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
  8499. */
  8500. reIntegrateRotationIntoRotationQuaternion: boolean;
  8501. /** @hidden */
  8502. _poseMatrix: Nullable<Matrix>;
  8503. /** @hidden */
  8504. _localMatrix: Matrix;
  8505. private _usePivotMatrix;
  8506. private _absolutePosition;
  8507. private _pivotMatrix;
  8508. private _pivotMatrixInverse;
  8509. protected _postMultiplyPivotMatrix: boolean;
  8510. protected _isWorldMatrixFrozen: boolean;
  8511. /** @hidden */
  8512. _indexInSceneTransformNodesArray: number;
  8513. /**
  8514. * An event triggered after the world matrix is updated
  8515. */
  8516. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8517. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8518. /**
  8519. * Gets a string identifying the name of the class
  8520. * @returns "TransformNode" string
  8521. */
  8522. getClassName(): string;
  8523. /**
  8524. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8525. */
  8526. position: Vector3;
  8527. /**
  8528. * 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)).
  8529. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8530. */
  8531. rotation: Vector3;
  8532. /**
  8533. * 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)).
  8534. */
  8535. scaling: Vector3;
  8536. /**
  8537. * 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).
  8538. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8539. */
  8540. rotationQuaternion: Nullable<Quaternion>;
  8541. /**
  8542. * The forward direction of that transform in world space.
  8543. */
  8544. readonly forward: Vector3;
  8545. /**
  8546. * The up direction of that transform in world space.
  8547. */
  8548. readonly up: Vector3;
  8549. /**
  8550. * The right direction of that transform in world space.
  8551. */
  8552. readonly right: Vector3;
  8553. /**
  8554. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8555. * @param matrix the matrix to copy the pose from
  8556. * @returns this TransformNode.
  8557. */
  8558. updatePoseMatrix(matrix: Matrix): TransformNode;
  8559. /**
  8560. * Returns the mesh Pose matrix.
  8561. * @returns the pose matrix
  8562. */
  8563. getPoseMatrix(): Matrix;
  8564. /** @hidden */
  8565. _isSynchronized(): boolean;
  8566. /** @hidden */
  8567. _initCache(): void;
  8568. /**
  8569. * Flag the transform node as dirty (Forcing it to update everything)
  8570. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8571. * @returns this transform node
  8572. */
  8573. markAsDirty(property: string): TransformNode;
  8574. /**
  8575. * Returns the current mesh absolute position.
  8576. * Returns a Vector3.
  8577. */
  8578. readonly absolutePosition: Vector3;
  8579. /**
  8580. * Sets a new matrix to apply before all other transformation
  8581. * @param matrix defines the transform matrix
  8582. * @returns the current TransformNode
  8583. */
  8584. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8585. /**
  8586. * Sets a new pivot matrix to the current node
  8587. * @param matrix defines the new pivot matrix to use
  8588. * @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
  8589. * @returns the current TransformNode
  8590. */
  8591. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8592. /**
  8593. * Returns the mesh pivot matrix.
  8594. * Default : Identity.
  8595. * @returns the matrix
  8596. */
  8597. getPivotMatrix(): Matrix;
  8598. /**
  8599. * Prevents the World matrix to be computed any longer.
  8600. * @returns the TransformNode.
  8601. */
  8602. freezeWorldMatrix(): TransformNode;
  8603. /**
  8604. * Allows back the World matrix computation.
  8605. * @returns the TransformNode.
  8606. */
  8607. unfreezeWorldMatrix(): this;
  8608. /**
  8609. * True if the World matrix has been frozen.
  8610. */
  8611. readonly isWorldMatrixFrozen: boolean;
  8612. /**
  8613. * Retuns the mesh absolute position in the World.
  8614. * @returns a Vector3.
  8615. */
  8616. getAbsolutePosition(): Vector3;
  8617. /**
  8618. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8619. * @param absolutePosition the absolute position to set
  8620. * @returns the TransformNode.
  8621. */
  8622. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8623. /**
  8624. * Sets the mesh position in its local space.
  8625. * @param vector3 the position to set in localspace
  8626. * @returns the TransformNode.
  8627. */
  8628. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8629. /**
  8630. * Returns the mesh position in the local space from the current World matrix values.
  8631. * @returns a new Vector3.
  8632. */
  8633. getPositionExpressedInLocalSpace(): Vector3;
  8634. /**
  8635. * Translates the mesh along the passed Vector3 in its local space.
  8636. * @param vector3 the distance to translate in localspace
  8637. * @returns the TransformNode.
  8638. */
  8639. locallyTranslate(vector3: Vector3): TransformNode;
  8640. private static _lookAtVectorCache;
  8641. /**
  8642. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8643. * @param targetPoint the position (must be in same space as current mesh) to look at
  8644. * @param yawCor optional yaw (y-axis) correction in radians
  8645. * @param pitchCor optional pitch (x-axis) correction in radians
  8646. * @param rollCor optional roll (z-axis) correction in radians
  8647. * @param space the choosen space of the target
  8648. * @returns the TransformNode.
  8649. */
  8650. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8651. /**
  8652. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8653. * This Vector3 is expressed in the World space.
  8654. * @param localAxis axis to rotate
  8655. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8656. */
  8657. getDirection(localAxis: Vector3): Vector3;
  8658. /**
  8659. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8660. * localAxis is expressed in the mesh local space.
  8661. * result is computed in the Wordl space from the mesh World matrix.
  8662. * @param localAxis axis to rotate
  8663. * @param result the resulting transformnode
  8664. * @returns this TransformNode.
  8665. */
  8666. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8667. /**
  8668. * Sets this transform node rotation to the given local axis.
  8669. * @param localAxis the axis in local space
  8670. * @param yawCor optional yaw (y-axis) correction in radians
  8671. * @param pitchCor optional pitch (x-axis) correction in radians
  8672. * @param rollCor optional roll (z-axis) correction in radians
  8673. * @returns this TransformNode
  8674. */
  8675. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8676. /**
  8677. * Sets a new pivot point to the current node
  8678. * @param point defines the new pivot point to use
  8679. * @param space defines if the point is in world or local space (local by default)
  8680. * @returns the current TransformNode
  8681. */
  8682. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8683. /**
  8684. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8685. * @returns the pivot point
  8686. */
  8687. getPivotPoint(): Vector3;
  8688. /**
  8689. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8690. * @param result the vector3 to store the result
  8691. * @returns this TransformNode.
  8692. */
  8693. getPivotPointToRef(result: Vector3): TransformNode;
  8694. /**
  8695. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8696. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8697. */
  8698. getAbsolutePivotPoint(): Vector3;
  8699. /**
  8700. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8701. * @param result vector3 to store the result
  8702. * @returns this TransformNode.
  8703. */
  8704. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8705. /**
  8706. * Defines the passed node as the parent of the current node.
  8707. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8708. * @see https://doc.babylonjs.com/how_to/parenting
  8709. * @param node the node ot set as the parent
  8710. * @returns this TransformNode.
  8711. */
  8712. setParent(node: Nullable<Node>): TransformNode;
  8713. private _nonUniformScaling;
  8714. /**
  8715. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8716. */
  8717. readonly nonUniformScaling: boolean;
  8718. /** @hidden */
  8719. _updateNonUniformScalingState(value: boolean): boolean;
  8720. /**
  8721. * Attach the current TransformNode to another TransformNode associated with a bone
  8722. * @param bone Bone affecting the TransformNode
  8723. * @param affectedTransformNode TransformNode associated with the bone
  8724. * @returns this object
  8725. */
  8726. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8727. /**
  8728. * Detach the transform node if its associated with a bone
  8729. * @returns this object
  8730. */
  8731. detachFromBone(): TransformNode;
  8732. private static _rotationAxisCache;
  8733. /**
  8734. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8735. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8736. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8737. * The passed axis is also normalized.
  8738. * @param axis the axis to rotate around
  8739. * @param amount the amount to rotate in radians
  8740. * @param space Space to rotate in (Default: local)
  8741. * @returns the TransformNode.
  8742. */
  8743. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8744. /**
  8745. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8746. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8747. * The passed axis is also normalized. .
  8748. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8749. * @param point the point to rotate around
  8750. * @param axis the axis to rotate around
  8751. * @param amount the amount to rotate in radians
  8752. * @returns the TransformNode
  8753. */
  8754. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8755. /**
  8756. * Translates the mesh along the axis vector for the passed distance in the given space.
  8757. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8758. * @param axis the axis to translate in
  8759. * @param distance the distance to translate
  8760. * @param space Space to rotate in (Default: local)
  8761. * @returns the TransformNode.
  8762. */
  8763. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8764. /**
  8765. * Adds a rotation step to the mesh current rotation.
  8766. * x, y, z are Euler angles expressed in radians.
  8767. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8768. * This means this rotation is made in the mesh local space only.
  8769. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8770. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8771. * ```javascript
  8772. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8773. * ```
  8774. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8775. * 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.
  8776. * @param x Rotation to add
  8777. * @param y Rotation to add
  8778. * @param z Rotation to add
  8779. * @returns the TransformNode.
  8780. */
  8781. addRotation(x: number, y: number, z: number): TransformNode;
  8782. /**
  8783. * @hidden
  8784. */
  8785. protected _getEffectiveParent(): Nullable<Node>;
  8786. /**
  8787. * Computes the world matrix of the node
  8788. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8789. * @returns the world matrix
  8790. */
  8791. computeWorldMatrix(force?: boolean): Matrix;
  8792. protected _afterComputeWorldMatrix(): void;
  8793. /**
  8794. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8795. * @param func callback function to add
  8796. *
  8797. * @returns the TransformNode.
  8798. */
  8799. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8800. /**
  8801. * Removes a registered callback function.
  8802. * @param func callback function to remove
  8803. * @returns the TransformNode.
  8804. */
  8805. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8806. /**
  8807. * Gets the position of the current mesh in camera space
  8808. * @param camera defines the camera to use
  8809. * @returns a position
  8810. */
  8811. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8812. /**
  8813. * Returns the distance from the mesh to the active camera
  8814. * @param camera defines the camera to use
  8815. * @returns the distance
  8816. */
  8817. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8818. /**
  8819. * Clone the current transform node
  8820. * @param name Name of the new clone
  8821. * @param newParent New parent for the clone
  8822. * @param doNotCloneChildren Do not clone children hierarchy
  8823. * @returns the new transform node
  8824. */
  8825. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8826. /**
  8827. * Serializes the objects information.
  8828. * @param currentSerializationObject defines the object to serialize in
  8829. * @returns the serialized object
  8830. */
  8831. serialize(currentSerializationObject?: any): any;
  8832. /**
  8833. * Returns a new TransformNode object parsed from the source provided.
  8834. * @param parsedTransformNode is the source.
  8835. * @param scene the scne the object belongs to
  8836. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8837. * @returns a new TransformNode object parsed from the source provided.
  8838. */
  8839. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8840. /**
  8841. * Get all child-transformNodes of this node
  8842. * @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
  8843. * @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
  8844. * @returns an array of TransformNode
  8845. */
  8846. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8847. /**
  8848. * Releases resources associated with this transform node.
  8849. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8850. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8851. */
  8852. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8853. /**
  8854. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8855. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8856. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8857. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8858. * @returns the current mesh
  8859. */
  8860. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8861. }
  8862. }
  8863. declare module BABYLON {
  8864. /**
  8865. * Class used to override all child animations of a given target
  8866. */
  8867. export class AnimationPropertiesOverride {
  8868. /**
  8869. * Gets or sets a value indicating if animation blending must be used
  8870. */
  8871. enableBlending: boolean;
  8872. /**
  8873. * Gets or sets the blending speed to use when enableBlending is true
  8874. */
  8875. blendingSpeed: number;
  8876. /**
  8877. * Gets or sets the default loop mode to use
  8878. */
  8879. loopMode: number;
  8880. }
  8881. }
  8882. declare module BABYLON {
  8883. /**
  8884. * Class used to store bone information
  8885. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8886. */
  8887. export class Bone extends Node {
  8888. /**
  8889. * defines the bone name
  8890. */
  8891. name: string;
  8892. private static _tmpVecs;
  8893. private static _tmpQuat;
  8894. private static _tmpMats;
  8895. /**
  8896. * Gets the list of child bones
  8897. */
  8898. children: Bone[];
  8899. /** Gets the animations associated with this bone */
  8900. animations: Animation[];
  8901. /**
  8902. * Gets or sets bone length
  8903. */
  8904. length: number;
  8905. /**
  8906. * @hidden Internal only
  8907. * Set this value to map this bone to a different index in the transform matrices
  8908. * Set this value to -1 to exclude the bone from the transform matrices
  8909. */
  8910. _index: Nullable<number>;
  8911. private _skeleton;
  8912. private _localMatrix;
  8913. private _restPose;
  8914. private _baseMatrix;
  8915. private _absoluteTransform;
  8916. private _invertedAbsoluteTransform;
  8917. private _parent;
  8918. private _scalingDeterminant;
  8919. private _worldTransform;
  8920. private _localScaling;
  8921. private _localRotation;
  8922. private _localPosition;
  8923. private _needToDecompose;
  8924. private _needToCompose;
  8925. /** @hidden */
  8926. _linkedTransformNode: Nullable<TransformNode>;
  8927. /** @hidden */
  8928. _waitingTransformNodeId: Nullable<string>;
  8929. /** @hidden */
  8930. /** @hidden */
  8931. _matrix: Matrix;
  8932. /**
  8933. * Create a new bone
  8934. * @param name defines the bone name
  8935. * @param skeleton defines the parent skeleton
  8936. * @param parentBone defines the parent (can be null if the bone is the root)
  8937. * @param localMatrix defines the local matrix
  8938. * @param restPose defines the rest pose matrix
  8939. * @param baseMatrix defines the base matrix
  8940. * @param index defines index of the bone in the hiearchy
  8941. */
  8942. constructor(
  8943. /**
  8944. * defines the bone name
  8945. */
  8946. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8947. /**
  8948. * Gets the current object class name.
  8949. * @return the class name
  8950. */
  8951. getClassName(): string;
  8952. /**
  8953. * Gets the parent skeleton
  8954. * @returns a skeleton
  8955. */
  8956. getSkeleton(): Skeleton;
  8957. /**
  8958. * Gets parent bone
  8959. * @returns a bone or null if the bone is the root of the bone hierarchy
  8960. */
  8961. getParent(): Nullable<Bone>;
  8962. /**
  8963. * Returns an array containing the root bones
  8964. * @returns an array containing the root bones
  8965. */
  8966. getChildren(): Array<Bone>;
  8967. /**
  8968. * Sets the parent bone
  8969. * @param parent defines the parent (can be null if the bone is the root)
  8970. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8971. */
  8972. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8973. /**
  8974. * Gets the local matrix
  8975. * @returns a matrix
  8976. */
  8977. getLocalMatrix(): Matrix;
  8978. /**
  8979. * Gets the base matrix (initial matrix which remains unchanged)
  8980. * @returns a matrix
  8981. */
  8982. getBaseMatrix(): Matrix;
  8983. /**
  8984. * Gets the rest pose matrix
  8985. * @returns a matrix
  8986. */
  8987. getRestPose(): Matrix;
  8988. /**
  8989. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8990. */
  8991. getWorldMatrix(): Matrix;
  8992. /**
  8993. * Sets the local matrix to rest pose matrix
  8994. */
  8995. returnToRest(): void;
  8996. /**
  8997. * Gets the inverse of the absolute transform matrix.
  8998. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8999. * @returns a matrix
  9000. */
  9001. getInvertedAbsoluteTransform(): Matrix;
  9002. /**
  9003. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9004. * @returns a matrix
  9005. */
  9006. getAbsoluteTransform(): Matrix;
  9007. /**
  9008. * Links with the given transform node.
  9009. * The local matrix of this bone is copied from the transform node every frame.
  9010. * @param transformNode defines the transform node to link to
  9011. */
  9012. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9013. /** Gets or sets current position (in local space) */
  9014. position: Vector3;
  9015. /** Gets or sets current rotation (in local space) */
  9016. rotation: Vector3;
  9017. /** Gets or sets current rotation quaternion (in local space) */
  9018. rotationQuaternion: Quaternion;
  9019. /** Gets or sets current scaling (in local space) */
  9020. scaling: Vector3;
  9021. /**
  9022. * Gets the animation properties override
  9023. */
  9024. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9025. private _decompose;
  9026. private _compose;
  9027. /**
  9028. * Update the base and local matrices
  9029. * @param matrix defines the new base or local matrix
  9030. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9031. * @param updateLocalMatrix defines if the local matrix should be updated
  9032. */
  9033. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9034. /** @hidden */
  9035. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9036. /**
  9037. * Flag the bone as dirty (Forcing it to update everything)
  9038. */
  9039. markAsDirty(): void;
  9040. /** @hidden */
  9041. _markAsDirtyAndCompose(): void;
  9042. private _markAsDirtyAndDecompose;
  9043. /**
  9044. * Translate the bone in local or world space
  9045. * @param vec The amount to translate the bone
  9046. * @param space The space that the translation is in
  9047. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9048. */
  9049. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9050. /**
  9051. * Set the postion of the bone in local or world space
  9052. * @param position The position to set the bone
  9053. * @param space The space that the position is in
  9054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9055. */
  9056. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9057. /**
  9058. * Set the absolute position of the bone (world space)
  9059. * @param position The position to set the bone
  9060. * @param mesh The mesh that this bone is attached to
  9061. */
  9062. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9063. /**
  9064. * Scale the bone on the x, y and z axes (in local space)
  9065. * @param x The amount to scale the bone on the x axis
  9066. * @param y The amount to scale the bone on the y axis
  9067. * @param z The amount to scale the bone on the z axis
  9068. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9069. */
  9070. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9071. /**
  9072. * Set the bone scaling in local space
  9073. * @param scale defines the scaling vector
  9074. */
  9075. setScale(scale: Vector3): void;
  9076. /**
  9077. * Gets the current scaling in local space
  9078. * @returns the current scaling vector
  9079. */
  9080. getScale(): Vector3;
  9081. /**
  9082. * Gets the current scaling in local space and stores it in a target vector
  9083. * @param result defines the target vector
  9084. */
  9085. getScaleToRef(result: Vector3): void;
  9086. /**
  9087. * Set the yaw, pitch, and roll of the bone in local or world space
  9088. * @param yaw The rotation of the bone on the y axis
  9089. * @param pitch The rotation of the bone on the x axis
  9090. * @param roll The rotation of the bone on the z axis
  9091. * @param space The space that the axes of rotation are in
  9092. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9093. */
  9094. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9095. /**
  9096. * Add a rotation to the bone on an axis in local or world space
  9097. * @param axis The axis to rotate the bone on
  9098. * @param amount The amount to rotate the bone
  9099. * @param space The space that the axis is in
  9100. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9101. */
  9102. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9103. /**
  9104. * Set the rotation of the bone to a particular axis angle in local or world space
  9105. * @param axis The axis to rotate the bone on
  9106. * @param angle The angle that the bone should be rotated to
  9107. * @param space The space that the axis is in
  9108. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9109. */
  9110. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9111. /**
  9112. * Set the euler rotation of the bone in local of world space
  9113. * @param rotation The euler rotation that the bone should be set to
  9114. * @param space The space that the rotation is in
  9115. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9116. */
  9117. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9118. /**
  9119. * Set the quaternion rotation of the bone in local of world space
  9120. * @param quat The quaternion rotation that the bone should be set to
  9121. * @param space The space that the rotation is in
  9122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9123. */
  9124. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9125. /**
  9126. * Set the rotation matrix of the bone in local of world space
  9127. * @param rotMat The rotation matrix that the bone should be set to
  9128. * @param space The space that the rotation is in
  9129. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9130. */
  9131. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9132. private _rotateWithMatrix;
  9133. private _getNegativeRotationToRef;
  9134. /**
  9135. * Get the position of the bone in local or world space
  9136. * @param space The space that the returned position is in
  9137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9138. * @returns The position of the bone
  9139. */
  9140. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9141. /**
  9142. * Copy the position of the bone to a vector3 in local or world space
  9143. * @param space The space that the returned position is in
  9144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9145. * @param result The vector3 to copy the position to
  9146. */
  9147. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9148. /**
  9149. * Get the absolute position of the bone (world space)
  9150. * @param mesh The mesh that this bone is attached to
  9151. * @returns The absolute position of the bone
  9152. */
  9153. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9154. /**
  9155. * Copy the absolute position of the bone (world space) to the result param
  9156. * @param mesh The mesh that this bone is attached to
  9157. * @param result The vector3 to copy the absolute position to
  9158. */
  9159. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9160. /**
  9161. * Compute the absolute transforms of this bone and its children
  9162. */
  9163. computeAbsoluteTransforms(): void;
  9164. /**
  9165. * Get the world direction from an axis that is in the local space of the bone
  9166. * @param localAxis The local direction that is used to compute the world direction
  9167. * @param mesh The mesh that this bone is attached to
  9168. * @returns The world direction
  9169. */
  9170. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9171. /**
  9172. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9173. * @param localAxis The local direction that is used to compute the world direction
  9174. * @param mesh The mesh that this bone is attached to
  9175. * @param result The vector3 that the world direction will be copied to
  9176. */
  9177. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9178. /**
  9179. * Get the euler rotation of the bone in local or world space
  9180. * @param space The space that the rotation should be in
  9181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9182. * @returns The euler rotation
  9183. */
  9184. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9185. /**
  9186. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9187. * @param space The space that the rotation should be in
  9188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9189. * @param result The vector3 that the rotation should be copied to
  9190. */
  9191. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9192. /**
  9193. * Get the quaternion rotation of the bone in either local or world space
  9194. * @param space The space that the rotation should be in
  9195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9196. * @returns The quaternion rotation
  9197. */
  9198. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9199. /**
  9200. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9201. * @param space The space that the rotation should be in
  9202. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9203. * @param result The quaternion that the rotation should be copied to
  9204. */
  9205. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9206. /**
  9207. * Get the rotation matrix of the bone in local or world space
  9208. * @param space The space that the rotation should be in
  9209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9210. * @returns The rotation matrix
  9211. */
  9212. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9213. /**
  9214. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9215. * @param space The space that the rotation should be in
  9216. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9217. * @param result The quaternion that the rotation should be copied to
  9218. */
  9219. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9220. /**
  9221. * Get the world position of a point that is in the local space of the bone
  9222. * @param position The local position
  9223. * @param mesh The mesh that this bone is attached to
  9224. * @returns The world position
  9225. */
  9226. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9227. /**
  9228. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9229. * @param position The local position
  9230. * @param mesh The mesh that this bone is attached to
  9231. * @param result The vector3 that the world position should be copied to
  9232. */
  9233. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9234. /**
  9235. * Get the local position of a point that is in world space
  9236. * @param position The world position
  9237. * @param mesh The mesh that this bone is attached to
  9238. * @returns The local position
  9239. */
  9240. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9241. /**
  9242. * Get the local position of a point that is in world space and copy it to the result param
  9243. * @param position The world position
  9244. * @param mesh The mesh that this bone is attached to
  9245. * @param result The vector3 that the local position should be copied to
  9246. */
  9247. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9248. }
  9249. }
  9250. declare module BABYLON {
  9251. interface Engine {
  9252. /**
  9253. * Creates a raw texture
  9254. * @param data defines the data to store in the texture
  9255. * @param width defines the width of the texture
  9256. * @param height defines the height of the texture
  9257. * @param format defines the format of the data
  9258. * @param generateMipMaps defines if the engine should generate the mip levels
  9259. * @param invertY defines if data must be stored with Y axis inverted
  9260. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9261. * @param compression defines the compression used (null by default)
  9262. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9263. * @returns the raw texture inside an InternalTexture
  9264. */
  9265. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9266. /**
  9267. * Update a raw texture
  9268. * @param texture defines the texture to update
  9269. * @param data defines the data to store in the texture
  9270. * @param format defines the format of the data
  9271. * @param invertY defines if data must be stored with Y axis inverted
  9272. */
  9273. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9274. /**
  9275. * Update a raw texture
  9276. * @param texture defines the texture to update
  9277. * @param data defines the data to store in the texture
  9278. * @param format defines the format of the data
  9279. * @param invertY defines if data must be stored with Y axis inverted
  9280. * @param compression defines the compression used (null by default)
  9281. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9282. */
  9283. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9284. /**
  9285. * Creates a new raw cube texture
  9286. * @param data defines the array of data to use to create each face
  9287. * @param size defines the size of the textures
  9288. * @param format defines the format of the data
  9289. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9290. * @param generateMipMaps defines if the engine should generate the mip levels
  9291. * @param invertY defines if data must be stored with Y axis inverted
  9292. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9293. * @param compression defines the compression used (null by default)
  9294. * @returns the cube texture as an InternalTexture
  9295. */
  9296. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9297. /**
  9298. * Update a raw cube texture
  9299. * @param texture defines the texture to udpdate
  9300. * @param data defines the data to store
  9301. * @param format defines the data format
  9302. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9303. * @param invertY defines if data must be stored with Y axis inverted
  9304. */
  9305. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9306. /**
  9307. * Update a raw cube texture
  9308. * @param texture defines the texture to udpdate
  9309. * @param data defines the data to store
  9310. * @param format defines the data format
  9311. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9312. * @param invertY defines if data must be stored with Y axis inverted
  9313. * @param compression defines the compression used (null by default)
  9314. */
  9315. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9316. /**
  9317. * Update a raw cube texture
  9318. * @param texture defines the texture to udpdate
  9319. * @param data defines the data to store
  9320. * @param format defines the data format
  9321. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9322. * @param invertY defines if data must be stored with Y axis inverted
  9323. * @param compression defines the compression used (null by default)
  9324. * @param level defines which level of the texture to update
  9325. */
  9326. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9327. /**
  9328. * Creates a new raw cube texture from a specified url
  9329. * @param url defines the url where the data is located
  9330. * @param scene defines the current scene
  9331. * @param size defines the size of the textures
  9332. * @param format defines the format of the data
  9333. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9334. * @param noMipmap defines if the engine should avoid generating the mip levels
  9335. * @param callback defines a callback used to extract texture data from loaded data
  9336. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9337. * @param onLoad defines a callback called when texture is loaded
  9338. * @param onError defines a callback called if there is an error
  9339. * @returns the cube texture as an InternalTexture
  9340. */
  9341. 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;
  9342. /**
  9343. * Creates a new raw cube texture from a specified url
  9344. * @param url defines the url where the data is located
  9345. * @param scene defines the current scene
  9346. * @param size defines the size of the textures
  9347. * @param format defines the format of the data
  9348. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9349. * @param noMipmap defines if the engine should avoid generating the mip levels
  9350. * @param callback defines a callback used to extract texture data from loaded data
  9351. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9352. * @param onLoad defines a callback called when texture is loaded
  9353. * @param onError defines a callback called if there is an error
  9354. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9355. * @param invertY defines if data must be stored with Y axis inverted
  9356. * @returns the cube texture as an InternalTexture
  9357. */
  9358. 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;
  9359. /**
  9360. * Creates a new raw 3D texture
  9361. * @param data defines the data used to create the texture
  9362. * @param width defines the width of the texture
  9363. * @param height defines the height of the texture
  9364. * @param depth defines the depth of the texture
  9365. * @param format defines the format of the texture
  9366. * @param generateMipMaps defines if the engine must generate mip levels
  9367. * @param invertY defines if data must be stored with Y axis inverted
  9368. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9369. * @param compression defines the compressed used (can be null)
  9370. * @param textureType defines the compressed used (can be null)
  9371. * @returns a new raw 3D texture (stored in an InternalTexture)
  9372. */
  9373. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9374. /**
  9375. * Update a raw 3D texture
  9376. * @param texture defines the texture to update
  9377. * @param data defines the data to store
  9378. * @param format defines the data format
  9379. * @param invertY defines if data must be stored with Y axis inverted
  9380. */
  9381. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9382. /**
  9383. * Update a raw 3D texture
  9384. * @param texture defines the texture to update
  9385. * @param data defines the data to store
  9386. * @param format defines the data format
  9387. * @param invertY defines if data must be stored with Y axis inverted
  9388. * @param compression defines the used compression (can be null)
  9389. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9390. */
  9391. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9392. }
  9393. }
  9394. declare module BABYLON {
  9395. /**
  9396. * Raw texture can help creating a texture directly from an array of data.
  9397. * This can be super useful if you either get the data from an uncompressed source or
  9398. * if you wish to create your texture pixel by pixel.
  9399. */
  9400. export class RawTexture extends Texture {
  9401. /**
  9402. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9403. */
  9404. format: number;
  9405. private _engine;
  9406. /**
  9407. * Instantiates a new RawTexture.
  9408. * Raw texture can help creating a texture directly from an array of data.
  9409. * This can be super useful if you either get the data from an uncompressed source or
  9410. * if you wish to create your texture pixel by pixel.
  9411. * @param data define the array of data to use to create the texture
  9412. * @param width define the width of the texture
  9413. * @param height define the height of the texture
  9414. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9415. * @param scene define the scene the texture belongs to
  9416. * @param generateMipMaps define whether mip maps should be generated or not
  9417. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9418. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9419. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9420. */
  9421. constructor(data: ArrayBufferView, width: number, height: number,
  9422. /**
  9423. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9424. */
  9425. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9426. /**
  9427. * Updates the texture underlying data.
  9428. * @param data Define the new data of the texture
  9429. */
  9430. update(data: ArrayBufferView): void;
  9431. /**
  9432. * Creates a luminance texture from some data.
  9433. * @param data Define the texture data
  9434. * @param width Define the width of the texture
  9435. * @param height Define the height of the texture
  9436. * @param scene Define the scene the texture belongs to
  9437. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9438. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9439. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9440. * @returns the luminance texture
  9441. */
  9442. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9443. /**
  9444. * Creates a luminance alpha texture from some data.
  9445. * @param data Define the texture data
  9446. * @param width Define the width of the texture
  9447. * @param height Define the height of the texture
  9448. * @param scene Define the scene the texture belongs to
  9449. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9450. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9451. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9452. * @returns the luminance alpha texture
  9453. */
  9454. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9455. /**
  9456. * Creates an alpha texture from some data.
  9457. * @param data Define the texture data
  9458. * @param width Define the width of the texture
  9459. * @param height Define the height of the texture
  9460. * @param scene Define the scene the texture belongs to
  9461. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9462. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9463. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9464. * @returns the alpha texture
  9465. */
  9466. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9467. /**
  9468. * Creates a RGB texture from some data.
  9469. * @param data Define the texture data
  9470. * @param width Define the width of the texture
  9471. * @param height Define the height of the texture
  9472. * @param scene Define the scene the texture belongs to
  9473. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9474. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9475. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9476. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9477. * @returns the RGB alpha texture
  9478. */
  9479. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9480. /**
  9481. * Creates a RGBA texture from some data.
  9482. * @param data Define the texture data
  9483. * @param width Define the width of the texture
  9484. * @param height Define the height of the texture
  9485. * @param scene Define the scene the texture belongs to
  9486. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9487. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9488. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9489. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9490. * @returns the RGBA texture
  9491. */
  9492. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9493. /**
  9494. * Creates a R texture from some data.
  9495. * @param data Define the texture data
  9496. * @param width Define the width of the texture
  9497. * @param height Define the height of the texture
  9498. * @param scene Define the scene the texture belongs to
  9499. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9500. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9501. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9502. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9503. * @returns the R texture
  9504. */
  9505. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9506. }
  9507. }
  9508. declare module BABYLON {
  9509. /**
  9510. * Defines a runtime animation
  9511. */
  9512. export class RuntimeAnimation {
  9513. private _events;
  9514. /**
  9515. * The current frame of the runtime animation
  9516. */
  9517. private _currentFrame;
  9518. /**
  9519. * The animation used by the runtime animation
  9520. */
  9521. private _animation;
  9522. /**
  9523. * The target of the runtime animation
  9524. */
  9525. private _target;
  9526. /**
  9527. * The initiating animatable
  9528. */
  9529. private _host;
  9530. /**
  9531. * The original value of the runtime animation
  9532. */
  9533. private _originalValue;
  9534. /**
  9535. * The original blend value of the runtime animation
  9536. */
  9537. private _originalBlendValue;
  9538. /**
  9539. * The offsets cache of the runtime animation
  9540. */
  9541. private _offsetsCache;
  9542. /**
  9543. * The high limits cache of the runtime animation
  9544. */
  9545. private _highLimitsCache;
  9546. /**
  9547. * Specifies if the runtime animation has been stopped
  9548. */
  9549. private _stopped;
  9550. /**
  9551. * The blending factor of the runtime animation
  9552. */
  9553. private _blendingFactor;
  9554. /**
  9555. * The BabylonJS scene
  9556. */
  9557. private _scene;
  9558. /**
  9559. * The current value of the runtime animation
  9560. */
  9561. private _currentValue;
  9562. /** @hidden */
  9563. _animationState: _IAnimationState;
  9564. /**
  9565. * The active target of the runtime animation
  9566. */
  9567. private _activeTargets;
  9568. private _currentActiveTarget;
  9569. private _directTarget;
  9570. /**
  9571. * The target path of the runtime animation
  9572. */
  9573. private _targetPath;
  9574. /**
  9575. * The weight of the runtime animation
  9576. */
  9577. private _weight;
  9578. /**
  9579. * The ratio offset of the runtime animation
  9580. */
  9581. private _ratioOffset;
  9582. /**
  9583. * The previous delay of the runtime animation
  9584. */
  9585. private _previousDelay;
  9586. /**
  9587. * The previous ratio of the runtime animation
  9588. */
  9589. private _previousRatio;
  9590. private _enableBlending;
  9591. private _keys;
  9592. private _minFrame;
  9593. private _maxFrame;
  9594. private _minValue;
  9595. private _maxValue;
  9596. private _targetIsArray;
  9597. /**
  9598. * Gets the current frame of the runtime animation
  9599. */
  9600. readonly currentFrame: number;
  9601. /**
  9602. * Gets the weight of the runtime animation
  9603. */
  9604. readonly weight: number;
  9605. /**
  9606. * Gets the current value of the runtime animation
  9607. */
  9608. readonly currentValue: any;
  9609. /**
  9610. * Gets the target path of the runtime animation
  9611. */
  9612. readonly targetPath: string;
  9613. /**
  9614. * Gets the actual target of the runtime animation
  9615. */
  9616. readonly target: any;
  9617. /** @hidden */
  9618. _onLoop: () => void;
  9619. /**
  9620. * Create a new RuntimeAnimation object
  9621. * @param target defines the target of the animation
  9622. * @param animation defines the source animation object
  9623. * @param scene defines the hosting scene
  9624. * @param host defines the initiating Animatable
  9625. */
  9626. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9627. private _preparePath;
  9628. /**
  9629. * Gets the animation from the runtime animation
  9630. */
  9631. readonly animation: Animation;
  9632. /**
  9633. * Resets the runtime animation to the beginning
  9634. * @param restoreOriginal defines whether to restore the target property to the original value
  9635. */
  9636. reset(restoreOriginal?: boolean): void;
  9637. /**
  9638. * Specifies if the runtime animation is stopped
  9639. * @returns Boolean specifying if the runtime animation is stopped
  9640. */
  9641. isStopped(): boolean;
  9642. /**
  9643. * Disposes of the runtime animation
  9644. */
  9645. dispose(): void;
  9646. /**
  9647. * Apply the interpolated value to the target
  9648. * @param currentValue defines the value computed by the animation
  9649. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9650. */
  9651. setValue(currentValue: any, weight: number): void;
  9652. private _getOriginalValues;
  9653. private _setValue;
  9654. /**
  9655. * Gets the loop pmode of the runtime animation
  9656. * @returns Loop Mode
  9657. */
  9658. private _getCorrectLoopMode;
  9659. /**
  9660. * Move the current animation to a given frame
  9661. * @param frame defines the frame to move to
  9662. */
  9663. goToFrame(frame: number): void;
  9664. /**
  9665. * @hidden Internal use only
  9666. */
  9667. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9668. /**
  9669. * Execute the current animation
  9670. * @param delay defines the delay to add to the current frame
  9671. * @param from defines the lower bound of the animation range
  9672. * @param to defines the upper bound of the animation range
  9673. * @param loop defines if the current animation must loop
  9674. * @param speedRatio defines the current speed ratio
  9675. * @param weight defines the weight of the animation (default is -1 so no weight)
  9676. * @param onLoop optional callback called when animation loops
  9677. * @returns a boolean indicating if the animation is running
  9678. */
  9679. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9680. }
  9681. }
  9682. declare module BABYLON {
  9683. /**
  9684. * Class used to store an actual running animation
  9685. */
  9686. export class Animatable {
  9687. /** defines the target object */
  9688. target: any;
  9689. /** defines the starting frame number (default is 0) */
  9690. fromFrame: number;
  9691. /** defines the ending frame number (default is 100) */
  9692. toFrame: number;
  9693. /** defines if the animation must loop (default is false) */
  9694. loopAnimation: boolean;
  9695. /** defines a callback to call when animation ends if it is not looping */
  9696. onAnimationEnd?: (() => void) | null | undefined;
  9697. /** defines a callback to call when animation loops */
  9698. onAnimationLoop?: (() => void) | null | undefined;
  9699. private _localDelayOffset;
  9700. private _pausedDelay;
  9701. private _runtimeAnimations;
  9702. private _paused;
  9703. private _scene;
  9704. private _speedRatio;
  9705. private _weight;
  9706. private _syncRoot;
  9707. /**
  9708. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9709. * This will only apply for non looping animation (default is true)
  9710. */
  9711. disposeOnEnd: boolean;
  9712. /**
  9713. * Gets a boolean indicating if the animation has started
  9714. */
  9715. animationStarted: boolean;
  9716. /**
  9717. * Observer raised when the animation ends
  9718. */
  9719. onAnimationEndObservable: Observable<Animatable>;
  9720. /**
  9721. * Observer raised when the animation loops
  9722. */
  9723. onAnimationLoopObservable: Observable<Animatable>;
  9724. /**
  9725. * Gets the root Animatable used to synchronize and normalize animations
  9726. */
  9727. readonly syncRoot: Nullable<Animatable>;
  9728. /**
  9729. * Gets the current frame of the first RuntimeAnimation
  9730. * Used to synchronize Animatables
  9731. */
  9732. readonly masterFrame: number;
  9733. /**
  9734. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9735. */
  9736. weight: number;
  9737. /**
  9738. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9739. */
  9740. speedRatio: number;
  9741. /**
  9742. * Creates a new Animatable
  9743. * @param scene defines the hosting scene
  9744. * @param target defines the target object
  9745. * @param fromFrame defines the starting frame number (default is 0)
  9746. * @param toFrame defines the ending frame number (default is 100)
  9747. * @param loopAnimation defines if the animation must loop (default is false)
  9748. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9749. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9750. * @param animations defines a group of animation to add to the new Animatable
  9751. * @param onAnimationLoop defines a callback to call when animation loops
  9752. */
  9753. constructor(scene: Scene,
  9754. /** defines the target object */
  9755. target: any,
  9756. /** defines the starting frame number (default is 0) */
  9757. fromFrame?: number,
  9758. /** defines the ending frame number (default is 100) */
  9759. toFrame?: number,
  9760. /** defines if the animation must loop (default is false) */
  9761. loopAnimation?: boolean, speedRatio?: number,
  9762. /** defines a callback to call when animation ends if it is not looping */
  9763. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9764. /** defines a callback to call when animation loops */
  9765. onAnimationLoop?: (() => void) | null | undefined);
  9766. /**
  9767. * Synchronize and normalize current Animatable with a source Animatable
  9768. * This is useful when using animation weights and when animations are not of the same length
  9769. * @param root defines the root Animatable to synchronize with
  9770. * @returns the current Animatable
  9771. */
  9772. syncWith(root: Animatable): Animatable;
  9773. /**
  9774. * Gets the list of runtime animations
  9775. * @returns an array of RuntimeAnimation
  9776. */
  9777. getAnimations(): RuntimeAnimation[];
  9778. /**
  9779. * Adds more animations to the current animatable
  9780. * @param target defines the target of the animations
  9781. * @param animations defines the new animations to add
  9782. */
  9783. appendAnimations(target: any, animations: Animation[]): void;
  9784. /**
  9785. * Gets the source animation for a specific property
  9786. * @param property defines the propertyu to look for
  9787. * @returns null or the source animation for the given property
  9788. */
  9789. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9790. /**
  9791. * Gets the runtime animation for a specific property
  9792. * @param property defines the propertyu to look for
  9793. * @returns null or the runtime animation for the given property
  9794. */
  9795. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9796. /**
  9797. * Resets the animatable to its original state
  9798. */
  9799. reset(): void;
  9800. /**
  9801. * Allows the animatable to blend with current running animations
  9802. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9803. * @param blendingSpeed defines the blending speed to use
  9804. */
  9805. enableBlending(blendingSpeed: number): void;
  9806. /**
  9807. * Disable animation blending
  9808. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9809. */
  9810. disableBlending(): void;
  9811. /**
  9812. * Jump directly to a given frame
  9813. * @param frame defines the frame to jump to
  9814. */
  9815. goToFrame(frame: number): void;
  9816. /**
  9817. * Pause the animation
  9818. */
  9819. pause(): void;
  9820. /**
  9821. * Restart the animation
  9822. */
  9823. restart(): void;
  9824. private _raiseOnAnimationEnd;
  9825. /**
  9826. * Stop and delete the current animation
  9827. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9828. * @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)
  9829. */
  9830. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9831. /**
  9832. * Wait asynchronously for the animation to end
  9833. * @returns a promise which will be fullfilled when the animation ends
  9834. */
  9835. waitAsync(): Promise<Animatable>;
  9836. /** @hidden */
  9837. _animate(delay: number): boolean;
  9838. }
  9839. interface Scene {
  9840. /** @hidden */
  9841. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9842. /** @hidden */
  9843. _processLateAnimationBindingsForMatrices(holder: {
  9844. totalWeight: number;
  9845. animations: RuntimeAnimation[];
  9846. originalValue: Matrix;
  9847. }): any;
  9848. /** @hidden */
  9849. _processLateAnimationBindingsForQuaternions(holder: {
  9850. totalWeight: number;
  9851. animations: RuntimeAnimation[];
  9852. originalValue: Quaternion;
  9853. }, refQuaternion: Quaternion): Quaternion;
  9854. /** @hidden */
  9855. _processLateAnimationBindings(): void;
  9856. /**
  9857. * Will start the animation sequence of a given target
  9858. * @param target defines the target
  9859. * @param from defines from which frame should animation start
  9860. * @param to defines until which frame should animation run.
  9861. * @param weight defines the weight to apply to the animation (1.0 by default)
  9862. * @param loop defines if the animation loops
  9863. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9864. * @param onAnimationEnd defines the function to be executed when the animation ends
  9865. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9866. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9867. * @param onAnimationLoop defines the callback to call when an animation loops
  9868. * @returns the animatable object created for this animation
  9869. */
  9870. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9871. /**
  9872. * Will start the animation sequence of a given target
  9873. * @param target defines the target
  9874. * @param from defines from which frame should animation start
  9875. * @param to defines until which frame should animation run.
  9876. * @param loop defines if the animation loops
  9877. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9878. * @param onAnimationEnd defines the function to be executed when the animation ends
  9879. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9880. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9881. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  9882. * @param onAnimationLoop defines the callback to call when an animation loops
  9883. * @returns the animatable object created for this animation
  9884. */
  9885. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9886. /**
  9887. * Will start the animation sequence of a given target and its hierarchy
  9888. * @param target defines the target
  9889. * @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.
  9890. * @param from defines from which frame should animation start
  9891. * @param to defines until which frame should animation run.
  9892. * @param loop defines if the animation loops
  9893. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9894. * @param onAnimationEnd defines the function to be executed when the animation ends
  9895. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9896. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9897. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9898. * @param onAnimationLoop defines the callback to call when an animation loops
  9899. * @returns the list of created animatables
  9900. */
  9901. 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[];
  9902. /**
  9903. * Begin a new animation on a given node
  9904. * @param target defines the target where the animation will take place
  9905. * @param animations defines the list of animations to start
  9906. * @param from defines the initial value
  9907. * @param to defines the final value
  9908. * @param loop defines if you want animation to loop (off by default)
  9909. * @param speedRatio defines the speed ratio to apply to all animations
  9910. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  9911. * @param onAnimationLoop defines the callback to call when an animation loops
  9912. * @returns the list of created animatables
  9913. */
  9914. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  9915. /**
  9916. * Begin a new animation on a given node and its hierarchy
  9917. * @param target defines the root node where the animation will take place
  9918. * @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.
  9919. * @param animations defines the list of animations to start
  9920. * @param from defines the initial value
  9921. * @param to defines the final value
  9922. * @param loop defines if you want animation to loop (off by default)
  9923. * @param speedRatio defines the speed ratio to apply to all animations
  9924. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  9925. * @param onAnimationLoop defines the callback to call when an animation loops
  9926. * @returns the list of animatables created for all nodes
  9927. */
  9928. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  9929. /**
  9930. * Gets the animatable associated with a specific target
  9931. * @param target defines the target of the animatable
  9932. * @returns the required animatable if found
  9933. */
  9934. getAnimatableByTarget(target: any): Nullable<Animatable>;
  9935. /**
  9936. * Gets all animatables associated with a given target
  9937. * @param target defines the target to look animatables for
  9938. * @returns an array of Animatables
  9939. */
  9940. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  9941. /**
  9942. * Stops and removes all animations that have been applied to the scene
  9943. */
  9944. stopAllAnimations(): void;
  9945. }
  9946. interface Bone {
  9947. /**
  9948. * Copy an animation range from another bone
  9949. * @param source defines the source bone
  9950. * @param rangeName defines the range name to copy
  9951. * @param frameOffset defines the frame offset
  9952. * @param rescaleAsRequired defines if rescaling must be applied if required
  9953. * @param skelDimensionsRatio defines the scaling ratio
  9954. * @returns true if operation was successful
  9955. */
  9956. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  9957. }
  9958. }
  9959. declare module BABYLON {
  9960. /**
  9961. * Class used to handle skinning animations
  9962. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9963. */
  9964. export class Skeleton implements IAnimatable {
  9965. /** defines the skeleton name */
  9966. name: string;
  9967. /** defines the skeleton Id */
  9968. id: string;
  9969. /**
  9970. * Defines the list of child bones
  9971. */
  9972. bones: Bone[];
  9973. /**
  9974. * Defines an estimate of the dimension of the skeleton at rest
  9975. */
  9976. dimensionsAtRest: Vector3;
  9977. /**
  9978. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  9979. */
  9980. needInitialSkinMatrix: boolean;
  9981. /**
  9982. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  9983. */
  9984. overrideMesh: Nullable<AbstractMesh>;
  9985. /**
  9986. * Gets the list of animations attached to this skeleton
  9987. */
  9988. animations: Array<Animation>;
  9989. private _scene;
  9990. private _isDirty;
  9991. private _transformMatrices;
  9992. private _transformMatrixTexture;
  9993. private _meshesWithPoseMatrix;
  9994. private _animatables;
  9995. private _identity;
  9996. private _synchronizedWithMesh;
  9997. private _ranges;
  9998. private _lastAbsoluteTransformsUpdateId;
  9999. private _canUseTextureForBones;
  10000. private _uniqueId;
  10001. /** @hidden */
  10002. _numBonesWithLinkedTransformNode: number;
  10003. /** @hidden */
  10004. _hasWaitingData: Nullable<boolean>;
  10005. /**
  10006. * Specifies if the skeleton should be serialized
  10007. */
  10008. doNotSerialize: boolean;
  10009. private _useTextureToStoreBoneMatrices;
  10010. /**
  10011. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  10012. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  10013. */
  10014. useTextureToStoreBoneMatrices: boolean;
  10015. private _animationPropertiesOverride;
  10016. /**
  10017. * Gets or sets the animation properties override
  10018. */
  10019. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10020. /**
  10021. * List of inspectable custom properties (used by the Inspector)
  10022. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  10023. */
  10024. inspectableCustomProperties: IInspectable[];
  10025. /**
  10026. * An observable triggered before computing the skeleton's matrices
  10027. */
  10028. onBeforeComputeObservable: Observable<Skeleton>;
  10029. /**
  10030. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  10031. */
  10032. readonly isUsingTextureForMatrices: boolean;
  10033. /**
  10034. * Gets the unique ID of this skeleton
  10035. */
  10036. readonly uniqueId: number;
  10037. /**
  10038. * Creates a new skeleton
  10039. * @param name defines the skeleton name
  10040. * @param id defines the skeleton Id
  10041. * @param scene defines the hosting scene
  10042. */
  10043. constructor(
  10044. /** defines the skeleton name */
  10045. name: string,
  10046. /** defines the skeleton Id */
  10047. id: string, scene: Scene);
  10048. /**
  10049. * Gets the current object class name.
  10050. * @return the class name
  10051. */
  10052. getClassName(): string;
  10053. /**
  10054. * Returns an array containing the root bones
  10055. * @returns an array containing the root bones
  10056. */
  10057. getChildren(): Array<Bone>;
  10058. /**
  10059. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  10060. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10061. * @returns a Float32Array containing matrices data
  10062. */
  10063. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  10064. /**
  10065. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  10066. * @returns a raw texture containing the data
  10067. */
  10068. getTransformMatrixTexture(): Nullable<RawTexture>;
  10069. /**
  10070. * Gets the current hosting scene
  10071. * @returns a scene object
  10072. */
  10073. getScene(): Scene;
  10074. /**
  10075. * Gets a string representing the current skeleton data
  10076. * @param fullDetails defines a boolean indicating if we want a verbose version
  10077. * @returns a string representing the current skeleton data
  10078. */
  10079. toString(fullDetails?: boolean): string;
  10080. /**
  10081. * Get bone's index searching by name
  10082. * @param name defines bone's name to search for
  10083. * @return the indice of the bone. Returns -1 if not found
  10084. */
  10085. getBoneIndexByName(name: string): number;
  10086. /**
  10087. * Creater a new animation range
  10088. * @param name defines the name of the range
  10089. * @param from defines the start key
  10090. * @param to defines the end key
  10091. */
  10092. createAnimationRange(name: string, from: number, to: number): void;
  10093. /**
  10094. * Delete a specific animation range
  10095. * @param name defines the name of the range
  10096. * @param deleteFrames defines if frames must be removed as well
  10097. */
  10098. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  10099. /**
  10100. * Gets a specific animation range
  10101. * @param name defines the name of the range to look for
  10102. * @returns the requested animation range or null if not found
  10103. */
  10104. getAnimationRange(name: string): Nullable<AnimationRange>;
  10105. /**
  10106. * Gets the list of all animation ranges defined on this skeleton
  10107. * @returns an array
  10108. */
  10109. getAnimationRanges(): Nullable<AnimationRange>[];
  10110. /**
  10111. * Copy animation range from a source skeleton.
  10112. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  10113. * @param source defines the source skeleton
  10114. * @param name defines the name of the range to copy
  10115. * @param rescaleAsRequired defines if rescaling must be applied if required
  10116. * @returns true if operation was successful
  10117. */
  10118. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  10119. /**
  10120. * Forces the skeleton to go to rest pose
  10121. */
  10122. returnToRest(): void;
  10123. private _getHighestAnimationFrame;
  10124. /**
  10125. * Begin a specific animation range
  10126. * @param name defines the name of the range to start
  10127. * @param loop defines if looping must be turned on (false by default)
  10128. * @param speedRatio defines the speed ratio to apply (1 by default)
  10129. * @param onAnimationEnd defines a callback which will be called when animation will end
  10130. * @returns a new animatable
  10131. */
  10132. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10133. /** @hidden */
  10134. _markAsDirty(): void;
  10135. /** @hidden */
  10136. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10137. /** @hidden */
  10138. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10139. private _computeTransformMatrices;
  10140. /**
  10141. * Build all resources required to render a skeleton
  10142. */
  10143. prepare(): void;
  10144. /**
  10145. * Gets the list of animatables currently running for this skeleton
  10146. * @returns an array of animatables
  10147. */
  10148. getAnimatables(): IAnimatable[];
  10149. /**
  10150. * Clone the current skeleton
  10151. * @param name defines the name of the new skeleton
  10152. * @param id defines the id of the new skeleton
  10153. * @returns the new skeleton
  10154. */
  10155. clone(name: string, id: string): Skeleton;
  10156. /**
  10157. * Enable animation blending for this skeleton
  10158. * @param blendingSpeed defines the blending speed to apply
  10159. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10160. */
  10161. enableBlending(blendingSpeed?: number): void;
  10162. /**
  10163. * Releases all resources associated with the current skeleton
  10164. */
  10165. dispose(): void;
  10166. /**
  10167. * Serialize the skeleton in a JSON object
  10168. * @returns a JSON object
  10169. */
  10170. serialize(): any;
  10171. /**
  10172. * Creates a new skeleton from serialized data
  10173. * @param parsedSkeleton defines the serialized data
  10174. * @param scene defines the hosting scene
  10175. * @returns a new skeleton
  10176. */
  10177. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10178. /**
  10179. * Compute all node absolute transforms
  10180. * @param forceUpdate defines if computation must be done even if cache is up to date
  10181. */
  10182. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10183. /**
  10184. * Gets the root pose matrix
  10185. * @returns a matrix
  10186. */
  10187. getPoseMatrix(): Nullable<Matrix>;
  10188. /**
  10189. * Sorts bones per internal index
  10190. */
  10191. sortBones(): void;
  10192. private _sortBones;
  10193. }
  10194. }
  10195. declare module BABYLON {
  10196. /**
  10197. * Defines a target to use with MorphTargetManager
  10198. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10199. */
  10200. export class MorphTarget implements IAnimatable {
  10201. /** defines the name of the target */
  10202. name: string;
  10203. /**
  10204. * Gets or sets the list of animations
  10205. */
  10206. animations: Animation[];
  10207. private _scene;
  10208. private _positions;
  10209. private _normals;
  10210. private _tangents;
  10211. private _uvs;
  10212. private _influence;
  10213. /**
  10214. * Observable raised when the influence changes
  10215. */
  10216. onInfluenceChanged: Observable<boolean>;
  10217. /** @hidden */
  10218. _onDataLayoutChanged: Observable<void>;
  10219. /**
  10220. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10221. */
  10222. influence: number;
  10223. /**
  10224. * Gets or sets the id of the morph Target
  10225. */
  10226. id: string;
  10227. private _animationPropertiesOverride;
  10228. /**
  10229. * Gets or sets the animation properties override
  10230. */
  10231. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10232. /**
  10233. * Creates a new MorphTarget
  10234. * @param name defines the name of the target
  10235. * @param influence defines the influence to use
  10236. * @param scene defines the scene the morphtarget belongs to
  10237. */
  10238. constructor(
  10239. /** defines the name of the target */
  10240. name: string, influence?: number, scene?: Nullable<Scene>);
  10241. /**
  10242. * Gets a boolean defining if the target contains position data
  10243. */
  10244. readonly hasPositions: boolean;
  10245. /**
  10246. * Gets a boolean defining if the target contains normal data
  10247. */
  10248. readonly hasNormals: boolean;
  10249. /**
  10250. * Gets a boolean defining if the target contains tangent data
  10251. */
  10252. readonly hasTangents: boolean;
  10253. /**
  10254. * Gets a boolean defining if the target contains texture coordinates data
  10255. */
  10256. readonly hasUVs: boolean;
  10257. /**
  10258. * Affects position data to this target
  10259. * @param data defines the position data to use
  10260. */
  10261. setPositions(data: Nullable<FloatArray>): void;
  10262. /**
  10263. * Gets the position data stored in this target
  10264. * @returns a FloatArray containing the position data (or null if not present)
  10265. */
  10266. getPositions(): Nullable<FloatArray>;
  10267. /**
  10268. * Affects normal data to this target
  10269. * @param data defines the normal data to use
  10270. */
  10271. setNormals(data: Nullable<FloatArray>): void;
  10272. /**
  10273. * Gets the normal data stored in this target
  10274. * @returns a FloatArray containing the normal data (or null if not present)
  10275. */
  10276. getNormals(): Nullable<FloatArray>;
  10277. /**
  10278. * Affects tangent data to this target
  10279. * @param data defines the tangent data to use
  10280. */
  10281. setTangents(data: Nullable<FloatArray>): void;
  10282. /**
  10283. * Gets the tangent data stored in this target
  10284. * @returns a FloatArray containing the tangent data (or null if not present)
  10285. */
  10286. getTangents(): Nullable<FloatArray>;
  10287. /**
  10288. * Affects texture coordinates data to this target
  10289. * @param data defines the texture coordinates data to use
  10290. */
  10291. setUVs(data: Nullable<FloatArray>): void;
  10292. /**
  10293. * Gets the texture coordinates data stored in this target
  10294. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  10295. */
  10296. getUVs(): Nullable<FloatArray>;
  10297. /**
  10298. * Serializes the current target into a Serialization object
  10299. * @returns the serialized object
  10300. */
  10301. serialize(): any;
  10302. /**
  10303. * Returns the string "MorphTarget"
  10304. * @returns "MorphTarget"
  10305. */
  10306. getClassName(): string;
  10307. /**
  10308. * Creates a new target from serialized data
  10309. * @param serializationObject defines the serialized data to use
  10310. * @returns a new MorphTarget
  10311. */
  10312. static Parse(serializationObject: any): MorphTarget;
  10313. /**
  10314. * Creates a MorphTarget from mesh data
  10315. * @param mesh defines the source mesh
  10316. * @param name defines the name to use for the new target
  10317. * @param influence defines the influence to attach to the target
  10318. * @returns a new MorphTarget
  10319. */
  10320. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10321. }
  10322. }
  10323. declare module BABYLON {
  10324. /**
  10325. * This class is used to deform meshes using morphing between different targets
  10326. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10327. */
  10328. export class MorphTargetManager {
  10329. private _targets;
  10330. private _targetInfluenceChangedObservers;
  10331. private _targetDataLayoutChangedObservers;
  10332. private _activeTargets;
  10333. private _scene;
  10334. private _influences;
  10335. private _supportsNormals;
  10336. private _supportsTangents;
  10337. private _supportsUVs;
  10338. private _vertexCount;
  10339. private _uniqueId;
  10340. private _tempInfluences;
  10341. /**
  10342. * Creates a new MorphTargetManager
  10343. * @param scene defines the current scene
  10344. */
  10345. constructor(scene?: Nullable<Scene>);
  10346. /**
  10347. * Gets the unique ID of this manager
  10348. */
  10349. readonly uniqueId: number;
  10350. /**
  10351. * Gets the number of vertices handled by this manager
  10352. */
  10353. readonly vertexCount: number;
  10354. /**
  10355. * Gets a boolean indicating if this manager supports morphing of normals
  10356. */
  10357. readonly supportsNormals: boolean;
  10358. /**
  10359. * Gets a boolean indicating if this manager supports morphing of tangents
  10360. */
  10361. readonly supportsTangents: boolean;
  10362. /**
  10363. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  10364. */
  10365. readonly supportsUVs: boolean;
  10366. /**
  10367. * Gets the number of targets stored in this manager
  10368. */
  10369. readonly numTargets: number;
  10370. /**
  10371. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10372. */
  10373. readonly numInfluencers: number;
  10374. /**
  10375. * Gets the list of influences (one per target)
  10376. */
  10377. readonly influences: Float32Array;
  10378. /**
  10379. * Gets the active target at specified index. An active target is a target with an influence > 0
  10380. * @param index defines the index to check
  10381. * @returns the requested target
  10382. */
  10383. getActiveTarget(index: number): MorphTarget;
  10384. /**
  10385. * Gets the target at specified index
  10386. * @param index defines the index to check
  10387. * @returns the requested target
  10388. */
  10389. getTarget(index: number): MorphTarget;
  10390. /**
  10391. * Add a new target to this manager
  10392. * @param target defines the target to add
  10393. */
  10394. addTarget(target: MorphTarget): void;
  10395. /**
  10396. * Removes a target from the manager
  10397. * @param target defines the target to remove
  10398. */
  10399. removeTarget(target: MorphTarget): void;
  10400. /**
  10401. * Serializes the current manager into a Serialization object
  10402. * @returns the serialized object
  10403. */
  10404. serialize(): any;
  10405. private _syncActiveTargets;
  10406. /**
  10407. * Syncrhonize the targets with all the meshes using this morph target manager
  10408. */
  10409. synchronize(): void;
  10410. /**
  10411. * Creates a new MorphTargetManager from serialized data
  10412. * @param serializationObject defines the serialized data
  10413. * @param scene defines the hosting scene
  10414. * @returns the new MorphTargetManager
  10415. */
  10416. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10417. }
  10418. }
  10419. declare module BABYLON {
  10420. /**
  10421. * Groups all the scene component constants in one place to ease maintenance.
  10422. * @hidden
  10423. */
  10424. export class SceneComponentConstants {
  10425. static readonly NAME_EFFECTLAYER: string;
  10426. static readonly NAME_LAYER: string;
  10427. static readonly NAME_LENSFLARESYSTEM: string;
  10428. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10429. static readonly NAME_PARTICLESYSTEM: string;
  10430. static readonly NAME_GAMEPAD: string;
  10431. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10432. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10433. static readonly NAME_DEPTHRENDERER: string;
  10434. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10435. static readonly NAME_SPRITE: string;
  10436. static readonly NAME_OUTLINERENDERER: string;
  10437. static readonly NAME_PROCEDURALTEXTURE: string;
  10438. static readonly NAME_SHADOWGENERATOR: string;
  10439. static readonly NAME_OCTREE: string;
  10440. static readonly NAME_PHYSICSENGINE: string;
  10441. static readonly NAME_AUDIO: string;
  10442. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10443. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10444. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10445. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10446. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10447. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10448. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10449. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10450. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10451. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10452. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10453. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10454. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10455. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10456. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10457. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10458. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10459. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10460. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10461. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10462. static readonly STEP_AFTERRENDER_AUDIO: number;
  10463. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10464. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10465. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10466. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10467. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10468. static readonly STEP_POINTERMOVE_SPRITE: number;
  10469. static readonly STEP_POINTERDOWN_SPRITE: number;
  10470. static readonly STEP_POINTERUP_SPRITE: number;
  10471. }
  10472. /**
  10473. * This represents a scene component.
  10474. *
  10475. * This is used to decouple the dependency the scene is having on the different workloads like
  10476. * layers, post processes...
  10477. */
  10478. export interface ISceneComponent {
  10479. /**
  10480. * The name of the component. Each component must have a unique name.
  10481. */
  10482. name: string;
  10483. /**
  10484. * The scene the component belongs to.
  10485. */
  10486. scene: Scene;
  10487. /**
  10488. * Register the component to one instance of a scene.
  10489. */
  10490. register(): void;
  10491. /**
  10492. * Rebuilds the elements related to this component in case of
  10493. * context lost for instance.
  10494. */
  10495. rebuild(): void;
  10496. /**
  10497. * Disposes the component and the associated ressources.
  10498. */
  10499. dispose(): void;
  10500. }
  10501. /**
  10502. * This represents a SERIALIZABLE scene component.
  10503. *
  10504. * This extends Scene Component to add Serialization methods on top.
  10505. */
  10506. export interface ISceneSerializableComponent extends ISceneComponent {
  10507. /**
  10508. * Adds all the elements from the container to the scene
  10509. * @param container the container holding the elements
  10510. */
  10511. addFromContainer(container: AbstractScene): void;
  10512. /**
  10513. * Removes all the elements in the container from the scene
  10514. * @param container contains the elements to remove
  10515. * @param dispose if the removed element should be disposed (default: false)
  10516. */
  10517. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10518. /**
  10519. * Serializes the component data to the specified json object
  10520. * @param serializationObject The object to serialize to
  10521. */
  10522. serialize(serializationObject: any): void;
  10523. }
  10524. /**
  10525. * Strong typing of a Mesh related stage step action
  10526. */
  10527. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10528. /**
  10529. * Strong typing of a Evaluate Sub Mesh related stage step action
  10530. */
  10531. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10532. /**
  10533. * Strong typing of a Active Mesh related stage step action
  10534. */
  10535. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10536. /**
  10537. * Strong typing of a Camera related stage step action
  10538. */
  10539. export type CameraStageAction = (camera: Camera) => void;
  10540. /**
  10541. * Strong typing of a Camera Frame buffer related stage step action
  10542. */
  10543. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10544. /**
  10545. * Strong typing of a Render Target related stage step action
  10546. */
  10547. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10548. /**
  10549. * Strong typing of a RenderingGroup related stage step action
  10550. */
  10551. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10552. /**
  10553. * Strong typing of a Mesh Render related stage step action
  10554. */
  10555. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10556. /**
  10557. * Strong typing of a simple stage step action
  10558. */
  10559. export type SimpleStageAction = () => void;
  10560. /**
  10561. * Strong typing of a render target action.
  10562. */
  10563. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10564. /**
  10565. * Strong typing of a pointer move action.
  10566. */
  10567. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10568. /**
  10569. * Strong typing of a pointer up/down action.
  10570. */
  10571. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10572. /**
  10573. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10574. * @hidden
  10575. */
  10576. export class Stage<T extends Function> extends Array<{
  10577. index: number;
  10578. component: ISceneComponent;
  10579. action: T;
  10580. }> {
  10581. /**
  10582. * Hide ctor from the rest of the world.
  10583. * @param items The items to add.
  10584. */
  10585. private constructor();
  10586. /**
  10587. * Creates a new Stage.
  10588. * @returns A new instance of a Stage
  10589. */
  10590. static Create<T extends Function>(): Stage<T>;
  10591. /**
  10592. * Registers a step in an ordered way in the targeted stage.
  10593. * @param index Defines the position to register the step in
  10594. * @param component Defines the component attached to the step
  10595. * @param action Defines the action to launch during the step
  10596. */
  10597. registerStep(index: number, component: ISceneComponent, action: T): void;
  10598. /**
  10599. * Clears all the steps from the stage.
  10600. */
  10601. clear(): void;
  10602. }
  10603. }
  10604. declare module BABYLON {
  10605. /**
  10606. * Class used to represent a specific level of detail of a mesh
  10607. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10608. */
  10609. export class MeshLODLevel {
  10610. /** Defines the distance where this level should star being displayed */
  10611. distance: number;
  10612. /** Defines the mesh to use to render this level */
  10613. mesh: Nullable<Mesh>;
  10614. /**
  10615. * Creates a new LOD level
  10616. * @param distance defines the distance where this level should star being displayed
  10617. * @param mesh defines the mesh to use to render this level
  10618. */
  10619. constructor(
  10620. /** Defines the distance where this level should star being displayed */
  10621. distance: number,
  10622. /** Defines the mesh to use to render this level */
  10623. mesh: Nullable<Mesh>);
  10624. }
  10625. }
  10626. declare module BABYLON {
  10627. /**
  10628. * Interface describing all the common properties and methods a shadow light needs to implement.
  10629. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10630. * as well as binding the different shadow properties to the effects.
  10631. */
  10632. export interface IShadowLight extends Light {
  10633. /**
  10634. * The light id in the scene (used in scene.findLighById for instance)
  10635. */
  10636. id: string;
  10637. /**
  10638. * The position the shdow will be casted from.
  10639. */
  10640. position: Vector3;
  10641. /**
  10642. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10643. */
  10644. direction: Vector3;
  10645. /**
  10646. * The transformed position. Position of the light in world space taking parenting in account.
  10647. */
  10648. transformedPosition: Vector3;
  10649. /**
  10650. * The transformed direction. Direction of the light in world space taking parenting in account.
  10651. */
  10652. transformedDirection: Vector3;
  10653. /**
  10654. * The friendly name of the light in the scene.
  10655. */
  10656. name: string;
  10657. /**
  10658. * Defines the shadow projection clipping minimum z value.
  10659. */
  10660. shadowMinZ: number;
  10661. /**
  10662. * Defines the shadow projection clipping maximum z value.
  10663. */
  10664. shadowMaxZ: number;
  10665. /**
  10666. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10667. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10668. */
  10669. computeTransformedInformation(): boolean;
  10670. /**
  10671. * Gets the scene the light belongs to.
  10672. * @returns The scene
  10673. */
  10674. getScene(): Scene;
  10675. /**
  10676. * Callback defining a custom Projection Matrix Builder.
  10677. * This can be used to override the default projection matrix computation.
  10678. */
  10679. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10680. /**
  10681. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10682. * @param matrix The materix to updated with the projection information
  10683. * @param viewMatrix The transform matrix of the light
  10684. * @param renderList The list of mesh to render in the map
  10685. * @returns The current light
  10686. */
  10687. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10688. /**
  10689. * Gets the current depth scale used in ESM.
  10690. * @returns The scale
  10691. */
  10692. getDepthScale(): number;
  10693. /**
  10694. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10695. * @returns true if a cube texture needs to be use
  10696. */
  10697. needCube(): boolean;
  10698. /**
  10699. * Detects if the projection matrix requires to be recomputed this frame.
  10700. * @returns true if it requires to be recomputed otherwise, false.
  10701. */
  10702. needProjectionMatrixCompute(): boolean;
  10703. /**
  10704. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10705. */
  10706. forceProjectionMatrixCompute(): void;
  10707. /**
  10708. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10709. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10710. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10711. */
  10712. getShadowDirection(faceIndex?: number): Vector3;
  10713. /**
  10714. * Gets the minZ used for shadow according to both the scene and the light.
  10715. * @param activeCamera The camera we are returning the min for
  10716. * @returns the depth min z
  10717. */
  10718. getDepthMinZ(activeCamera: Camera): number;
  10719. /**
  10720. * Gets the maxZ used for shadow according to both the scene and the light.
  10721. * @param activeCamera The camera we are returning the max for
  10722. * @returns the depth max z
  10723. */
  10724. getDepthMaxZ(activeCamera: Camera): number;
  10725. }
  10726. /**
  10727. * Base implementation IShadowLight
  10728. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10729. */
  10730. export abstract class ShadowLight extends Light implements IShadowLight {
  10731. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10732. protected _position: Vector3;
  10733. protected _setPosition(value: Vector3): void;
  10734. /**
  10735. * Sets the position the shadow will be casted from. Also use as the light position for both
  10736. * point and spot lights.
  10737. */
  10738. /**
  10739. * Sets the position the shadow will be casted from. Also use as the light position for both
  10740. * point and spot lights.
  10741. */
  10742. position: Vector3;
  10743. protected _direction: Vector3;
  10744. protected _setDirection(value: Vector3): void;
  10745. /**
  10746. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10747. * Also use as the light direction on spot and directional lights.
  10748. */
  10749. /**
  10750. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10751. * Also use as the light direction on spot and directional lights.
  10752. */
  10753. direction: Vector3;
  10754. private _shadowMinZ;
  10755. /**
  10756. * Gets the shadow projection clipping minimum z value.
  10757. */
  10758. /**
  10759. * Sets the shadow projection clipping minimum z value.
  10760. */
  10761. shadowMinZ: number;
  10762. private _shadowMaxZ;
  10763. /**
  10764. * Sets the shadow projection clipping maximum z value.
  10765. */
  10766. /**
  10767. * Gets the shadow projection clipping maximum z value.
  10768. */
  10769. shadowMaxZ: number;
  10770. /**
  10771. * Callback defining a custom Projection Matrix Builder.
  10772. * This can be used to override the default projection matrix computation.
  10773. */
  10774. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10775. /**
  10776. * The transformed position. Position of the light in world space taking parenting in account.
  10777. */
  10778. transformedPosition: Vector3;
  10779. /**
  10780. * The transformed direction. Direction of the light in world space taking parenting in account.
  10781. */
  10782. transformedDirection: Vector3;
  10783. private _needProjectionMatrixCompute;
  10784. /**
  10785. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10786. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10787. */
  10788. computeTransformedInformation(): boolean;
  10789. /**
  10790. * Return the depth scale used for the shadow map.
  10791. * @returns the depth scale.
  10792. */
  10793. getDepthScale(): number;
  10794. /**
  10795. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10796. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10797. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10798. */
  10799. getShadowDirection(faceIndex?: number): Vector3;
  10800. /**
  10801. * Returns the ShadowLight absolute position in the World.
  10802. * @returns the position vector in world space
  10803. */
  10804. getAbsolutePosition(): Vector3;
  10805. /**
  10806. * Sets the ShadowLight direction toward the passed target.
  10807. * @param target The point to target in local space
  10808. * @returns the updated ShadowLight direction
  10809. */
  10810. setDirectionToTarget(target: Vector3): Vector3;
  10811. /**
  10812. * Returns the light rotation in euler definition.
  10813. * @returns the x y z rotation in local space.
  10814. */
  10815. getRotation(): Vector3;
  10816. /**
  10817. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10818. * @returns true if a cube texture needs to be use
  10819. */
  10820. needCube(): boolean;
  10821. /**
  10822. * Detects if the projection matrix requires to be recomputed this frame.
  10823. * @returns true if it requires to be recomputed otherwise, false.
  10824. */
  10825. needProjectionMatrixCompute(): boolean;
  10826. /**
  10827. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10828. */
  10829. forceProjectionMatrixCompute(): void;
  10830. /** @hidden */
  10831. _initCache(): void;
  10832. /** @hidden */
  10833. _isSynchronized(): boolean;
  10834. /**
  10835. * Computes the world matrix of the node
  10836. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10837. * @returns the world matrix
  10838. */
  10839. computeWorldMatrix(force?: boolean): Matrix;
  10840. /**
  10841. * Gets the minZ used for shadow according to both the scene and the light.
  10842. * @param activeCamera The camera we are returning the min for
  10843. * @returns the depth min z
  10844. */
  10845. getDepthMinZ(activeCamera: Camera): number;
  10846. /**
  10847. * Gets the maxZ used for shadow according to both the scene and the light.
  10848. * @param activeCamera The camera we are returning the max for
  10849. * @returns the depth max z
  10850. */
  10851. getDepthMaxZ(activeCamera: Camera): number;
  10852. /**
  10853. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10854. * @param matrix The materix to updated with the projection information
  10855. * @param viewMatrix The transform matrix of the light
  10856. * @param renderList The list of mesh to render in the map
  10857. * @returns The current light
  10858. */
  10859. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10860. }
  10861. }
  10862. declare module BABYLON {
  10863. /**
  10864. * "Static Class" containing the most commonly used helper while dealing with material for
  10865. * rendering purpose.
  10866. *
  10867. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  10868. *
  10869. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  10870. */
  10871. export class MaterialHelper {
  10872. /**
  10873. * Bind the current view position to an effect.
  10874. * @param effect The effect to be bound
  10875. * @param scene The scene the eyes position is used from
  10876. */
  10877. static BindEyePosition(effect: Effect, scene: Scene): void;
  10878. /**
  10879. * Helps preparing the defines values about the UVs in used in the effect.
  10880. * UVs are shared as much as we can accross channels in the shaders.
  10881. * @param texture The texture we are preparing the UVs for
  10882. * @param defines The defines to update
  10883. * @param key The channel key "diffuse", "specular"... used in the shader
  10884. */
  10885. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  10886. /**
  10887. * Binds a texture matrix value to its corrsponding uniform
  10888. * @param texture The texture to bind the matrix for
  10889. * @param uniformBuffer The uniform buffer receivin the data
  10890. * @param key The channel key "diffuse", "specular"... used in the shader
  10891. */
  10892. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  10893. /**
  10894. * Gets the current status of the fog (should it be enabled?)
  10895. * @param mesh defines the mesh to evaluate for fog support
  10896. * @param scene defines the hosting scene
  10897. * @returns true if fog must be enabled
  10898. */
  10899. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  10900. /**
  10901. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  10902. * @param mesh defines the current mesh
  10903. * @param scene defines the current scene
  10904. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  10905. * @param pointsCloud defines if point cloud rendering has to be turned on
  10906. * @param fogEnabled defines if fog has to be turned on
  10907. * @param alphaTest defines if alpha testing has to be turned on
  10908. * @param defines defines the current list of defines
  10909. */
  10910. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  10911. /**
  10912. * Helper used to prepare the list of defines associated with frame values for shader compilation
  10913. * @param scene defines the current scene
  10914. * @param engine defines the current engine
  10915. * @param defines specifies the list of active defines
  10916. * @param useInstances defines if instances have to be turned on
  10917. * @param useClipPlane defines if clip plane have to be turned on
  10918. */
  10919. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  10920. /**
  10921. * Prepares the defines for bones
  10922. * @param mesh The mesh containing the geometry data we will draw
  10923. * @param defines The defines to update
  10924. */
  10925. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  10926. /**
  10927. * Prepares the defines for morph targets
  10928. * @param mesh The mesh containing the geometry data we will draw
  10929. * @param defines The defines to update
  10930. */
  10931. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  10932. /**
  10933. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  10934. * @param mesh The mesh containing the geometry data we will draw
  10935. * @param defines The defines to update
  10936. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  10937. * @param useBones Precise whether bones should be used or not (override mesh info)
  10938. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  10939. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  10940. * @returns false if defines are considered not dirty and have not been checked
  10941. */
  10942. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  10943. /**
  10944. * Prepares the defines related to multiview
  10945. * @param scene The scene we are intending to draw
  10946. * @param defines The defines to update
  10947. */
  10948. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  10949. /**
  10950. * Prepares the defines related to the light information passed in parameter
  10951. * @param scene The scene we are intending to draw
  10952. * @param mesh The mesh the effect is compiling for
  10953. * @param light The light the effect is compiling for
  10954. * @param lightIndex The index of the light
  10955. * @param defines The defines to update
  10956. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10957. * @param state Defines the current state regarding what is needed (normals, etc...)
  10958. */
  10959. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  10960. needNormals: boolean;
  10961. needRebuild: boolean;
  10962. shadowEnabled: boolean;
  10963. specularEnabled: boolean;
  10964. lightmapMode: boolean;
  10965. }): void;
  10966. /**
  10967. * Prepares the defines related to the light information passed in parameter
  10968. * @param scene The scene we are intending to draw
  10969. * @param mesh The mesh the effect is compiling for
  10970. * @param defines The defines to update
  10971. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10972. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  10973. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  10974. * @returns true if normals will be required for the rest of the effect
  10975. */
  10976. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  10977. /**
  10978. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  10979. * @param lightIndex defines the light index
  10980. * @param uniformsList The uniform list
  10981. * @param samplersList The sampler list
  10982. * @param projectedLightTexture defines if projected texture must be used
  10983. * @param uniformBuffersList defines an optional list of uniform buffers
  10984. */
  10985. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  10986. /**
  10987. * Prepares the uniforms and samplers list to be used in the effect
  10988. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  10989. * @param samplersList The sampler list
  10990. * @param defines The defines helping in the list generation
  10991. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  10992. */
  10993. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  10994. /**
  10995. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  10996. * @param defines The defines to update while falling back
  10997. * @param fallbacks The authorized effect fallbacks
  10998. * @param maxSimultaneousLights The maximum number of lights allowed
  10999. * @param rank the current rank of the Effect
  11000. * @returns The newly affected rank
  11001. */
  11002. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  11003. private static _TmpMorphInfluencers;
  11004. /**
  11005. * Prepares the list of attributes required for morph targets according to the effect defines.
  11006. * @param attribs The current list of supported attribs
  11007. * @param mesh The mesh to prepare the morph targets attributes for
  11008. * @param influencers The number of influencers
  11009. */
  11010. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  11011. /**
  11012. * Prepares the list of attributes required for morph targets according to the effect defines.
  11013. * @param attribs The current list of supported attribs
  11014. * @param mesh The mesh to prepare the morph targets attributes for
  11015. * @param defines The current Defines of the effect
  11016. */
  11017. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  11018. /**
  11019. * Prepares the list of attributes required for bones according to the effect defines.
  11020. * @param attribs The current list of supported attribs
  11021. * @param mesh The mesh to prepare the bones attributes for
  11022. * @param defines The current Defines of the effect
  11023. * @param fallbacks The current efffect fallback strategy
  11024. */
  11025. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  11026. /**
  11027. * Check and prepare the list of attributes required for instances according to the effect defines.
  11028. * @param attribs The current list of supported attribs
  11029. * @param defines The current MaterialDefines of the effect
  11030. */
  11031. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  11032. /**
  11033. * Add the list of attributes required for instances to the attribs array.
  11034. * @param attribs The current list of supported attribs
  11035. */
  11036. static PushAttributesForInstances(attribs: string[]): void;
  11037. /**
  11038. * Binds the light shadow information to the effect for the given mesh.
  11039. * @param light The light containing the generator
  11040. * @param scene The scene the lights belongs to
  11041. * @param mesh The mesh we are binding the information to render
  11042. * @param lightIndex The light index in the effect used to render the mesh
  11043. * @param effect The effect we are binding the data to
  11044. */
  11045. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  11046. /**
  11047. * Binds the light information to the effect.
  11048. * @param light The light containing the generator
  11049. * @param effect The effect we are binding the data to
  11050. * @param lightIndex The light index in the effect used to render
  11051. */
  11052. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  11053. /**
  11054. * Binds the lights information from the scene to the effect for the given mesh.
  11055. * @param light Light to bind
  11056. * @param lightIndex Light index
  11057. * @param scene The scene where the light belongs to
  11058. * @param mesh The mesh we are binding the information to render
  11059. * @param effect The effect we are binding the data to
  11060. * @param useSpecular Defines if specular is supported
  11061. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11062. */
  11063. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  11064. /**
  11065. * Binds the lights information from the scene to the effect for the given mesh.
  11066. * @param scene The scene the lights belongs to
  11067. * @param mesh The mesh we are binding the information to render
  11068. * @param effect The effect we are binding the data to
  11069. * @param defines The generated defines for the effect
  11070. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  11071. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11072. */
  11073. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11074. private static _tempFogColor;
  11075. /**
  11076. * Binds the fog information from the scene to the effect for the given mesh.
  11077. * @param scene The scene the lights belongs to
  11078. * @param mesh The mesh we are binding the information to render
  11079. * @param effect The effect we are binding the data to
  11080. * @param linearSpace Defines if the fog effect is applied in linear space
  11081. */
  11082. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  11083. /**
  11084. * Binds the bones information from the mesh to the effect.
  11085. * @param mesh The mesh we are binding the information to render
  11086. * @param effect The effect we are binding the data to
  11087. */
  11088. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11089. /**
  11090. * Binds the morph targets information from the mesh to the effect.
  11091. * @param abstractMesh The mesh we are binding the information to render
  11092. * @param effect The effect we are binding the data to
  11093. */
  11094. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11095. /**
  11096. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11097. * @param defines The generated defines used in the effect
  11098. * @param effect The effect we are binding the data to
  11099. * @param scene The scene we are willing to render with logarithmic scale for
  11100. */
  11101. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11102. /**
  11103. * Binds the clip plane information from the scene to the effect.
  11104. * @param scene The scene the clip plane information are extracted from
  11105. * @param effect The effect we are binding the data to
  11106. */
  11107. static BindClipPlane(effect: Effect, scene: Scene): void;
  11108. }
  11109. }
  11110. declare module BABYLON {
  11111. /** @hidden */
  11112. export var shadowMapPixelShader: {
  11113. name: string;
  11114. shader: string;
  11115. };
  11116. }
  11117. declare module BABYLON {
  11118. /** @hidden */
  11119. export var bonesDeclaration: {
  11120. name: string;
  11121. shader: string;
  11122. };
  11123. }
  11124. declare module BABYLON {
  11125. /** @hidden */
  11126. export var morphTargetsVertexGlobalDeclaration: {
  11127. name: string;
  11128. shader: string;
  11129. };
  11130. }
  11131. declare module BABYLON {
  11132. /** @hidden */
  11133. export var morphTargetsVertexDeclaration: {
  11134. name: string;
  11135. shader: string;
  11136. };
  11137. }
  11138. declare module BABYLON {
  11139. /** @hidden */
  11140. export var instancesDeclaration: {
  11141. name: string;
  11142. shader: string;
  11143. };
  11144. }
  11145. declare module BABYLON {
  11146. /** @hidden */
  11147. export var morphTargetsVertex: {
  11148. name: string;
  11149. shader: string;
  11150. };
  11151. }
  11152. declare module BABYLON {
  11153. /** @hidden */
  11154. export var instancesVertex: {
  11155. name: string;
  11156. shader: string;
  11157. };
  11158. }
  11159. declare module BABYLON {
  11160. /** @hidden */
  11161. export var bonesVertex: {
  11162. name: string;
  11163. shader: string;
  11164. };
  11165. }
  11166. declare module BABYLON {
  11167. /** @hidden */
  11168. export var shadowMapVertexShader: {
  11169. name: string;
  11170. shader: string;
  11171. };
  11172. }
  11173. declare module BABYLON {
  11174. /** @hidden */
  11175. export var depthBoxBlurPixelShader: {
  11176. name: string;
  11177. shader: string;
  11178. };
  11179. }
  11180. declare module BABYLON {
  11181. /**
  11182. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11183. */
  11184. export interface ICustomShaderOptions {
  11185. /**
  11186. * Gets or sets the custom shader name to use
  11187. */
  11188. shaderName: string;
  11189. /**
  11190. * The list of attribute names used in the shader
  11191. */
  11192. attributes?: string[];
  11193. /**
  11194. * The list of unifrom names used in the shader
  11195. */
  11196. uniforms?: string[];
  11197. /**
  11198. * The list of sampler names used in the shader
  11199. */
  11200. samplers?: string[];
  11201. /**
  11202. * The list of defines used in the shader
  11203. */
  11204. defines?: string[];
  11205. }
  11206. /**
  11207. * Interface to implement to create a shadow generator compatible with BJS.
  11208. */
  11209. export interface IShadowGenerator {
  11210. /**
  11211. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11212. * @returns The render target texture if present otherwise, null
  11213. */
  11214. getShadowMap(): Nullable<RenderTargetTexture>;
  11215. /**
  11216. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11217. * @returns The render target texture if the shadow map is present otherwise, null
  11218. */
  11219. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11220. /**
  11221. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11222. * @param subMesh The submesh we want to render in the shadow map
  11223. * @param useInstances Defines wether will draw in the map using instances
  11224. * @returns true if ready otherwise, false
  11225. */
  11226. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11227. /**
  11228. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11229. * @param defines Defines of the material we want to update
  11230. * @param lightIndex Index of the light in the enabled light list of the material
  11231. */
  11232. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11233. /**
  11234. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11235. * defined in the generator but impacting the effect).
  11236. * It implies the unifroms available on the materials are the standard BJS ones.
  11237. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11238. * @param effect The effect we are binfing the information for
  11239. */
  11240. bindShadowLight(lightIndex: string, effect: Effect): void;
  11241. /**
  11242. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11243. * (eq to shadow prjection matrix * light transform matrix)
  11244. * @returns The transform matrix used to create the shadow map
  11245. */
  11246. getTransformMatrix(): Matrix;
  11247. /**
  11248. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11249. * Cube and 2D textures for instance.
  11250. */
  11251. recreateShadowMap(): void;
  11252. /**
  11253. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11254. * @param onCompiled Callback triggered at the and of the effects compilation
  11255. * @param options Sets of optional options forcing the compilation with different modes
  11256. */
  11257. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11258. useInstances: boolean;
  11259. }>): void;
  11260. /**
  11261. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11262. * @param options Sets of optional options forcing the compilation with different modes
  11263. * @returns A promise that resolves when the compilation completes
  11264. */
  11265. forceCompilationAsync(options?: Partial<{
  11266. useInstances: boolean;
  11267. }>): Promise<void>;
  11268. /**
  11269. * Serializes the shadow generator setup to a json object.
  11270. * @returns The serialized JSON object
  11271. */
  11272. serialize(): any;
  11273. /**
  11274. * Disposes the Shadow map and related Textures and effects.
  11275. */
  11276. dispose(): void;
  11277. }
  11278. /**
  11279. * Default implementation IShadowGenerator.
  11280. * This is the main object responsible of generating shadows in the framework.
  11281. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11282. */
  11283. export class ShadowGenerator implements IShadowGenerator {
  11284. /**
  11285. * Shadow generator mode None: no filtering applied.
  11286. */
  11287. static readonly FILTER_NONE: number;
  11288. /**
  11289. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11290. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11291. */
  11292. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11293. /**
  11294. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11295. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11296. */
  11297. static readonly FILTER_POISSONSAMPLING: number;
  11298. /**
  11299. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11300. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11301. */
  11302. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11303. /**
  11304. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11305. * edge artifacts on steep falloff.
  11306. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11307. */
  11308. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11309. /**
  11310. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11311. * edge artifacts on steep falloff.
  11312. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11313. */
  11314. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11315. /**
  11316. * Shadow generator mode PCF: Percentage Closer Filtering
  11317. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11318. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11319. */
  11320. static readonly FILTER_PCF: number;
  11321. /**
  11322. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11323. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11324. * Contact Hardening
  11325. */
  11326. static readonly FILTER_PCSS: number;
  11327. /**
  11328. * Reserved for PCF and PCSS
  11329. * Highest Quality.
  11330. *
  11331. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11332. *
  11333. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11334. */
  11335. static readonly QUALITY_HIGH: number;
  11336. /**
  11337. * Reserved for PCF and PCSS
  11338. * Good tradeoff for quality/perf cross devices
  11339. *
  11340. * Execute PCF on a 3*3 kernel.
  11341. *
  11342. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11343. */
  11344. static readonly QUALITY_MEDIUM: number;
  11345. /**
  11346. * Reserved for PCF and PCSS
  11347. * The lowest quality but the fastest.
  11348. *
  11349. * Execute PCF on a 1*1 kernel.
  11350. *
  11351. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11352. */
  11353. static readonly QUALITY_LOW: number;
  11354. /** Gets or sets the custom shader name to use */
  11355. customShaderOptions: ICustomShaderOptions;
  11356. /**
  11357. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11358. */
  11359. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11360. /**
  11361. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11362. */
  11363. onAfterShadowMapRenderObservable: Observable<Effect>;
  11364. /**
  11365. * Observable triggered before a mesh is rendered in the shadow map.
  11366. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11367. */
  11368. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11369. /**
  11370. * Observable triggered after a mesh is rendered in the shadow map.
  11371. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11372. */
  11373. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11374. private _bias;
  11375. /**
  11376. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11377. */
  11378. /**
  11379. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11380. */
  11381. bias: number;
  11382. private _normalBias;
  11383. /**
  11384. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11385. */
  11386. /**
  11387. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11388. */
  11389. normalBias: number;
  11390. private _blurBoxOffset;
  11391. /**
  11392. * Gets the blur box offset: offset applied during the blur pass.
  11393. * Only useful if useKernelBlur = false
  11394. */
  11395. /**
  11396. * Sets the blur box offset: offset applied during the blur pass.
  11397. * Only useful if useKernelBlur = false
  11398. */
  11399. blurBoxOffset: number;
  11400. private _blurScale;
  11401. /**
  11402. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11403. * 2 means half of the size.
  11404. */
  11405. /**
  11406. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11407. * 2 means half of the size.
  11408. */
  11409. blurScale: number;
  11410. private _blurKernel;
  11411. /**
  11412. * Gets the blur kernel: kernel size of the blur pass.
  11413. * Only useful if useKernelBlur = true
  11414. */
  11415. /**
  11416. * Sets the blur kernel: kernel size of the blur pass.
  11417. * Only useful if useKernelBlur = true
  11418. */
  11419. blurKernel: number;
  11420. private _useKernelBlur;
  11421. /**
  11422. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11423. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11424. */
  11425. /**
  11426. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11427. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11428. */
  11429. useKernelBlur: boolean;
  11430. private _depthScale;
  11431. /**
  11432. * Gets the depth scale used in ESM mode.
  11433. */
  11434. /**
  11435. * Sets the depth scale used in ESM mode.
  11436. * This can override the scale stored on the light.
  11437. */
  11438. depthScale: number;
  11439. private _filter;
  11440. /**
  11441. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11442. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11443. */
  11444. /**
  11445. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11446. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11447. */
  11448. filter: number;
  11449. /**
  11450. * Gets if the current filter is set to Poisson Sampling.
  11451. */
  11452. /**
  11453. * Sets the current filter to Poisson Sampling.
  11454. */
  11455. usePoissonSampling: boolean;
  11456. /**
  11457. * Gets if the current filter is set to ESM.
  11458. */
  11459. /**
  11460. * Sets the current filter is to ESM.
  11461. */
  11462. useExponentialShadowMap: boolean;
  11463. /**
  11464. * Gets if the current filter is set to filtered ESM.
  11465. */
  11466. /**
  11467. * Gets if the current filter is set to filtered ESM.
  11468. */
  11469. useBlurExponentialShadowMap: boolean;
  11470. /**
  11471. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11472. * exponential to prevent steep falloff artifacts).
  11473. */
  11474. /**
  11475. * Sets the current filter to "close ESM" (using the inverse of the
  11476. * exponential to prevent steep falloff artifacts).
  11477. */
  11478. useCloseExponentialShadowMap: boolean;
  11479. /**
  11480. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11481. * exponential to prevent steep falloff artifacts).
  11482. */
  11483. /**
  11484. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11485. * exponential to prevent steep falloff artifacts).
  11486. */
  11487. useBlurCloseExponentialShadowMap: boolean;
  11488. /**
  11489. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11490. */
  11491. /**
  11492. * Sets the current filter to "PCF" (percentage closer filtering).
  11493. */
  11494. usePercentageCloserFiltering: boolean;
  11495. private _filteringQuality;
  11496. /**
  11497. * Gets the PCF or PCSS Quality.
  11498. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11499. */
  11500. /**
  11501. * Sets the PCF or PCSS Quality.
  11502. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11503. */
  11504. filteringQuality: number;
  11505. /**
  11506. * Gets if the current filter is set to "PCSS" (contact hardening).
  11507. */
  11508. /**
  11509. * Sets the current filter to "PCSS" (contact hardening).
  11510. */
  11511. useContactHardeningShadow: boolean;
  11512. private _contactHardeningLightSizeUVRatio;
  11513. /**
  11514. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11515. * Using a ratio helps keeping shape stability independently of the map size.
  11516. *
  11517. * It does not account for the light projection as it was having too much
  11518. * instability during the light setup or during light position changes.
  11519. *
  11520. * Only valid if useContactHardeningShadow is true.
  11521. */
  11522. /**
  11523. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11524. * Using a ratio helps keeping shape stability independently of the map size.
  11525. *
  11526. * It does not account for the light projection as it was having too much
  11527. * instability during the light setup or during light position changes.
  11528. *
  11529. * Only valid if useContactHardeningShadow is true.
  11530. */
  11531. contactHardeningLightSizeUVRatio: number;
  11532. private _darkness;
  11533. /** Gets or sets the actual darkness of a shadow */
  11534. darkness: number;
  11535. /**
  11536. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11537. * 0 means strongest and 1 would means no shadow.
  11538. * @returns the darkness.
  11539. */
  11540. getDarkness(): number;
  11541. /**
  11542. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11543. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11544. * @returns the shadow generator allowing fluent coding.
  11545. */
  11546. setDarkness(darkness: number): ShadowGenerator;
  11547. private _transparencyShadow;
  11548. /** Gets or sets the ability to have transparent shadow */
  11549. transparencyShadow: boolean;
  11550. /**
  11551. * Sets the ability to have transparent shadow (boolean).
  11552. * @param transparent True if transparent else False
  11553. * @returns the shadow generator allowing fluent coding
  11554. */
  11555. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11556. private _shadowMap;
  11557. private _shadowMap2;
  11558. /**
  11559. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11560. * @returns The render target texture if present otherwise, null
  11561. */
  11562. getShadowMap(): Nullable<RenderTargetTexture>;
  11563. /**
  11564. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11565. * @returns The render target texture if the shadow map is present otherwise, null
  11566. */
  11567. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11568. /**
  11569. * Gets the class name of that object
  11570. * @returns "ShadowGenerator"
  11571. */
  11572. getClassName(): string;
  11573. /**
  11574. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11575. * @param mesh Mesh to add
  11576. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11577. * @returns the Shadow Generator itself
  11578. */
  11579. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11580. /**
  11581. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11582. * @param mesh Mesh to remove
  11583. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11584. * @returns the Shadow Generator itself
  11585. */
  11586. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11587. /**
  11588. * Controls the extent to which the shadows fade out at the edge of the frustum
  11589. * Used only by directionals and spots
  11590. */
  11591. frustumEdgeFalloff: number;
  11592. private _light;
  11593. /**
  11594. * Returns the associated light object.
  11595. * @returns the light generating the shadow
  11596. */
  11597. getLight(): IShadowLight;
  11598. /**
  11599. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11600. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11601. * It might on the other hand introduce peter panning.
  11602. */
  11603. forceBackFacesOnly: boolean;
  11604. private _scene;
  11605. private _lightDirection;
  11606. private _effect;
  11607. private _viewMatrix;
  11608. private _projectionMatrix;
  11609. private _transformMatrix;
  11610. private _cachedPosition;
  11611. private _cachedDirection;
  11612. private _cachedDefines;
  11613. private _currentRenderID;
  11614. private _boxBlurPostprocess;
  11615. private _kernelBlurXPostprocess;
  11616. private _kernelBlurYPostprocess;
  11617. private _blurPostProcesses;
  11618. private _mapSize;
  11619. private _currentFaceIndex;
  11620. private _currentFaceIndexCache;
  11621. private _textureType;
  11622. private _defaultTextureMatrix;
  11623. /** @hidden */
  11624. static _SceneComponentInitialization: (scene: Scene) => void;
  11625. /**
  11626. * Creates a ShadowGenerator object.
  11627. * A ShadowGenerator is the required tool to use the shadows.
  11628. * Each light casting shadows needs to use its own ShadowGenerator.
  11629. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11630. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11631. * @param light The light object generating the shadows.
  11632. * @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.
  11633. */
  11634. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11635. private _initializeGenerator;
  11636. private _initializeShadowMap;
  11637. private _initializeBlurRTTAndPostProcesses;
  11638. private _renderForShadowMap;
  11639. private _renderSubMeshForShadowMap;
  11640. private _applyFilterValues;
  11641. /**
  11642. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11643. * @param onCompiled Callback triggered at the and of the effects compilation
  11644. * @param options Sets of optional options forcing the compilation with different modes
  11645. */
  11646. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11647. useInstances: boolean;
  11648. }>): void;
  11649. /**
  11650. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11651. * @param options Sets of optional options forcing the compilation with different modes
  11652. * @returns A promise that resolves when the compilation completes
  11653. */
  11654. forceCompilationAsync(options?: Partial<{
  11655. useInstances: boolean;
  11656. }>): Promise<void>;
  11657. /**
  11658. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11659. * @param subMesh The submesh we want to render in the shadow map
  11660. * @param useInstances Defines wether will draw in the map using instances
  11661. * @returns true if ready otherwise, false
  11662. */
  11663. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11664. /**
  11665. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11666. * @param defines Defines of the material we want to update
  11667. * @param lightIndex Index of the light in the enabled light list of the material
  11668. */
  11669. prepareDefines(defines: any, lightIndex: number): void;
  11670. /**
  11671. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11672. * defined in the generator but impacting the effect).
  11673. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11674. * @param effect The effect we are binfing the information for
  11675. */
  11676. bindShadowLight(lightIndex: string, effect: Effect): void;
  11677. /**
  11678. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11679. * (eq to shadow prjection matrix * light transform matrix)
  11680. * @returns The transform matrix used to create the shadow map
  11681. */
  11682. getTransformMatrix(): Matrix;
  11683. /**
  11684. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11685. * Cube and 2D textures for instance.
  11686. */
  11687. recreateShadowMap(): void;
  11688. private _disposeBlurPostProcesses;
  11689. private _disposeRTTandPostProcesses;
  11690. /**
  11691. * Disposes the ShadowGenerator.
  11692. * Returns nothing.
  11693. */
  11694. dispose(): void;
  11695. /**
  11696. * Serializes the shadow generator setup to a json object.
  11697. * @returns The serialized JSON object
  11698. */
  11699. serialize(): any;
  11700. /**
  11701. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11702. * @param parsedShadowGenerator The JSON object to parse
  11703. * @param scene The scene to create the shadow map for
  11704. * @returns The parsed shadow generator
  11705. */
  11706. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11707. }
  11708. }
  11709. declare module BABYLON {
  11710. /**
  11711. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11712. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11713. * 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.
  11714. */
  11715. export abstract class Light extends Node {
  11716. /**
  11717. * Falloff Default: light is falling off following the material specification:
  11718. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11719. */
  11720. static readonly FALLOFF_DEFAULT: number;
  11721. /**
  11722. * Falloff Physical: light is falling off following the inverse squared distance law.
  11723. */
  11724. static readonly FALLOFF_PHYSICAL: number;
  11725. /**
  11726. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11727. * to enhance interoperability with other engines.
  11728. */
  11729. static readonly FALLOFF_GLTF: number;
  11730. /**
  11731. * Falloff Standard: light is falling off like in the standard material
  11732. * to enhance interoperability with other materials.
  11733. */
  11734. static readonly FALLOFF_STANDARD: number;
  11735. /**
  11736. * If every light affecting the material is in this lightmapMode,
  11737. * material.lightmapTexture adds or multiplies
  11738. * (depends on material.useLightmapAsShadowmap)
  11739. * after every other light calculations.
  11740. */
  11741. static readonly LIGHTMAP_DEFAULT: number;
  11742. /**
  11743. * material.lightmapTexture as only diffuse lighting from this light
  11744. * adds only specular lighting from this light
  11745. * adds dynamic shadows
  11746. */
  11747. static readonly LIGHTMAP_SPECULAR: number;
  11748. /**
  11749. * material.lightmapTexture as only lighting
  11750. * no light calculation from this light
  11751. * only adds dynamic shadows from this light
  11752. */
  11753. static readonly LIGHTMAP_SHADOWSONLY: number;
  11754. /**
  11755. * Each light type uses the default quantity according to its type:
  11756. * point/spot lights use luminous intensity
  11757. * directional lights use illuminance
  11758. */
  11759. static readonly INTENSITYMODE_AUTOMATIC: number;
  11760. /**
  11761. * lumen (lm)
  11762. */
  11763. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11764. /**
  11765. * candela (lm/sr)
  11766. */
  11767. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11768. /**
  11769. * lux (lm/m^2)
  11770. */
  11771. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11772. /**
  11773. * nit (cd/m^2)
  11774. */
  11775. static readonly INTENSITYMODE_LUMINANCE: number;
  11776. /**
  11777. * Light type const id of the point light.
  11778. */
  11779. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11780. /**
  11781. * Light type const id of the directional light.
  11782. */
  11783. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11784. /**
  11785. * Light type const id of the spot light.
  11786. */
  11787. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11788. /**
  11789. * Light type const id of the hemispheric light.
  11790. */
  11791. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11792. /**
  11793. * Diffuse gives the basic color to an object.
  11794. */
  11795. diffuse: Color3;
  11796. /**
  11797. * Specular produces a highlight color on an object.
  11798. * Note: This is note affecting PBR materials.
  11799. */
  11800. specular: Color3;
  11801. /**
  11802. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11803. * falling off base on range or angle.
  11804. * This can be set to any values in Light.FALLOFF_x.
  11805. *
  11806. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11807. * other types of materials.
  11808. */
  11809. falloffType: number;
  11810. /**
  11811. * Strength of the light.
  11812. * Note: By default it is define in the framework own unit.
  11813. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11814. */
  11815. intensity: number;
  11816. private _range;
  11817. protected _inverseSquaredRange: number;
  11818. /**
  11819. * Defines how far from the source the light is impacting in scene units.
  11820. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11821. */
  11822. /**
  11823. * Defines how far from the source the light is impacting in scene units.
  11824. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11825. */
  11826. range: number;
  11827. /**
  11828. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11829. * of light.
  11830. */
  11831. private _photometricScale;
  11832. private _intensityMode;
  11833. /**
  11834. * Gets the photometric scale used to interpret the intensity.
  11835. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11836. */
  11837. /**
  11838. * Sets the photometric scale used to interpret the intensity.
  11839. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11840. */
  11841. intensityMode: number;
  11842. private _radius;
  11843. /**
  11844. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11845. */
  11846. /**
  11847. * sets the light radius used by PBR Materials to simulate soft area lights.
  11848. */
  11849. radius: number;
  11850. private _renderPriority;
  11851. /**
  11852. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11853. * exceeding the number allowed of the materials.
  11854. */
  11855. renderPriority: number;
  11856. private _shadowEnabled;
  11857. /**
  11858. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11859. * the current shadow generator.
  11860. */
  11861. /**
  11862. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11863. * the current shadow generator.
  11864. */
  11865. shadowEnabled: boolean;
  11866. private _includedOnlyMeshes;
  11867. /**
  11868. * Gets the only meshes impacted by this light.
  11869. */
  11870. /**
  11871. * Sets the only meshes impacted by this light.
  11872. */
  11873. includedOnlyMeshes: AbstractMesh[];
  11874. private _excludedMeshes;
  11875. /**
  11876. * Gets the meshes not impacted by this light.
  11877. */
  11878. /**
  11879. * Sets the meshes not impacted by this light.
  11880. */
  11881. excludedMeshes: AbstractMesh[];
  11882. private _excludeWithLayerMask;
  11883. /**
  11884. * Gets the layer id use to find what meshes are not impacted by the light.
  11885. * Inactive if 0
  11886. */
  11887. /**
  11888. * Sets the layer id use to find what meshes are not impacted by the light.
  11889. * Inactive if 0
  11890. */
  11891. excludeWithLayerMask: number;
  11892. private _includeOnlyWithLayerMask;
  11893. /**
  11894. * Gets the layer id use to find what meshes are impacted by the light.
  11895. * Inactive if 0
  11896. */
  11897. /**
  11898. * Sets the layer id use to find what meshes are impacted by the light.
  11899. * Inactive if 0
  11900. */
  11901. includeOnlyWithLayerMask: number;
  11902. private _lightmapMode;
  11903. /**
  11904. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11905. */
  11906. /**
  11907. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11908. */
  11909. lightmapMode: number;
  11910. /**
  11911. * Shadow generator associted to the light.
  11912. * @hidden Internal use only.
  11913. */
  11914. _shadowGenerator: Nullable<IShadowGenerator>;
  11915. /**
  11916. * @hidden Internal use only.
  11917. */
  11918. _excludedMeshesIds: string[];
  11919. /**
  11920. * @hidden Internal use only.
  11921. */
  11922. _includedOnlyMeshesIds: string[];
  11923. /**
  11924. * The current light unifom buffer.
  11925. * @hidden Internal use only.
  11926. */
  11927. _uniformBuffer: UniformBuffer;
  11928. /**
  11929. * Creates a Light object in the scene.
  11930. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11931. * @param name The firendly name of the light
  11932. * @param scene The scene the light belongs too
  11933. */
  11934. constructor(name: string, scene: Scene);
  11935. protected abstract _buildUniformLayout(): void;
  11936. /**
  11937. * Sets the passed Effect "effect" with the Light information.
  11938. * @param effect The effect to update
  11939. * @param lightIndex The index of the light in the effect to update
  11940. * @returns The light
  11941. */
  11942. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11943. /**
  11944. * Returns the string "Light".
  11945. * @returns the class name
  11946. */
  11947. getClassName(): string;
  11948. /** @hidden */
  11949. readonly _isLight: boolean;
  11950. /**
  11951. * Converts the light information to a readable string for debug purpose.
  11952. * @param fullDetails Supports for multiple levels of logging within scene loading
  11953. * @returns the human readable light info
  11954. */
  11955. toString(fullDetails?: boolean): string;
  11956. /** @hidden */
  11957. protected _syncParentEnabledState(): void;
  11958. /**
  11959. * Set the enabled state of this node.
  11960. * @param value - the new enabled state
  11961. */
  11962. setEnabled(value: boolean): void;
  11963. /**
  11964. * Returns the Light associated shadow generator if any.
  11965. * @return the associated shadow generator.
  11966. */
  11967. getShadowGenerator(): Nullable<IShadowGenerator>;
  11968. /**
  11969. * Returns a Vector3, the absolute light position in the World.
  11970. * @returns the world space position of the light
  11971. */
  11972. getAbsolutePosition(): Vector3;
  11973. /**
  11974. * Specifies if the light will affect the passed mesh.
  11975. * @param mesh The mesh to test against the light
  11976. * @return true the mesh is affected otherwise, false.
  11977. */
  11978. canAffectMesh(mesh: AbstractMesh): boolean;
  11979. /**
  11980. * Sort function to order lights for rendering.
  11981. * @param a First Light object to compare to second.
  11982. * @param b Second Light object to compare first.
  11983. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11984. */
  11985. static CompareLightsPriority(a: Light, b: Light): number;
  11986. /**
  11987. * Releases resources associated with this node.
  11988. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11989. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11990. */
  11991. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11992. /**
  11993. * Returns the light type ID (integer).
  11994. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11995. */
  11996. getTypeID(): number;
  11997. /**
  11998. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11999. * @returns the scaled intensity in intensity mode unit
  12000. */
  12001. getScaledIntensity(): number;
  12002. /**
  12003. * Returns a new Light object, named "name", from the current one.
  12004. * @param name The name of the cloned light
  12005. * @returns the new created light
  12006. */
  12007. clone(name: string): Nullable<Light>;
  12008. /**
  12009. * Serializes the current light into a Serialization object.
  12010. * @returns the serialized object.
  12011. */
  12012. serialize(): any;
  12013. /**
  12014. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12015. * This new light is named "name" and added to the passed scene.
  12016. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12017. * @param name The friendly name of the light
  12018. * @param scene The scene the new light will belong to
  12019. * @returns the constructor function
  12020. */
  12021. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12022. /**
  12023. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12024. * @param parsedLight The JSON representation of the light
  12025. * @param scene The scene to create the parsed light in
  12026. * @returns the created light after parsing
  12027. */
  12028. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12029. private _hookArrayForExcluded;
  12030. private _hookArrayForIncludedOnly;
  12031. private _resyncMeshes;
  12032. /**
  12033. * Forces the meshes to update their light related information in their rendering used effects
  12034. * @hidden Internal Use Only
  12035. */
  12036. _markMeshesAsLightDirty(): void;
  12037. /**
  12038. * Recomputes the cached photometric scale if needed.
  12039. */
  12040. private _computePhotometricScale;
  12041. /**
  12042. * Returns the Photometric Scale according to the light type and intensity mode.
  12043. */
  12044. private _getPhotometricScale;
  12045. /**
  12046. * Reorder the light in the scene according to their defined priority.
  12047. * @hidden Internal Use Only
  12048. */
  12049. _reorderLightsInScene(): void;
  12050. /**
  12051. * Prepares the list of defines specific to the light type.
  12052. * @param defines the list of defines
  12053. * @param lightIndex defines the index of the light for the effect
  12054. */
  12055. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12056. }
  12057. }
  12058. declare module BABYLON {
  12059. /**
  12060. * Creates an instance based on a source mesh.
  12061. */
  12062. export class InstancedMesh extends AbstractMesh {
  12063. private _sourceMesh;
  12064. private _currentLOD;
  12065. /** @hidden */
  12066. _indexInSourceMeshInstanceArray: number;
  12067. constructor(name: string, source: Mesh);
  12068. /**
  12069. * Returns the string "InstancedMesh".
  12070. */
  12071. getClassName(): string;
  12072. /** Gets the list of lights affecting that mesh */
  12073. readonly lightSources: Light[];
  12074. _resyncLightSources(): void;
  12075. _resyncLighSource(light: Light): void;
  12076. _removeLightSource(light: Light): void;
  12077. /**
  12078. * If the source mesh receives shadows
  12079. */
  12080. readonly receiveShadows: boolean;
  12081. /**
  12082. * The material of the source mesh
  12083. */
  12084. readonly material: Nullable<Material>;
  12085. /**
  12086. * Visibility of the source mesh
  12087. */
  12088. readonly visibility: number;
  12089. /**
  12090. * Skeleton of the source mesh
  12091. */
  12092. readonly skeleton: Nullable<Skeleton>;
  12093. /**
  12094. * Rendering ground id of the source mesh
  12095. */
  12096. renderingGroupId: number;
  12097. /**
  12098. * Returns the total number of vertices (integer).
  12099. */
  12100. getTotalVertices(): number;
  12101. /**
  12102. * Returns a positive integer : the total number of indices in this mesh geometry.
  12103. * @returns the numner of indices or zero if the mesh has no geometry.
  12104. */
  12105. getTotalIndices(): number;
  12106. /**
  12107. * The source mesh of the instance
  12108. */
  12109. readonly sourceMesh: Mesh;
  12110. /**
  12111. * Is this node ready to be used/rendered
  12112. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12113. * @return {boolean} is it ready
  12114. */
  12115. isReady(completeCheck?: boolean): boolean;
  12116. /**
  12117. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12118. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12119. * @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.
  12120. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12121. */
  12122. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12123. /**
  12124. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12125. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12126. * The `data` are either a numeric array either a Float32Array.
  12127. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12128. * 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).
  12129. * Note that a new underlying VertexBuffer object is created each call.
  12130. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12131. *
  12132. * Possible `kind` values :
  12133. * - VertexBuffer.PositionKind
  12134. * - VertexBuffer.UVKind
  12135. * - VertexBuffer.UV2Kind
  12136. * - VertexBuffer.UV3Kind
  12137. * - VertexBuffer.UV4Kind
  12138. * - VertexBuffer.UV5Kind
  12139. * - VertexBuffer.UV6Kind
  12140. * - VertexBuffer.ColorKind
  12141. * - VertexBuffer.MatricesIndicesKind
  12142. * - VertexBuffer.MatricesIndicesExtraKind
  12143. * - VertexBuffer.MatricesWeightsKind
  12144. * - VertexBuffer.MatricesWeightsExtraKind
  12145. *
  12146. * Returns the Mesh.
  12147. */
  12148. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12149. /**
  12150. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12151. * If the mesh has no geometry, it is simply returned as it is.
  12152. * The `data` are either a numeric array either a Float32Array.
  12153. * No new underlying VertexBuffer object is created.
  12154. * 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.
  12155. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12156. *
  12157. * Possible `kind` values :
  12158. * - VertexBuffer.PositionKind
  12159. * - VertexBuffer.UVKind
  12160. * - VertexBuffer.UV2Kind
  12161. * - VertexBuffer.UV3Kind
  12162. * - VertexBuffer.UV4Kind
  12163. * - VertexBuffer.UV5Kind
  12164. * - VertexBuffer.UV6Kind
  12165. * - VertexBuffer.ColorKind
  12166. * - VertexBuffer.MatricesIndicesKind
  12167. * - VertexBuffer.MatricesIndicesExtraKind
  12168. * - VertexBuffer.MatricesWeightsKind
  12169. * - VertexBuffer.MatricesWeightsExtraKind
  12170. *
  12171. * Returns the Mesh.
  12172. */
  12173. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12174. /**
  12175. * Sets the mesh indices.
  12176. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12177. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12178. * This method creates a new index buffer each call.
  12179. * Returns the Mesh.
  12180. */
  12181. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12182. /**
  12183. * Boolean : True if the mesh owns the requested kind of data.
  12184. */
  12185. isVerticesDataPresent(kind: string): boolean;
  12186. /**
  12187. * Returns an array of indices (IndicesArray).
  12188. */
  12189. getIndices(): Nullable<IndicesArray>;
  12190. readonly _positions: Nullable<Vector3[]>;
  12191. /**
  12192. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12193. * This means the mesh underlying bounding box and sphere are recomputed.
  12194. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12195. * @returns the current mesh
  12196. */
  12197. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12198. /** @hidden */
  12199. _preActivate(): InstancedMesh;
  12200. /** @hidden */
  12201. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12202. /** @hidden */
  12203. _postActivate(): void;
  12204. getWorldMatrix(): Matrix;
  12205. readonly isAnInstance: boolean;
  12206. /**
  12207. * Returns the current associated LOD AbstractMesh.
  12208. */
  12209. getLOD(camera: Camera): AbstractMesh;
  12210. /** @hidden */
  12211. _syncSubMeshes(): InstancedMesh;
  12212. /** @hidden */
  12213. _generatePointsArray(): boolean;
  12214. /**
  12215. * Creates a new InstancedMesh from the current mesh.
  12216. * - name (string) : the cloned mesh name
  12217. * - newParent (optional Node) : the optional Node to parent the clone to.
  12218. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12219. *
  12220. * Returns the clone.
  12221. */
  12222. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12223. /**
  12224. * Disposes the InstancedMesh.
  12225. * Returns nothing.
  12226. */
  12227. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12228. }
  12229. }
  12230. declare module BABYLON {
  12231. /**
  12232. * Defines the options associated with the creation of a shader material.
  12233. */
  12234. export interface IShaderMaterialOptions {
  12235. /**
  12236. * Does the material work in alpha blend mode
  12237. */
  12238. needAlphaBlending: boolean;
  12239. /**
  12240. * Does the material work in alpha test mode
  12241. */
  12242. needAlphaTesting: boolean;
  12243. /**
  12244. * The list of attribute names used in the shader
  12245. */
  12246. attributes: string[];
  12247. /**
  12248. * The list of unifrom names used in the shader
  12249. */
  12250. uniforms: string[];
  12251. /**
  12252. * The list of UBO names used in the shader
  12253. */
  12254. uniformBuffers: string[];
  12255. /**
  12256. * The list of sampler names used in the shader
  12257. */
  12258. samplers: string[];
  12259. /**
  12260. * The list of defines used in the shader
  12261. */
  12262. defines: string[];
  12263. }
  12264. /**
  12265. * 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.
  12266. *
  12267. * This returned material effects how the mesh will look based on the code in the shaders.
  12268. *
  12269. * @see http://doc.babylonjs.com/how_to/shader_material
  12270. */
  12271. export class ShaderMaterial extends Material {
  12272. private _shaderPath;
  12273. private _options;
  12274. private _textures;
  12275. private _textureArrays;
  12276. private _floats;
  12277. private _ints;
  12278. private _floatsArrays;
  12279. private _colors3;
  12280. private _colors3Arrays;
  12281. private _colors4;
  12282. private _colors4Arrays;
  12283. private _vectors2;
  12284. private _vectors3;
  12285. private _vectors4;
  12286. private _matrices;
  12287. private _matrices3x3;
  12288. private _matrices2x2;
  12289. private _vectors2Arrays;
  12290. private _vectors3Arrays;
  12291. private _vectors4Arrays;
  12292. private _cachedWorldViewMatrix;
  12293. private _cachedWorldViewProjectionMatrix;
  12294. private _renderId;
  12295. /**
  12296. * Instantiate a new shader material.
  12297. * 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.
  12298. * This returned material effects how the mesh will look based on the code in the shaders.
  12299. * @see http://doc.babylonjs.com/how_to/shader_material
  12300. * @param name Define the name of the material in the scene
  12301. * @param scene Define the scene the material belongs to
  12302. * @param shaderPath Defines the route to the shader code in one of three ways:
  12303. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12304. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12305. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12306. * @param options Define the options used to create the shader
  12307. */
  12308. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12309. /**
  12310. * Gets the options used to compile the shader.
  12311. * They can be modified to trigger a new compilation
  12312. */
  12313. readonly options: IShaderMaterialOptions;
  12314. /**
  12315. * Gets the current class name of the material e.g. "ShaderMaterial"
  12316. * Mainly use in serialization.
  12317. * @returns the class name
  12318. */
  12319. getClassName(): string;
  12320. /**
  12321. * Specifies if the material will require alpha blending
  12322. * @returns a boolean specifying if alpha blending is needed
  12323. */
  12324. needAlphaBlending(): boolean;
  12325. /**
  12326. * Specifies if this material should be rendered in alpha test mode
  12327. * @returns a boolean specifying if an alpha test is needed.
  12328. */
  12329. needAlphaTesting(): boolean;
  12330. private _checkUniform;
  12331. /**
  12332. * Set a texture in the shader.
  12333. * @param name Define the name of the uniform samplers as defined in the shader
  12334. * @param texture Define the texture to bind to this sampler
  12335. * @return the material itself allowing "fluent" like uniform updates
  12336. */
  12337. setTexture(name: string, texture: Texture): ShaderMaterial;
  12338. /**
  12339. * Set a texture array in the shader.
  12340. * @param name Define the name of the uniform sampler array as defined in the shader
  12341. * @param textures Define the list of textures to bind to this sampler
  12342. * @return the material itself allowing "fluent" like uniform updates
  12343. */
  12344. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12345. /**
  12346. * Set a float in the shader.
  12347. * @param name Define the name of the uniform as defined in the shader
  12348. * @param value Define the value to give to the uniform
  12349. * @return the material itself allowing "fluent" like uniform updates
  12350. */
  12351. setFloat(name: string, value: number): ShaderMaterial;
  12352. /**
  12353. * Set a int in the shader.
  12354. * @param name Define the name of the uniform as defined in the shader
  12355. * @param value Define the value to give to the uniform
  12356. * @return the material itself allowing "fluent" like uniform updates
  12357. */
  12358. setInt(name: string, value: number): ShaderMaterial;
  12359. /**
  12360. * Set an array of floats in the shader.
  12361. * @param name Define the name of the uniform as defined in the shader
  12362. * @param value Define the value to give to the uniform
  12363. * @return the material itself allowing "fluent" like uniform updates
  12364. */
  12365. setFloats(name: string, value: number[]): ShaderMaterial;
  12366. /**
  12367. * Set a vec3 in the shader from a Color3.
  12368. * @param name Define the name of the uniform as defined in the shader
  12369. * @param value Define the value to give to the uniform
  12370. * @return the material itself allowing "fluent" like uniform updates
  12371. */
  12372. setColor3(name: string, value: Color3): ShaderMaterial;
  12373. /**
  12374. * Set a vec3 array in the shader from a Color3 array.
  12375. * @param name Define the name of the uniform as defined in the shader
  12376. * @param value Define the value to give to the uniform
  12377. * @return the material itself allowing "fluent" like uniform updates
  12378. */
  12379. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12380. /**
  12381. * Set a vec4 in the shader from a Color4.
  12382. * @param name Define the name of the uniform as defined in the shader
  12383. * @param value Define the value to give to the uniform
  12384. * @return the material itself allowing "fluent" like uniform updates
  12385. */
  12386. setColor4(name: string, value: Color4): ShaderMaterial;
  12387. /**
  12388. * Set a vec4 array in the shader from a Color4 array.
  12389. * @param name Define the name of the uniform as defined in the shader
  12390. * @param value Define the value to give to the uniform
  12391. * @return the material itself allowing "fluent" like uniform updates
  12392. */
  12393. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  12394. /**
  12395. * Set a vec2 in the shader from a Vector2.
  12396. * @param name Define the name of the uniform as defined in the shader
  12397. * @param value Define the value to give to the uniform
  12398. * @return the material itself allowing "fluent" like uniform updates
  12399. */
  12400. setVector2(name: string, value: Vector2): ShaderMaterial;
  12401. /**
  12402. * Set a vec3 in the shader from a Vector3.
  12403. * @param name Define the name of the uniform as defined in the shader
  12404. * @param value Define the value to give to the uniform
  12405. * @return the material itself allowing "fluent" like uniform updates
  12406. */
  12407. setVector3(name: string, value: Vector3): ShaderMaterial;
  12408. /**
  12409. * Set a vec4 in the shader from a Vector4.
  12410. * @param name Define the name of the uniform as defined in the shader
  12411. * @param value Define the value to give to the uniform
  12412. * @return the material itself allowing "fluent" like uniform updates
  12413. */
  12414. setVector4(name: string, value: Vector4): ShaderMaterial;
  12415. /**
  12416. * Set a mat4 in the shader from a Matrix.
  12417. * @param name Define the name of the uniform as defined in the shader
  12418. * @param value Define the value to give to the uniform
  12419. * @return the material itself allowing "fluent" like uniform updates
  12420. */
  12421. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12422. /**
  12423. * Set a mat3 in the shader from a Float32Array.
  12424. * @param name Define the name of the uniform as defined in the shader
  12425. * @param value Define the value to give to the uniform
  12426. * @return the material itself allowing "fluent" like uniform updates
  12427. */
  12428. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12429. /**
  12430. * Set a mat2 in the shader from a Float32Array.
  12431. * @param name Define the name of the uniform as defined in the shader
  12432. * @param value Define the value to give to the uniform
  12433. * @return the material itself allowing "fluent" like uniform updates
  12434. */
  12435. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12436. /**
  12437. * Set a vec2 array in the shader from a number array.
  12438. * @param name Define the name of the uniform as defined in the shader
  12439. * @param value Define the value to give to the uniform
  12440. * @return the material itself allowing "fluent" like uniform updates
  12441. */
  12442. setArray2(name: string, value: number[]): ShaderMaterial;
  12443. /**
  12444. * Set a vec3 array in the shader from a number array.
  12445. * @param name Define the name of the uniform as defined in the shader
  12446. * @param value Define the value to give to the uniform
  12447. * @return the material itself allowing "fluent" like uniform updates
  12448. */
  12449. setArray3(name: string, value: number[]): ShaderMaterial;
  12450. /**
  12451. * Set a vec4 array in the shader from a number array.
  12452. * @param name Define the name of the uniform as defined in the shader
  12453. * @param value Define the value to give to the uniform
  12454. * @return the material itself allowing "fluent" like uniform updates
  12455. */
  12456. setArray4(name: string, value: number[]): ShaderMaterial;
  12457. private _checkCache;
  12458. /**
  12459. * Specifies that the submesh is ready to be used
  12460. * @param mesh defines the mesh to check
  12461. * @param subMesh defines which submesh to check
  12462. * @param useInstances specifies that instances should be used
  12463. * @returns a boolean indicating that the submesh is ready or not
  12464. */
  12465. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12466. /**
  12467. * Checks if the material is ready to render the requested mesh
  12468. * @param mesh Define the mesh to render
  12469. * @param useInstances Define whether or not the material is used with instances
  12470. * @returns true if ready, otherwise false
  12471. */
  12472. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12473. /**
  12474. * Binds the world matrix to the material
  12475. * @param world defines the world transformation matrix
  12476. */
  12477. bindOnlyWorldMatrix(world: Matrix): void;
  12478. /**
  12479. * Binds the material to the mesh
  12480. * @param world defines the world transformation matrix
  12481. * @param mesh defines the mesh to bind the material to
  12482. */
  12483. bind(world: Matrix, mesh?: Mesh): void;
  12484. /**
  12485. * Gets the active textures from the material
  12486. * @returns an array of textures
  12487. */
  12488. getActiveTextures(): BaseTexture[];
  12489. /**
  12490. * Specifies if the material uses a texture
  12491. * @param texture defines the texture to check against the material
  12492. * @returns a boolean specifying if the material uses the texture
  12493. */
  12494. hasTexture(texture: BaseTexture): boolean;
  12495. /**
  12496. * Makes a duplicate of the material, and gives it a new name
  12497. * @param name defines the new name for the duplicated material
  12498. * @returns the cloned material
  12499. */
  12500. clone(name: string): ShaderMaterial;
  12501. /**
  12502. * Disposes the material
  12503. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12504. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12505. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12506. */
  12507. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12508. /**
  12509. * Serializes this material in a JSON representation
  12510. * @returns the serialized material object
  12511. */
  12512. serialize(): any;
  12513. /**
  12514. * Creates a shader material from parsed shader material data
  12515. * @param source defines the JSON represnetation of the material
  12516. * @param scene defines the hosting scene
  12517. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12518. * @returns a new material
  12519. */
  12520. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12521. }
  12522. }
  12523. declare module BABYLON {
  12524. /** @hidden */
  12525. export var clipPlaneFragmentDeclaration: {
  12526. name: string;
  12527. shader: string;
  12528. };
  12529. }
  12530. declare module BABYLON {
  12531. /** @hidden */
  12532. export var clipPlaneFragment: {
  12533. name: string;
  12534. shader: string;
  12535. };
  12536. }
  12537. declare module BABYLON {
  12538. /** @hidden */
  12539. export var colorPixelShader: {
  12540. name: string;
  12541. shader: string;
  12542. };
  12543. }
  12544. declare module BABYLON {
  12545. /** @hidden */
  12546. export var clipPlaneVertexDeclaration: {
  12547. name: string;
  12548. shader: string;
  12549. };
  12550. }
  12551. declare module BABYLON {
  12552. /** @hidden */
  12553. export var clipPlaneVertex: {
  12554. name: string;
  12555. shader: string;
  12556. };
  12557. }
  12558. declare module BABYLON {
  12559. /** @hidden */
  12560. export var colorVertexShader: {
  12561. name: string;
  12562. shader: string;
  12563. };
  12564. }
  12565. declare module BABYLON {
  12566. /**
  12567. * Line mesh
  12568. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12569. */
  12570. export class LinesMesh extends Mesh {
  12571. /**
  12572. * If vertex color should be applied to the mesh
  12573. */
  12574. readonly useVertexColor?: boolean | undefined;
  12575. /**
  12576. * If vertex alpha should be applied to the mesh
  12577. */
  12578. readonly useVertexAlpha?: boolean | undefined;
  12579. /**
  12580. * Color of the line (Default: White)
  12581. */
  12582. color: Color3;
  12583. /**
  12584. * Alpha of the line (Default: 1)
  12585. */
  12586. alpha: number;
  12587. /**
  12588. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12589. * This margin is expressed in world space coordinates, so its value may vary.
  12590. * Default value is 0.1
  12591. */
  12592. intersectionThreshold: number;
  12593. private _colorShader;
  12594. private color4;
  12595. /**
  12596. * Creates a new LinesMesh
  12597. * @param name defines the name
  12598. * @param scene defines the hosting scene
  12599. * @param parent defines the parent mesh if any
  12600. * @param source defines the optional source LinesMesh used to clone data from
  12601. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12602. * When false, achieved by calling a clone(), also passing False.
  12603. * This will make creation of children, recursive.
  12604. * @param useVertexColor defines if this LinesMesh supports vertex color
  12605. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12606. */
  12607. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12608. /**
  12609. * If vertex color should be applied to the mesh
  12610. */
  12611. useVertexColor?: boolean | undefined,
  12612. /**
  12613. * If vertex alpha should be applied to the mesh
  12614. */
  12615. useVertexAlpha?: boolean | undefined);
  12616. private _addClipPlaneDefine;
  12617. private _removeClipPlaneDefine;
  12618. isReady(): boolean;
  12619. /**
  12620. * Returns the string "LineMesh"
  12621. */
  12622. getClassName(): string;
  12623. /**
  12624. * @hidden
  12625. */
  12626. /**
  12627. * @hidden
  12628. */
  12629. material: Material;
  12630. /**
  12631. * @hidden
  12632. */
  12633. readonly checkCollisions: boolean;
  12634. /** @hidden */
  12635. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12636. /** @hidden */
  12637. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12638. /**
  12639. * Disposes of the line mesh
  12640. * @param doNotRecurse If children should be disposed
  12641. */
  12642. dispose(doNotRecurse?: boolean): void;
  12643. /**
  12644. * Returns a new LineMesh object cloned from the current one.
  12645. */
  12646. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12647. /**
  12648. * Creates a new InstancedLinesMesh object from the mesh model.
  12649. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12650. * @param name defines the name of the new instance
  12651. * @returns a new InstancedLinesMesh
  12652. */
  12653. createInstance(name: string): InstancedLinesMesh;
  12654. }
  12655. /**
  12656. * Creates an instance based on a source LinesMesh
  12657. */
  12658. export class InstancedLinesMesh extends InstancedMesh {
  12659. /**
  12660. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12661. * This margin is expressed in world space coordinates, so its value may vary.
  12662. * Initilized with the intersectionThreshold value of the source LinesMesh
  12663. */
  12664. intersectionThreshold: number;
  12665. constructor(name: string, source: LinesMesh);
  12666. /**
  12667. * Returns the string "InstancedLinesMesh".
  12668. */
  12669. getClassName(): string;
  12670. }
  12671. }
  12672. declare module BABYLON {
  12673. /**
  12674. * Mesh representing the gorund
  12675. */
  12676. export class GroundMesh extends Mesh {
  12677. /** If octree should be generated */
  12678. generateOctree: boolean;
  12679. private _heightQuads;
  12680. /** @hidden */
  12681. _subdivisionsX: number;
  12682. /** @hidden */
  12683. _subdivisionsY: number;
  12684. /** @hidden */
  12685. _width: number;
  12686. /** @hidden */
  12687. _height: number;
  12688. /** @hidden */
  12689. _minX: number;
  12690. /** @hidden */
  12691. _maxX: number;
  12692. /** @hidden */
  12693. _minZ: number;
  12694. /** @hidden */
  12695. _maxZ: number;
  12696. constructor(name: string, scene: Scene);
  12697. /**
  12698. * "GroundMesh"
  12699. * @returns "GroundMesh"
  12700. */
  12701. getClassName(): string;
  12702. /**
  12703. * The minimum of x and y subdivisions
  12704. */
  12705. readonly subdivisions: number;
  12706. /**
  12707. * X subdivisions
  12708. */
  12709. readonly subdivisionsX: number;
  12710. /**
  12711. * Y subdivisions
  12712. */
  12713. readonly subdivisionsY: number;
  12714. /**
  12715. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12716. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12717. * @param chunksCount the number of subdivisions for x and y
  12718. * @param octreeBlocksSize (Default: 32)
  12719. */
  12720. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12721. /**
  12722. * Returns a height (y) value in the Worl system :
  12723. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12724. * @param x x coordinate
  12725. * @param z z coordinate
  12726. * @returns the ground y position if (x, z) are outside the ground surface.
  12727. */
  12728. getHeightAtCoordinates(x: number, z: number): number;
  12729. /**
  12730. * Returns a normalized vector (Vector3) orthogonal to the ground
  12731. * at the ground coordinates (x, z) expressed in the World system.
  12732. * @param x x coordinate
  12733. * @param z z coordinate
  12734. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12735. */
  12736. getNormalAtCoordinates(x: number, z: number): Vector3;
  12737. /**
  12738. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12739. * at the ground coordinates (x, z) expressed in the World system.
  12740. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  12741. * @param x x coordinate
  12742. * @param z z coordinate
  12743. * @param ref vector to store the result
  12744. * @returns the GroundMesh.
  12745. */
  12746. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  12747. /**
  12748. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  12749. * if the ground has been updated.
  12750. * This can be used in the render loop.
  12751. * @returns the GroundMesh.
  12752. */
  12753. updateCoordinateHeights(): GroundMesh;
  12754. private _getFacetAt;
  12755. private _initHeightQuads;
  12756. private _computeHeightQuads;
  12757. /**
  12758. * Serializes this ground mesh
  12759. * @param serializationObject object to write serialization to
  12760. */
  12761. serialize(serializationObject: any): void;
  12762. /**
  12763. * Parses a serialized ground mesh
  12764. * @param parsedMesh the serialized mesh
  12765. * @param scene the scene to create the ground mesh in
  12766. * @returns the created ground mesh
  12767. */
  12768. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  12769. }
  12770. }
  12771. declare module BABYLON {
  12772. /**
  12773. * Interface for Physics-Joint data
  12774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12775. */
  12776. export interface PhysicsJointData {
  12777. /**
  12778. * The main pivot of the joint
  12779. */
  12780. mainPivot?: Vector3;
  12781. /**
  12782. * The connected pivot of the joint
  12783. */
  12784. connectedPivot?: Vector3;
  12785. /**
  12786. * The main axis of the joint
  12787. */
  12788. mainAxis?: Vector3;
  12789. /**
  12790. * The connected axis of the joint
  12791. */
  12792. connectedAxis?: Vector3;
  12793. /**
  12794. * The collision of the joint
  12795. */
  12796. collision?: boolean;
  12797. /**
  12798. * Native Oimo/Cannon/Energy data
  12799. */
  12800. nativeParams?: any;
  12801. }
  12802. /**
  12803. * This is a holder class for the physics joint created by the physics plugin
  12804. * It holds a set of functions to control the underlying joint
  12805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12806. */
  12807. export class PhysicsJoint {
  12808. /**
  12809. * The type of the physics joint
  12810. */
  12811. type: number;
  12812. /**
  12813. * The data for the physics joint
  12814. */
  12815. jointData: PhysicsJointData;
  12816. private _physicsJoint;
  12817. protected _physicsPlugin: IPhysicsEnginePlugin;
  12818. /**
  12819. * Initializes the physics joint
  12820. * @param type The type of the physics joint
  12821. * @param jointData The data for the physics joint
  12822. */
  12823. constructor(
  12824. /**
  12825. * The type of the physics joint
  12826. */
  12827. type: number,
  12828. /**
  12829. * The data for the physics joint
  12830. */
  12831. jointData: PhysicsJointData);
  12832. /**
  12833. * Gets the physics joint
  12834. */
  12835. /**
  12836. * Sets the physics joint
  12837. */
  12838. physicsJoint: any;
  12839. /**
  12840. * Sets the physics plugin
  12841. */
  12842. physicsPlugin: IPhysicsEnginePlugin;
  12843. /**
  12844. * Execute a function that is physics-plugin specific.
  12845. * @param {Function} func the function that will be executed.
  12846. * It accepts two parameters: the physics world and the physics joint
  12847. */
  12848. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  12849. /**
  12850. * Distance-Joint type
  12851. */
  12852. static DistanceJoint: number;
  12853. /**
  12854. * Hinge-Joint type
  12855. */
  12856. static HingeJoint: number;
  12857. /**
  12858. * Ball-and-Socket joint type
  12859. */
  12860. static BallAndSocketJoint: number;
  12861. /**
  12862. * Wheel-Joint type
  12863. */
  12864. static WheelJoint: number;
  12865. /**
  12866. * Slider-Joint type
  12867. */
  12868. static SliderJoint: number;
  12869. /**
  12870. * Prismatic-Joint type
  12871. */
  12872. static PrismaticJoint: number;
  12873. /**
  12874. * Universal-Joint type
  12875. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  12876. */
  12877. static UniversalJoint: number;
  12878. /**
  12879. * Hinge-Joint 2 type
  12880. */
  12881. static Hinge2Joint: number;
  12882. /**
  12883. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  12884. */
  12885. static PointToPointJoint: number;
  12886. /**
  12887. * Spring-Joint type
  12888. */
  12889. static SpringJoint: number;
  12890. /**
  12891. * Lock-Joint type
  12892. */
  12893. static LockJoint: number;
  12894. }
  12895. /**
  12896. * A class representing a physics distance joint
  12897. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12898. */
  12899. export class DistanceJoint extends PhysicsJoint {
  12900. /**
  12901. *
  12902. * @param jointData The data for the Distance-Joint
  12903. */
  12904. constructor(jointData: DistanceJointData);
  12905. /**
  12906. * Update the predefined distance.
  12907. * @param maxDistance The maximum preferred distance
  12908. * @param minDistance The minimum preferred distance
  12909. */
  12910. updateDistance(maxDistance: number, minDistance?: number): void;
  12911. }
  12912. /**
  12913. * Represents a Motor-Enabled Joint
  12914. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12915. */
  12916. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  12917. /**
  12918. * Initializes the Motor-Enabled Joint
  12919. * @param type The type of the joint
  12920. * @param jointData The physica joint data for the joint
  12921. */
  12922. constructor(type: number, jointData: PhysicsJointData);
  12923. /**
  12924. * Set the motor values.
  12925. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12926. * @param force the force to apply
  12927. * @param maxForce max force for this motor.
  12928. */
  12929. setMotor(force?: number, maxForce?: number): void;
  12930. /**
  12931. * Set the motor's limits.
  12932. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12933. * @param upperLimit The upper limit of the motor
  12934. * @param lowerLimit The lower limit of the motor
  12935. */
  12936. setLimit(upperLimit: number, lowerLimit?: number): void;
  12937. }
  12938. /**
  12939. * This class represents a single physics Hinge-Joint
  12940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12941. */
  12942. export class HingeJoint extends MotorEnabledJoint {
  12943. /**
  12944. * Initializes the Hinge-Joint
  12945. * @param jointData The joint data for the Hinge-Joint
  12946. */
  12947. constructor(jointData: PhysicsJointData);
  12948. /**
  12949. * Set the motor values.
  12950. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12951. * @param {number} force the force to apply
  12952. * @param {number} maxForce max force for this motor.
  12953. */
  12954. setMotor(force?: number, maxForce?: number): void;
  12955. /**
  12956. * Set the motor's limits.
  12957. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12958. * @param upperLimit The upper limit of the motor
  12959. * @param lowerLimit The lower limit of the motor
  12960. */
  12961. setLimit(upperLimit: number, lowerLimit?: number): void;
  12962. }
  12963. /**
  12964. * This class represents a dual hinge physics joint (same as wheel joint)
  12965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12966. */
  12967. export class Hinge2Joint extends MotorEnabledJoint {
  12968. /**
  12969. * Initializes the Hinge2-Joint
  12970. * @param jointData The joint data for the Hinge2-Joint
  12971. */
  12972. constructor(jointData: PhysicsJointData);
  12973. /**
  12974. * Set the motor values.
  12975. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12976. * @param {number} targetSpeed the speed the motor is to reach
  12977. * @param {number} maxForce max force for this motor.
  12978. * @param {motorIndex} the motor's index, 0 or 1.
  12979. */
  12980. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  12981. /**
  12982. * Set the motor limits.
  12983. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12984. * @param {number} upperLimit the upper limit
  12985. * @param {number} lowerLimit lower limit
  12986. * @param {motorIndex} the motor's index, 0 or 1.
  12987. */
  12988. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  12989. }
  12990. /**
  12991. * Interface for a motor enabled joint
  12992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12993. */
  12994. export interface IMotorEnabledJoint {
  12995. /**
  12996. * Physics joint
  12997. */
  12998. physicsJoint: any;
  12999. /**
  13000. * Sets the motor of the motor-enabled joint
  13001. * @param force The force of the motor
  13002. * @param maxForce The maximum force of the motor
  13003. * @param motorIndex The index of the motor
  13004. */
  13005. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  13006. /**
  13007. * Sets the limit of the motor
  13008. * @param upperLimit The upper limit of the motor
  13009. * @param lowerLimit The lower limit of the motor
  13010. * @param motorIndex The index of the motor
  13011. */
  13012. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13013. }
  13014. /**
  13015. * Joint data for a Distance-Joint
  13016. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13017. */
  13018. export interface DistanceJointData extends PhysicsJointData {
  13019. /**
  13020. * Max distance the 2 joint objects can be apart
  13021. */
  13022. maxDistance: number;
  13023. }
  13024. /**
  13025. * Joint data from a spring joint
  13026. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13027. */
  13028. export interface SpringJointData extends PhysicsJointData {
  13029. /**
  13030. * Length of the spring
  13031. */
  13032. length: number;
  13033. /**
  13034. * Stiffness of the spring
  13035. */
  13036. stiffness: number;
  13037. /**
  13038. * Damping of the spring
  13039. */
  13040. damping: number;
  13041. /** this callback will be called when applying the force to the impostors. */
  13042. forceApplicationCallback: () => void;
  13043. }
  13044. }
  13045. declare module BABYLON {
  13046. /**
  13047. * Holds the data for the raycast result
  13048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13049. */
  13050. export class PhysicsRaycastResult {
  13051. private _hasHit;
  13052. private _hitDistance;
  13053. private _hitNormalWorld;
  13054. private _hitPointWorld;
  13055. private _rayFromWorld;
  13056. private _rayToWorld;
  13057. /**
  13058. * Gets if there was a hit
  13059. */
  13060. readonly hasHit: boolean;
  13061. /**
  13062. * Gets the distance from the hit
  13063. */
  13064. readonly hitDistance: number;
  13065. /**
  13066. * Gets the hit normal/direction in the world
  13067. */
  13068. readonly hitNormalWorld: Vector3;
  13069. /**
  13070. * Gets the hit point in the world
  13071. */
  13072. readonly hitPointWorld: Vector3;
  13073. /**
  13074. * Gets the ray "start point" of the ray in the world
  13075. */
  13076. readonly rayFromWorld: Vector3;
  13077. /**
  13078. * Gets the ray "end point" of the ray in the world
  13079. */
  13080. readonly rayToWorld: Vector3;
  13081. /**
  13082. * Sets the hit data (normal & point in world space)
  13083. * @param hitNormalWorld defines the normal in world space
  13084. * @param hitPointWorld defines the point in world space
  13085. */
  13086. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13087. /**
  13088. * Sets the distance from the start point to the hit point
  13089. * @param distance
  13090. */
  13091. setHitDistance(distance: number): void;
  13092. /**
  13093. * Calculates the distance manually
  13094. */
  13095. calculateHitDistance(): void;
  13096. /**
  13097. * Resets all the values to default
  13098. * @param from The from point on world space
  13099. * @param to The to point on world space
  13100. */
  13101. reset(from?: Vector3, to?: Vector3): void;
  13102. }
  13103. /**
  13104. * Interface for the size containing width and height
  13105. */
  13106. interface IXYZ {
  13107. /**
  13108. * X
  13109. */
  13110. x: number;
  13111. /**
  13112. * Y
  13113. */
  13114. y: number;
  13115. /**
  13116. * Z
  13117. */
  13118. z: number;
  13119. }
  13120. }
  13121. declare module BABYLON {
  13122. /**
  13123. * Interface used to describe a physics joint
  13124. */
  13125. export interface PhysicsImpostorJoint {
  13126. /** Defines the main impostor to which the joint is linked */
  13127. mainImpostor: PhysicsImpostor;
  13128. /** Defines the impostor that is connected to the main impostor using this joint */
  13129. connectedImpostor: PhysicsImpostor;
  13130. /** Defines the joint itself */
  13131. joint: PhysicsJoint;
  13132. }
  13133. /** @hidden */
  13134. export interface IPhysicsEnginePlugin {
  13135. world: any;
  13136. name: string;
  13137. setGravity(gravity: Vector3): void;
  13138. setTimeStep(timeStep: number): void;
  13139. getTimeStep(): number;
  13140. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13141. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13142. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13143. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13144. removePhysicsBody(impostor: PhysicsImpostor): void;
  13145. generateJoint(joint: PhysicsImpostorJoint): void;
  13146. removeJoint(joint: PhysicsImpostorJoint): void;
  13147. isSupported(): boolean;
  13148. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13149. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13150. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13151. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13152. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13153. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13154. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13155. getBodyMass(impostor: PhysicsImpostor): number;
  13156. getBodyFriction(impostor: PhysicsImpostor): number;
  13157. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13158. getBodyRestitution(impostor: PhysicsImpostor): number;
  13159. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13160. getBodyPressure?(impostor: PhysicsImpostor): number;
  13161. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13162. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13163. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13164. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13165. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13166. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13167. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13168. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13169. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13170. sleepBody(impostor: PhysicsImpostor): void;
  13171. wakeUpBody(impostor: PhysicsImpostor): void;
  13172. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13173. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13174. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13175. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13176. getRadius(impostor: PhysicsImpostor): number;
  13177. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13178. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13179. dispose(): void;
  13180. }
  13181. /**
  13182. * Interface used to define a physics engine
  13183. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13184. */
  13185. export interface IPhysicsEngine {
  13186. /**
  13187. * Gets the gravity vector used by the simulation
  13188. */
  13189. gravity: Vector3;
  13190. /**
  13191. * Sets the gravity vector used by the simulation
  13192. * @param gravity defines the gravity vector to use
  13193. */
  13194. setGravity(gravity: Vector3): void;
  13195. /**
  13196. * Set the time step of the physics engine.
  13197. * Default is 1/60.
  13198. * To slow it down, enter 1/600 for example.
  13199. * To speed it up, 1/30
  13200. * @param newTimeStep the new timestep to apply to this world.
  13201. */
  13202. setTimeStep(newTimeStep: number): void;
  13203. /**
  13204. * Get the time step of the physics engine.
  13205. * @returns the current time step
  13206. */
  13207. getTimeStep(): number;
  13208. /**
  13209. * Release all resources
  13210. */
  13211. dispose(): void;
  13212. /**
  13213. * Gets the name of the current physics plugin
  13214. * @returns the name of the plugin
  13215. */
  13216. getPhysicsPluginName(): string;
  13217. /**
  13218. * Adding a new impostor for the impostor tracking.
  13219. * This will be done by the impostor itself.
  13220. * @param impostor the impostor to add
  13221. */
  13222. addImpostor(impostor: PhysicsImpostor): void;
  13223. /**
  13224. * Remove an impostor from the engine.
  13225. * This impostor and its mesh will not longer be updated by the physics engine.
  13226. * @param impostor the impostor to remove
  13227. */
  13228. removeImpostor(impostor: PhysicsImpostor): void;
  13229. /**
  13230. * Add a joint to the physics engine
  13231. * @param mainImpostor defines the main impostor to which the joint is added.
  13232. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13233. * @param joint defines the joint that will connect both impostors.
  13234. */
  13235. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13236. /**
  13237. * Removes a joint from the simulation
  13238. * @param mainImpostor defines the impostor used with the joint
  13239. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13240. * @param joint defines the joint to remove
  13241. */
  13242. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13243. /**
  13244. * Gets the current plugin used to run the simulation
  13245. * @returns current plugin
  13246. */
  13247. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13248. /**
  13249. * Gets the list of physic impostors
  13250. * @returns an array of PhysicsImpostor
  13251. */
  13252. getImpostors(): Array<PhysicsImpostor>;
  13253. /**
  13254. * Gets the impostor for a physics enabled object
  13255. * @param object defines the object impersonated by the impostor
  13256. * @returns the PhysicsImpostor or null if not found
  13257. */
  13258. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13259. /**
  13260. * Gets the impostor for a physics body object
  13261. * @param body defines physics body used by the impostor
  13262. * @returns the PhysicsImpostor or null if not found
  13263. */
  13264. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13265. /**
  13266. * Does a raycast in the physics world
  13267. * @param from when should the ray start?
  13268. * @param to when should the ray end?
  13269. * @returns PhysicsRaycastResult
  13270. */
  13271. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13272. /**
  13273. * Called by the scene. No need to call it.
  13274. * @param delta defines the timespam between frames
  13275. */
  13276. _step(delta: number): void;
  13277. }
  13278. }
  13279. declare module BABYLON {
  13280. /**
  13281. * The interface for the physics imposter parameters
  13282. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13283. */
  13284. export interface PhysicsImpostorParameters {
  13285. /**
  13286. * The mass of the physics imposter
  13287. */
  13288. mass: number;
  13289. /**
  13290. * The friction of the physics imposter
  13291. */
  13292. friction?: number;
  13293. /**
  13294. * The coefficient of restitution of the physics imposter
  13295. */
  13296. restitution?: number;
  13297. /**
  13298. * The native options of the physics imposter
  13299. */
  13300. nativeOptions?: any;
  13301. /**
  13302. * Specifies if the parent should be ignored
  13303. */
  13304. ignoreParent?: boolean;
  13305. /**
  13306. * Specifies if bi-directional transformations should be disabled
  13307. */
  13308. disableBidirectionalTransformation?: boolean;
  13309. /**
  13310. * The pressure inside the physics imposter, soft object only
  13311. */
  13312. pressure?: number;
  13313. /**
  13314. * The stiffness the physics imposter, soft object only
  13315. */
  13316. stiffness?: number;
  13317. /**
  13318. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13319. */
  13320. velocityIterations?: number;
  13321. /**
  13322. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13323. */
  13324. positionIterations?: number;
  13325. /**
  13326. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13327. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13328. * Add to fix multiple points
  13329. */
  13330. fixedPoints?: number;
  13331. /**
  13332. * The collision margin around a soft object
  13333. */
  13334. margin?: number;
  13335. /**
  13336. * The collision margin around a soft object
  13337. */
  13338. damping?: number;
  13339. /**
  13340. * The path for a rope based on an extrusion
  13341. */
  13342. path?: any;
  13343. /**
  13344. * The shape of an extrusion used for a rope based on an extrusion
  13345. */
  13346. shape?: any;
  13347. }
  13348. /**
  13349. * Interface for a physics-enabled object
  13350. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13351. */
  13352. export interface IPhysicsEnabledObject {
  13353. /**
  13354. * The position of the physics-enabled object
  13355. */
  13356. position: Vector3;
  13357. /**
  13358. * The rotation of the physics-enabled object
  13359. */
  13360. rotationQuaternion: Nullable<Quaternion>;
  13361. /**
  13362. * The scale of the physics-enabled object
  13363. */
  13364. scaling: Vector3;
  13365. /**
  13366. * The rotation of the physics-enabled object
  13367. */
  13368. rotation?: Vector3;
  13369. /**
  13370. * The parent of the physics-enabled object
  13371. */
  13372. parent?: any;
  13373. /**
  13374. * The bounding info of the physics-enabled object
  13375. * @returns The bounding info of the physics-enabled object
  13376. */
  13377. getBoundingInfo(): BoundingInfo;
  13378. /**
  13379. * Computes the world matrix
  13380. * @param force Specifies if the world matrix should be computed by force
  13381. * @returns A world matrix
  13382. */
  13383. computeWorldMatrix(force: boolean): Matrix;
  13384. /**
  13385. * Gets the world matrix
  13386. * @returns A world matrix
  13387. */
  13388. getWorldMatrix?(): Matrix;
  13389. /**
  13390. * Gets the child meshes
  13391. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13392. * @returns An array of abstract meshes
  13393. */
  13394. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13395. /**
  13396. * Gets the vertex data
  13397. * @param kind The type of vertex data
  13398. * @returns A nullable array of numbers, or a float32 array
  13399. */
  13400. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13401. /**
  13402. * Gets the indices from the mesh
  13403. * @returns A nullable array of index arrays
  13404. */
  13405. getIndices?(): Nullable<IndicesArray>;
  13406. /**
  13407. * Gets the scene from the mesh
  13408. * @returns the indices array or null
  13409. */
  13410. getScene?(): Scene;
  13411. /**
  13412. * Gets the absolute position from the mesh
  13413. * @returns the absolute position
  13414. */
  13415. getAbsolutePosition(): Vector3;
  13416. /**
  13417. * Gets the absolute pivot point from the mesh
  13418. * @returns the absolute pivot point
  13419. */
  13420. getAbsolutePivotPoint(): Vector3;
  13421. /**
  13422. * Rotates the mesh
  13423. * @param axis The axis of rotation
  13424. * @param amount The amount of rotation
  13425. * @param space The space of the rotation
  13426. * @returns The rotation transform node
  13427. */
  13428. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13429. /**
  13430. * Translates the mesh
  13431. * @param axis The axis of translation
  13432. * @param distance The distance of translation
  13433. * @param space The space of the translation
  13434. * @returns The transform node
  13435. */
  13436. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13437. /**
  13438. * Sets the absolute position of the mesh
  13439. * @param absolutePosition The absolute position of the mesh
  13440. * @returns The transform node
  13441. */
  13442. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13443. /**
  13444. * Gets the class name of the mesh
  13445. * @returns The class name
  13446. */
  13447. getClassName(): string;
  13448. }
  13449. /**
  13450. * Represents a physics imposter
  13451. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13452. */
  13453. export class PhysicsImpostor {
  13454. /**
  13455. * The physics-enabled object used as the physics imposter
  13456. */
  13457. object: IPhysicsEnabledObject;
  13458. /**
  13459. * The type of the physics imposter
  13460. */
  13461. type: number;
  13462. private _options;
  13463. private _scene?;
  13464. /**
  13465. * The default object size of the imposter
  13466. */
  13467. static DEFAULT_OBJECT_SIZE: Vector3;
  13468. /**
  13469. * The identity quaternion of the imposter
  13470. */
  13471. static IDENTITY_QUATERNION: Quaternion;
  13472. /** @hidden */
  13473. _pluginData: any;
  13474. private _physicsEngine;
  13475. private _physicsBody;
  13476. private _bodyUpdateRequired;
  13477. private _onBeforePhysicsStepCallbacks;
  13478. private _onAfterPhysicsStepCallbacks;
  13479. /** @hidden */
  13480. _onPhysicsCollideCallbacks: Array<{
  13481. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13482. otherImpostors: Array<PhysicsImpostor>;
  13483. }>;
  13484. private _deltaPosition;
  13485. private _deltaRotation;
  13486. private _deltaRotationConjugated;
  13487. /** @hidden */
  13488. _isFromLine: boolean;
  13489. private _parent;
  13490. private _isDisposed;
  13491. private static _tmpVecs;
  13492. private static _tmpQuat;
  13493. /**
  13494. * Specifies if the physics imposter is disposed
  13495. */
  13496. readonly isDisposed: boolean;
  13497. /**
  13498. * Gets the mass of the physics imposter
  13499. */
  13500. mass: number;
  13501. /**
  13502. * Gets the coefficient of friction
  13503. */
  13504. /**
  13505. * Sets the coefficient of friction
  13506. */
  13507. friction: number;
  13508. /**
  13509. * Gets the coefficient of restitution
  13510. */
  13511. /**
  13512. * Sets the coefficient of restitution
  13513. */
  13514. restitution: number;
  13515. /**
  13516. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13517. */
  13518. /**
  13519. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13520. */
  13521. pressure: number;
  13522. /**
  13523. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13524. */
  13525. /**
  13526. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13527. */
  13528. stiffness: number;
  13529. /**
  13530. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13531. */
  13532. /**
  13533. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13534. */
  13535. velocityIterations: number;
  13536. /**
  13537. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13538. */
  13539. /**
  13540. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13541. */
  13542. positionIterations: number;
  13543. /**
  13544. * The unique id of the physics imposter
  13545. * set by the physics engine when adding this impostor to the array
  13546. */
  13547. uniqueId: number;
  13548. /**
  13549. * @hidden
  13550. */
  13551. soft: boolean;
  13552. /**
  13553. * @hidden
  13554. */
  13555. segments: number;
  13556. private _joints;
  13557. /**
  13558. * Initializes the physics imposter
  13559. * @param object The physics-enabled object used as the physics imposter
  13560. * @param type The type of the physics imposter
  13561. * @param _options The options for the physics imposter
  13562. * @param _scene The Babylon scene
  13563. */
  13564. constructor(
  13565. /**
  13566. * The physics-enabled object used as the physics imposter
  13567. */
  13568. object: IPhysicsEnabledObject,
  13569. /**
  13570. * The type of the physics imposter
  13571. */
  13572. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13573. /**
  13574. * This function will completly initialize this impostor.
  13575. * It will create a new body - but only if this mesh has no parent.
  13576. * If it has, this impostor will not be used other than to define the impostor
  13577. * of the child mesh.
  13578. * @hidden
  13579. */
  13580. _init(): void;
  13581. private _getPhysicsParent;
  13582. /**
  13583. * Should a new body be generated.
  13584. * @returns boolean specifying if body initialization is required
  13585. */
  13586. isBodyInitRequired(): boolean;
  13587. /**
  13588. * Sets the updated scaling
  13589. * @param updated Specifies if the scaling is updated
  13590. */
  13591. setScalingUpdated(): void;
  13592. /**
  13593. * Force a regeneration of this or the parent's impostor's body.
  13594. * Use under cautious - This will remove all joints already implemented.
  13595. */
  13596. forceUpdate(): void;
  13597. /**
  13598. * Gets the body that holds this impostor. Either its own, or its parent.
  13599. */
  13600. /**
  13601. * Set the physics body. Used mainly by the physics engine/plugin
  13602. */
  13603. physicsBody: any;
  13604. /**
  13605. * Get the parent of the physics imposter
  13606. * @returns Physics imposter or null
  13607. */
  13608. /**
  13609. * Sets the parent of the physics imposter
  13610. */
  13611. parent: Nullable<PhysicsImpostor>;
  13612. /**
  13613. * Resets the update flags
  13614. */
  13615. resetUpdateFlags(): void;
  13616. /**
  13617. * Gets the object extend size
  13618. * @returns the object extend size
  13619. */
  13620. getObjectExtendSize(): Vector3;
  13621. /**
  13622. * Gets the object center
  13623. * @returns The object center
  13624. */
  13625. getObjectCenter(): Vector3;
  13626. /**
  13627. * Get a specific parametes from the options parameter
  13628. * @param paramName The object parameter name
  13629. * @returns The object parameter
  13630. */
  13631. getParam(paramName: string): any;
  13632. /**
  13633. * Sets a specific parameter in the options given to the physics plugin
  13634. * @param paramName The parameter name
  13635. * @param value The value of the parameter
  13636. */
  13637. setParam(paramName: string, value: number): void;
  13638. /**
  13639. * Specifically change the body's mass option. Won't recreate the physics body object
  13640. * @param mass The mass of the physics imposter
  13641. */
  13642. setMass(mass: number): void;
  13643. /**
  13644. * Gets the linear velocity
  13645. * @returns linear velocity or null
  13646. */
  13647. getLinearVelocity(): Nullable<Vector3>;
  13648. /**
  13649. * Sets the linear velocity
  13650. * @param velocity linear velocity or null
  13651. */
  13652. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13653. /**
  13654. * Gets the angular velocity
  13655. * @returns angular velocity or null
  13656. */
  13657. getAngularVelocity(): Nullable<Vector3>;
  13658. /**
  13659. * Sets the angular velocity
  13660. * @param velocity The velocity or null
  13661. */
  13662. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13663. /**
  13664. * Execute a function with the physics plugin native code
  13665. * Provide a function the will have two variables - the world object and the physics body object
  13666. * @param func The function to execute with the physics plugin native code
  13667. */
  13668. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13669. /**
  13670. * Register a function that will be executed before the physics world is stepping forward
  13671. * @param func The function to execute before the physics world is stepped forward
  13672. */
  13673. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13674. /**
  13675. * Unregister a function that will be executed before the physics world is stepping forward
  13676. * @param func The function to execute before the physics world is stepped forward
  13677. */
  13678. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13679. /**
  13680. * Register a function that will be executed after the physics step
  13681. * @param func The function to execute after physics step
  13682. */
  13683. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13684. /**
  13685. * Unregisters a function that will be executed after the physics step
  13686. * @param func The function to execute after physics step
  13687. */
  13688. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13689. /**
  13690. * register a function that will be executed when this impostor collides against a different body
  13691. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13692. * @param func Callback that is executed on collision
  13693. */
  13694. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13695. /**
  13696. * Unregisters the physics imposter on contact
  13697. * @param collideAgainst The physics object to collide against
  13698. * @param func Callback to execute on collision
  13699. */
  13700. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13701. private _tmpQuat;
  13702. private _tmpQuat2;
  13703. /**
  13704. * Get the parent rotation
  13705. * @returns The parent rotation
  13706. */
  13707. getParentsRotation(): Quaternion;
  13708. /**
  13709. * this function is executed by the physics engine.
  13710. */
  13711. beforeStep: () => void;
  13712. /**
  13713. * this function is executed by the physics engine
  13714. */
  13715. afterStep: () => void;
  13716. /**
  13717. * Legacy collision detection event support
  13718. */
  13719. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13720. /**
  13721. * event and body object due to cannon's event-based architecture.
  13722. */
  13723. onCollide: (e: {
  13724. body: any;
  13725. }) => void;
  13726. /**
  13727. * Apply a force
  13728. * @param force The force to apply
  13729. * @param contactPoint The contact point for the force
  13730. * @returns The physics imposter
  13731. */
  13732. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13733. /**
  13734. * Apply an impulse
  13735. * @param force The impulse force
  13736. * @param contactPoint The contact point for the impulse force
  13737. * @returns The physics imposter
  13738. */
  13739. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13740. /**
  13741. * A help function to create a joint
  13742. * @param otherImpostor A physics imposter used to create a joint
  13743. * @param jointType The type of joint
  13744. * @param jointData The data for the joint
  13745. * @returns The physics imposter
  13746. */
  13747. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  13748. /**
  13749. * Add a joint to this impostor with a different impostor
  13750. * @param otherImpostor A physics imposter used to add a joint
  13751. * @param joint The joint to add
  13752. * @returns The physics imposter
  13753. */
  13754. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  13755. /**
  13756. * Add an anchor to a cloth impostor
  13757. * @param otherImpostor rigid impostor to anchor to
  13758. * @param width ratio across width from 0 to 1
  13759. * @param height ratio up height from 0 to 1
  13760. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  13761. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  13762. * @returns impostor the soft imposter
  13763. */
  13764. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13765. /**
  13766. * Add a hook to a rope impostor
  13767. * @param otherImpostor rigid impostor to anchor to
  13768. * @param length ratio across rope from 0 to 1
  13769. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  13770. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  13771. * @returns impostor the rope imposter
  13772. */
  13773. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13774. /**
  13775. * Will keep this body still, in a sleep mode.
  13776. * @returns the physics imposter
  13777. */
  13778. sleep(): PhysicsImpostor;
  13779. /**
  13780. * Wake the body up.
  13781. * @returns The physics imposter
  13782. */
  13783. wakeUp(): PhysicsImpostor;
  13784. /**
  13785. * Clones the physics imposter
  13786. * @param newObject The physics imposter clones to this physics-enabled object
  13787. * @returns A nullable physics imposter
  13788. */
  13789. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13790. /**
  13791. * Disposes the physics imposter
  13792. */
  13793. dispose(): void;
  13794. /**
  13795. * Sets the delta position
  13796. * @param position The delta position amount
  13797. */
  13798. setDeltaPosition(position: Vector3): void;
  13799. /**
  13800. * Sets the delta rotation
  13801. * @param rotation The delta rotation amount
  13802. */
  13803. setDeltaRotation(rotation: Quaternion): void;
  13804. /**
  13805. * Gets the box size of the physics imposter and stores the result in the input parameter
  13806. * @param result Stores the box size
  13807. * @returns The physics imposter
  13808. */
  13809. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  13810. /**
  13811. * Gets the radius of the physics imposter
  13812. * @returns Radius of the physics imposter
  13813. */
  13814. getRadius(): number;
  13815. /**
  13816. * Sync a bone with this impostor
  13817. * @param bone The bone to sync to the impostor.
  13818. * @param boneMesh The mesh that the bone is influencing.
  13819. * @param jointPivot The pivot of the joint / bone in local space.
  13820. * @param distToJoint Optional distance from the impostor to the joint.
  13821. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13822. */
  13823. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  13824. /**
  13825. * Sync impostor to a bone
  13826. * @param bone The bone that the impostor will be synced to.
  13827. * @param boneMesh The mesh that the bone is influencing.
  13828. * @param jointPivot The pivot of the joint / bone in local space.
  13829. * @param distToJoint Optional distance from the impostor to the joint.
  13830. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13831. * @param boneAxis Optional vector3 axis the bone is aligned with
  13832. */
  13833. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  13834. /**
  13835. * No-Imposter type
  13836. */
  13837. static NoImpostor: number;
  13838. /**
  13839. * Sphere-Imposter type
  13840. */
  13841. static SphereImpostor: number;
  13842. /**
  13843. * Box-Imposter type
  13844. */
  13845. static BoxImpostor: number;
  13846. /**
  13847. * Plane-Imposter type
  13848. */
  13849. static PlaneImpostor: number;
  13850. /**
  13851. * Mesh-imposter type
  13852. */
  13853. static MeshImpostor: number;
  13854. /**
  13855. * Capsule-Impostor type (Ammo.js plugin only)
  13856. */
  13857. static CapsuleImpostor: number;
  13858. /**
  13859. * Cylinder-Imposter type
  13860. */
  13861. static CylinderImpostor: number;
  13862. /**
  13863. * Particle-Imposter type
  13864. */
  13865. static ParticleImpostor: number;
  13866. /**
  13867. * Heightmap-Imposter type
  13868. */
  13869. static HeightmapImpostor: number;
  13870. /**
  13871. * ConvexHull-Impostor type (Ammo.js plugin only)
  13872. */
  13873. static ConvexHullImpostor: number;
  13874. /**
  13875. * Rope-Imposter type
  13876. */
  13877. static RopeImpostor: number;
  13878. /**
  13879. * Cloth-Imposter type
  13880. */
  13881. static ClothImpostor: number;
  13882. /**
  13883. * Softbody-Imposter type
  13884. */
  13885. static SoftbodyImpostor: number;
  13886. }
  13887. }
  13888. declare module BABYLON {
  13889. /**
  13890. * @hidden
  13891. **/
  13892. export class _CreationDataStorage {
  13893. closePath?: boolean;
  13894. closeArray?: boolean;
  13895. idx: number[];
  13896. dashSize: number;
  13897. gapSize: number;
  13898. path3D: Path3D;
  13899. pathArray: Vector3[][];
  13900. arc: number;
  13901. radius: number;
  13902. cap: number;
  13903. tessellation: number;
  13904. }
  13905. /**
  13906. * @hidden
  13907. **/
  13908. class _InstanceDataStorage {
  13909. visibleInstances: any;
  13910. batchCache: _InstancesBatch;
  13911. instancesBufferSize: number;
  13912. instancesBuffer: Nullable<Buffer>;
  13913. instancesData: Float32Array;
  13914. overridenInstanceCount: number;
  13915. isFrozen: boolean;
  13916. previousBatch: Nullable<_InstancesBatch>;
  13917. hardwareInstancedRendering: boolean;
  13918. sideOrientation: number;
  13919. }
  13920. /**
  13921. * @hidden
  13922. **/
  13923. export class _InstancesBatch {
  13924. mustReturn: boolean;
  13925. visibleInstances: Nullable<InstancedMesh[]>[];
  13926. renderSelf: boolean[];
  13927. hardwareInstancedRendering: boolean[];
  13928. }
  13929. /**
  13930. * Class used to represent renderable models
  13931. */
  13932. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  13933. /**
  13934. * Mesh side orientation : usually the external or front surface
  13935. */
  13936. static readonly FRONTSIDE: number;
  13937. /**
  13938. * Mesh side orientation : usually the internal or back surface
  13939. */
  13940. static readonly BACKSIDE: number;
  13941. /**
  13942. * Mesh side orientation : both internal and external or front and back surfaces
  13943. */
  13944. static readonly DOUBLESIDE: number;
  13945. /**
  13946. * Mesh side orientation : by default, `FRONTSIDE`
  13947. */
  13948. static readonly DEFAULTSIDE: number;
  13949. /**
  13950. * Mesh cap setting : no cap
  13951. */
  13952. static readonly NO_CAP: number;
  13953. /**
  13954. * Mesh cap setting : one cap at the beginning of the mesh
  13955. */
  13956. static readonly CAP_START: number;
  13957. /**
  13958. * Mesh cap setting : one cap at the end of the mesh
  13959. */
  13960. static readonly CAP_END: number;
  13961. /**
  13962. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  13963. */
  13964. static readonly CAP_ALL: number;
  13965. /**
  13966. * Mesh pattern setting : no flip or rotate
  13967. */
  13968. static readonly NO_FLIP: number;
  13969. /**
  13970. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  13971. */
  13972. static readonly FLIP_TILE: number;
  13973. /**
  13974. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  13975. */
  13976. static readonly ROTATE_TILE: number;
  13977. /**
  13978. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  13979. */
  13980. static readonly FLIP_ROW: number;
  13981. /**
  13982. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  13983. */
  13984. static readonly ROTATE_ROW: number;
  13985. /**
  13986. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  13987. */
  13988. static readonly FLIP_N_ROTATE_TILE: number;
  13989. /**
  13990. * Mesh pattern setting : rotate pattern and rotate
  13991. */
  13992. static readonly FLIP_N_ROTATE_ROW: number;
  13993. /**
  13994. * Mesh tile positioning : part tiles same on left/right or top/bottom
  13995. */
  13996. static readonly CENTER: number;
  13997. /**
  13998. * Mesh tile positioning : part tiles on left
  13999. */
  14000. static readonly LEFT: number;
  14001. /**
  14002. * Mesh tile positioning : part tiles on right
  14003. */
  14004. static readonly RIGHT: number;
  14005. /**
  14006. * Mesh tile positioning : part tiles on top
  14007. */
  14008. static readonly TOP: number;
  14009. /**
  14010. * Mesh tile positioning : part tiles on bottom
  14011. */
  14012. static readonly BOTTOM: number;
  14013. /**
  14014. * Gets the default side orientation.
  14015. * @param orientation the orientation to value to attempt to get
  14016. * @returns the default orientation
  14017. * @hidden
  14018. */
  14019. static _GetDefaultSideOrientation(orientation?: number): number;
  14020. private _internalMeshDataInfo;
  14021. /**
  14022. * An event triggered before rendering the mesh
  14023. */
  14024. readonly onBeforeRenderObservable: Observable<Mesh>;
  14025. /**
  14026. * An event triggered before binding the mesh
  14027. */
  14028. readonly onBeforeBindObservable: Observable<Mesh>;
  14029. /**
  14030. * An event triggered after rendering the mesh
  14031. */
  14032. readonly onAfterRenderObservable: Observable<Mesh>;
  14033. /**
  14034. * An event triggered before drawing the mesh
  14035. */
  14036. readonly onBeforeDrawObservable: Observable<Mesh>;
  14037. private _onBeforeDrawObserver;
  14038. /**
  14039. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  14040. */
  14041. onBeforeDraw: () => void;
  14042. /**
  14043. * Gets the delay loading state of the mesh (when delay loading is turned on)
  14044. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  14045. */
  14046. delayLoadState: number;
  14047. /**
  14048. * Gets the list of instances created from this mesh
  14049. * it is not supposed to be modified manually.
  14050. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  14051. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14052. */
  14053. instances: InstancedMesh[];
  14054. /**
  14055. * Gets the file containing delay loading data for this mesh
  14056. */
  14057. delayLoadingFile: string;
  14058. /** @hidden */
  14059. _binaryInfo: any;
  14060. /**
  14061. * User defined function used to change how LOD level selection is done
  14062. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  14063. */
  14064. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  14065. /**
  14066. * Gets or sets the morph target manager
  14067. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14068. */
  14069. morphTargetManager: Nullable<MorphTargetManager>;
  14070. /** @hidden */
  14071. _creationDataStorage: Nullable<_CreationDataStorage>;
  14072. /** @hidden */
  14073. _geometry: Nullable<Geometry>;
  14074. /** @hidden */
  14075. _delayInfo: Array<string>;
  14076. /** @hidden */
  14077. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14078. /** @hidden */
  14079. _instanceDataStorage: _InstanceDataStorage;
  14080. private _effectiveMaterial;
  14081. /** @hidden */
  14082. _shouldGenerateFlatShading: boolean;
  14083. /** @hidden */
  14084. _originalBuilderSideOrientation: number;
  14085. /**
  14086. * Use this property to change the original side orientation defined at construction time
  14087. */
  14088. overrideMaterialSideOrientation: Nullable<number>;
  14089. /**
  14090. * Gets the source mesh (the one used to clone this one from)
  14091. */
  14092. readonly source: Nullable<Mesh>;
  14093. /**
  14094. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14095. */
  14096. isUnIndexed: boolean;
  14097. /**
  14098. * @constructor
  14099. * @param name The value used by scene.getMeshByName() to do a lookup.
  14100. * @param scene The scene to add this mesh to.
  14101. * @param parent The parent of this mesh, if it has one
  14102. * @param source An optional Mesh from which geometry is shared, cloned.
  14103. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14104. * When false, achieved by calling a clone(), also passing False.
  14105. * This will make creation of children, recursive.
  14106. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14107. */
  14108. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14109. /**
  14110. * Gets the class name
  14111. * @returns the string "Mesh".
  14112. */
  14113. getClassName(): string;
  14114. /** @hidden */
  14115. readonly _isMesh: boolean;
  14116. /**
  14117. * Returns a description of this mesh
  14118. * @param fullDetails define if full details about this mesh must be used
  14119. * @returns a descriptive string representing this mesh
  14120. */
  14121. toString(fullDetails?: boolean): string;
  14122. /** @hidden */
  14123. _unBindEffect(): void;
  14124. /**
  14125. * Gets a boolean indicating if this mesh has LOD
  14126. */
  14127. readonly hasLODLevels: boolean;
  14128. /**
  14129. * Gets the list of MeshLODLevel associated with the current mesh
  14130. * @returns an array of MeshLODLevel
  14131. */
  14132. getLODLevels(): MeshLODLevel[];
  14133. private _sortLODLevels;
  14134. /**
  14135. * Add a mesh as LOD level triggered at the given distance.
  14136. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14137. * @param distance The distance from the center of the object to show this level
  14138. * @param mesh The mesh to be added as LOD level (can be null)
  14139. * @return This mesh (for chaining)
  14140. */
  14141. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14142. /**
  14143. * Returns the LOD level mesh at the passed distance or null if not found.
  14144. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14145. * @param distance The distance from the center of the object to show this level
  14146. * @returns a Mesh or `null`
  14147. */
  14148. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14149. /**
  14150. * Remove a mesh from the LOD array
  14151. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14152. * @param mesh defines the mesh to be removed
  14153. * @return This mesh (for chaining)
  14154. */
  14155. removeLODLevel(mesh: Mesh): Mesh;
  14156. /**
  14157. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14158. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14159. * @param camera defines the camera to use to compute distance
  14160. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14161. * @return This mesh (for chaining)
  14162. */
  14163. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14164. /**
  14165. * Gets the mesh internal Geometry object
  14166. */
  14167. readonly geometry: Nullable<Geometry>;
  14168. /**
  14169. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14170. * @returns the total number of vertices
  14171. */
  14172. getTotalVertices(): number;
  14173. /**
  14174. * Returns the content of an associated vertex buffer
  14175. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14176. * - VertexBuffer.PositionKind
  14177. * - VertexBuffer.UVKind
  14178. * - VertexBuffer.UV2Kind
  14179. * - VertexBuffer.UV3Kind
  14180. * - VertexBuffer.UV4Kind
  14181. * - VertexBuffer.UV5Kind
  14182. * - VertexBuffer.UV6Kind
  14183. * - VertexBuffer.ColorKind
  14184. * - VertexBuffer.MatricesIndicesKind
  14185. * - VertexBuffer.MatricesIndicesExtraKind
  14186. * - VertexBuffer.MatricesWeightsKind
  14187. * - VertexBuffer.MatricesWeightsExtraKind
  14188. * @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
  14189. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14190. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14191. */
  14192. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14193. /**
  14194. * Returns the mesh VertexBuffer object from the requested `kind`
  14195. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14196. * - VertexBuffer.PositionKind
  14197. * - VertexBuffer.NormalKind
  14198. * - VertexBuffer.UVKind
  14199. * - VertexBuffer.UV2Kind
  14200. * - VertexBuffer.UV3Kind
  14201. * - VertexBuffer.UV4Kind
  14202. * - VertexBuffer.UV5Kind
  14203. * - VertexBuffer.UV6Kind
  14204. * - VertexBuffer.ColorKind
  14205. * - VertexBuffer.MatricesIndicesKind
  14206. * - VertexBuffer.MatricesIndicesExtraKind
  14207. * - VertexBuffer.MatricesWeightsKind
  14208. * - VertexBuffer.MatricesWeightsExtraKind
  14209. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14210. */
  14211. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14212. /**
  14213. * Tests if a specific vertex buffer is associated with this mesh
  14214. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14215. * - VertexBuffer.PositionKind
  14216. * - VertexBuffer.NormalKind
  14217. * - VertexBuffer.UVKind
  14218. * - VertexBuffer.UV2Kind
  14219. * - VertexBuffer.UV3Kind
  14220. * - VertexBuffer.UV4Kind
  14221. * - VertexBuffer.UV5Kind
  14222. * - VertexBuffer.UV6Kind
  14223. * - VertexBuffer.ColorKind
  14224. * - VertexBuffer.MatricesIndicesKind
  14225. * - VertexBuffer.MatricesIndicesExtraKind
  14226. * - VertexBuffer.MatricesWeightsKind
  14227. * - VertexBuffer.MatricesWeightsExtraKind
  14228. * @returns a boolean
  14229. */
  14230. isVerticesDataPresent(kind: string): boolean;
  14231. /**
  14232. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14233. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14234. * - VertexBuffer.PositionKind
  14235. * - VertexBuffer.UVKind
  14236. * - VertexBuffer.UV2Kind
  14237. * - VertexBuffer.UV3Kind
  14238. * - VertexBuffer.UV4Kind
  14239. * - VertexBuffer.UV5Kind
  14240. * - VertexBuffer.UV6Kind
  14241. * - VertexBuffer.ColorKind
  14242. * - VertexBuffer.MatricesIndicesKind
  14243. * - VertexBuffer.MatricesIndicesExtraKind
  14244. * - VertexBuffer.MatricesWeightsKind
  14245. * - VertexBuffer.MatricesWeightsExtraKind
  14246. * @returns a boolean
  14247. */
  14248. isVertexBufferUpdatable(kind: string): boolean;
  14249. /**
  14250. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14251. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14252. * - VertexBuffer.PositionKind
  14253. * - VertexBuffer.NormalKind
  14254. * - VertexBuffer.UVKind
  14255. * - VertexBuffer.UV2Kind
  14256. * - VertexBuffer.UV3Kind
  14257. * - VertexBuffer.UV4Kind
  14258. * - VertexBuffer.UV5Kind
  14259. * - VertexBuffer.UV6Kind
  14260. * - VertexBuffer.ColorKind
  14261. * - VertexBuffer.MatricesIndicesKind
  14262. * - VertexBuffer.MatricesIndicesExtraKind
  14263. * - VertexBuffer.MatricesWeightsKind
  14264. * - VertexBuffer.MatricesWeightsExtraKind
  14265. * @returns an array of strings
  14266. */
  14267. getVerticesDataKinds(): string[];
  14268. /**
  14269. * Returns a positive integer : the total number of indices in this mesh geometry.
  14270. * @returns the numner of indices or zero if the mesh has no geometry.
  14271. */
  14272. getTotalIndices(): number;
  14273. /**
  14274. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14275. * @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.
  14276. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14277. * @returns the indices array or an empty array if the mesh has no geometry
  14278. */
  14279. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14280. readonly isBlocked: boolean;
  14281. /**
  14282. * Determine if the current mesh is ready to be rendered
  14283. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14284. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14285. * @returns true if all associated assets are ready (material, textures, shaders)
  14286. */
  14287. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14288. /**
  14289. * 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.
  14290. */
  14291. readonly areNormalsFrozen: boolean;
  14292. /**
  14293. * 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.
  14294. * @returns the current mesh
  14295. */
  14296. freezeNormals(): Mesh;
  14297. /**
  14298. * 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
  14299. * @returns the current mesh
  14300. */
  14301. unfreezeNormals(): Mesh;
  14302. /**
  14303. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14304. */
  14305. overridenInstanceCount: number;
  14306. /** @hidden */
  14307. _preActivate(): Mesh;
  14308. /** @hidden */
  14309. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14310. /** @hidden */
  14311. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14312. /**
  14313. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14314. * This means the mesh underlying bounding box and sphere are recomputed.
  14315. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14316. * @returns the current mesh
  14317. */
  14318. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14319. /** @hidden */
  14320. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14321. /**
  14322. * This function will subdivide the mesh into multiple submeshes
  14323. * @param count defines the expected number of submeshes
  14324. */
  14325. subdivide(count: number): void;
  14326. /**
  14327. * Copy a FloatArray into a specific associated vertex buffer
  14328. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14329. * - VertexBuffer.PositionKind
  14330. * - VertexBuffer.UVKind
  14331. * - VertexBuffer.UV2Kind
  14332. * - VertexBuffer.UV3Kind
  14333. * - VertexBuffer.UV4Kind
  14334. * - VertexBuffer.UV5Kind
  14335. * - VertexBuffer.UV6Kind
  14336. * - VertexBuffer.ColorKind
  14337. * - VertexBuffer.MatricesIndicesKind
  14338. * - VertexBuffer.MatricesIndicesExtraKind
  14339. * - VertexBuffer.MatricesWeightsKind
  14340. * - VertexBuffer.MatricesWeightsExtraKind
  14341. * @param data defines the data source
  14342. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14343. * @param stride defines the data stride size (can be null)
  14344. * @returns the current mesh
  14345. */
  14346. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14347. /**
  14348. * Flags an associated vertex buffer as updatable
  14349. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14350. * - VertexBuffer.PositionKind
  14351. * - VertexBuffer.UVKind
  14352. * - VertexBuffer.UV2Kind
  14353. * - VertexBuffer.UV3Kind
  14354. * - VertexBuffer.UV4Kind
  14355. * - VertexBuffer.UV5Kind
  14356. * - VertexBuffer.UV6Kind
  14357. * - VertexBuffer.ColorKind
  14358. * - VertexBuffer.MatricesIndicesKind
  14359. * - VertexBuffer.MatricesIndicesExtraKind
  14360. * - VertexBuffer.MatricesWeightsKind
  14361. * - VertexBuffer.MatricesWeightsExtraKind
  14362. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14363. */
  14364. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14365. /**
  14366. * Sets the mesh global Vertex Buffer
  14367. * @param buffer defines the buffer to use
  14368. * @returns the current mesh
  14369. */
  14370. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14371. /**
  14372. * Update a specific associated vertex buffer
  14373. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14374. * - VertexBuffer.PositionKind
  14375. * - VertexBuffer.UVKind
  14376. * - VertexBuffer.UV2Kind
  14377. * - VertexBuffer.UV3Kind
  14378. * - VertexBuffer.UV4Kind
  14379. * - VertexBuffer.UV5Kind
  14380. * - VertexBuffer.UV6Kind
  14381. * - VertexBuffer.ColorKind
  14382. * - VertexBuffer.MatricesIndicesKind
  14383. * - VertexBuffer.MatricesIndicesExtraKind
  14384. * - VertexBuffer.MatricesWeightsKind
  14385. * - VertexBuffer.MatricesWeightsExtraKind
  14386. * @param data defines the data source
  14387. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14388. * @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)
  14389. * @returns the current mesh
  14390. */
  14391. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14392. /**
  14393. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14394. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14395. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14396. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14397. * @returns the current mesh
  14398. */
  14399. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14400. /**
  14401. * Creates a un-shared specific occurence of the geometry for the mesh.
  14402. * @returns the current mesh
  14403. */
  14404. makeGeometryUnique(): Mesh;
  14405. /**
  14406. * Set the index buffer of this mesh
  14407. * @param indices defines the source data
  14408. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14409. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14410. * @returns the current mesh
  14411. */
  14412. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14413. /**
  14414. * Update the current index buffer
  14415. * @param indices defines the source data
  14416. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14417. * @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)
  14418. * @returns the current mesh
  14419. */
  14420. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14421. /**
  14422. * Invert the geometry to move from a right handed system to a left handed one.
  14423. * @returns the current mesh
  14424. */
  14425. toLeftHanded(): Mesh;
  14426. /** @hidden */
  14427. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14428. /** @hidden */
  14429. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14430. /**
  14431. * Registers for this mesh a javascript function called just before the rendering process
  14432. * @param func defines the function to call before rendering this mesh
  14433. * @returns the current mesh
  14434. */
  14435. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14436. /**
  14437. * Disposes a previously registered javascript function called before the rendering
  14438. * @param func defines the function to remove
  14439. * @returns the current mesh
  14440. */
  14441. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14442. /**
  14443. * Registers for this mesh a javascript function called just after the rendering is complete
  14444. * @param func defines the function to call after rendering this mesh
  14445. * @returns the current mesh
  14446. */
  14447. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14448. /**
  14449. * Disposes a previously registered javascript function called after the rendering.
  14450. * @param func defines the function to remove
  14451. * @returns the current mesh
  14452. */
  14453. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14454. /** @hidden */
  14455. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14456. /** @hidden */
  14457. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14458. /** @hidden */
  14459. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14460. /** @hidden */
  14461. _rebuild(): void;
  14462. /** @hidden */
  14463. _freeze(): void;
  14464. /** @hidden */
  14465. _unFreeze(): void;
  14466. /**
  14467. * 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
  14468. * @param subMesh defines the subMesh to render
  14469. * @param enableAlphaMode defines if alpha mode can be changed
  14470. * @returns the current mesh
  14471. */
  14472. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14473. private _onBeforeDraw;
  14474. /**
  14475. * Renormalize the mesh and patch it up if there are no weights
  14476. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14477. * However in the case of zero weights then we set just a single influence to 1.
  14478. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14479. */
  14480. cleanMatrixWeights(): void;
  14481. private normalizeSkinFourWeights;
  14482. private normalizeSkinWeightsAndExtra;
  14483. /**
  14484. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14485. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14486. * the user know there was an issue with importing the mesh
  14487. * @returns a validation object with skinned, valid and report string
  14488. */
  14489. validateSkinning(): {
  14490. skinned: boolean;
  14491. valid: boolean;
  14492. report: string;
  14493. };
  14494. /** @hidden */
  14495. _checkDelayState(): Mesh;
  14496. private _queueLoad;
  14497. /**
  14498. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14499. * A mesh is in the frustum if its bounding box intersects the frustum
  14500. * @param frustumPlanes defines the frustum to test
  14501. * @returns true if the mesh is in the frustum planes
  14502. */
  14503. isInFrustum(frustumPlanes: Plane[]): boolean;
  14504. /**
  14505. * Sets the mesh material by the material or multiMaterial `id` property
  14506. * @param id is a string identifying the material or the multiMaterial
  14507. * @returns the current mesh
  14508. */
  14509. setMaterialByID(id: string): Mesh;
  14510. /**
  14511. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14512. * @returns an array of IAnimatable
  14513. */
  14514. getAnimatables(): IAnimatable[];
  14515. /**
  14516. * Modifies the mesh geometry according to the passed transformation matrix.
  14517. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14518. * The mesh normals are modified using the same transformation.
  14519. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14520. * @param transform defines the transform matrix to use
  14521. * @see http://doc.babylonjs.com/resources/baking_transformations
  14522. * @returns the current mesh
  14523. */
  14524. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14525. /**
  14526. * Modifies the mesh geometry according to its own current World Matrix.
  14527. * The mesh World Matrix is then reset.
  14528. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14529. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14530. * @see http://doc.babylonjs.com/resources/baking_transformations
  14531. * @returns the current mesh
  14532. */
  14533. bakeCurrentTransformIntoVertices(): Mesh;
  14534. /** @hidden */
  14535. readonly _positions: Nullable<Vector3[]>;
  14536. /** @hidden */
  14537. _resetPointsArrayCache(): Mesh;
  14538. /** @hidden */
  14539. _generatePointsArray(): boolean;
  14540. /**
  14541. * Returns a new Mesh object generated from the current mesh properties.
  14542. * This method must not get confused with createInstance()
  14543. * @param name is a string, the name given to the new mesh
  14544. * @param newParent can be any Node object (default `null`)
  14545. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14546. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14547. * @returns a new mesh
  14548. */
  14549. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14550. /**
  14551. * Releases resources associated with this mesh.
  14552. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14553. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14554. */
  14555. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14556. /**
  14557. * Modifies the mesh geometry according to a displacement map.
  14558. * 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.
  14559. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14560. * @param url is a string, the URL from the image file is to be downloaded.
  14561. * @param minHeight is the lower limit of the displacement.
  14562. * @param maxHeight is the upper limit of the displacement.
  14563. * @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.
  14564. * @param uvOffset is an optional vector2 used to offset UV.
  14565. * @param uvScale is an optional vector2 used to scale UV.
  14566. * @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.
  14567. * @returns the Mesh.
  14568. */
  14569. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14570. /**
  14571. * Modifies the mesh geometry according to a displacementMap buffer.
  14572. * 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.
  14573. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14574. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14575. * @param heightMapWidth is the width of the buffer image.
  14576. * @param heightMapHeight is the height of the buffer image.
  14577. * @param minHeight is the lower limit of the displacement.
  14578. * @param maxHeight is the upper limit of the displacement.
  14579. * @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.
  14580. * @param uvOffset is an optional vector2 used to offset UV.
  14581. * @param uvScale is an optional vector2 used to scale UV.
  14582. * @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.
  14583. * @returns the Mesh.
  14584. */
  14585. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14586. /**
  14587. * Modify the mesh to get a flat shading rendering.
  14588. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14589. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14590. * @returns current mesh
  14591. */
  14592. convertToFlatShadedMesh(): Mesh;
  14593. /**
  14594. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14595. * In other words, more vertices, no more indices and a single bigger VBO.
  14596. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14597. * @returns current mesh
  14598. */
  14599. convertToUnIndexedMesh(): Mesh;
  14600. /**
  14601. * Inverses facet orientations.
  14602. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14603. * @param flipNormals will also inverts the normals
  14604. * @returns current mesh
  14605. */
  14606. flipFaces(flipNormals?: boolean): Mesh;
  14607. /**
  14608. * Increase the number of facets and hence vertices in a mesh
  14609. * Vertex normals are interpolated from existing vertex normals
  14610. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14611. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14612. */
  14613. increaseVertices(numberPerEdge: number): void;
  14614. /**
  14615. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14616. * This will undo any application of covertToFlatShadedMesh
  14617. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14618. */
  14619. forceSharedVertices(): void;
  14620. /** @hidden */
  14621. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14622. /** @hidden */
  14623. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14624. /**
  14625. * Creates a new InstancedMesh object from the mesh model.
  14626. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14627. * @param name defines the name of the new instance
  14628. * @returns a new InstancedMesh
  14629. */
  14630. createInstance(name: string): InstancedMesh;
  14631. /**
  14632. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14633. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14634. * @returns the current mesh
  14635. */
  14636. synchronizeInstances(): Mesh;
  14637. /**
  14638. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14639. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14640. * This should be used together with the simplification to avoid disappearing triangles.
  14641. * @param successCallback an optional success callback to be called after the optimization finished.
  14642. * @returns the current mesh
  14643. */
  14644. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14645. /**
  14646. * Serialize current mesh
  14647. * @param serializationObject defines the object which will receive the serialization data
  14648. */
  14649. serialize(serializationObject: any): void;
  14650. /** @hidden */
  14651. _syncGeometryWithMorphTargetManager(): void;
  14652. /** @hidden */
  14653. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14654. /**
  14655. * Returns a new Mesh object parsed from the source provided.
  14656. * @param parsedMesh is the source
  14657. * @param scene defines the hosting scene
  14658. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14659. * @returns a new Mesh
  14660. */
  14661. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14662. /**
  14663. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14664. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14665. * @param name defines the name of the mesh to create
  14666. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14667. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14668. * @param closePath creates a seam between the first and the last points of each path of the path array
  14669. * @param offset is taken in account only if the `pathArray` is containing a single path
  14670. * @param scene defines the hosting scene
  14671. * @param updatable defines if the mesh must be flagged as updatable
  14672. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14673. * @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)
  14674. * @returns a new Mesh
  14675. */
  14676. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14677. /**
  14678. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14679. * @param name defines the name of the mesh to create
  14680. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14681. * @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
  14682. * @param scene defines the hosting scene
  14683. * @param updatable defines if the mesh must be flagged as updatable
  14684. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14685. * @returns a new Mesh
  14686. */
  14687. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14688. /**
  14689. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14690. * @param name defines the name of the mesh to create
  14691. * @param size sets the size (float) of each box side (default 1)
  14692. * @param scene defines the hosting scene
  14693. * @param updatable defines if the mesh must be flagged as updatable
  14694. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14695. * @returns a new Mesh
  14696. */
  14697. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14698. /**
  14699. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  14700. * @param name defines the name of the mesh to create
  14701. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14702. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14703. * @param scene defines the hosting scene
  14704. * @param updatable defines if the mesh must be flagged as updatable
  14705. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14706. * @returns a new Mesh
  14707. */
  14708. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14709. /**
  14710. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  14711. * @param name defines the name of the mesh to create
  14712. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14713. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14714. * @param scene defines the hosting scene
  14715. * @returns a new Mesh
  14716. */
  14717. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  14718. /**
  14719. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  14720. * @param name defines the name of the mesh to create
  14721. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  14722. * @param diameterTop set the top cap diameter (floats, default 1)
  14723. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  14724. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  14725. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  14726. * @param scene defines the hosting scene
  14727. * @param updatable defines if the mesh must be flagged as updatable
  14728. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14729. * @returns a new Mesh
  14730. */
  14731. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  14732. /**
  14733. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  14734. * @param name defines the name of the mesh to create
  14735. * @param diameter sets the diameter size (float) of the torus (default 1)
  14736. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  14737. * @param tessellation sets the number of torus sides (postive integer, default 16)
  14738. * @param scene defines the hosting scene
  14739. * @param updatable defines if the mesh must be flagged as updatable
  14740. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14741. * @returns a new Mesh
  14742. */
  14743. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14744. /**
  14745. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  14746. * @param name defines the name of the mesh to create
  14747. * @param radius sets the global radius size (float) of the torus knot (default 2)
  14748. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  14749. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  14750. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  14751. * @param p the number of windings on X axis (positive integers, default 2)
  14752. * @param q the number of windings on Y axis (positive integers, default 3)
  14753. * @param scene defines the hosting scene
  14754. * @param updatable defines if the mesh must be flagged as updatable
  14755. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14756. * @returns a new Mesh
  14757. */
  14758. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14759. /**
  14760. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  14761. * @param name defines the name of the mesh to create
  14762. * @param points is an array successive Vector3
  14763. * @param scene defines the hosting scene
  14764. * @param updatable defines if the mesh must be flagged as updatable
  14765. * @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).
  14766. * @returns a new Mesh
  14767. */
  14768. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  14769. /**
  14770. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  14771. * @param name defines the name of the mesh to create
  14772. * @param points is an array successive Vector3
  14773. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  14774. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  14775. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  14776. * @param scene defines the hosting scene
  14777. * @param updatable defines if the mesh must be flagged as updatable
  14778. * @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)
  14779. * @returns a new Mesh
  14780. */
  14781. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  14782. /**
  14783. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  14784. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  14785. * 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.
  14786. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14787. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14788. * Remember you can only change the shape positions, not their number when updating a polygon.
  14789. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  14790. * @param name defines the name of the mesh to create
  14791. * @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
  14792. * @param scene defines the hosting scene
  14793. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14794. * @param updatable defines if the mesh must be flagged as updatable
  14795. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14796. * @param earcutInjection can be used to inject your own earcut reference
  14797. * @returns a new Mesh
  14798. */
  14799. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14800. /**
  14801. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  14802. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  14803. * @param name defines the name of the mesh to create
  14804. * @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
  14805. * @param depth defines the height of extrusion
  14806. * @param scene defines the hosting scene
  14807. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14808. * @param updatable defines if the mesh must be flagged as updatable
  14809. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14810. * @param earcutInjection can be used to inject your own earcut reference
  14811. * @returns a new Mesh
  14812. */
  14813. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14814. /**
  14815. * Creates an extruded shape mesh.
  14816. * 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
  14817. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14818. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  14819. * @param name defines the name of the mesh to create
  14820. * @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
  14821. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  14822. * @param scale is the value to scale the shape
  14823. * @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
  14824. * @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
  14825. * @param scene defines the hosting scene
  14826. * @param updatable defines if the mesh must be flagged as updatable
  14827. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14828. * @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)
  14829. * @returns a new Mesh
  14830. */
  14831. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14832. /**
  14833. * Creates an custom extruded shape mesh.
  14834. * The custom extrusion is a parametric shape.
  14835. * It has no predefined shape. Its final shape will depend on the input parameters.
  14836. * Please consider using the same method from the MeshBuilder class instead
  14837. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  14838. * @param name defines the name of the mesh to create
  14839. * @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
  14840. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  14841. * @param scaleFunction is a custom Javascript function called on each path point
  14842. * @param rotationFunction is a custom Javascript function called on each path point
  14843. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  14844. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  14845. * @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
  14846. * @param scene defines the hosting scene
  14847. * @param updatable defines if the mesh must be flagged as updatable
  14848. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14849. * @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)
  14850. * @returns a new Mesh
  14851. */
  14852. 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;
  14853. /**
  14854. * Creates lathe mesh.
  14855. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  14856. * Please consider using the same method from the MeshBuilder class instead
  14857. * @param name defines the name of the mesh to create
  14858. * @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
  14859. * @param radius is the radius value of the lathe
  14860. * @param tessellation is the side number of the lathe.
  14861. * @param scene defines the hosting scene
  14862. * @param updatable defines if the mesh must be flagged as updatable
  14863. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14864. * @returns a new Mesh
  14865. */
  14866. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14867. /**
  14868. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  14869. * @param name defines the name of the mesh to create
  14870. * @param size sets the size (float) of both sides of the plane at once (default 1)
  14871. * @param scene defines the hosting scene
  14872. * @param updatable defines if the mesh must be flagged as updatable
  14873. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14874. * @returns a new Mesh
  14875. */
  14876. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14877. /**
  14878. * Creates a ground mesh.
  14879. * Please consider using the same method from the MeshBuilder class instead
  14880. * @param name defines the name of the mesh to create
  14881. * @param width set the width of the ground
  14882. * @param height set the height of the ground
  14883. * @param subdivisions sets the number of subdivisions per side
  14884. * @param scene defines the hosting scene
  14885. * @param updatable defines if the mesh must be flagged as updatable
  14886. * @returns a new Mesh
  14887. */
  14888. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  14889. /**
  14890. * Creates a tiled ground mesh.
  14891. * Please consider using the same method from the MeshBuilder class instead
  14892. * @param name defines the name of the mesh to create
  14893. * @param xmin set the ground minimum X coordinate
  14894. * @param zmin set the ground minimum Y coordinate
  14895. * @param xmax set the ground maximum X coordinate
  14896. * @param zmax set the ground maximum Z coordinate
  14897. * @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
  14898. * @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
  14899. * @param scene defines the hosting scene
  14900. * @param updatable defines if the mesh must be flagged as updatable
  14901. * @returns a new Mesh
  14902. */
  14903. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  14904. w: number;
  14905. h: number;
  14906. }, precision: {
  14907. w: number;
  14908. h: number;
  14909. }, scene: Scene, updatable?: boolean): Mesh;
  14910. /**
  14911. * Creates a ground mesh from a height map.
  14912. * Please consider using the same method from the MeshBuilder class instead
  14913. * @see http://doc.babylonjs.com/babylon101/height_map
  14914. * @param name defines the name of the mesh to create
  14915. * @param url sets the URL of the height map image resource
  14916. * @param width set the ground width size
  14917. * @param height set the ground height size
  14918. * @param subdivisions sets the number of subdivision per side
  14919. * @param minHeight is the minimum altitude on the ground
  14920. * @param maxHeight is the maximum altitude on the ground
  14921. * @param scene defines the hosting scene
  14922. * @param updatable defines if the mesh must be flagged as updatable
  14923. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  14924. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  14925. * @returns a new Mesh
  14926. */
  14927. 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;
  14928. /**
  14929. * Creates a tube mesh.
  14930. * The tube is a parametric shape.
  14931. * It has no predefined shape. Its final shape will depend on the input parameters.
  14932. * Please consider using the same method from the MeshBuilder class instead
  14933. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14934. * @param name defines the name of the mesh to create
  14935. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  14936. * @param radius sets the tube radius size
  14937. * @param tessellation is the number of sides on the tubular surface
  14938. * @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
  14939. * @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
  14940. * @param scene defines the hosting scene
  14941. * @param updatable defines if the mesh must be flagged as updatable
  14942. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14943. * @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)
  14944. * @returns a new Mesh
  14945. */
  14946. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  14947. (i: number, distance: number): number;
  14948. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14949. /**
  14950. * Creates a polyhedron mesh.
  14951. * Please consider using the same method from the MeshBuilder class instead.
  14952. * * 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
  14953. * * The parameter `size` (positive float, default 1) sets the polygon size
  14954. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  14955. * * 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`
  14956. * * 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
  14957. * * 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)`)
  14958. * * 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
  14959. * * 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
  14960. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14961. * * 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
  14962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  14963. * @param name defines the name of the mesh to create
  14964. * @param options defines the options used to create the mesh
  14965. * @param scene defines the hosting scene
  14966. * @returns a new Mesh
  14967. */
  14968. static CreatePolyhedron(name: string, options: {
  14969. type?: number;
  14970. size?: number;
  14971. sizeX?: number;
  14972. sizeY?: number;
  14973. sizeZ?: number;
  14974. custom?: any;
  14975. faceUV?: Vector4[];
  14976. faceColors?: Color4[];
  14977. updatable?: boolean;
  14978. sideOrientation?: number;
  14979. }, scene: Scene): Mesh;
  14980. /**
  14981. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  14982. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  14983. * * 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`)
  14984. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  14985. * * 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
  14986. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14987. * * 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
  14988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  14989. * @param name defines the name of the mesh
  14990. * @param options defines the options used to create the mesh
  14991. * @param scene defines the hosting scene
  14992. * @returns a new Mesh
  14993. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  14994. */
  14995. static CreateIcoSphere(name: string, options: {
  14996. radius?: number;
  14997. flat?: boolean;
  14998. subdivisions?: number;
  14999. sideOrientation?: number;
  15000. updatable?: boolean;
  15001. }, scene: Scene): Mesh;
  15002. /**
  15003. * Creates a decal mesh.
  15004. * Please consider using the same method from the MeshBuilder class instead.
  15005. * A decal is a mesh usually applied as a model onto the surface of another mesh
  15006. * @param name defines the name of the mesh
  15007. * @param sourceMesh defines the mesh receiving the decal
  15008. * @param position sets the position of the decal in world coordinates
  15009. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  15010. * @param size sets the decal scaling
  15011. * @param angle sets the angle to rotate the decal
  15012. * @returns a new Mesh
  15013. */
  15014. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15015. /**
  15016. * Prepare internal position array for software CPU skinning
  15017. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  15018. */
  15019. setPositionsForCPUSkinning(): Float32Array;
  15020. /**
  15021. * Prepare internal normal array for software CPU skinning
  15022. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15023. */
  15024. setNormalsForCPUSkinning(): Float32Array;
  15025. /**
  15026. * Updates the vertex buffer by applying transformation from the bones
  15027. * @param skeleton defines the skeleton to apply to current mesh
  15028. * @returns the current mesh
  15029. */
  15030. applySkeleton(skeleton: Skeleton): Mesh;
  15031. /**
  15032. * 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
  15033. * @param meshes defines the list of meshes to scan
  15034. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  15035. */
  15036. static MinMax(meshes: AbstractMesh[]): {
  15037. min: Vector3;
  15038. max: Vector3;
  15039. };
  15040. /**
  15041. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  15042. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  15043. * @returns a vector3
  15044. */
  15045. static Center(meshesOrMinMaxVector: {
  15046. min: Vector3;
  15047. max: Vector3;
  15048. } | AbstractMesh[]): Vector3;
  15049. /**
  15050. * Merge the array of meshes into a single mesh for performance reasons.
  15051. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  15052. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  15053. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  15054. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15055. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  15056. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  15057. * @returns a new mesh
  15058. */
  15059. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  15060. /** @hidden */
  15061. addInstance(instance: InstancedMesh): void;
  15062. /** @hidden */
  15063. removeInstance(instance: InstancedMesh): void;
  15064. }
  15065. }
  15066. declare module BABYLON {
  15067. /**
  15068. * Interface used to define Action
  15069. */
  15070. export interface IAction {
  15071. /**
  15072. * Trigger for the action
  15073. */
  15074. trigger: number;
  15075. /** Options of the trigger */
  15076. triggerOptions: any;
  15077. /**
  15078. * Gets the trigger parameters
  15079. * @returns the trigger parameters
  15080. */
  15081. getTriggerParameter(): any;
  15082. /**
  15083. * Internal only - executes current action event
  15084. * @hidden
  15085. */
  15086. _executeCurrent(evt?: ActionEvent): void;
  15087. /**
  15088. * Serialize placeholder for child classes
  15089. * @param parent of child
  15090. * @returns the serialized object
  15091. */
  15092. serialize(parent: any): any;
  15093. /**
  15094. * Internal only
  15095. * @hidden
  15096. */
  15097. _prepare(): void;
  15098. /**
  15099. * Internal only - manager for action
  15100. * @hidden
  15101. */
  15102. _actionManager: AbstractActionManager;
  15103. /**
  15104. * Adds action to chain of actions, may be a DoNothingAction
  15105. * @param action defines the next action to execute
  15106. * @returns The action passed in
  15107. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15108. */
  15109. then(action: IAction): IAction;
  15110. }
  15111. /**
  15112. * The action to be carried out following a trigger
  15113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15114. */
  15115. export class Action implements IAction {
  15116. /** the trigger, with or without parameters, for the action */
  15117. triggerOptions: any;
  15118. /**
  15119. * Trigger for the action
  15120. */
  15121. trigger: number;
  15122. /**
  15123. * Internal only - manager for action
  15124. * @hidden
  15125. */
  15126. _actionManager: ActionManager;
  15127. private _nextActiveAction;
  15128. private _child;
  15129. private _condition?;
  15130. private _triggerParameter;
  15131. /**
  15132. * An event triggered prior to action being executed.
  15133. */
  15134. onBeforeExecuteObservable: Observable<Action>;
  15135. /**
  15136. * Creates a new Action
  15137. * @param triggerOptions the trigger, with or without parameters, for the action
  15138. * @param condition an optional determinant of action
  15139. */
  15140. constructor(
  15141. /** the trigger, with or without parameters, for the action */
  15142. triggerOptions: any, condition?: Condition);
  15143. /**
  15144. * Internal only
  15145. * @hidden
  15146. */
  15147. _prepare(): void;
  15148. /**
  15149. * Gets the trigger parameters
  15150. * @returns the trigger parameters
  15151. */
  15152. getTriggerParameter(): any;
  15153. /**
  15154. * Internal only - executes current action event
  15155. * @hidden
  15156. */
  15157. _executeCurrent(evt?: ActionEvent): void;
  15158. /**
  15159. * Execute placeholder for child classes
  15160. * @param evt optional action event
  15161. */
  15162. execute(evt?: ActionEvent): void;
  15163. /**
  15164. * Skips to next active action
  15165. */
  15166. skipToNextActiveAction(): void;
  15167. /**
  15168. * Adds action to chain of actions, may be a DoNothingAction
  15169. * @param action defines the next action to execute
  15170. * @returns The action passed in
  15171. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15172. */
  15173. then(action: Action): Action;
  15174. /**
  15175. * Internal only
  15176. * @hidden
  15177. */
  15178. _getProperty(propertyPath: string): string;
  15179. /**
  15180. * Internal only
  15181. * @hidden
  15182. */
  15183. _getEffectiveTarget(target: any, propertyPath: string): any;
  15184. /**
  15185. * Serialize placeholder for child classes
  15186. * @param parent of child
  15187. * @returns the serialized object
  15188. */
  15189. serialize(parent: any): any;
  15190. /**
  15191. * Internal only called by serialize
  15192. * @hidden
  15193. */
  15194. protected _serialize(serializedAction: any, parent?: any): any;
  15195. /**
  15196. * Internal only
  15197. * @hidden
  15198. */
  15199. static _SerializeValueAsString: (value: any) => string;
  15200. /**
  15201. * Internal only
  15202. * @hidden
  15203. */
  15204. static _GetTargetProperty: (target: Scene | Node) => {
  15205. name: string;
  15206. targetType: string;
  15207. value: string;
  15208. };
  15209. }
  15210. }
  15211. declare module BABYLON {
  15212. /**
  15213. * A Condition applied to an Action
  15214. */
  15215. export class Condition {
  15216. /**
  15217. * Internal only - manager for action
  15218. * @hidden
  15219. */
  15220. _actionManager: ActionManager;
  15221. /**
  15222. * Internal only
  15223. * @hidden
  15224. */
  15225. _evaluationId: number;
  15226. /**
  15227. * Internal only
  15228. * @hidden
  15229. */
  15230. _currentResult: boolean;
  15231. /**
  15232. * Creates a new Condition
  15233. * @param actionManager the manager of the action the condition is applied to
  15234. */
  15235. constructor(actionManager: ActionManager);
  15236. /**
  15237. * Check if the current condition is valid
  15238. * @returns a boolean
  15239. */
  15240. isValid(): boolean;
  15241. /**
  15242. * Internal only
  15243. * @hidden
  15244. */
  15245. _getProperty(propertyPath: string): string;
  15246. /**
  15247. * Internal only
  15248. * @hidden
  15249. */
  15250. _getEffectiveTarget(target: any, propertyPath: string): any;
  15251. /**
  15252. * Serialize placeholder for child classes
  15253. * @returns the serialized object
  15254. */
  15255. serialize(): any;
  15256. /**
  15257. * Internal only
  15258. * @hidden
  15259. */
  15260. protected _serialize(serializedCondition: any): any;
  15261. }
  15262. /**
  15263. * Defines specific conditional operators as extensions of Condition
  15264. */
  15265. export class ValueCondition extends Condition {
  15266. /** path to specify the property of the target the conditional operator uses */
  15267. propertyPath: string;
  15268. /** the value compared by the conditional operator against the current value of the property */
  15269. value: any;
  15270. /** the conditional operator, default ValueCondition.IsEqual */
  15271. operator: number;
  15272. /**
  15273. * Internal only
  15274. * @hidden
  15275. */
  15276. private static _IsEqual;
  15277. /**
  15278. * Internal only
  15279. * @hidden
  15280. */
  15281. private static _IsDifferent;
  15282. /**
  15283. * Internal only
  15284. * @hidden
  15285. */
  15286. private static _IsGreater;
  15287. /**
  15288. * Internal only
  15289. * @hidden
  15290. */
  15291. private static _IsLesser;
  15292. /**
  15293. * returns the number for IsEqual
  15294. */
  15295. static readonly IsEqual: number;
  15296. /**
  15297. * Returns the number for IsDifferent
  15298. */
  15299. static readonly IsDifferent: number;
  15300. /**
  15301. * Returns the number for IsGreater
  15302. */
  15303. static readonly IsGreater: number;
  15304. /**
  15305. * Returns the number for IsLesser
  15306. */
  15307. static readonly IsLesser: number;
  15308. /**
  15309. * Internal only The action manager for the condition
  15310. * @hidden
  15311. */
  15312. _actionManager: ActionManager;
  15313. /**
  15314. * Internal only
  15315. * @hidden
  15316. */
  15317. private _target;
  15318. /**
  15319. * Internal only
  15320. * @hidden
  15321. */
  15322. private _effectiveTarget;
  15323. /**
  15324. * Internal only
  15325. * @hidden
  15326. */
  15327. private _property;
  15328. /**
  15329. * Creates a new ValueCondition
  15330. * @param actionManager manager for the action the condition applies to
  15331. * @param target for the action
  15332. * @param propertyPath path to specify the property of the target the conditional operator uses
  15333. * @param value the value compared by the conditional operator against the current value of the property
  15334. * @param operator the conditional operator, default ValueCondition.IsEqual
  15335. */
  15336. constructor(actionManager: ActionManager, target: any,
  15337. /** path to specify the property of the target the conditional operator uses */
  15338. propertyPath: string,
  15339. /** the value compared by the conditional operator against the current value of the property */
  15340. value: any,
  15341. /** the conditional operator, default ValueCondition.IsEqual */
  15342. operator?: number);
  15343. /**
  15344. * Compares the given value with the property value for the specified conditional operator
  15345. * @returns the result of the comparison
  15346. */
  15347. isValid(): boolean;
  15348. /**
  15349. * Serialize the ValueCondition into a JSON compatible object
  15350. * @returns serialization object
  15351. */
  15352. serialize(): any;
  15353. /**
  15354. * Gets the name of the conditional operator for the ValueCondition
  15355. * @param operator the conditional operator
  15356. * @returns the name
  15357. */
  15358. static GetOperatorName(operator: number): string;
  15359. }
  15360. /**
  15361. * Defines a predicate condition as an extension of Condition
  15362. */
  15363. export class PredicateCondition extends Condition {
  15364. /** defines the predicate function used to validate the condition */
  15365. predicate: () => boolean;
  15366. /**
  15367. * Internal only - manager for action
  15368. * @hidden
  15369. */
  15370. _actionManager: ActionManager;
  15371. /**
  15372. * Creates a new PredicateCondition
  15373. * @param actionManager manager for the action the condition applies to
  15374. * @param predicate defines the predicate function used to validate the condition
  15375. */
  15376. constructor(actionManager: ActionManager,
  15377. /** defines the predicate function used to validate the condition */
  15378. predicate: () => boolean);
  15379. /**
  15380. * @returns the validity of the predicate condition
  15381. */
  15382. isValid(): boolean;
  15383. }
  15384. /**
  15385. * Defines a state condition as an extension of Condition
  15386. */
  15387. export class StateCondition extends Condition {
  15388. /** Value to compare with target state */
  15389. value: string;
  15390. /**
  15391. * Internal only - manager for action
  15392. * @hidden
  15393. */
  15394. _actionManager: ActionManager;
  15395. /**
  15396. * Internal only
  15397. * @hidden
  15398. */
  15399. private _target;
  15400. /**
  15401. * Creates a new StateCondition
  15402. * @param actionManager manager for the action the condition applies to
  15403. * @param target of the condition
  15404. * @param value to compare with target state
  15405. */
  15406. constructor(actionManager: ActionManager, target: any,
  15407. /** Value to compare with target state */
  15408. value: string);
  15409. /**
  15410. * Gets a boolean indicating if the current condition is met
  15411. * @returns the validity of the state
  15412. */
  15413. isValid(): boolean;
  15414. /**
  15415. * Serialize the StateCondition into a JSON compatible object
  15416. * @returns serialization object
  15417. */
  15418. serialize(): any;
  15419. }
  15420. }
  15421. declare module BABYLON {
  15422. /**
  15423. * This defines an action responsible to toggle a boolean once triggered.
  15424. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15425. */
  15426. export class SwitchBooleanAction extends Action {
  15427. /**
  15428. * The path to the boolean property in the target object
  15429. */
  15430. propertyPath: string;
  15431. private _target;
  15432. private _effectiveTarget;
  15433. private _property;
  15434. /**
  15435. * Instantiate the action
  15436. * @param triggerOptions defines the trigger options
  15437. * @param target defines the object containing the boolean
  15438. * @param propertyPath defines the path to the boolean property in the target object
  15439. * @param condition defines the trigger related conditions
  15440. */
  15441. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15442. /** @hidden */
  15443. _prepare(): void;
  15444. /**
  15445. * Execute the action toggle the boolean value.
  15446. */
  15447. execute(): void;
  15448. /**
  15449. * Serializes the actions and its related information.
  15450. * @param parent defines the object to serialize in
  15451. * @returns the serialized object
  15452. */
  15453. serialize(parent: any): any;
  15454. }
  15455. /**
  15456. * This defines an action responsible to set a the state field of the target
  15457. * to a desired value once triggered.
  15458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15459. */
  15460. export class SetStateAction extends Action {
  15461. /**
  15462. * The value to store in the state field.
  15463. */
  15464. value: string;
  15465. private _target;
  15466. /**
  15467. * Instantiate the action
  15468. * @param triggerOptions defines the trigger options
  15469. * @param target defines the object containing the state property
  15470. * @param value defines the value to store in the state field
  15471. * @param condition defines the trigger related conditions
  15472. */
  15473. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15474. /**
  15475. * Execute the action and store the value on the target state property.
  15476. */
  15477. execute(): void;
  15478. /**
  15479. * Serializes the actions and its related information.
  15480. * @param parent defines the object to serialize in
  15481. * @returns the serialized object
  15482. */
  15483. serialize(parent: any): any;
  15484. }
  15485. /**
  15486. * This defines an action responsible to set a property of the target
  15487. * to a desired value once triggered.
  15488. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15489. */
  15490. export class SetValueAction extends Action {
  15491. /**
  15492. * The path of the property to set in the target.
  15493. */
  15494. propertyPath: string;
  15495. /**
  15496. * The value to set in the property
  15497. */
  15498. value: any;
  15499. private _target;
  15500. private _effectiveTarget;
  15501. private _property;
  15502. /**
  15503. * Instantiate the action
  15504. * @param triggerOptions defines the trigger options
  15505. * @param target defines the object containing the property
  15506. * @param propertyPath defines the path of the property to set in the target
  15507. * @param value defines the value to set in the property
  15508. * @param condition defines the trigger related conditions
  15509. */
  15510. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15511. /** @hidden */
  15512. _prepare(): void;
  15513. /**
  15514. * Execute the action and set the targetted property to the desired value.
  15515. */
  15516. execute(): void;
  15517. /**
  15518. * Serializes the actions and its related information.
  15519. * @param parent defines the object to serialize in
  15520. * @returns the serialized object
  15521. */
  15522. serialize(parent: any): any;
  15523. }
  15524. /**
  15525. * This defines an action responsible to increment the target value
  15526. * to a desired value once triggered.
  15527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15528. */
  15529. export class IncrementValueAction extends Action {
  15530. /**
  15531. * The path of the property to increment in the target.
  15532. */
  15533. propertyPath: string;
  15534. /**
  15535. * The value we should increment the property by.
  15536. */
  15537. value: any;
  15538. private _target;
  15539. private _effectiveTarget;
  15540. private _property;
  15541. /**
  15542. * Instantiate the action
  15543. * @param triggerOptions defines the trigger options
  15544. * @param target defines the object containing the property
  15545. * @param propertyPath defines the path of the property to increment in the target
  15546. * @param value defines the value value we should increment the property by
  15547. * @param condition defines the trigger related conditions
  15548. */
  15549. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15550. /** @hidden */
  15551. _prepare(): void;
  15552. /**
  15553. * Execute the action and increment the target of the value amount.
  15554. */
  15555. execute(): void;
  15556. /**
  15557. * Serializes the actions and its related information.
  15558. * @param parent defines the object to serialize in
  15559. * @returns the serialized object
  15560. */
  15561. serialize(parent: any): any;
  15562. }
  15563. /**
  15564. * This defines an action responsible to start an animation once triggered.
  15565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15566. */
  15567. export class PlayAnimationAction extends Action {
  15568. /**
  15569. * Where the animation should start (animation frame)
  15570. */
  15571. from: number;
  15572. /**
  15573. * Where the animation should stop (animation frame)
  15574. */
  15575. to: number;
  15576. /**
  15577. * Define if the animation should loop or stop after the first play.
  15578. */
  15579. loop?: boolean;
  15580. private _target;
  15581. /**
  15582. * Instantiate the action
  15583. * @param triggerOptions defines the trigger options
  15584. * @param target defines the target animation or animation name
  15585. * @param from defines from where the animation should start (animation frame)
  15586. * @param end defines where the animation should stop (animation frame)
  15587. * @param loop defines if the animation should loop or stop after the first play
  15588. * @param condition defines the trigger related conditions
  15589. */
  15590. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15591. /** @hidden */
  15592. _prepare(): void;
  15593. /**
  15594. * Execute the action and play the animation.
  15595. */
  15596. execute(): void;
  15597. /**
  15598. * Serializes the actions and its related information.
  15599. * @param parent defines the object to serialize in
  15600. * @returns the serialized object
  15601. */
  15602. serialize(parent: any): any;
  15603. }
  15604. /**
  15605. * This defines an action responsible to stop an animation once triggered.
  15606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15607. */
  15608. export class StopAnimationAction extends Action {
  15609. private _target;
  15610. /**
  15611. * Instantiate the action
  15612. * @param triggerOptions defines the trigger options
  15613. * @param target defines the target animation or animation name
  15614. * @param condition defines the trigger related conditions
  15615. */
  15616. constructor(triggerOptions: any, target: any, condition?: Condition);
  15617. /** @hidden */
  15618. _prepare(): void;
  15619. /**
  15620. * Execute the action and stop the animation.
  15621. */
  15622. execute(): void;
  15623. /**
  15624. * Serializes the actions and its related information.
  15625. * @param parent defines the object to serialize in
  15626. * @returns the serialized object
  15627. */
  15628. serialize(parent: any): any;
  15629. }
  15630. /**
  15631. * This defines an action responsible that does nothing once triggered.
  15632. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15633. */
  15634. export class DoNothingAction extends Action {
  15635. /**
  15636. * Instantiate the action
  15637. * @param triggerOptions defines the trigger options
  15638. * @param condition defines the trigger related conditions
  15639. */
  15640. constructor(triggerOptions?: any, condition?: Condition);
  15641. /**
  15642. * Execute the action and do nothing.
  15643. */
  15644. execute(): void;
  15645. /**
  15646. * Serializes the actions and its related information.
  15647. * @param parent defines the object to serialize in
  15648. * @returns the serialized object
  15649. */
  15650. serialize(parent: any): any;
  15651. }
  15652. /**
  15653. * This defines an action responsible to trigger several actions once triggered.
  15654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15655. */
  15656. export class CombineAction extends Action {
  15657. /**
  15658. * The list of aggregated animations to run.
  15659. */
  15660. children: Action[];
  15661. /**
  15662. * Instantiate the action
  15663. * @param triggerOptions defines the trigger options
  15664. * @param children defines the list of aggregated animations to run
  15665. * @param condition defines the trigger related conditions
  15666. */
  15667. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15668. /** @hidden */
  15669. _prepare(): void;
  15670. /**
  15671. * Execute the action and executes all the aggregated actions.
  15672. */
  15673. execute(evt: ActionEvent): void;
  15674. /**
  15675. * Serializes the actions and its related information.
  15676. * @param parent defines the object to serialize in
  15677. * @returns the serialized object
  15678. */
  15679. serialize(parent: any): any;
  15680. }
  15681. /**
  15682. * This defines an action responsible to run code (external event) once triggered.
  15683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15684. */
  15685. export class ExecuteCodeAction extends Action {
  15686. /**
  15687. * The callback function to run.
  15688. */
  15689. func: (evt: ActionEvent) => void;
  15690. /**
  15691. * Instantiate the action
  15692. * @param triggerOptions defines the trigger options
  15693. * @param func defines the callback function to run
  15694. * @param condition defines the trigger related conditions
  15695. */
  15696. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  15697. /**
  15698. * Execute the action and run the attached code.
  15699. */
  15700. execute(evt: ActionEvent): void;
  15701. }
  15702. /**
  15703. * This defines an action responsible to set the parent property of the target once triggered.
  15704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15705. */
  15706. export class SetParentAction extends Action {
  15707. private _parent;
  15708. private _target;
  15709. /**
  15710. * Instantiate the action
  15711. * @param triggerOptions defines the trigger options
  15712. * @param target defines the target containing the parent property
  15713. * @param parent defines from where the animation should start (animation frame)
  15714. * @param condition defines the trigger related conditions
  15715. */
  15716. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  15717. /** @hidden */
  15718. _prepare(): void;
  15719. /**
  15720. * Execute the action and set the parent property.
  15721. */
  15722. execute(): void;
  15723. /**
  15724. * Serializes the actions and its related information.
  15725. * @param parent defines the object to serialize in
  15726. * @returns the serialized object
  15727. */
  15728. serialize(parent: any): any;
  15729. }
  15730. }
  15731. declare module BABYLON {
  15732. /**
  15733. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  15734. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  15735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15736. */
  15737. export class ActionManager extends AbstractActionManager {
  15738. /**
  15739. * Nothing
  15740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15741. */
  15742. static readonly NothingTrigger: number;
  15743. /**
  15744. * On pick
  15745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15746. */
  15747. static readonly OnPickTrigger: number;
  15748. /**
  15749. * On left pick
  15750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15751. */
  15752. static readonly OnLeftPickTrigger: number;
  15753. /**
  15754. * On right pick
  15755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15756. */
  15757. static readonly OnRightPickTrigger: number;
  15758. /**
  15759. * On center pick
  15760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15761. */
  15762. static readonly OnCenterPickTrigger: number;
  15763. /**
  15764. * On pick down
  15765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15766. */
  15767. static readonly OnPickDownTrigger: number;
  15768. /**
  15769. * On double pick
  15770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15771. */
  15772. static readonly OnDoublePickTrigger: number;
  15773. /**
  15774. * On pick up
  15775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15776. */
  15777. static readonly OnPickUpTrigger: number;
  15778. /**
  15779. * On pick out.
  15780. * This trigger will only be raised if you also declared a OnPickDown
  15781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15782. */
  15783. static readonly OnPickOutTrigger: number;
  15784. /**
  15785. * On long press
  15786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15787. */
  15788. static readonly OnLongPressTrigger: number;
  15789. /**
  15790. * On pointer over
  15791. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15792. */
  15793. static readonly OnPointerOverTrigger: number;
  15794. /**
  15795. * On pointer out
  15796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15797. */
  15798. static readonly OnPointerOutTrigger: number;
  15799. /**
  15800. * On every frame
  15801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15802. */
  15803. static readonly OnEveryFrameTrigger: number;
  15804. /**
  15805. * On intersection enter
  15806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15807. */
  15808. static readonly OnIntersectionEnterTrigger: number;
  15809. /**
  15810. * On intersection exit
  15811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15812. */
  15813. static readonly OnIntersectionExitTrigger: number;
  15814. /**
  15815. * On key down
  15816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15817. */
  15818. static readonly OnKeyDownTrigger: number;
  15819. /**
  15820. * On key up
  15821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15822. */
  15823. static readonly OnKeyUpTrigger: number;
  15824. private _scene;
  15825. /**
  15826. * Creates a new action manager
  15827. * @param scene defines the hosting scene
  15828. */
  15829. constructor(scene: Scene);
  15830. /**
  15831. * Releases all associated resources
  15832. */
  15833. dispose(): void;
  15834. /**
  15835. * Gets hosting scene
  15836. * @returns the hosting scene
  15837. */
  15838. getScene(): Scene;
  15839. /**
  15840. * Does this action manager handles actions of any of the given triggers
  15841. * @param triggers defines the triggers to be tested
  15842. * @return a boolean indicating whether one (or more) of the triggers is handled
  15843. */
  15844. hasSpecificTriggers(triggers: number[]): boolean;
  15845. /**
  15846. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  15847. * speed.
  15848. * @param triggerA defines the trigger to be tested
  15849. * @param triggerB defines the trigger to be tested
  15850. * @return a boolean indicating whether one (or more) of the triggers is handled
  15851. */
  15852. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  15853. /**
  15854. * Does this action manager handles actions of a given trigger
  15855. * @param trigger defines the trigger to be tested
  15856. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  15857. * @return whether the trigger is handled
  15858. */
  15859. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  15860. /**
  15861. * Does this action manager has pointer triggers
  15862. */
  15863. readonly hasPointerTriggers: boolean;
  15864. /**
  15865. * Does this action manager has pick triggers
  15866. */
  15867. readonly hasPickTriggers: boolean;
  15868. /**
  15869. * Registers an action to this action manager
  15870. * @param action defines the action to be registered
  15871. * @return the action amended (prepared) after registration
  15872. */
  15873. registerAction(action: IAction): Nullable<IAction>;
  15874. /**
  15875. * Unregisters an action to this action manager
  15876. * @param action defines the action to be unregistered
  15877. * @return a boolean indicating whether the action has been unregistered
  15878. */
  15879. unregisterAction(action: IAction): Boolean;
  15880. /**
  15881. * Process a specific trigger
  15882. * @param trigger defines the trigger to process
  15883. * @param evt defines the event details to be processed
  15884. */
  15885. processTrigger(trigger: number, evt?: IActionEvent): void;
  15886. /** @hidden */
  15887. _getEffectiveTarget(target: any, propertyPath: string): any;
  15888. /** @hidden */
  15889. _getProperty(propertyPath: string): string;
  15890. /**
  15891. * Serialize this manager to a JSON object
  15892. * @param name defines the property name to store this manager
  15893. * @returns a JSON representation of this manager
  15894. */
  15895. serialize(name: string): any;
  15896. /**
  15897. * Creates a new ActionManager from a JSON data
  15898. * @param parsedActions defines the JSON data to read from
  15899. * @param object defines the hosting mesh
  15900. * @param scene defines the hosting scene
  15901. */
  15902. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  15903. /**
  15904. * Get a trigger name by index
  15905. * @param trigger defines the trigger index
  15906. * @returns a trigger name
  15907. */
  15908. static GetTriggerName(trigger: number): string;
  15909. }
  15910. }
  15911. declare module BABYLON {
  15912. /**
  15913. * Class representing a ray with position and direction
  15914. */
  15915. export class Ray {
  15916. /** origin point */
  15917. origin: Vector3;
  15918. /** direction */
  15919. direction: Vector3;
  15920. /** length of the ray */
  15921. length: number;
  15922. private static readonly TmpVector3;
  15923. private _tmpRay;
  15924. /**
  15925. * Creates a new ray
  15926. * @param origin origin point
  15927. * @param direction direction
  15928. * @param length length of the ray
  15929. */
  15930. constructor(
  15931. /** origin point */
  15932. origin: Vector3,
  15933. /** direction */
  15934. direction: Vector3,
  15935. /** length of the ray */
  15936. length?: number);
  15937. /**
  15938. * Checks if the ray intersects a box
  15939. * @param minimum bound of the box
  15940. * @param maximum bound of the box
  15941. * @param intersectionTreshold extra extend to be added to the box in all direction
  15942. * @returns if the box was hit
  15943. */
  15944. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  15945. /**
  15946. * Checks if the ray intersects a box
  15947. * @param box the bounding box to check
  15948. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  15949. * @returns if the box was hit
  15950. */
  15951. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  15952. /**
  15953. * If the ray hits a sphere
  15954. * @param sphere the bounding sphere to check
  15955. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  15956. * @returns true if it hits the sphere
  15957. */
  15958. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  15959. /**
  15960. * If the ray hits a triange
  15961. * @param vertex0 triangle vertex
  15962. * @param vertex1 triangle vertex
  15963. * @param vertex2 triangle vertex
  15964. * @returns intersection information if hit
  15965. */
  15966. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  15967. /**
  15968. * Checks if ray intersects a plane
  15969. * @param plane the plane to check
  15970. * @returns the distance away it was hit
  15971. */
  15972. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  15973. /**
  15974. * Checks if ray intersects a mesh
  15975. * @param mesh the mesh to check
  15976. * @param fastCheck if only the bounding box should checked
  15977. * @returns picking info of the intersecton
  15978. */
  15979. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  15980. /**
  15981. * Checks if ray intersects a mesh
  15982. * @param meshes the meshes to check
  15983. * @param fastCheck if only the bounding box should checked
  15984. * @param results array to store result in
  15985. * @returns Array of picking infos
  15986. */
  15987. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  15988. private _comparePickingInfo;
  15989. private static smallnum;
  15990. private static rayl;
  15991. /**
  15992. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  15993. * @param sega the first point of the segment to test the intersection against
  15994. * @param segb the second point of the segment to test the intersection against
  15995. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  15996. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  15997. */
  15998. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  15999. /**
  16000. * Update the ray from viewport position
  16001. * @param x position
  16002. * @param y y position
  16003. * @param viewportWidth viewport width
  16004. * @param viewportHeight viewport height
  16005. * @param world world matrix
  16006. * @param view view matrix
  16007. * @param projection projection matrix
  16008. * @returns this ray updated
  16009. */
  16010. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16011. /**
  16012. * Creates a ray with origin and direction of 0,0,0
  16013. * @returns the new ray
  16014. */
  16015. static Zero(): Ray;
  16016. /**
  16017. * Creates a new ray from screen space and viewport
  16018. * @param x position
  16019. * @param y y position
  16020. * @param viewportWidth viewport width
  16021. * @param viewportHeight viewport height
  16022. * @param world world matrix
  16023. * @param view view matrix
  16024. * @param projection projection matrix
  16025. * @returns new ray
  16026. */
  16027. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16028. /**
  16029. * 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
  16030. * transformed to the given world matrix.
  16031. * @param origin The origin point
  16032. * @param end The end point
  16033. * @param world a matrix to transform the ray to. Default is the identity matrix.
  16034. * @returns the new ray
  16035. */
  16036. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  16037. /**
  16038. * Transforms a ray by a matrix
  16039. * @param ray ray to transform
  16040. * @param matrix matrix to apply
  16041. * @returns the resulting new ray
  16042. */
  16043. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  16044. /**
  16045. * Transforms a ray by a matrix
  16046. * @param ray ray to transform
  16047. * @param matrix matrix to apply
  16048. * @param result ray to store result in
  16049. */
  16050. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  16051. /**
  16052. * Unproject a ray from screen space to object space
  16053. * @param sourceX defines the screen space x coordinate to use
  16054. * @param sourceY defines the screen space y coordinate to use
  16055. * @param viewportWidth defines the current width of the viewport
  16056. * @param viewportHeight defines the current height of the viewport
  16057. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16058. * @param view defines the view matrix to use
  16059. * @param projection defines the projection matrix to use
  16060. */
  16061. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  16062. }
  16063. /**
  16064. * Type used to define predicate used to select faces when a mesh intersection is detected
  16065. */
  16066. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  16067. interface Scene {
  16068. /** @hidden */
  16069. _tempPickingRay: Nullable<Ray>;
  16070. /** @hidden */
  16071. _cachedRayForTransform: Ray;
  16072. /** @hidden */
  16073. _pickWithRayInverseMatrix: Matrix;
  16074. /** @hidden */
  16075. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  16076. /** @hidden */
  16077. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  16078. }
  16079. }
  16080. declare module BABYLON {
  16081. interface Scene {
  16082. /** @hidden */
  16083. _pointerOverSprite: Nullable<Sprite>;
  16084. /** @hidden */
  16085. _pickedDownSprite: Nullable<Sprite>;
  16086. /** @hidden */
  16087. _tempSpritePickingRay: Nullable<Ray>;
  16088. /**
  16089. * All of the sprite managers added to this scene
  16090. * @see http://doc.babylonjs.com/babylon101/sprites
  16091. */
  16092. spriteManagers: Array<ISpriteManager>;
  16093. /**
  16094. * An event triggered when sprites rendering is about to start
  16095. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16096. */
  16097. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16098. /**
  16099. * An event triggered when sprites rendering is done
  16100. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16101. */
  16102. onAfterSpritesRenderingObservable: Observable<Scene>;
  16103. /** @hidden */
  16104. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16105. /** Launch a ray to try to pick a sprite in the scene
  16106. * @param x position on screen
  16107. * @param y position on screen
  16108. * @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
  16109. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16110. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16111. * @returns a PickingInfo
  16112. */
  16113. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16114. /** Use the given ray to pick a sprite in the scene
  16115. * @param ray The ray (in world space) to use to pick meshes
  16116. * @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
  16117. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16118. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16119. * @returns a PickingInfo
  16120. */
  16121. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16122. /**
  16123. * Force the sprite under the pointer
  16124. * @param sprite defines the sprite to use
  16125. */
  16126. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16127. /**
  16128. * Gets the sprite under the pointer
  16129. * @returns a Sprite or null if no sprite is under the pointer
  16130. */
  16131. getPointerOverSprite(): Nullable<Sprite>;
  16132. }
  16133. /**
  16134. * Defines the sprite scene component responsible to manage sprites
  16135. * in a given scene.
  16136. */
  16137. export class SpriteSceneComponent implements ISceneComponent {
  16138. /**
  16139. * The component name helpfull to identify the component in the list of scene components.
  16140. */
  16141. readonly name: string;
  16142. /**
  16143. * The scene the component belongs to.
  16144. */
  16145. scene: Scene;
  16146. /** @hidden */
  16147. private _spritePredicate;
  16148. /**
  16149. * Creates a new instance of the component for the given scene
  16150. * @param scene Defines the scene to register the component in
  16151. */
  16152. constructor(scene: Scene);
  16153. /**
  16154. * Registers the component in a given scene
  16155. */
  16156. register(): void;
  16157. /**
  16158. * Rebuilds the elements related to this component in case of
  16159. * context lost for instance.
  16160. */
  16161. rebuild(): void;
  16162. /**
  16163. * Disposes the component and the associated ressources.
  16164. */
  16165. dispose(): void;
  16166. private _pickSpriteButKeepRay;
  16167. private _pointerMove;
  16168. private _pointerDown;
  16169. private _pointerUp;
  16170. }
  16171. }
  16172. declare module BABYLON {
  16173. /** @hidden */
  16174. export var fogFragmentDeclaration: {
  16175. name: string;
  16176. shader: string;
  16177. };
  16178. }
  16179. declare module BABYLON {
  16180. /** @hidden */
  16181. export var fogFragment: {
  16182. name: string;
  16183. shader: string;
  16184. };
  16185. }
  16186. declare module BABYLON {
  16187. /** @hidden */
  16188. export var spritesPixelShader: {
  16189. name: string;
  16190. shader: string;
  16191. };
  16192. }
  16193. declare module BABYLON {
  16194. /** @hidden */
  16195. export var fogVertexDeclaration: {
  16196. name: string;
  16197. shader: string;
  16198. };
  16199. }
  16200. declare module BABYLON {
  16201. /** @hidden */
  16202. export var spritesVertexShader: {
  16203. name: string;
  16204. shader: string;
  16205. };
  16206. }
  16207. declare module BABYLON {
  16208. /**
  16209. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16210. */
  16211. export interface ISpriteManager extends IDisposable {
  16212. /**
  16213. * Restricts the camera to viewing objects with the same layerMask.
  16214. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16215. */
  16216. layerMask: number;
  16217. /**
  16218. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16219. */
  16220. isPickable: boolean;
  16221. /**
  16222. * Specifies the rendering group id for this mesh (0 by default)
  16223. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16224. */
  16225. renderingGroupId: number;
  16226. /**
  16227. * Defines the list of sprites managed by the manager.
  16228. */
  16229. sprites: Array<Sprite>;
  16230. /**
  16231. * Tests the intersection of a sprite with a specific ray.
  16232. * @param ray The ray we are sending to test the collision
  16233. * @param camera The camera space we are sending rays in
  16234. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16235. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16236. * @returns picking info or null.
  16237. */
  16238. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16239. /**
  16240. * Renders the list of sprites on screen.
  16241. */
  16242. render(): void;
  16243. }
  16244. /**
  16245. * Class used to manage multiple sprites on the same spritesheet
  16246. * @see http://doc.babylonjs.com/babylon101/sprites
  16247. */
  16248. export class SpriteManager implements ISpriteManager {
  16249. /** defines the manager's name */
  16250. name: string;
  16251. /** Gets the list of sprites */
  16252. sprites: Sprite[];
  16253. /** Gets or sets the rendering group id (0 by default) */
  16254. renderingGroupId: number;
  16255. /** Gets or sets camera layer mask */
  16256. layerMask: number;
  16257. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16258. fogEnabled: boolean;
  16259. /** Gets or sets a boolean indicating if the sprites are pickable */
  16260. isPickable: boolean;
  16261. /** Defines the default width of a cell in the spritesheet */
  16262. cellWidth: number;
  16263. /** Defines the default height of a cell in the spritesheet */
  16264. cellHeight: number;
  16265. /**
  16266. * An event triggered when the manager is disposed.
  16267. */
  16268. onDisposeObservable: Observable<SpriteManager>;
  16269. private _onDisposeObserver;
  16270. /**
  16271. * Callback called when the manager is disposed
  16272. */
  16273. onDispose: () => void;
  16274. private _capacity;
  16275. private _spriteTexture;
  16276. private _epsilon;
  16277. private _scene;
  16278. private _vertexData;
  16279. private _buffer;
  16280. private _vertexBuffers;
  16281. private _indexBuffer;
  16282. private _effectBase;
  16283. private _effectFog;
  16284. /**
  16285. * Gets or sets the spritesheet texture
  16286. */
  16287. texture: Texture;
  16288. /**
  16289. * Creates a new sprite manager
  16290. * @param name defines the manager's name
  16291. * @param imgUrl defines the sprite sheet url
  16292. * @param capacity defines the maximum allowed number of sprites
  16293. * @param cellSize defines the size of a sprite cell
  16294. * @param scene defines the hosting scene
  16295. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16296. * @param samplingMode defines the smapling mode to use with spritesheet
  16297. */
  16298. constructor(
  16299. /** defines the manager's name */
  16300. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16301. private _appendSpriteVertex;
  16302. /**
  16303. * Intersects the sprites with a ray
  16304. * @param ray defines the ray to intersect with
  16305. * @param camera defines the current active camera
  16306. * @param predicate defines a predicate used to select candidate sprites
  16307. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16308. * @returns null if no hit or a PickingInfo
  16309. */
  16310. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16311. /**
  16312. * Render all child sprites
  16313. */
  16314. render(): void;
  16315. /**
  16316. * Release associated resources
  16317. */
  16318. dispose(): void;
  16319. }
  16320. }
  16321. declare module BABYLON {
  16322. /**
  16323. * Class used to represent a sprite
  16324. * @see http://doc.babylonjs.com/babylon101/sprites
  16325. */
  16326. export class Sprite {
  16327. /** defines the name */
  16328. name: string;
  16329. /** Gets or sets the current world position */
  16330. position: Vector3;
  16331. /** Gets or sets the main color */
  16332. color: Color4;
  16333. /** Gets or sets the width */
  16334. width: number;
  16335. /** Gets or sets the height */
  16336. height: number;
  16337. /** Gets or sets rotation angle */
  16338. angle: number;
  16339. /** Gets or sets the cell index in the sprite sheet */
  16340. cellIndex: number;
  16341. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16342. invertU: number;
  16343. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16344. invertV: number;
  16345. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16346. disposeWhenFinishedAnimating: boolean;
  16347. /** Gets the list of attached animations */
  16348. animations: Animation[];
  16349. /** Gets or sets a boolean indicating if the sprite can be picked */
  16350. isPickable: boolean;
  16351. /**
  16352. * Gets or sets the associated action manager
  16353. */
  16354. actionManager: Nullable<ActionManager>;
  16355. private _animationStarted;
  16356. private _loopAnimation;
  16357. private _fromIndex;
  16358. private _toIndex;
  16359. private _delay;
  16360. private _direction;
  16361. private _manager;
  16362. private _time;
  16363. private _onAnimationEnd;
  16364. /**
  16365. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16366. */
  16367. isVisible: boolean;
  16368. /**
  16369. * Gets or sets the sprite size
  16370. */
  16371. size: number;
  16372. /**
  16373. * Creates a new Sprite
  16374. * @param name defines the name
  16375. * @param manager defines the manager
  16376. */
  16377. constructor(
  16378. /** defines the name */
  16379. name: string, manager: ISpriteManager);
  16380. /**
  16381. * Starts an animation
  16382. * @param from defines the initial key
  16383. * @param to defines the end key
  16384. * @param loop defines if the animation must loop
  16385. * @param delay defines the start delay (in ms)
  16386. * @param onAnimationEnd defines a callback to call when animation ends
  16387. */
  16388. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16389. /** Stops current animation (if any) */
  16390. stopAnimation(): void;
  16391. /** @hidden */
  16392. _animate(deltaTime: number): void;
  16393. /** Release associated resources */
  16394. dispose(): void;
  16395. }
  16396. }
  16397. declare module BABYLON {
  16398. /**
  16399. * Information about the result of picking within a scene
  16400. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16401. */
  16402. export class PickingInfo {
  16403. /** @hidden */
  16404. _pickingUnavailable: boolean;
  16405. /**
  16406. * If the pick collided with an object
  16407. */
  16408. hit: boolean;
  16409. /**
  16410. * Distance away where the pick collided
  16411. */
  16412. distance: number;
  16413. /**
  16414. * The location of pick collision
  16415. */
  16416. pickedPoint: Nullable<Vector3>;
  16417. /**
  16418. * The mesh corresponding the the pick collision
  16419. */
  16420. pickedMesh: Nullable<AbstractMesh>;
  16421. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16422. bu: number;
  16423. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16424. bv: number;
  16425. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16426. faceId: number;
  16427. /** Id of the the submesh that was picked */
  16428. subMeshId: number;
  16429. /** If a sprite was picked, this will be the sprite the pick collided with */
  16430. pickedSprite: Nullable<Sprite>;
  16431. /**
  16432. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16433. */
  16434. originMesh: Nullable<AbstractMesh>;
  16435. /**
  16436. * The ray that was used to perform the picking.
  16437. */
  16438. ray: Nullable<Ray>;
  16439. /**
  16440. * Gets the normal correspodning to the face the pick collided with
  16441. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16442. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16443. * @returns The normal correspodning to the face the pick collided with
  16444. */
  16445. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16446. /**
  16447. * Gets the texture coordinates of where the pick occured
  16448. * @returns the vector containing the coordnates of the texture
  16449. */
  16450. getTextureCoordinates(): Nullable<Vector2>;
  16451. }
  16452. }
  16453. declare module BABYLON {
  16454. /**
  16455. * Gather the list of pointer event types as constants.
  16456. */
  16457. export class PointerEventTypes {
  16458. /**
  16459. * 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.
  16460. */
  16461. static readonly POINTERDOWN: number;
  16462. /**
  16463. * The pointerup event is fired when a pointer is no longer active.
  16464. */
  16465. static readonly POINTERUP: number;
  16466. /**
  16467. * The pointermove event is fired when a pointer changes coordinates.
  16468. */
  16469. static readonly POINTERMOVE: number;
  16470. /**
  16471. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16472. */
  16473. static readonly POINTERWHEEL: number;
  16474. /**
  16475. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16476. */
  16477. static readonly POINTERPICK: number;
  16478. /**
  16479. * The pointertap event is fired when a the object has been touched and released without drag.
  16480. */
  16481. static readonly POINTERTAP: number;
  16482. /**
  16483. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16484. */
  16485. static readonly POINTERDOUBLETAP: number;
  16486. }
  16487. /**
  16488. * Base class of pointer info types.
  16489. */
  16490. export class PointerInfoBase {
  16491. /**
  16492. * Defines the type of event (PointerEventTypes)
  16493. */
  16494. type: number;
  16495. /**
  16496. * Defines the related dom event
  16497. */
  16498. event: PointerEvent | MouseWheelEvent;
  16499. /**
  16500. * Instantiates the base class of pointers info.
  16501. * @param type Defines the type of event (PointerEventTypes)
  16502. * @param event Defines the related dom event
  16503. */
  16504. constructor(
  16505. /**
  16506. * Defines the type of event (PointerEventTypes)
  16507. */
  16508. type: number,
  16509. /**
  16510. * Defines the related dom event
  16511. */
  16512. event: PointerEvent | MouseWheelEvent);
  16513. }
  16514. /**
  16515. * This class is used to store pointer related info for the onPrePointerObservable event.
  16516. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16517. */
  16518. export class PointerInfoPre extends PointerInfoBase {
  16519. /**
  16520. * Ray from a pointer if availible (eg. 6dof controller)
  16521. */
  16522. ray: Nullable<Ray>;
  16523. /**
  16524. * Defines the local position of the pointer on the canvas.
  16525. */
  16526. localPosition: Vector2;
  16527. /**
  16528. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16529. */
  16530. skipOnPointerObservable: boolean;
  16531. /**
  16532. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16533. * @param type Defines the type of event (PointerEventTypes)
  16534. * @param event Defines the related dom event
  16535. * @param localX Defines the local x coordinates of the pointer when the event occured
  16536. * @param localY Defines the local y coordinates of the pointer when the event occured
  16537. */
  16538. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16539. }
  16540. /**
  16541. * This type contains all the data related to a pointer event in Babylon.js.
  16542. * 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.
  16543. */
  16544. export class PointerInfo extends PointerInfoBase {
  16545. /**
  16546. * Defines the picking info associated to the info (if any)\
  16547. */
  16548. pickInfo: Nullable<PickingInfo>;
  16549. /**
  16550. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16551. * @param type Defines the type of event (PointerEventTypes)
  16552. * @param event Defines the related dom event
  16553. * @param pickInfo Defines the picking info associated to the info (if any)\
  16554. */
  16555. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16556. /**
  16557. * Defines the picking info associated to the info (if any)\
  16558. */
  16559. pickInfo: Nullable<PickingInfo>);
  16560. }
  16561. /**
  16562. * Data relating to a touch event on the screen.
  16563. */
  16564. export interface PointerTouch {
  16565. /**
  16566. * X coordinate of touch.
  16567. */
  16568. x: number;
  16569. /**
  16570. * Y coordinate of touch.
  16571. */
  16572. y: number;
  16573. /**
  16574. * Id of touch. Unique for each finger.
  16575. */
  16576. pointerId: number;
  16577. /**
  16578. * Event type passed from DOM.
  16579. */
  16580. type: any;
  16581. }
  16582. }
  16583. declare module BABYLON {
  16584. /**
  16585. * Manage the mouse inputs to control the movement of a free camera.
  16586. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16587. */
  16588. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16589. /**
  16590. * Define if touch is enabled in the mouse input
  16591. */
  16592. touchEnabled: boolean;
  16593. /**
  16594. * Defines the camera the input is attached to.
  16595. */
  16596. camera: FreeCamera;
  16597. /**
  16598. * Defines the buttons associated with the input to handle camera move.
  16599. */
  16600. buttons: number[];
  16601. /**
  16602. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16603. */
  16604. angularSensibility: number;
  16605. private _pointerInput;
  16606. private _onMouseMove;
  16607. private _observer;
  16608. private previousPosition;
  16609. /**
  16610. * Observable for when a pointer move event occurs containing the move offset
  16611. */
  16612. onPointerMovedObservable: Observable<{
  16613. offsetX: number;
  16614. offsetY: number;
  16615. }>;
  16616. /**
  16617. * @hidden
  16618. * If the camera should be rotated automatically based on pointer movement
  16619. */
  16620. _allowCameraRotation: boolean;
  16621. /**
  16622. * Manage the mouse inputs to control the movement of a free camera.
  16623. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16624. * @param touchEnabled Defines if touch is enabled or not
  16625. */
  16626. constructor(
  16627. /**
  16628. * Define if touch is enabled in the mouse input
  16629. */
  16630. touchEnabled?: boolean);
  16631. /**
  16632. * Attach the input controls to a specific dom element to get the input from.
  16633. * @param element Defines the element the controls should be listened from
  16634. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16635. */
  16636. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16637. /**
  16638. * Called on JS contextmenu event.
  16639. * Override this method to provide functionality.
  16640. */
  16641. protected onContextMenu(evt: PointerEvent): void;
  16642. /**
  16643. * Detach the current controls from the specified dom element.
  16644. * @param element Defines the element to stop listening the inputs from
  16645. */
  16646. detachControl(element: Nullable<HTMLElement>): void;
  16647. /**
  16648. * Gets the class name of the current intput.
  16649. * @returns the class name
  16650. */
  16651. getClassName(): string;
  16652. /**
  16653. * Get the friendly name associated with the input class.
  16654. * @returns the input friendly name
  16655. */
  16656. getSimpleName(): string;
  16657. }
  16658. }
  16659. declare module BABYLON {
  16660. /**
  16661. * Manage the touch inputs to control the movement of a free camera.
  16662. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16663. */
  16664. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  16665. /**
  16666. * Defines the camera the input is attached to.
  16667. */
  16668. camera: FreeCamera;
  16669. /**
  16670. * Defines the touch sensibility for rotation.
  16671. * The higher the faster.
  16672. */
  16673. touchAngularSensibility: number;
  16674. /**
  16675. * Defines the touch sensibility for move.
  16676. * The higher the faster.
  16677. */
  16678. touchMoveSensibility: number;
  16679. private _offsetX;
  16680. private _offsetY;
  16681. private _pointerPressed;
  16682. private _pointerInput;
  16683. private _observer;
  16684. private _onLostFocus;
  16685. /**
  16686. * Attach the input controls to a specific dom element to get the input from.
  16687. * @param element Defines the element the controls should be listened from
  16688. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16689. */
  16690. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16691. /**
  16692. * Detach the current controls from the specified dom element.
  16693. * @param element Defines the element to stop listening the inputs from
  16694. */
  16695. detachControl(element: Nullable<HTMLElement>): void;
  16696. /**
  16697. * Update the current camera state depending on the inputs that have been used this frame.
  16698. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  16699. */
  16700. checkInputs(): void;
  16701. /**
  16702. * Gets the class name of the current intput.
  16703. * @returns the class name
  16704. */
  16705. getClassName(): string;
  16706. /**
  16707. * Get the friendly name associated with the input class.
  16708. * @returns the input friendly name
  16709. */
  16710. getSimpleName(): string;
  16711. }
  16712. }
  16713. declare module BABYLON {
  16714. /**
  16715. * Default Inputs manager for the FreeCamera.
  16716. * It groups all the default supported inputs for ease of use.
  16717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16718. */
  16719. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  16720. /**
  16721. * @hidden
  16722. */
  16723. _mouseInput: Nullable<FreeCameraMouseInput>;
  16724. /**
  16725. * Instantiates a new FreeCameraInputsManager.
  16726. * @param camera Defines the camera the inputs belong to
  16727. */
  16728. constructor(camera: FreeCamera);
  16729. /**
  16730. * Add keyboard input support to the input manager.
  16731. * @returns the current input manager
  16732. */
  16733. addKeyboard(): FreeCameraInputsManager;
  16734. /**
  16735. * Add mouse input support to the input manager.
  16736. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  16737. * @returns the current input manager
  16738. */
  16739. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  16740. /**
  16741. * Removes the mouse input support from the manager
  16742. * @returns the current input manager
  16743. */
  16744. removeMouse(): FreeCameraInputsManager;
  16745. /**
  16746. * Add touch input support to the input manager.
  16747. * @returns the current input manager
  16748. */
  16749. addTouch(): FreeCameraInputsManager;
  16750. /**
  16751. * Remove all attached input methods from a camera
  16752. */
  16753. clear(): void;
  16754. }
  16755. }
  16756. declare module BABYLON {
  16757. /**
  16758. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  16759. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  16760. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  16761. */
  16762. export class FreeCamera extends TargetCamera {
  16763. /**
  16764. * Define the collision ellipsoid of the camera.
  16765. * This is helpful to simulate a camera body like the player body around the camera
  16766. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  16767. */
  16768. ellipsoid: Vector3;
  16769. /**
  16770. * Define an offset for the position of the ellipsoid around the camera.
  16771. * This can be helpful to determine the center of the body near the gravity center of the body
  16772. * instead of its head.
  16773. */
  16774. ellipsoidOffset: Vector3;
  16775. /**
  16776. * Enable or disable collisions of the camera with the rest of the scene objects.
  16777. */
  16778. checkCollisions: boolean;
  16779. /**
  16780. * Enable or disable gravity on the camera.
  16781. */
  16782. applyGravity: boolean;
  16783. /**
  16784. * Define the input manager associated to the camera.
  16785. */
  16786. inputs: FreeCameraInputsManager;
  16787. /**
  16788. * Gets the input sensibility for a mouse input. (default is 2000.0)
  16789. * Higher values reduce sensitivity.
  16790. */
  16791. /**
  16792. * Sets the input sensibility for a mouse input. (default is 2000.0)
  16793. * Higher values reduce sensitivity.
  16794. */
  16795. angularSensibility: number;
  16796. /**
  16797. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  16798. */
  16799. keysUp: number[];
  16800. /**
  16801. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  16802. */
  16803. keysDown: number[];
  16804. /**
  16805. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  16806. */
  16807. keysLeft: number[];
  16808. /**
  16809. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  16810. */
  16811. keysRight: number[];
  16812. /**
  16813. * Event raised when the camera collide with a mesh in the scene.
  16814. */
  16815. onCollide: (collidedMesh: AbstractMesh) => void;
  16816. private _collider;
  16817. private _needMoveForGravity;
  16818. private _oldPosition;
  16819. private _diffPosition;
  16820. private _newPosition;
  16821. /** @hidden */
  16822. _localDirection: Vector3;
  16823. /** @hidden */
  16824. _transformedDirection: Vector3;
  16825. /**
  16826. * Instantiates a Free Camera.
  16827. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  16828. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  16829. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  16830. * @param name Define the name of the camera in the scene
  16831. * @param position Define the start position of the camera in the scene
  16832. * @param scene Define the scene the camera belongs to
  16833. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  16834. */
  16835. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  16836. /**
  16837. * Attached controls to the current camera.
  16838. * @param element Defines the element the controls should be listened from
  16839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16840. */
  16841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16842. /**
  16843. * Detach the current controls from the camera.
  16844. * The camera will stop reacting to inputs.
  16845. * @param element Defines the element to stop listening the inputs from
  16846. */
  16847. detachControl(element: HTMLElement): void;
  16848. private _collisionMask;
  16849. /**
  16850. * Define a collision mask to limit the list of object the camera can collide with
  16851. */
  16852. collisionMask: number;
  16853. /** @hidden */
  16854. _collideWithWorld(displacement: Vector3): void;
  16855. private _onCollisionPositionChange;
  16856. /** @hidden */
  16857. _checkInputs(): void;
  16858. /** @hidden */
  16859. _decideIfNeedsToMove(): boolean;
  16860. /** @hidden */
  16861. _updatePosition(): void;
  16862. /**
  16863. * Destroy the camera and release the current resources hold by it.
  16864. */
  16865. dispose(): void;
  16866. /**
  16867. * Gets the current object class name.
  16868. * @return the class name
  16869. */
  16870. getClassName(): string;
  16871. }
  16872. }
  16873. declare module BABYLON {
  16874. /**
  16875. * Represents a gamepad control stick position
  16876. */
  16877. export class StickValues {
  16878. /**
  16879. * The x component of the control stick
  16880. */
  16881. x: number;
  16882. /**
  16883. * The y component of the control stick
  16884. */
  16885. y: number;
  16886. /**
  16887. * Initializes the gamepad x and y control stick values
  16888. * @param x The x component of the gamepad control stick value
  16889. * @param y The y component of the gamepad control stick value
  16890. */
  16891. constructor(
  16892. /**
  16893. * The x component of the control stick
  16894. */
  16895. x: number,
  16896. /**
  16897. * The y component of the control stick
  16898. */
  16899. y: number);
  16900. }
  16901. /**
  16902. * An interface which manages callbacks for gamepad button changes
  16903. */
  16904. export interface GamepadButtonChanges {
  16905. /**
  16906. * Called when a gamepad has been changed
  16907. */
  16908. changed: boolean;
  16909. /**
  16910. * Called when a gamepad press event has been triggered
  16911. */
  16912. pressChanged: boolean;
  16913. /**
  16914. * Called when a touch event has been triggered
  16915. */
  16916. touchChanged: boolean;
  16917. /**
  16918. * Called when a value has changed
  16919. */
  16920. valueChanged: boolean;
  16921. }
  16922. /**
  16923. * Represents a gamepad
  16924. */
  16925. export class Gamepad {
  16926. /**
  16927. * The id of the gamepad
  16928. */
  16929. id: string;
  16930. /**
  16931. * The index of the gamepad
  16932. */
  16933. index: number;
  16934. /**
  16935. * The browser gamepad
  16936. */
  16937. browserGamepad: any;
  16938. /**
  16939. * Specifies what type of gamepad this represents
  16940. */
  16941. type: number;
  16942. private _leftStick;
  16943. private _rightStick;
  16944. /** @hidden */
  16945. _isConnected: boolean;
  16946. private _leftStickAxisX;
  16947. private _leftStickAxisY;
  16948. private _rightStickAxisX;
  16949. private _rightStickAxisY;
  16950. /**
  16951. * Triggered when the left control stick has been changed
  16952. */
  16953. private _onleftstickchanged;
  16954. /**
  16955. * Triggered when the right control stick has been changed
  16956. */
  16957. private _onrightstickchanged;
  16958. /**
  16959. * Represents a gamepad controller
  16960. */
  16961. static GAMEPAD: number;
  16962. /**
  16963. * Represents a generic controller
  16964. */
  16965. static GENERIC: number;
  16966. /**
  16967. * Represents an XBox controller
  16968. */
  16969. static XBOX: number;
  16970. /**
  16971. * Represents a pose-enabled controller
  16972. */
  16973. static POSE_ENABLED: number;
  16974. /**
  16975. * Specifies whether the left control stick should be Y-inverted
  16976. */
  16977. protected _invertLeftStickY: boolean;
  16978. /**
  16979. * Specifies if the gamepad has been connected
  16980. */
  16981. readonly isConnected: boolean;
  16982. /**
  16983. * Initializes the gamepad
  16984. * @param id The id of the gamepad
  16985. * @param index The index of the gamepad
  16986. * @param browserGamepad The browser gamepad
  16987. * @param leftStickX The x component of the left joystick
  16988. * @param leftStickY The y component of the left joystick
  16989. * @param rightStickX The x component of the right joystick
  16990. * @param rightStickY The y component of the right joystick
  16991. */
  16992. constructor(
  16993. /**
  16994. * The id of the gamepad
  16995. */
  16996. id: string,
  16997. /**
  16998. * The index of the gamepad
  16999. */
  17000. index: number,
  17001. /**
  17002. * The browser gamepad
  17003. */
  17004. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  17005. /**
  17006. * Callback triggered when the left joystick has changed
  17007. * @param callback
  17008. */
  17009. onleftstickchanged(callback: (values: StickValues) => void): void;
  17010. /**
  17011. * Callback triggered when the right joystick has changed
  17012. * @param callback
  17013. */
  17014. onrightstickchanged(callback: (values: StickValues) => void): void;
  17015. /**
  17016. * Gets the left joystick
  17017. */
  17018. /**
  17019. * Sets the left joystick values
  17020. */
  17021. leftStick: StickValues;
  17022. /**
  17023. * Gets the right joystick
  17024. */
  17025. /**
  17026. * Sets the right joystick value
  17027. */
  17028. rightStick: StickValues;
  17029. /**
  17030. * Updates the gamepad joystick positions
  17031. */
  17032. update(): void;
  17033. /**
  17034. * Disposes the gamepad
  17035. */
  17036. dispose(): void;
  17037. }
  17038. /**
  17039. * Represents a generic gamepad
  17040. */
  17041. export class GenericPad extends Gamepad {
  17042. private _buttons;
  17043. private _onbuttondown;
  17044. private _onbuttonup;
  17045. /**
  17046. * Observable triggered when a button has been pressed
  17047. */
  17048. onButtonDownObservable: Observable<number>;
  17049. /**
  17050. * Observable triggered when a button has been released
  17051. */
  17052. onButtonUpObservable: Observable<number>;
  17053. /**
  17054. * Callback triggered when a button has been pressed
  17055. * @param callback Called when a button has been pressed
  17056. */
  17057. onbuttondown(callback: (buttonPressed: number) => void): void;
  17058. /**
  17059. * Callback triggered when a button has been released
  17060. * @param callback Called when a button has been released
  17061. */
  17062. onbuttonup(callback: (buttonReleased: number) => void): void;
  17063. /**
  17064. * Initializes the generic gamepad
  17065. * @param id The id of the generic gamepad
  17066. * @param index The index of the generic gamepad
  17067. * @param browserGamepad The browser gamepad
  17068. */
  17069. constructor(id: string, index: number, browserGamepad: any);
  17070. private _setButtonValue;
  17071. /**
  17072. * Updates the generic gamepad
  17073. */
  17074. update(): void;
  17075. /**
  17076. * Disposes the generic gamepad
  17077. */
  17078. dispose(): void;
  17079. }
  17080. }
  17081. declare module BABYLON {
  17082. /**
  17083. * Defines the types of pose enabled controllers that are supported
  17084. */
  17085. export enum PoseEnabledControllerType {
  17086. /**
  17087. * HTC Vive
  17088. */
  17089. VIVE = 0,
  17090. /**
  17091. * Oculus Rift
  17092. */
  17093. OCULUS = 1,
  17094. /**
  17095. * Windows mixed reality
  17096. */
  17097. WINDOWS = 2,
  17098. /**
  17099. * Samsung gear VR
  17100. */
  17101. GEAR_VR = 3,
  17102. /**
  17103. * Google Daydream
  17104. */
  17105. DAYDREAM = 4,
  17106. /**
  17107. * Generic
  17108. */
  17109. GENERIC = 5
  17110. }
  17111. /**
  17112. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17113. */
  17114. export interface MutableGamepadButton {
  17115. /**
  17116. * Value of the button/trigger
  17117. */
  17118. value: number;
  17119. /**
  17120. * If the button/trigger is currently touched
  17121. */
  17122. touched: boolean;
  17123. /**
  17124. * If the button/trigger is currently pressed
  17125. */
  17126. pressed: boolean;
  17127. }
  17128. /**
  17129. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17130. * @hidden
  17131. */
  17132. export interface ExtendedGamepadButton extends GamepadButton {
  17133. /**
  17134. * If the button/trigger is currently pressed
  17135. */
  17136. readonly pressed: boolean;
  17137. /**
  17138. * If the button/trigger is currently touched
  17139. */
  17140. readonly touched: boolean;
  17141. /**
  17142. * Value of the button/trigger
  17143. */
  17144. readonly value: number;
  17145. }
  17146. /** @hidden */
  17147. export interface _GamePadFactory {
  17148. /**
  17149. * Returns wether or not the current gamepad can be created for this type of controller.
  17150. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17151. * @returns true if it can be created, otherwise false
  17152. */
  17153. canCreate(gamepadInfo: any): boolean;
  17154. /**
  17155. * Creates a new instance of the Gamepad.
  17156. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17157. * @returns the new gamepad instance
  17158. */
  17159. create(gamepadInfo: any): Gamepad;
  17160. }
  17161. /**
  17162. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17163. */
  17164. export class PoseEnabledControllerHelper {
  17165. /** @hidden */
  17166. static _ControllerFactories: _GamePadFactory[];
  17167. /** @hidden */
  17168. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17169. /**
  17170. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17171. * @param vrGamepad the gamepad to initialized
  17172. * @returns a vr controller of the type the gamepad identified as
  17173. */
  17174. static InitiateController(vrGamepad: any): Gamepad;
  17175. }
  17176. /**
  17177. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17178. */
  17179. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17180. private _deviceRoomPosition;
  17181. private _deviceRoomRotationQuaternion;
  17182. /**
  17183. * The device position in babylon space
  17184. */
  17185. devicePosition: Vector3;
  17186. /**
  17187. * The device rotation in babylon space
  17188. */
  17189. deviceRotationQuaternion: Quaternion;
  17190. /**
  17191. * The scale factor of the device in babylon space
  17192. */
  17193. deviceScaleFactor: number;
  17194. /**
  17195. * (Likely devicePosition should be used instead) The device position in its room space
  17196. */
  17197. position: Vector3;
  17198. /**
  17199. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17200. */
  17201. rotationQuaternion: Quaternion;
  17202. /**
  17203. * The type of controller (Eg. Windows mixed reality)
  17204. */
  17205. controllerType: PoseEnabledControllerType;
  17206. protected _calculatedPosition: Vector3;
  17207. private _calculatedRotation;
  17208. /**
  17209. * The raw pose from the device
  17210. */
  17211. rawPose: DevicePose;
  17212. private _trackPosition;
  17213. private _maxRotationDistFromHeadset;
  17214. private _draggedRoomRotation;
  17215. /**
  17216. * @hidden
  17217. */
  17218. _disableTrackPosition(fixedPosition: Vector3): void;
  17219. /**
  17220. * Internal, the mesh attached to the controller
  17221. * @hidden
  17222. */
  17223. _mesh: Nullable<AbstractMesh>;
  17224. private _poseControlledCamera;
  17225. private _leftHandSystemQuaternion;
  17226. /**
  17227. * Internal, matrix used to convert room space to babylon space
  17228. * @hidden
  17229. */
  17230. _deviceToWorld: Matrix;
  17231. /**
  17232. * Node to be used when casting a ray from the controller
  17233. * @hidden
  17234. */
  17235. _pointingPoseNode: Nullable<TransformNode>;
  17236. /**
  17237. * Name of the child mesh that can be used to cast a ray from the controller
  17238. */
  17239. static readonly POINTING_POSE: string;
  17240. /**
  17241. * Creates a new PoseEnabledController from a gamepad
  17242. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17243. */
  17244. constructor(browserGamepad: any);
  17245. private _workingMatrix;
  17246. /**
  17247. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17248. */
  17249. update(): void;
  17250. /**
  17251. * Updates only the pose device and mesh without doing any button event checking
  17252. */
  17253. protected _updatePoseAndMesh(): void;
  17254. /**
  17255. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17256. * @param poseData raw pose fromthe device
  17257. */
  17258. updateFromDevice(poseData: DevicePose): void;
  17259. /**
  17260. * @hidden
  17261. */
  17262. _meshAttachedObservable: Observable<AbstractMesh>;
  17263. /**
  17264. * Attaches a mesh to the controller
  17265. * @param mesh the mesh to be attached
  17266. */
  17267. attachToMesh(mesh: AbstractMesh): void;
  17268. /**
  17269. * Attaches the controllers mesh to a camera
  17270. * @param camera the camera the mesh should be attached to
  17271. */
  17272. attachToPoseControlledCamera(camera: TargetCamera): void;
  17273. /**
  17274. * Disposes of the controller
  17275. */
  17276. dispose(): void;
  17277. /**
  17278. * The mesh that is attached to the controller
  17279. */
  17280. readonly mesh: Nullable<AbstractMesh>;
  17281. /**
  17282. * Gets the ray of the controller in the direction the controller is pointing
  17283. * @param length the length the resulting ray should be
  17284. * @returns a ray in the direction the controller is pointing
  17285. */
  17286. getForwardRay(length?: number): Ray;
  17287. }
  17288. }
  17289. declare module BABYLON {
  17290. /**
  17291. * Defines the WebVRController object that represents controllers tracked in 3D space
  17292. */
  17293. export abstract class WebVRController extends PoseEnabledController {
  17294. /**
  17295. * Internal, the default controller model for the controller
  17296. */
  17297. protected _defaultModel: AbstractMesh;
  17298. /**
  17299. * Fired when the trigger state has changed
  17300. */
  17301. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17302. /**
  17303. * Fired when the main button state has changed
  17304. */
  17305. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17306. /**
  17307. * Fired when the secondary button state has changed
  17308. */
  17309. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17310. /**
  17311. * Fired when the pad state has changed
  17312. */
  17313. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17314. /**
  17315. * Fired when controllers stick values have changed
  17316. */
  17317. onPadValuesChangedObservable: Observable<StickValues>;
  17318. /**
  17319. * Array of button availible on the controller
  17320. */
  17321. protected _buttons: Array<MutableGamepadButton>;
  17322. private _onButtonStateChange;
  17323. /**
  17324. * Fired when a controller button's state has changed
  17325. * @param callback the callback containing the button that was modified
  17326. */
  17327. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17328. /**
  17329. * X and Y axis corresponding to the controllers joystick
  17330. */
  17331. pad: StickValues;
  17332. /**
  17333. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17334. */
  17335. hand: string;
  17336. /**
  17337. * The default controller model for the controller
  17338. */
  17339. readonly defaultModel: AbstractMesh;
  17340. /**
  17341. * Creates a new WebVRController from a gamepad
  17342. * @param vrGamepad the gamepad that the WebVRController should be created from
  17343. */
  17344. constructor(vrGamepad: any);
  17345. /**
  17346. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17347. */
  17348. update(): void;
  17349. /**
  17350. * Function to be called when a button is modified
  17351. */
  17352. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17353. /**
  17354. * Loads a mesh and attaches it to the controller
  17355. * @param scene the scene the mesh should be added to
  17356. * @param meshLoaded callback for when the mesh has been loaded
  17357. */
  17358. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17359. private _setButtonValue;
  17360. private _changes;
  17361. private _checkChanges;
  17362. /**
  17363. * Disposes of th webVRCOntroller
  17364. */
  17365. dispose(): void;
  17366. }
  17367. }
  17368. declare module BABYLON {
  17369. /**
  17370. * The HemisphericLight simulates the ambient environment light,
  17371. * so the passed direction is the light reflection direction, not the incoming direction.
  17372. */
  17373. export class HemisphericLight extends Light {
  17374. /**
  17375. * The groundColor is the light in the opposite direction to the one specified during creation.
  17376. * 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.
  17377. */
  17378. groundColor: Color3;
  17379. /**
  17380. * The light reflection direction, not the incoming direction.
  17381. */
  17382. direction: Vector3;
  17383. /**
  17384. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17385. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17386. * The HemisphericLight can't cast shadows.
  17387. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17388. * @param name The friendly name of the light
  17389. * @param direction The direction of the light reflection
  17390. * @param scene The scene the light belongs to
  17391. */
  17392. constructor(name: string, direction: Vector3, scene: Scene);
  17393. protected _buildUniformLayout(): void;
  17394. /**
  17395. * Returns the string "HemisphericLight".
  17396. * @return The class name
  17397. */
  17398. getClassName(): string;
  17399. /**
  17400. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17401. * Returns the updated direction.
  17402. * @param target The target the direction should point to
  17403. * @return The computed direction
  17404. */
  17405. setDirectionToTarget(target: Vector3): Vector3;
  17406. /**
  17407. * Returns the shadow generator associated to the light.
  17408. * @returns Always null for hemispheric lights because it does not support shadows.
  17409. */
  17410. getShadowGenerator(): Nullable<IShadowGenerator>;
  17411. /**
  17412. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17413. * @param effect The effect to update
  17414. * @param lightIndex The index of the light in the effect to update
  17415. * @returns The hemispheric light
  17416. */
  17417. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17418. /**
  17419. * Computes the world matrix of the node
  17420. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17421. * @param useWasUpdatedFlag defines a reserved property
  17422. * @returns the world matrix
  17423. */
  17424. computeWorldMatrix(): Matrix;
  17425. /**
  17426. * Returns the integer 3.
  17427. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17428. */
  17429. getTypeID(): number;
  17430. /**
  17431. * Prepares the list of defines specific to the light type.
  17432. * @param defines the list of defines
  17433. * @param lightIndex defines the index of the light for the effect
  17434. */
  17435. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17436. }
  17437. }
  17438. declare module BABYLON {
  17439. /** @hidden */
  17440. export var vrMultiviewToSingleviewPixelShader: {
  17441. name: string;
  17442. shader: string;
  17443. };
  17444. }
  17445. declare module BABYLON {
  17446. /**
  17447. * Renders to multiple views with a single draw call
  17448. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17449. */
  17450. export class MultiviewRenderTarget extends RenderTargetTexture {
  17451. /**
  17452. * Creates a multiview render target
  17453. * @param scene scene used with the render target
  17454. * @param size the size of the render target (used for each view)
  17455. */
  17456. constructor(scene: Scene, size?: number | {
  17457. width: number;
  17458. height: number;
  17459. } | {
  17460. ratio: number;
  17461. });
  17462. /**
  17463. * @hidden
  17464. * @param faceIndex the face index, if its a cube texture
  17465. */
  17466. _bindFrameBuffer(faceIndex?: number): void;
  17467. /**
  17468. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17469. * @returns the view count
  17470. */
  17471. getViewCount(): number;
  17472. }
  17473. }
  17474. declare module BABYLON {
  17475. interface Engine {
  17476. /**
  17477. * Creates a new multiview render target
  17478. * @param width defines the width of the texture
  17479. * @param height defines the height of the texture
  17480. * @returns the created multiview texture
  17481. */
  17482. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17483. /**
  17484. * Binds a multiview framebuffer to be drawn to
  17485. * @param multiviewTexture texture to bind
  17486. */
  17487. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17488. }
  17489. interface Camera {
  17490. /**
  17491. * @hidden
  17492. * 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)
  17493. */
  17494. _useMultiviewToSingleView: boolean;
  17495. /**
  17496. * @hidden
  17497. * 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)
  17498. */
  17499. _multiviewTexture: Nullable<RenderTargetTexture>;
  17500. /**
  17501. * @hidden
  17502. * ensures the multiview texture of the camera exists and has the specified width/height
  17503. * @param width height to set on the multiview texture
  17504. * @param height width to set on the multiview texture
  17505. */
  17506. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17507. }
  17508. interface Scene {
  17509. /** @hidden */
  17510. _transformMatrixR: Matrix;
  17511. /** @hidden */
  17512. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17513. /** @hidden */
  17514. _createMultiviewUbo(): void;
  17515. /** @hidden */
  17516. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17517. /** @hidden */
  17518. _renderMultiviewToSingleView(camera: Camera): void;
  17519. }
  17520. }
  17521. declare module BABYLON {
  17522. /**
  17523. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17524. * This will not be used for webXR as it supports displaying texture arrays directly
  17525. */
  17526. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17527. /**
  17528. * Initializes a VRMultiviewToSingleview
  17529. * @param name name of the post process
  17530. * @param camera camera to be applied to
  17531. * @param scaleFactor scaling factor to the size of the output texture
  17532. */
  17533. constructor(name: string, camera: Camera, scaleFactor: number);
  17534. }
  17535. }
  17536. declare module BABYLON {
  17537. interface Engine {
  17538. /** @hidden */
  17539. _vrDisplay: any;
  17540. /** @hidden */
  17541. _vrSupported: boolean;
  17542. /** @hidden */
  17543. _oldSize: Size;
  17544. /** @hidden */
  17545. _oldHardwareScaleFactor: number;
  17546. /** @hidden */
  17547. _vrExclusivePointerMode: boolean;
  17548. /** @hidden */
  17549. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17550. /** @hidden */
  17551. _onVRDisplayPointerRestricted: () => void;
  17552. /** @hidden */
  17553. _onVRDisplayPointerUnrestricted: () => void;
  17554. /** @hidden */
  17555. _onVrDisplayConnect: Nullable<(display: any) => void>;
  17556. /** @hidden */
  17557. _onVrDisplayDisconnect: Nullable<() => void>;
  17558. /** @hidden */
  17559. _onVrDisplayPresentChange: Nullable<() => void>;
  17560. /**
  17561. * Observable signaled when VR display mode changes
  17562. */
  17563. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17564. /**
  17565. * Observable signaled when VR request present is complete
  17566. */
  17567. onVRRequestPresentComplete: Observable<boolean>;
  17568. /**
  17569. * Observable signaled when VR request present starts
  17570. */
  17571. onVRRequestPresentStart: Observable<Engine>;
  17572. /**
  17573. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17574. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17575. */
  17576. isInVRExclusivePointerMode: boolean;
  17577. /**
  17578. * Gets a boolean indicating if a webVR device was detected
  17579. * @returns true if a webVR device was detected
  17580. */
  17581. isVRDevicePresent(): boolean;
  17582. /**
  17583. * Gets the current webVR device
  17584. * @returns the current webVR device (or null)
  17585. */
  17586. getVRDevice(): any;
  17587. /**
  17588. * Initializes a webVR display and starts listening to display change events
  17589. * The onVRDisplayChangedObservable will be notified upon these changes
  17590. * @returns A promise containing a VRDisplay and if vr is supported
  17591. */
  17592. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  17593. /** @hidden */
  17594. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  17595. /**
  17596. * Call this function to switch to webVR mode
  17597. * Will do nothing if webVR is not supported or if there is no webVR device
  17598. * @see http://doc.babylonjs.com/how_to/webvr_camera
  17599. */
  17600. enableVR(): void;
  17601. /** @hidden */
  17602. _onVRFullScreenTriggered(): void;
  17603. }
  17604. }
  17605. declare module BABYLON {
  17606. /**
  17607. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  17608. * IMPORTANT!! The data is right-hand data.
  17609. * @export
  17610. * @interface DevicePose
  17611. */
  17612. export interface DevicePose {
  17613. /**
  17614. * The position of the device, values in array are [x,y,z].
  17615. */
  17616. readonly position: Nullable<Float32Array>;
  17617. /**
  17618. * The linearVelocity of the device, values in array are [x,y,z].
  17619. */
  17620. readonly linearVelocity: Nullable<Float32Array>;
  17621. /**
  17622. * The linearAcceleration of the device, values in array are [x,y,z].
  17623. */
  17624. readonly linearAcceleration: Nullable<Float32Array>;
  17625. /**
  17626. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  17627. */
  17628. readonly orientation: Nullable<Float32Array>;
  17629. /**
  17630. * The angularVelocity of the device, values in array are [x,y,z].
  17631. */
  17632. readonly angularVelocity: Nullable<Float32Array>;
  17633. /**
  17634. * The angularAcceleration of the device, values in array are [x,y,z].
  17635. */
  17636. readonly angularAcceleration: Nullable<Float32Array>;
  17637. }
  17638. /**
  17639. * Interface representing a pose controlled object in Babylon.
  17640. * A pose controlled object has both regular pose values as well as pose values
  17641. * from an external device such as a VR head mounted display
  17642. */
  17643. export interface PoseControlled {
  17644. /**
  17645. * The position of the object in babylon space.
  17646. */
  17647. position: Vector3;
  17648. /**
  17649. * The rotation quaternion of the object in babylon space.
  17650. */
  17651. rotationQuaternion: Quaternion;
  17652. /**
  17653. * The position of the device in babylon space.
  17654. */
  17655. devicePosition?: Vector3;
  17656. /**
  17657. * The rotation quaternion of the device in babylon space.
  17658. */
  17659. deviceRotationQuaternion: Quaternion;
  17660. /**
  17661. * The raw pose coming from the device.
  17662. */
  17663. rawPose: Nullable<DevicePose>;
  17664. /**
  17665. * The scale of the device to be used when translating from device space to babylon space.
  17666. */
  17667. deviceScaleFactor: number;
  17668. /**
  17669. * Updates the poseControlled values based on the input device pose.
  17670. * @param poseData the pose data to update the object with
  17671. */
  17672. updateFromDevice(poseData: DevicePose): void;
  17673. }
  17674. /**
  17675. * Set of options to customize the webVRCamera
  17676. */
  17677. export interface WebVROptions {
  17678. /**
  17679. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  17680. */
  17681. trackPosition?: boolean;
  17682. /**
  17683. * Sets the scale of the vrDevice in babylon space. (default: 1)
  17684. */
  17685. positionScale?: number;
  17686. /**
  17687. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  17688. */
  17689. displayName?: string;
  17690. /**
  17691. * Should the native controller meshes be initialized. (default: true)
  17692. */
  17693. controllerMeshes?: boolean;
  17694. /**
  17695. * Creating a default HemiLight only on controllers. (default: true)
  17696. */
  17697. defaultLightingOnControllers?: boolean;
  17698. /**
  17699. * If you don't want to use the default VR button of the helper. (default: false)
  17700. */
  17701. useCustomVRButton?: boolean;
  17702. /**
  17703. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  17704. */
  17705. customVRButton?: HTMLButtonElement;
  17706. /**
  17707. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  17708. */
  17709. rayLength?: number;
  17710. /**
  17711. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  17712. */
  17713. defaultHeight?: number;
  17714. /**
  17715. * If multiview should be used if availible (default: false)
  17716. */
  17717. useMultiview?: boolean;
  17718. }
  17719. /**
  17720. * This represents a WebVR camera.
  17721. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17722. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17723. */
  17724. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  17725. private webVROptions;
  17726. /**
  17727. * @hidden
  17728. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17729. */
  17730. _vrDevice: any;
  17731. /**
  17732. * The rawPose of the vrDevice.
  17733. */
  17734. rawPose: Nullable<DevicePose>;
  17735. private _onVREnabled;
  17736. private _specsVersion;
  17737. private _attached;
  17738. private _frameData;
  17739. protected _descendants: Array<Node>;
  17740. private _deviceRoomPosition;
  17741. /** @hidden */
  17742. _deviceRoomRotationQuaternion: Quaternion;
  17743. private _standingMatrix;
  17744. /**
  17745. * Represents device position in babylon space.
  17746. */
  17747. devicePosition: Vector3;
  17748. /**
  17749. * Represents device rotation in babylon space.
  17750. */
  17751. deviceRotationQuaternion: Quaternion;
  17752. /**
  17753. * The scale of the device to be used when translating from device space to babylon space.
  17754. */
  17755. deviceScaleFactor: number;
  17756. private _deviceToWorld;
  17757. private _worldToDevice;
  17758. /**
  17759. * References to the webVR controllers for the vrDevice.
  17760. */
  17761. controllers: Array<WebVRController>;
  17762. /**
  17763. * Emits an event when a controller is attached.
  17764. */
  17765. onControllersAttachedObservable: Observable<WebVRController[]>;
  17766. /**
  17767. * Emits an event when a controller's mesh has been loaded;
  17768. */
  17769. onControllerMeshLoadedObservable: Observable<WebVRController>;
  17770. /**
  17771. * Emits an event when the HMD's pose has been updated.
  17772. */
  17773. onPoseUpdatedFromDeviceObservable: Observable<any>;
  17774. private _poseSet;
  17775. /**
  17776. * If the rig cameras be used as parent instead of this camera.
  17777. */
  17778. rigParenting: boolean;
  17779. private _lightOnControllers;
  17780. private _defaultHeight?;
  17781. /**
  17782. * Instantiates a WebVRFreeCamera.
  17783. * @param name The name of the WebVRFreeCamera
  17784. * @param position The starting anchor position for the camera
  17785. * @param scene The scene the camera belongs to
  17786. * @param webVROptions a set of customizable options for the webVRCamera
  17787. */
  17788. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  17789. /**
  17790. * Gets the device distance from the ground in meters.
  17791. * @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.
  17792. */
  17793. deviceDistanceToRoomGround(): number;
  17794. /**
  17795. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17796. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  17797. */
  17798. useStandingMatrix(callback?: (bool: boolean) => void): void;
  17799. /**
  17800. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17801. * @returns A promise with a boolean set to if the standing matrix is supported.
  17802. */
  17803. useStandingMatrixAsync(): Promise<boolean>;
  17804. /**
  17805. * Disposes the camera
  17806. */
  17807. dispose(): void;
  17808. /**
  17809. * Gets a vrController by name.
  17810. * @param name The name of the controller to retreive
  17811. * @returns the controller matching the name specified or null if not found
  17812. */
  17813. getControllerByName(name: string): Nullable<WebVRController>;
  17814. private _leftController;
  17815. /**
  17816. * The controller corresponding to the users left hand.
  17817. */
  17818. readonly leftController: Nullable<WebVRController>;
  17819. private _rightController;
  17820. /**
  17821. * The controller corresponding to the users right hand.
  17822. */
  17823. readonly rightController: Nullable<WebVRController>;
  17824. /**
  17825. * Casts a ray forward from the vrCamera's gaze.
  17826. * @param length Length of the ray (default: 100)
  17827. * @returns the ray corresponding to the gaze
  17828. */
  17829. getForwardRay(length?: number): Ray;
  17830. /**
  17831. * @hidden
  17832. * Updates the camera based on device's frame data
  17833. */
  17834. _checkInputs(): void;
  17835. /**
  17836. * Updates the poseControlled values based on the input device pose.
  17837. * @param poseData Pose coming from the device
  17838. */
  17839. updateFromDevice(poseData: DevicePose): void;
  17840. private _htmlElementAttached;
  17841. private _detachIfAttached;
  17842. /**
  17843. * WebVR's attach control will start broadcasting frames to the device.
  17844. * Note that in certain browsers (chrome for example) this function must be called
  17845. * within a user-interaction callback. Example:
  17846. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  17847. *
  17848. * @param element html element to attach the vrDevice to
  17849. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  17850. */
  17851. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17852. /**
  17853. * Detaches the camera from the html element and disables VR
  17854. *
  17855. * @param element html element to detach from
  17856. */
  17857. detachControl(element: HTMLElement): void;
  17858. /**
  17859. * @returns the name of this class
  17860. */
  17861. getClassName(): string;
  17862. /**
  17863. * Calls resetPose on the vrDisplay
  17864. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  17865. */
  17866. resetToCurrentRotation(): void;
  17867. /**
  17868. * @hidden
  17869. * Updates the rig cameras (left and right eye)
  17870. */
  17871. _updateRigCameras(): void;
  17872. private _workingVector;
  17873. private _oneVector;
  17874. private _workingMatrix;
  17875. private updateCacheCalled;
  17876. private _correctPositionIfNotTrackPosition;
  17877. /**
  17878. * @hidden
  17879. * Updates the cached values of the camera
  17880. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  17881. */
  17882. _updateCache(ignoreParentClass?: boolean): void;
  17883. /**
  17884. * @hidden
  17885. * Get current device position in babylon world
  17886. */
  17887. _computeDevicePosition(): void;
  17888. /**
  17889. * Updates the current device position and rotation in the babylon world
  17890. */
  17891. update(): void;
  17892. /**
  17893. * @hidden
  17894. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  17895. * @returns an identity matrix
  17896. */
  17897. _getViewMatrix(): Matrix;
  17898. private _tmpMatrix;
  17899. /**
  17900. * This function is called by the two RIG cameras.
  17901. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  17902. * @hidden
  17903. */
  17904. _getWebVRViewMatrix(): Matrix;
  17905. /** @hidden */
  17906. _getWebVRProjectionMatrix(): Matrix;
  17907. private _onGamepadConnectedObserver;
  17908. private _onGamepadDisconnectedObserver;
  17909. private _updateCacheWhenTrackingDisabledObserver;
  17910. /**
  17911. * Initializes the controllers and their meshes
  17912. */
  17913. initControllers(): void;
  17914. }
  17915. }
  17916. declare module BABYLON {
  17917. /**
  17918. * Size options for a post process
  17919. */
  17920. export type PostProcessOptions = {
  17921. width: number;
  17922. height: number;
  17923. };
  17924. /**
  17925. * PostProcess can be used to apply a shader to a texture after it has been rendered
  17926. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  17927. */
  17928. export class PostProcess {
  17929. /** Name of the PostProcess. */
  17930. name: string;
  17931. /**
  17932. * Gets or sets the unique id of the post process
  17933. */
  17934. uniqueId: number;
  17935. /**
  17936. * Width of the texture to apply the post process on
  17937. */
  17938. width: number;
  17939. /**
  17940. * Height of the texture to apply the post process on
  17941. */
  17942. height: number;
  17943. /**
  17944. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  17945. * @hidden
  17946. */
  17947. _outputTexture: Nullable<InternalTexture>;
  17948. /**
  17949. * Sampling mode used by the shader
  17950. * See https://doc.babylonjs.com/classes/3.1/texture
  17951. */
  17952. renderTargetSamplingMode: number;
  17953. /**
  17954. * Clear color to use when screen clearing
  17955. */
  17956. clearColor: Color4;
  17957. /**
  17958. * If the buffer needs to be cleared before applying the post process. (default: true)
  17959. * Should be set to false if shader will overwrite all previous pixels.
  17960. */
  17961. autoClear: boolean;
  17962. /**
  17963. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  17964. */
  17965. alphaMode: number;
  17966. /**
  17967. * Sets the setAlphaBlendConstants of the babylon engine
  17968. */
  17969. alphaConstants: Color4;
  17970. /**
  17971. * Animations to be used for the post processing
  17972. */
  17973. animations: Animation[];
  17974. /**
  17975. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  17976. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  17977. */
  17978. enablePixelPerfectMode: boolean;
  17979. /**
  17980. * Force the postprocess to be applied without taking in account viewport
  17981. */
  17982. forceFullscreenViewport: boolean;
  17983. /**
  17984. * List of inspectable custom properties (used by the Inspector)
  17985. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17986. */
  17987. inspectableCustomProperties: IInspectable[];
  17988. /**
  17989. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  17990. *
  17991. * | Value | Type | Description |
  17992. * | ----- | ----------------------------------- | ----------- |
  17993. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  17994. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  17995. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  17996. *
  17997. */
  17998. scaleMode: number;
  17999. /**
  18000. * Force textures to be a power of two (default: false)
  18001. */
  18002. alwaysForcePOT: boolean;
  18003. private _samples;
  18004. /**
  18005. * Number of sample textures (default: 1)
  18006. */
  18007. samples: number;
  18008. /**
  18009. * Modify the scale of the post process to be the same as the viewport (default: false)
  18010. */
  18011. adaptScaleToCurrentViewport: boolean;
  18012. private _camera;
  18013. private _scene;
  18014. private _engine;
  18015. private _options;
  18016. private _reusable;
  18017. private _textureType;
  18018. /**
  18019. * Smart array of input and output textures for the post process.
  18020. * @hidden
  18021. */
  18022. _textures: SmartArray<InternalTexture>;
  18023. /**
  18024. * The index in _textures that corresponds to the output texture.
  18025. * @hidden
  18026. */
  18027. _currentRenderTextureInd: number;
  18028. private _effect;
  18029. private _samplers;
  18030. private _fragmentUrl;
  18031. private _vertexUrl;
  18032. private _parameters;
  18033. private _scaleRatio;
  18034. protected _indexParameters: any;
  18035. private _shareOutputWithPostProcess;
  18036. private _texelSize;
  18037. private _forcedOutputTexture;
  18038. /**
  18039. * Returns the fragment url or shader name used in the post process.
  18040. * @returns the fragment url or name in the shader store.
  18041. */
  18042. getEffectName(): string;
  18043. /**
  18044. * An event triggered when the postprocess is activated.
  18045. */
  18046. onActivateObservable: Observable<Camera>;
  18047. private _onActivateObserver;
  18048. /**
  18049. * A function that is added to the onActivateObservable
  18050. */
  18051. onActivate: Nullable<(camera: Camera) => void>;
  18052. /**
  18053. * An event triggered when the postprocess changes its size.
  18054. */
  18055. onSizeChangedObservable: Observable<PostProcess>;
  18056. private _onSizeChangedObserver;
  18057. /**
  18058. * A function that is added to the onSizeChangedObservable
  18059. */
  18060. onSizeChanged: (postProcess: PostProcess) => void;
  18061. /**
  18062. * An event triggered when the postprocess applies its effect.
  18063. */
  18064. onApplyObservable: Observable<Effect>;
  18065. private _onApplyObserver;
  18066. /**
  18067. * A function that is added to the onApplyObservable
  18068. */
  18069. onApply: (effect: Effect) => void;
  18070. /**
  18071. * An event triggered before rendering the postprocess
  18072. */
  18073. onBeforeRenderObservable: Observable<Effect>;
  18074. private _onBeforeRenderObserver;
  18075. /**
  18076. * A function that is added to the onBeforeRenderObservable
  18077. */
  18078. onBeforeRender: (effect: Effect) => void;
  18079. /**
  18080. * An event triggered after rendering the postprocess
  18081. */
  18082. onAfterRenderObservable: Observable<Effect>;
  18083. private _onAfterRenderObserver;
  18084. /**
  18085. * A function that is added to the onAfterRenderObservable
  18086. */
  18087. onAfterRender: (efect: Effect) => void;
  18088. /**
  18089. * 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
  18090. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18091. */
  18092. inputTexture: InternalTexture;
  18093. /**
  18094. * Gets the camera which post process is applied to.
  18095. * @returns The camera the post process is applied to.
  18096. */
  18097. getCamera(): Camera;
  18098. /**
  18099. * Gets the texel size of the postprocess.
  18100. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18101. */
  18102. readonly texelSize: Vector2;
  18103. /**
  18104. * Creates a new instance PostProcess
  18105. * @param name The name of the PostProcess.
  18106. * @param fragmentUrl The url of the fragment shader to be used.
  18107. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18108. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18109. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18110. * @param camera The camera to apply the render pass to.
  18111. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18112. * @param engine The engine which the post process will be applied. (default: current engine)
  18113. * @param reusable If the post process can be reused on the same frame. (default: false)
  18114. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18115. * @param textureType Type of textures used when performing the post process. (default: 0)
  18116. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18117. * @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
  18118. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18119. */
  18120. constructor(
  18121. /** Name of the PostProcess. */
  18122. 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);
  18123. /**
  18124. * Gets a string idenfifying the name of the class
  18125. * @returns "PostProcess" string
  18126. */
  18127. getClassName(): string;
  18128. /**
  18129. * Gets the engine which this post process belongs to.
  18130. * @returns The engine the post process was enabled with.
  18131. */
  18132. getEngine(): Engine;
  18133. /**
  18134. * The effect that is created when initializing the post process.
  18135. * @returns The created effect corresponding the the postprocess.
  18136. */
  18137. getEffect(): Effect;
  18138. /**
  18139. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18140. * @param postProcess The post process to share the output with.
  18141. * @returns This post process.
  18142. */
  18143. shareOutputWith(postProcess: PostProcess): PostProcess;
  18144. /**
  18145. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18146. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18147. */
  18148. useOwnOutput(): void;
  18149. /**
  18150. * Updates the effect with the current post process compile time values and recompiles the shader.
  18151. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18152. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18153. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18154. * @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
  18155. * @param onCompiled Called when the shader has been compiled.
  18156. * @param onError Called if there is an error when compiling a shader.
  18157. */
  18158. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18159. /**
  18160. * The post process is reusable if it can be used multiple times within one frame.
  18161. * @returns If the post process is reusable
  18162. */
  18163. isReusable(): boolean;
  18164. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18165. markTextureDirty(): void;
  18166. /**
  18167. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18168. * 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.
  18169. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18170. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18171. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18172. * @returns The target texture that was bound to be written to.
  18173. */
  18174. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18175. /**
  18176. * If the post process is supported.
  18177. */
  18178. readonly isSupported: boolean;
  18179. /**
  18180. * The aspect ratio of the output texture.
  18181. */
  18182. readonly aspectRatio: number;
  18183. /**
  18184. * Get a value indicating if the post-process is ready to be used
  18185. * @returns true if the post-process is ready (shader is compiled)
  18186. */
  18187. isReady(): boolean;
  18188. /**
  18189. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18190. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18191. */
  18192. apply(): Nullable<Effect>;
  18193. private _disposeTextures;
  18194. /**
  18195. * Disposes the post process.
  18196. * @param camera The camera to dispose the post process on.
  18197. */
  18198. dispose(camera?: Camera): void;
  18199. }
  18200. }
  18201. declare module BABYLON {
  18202. /** @hidden */
  18203. export var kernelBlurVaryingDeclaration: {
  18204. name: string;
  18205. shader: string;
  18206. };
  18207. }
  18208. declare module BABYLON {
  18209. /** @hidden */
  18210. export var kernelBlurFragment: {
  18211. name: string;
  18212. shader: string;
  18213. };
  18214. }
  18215. declare module BABYLON {
  18216. /** @hidden */
  18217. export var kernelBlurFragment2: {
  18218. name: string;
  18219. shader: string;
  18220. };
  18221. }
  18222. declare module BABYLON {
  18223. /** @hidden */
  18224. export var kernelBlurPixelShader: {
  18225. name: string;
  18226. shader: string;
  18227. };
  18228. }
  18229. declare module BABYLON {
  18230. /** @hidden */
  18231. export var kernelBlurVertex: {
  18232. name: string;
  18233. shader: string;
  18234. };
  18235. }
  18236. declare module BABYLON {
  18237. /** @hidden */
  18238. export var kernelBlurVertexShader: {
  18239. name: string;
  18240. shader: string;
  18241. };
  18242. }
  18243. declare module BABYLON {
  18244. /**
  18245. * The Blur Post Process which blurs an image based on a kernel and direction.
  18246. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18247. */
  18248. export class BlurPostProcess extends PostProcess {
  18249. /** The direction in which to blur the image. */
  18250. direction: Vector2;
  18251. private blockCompilation;
  18252. protected _kernel: number;
  18253. protected _idealKernel: number;
  18254. protected _packedFloat: boolean;
  18255. private _staticDefines;
  18256. /**
  18257. * Sets the length in pixels of the blur sample region
  18258. */
  18259. /**
  18260. * Gets the length in pixels of the blur sample region
  18261. */
  18262. kernel: number;
  18263. /**
  18264. * Sets wether or not the blur needs to unpack/repack floats
  18265. */
  18266. /**
  18267. * Gets wether or not the blur is unpacking/repacking floats
  18268. */
  18269. packedFloat: boolean;
  18270. /**
  18271. * Creates a new instance BlurPostProcess
  18272. * @param name The name of the effect.
  18273. * @param direction The direction in which to blur the image.
  18274. * @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.
  18275. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18276. * @param camera The camera to apply the render pass to.
  18277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18278. * @param engine The engine which the post process will be applied. (default: current engine)
  18279. * @param reusable If the post process can be reused on the same frame. (default: false)
  18280. * @param textureType Type of textures used when performing the post process. (default: 0)
  18281. * @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)
  18282. */
  18283. constructor(name: string,
  18284. /** The direction in which to blur the image. */
  18285. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18286. /**
  18287. * Updates the effect with the current post process compile time values and recompiles the shader.
  18288. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18289. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18290. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18291. * @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
  18292. * @param onCompiled Called when the shader has been compiled.
  18293. * @param onError Called if there is an error when compiling a shader.
  18294. */
  18295. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18296. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18297. /**
  18298. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18299. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18300. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18301. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18302. * The gaps between physical kernels are compensated for in the weighting of the samples
  18303. * @param idealKernel Ideal blur kernel.
  18304. * @return Nearest best kernel.
  18305. */
  18306. protected _nearestBestKernel(idealKernel: number): number;
  18307. /**
  18308. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18309. * @param x The point on the Gaussian distribution to sample.
  18310. * @return the value of the Gaussian function at x.
  18311. */
  18312. protected _gaussianWeight(x: number): number;
  18313. /**
  18314. * Generates a string that can be used as a floating point number in GLSL.
  18315. * @param x Value to print.
  18316. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18317. * @return GLSL float string.
  18318. */
  18319. protected _glslFloat(x: number, decimalFigures?: number): string;
  18320. }
  18321. }
  18322. declare module BABYLON {
  18323. /**
  18324. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18325. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18326. * You can then easily use it as a reflectionTexture on a flat surface.
  18327. * In case the surface is not a plane, please consider relying on reflection probes.
  18328. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18329. */
  18330. export class MirrorTexture extends RenderTargetTexture {
  18331. private scene;
  18332. /**
  18333. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18334. * 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.
  18335. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18336. */
  18337. mirrorPlane: Plane;
  18338. /**
  18339. * Define the blur ratio used to blur the reflection if needed.
  18340. */
  18341. blurRatio: number;
  18342. /**
  18343. * Define the adaptive blur kernel used to blur the reflection if needed.
  18344. * This will autocompute the closest best match for the `blurKernel`
  18345. */
  18346. adaptiveBlurKernel: number;
  18347. /**
  18348. * Define the blur kernel used to blur the reflection if needed.
  18349. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18350. */
  18351. blurKernel: number;
  18352. /**
  18353. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18354. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18355. */
  18356. blurKernelX: number;
  18357. /**
  18358. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18359. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18360. */
  18361. blurKernelY: number;
  18362. private _autoComputeBlurKernel;
  18363. protected _onRatioRescale(): void;
  18364. private _updateGammaSpace;
  18365. private _imageProcessingConfigChangeObserver;
  18366. private _transformMatrix;
  18367. private _mirrorMatrix;
  18368. private _savedViewMatrix;
  18369. private _blurX;
  18370. private _blurY;
  18371. private _adaptiveBlurKernel;
  18372. private _blurKernelX;
  18373. private _blurKernelY;
  18374. private _blurRatio;
  18375. /**
  18376. * Instantiates a Mirror Texture.
  18377. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18378. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18379. * You can then easily use it as a reflectionTexture on a flat surface.
  18380. * In case the surface is not a plane, please consider relying on reflection probes.
  18381. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18382. * @param name
  18383. * @param size
  18384. * @param scene
  18385. * @param generateMipMaps
  18386. * @param type
  18387. * @param samplingMode
  18388. * @param generateDepthBuffer
  18389. */
  18390. constructor(name: string, size: number | {
  18391. width: number;
  18392. height: number;
  18393. } | {
  18394. ratio: number;
  18395. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18396. private _preparePostProcesses;
  18397. /**
  18398. * Clone the mirror texture.
  18399. * @returns the cloned texture
  18400. */
  18401. clone(): MirrorTexture;
  18402. /**
  18403. * Serialize the texture to a JSON representation you could use in Parse later on
  18404. * @returns the serialized JSON representation
  18405. */
  18406. serialize(): any;
  18407. /**
  18408. * Dispose the texture and release its associated resources.
  18409. */
  18410. dispose(): void;
  18411. }
  18412. }
  18413. declare module BABYLON {
  18414. /**
  18415. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18416. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18417. */
  18418. export class Texture extends BaseTexture {
  18419. /** @hidden */
  18420. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18421. /** @hidden */
  18422. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18423. /** @hidden */
  18424. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18425. /** nearest is mag = nearest and min = nearest and mip = linear */
  18426. static readonly NEAREST_SAMPLINGMODE: number;
  18427. /** nearest is mag = nearest and min = nearest and mip = linear */
  18428. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18429. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18430. static readonly BILINEAR_SAMPLINGMODE: number;
  18431. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18432. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18433. /** Trilinear is mag = linear and min = linear and mip = linear */
  18434. static readonly TRILINEAR_SAMPLINGMODE: number;
  18435. /** Trilinear is mag = linear and min = linear and mip = linear */
  18436. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18437. /** mag = nearest and min = nearest and mip = nearest */
  18438. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18439. /** mag = nearest and min = linear and mip = nearest */
  18440. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18441. /** mag = nearest and min = linear and mip = linear */
  18442. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18443. /** mag = nearest and min = linear and mip = none */
  18444. static readonly NEAREST_LINEAR: number;
  18445. /** mag = nearest and min = nearest and mip = none */
  18446. static readonly NEAREST_NEAREST: number;
  18447. /** mag = linear and min = nearest and mip = nearest */
  18448. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18449. /** mag = linear and min = nearest and mip = linear */
  18450. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18451. /** mag = linear and min = linear and mip = none */
  18452. static readonly LINEAR_LINEAR: number;
  18453. /** mag = linear and min = nearest and mip = none */
  18454. static readonly LINEAR_NEAREST: number;
  18455. /** Explicit coordinates mode */
  18456. static readonly EXPLICIT_MODE: number;
  18457. /** Spherical coordinates mode */
  18458. static readonly SPHERICAL_MODE: number;
  18459. /** Planar coordinates mode */
  18460. static readonly PLANAR_MODE: number;
  18461. /** Cubic coordinates mode */
  18462. static readonly CUBIC_MODE: number;
  18463. /** Projection coordinates mode */
  18464. static readonly PROJECTION_MODE: number;
  18465. /** Inverse Cubic coordinates mode */
  18466. static readonly SKYBOX_MODE: number;
  18467. /** Inverse Cubic coordinates mode */
  18468. static readonly INVCUBIC_MODE: number;
  18469. /** Equirectangular coordinates mode */
  18470. static readonly EQUIRECTANGULAR_MODE: number;
  18471. /** Equirectangular Fixed coordinates mode */
  18472. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18473. /** Equirectangular Fixed Mirrored coordinates mode */
  18474. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18475. /** Texture is not repeating outside of 0..1 UVs */
  18476. static readonly CLAMP_ADDRESSMODE: number;
  18477. /** Texture is repeating outside of 0..1 UVs */
  18478. static readonly WRAP_ADDRESSMODE: number;
  18479. /** Texture is repeating and mirrored */
  18480. static readonly MIRROR_ADDRESSMODE: number;
  18481. /**
  18482. * 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
  18483. */
  18484. static UseSerializedUrlIfAny: boolean;
  18485. /**
  18486. * Define the url of the texture.
  18487. */
  18488. url: Nullable<string>;
  18489. /**
  18490. * Define an offset on the texture to offset the u coordinates of the UVs
  18491. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18492. */
  18493. uOffset: number;
  18494. /**
  18495. * Define an offset on the texture to offset the v coordinates of the UVs
  18496. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18497. */
  18498. vOffset: number;
  18499. /**
  18500. * Define an offset on the texture to scale the u coordinates of the UVs
  18501. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18502. */
  18503. uScale: number;
  18504. /**
  18505. * Define an offset on the texture to scale the v coordinates of the UVs
  18506. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18507. */
  18508. vScale: number;
  18509. /**
  18510. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18511. * @see http://doc.babylonjs.com/how_to/more_materials
  18512. */
  18513. uAng: number;
  18514. /**
  18515. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18516. * @see http://doc.babylonjs.com/how_to/more_materials
  18517. */
  18518. vAng: number;
  18519. /**
  18520. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18521. * @see http://doc.babylonjs.com/how_to/more_materials
  18522. */
  18523. wAng: number;
  18524. /**
  18525. * Defines the center of rotation (U)
  18526. */
  18527. uRotationCenter: number;
  18528. /**
  18529. * Defines the center of rotation (V)
  18530. */
  18531. vRotationCenter: number;
  18532. /**
  18533. * Defines the center of rotation (W)
  18534. */
  18535. wRotationCenter: number;
  18536. /**
  18537. * Are mip maps generated for this texture or not.
  18538. */
  18539. readonly noMipmap: boolean;
  18540. /**
  18541. * List of inspectable custom properties (used by the Inspector)
  18542. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18543. */
  18544. inspectableCustomProperties: Nullable<IInspectable[]>;
  18545. private _noMipmap;
  18546. /** @hidden */
  18547. _invertY: boolean;
  18548. private _rowGenerationMatrix;
  18549. private _cachedTextureMatrix;
  18550. private _projectionModeMatrix;
  18551. private _t0;
  18552. private _t1;
  18553. private _t2;
  18554. private _cachedUOffset;
  18555. private _cachedVOffset;
  18556. private _cachedUScale;
  18557. private _cachedVScale;
  18558. private _cachedUAng;
  18559. private _cachedVAng;
  18560. private _cachedWAng;
  18561. private _cachedProjectionMatrixId;
  18562. private _cachedCoordinatesMode;
  18563. /** @hidden */
  18564. protected _initialSamplingMode: number;
  18565. /** @hidden */
  18566. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18567. private _deleteBuffer;
  18568. protected _format: Nullable<number>;
  18569. private _delayedOnLoad;
  18570. private _delayedOnError;
  18571. /**
  18572. * Observable triggered once the texture has been loaded.
  18573. */
  18574. onLoadObservable: Observable<Texture>;
  18575. protected _isBlocking: boolean;
  18576. /**
  18577. * Is the texture preventing material to render while loading.
  18578. * If false, a default texture will be used instead of the loading one during the preparation step.
  18579. */
  18580. isBlocking: boolean;
  18581. /**
  18582. * Get the current sampling mode associated with the texture.
  18583. */
  18584. readonly samplingMode: number;
  18585. /**
  18586. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18587. */
  18588. readonly invertY: boolean;
  18589. /**
  18590. * Instantiates a new texture.
  18591. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18592. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18593. * @param url define the url of the picture to load as a texture
  18594. * @param scene define the scene the texture will belong to
  18595. * @param noMipmap define if the texture will require mip maps or not
  18596. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18597. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18598. * @param onLoad define a callback triggered when the texture has been loaded
  18599. * @param onError define a callback triggered when an error occurred during the loading session
  18600. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18601. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18602. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18603. */
  18604. constructor(url: Nullable<string>, scene: Nullable<Scene>, 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);
  18605. /**
  18606. * Update the url (and optional buffer) of this texture if url was null during construction.
  18607. * @param url the url of the texture
  18608. * @param buffer the buffer of the texture (defaults to null)
  18609. * @param onLoad callback called when the texture is loaded (defaults to null)
  18610. */
  18611. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18612. /**
  18613. * Finish the loading sequence of a texture flagged as delayed load.
  18614. * @hidden
  18615. */
  18616. delayLoad(): void;
  18617. private _prepareRowForTextureGeneration;
  18618. /**
  18619. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18620. * @returns the transform matrix of the texture.
  18621. */
  18622. getTextureMatrix(): Matrix;
  18623. /**
  18624. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18625. * @returns The reflection texture transform
  18626. */
  18627. getReflectionTextureMatrix(): Matrix;
  18628. /**
  18629. * Clones the texture.
  18630. * @returns the cloned texture
  18631. */
  18632. clone(): Texture;
  18633. /**
  18634. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18635. * @returns The JSON representation of the texture
  18636. */
  18637. serialize(): any;
  18638. /**
  18639. * Get the current class name of the texture useful for serialization or dynamic coding.
  18640. * @returns "Texture"
  18641. */
  18642. getClassName(): string;
  18643. /**
  18644. * Dispose the texture and release its associated resources.
  18645. */
  18646. dispose(): void;
  18647. /**
  18648. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18649. * @param parsedTexture Define the JSON representation of the texture
  18650. * @param scene Define the scene the parsed texture should be instantiated in
  18651. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18652. * @returns The parsed texture if successful
  18653. */
  18654. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18655. /**
  18656. * Creates a texture from its base 64 representation.
  18657. * @param data Define the base64 payload without the data: prefix
  18658. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18659. * @param scene Define the scene the texture should belong to
  18660. * @param noMipmap Forces the texture to not create mip map information if true
  18661. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18662. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18663. * @param onLoad define a callback triggered when the texture has been loaded
  18664. * @param onError define a callback triggered when an error occurred during the loading session
  18665. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18666. * @returns the created texture
  18667. */
  18668. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18669. /**
  18670. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18671. * @param data Define the base64 payload without the data: prefix
  18672. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18673. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18674. * @param scene Define the scene the texture should belong to
  18675. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18676. * @param noMipmap Forces the texture to not create mip map information if true
  18677. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18678. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18679. * @param onLoad define a callback triggered when the texture has been loaded
  18680. * @param onError define a callback triggered when an error occurred during the loading session
  18681. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18682. * @returns the created texture
  18683. */
  18684. 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;
  18685. }
  18686. }
  18687. declare module BABYLON {
  18688. /**
  18689. * PostProcessManager is used to manage one or more post processes or post process pipelines
  18690. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18691. */
  18692. export class PostProcessManager {
  18693. private _scene;
  18694. private _indexBuffer;
  18695. private _vertexBuffers;
  18696. /**
  18697. * Creates a new instance PostProcess
  18698. * @param scene The scene that the post process is associated with.
  18699. */
  18700. constructor(scene: Scene);
  18701. private _prepareBuffers;
  18702. private _buildIndexBuffer;
  18703. /**
  18704. * Rebuilds the vertex buffers of the manager.
  18705. * @hidden
  18706. */
  18707. _rebuild(): void;
  18708. /**
  18709. * Prepares a frame to be run through a post process.
  18710. * @param sourceTexture The input texture to the post procesess. (default: null)
  18711. * @param postProcesses An array of post processes to be run. (default: null)
  18712. * @returns True if the post processes were able to be run.
  18713. * @hidden
  18714. */
  18715. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  18716. /**
  18717. * Manually render a set of post processes to a texture.
  18718. * @param postProcesses An array of post processes to be run.
  18719. * @param targetTexture The target texture to render to.
  18720. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  18721. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  18722. * @param lodLevel defines which lod of the texture to render to
  18723. */
  18724. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  18725. /**
  18726. * Finalize the result of the output of the postprocesses.
  18727. * @param doNotPresent If true the result will not be displayed to the screen.
  18728. * @param targetTexture The target texture to render to.
  18729. * @param faceIndex The index of the face to bind the target texture to.
  18730. * @param postProcesses The array of post processes to render.
  18731. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  18732. * @hidden
  18733. */
  18734. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  18735. /**
  18736. * Disposes of the post process manager.
  18737. */
  18738. dispose(): void;
  18739. }
  18740. }
  18741. declare module BABYLON {
  18742. interface AbstractScene {
  18743. /**
  18744. * The list of procedural textures added to the scene
  18745. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18746. */
  18747. proceduralTextures: Array<ProceduralTexture>;
  18748. }
  18749. /**
  18750. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  18751. * in a given scene.
  18752. */
  18753. export class ProceduralTextureSceneComponent implements ISceneComponent {
  18754. /**
  18755. * The component name helpfull to identify the component in the list of scene components.
  18756. */
  18757. readonly name: string;
  18758. /**
  18759. * The scene the component belongs to.
  18760. */
  18761. scene: Scene;
  18762. /**
  18763. * Creates a new instance of the component for the given scene
  18764. * @param scene Defines the scene to register the component in
  18765. */
  18766. constructor(scene: Scene);
  18767. /**
  18768. * Registers the component in a given scene
  18769. */
  18770. register(): void;
  18771. /**
  18772. * Rebuilds the elements related to this component in case of
  18773. * context lost for instance.
  18774. */
  18775. rebuild(): void;
  18776. /**
  18777. * Disposes the component and the associated ressources.
  18778. */
  18779. dispose(): void;
  18780. private _beforeClear;
  18781. }
  18782. }
  18783. declare module BABYLON {
  18784. interface Engine {
  18785. /**
  18786. * Creates a new render target cube texture
  18787. * @param size defines the size of the texture
  18788. * @param options defines the options used to create the texture
  18789. * @returns a new render target cube texture stored in an InternalTexture
  18790. */
  18791. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  18792. }
  18793. }
  18794. declare module BABYLON {
  18795. /** @hidden */
  18796. export var proceduralVertexShader: {
  18797. name: string;
  18798. shader: string;
  18799. };
  18800. }
  18801. declare module BABYLON {
  18802. /**
  18803. * 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.
  18804. * This is the base class of any Procedural texture and contains most of the shareable code.
  18805. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18806. */
  18807. export class ProceduralTexture extends Texture {
  18808. isCube: boolean;
  18809. /**
  18810. * Define if the texture is enabled or not (disabled texture will not render)
  18811. */
  18812. isEnabled: boolean;
  18813. /**
  18814. * Define if the texture must be cleared before rendering (default is true)
  18815. */
  18816. autoClear: boolean;
  18817. /**
  18818. * Callback called when the texture is generated
  18819. */
  18820. onGenerated: () => void;
  18821. /**
  18822. * Event raised when the texture is generated
  18823. */
  18824. onGeneratedObservable: Observable<ProceduralTexture>;
  18825. /** @hidden */
  18826. _generateMipMaps: boolean;
  18827. /** @hidden **/
  18828. _effect: Effect;
  18829. /** @hidden */
  18830. _textures: {
  18831. [key: string]: Texture;
  18832. };
  18833. private _size;
  18834. private _currentRefreshId;
  18835. private _refreshRate;
  18836. private _vertexBuffers;
  18837. private _indexBuffer;
  18838. private _uniforms;
  18839. private _samplers;
  18840. private _fragment;
  18841. private _floats;
  18842. private _ints;
  18843. private _floatsArrays;
  18844. private _colors3;
  18845. private _colors4;
  18846. private _vectors2;
  18847. private _vectors3;
  18848. private _matrices;
  18849. private _fallbackTexture;
  18850. private _fallbackTextureUsed;
  18851. private _engine;
  18852. private _cachedDefines;
  18853. private _contentUpdateId;
  18854. private _contentData;
  18855. /**
  18856. * Instantiates a new procedural texture.
  18857. * 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.
  18858. * This is the base class of any Procedural texture and contains most of the shareable code.
  18859. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18860. * @param name Define the name of the texture
  18861. * @param size Define the size of the texture to create
  18862. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  18863. * @param scene Define the scene the texture belongs to
  18864. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  18865. * @param generateMipMaps Define if the texture should creates mip maps or not
  18866. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  18867. */
  18868. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  18869. /**
  18870. * The effect that is created when initializing the post process.
  18871. * @returns The created effect corresponding the the postprocess.
  18872. */
  18873. getEffect(): Effect;
  18874. /**
  18875. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  18876. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  18877. */
  18878. getContent(): Nullable<ArrayBufferView>;
  18879. private _createIndexBuffer;
  18880. /** @hidden */
  18881. _rebuild(): void;
  18882. /**
  18883. * Resets the texture in order to recreate its associated resources.
  18884. * This can be called in case of context loss
  18885. */
  18886. reset(): void;
  18887. protected _getDefines(): string;
  18888. /**
  18889. * Is the texture ready to be used ? (rendered at least once)
  18890. * @returns true if ready, otherwise, false.
  18891. */
  18892. isReady(): boolean;
  18893. /**
  18894. * Resets the refresh counter of the texture and start bak from scratch.
  18895. * Could be useful to regenerate the texture if it is setup to render only once.
  18896. */
  18897. resetRefreshCounter(): void;
  18898. /**
  18899. * Set the fragment shader to use in order to render the texture.
  18900. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  18901. */
  18902. setFragment(fragment: any): void;
  18903. /**
  18904. * Define the refresh rate of the texture or the rendering frequency.
  18905. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18906. */
  18907. refreshRate: number;
  18908. /** @hidden */
  18909. _shouldRender(): boolean;
  18910. /**
  18911. * Get the size the texture is rendering at.
  18912. * @returns the size (texture is always squared)
  18913. */
  18914. getRenderSize(): number;
  18915. /**
  18916. * Resize the texture to new value.
  18917. * @param size Define the new size the texture should have
  18918. * @param generateMipMaps Define whether the new texture should create mip maps
  18919. */
  18920. resize(size: number, generateMipMaps: boolean): void;
  18921. private _checkUniform;
  18922. /**
  18923. * Set a texture in the shader program used to render.
  18924. * @param name Define the name of the uniform samplers as defined in the shader
  18925. * @param texture Define the texture to bind to this sampler
  18926. * @return the texture itself allowing "fluent" like uniform updates
  18927. */
  18928. setTexture(name: string, texture: Texture): ProceduralTexture;
  18929. /**
  18930. * Set a float in the shader.
  18931. * @param name Define the name of the uniform as defined in the shader
  18932. * @param value Define the value to give to the uniform
  18933. * @return the texture itself allowing "fluent" like uniform updates
  18934. */
  18935. setFloat(name: string, value: number): ProceduralTexture;
  18936. /**
  18937. * Set a int in the shader.
  18938. * @param name Define the name of the uniform as defined in the shader
  18939. * @param value Define the value to give to the uniform
  18940. * @return the texture itself allowing "fluent" like uniform updates
  18941. */
  18942. setInt(name: string, value: number): ProceduralTexture;
  18943. /**
  18944. * Set an array of floats in the shader.
  18945. * @param name Define the name of the uniform as defined in the shader
  18946. * @param value Define the value to give to the uniform
  18947. * @return the texture itself allowing "fluent" like uniform updates
  18948. */
  18949. setFloats(name: string, value: number[]): ProceduralTexture;
  18950. /**
  18951. * Set a vec3 in the shader from a Color3.
  18952. * @param name Define the name of the uniform as defined in the shader
  18953. * @param value Define the value to give to the uniform
  18954. * @return the texture itself allowing "fluent" like uniform updates
  18955. */
  18956. setColor3(name: string, value: Color3): ProceduralTexture;
  18957. /**
  18958. * Set a vec4 in the shader from a Color4.
  18959. * @param name Define the name of the uniform as defined in the shader
  18960. * @param value Define the value to give to the uniform
  18961. * @return the texture itself allowing "fluent" like uniform updates
  18962. */
  18963. setColor4(name: string, value: Color4): ProceduralTexture;
  18964. /**
  18965. * Set a vec2 in the shader from a Vector2.
  18966. * @param name Define the name of the uniform as defined in the shader
  18967. * @param value Define the value to give to the uniform
  18968. * @return the texture itself allowing "fluent" like uniform updates
  18969. */
  18970. setVector2(name: string, value: Vector2): ProceduralTexture;
  18971. /**
  18972. * Set a vec3 in the shader from a Vector3.
  18973. * @param name Define the name of the uniform as defined in the shader
  18974. * @param value Define the value to give to the uniform
  18975. * @return the texture itself allowing "fluent" like uniform updates
  18976. */
  18977. setVector3(name: string, value: Vector3): ProceduralTexture;
  18978. /**
  18979. * Set a mat4 in the shader from a MAtrix.
  18980. * @param name Define the name of the uniform as defined in the shader
  18981. * @param value Define the value to give to the uniform
  18982. * @return the texture itself allowing "fluent" like uniform updates
  18983. */
  18984. setMatrix(name: string, value: Matrix): ProceduralTexture;
  18985. /**
  18986. * Render the texture to its associated render target.
  18987. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  18988. */
  18989. render(useCameraPostProcess?: boolean): void;
  18990. /**
  18991. * Clone the texture.
  18992. * @returns the cloned texture
  18993. */
  18994. clone(): ProceduralTexture;
  18995. /**
  18996. * Dispose the texture and release its asoociated resources.
  18997. */
  18998. dispose(): void;
  18999. }
  19000. }
  19001. declare module BABYLON {
  19002. /**
  19003. * This represents the base class for particle system in Babylon.
  19004. * 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.
  19005. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19006. * @example https://doc.babylonjs.com/babylon101/particles
  19007. */
  19008. export class BaseParticleSystem {
  19009. /**
  19010. * Source color is added to the destination color without alpha affecting the result
  19011. */
  19012. static BLENDMODE_ONEONE: number;
  19013. /**
  19014. * Blend current color and particle color using particle’s alpha
  19015. */
  19016. static BLENDMODE_STANDARD: number;
  19017. /**
  19018. * Add current color and particle color multiplied by particle’s alpha
  19019. */
  19020. static BLENDMODE_ADD: number;
  19021. /**
  19022. * Multiply current color with particle color
  19023. */
  19024. static BLENDMODE_MULTIPLY: number;
  19025. /**
  19026. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  19027. */
  19028. static BLENDMODE_MULTIPLYADD: number;
  19029. /**
  19030. * List of animations used by the particle system.
  19031. */
  19032. animations: Animation[];
  19033. /**
  19034. * The id of the Particle system.
  19035. */
  19036. id: string;
  19037. /**
  19038. * The friendly name of the Particle system.
  19039. */
  19040. name: string;
  19041. /**
  19042. * The rendering group used by the Particle system to chose when to render.
  19043. */
  19044. renderingGroupId: number;
  19045. /**
  19046. * The emitter represents the Mesh or position we are attaching the particle system to.
  19047. */
  19048. emitter: Nullable<AbstractMesh | Vector3>;
  19049. /**
  19050. * The maximum number of particles to emit per frame
  19051. */
  19052. emitRate: number;
  19053. /**
  19054. * If you want to launch only a few particles at once, that can be done, as well.
  19055. */
  19056. manualEmitCount: number;
  19057. /**
  19058. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19059. */
  19060. updateSpeed: number;
  19061. /**
  19062. * The amount of time the particle system is running (depends of the overall update speed).
  19063. */
  19064. targetStopDuration: number;
  19065. /**
  19066. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19067. */
  19068. disposeOnStop: boolean;
  19069. /**
  19070. * Minimum power of emitting particles.
  19071. */
  19072. minEmitPower: number;
  19073. /**
  19074. * Maximum power of emitting particles.
  19075. */
  19076. maxEmitPower: number;
  19077. /**
  19078. * Minimum life time of emitting particles.
  19079. */
  19080. minLifeTime: number;
  19081. /**
  19082. * Maximum life time of emitting particles.
  19083. */
  19084. maxLifeTime: number;
  19085. /**
  19086. * Minimum Size of emitting particles.
  19087. */
  19088. minSize: number;
  19089. /**
  19090. * Maximum Size of emitting particles.
  19091. */
  19092. maxSize: number;
  19093. /**
  19094. * Minimum scale of emitting particles on X axis.
  19095. */
  19096. minScaleX: number;
  19097. /**
  19098. * Maximum scale of emitting particles on X axis.
  19099. */
  19100. maxScaleX: number;
  19101. /**
  19102. * Minimum scale of emitting particles on Y axis.
  19103. */
  19104. minScaleY: number;
  19105. /**
  19106. * Maximum scale of emitting particles on Y axis.
  19107. */
  19108. maxScaleY: number;
  19109. /**
  19110. * Gets or sets the minimal initial rotation in radians.
  19111. */
  19112. minInitialRotation: number;
  19113. /**
  19114. * Gets or sets the maximal initial rotation in radians.
  19115. */
  19116. maxInitialRotation: number;
  19117. /**
  19118. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19119. */
  19120. minAngularSpeed: number;
  19121. /**
  19122. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19123. */
  19124. maxAngularSpeed: number;
  19125. /**
  19126. * The texture used to render each particle. (this can be a spritesheet)
  19127. */
  19128. particleTexture: Nullable<Texture>;
  19129. /**
  19130. * The layer mask we are rendering the particles through.
  19131. */
  19132. layerMask: number;
  19133. /**
  19134. * This can help using your own shader to render the particle system.
  19135. * The according effect will be created
  19136. */
  19137. customShader: any;
  19138. /**
  19139. * By default particle system starts as soon as they are created. This prevents the
  19140. * automatic start to happen and let you decide when to start emitting particles.
  19141. */
  19142. preventAutoStart: boolean;
  19143. private _noiseTexture;
  19144. /**
  19145. * Gets or sets a texture used to add random noise to particle positions
  19146. */
  19147. noiseTexture: Nullable<ProceduralTexture>;
  19148. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19149. noiseStrength: Vector3;
  19150. /**
  19151. * Callback triggered when the particle animation is ending.
  19152. */
  19153. onAnimationEnd: Nullable<() => void>;
  19154. /**
  19155. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19156. */
  19157. blendMode: number;
  19158. /**
  19159. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19160. * to override the particles.
  19161. */
  19162. forceDepthWrite: boolean;
  19163. /** 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 */
  19164. preWarmCycles: number;
  19165. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19166. preWarmStepOffset: number;
  19167. /**
  19168. * 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)
  19169. */
  19170. spriteCellChangeSpeed: number;
  19171. /**
  19172. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19173. */
  19174. startSpriteCellID: number;
  19175. /**
  19176. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19177. */
  19178. endSpriteCellID: number;
  19179. /**
  19180. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19181. */
  19182. spriteCellWidth: number;
  19183. /**
  19184. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19185. */
  19186. spriteCellHeight: number;
  19187. /**
  19188. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19189. */
  19190. spriteRandomStartCell: boolean;
  19191. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19192. translationPivot: Vector2;
  19193. /** @hidden */
  19194. protected _isAnimationSheetEnabled: boolean;
  19195. /**
  19196. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19197. */
  19198. beginAnimationOnStart: boolean;
  19199. /**
  19200. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19201. */
  19202. beginAnimationFrom: number;
  19203. /**
  19204. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19205. */
  19206. beginAnimationTo: number;
  19207. /**
  19208. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19209. */
  19210. beginAnimationLoop: boolean;
  19211. /**
  19212. * Gets or sets a world offset applied to all particles
  19213. */
  19214. worldOffset: Vector3;
  19215. /**
  19216. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19217. */
  19218. isAnimationSheetEnabled: boolean;
  19219. /**
  19220. * Get hosting scene
  19221. * @returns the scene
  19222. */
  19223. getScene(): Scene;
  19224. /**
  19225. * You can use gravity if you want to give an orientation to your particles.
  19226. */
  19227. gravity: Vector3;
  19228. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19229. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19230. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19231. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19232. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19233. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19234. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19235. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19236. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19237. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19238. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19239. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19240. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19241. /**
  19242. * Defines the delay in milliseconds before starting the system (0 by default)
  19243. */
  19244. startDelay: number;
  19245. /**
  19246. * Gets the current list of drag gradients.
  19247. * You must use addDragGradient and removeDragGradient to udpate this list
  19248. * @returns the list of drag gradients
  19249. */
  19250. getDragGradients(): Nullable<Array<FactorGradient>>;
  19251. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19252. limitVelocityDamping: number;
  19253. /**
  19254. * Gets the current list of limit velocity gradients.
  19255. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19256. * @returns the list of limit velocity gradients
  19257. */
  19258. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19259. /**
  19260. * Gets the current list of color gradients.
  19261. * You must use addColorGradient and removeColorGradient to udpate this list
  19262. * @returns the list of color gradients
  19263. */
  19264. getColorGradients(): Nullable<Array<ColorGradient>>;
  19265. /**
  19266. * Gets the current list of size gradients.
  19267. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19268. * @returns the list of size gradients
  19269. */
  19270. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19271. /**
  19272. * Gets the current list of color remap gradients.
  19273. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19274. * @returns the list of color remap gradients
  19275. */
  19276. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19277. /**
  19278. * Gets the current list of alpha remap gradients.
  19279. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19280. * @returns the list of alpha remap gradients
  19281. */
  19282. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19283. /**
  19284. * Gets the current list of life time gradients.
  19285. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19286. * @returns the list of life time gradients
  19287. */
  19288. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19289. /**
  19290. * Gets the current list of angular speed gradients.
  19291. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19292. * @returns the list of angular speed gradients
  19293. */
  19294. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19295. /**
  19296. * Gets the current list of velocity gradients.
  19297. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19298. * @returns the list of velocity gradients
  19299. */
  19300. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19301. /**
  19302. * Gets the current list of start size gradients.
  19303. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19304. * @returns the list of start size gradients
  19305. */
  19306. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19307. /**
  19308. * Gets the current list of emit rate gradients.
  19309. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19310. * @returns the list of emit rate gradients
  19311. */
  19312. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19313. /**
  19314. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19315. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19316. */
  19317. direction1: Vector3;
  19318. /**
  19319. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19320. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19321. */
  19322. direction2: Vector3;
  19323. /**
  19324. * 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.
  19325. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19326. */
  19327. minEmitBox: Vector3;
  19328. /**
  19329. * 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.
  19330. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19331. */
  19332. maxEmitBox: Vector3;
  19333. /**
  19334. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19335. */
  19336. color1: Color4;
  19337. /**
  19338. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19339. */
  19340. color2: Color4;
  19341. /**
  19342. * Color the particle will have at the end of its lifetime
  19343. */
  19344. colorDead: Color4;
  19345. /**
  19346. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19347. */
  19348. textureMask: Color4;
  19349. /**
  19350. * The particle emitter type defines the emitter used by the particle system.
  19351. * It can be for example box, sphere, or cone...
  19352. */
  19353. particleEmitterType: IParticleEmitterType;
  19354. /** @hidden */
  19355. _isSubEmitter: boolean;
  19356. /**
  19357. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19358. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19359. */
  19360. billboardMode: number;
  19361. protected _isBillboardBased: boolean;
  19362. /**
  19363. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19364. */
  19365. isBillboardBased: boolean;
  19366. /**
  19367. * The scene the particle system belongs to.
  19368. */
  19369. protected _scene: Scene;
  19370. /**
  19371. * Local cache of defines for image processing.
  19372. */
  19373. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19374. /**
  19375. * Default configuration related to image processing available in the standard Material.
  19376. */
  19377. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19378. /**
  19379. * Gets the image processing configuration used either in this material.
  19380. */
  19381. /**
  19382. * Sets the Default image processing configuration used either in the this material.
  19383. *
  19384. * If sets to null, the scene one is in use.
  19385. */
  19386. imageProcessingConfiguration: ImageProcessingConfiguration;
  19387. /**
  19388. * Attaches a new image processing configuration to the Standard Material.
  19389. * @param configuration
  19390. */
  19391. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19392. /** @hidden */
  19393. protected _reset(): void;
  19394. /** @hidden */
  19395. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19396. /**
  19397. * Instantiates a particle system.
  19398. * 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.
  19399. * @param name The name of the particle system
  19400. */
  19401. constructor(name: string);
  19402. /**
  19403. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19404. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19405. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19406. * @returns the emitter
  19407. */
  19408. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19409. /**
  19410. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19411. * @param radius The radius of the hemisphere to emit from
  19412. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19413. * @returns the emitter
  19414. */
  19415. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19416. /**
  19417. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19418. * @param radius The radius of the sphere to emit from
  19419. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19420. * @returns the emitter
  19421. */
  19422. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19423. /**
  19424. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19425. * @param radius The radius of the sphere to emit from
  19426. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19427. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19428. * @returns the emitter
  19429. */
  19430. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19431. /**
  19432. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19433. * @param radius The radius of the emission cylinder
  19434. * @param height The height of the emission cylinder
  19435. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19436. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19437. * @returns the emitter
  19438. */
  19439. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19440. /**
  19441. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19442. * @param radius The radius of the cylinder to emit from
  19443. * @param height The height of the emission cylinder
  19444. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19445. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19446. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19447. * @returns the emitter
  19448. */
  19449. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19450. /**
  19451. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19452. * @param radius The radius of the cone to emit from
  19453. * @param angle The base angle of the cone
  19454. * @returns the emitter
  19455. */
  19456. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19457. /**
  19458. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19459. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19460. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19461. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19462. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19463. * @returns the emitter
  19464. */
  19465. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19466. }
  19467. }
  19468. declare module BABYLON {
  19469. /**
  19470. * Type of sub emitter
  19471. */
  19472. export enum SubEmitterType {
  19473. /**
  19474. * Attached to the particle over it's lifetime
  19475. */
  19476. ATTACHED = 0,
  19477. /**
  19478. * Created when the particle dies
  19479. */
  19480. END = 1
  19481. }
  19482. /**
  19483. * Sub emitter class used to emit particles from an existing particle
  19484. */
  19485. export class SubEmitter {
  19486. /**
  19487. * the particle system to be used by the sub emitter
  19488. */
  19489. particleSystem: ParticleSystem;
  19490. /**
  19491. * Type of the submitter (Default: END)
  19492. */
  19493. type: SubEmitterType;
  19494. /**
  19495. * 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)
  19496. * Note: This only is supported when using an emitter of type Mesh
  19497. */
  19498. inheritDirection: boolean;
  19499. /**
  19500. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  19501. */
  19502. inheritedVelocityAmount: number;
  19503. /**
  19504. * Creates a sub emitter
  19505. * @param particleSystem the particle system to be used by the sub emitter
  19506. */
  19507. constructor(
  19508. /**
  19509. * the particle system to be used by the sub emitter
  19510. */
  19511. particleSystem: ParticleSystem);
  19512. /**
  19513. * Clones the sub emitter
  19514. * @returns the cloned sub emitter
  19515. */
  19516. clone(): SubEmitter;
  19517. /**
  19518. * Serialize current object to a JSON object
  19519. * @returns the serialized object
  19520. */
  19521. serialize(): any;
  19522. /** @hidden */
  19523. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  19524. /**
  19525. * Creates a new SubEmitter from a serialized JSON version
  19526. * @param serializationObject defines the JSON object to read from
  19527. * @param scene defines the hosting scene
  19528. * @param rootUrl defines the rootUrl for data loading
  19529. * @returns a new SubEmitter
  19530. */
  19531. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  19532. /** Release associated resources */
  19533. dispose(): void;
  19534. }
  19535. }
  19536. declare module BABYLON {
  19537. /** @hidden */
  19538. export var imageProcessingDeclaration: {
  19539. name: string;
  19540. shader: string;
  19541. };
  19542. }
  19543. declare module BABYLON {
  19544. /** @hidden */
  19545. export var imageProcessingFunctions: {
  19546. name: string;
  19547. shader: string;
  19548. };
  19549. }
  19550. declare module BABYLON {
  19551. /** @hidden */
  19552. export var particlesPixelShader: {
  19553. name: string;
  19554. shader: string;
  19555. };
  19556. }
  19557. declare module BABYLON {
  19558. /** @hidden */
  19559. export var particlesVertexShader: {
  19560. name: string;
  19561. shader: string;
  19562. };
  19563. }
  19564. declare module BABYLON {
  19565. /**
  19566. * This represents a particle system in Babylon.
  19567. * 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.
  19568. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19569. * @example https://doc.babylonjs.com/babylon101/particles
  19570. */
  19571. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  19572. /**
  19573. * Billboard mode will only apply to Y axis
  19574. */
  19575. static readonly BILLBOARDMODE_Y: number;
  19576. /**
  19577. * Billboard mode will apply to all axes
  19578. */
  19579. static readonly BILLBOARDMODE_ALL: number;
  19580. /**
  19581. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  19582. */
  19583. static readonly BILLBOARDMODE_STRETCHED: number;
  19584. /**
  19585. * This function can be defined to provide custom update for active particles.
  19586. * This function will be called instead of regular update (age, position, color, etc.).
  19587. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  19588. */
  19589. updateFunction: (particles: Particle[]) => void;
  19590. private _emitterWorldMatrix;
  19591. /**
  19592. * This function can be defined to specify initial direction for every new particle.
  19593. * It by default use the emitterType defined function
  19594. */
  19595. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  19596. /**
  19597. * This function can be defined to specify initial position for every new particle.
  19598. * It by default use the emitterType defined function
  19599. */
  19600. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  19601. /**
  19602. * @hidden
  19603. */
  19604. _inheritedVelocityOffset: Vector3;
  19605. /**
  19606. * An event triggered when the system is disposed
  19607. */
  19608. onDisposeObservable: Observable<ParticleSystem>;
  19609. private _onDisposeObserver;
  19610. /**
  19611. * Sets a callback that will be triggered when the system is disposed
  19612. */
  19613. onDispose: () => void;
  19614. private _particles;
  19615. private _epsilon;
  19616. private _capacity;
  19617. private _stockParticles;
  19618. private _newPartsExcess;
  19619. private _vertexData;
  19620. private _vertexBuffer;
  19621. private _vertexBuffers;
  19622. private _spriteBuffer;
  19623. private _indexBuffer;
  19624. private _effect;
  19625. private _customEffect;
  19626. private _cachedDefines;
  19627. private _scaledColorStep;
  19628. private _colorDiff;
  19629. private _scaledDirection;
  19630. private _scaledGravity;
  19631. private _currentRenderId;
  19632. private _alive;
  19633. private _useInstancing;
  19634. private _started;
  19635. private _stopped;
  19636. private _actualFrame;
  19637. private _scaledUpdateSpeed;
  19638. private _vertexBufferSize;
  19639. /** @hidden */
  19640. _currentEmitRateGradient: Nullable<FactorGradient>;
  19641. /** @hidden */
  19642. _currentEmitRate1: number;
  19643. /** @hidden */
  19644. _currentEmitRate2: number;
  19645. /** @hidden */
  19646. _currentStartSizeGradient: Nullable<FactorGradient>;
  19647. /** @hidden */
  19648. _currentStartSize1: number;
  19649. /** @hidden */
  19650. _currentStartSize2: number;
  19651. private readonly _rawTextureWidth;
  19652. private _rampGradientsTexture;
  19653. private _useRampGradients;
  19654. /** Gets or sets a boolean indicating that ramp gradients must be used
  19655. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19656. */
  19657. useRampGradients: boolean;
  19658. /**
  19659. * 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.
  19660. * 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: [])
  19661. */
  19662. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  19663. private _subEmitters;
  19664. /**
  19665. * @hidden
  19666. * If the particle systems emitter should be disposed when the particle system is disposed
  19667. */
  19668. _disposeEmitterOnDispose: boolean;
  19669. /**
  19670. * The current active Sub-systems, this property is used by the root particle system only.
  19671. */
  19672. activeSubSystems: Array<ParticleSystem>;
  19673. private _rootParticleSystem;
  19674. /**
  19675. * Gets the current list of active particles
  19676. */
  19677. readonly particles: Particle[];
  19678. /**
  19679. * Returns the string "ParticleSystem"
  19680. * @returns a string containing the class name
  19681. */
  19682. getClassName(): string;
  19683. /**
  19684. * Instantiates a particle system.
  19685. * 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.
  19686. * @param name The name of the particle system
  19687. * @param capacity The max number of particles alive at the same time
  19688. * @param scene The scene the particle system belongs to
  19689. * @param customEffect a custom effect used to change the way particles are rendered by default
  19690. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  19691. * @param epsilon Offset used to render the particles
  19692. */
  19693. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  19694. private _addFactorGradient;
  19695. private _removeFactorGradient;
  19696. /**
  19697. * Adds a new life time gradient
  19698. * @param gradient defines the gradient to use (between 0 and 1)
  19699. * @param factor defines the life time factor to affect to the specified gradient
  19700. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19701. * @returns the current particle system
  19702. */
  19703. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19704. /**
  19705. * Remove a specific life time gradient
  19706. * @param gradient defines the gradient to remove
  19707. * @returns the current particle system
  19708. */
  19709. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19710. /**
  19711. * Adds a new size gradient
  19712. * @param gradient defines the gradient to use (between 0 and 1)
  19713. * @param factor defines the size factor to affect to the specified gradient
  19714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19715. * @returns the current particle system
  19716. */
  19717. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19718. /**
  19719. * Remove a specific size gradient
  19720. * @param gradient defines the gradient to remove
  19721. * @returns the current particle system
  19722. */
  19723. removeSizeGradient(gradient: number): IParticleSystem;
  19724. /**
  19725. * Adds a new color remap gradient
  19726. * @param gradient defines the gradient to use (between 0 and 1)
  19727. * @param min defines the color remap minimal range
  19728. * @param max defines the color remap maximal range
  19729. * @returns the current particle system
  19730. */
  19731. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19732. /**
  19733. * Remove a specific color remap gradient
  19734. * @param gradient defines the gradient to remove
  19735. * @returns the current particle system
  19736. */
  19737. removeColorRemapGradient(gradient: number): IParticleSystem;
  19738. /**
  19739. * Adds a new alpha remap gradient
  19740. * @param gradient defines the gradient to use (between 0 and 1)
  19741. * @param min defines the alpha remap minimal range
  19742. * @param max defines the alpha remap maximal range
  19743. * @returns the current particle system
  19744. */
  19745. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19746. /**
  19747. * Remove a specific alpha remap gradient
  19748. * @param gradient defines the gradient to remove
  19749. * @returns the current particle system
  19750. */
  19751. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  19752. /**
  19753. * Adds a new angular speed gradient
  19754. * @param gradient defines the gradient to use (between 0 and 1)
  19755. * @param factor defines the angular speed to affect to the specified gradient
  19756. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19757. * @returns the current particle system
  19758. */
  19759. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19760. /**
  19761. * Remove a specific angular speed gradient
  19762. * @param gradient defines the gradient to remove
  19763. * @returns the current particle system
  19764. */
  19765. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19766. /**
  19767. * Adds a new velocity gradient
  19768. * @param gradient defines the gradient to use (between 0 and 1)
  19769. * @param factor defines the velocity to affect to the specified gradient
  19770. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19771. * @returns the current particle system
  19772. */
  19773. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19774. /**
  19775. * Remove a specific velocity gradient
  19776. * @param gradient defines the gradient to remove
  19777. * @returns the current particle system
  19778. */
  19779. removeVelocityGradient(gradient: number): IParticleSystem;
  19780. /**
  19781. * Adds a new limit velocity gradient
  19782. * @param gradient defines the gradient to use (between 0 and 1)
  19783. * @param factor defines the limit velocity value to affect to the specified gradient
  19784. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19785. * @returns the current particle system
  19786. */
  19787. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19788. /**
  19789. * Remove a specific limit velocity gradient
  19790. * @param gradient defines the gradient to remove
  19791. * @returns the current particle system
  19792. */
  19793. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19794. /**
  19795. * Adds a new drag gradient
  19796. * @param gradient defines the gradient to use (between 0 and 1)
  19797. * @param factor defines the drag value to affect to the specified gradient
  19798. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19799. * @returns the current particle system
  19800. */
  19801. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19802. /**
  19803. * Remove a specific drag gradient
  19804. * @param gradient defines the gradient to remove
  19805. * @returns the current particle system
  19806. */
  19807. removeDragGradient(gradient: number): IParticleSystem;
  19808. /**
  19809. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19810. * @param gradient defines the gradient to use (between 0 and 1)
  19811. * @param factor defines the emit rate value to affect to the specified gradient
  19812. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19813. * @returns the current particle system
  19814. */
  19815. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19816. /**
  19817. * Remove a specific emit rate gradient
  19818. * @param gradient defines the gradient to remove
  19819. * @returns the current particle system
  19820. */
  19821. removeEmitRateGradient(gradient: number): IParticleSystem;
  19822. /**
  19823. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19824. * @param gradient defines the gradient to use (between 0 and 1)
  19825. * @param factor defines the start size value to affect to the specified gradient
  19826. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19827. * @returns the current particle system
  19828. */
  19829. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19830. /**
  19831. * Remove a specific start size gradient
  19832. * @param gradient defines the gradient to remove
  19833. * @returns the current particle system
  19834. */
  19835. removeStartSizeGradient(gradient: number): IParticleSystem;
  19836. private _createRampGradientTexture;
  19837. /**
  19838. * Gets the current list of ramp gradients.
  19839. * You must use addRampGradient and removeRampGradient to udpate this list
  19840. * @returns the list of ramp gradients
  19841. */
  19842. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19843. /**
  19844. * Adds a new ramp gradient used to remap particle colors
  19845. * @param gradient defines the gradient to use (between 0 and 1)
  19846. * @param color defines the color to affect to the specified gradient
  19847. * @returns the current particle system
  19848. */
  19849. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  19850. /**
  19851. * Remove a specific ramp gradient
  19852. * @param gradient defines the gradient to remove
  19853. * @returns the current particle system
  19854. */
  19855. removeRampGradient(gradient: number): ParticleSystem;
  19856. /**
  19857. * Adds a new color gradient
  19858. * @param gradient defines the gradient to use (between 0 and 1)
  19859. * @param color1 defines the color to affect to the specified gradient
  19860. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19861. * @returns this particle system
  19862. */
  19863. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19864. /**
  19865. * Remove a specific color gradient
  19866. * @param gradient defines the gradient to remove
  19867. * @returns this particle system
  19868. */
  19869. removeColorGradient(gradient: number): IParticleSystem;
  19870. private _fetchR;
  19871. protected _reset(): void;
  19872. private _resetEffect;
  19873. private _createVertexBuffers;
  19874. private _createIndexBuffer;
  19875. /**
  19876. * Gets the maximum number of particles active at the same time.
  19877. * @returns The max number of active particles.
  19878. */
  19879. getCapacity(): number;
  19880. /**
  19881. * Gets whether there are still active particles in the system.
  19882. * @returns True if it is alive, otherwise false.
  19883. */
  19884. isAlive(): boolean;
  19885. /**
  19886. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19887. * @returns True if it has been started, otherwise false.
  19888. */
  19889. isStarted(): boolean;
  19890. private _prepareSubEmitterInternalArray;
  19891. /**
  19892. * Starts the particle system and begins to emit
  19893. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  19894. */
  19895. start(delay?: number): void;
  19896. /**
  19897. * Stops the particle system.
  19898. * @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.
  19899. */
  19900. stop(stopSubEmitters?: boolean): void;
  19901. /**
  19902. * Remove all active particles
  19903. */
  19904. reset(): void;
  19905. /**
  19906. * @hidden (for internal use only)
  19907. */
  19908. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  19909. /**
  19910. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  19911. * Its lifetime will start back at 0.
  19912. */
  19913. recycleParticle: (particle: Particle) => void;
  19914. private _stopSubEmitters;
  19915. private _createParticle;
  19916. private _removeFromRoot;
  19917. private _emitFromParticle;
  19918. private _update;
  19919. /** @hidden */
  19920. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  19921. /** @hidden */
  19922. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  19923. /** @hidden */
  19924. private _getEffect;
  19925. /**
  19926. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  19927. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  19928. */
  19929. animate(preWarmOnly?: boolean): void;
  19930. private _appendParticleVertices;
  19931. /**
  19932. * Rebuilds the particle system.
  19933. */
  19934. rebuild(): void;
  19935. /**
  19936. * Is this system ready to be used/rendered
  19937. * @return true if the system is ready
  19938. */
  19939. isReady(): boolean;
  19940. private _render;
  19941. /**
  19942. * Renders the particle system in its current state.
  19943. * @returns the current number of particles
  19944. */
  19945. render(): number;
  19946. /**
  19947. * Disposes the particle system and free the associated resources
  19948. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19949. */
  19950. dispose(disposeTexture?: boolean): void;
  19951. /**
  19952. * Clones the particle system.
  19953. * @param name The name of the cloned object
  19954. * @param newEmitter The new emitter to use
  19955. * @returns the cloned particle system
  19956. */
  19957. clone(name: string, newEmitter: any): ParticleSystem;
  19958. /**
  19959. * Serializes the particle system to a JSON object.
  19960. * @returns the JSON object
  19961. */
  19962. serialize(): any;
  19963. /** @hidden */
  19964. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  19965. /** @hidden */
  19966. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  19967. /**
  19968. * Parses a JSON object to create a particle system.
  19969. * @param parsedParticleSystem The JSON object to parse
  19970. * @param scene The scene to create the particle system in
  19971. * @param rootUrl The root url to use to load external dependencies like texture
  19972. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  19973. * @returns the Parsed particle system
  19974. */
  19975. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  19976. }
  19977. }
  19978. declare module BABYLON {
  19979. /**
  19980. * A particle represents one of the element emitted by a particle system.
  19981. * This is mainly define by its coordinates, direction, velocity and age.
  19982. */
  19983. export class Particle {
  19984. /**
  19985. * The particle system the particle belongs to.
  19986. */
  19987. particleSystem: ParticleSystem;
  19988. private static _Count;
  19989. /**
  19990. * Unique ID of the particle
  19991. */
  19992. id: number;
  19993. /**
  19994. * The world position of the particle in the scene.
  19995. */
  19996. position: Vector3;
  19997. /**
  19998. * The world direction of the particle in the scene.
  19999. */
  20000. direction: Vector3;
  20001. /**
  20002. * The color of the particle.
  20003. */
  20004. color: Color4;
  20005. /**
  20006. * The color change of the particle per step.
  20007. */
  20008. colorStep: Color4;
  20009. /**
  20010. * Defines how long will the life of the particle be.
  20011. */
  20012. lifeTime: number;
  20013. /**
  20014. * The current age of the particle.
  20015. */
  20016. age: number;
  20017. /**
  20018. * The current size of the particle.
  20019. */
  20020. size: number;
  20021. /**
  20022. * The current scale of the particle.
  20023. */
  20024. scale: Vector2;
  20025. /**
  20026. * The current angle of the particle.
  20027. */
  20028. angle: number;
  20029. /**
  20030. * Defines how fast is the angle changing.
  20031. */
  20032. angularSpeed: number;
  20033. /**
  20034. * Defines the cell index used by the particle to be rendered from a sprite.
  20035. */
  20036. cellIndex: number;
  20037. /**
  20038. * The information required to support color remapping
  20039. */
  20040. remapData: Vector4;
  20041. /** @hidden */
  20042. _randomCellOffset?: number;
  20043. /** @hidden */
  20044. _initialDirection: Nullable<Vector3>;
  20045. /** @hidden */
  20046. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  20047. /** @hidden */
  20048. _initialStartSpriteCellID: number;
  20049. /** @hidden */
  20050. _initialEndSpriteCellID: number;
  20051. /** @hidden */
  20052. _currentColorGradient: Nullable<ColorGradient>;
  20053. /** @hidden */
  20054. _currentColor1: Color4;
  20055. /** @hidden */
  20056. _currentColor2: Color4;
  20057. /** @hidden */
  20058. _currentSizeGradient: Nullable<FactorGradient>;
  20059. /** @hidden */
  20060. _currentSize1: number;
  20061. /** @hidden */
  20062. _currentSize2: number;
  20063. /** @hidden */
  20064. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  20065. /** @hidden */
  20066. _currentAngularSpeed1: number;
  20067. /** @hidden */
  20068. _currentAngularSpeed2: number;
  20069. /** @hidden */
  20070. _currentVelocityGradient: Nullable<FactorGradient>;
  20071. /** @hidden */
  20072. _currentVelocity1: number;
  20073. /** @hidden */
  20074. _currentVelocity2: number;
  20075. /** @hidden */
  20076. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  20077. /** @hidden */
  20078. _currentLimitVelocity1: number;
  20079. /** @hidden */
  20080. _currentLimitVelocity2: number;
  20081. /** @hidden */
  20082. _currentDragGradient: Nullable<FactorGradient>;
  20083. /** @hidden */
  20084. _currentDrag1: number;
  20085. /** @hidden */
  20086. _currentDrag2: number;
  20087. /** @hidden */
  20088. _randomNoiseCoordinates1: Vector3;
  20089. /** @hidden */
  20090. _randomNoiseCoordinates2: Vector3;
  20091. /**
  20092. * Creates a new instance Particle
  20093. * @param particleSystem the particle system the particle belongs to
  20094. */
  20095. constructor(
  20096. /**
  20097. * The particle system the particle belongs to.
  20098. */
  20099. particleSystem: ParticleSystem);
  20100. private updateCellInfoFromSystem;
  20101. /**
  20102. * Defines how the sprite cell index is updated for the particle
  20103. */
  20104. updateCellIndex(): void;
  20105. /** @hidden */
  20106. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20107. /** @hidden */
  20108. _inheritParticleInfoToSubEmitters(): void;
  20109. /** @hidden */
  20110. _reset(): void;
  20111. /**
  20112. * Copy the properties of particle to another one.
  20113. * @param other the particle to copy the information to.
  20114. */
  20115. copyTo(other: Particle): void;
  20116. }
  20117. }
  20118. declare module BABYLON {
  20119. /**
  20120. * Particle emitter represents a volume emitting particles.
  20121. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20122. */
  20123. export interface IParticleEmitterType {
  20124. /**
  20125. * Called by the particle System when the direction is computed for the created particle.
  20126. * @param worldMatrix is the world matrix of the particle system
  20127. * @param directionToUpdate is the direction vector to update with the result
  20128. * @param particle is the particle we are computed the direction for
  20129. */
  20130. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20131. /**
  20132. * Called by the particle System when the position is computed for the created particle.
  20133. * @param worldMatrix is the world matrix of the particle system
  20134. * @param positionToUpdate is the position vector to update with the result
  20135. * @param particle is the particle we are computed the position for
  20136. */
  20137. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20138. /**
  20139. * Clones the current emitter and returns a copy of it
  20140. * @returns the new emitter
  20141. */
  20142. clone(): IParticleEmitterType;
  20143. /**
  20144. * Called by the GPUParticleSystem to setup the update shader
  20145. * @param effect defines the update shader
  20146. */
  20147. applyToShader(effect: Effect): void;
  20148. /**
  20149. * Returns a string to use to update the GPU particles update shader
  20150. * @returns the effect defines string
  20151. */
  20152. getEffectDefines(): string;
  20153. /**
  20154. * Returns a string representing the class name
  20155. * @returns a string containing the class name
  20156. */
  20157. getClassName(): string;
  20158. /**
  20159. * Serializes the particle system to a JSON object.
  20160. * @returns the JSON object
  20161. */
  20162. serialize(): any;
  20163. /**
  20164. * Parse properties from a JSON object
  20165. * @param serializationObject defines the JSON object
  20166. */
  20167. parse(serializationObject: any): void;
  20168. }
  20169. }
  20170. declare module BABYLON {
  20171. /**
  20172. * Particle emitter emitting particles from the inside of a box.
  20173. * It emits the particles randomly between 2 given directions.
  20174. */
  20175. export class BoxParticleEmitter implements IParticleEmitterType {
  20176. /**
  20177. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20178. */
  20179. direction1: Vector3;
  20180. /**
  20181. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20182. */
  20183. direction2: Vector3;
  20184. /**
  20185. * 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.
  20186. */
  20187. minEmitBox: Vector3;
  20188. /**
  20189. * 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.
  20190. */
  20191. maxEmitBox: Vector3;
  20192. /**
  20193. * Creates a new instance BoxParticleEmitter
  20194. */
  20195. constructor();
  20196. /**
  20197. * Called by the particle System when the direction is computed for the created particle.
  20198. * @param worldMatrix is the world matrix of the particle system
  20199. * @param directionToUpdate is the direction vector to update with the result
  20200. * @param particle is the particle we are computed the direction for
  20201. */
  20202. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20203. /**
  20204. * Called by the particle System when the position is computed for the created particle.
  20205. * @param worldMatrix is the world matrix of the particle system
  20206. * @param positionToUpdate is the position vector to update with the result
  20207. * @param particle is the particle we are computed the position for
  20208. */
  20209. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20210. /**
  20211. * Clones the current emitter and returns a copy of it
  20212. * @returns the new emitter
  20213. */
  20214. clone(): BoxParticleEmitter;
  20215. /**
  20216. * Called by the GPUParticleSystem to setup the update shader
  20217. * @param effect defines the update shader
  20218. */
  20219. applyToShader(effect: Effect): void;
  20220. /**
  20221. * Returns a string to use to update the GPU particles update shader
  20222. * @returns a string containng the defines string
  20223. */
  20224. getEffectDefines(): string;
  20225. /**
  20226. * Returns the string "BoxParticleEmitter"
  20227. * @returns a string containing the class name
  20228. */
  20229. getClassName(): string;
  20230. /**
  20231. * Serializes the particle system to a JSON object.
  20232. * @returns the JSON object
  20233. */
  20234. serialize(): any;
  20235. /**
  20236. * Parse properties from a JSON object
  20237. * @param serializationObject defines the JSON object
  20238. */
  20239. parse(serializationObject: any): void;
  20240. }
  20241. }
  20242. declare module BABYLON {
  20243. /**
  20244. * Particle emitter emitting particles from the inside of a cone.
  20245. * It emits the particles alongside the cone volume from the base to the particle.
  20246. * The emission direction might be randomized.
  20247. */
  20248. export class ConeParticleEmitter implements IParticleEmitterType {
  20249. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20250. directionRandomizer: number;
  20251. private _radius;
  20252. private _angle;
  20253. private _height;
  20254. /**
  20255. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20256. */
  20257. radiusRange: number;
  20258. /**
  20259. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20260. */
  20261. heightRange: number;
  20262. /**
  20263. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20264. */
  20265. emitFromSpawnPointOnly: boolean;
  20266. /**
  20267. * Gets or sets the radius of the emission cone
  20268. */
  20269. radius: number;
  20270. /**
  20271. * Gets or sets the angle of the emission cone
  20272. */
  20273. angle: number;
  20274. private _buildHeight;
  20275. /**
  20276. * Creates a new instance ConeParticleEmitter
  20277. * @param radius the radius of the emission cone (1 by default)
  20278. * @param angle the cone base angle (PI by default)
  20279. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20280. */
  20281. constructor(radius?: number, angle?: number,
  20282. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20283. directionRandomizer?: number);
  20284. /**
  20285. * Called by the particle System when the direction is computed for the created particle.
  20286. * @param worldMatrix is the world matrix of the particle system
  20287. * @param directionToUpdate is the direction vector to update with the result
  20288. * @param particle is the particle we are computed the direction for
  20289. */
  20290. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20291. /**
  20292. * Called by the particle System when the position is computed for the created particle.
  20293. * @param worldMatrix is the world matrix of the particle system
  20294. * @param positionToUpdate is the position vector to update with the result
  20295. * @param particle is the particle we are computed the position for
  20296. */
  20297. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20298. /**
  20299. * Clones the current emitter and returns a copy of it
  20300. * @returns the new emitter
  20301. */
  20302. clone(): ConeParticleEmitter;
  20303. /**
  20304. * Called by the GPUParticleSystem to setup the update shader
  20305. * @param effect defines the update shader
  20306. */
  20307. applyToShader(effect: Effect): void;
  20308. /**
  20309. * Returns a string to use to update the GPU particles update shader
  20310. * @returns a string containng the defines string
  20311. */
  20312. getEffectDefines(): string;
  20313. /**
  20314. * Returns the string "ConeParticleEmitter"
  20315. * @returns a string containing the class name
  20316. */
  20317. getClassName(): string;
  20318. /**
  20319. * Serializes the particle system to a JSON object.
  20320. * @returns the JSON object
  20321. */
  20322. serialize(): any;
  20323. /**
  20324. * Parse properties from a JSON object
  20325. * @param serializationObject defines the JSON object
  20326. */
  20327. parse(serializationObject: any): void;
  20328. }
  20329. }
  20330. declare module BABYLON {
  20331. /**
  20332. * Particle emitter emitting particles from the inside of a cylinder.
  20333. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20334. */
  20335. export class CylinderParticleEmitter implements IParticleEmitterType {
  20336. /**
  20337. * The radius of the emission cylinder.
  20338. */
  20339. radius: number;
  20340. /**
  20341. * The height of the emission cylinder.
  20342. */
  20343. height: number;
  20344. /**
  20345. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20346. */
  20347. radiusRange: number;
  20348. /**
  20349. * How much to randomize the particle direction [0-1].
  20350. */
  20351. directionRandomizer: number;
  20352. /**
  20353. * Creates a new instance CylinderParticleEmitter
  20354. * @param radius the radius of the emission cylinder (1 by default)
  20355. * @param height the height of the emission cylinder (1 by default)
  20356. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20357. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20358. */
  20359. constructor(
  20360. /**
  20361. * The radius of the emission cylinder.
  20362. */
  20363. radius?: number,
  20364. /**
  20365. * The height of the emission cylinder.
  20366. */
  20367. height?: number,
  20368. /**
  20369. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20370. */
  20371. radiusRange?: number,
  20372. /**
  20373. * How much to randomize the particle direction [0-1].
  20374. */
  20375. directionRandomizer?: number);
  20376. /**
  20377. * Called by the particle System when the direction is computed for the created particle.
  20378. * @param worldMatrix is the world matrix of the particle system
  20379. * @param directionToUpdate is the direction vector to update with the result
  20380. * @param particle is the particle we are computed the direction for
  20381. */
  20382. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20383. /**
  20384. * Called by the particle System when the position is computed for the created particle.
  20385. * @param worldMatrix is the world matrix of the particle system
  20386. * @param positionToUpdate is the position vector to update with the result
  20387. * @param particle is the particle we are computed the position for
  20388. */
  20389. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20390. /**
  20391. * Clones the current emitter and returns a copy of it
  20392. * @returns the new emitter
  20393. */
  20394. clone(): CylinderParticleEmitter;
  20395. /**
  20396. * Called by the GPUParticleSystem to setup the update shader
  20397. * @param effect defines the update shader
  20398. */
  20399. applyToShader(effect: Effect): void;
  20400. /**
  20401. * Returns a string to use to update the GPU particles update shader
  20402. * @returns a string containng the defines string
  20403. */
  20404. getEffectDefines(): string;
  20405. /**
  20406. * Returns the string "CylinderParticleEmitter"
  20407. * @returns a string containing the class name
  20408. */
  20409. getClassName(): string;
  20410. /**
  20411. * Serializes the particle system to a JSON object.
  20412. * @returns the JSON object
  20413. */
  20414. serialize(): any;
  20415. /**
  20416. * Parse properties from a JSON object
  20417. * @param serializationObject defines the JSON object
  20418. */
  20419. parse(serializationObject: any): void;
  20420. }
  20421. /**
  20422. * Particle emitter emitting particles from the inside of a cylinder.
  20423. * It emits the particles randomly between two vectors.
  20424. */
  20425. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20426. /**
  20427. * The min limit of the emission direction.
  20428. */
  20429. direction1: Vector3;
  20430. /**
  20431. * The max limit of the emission direction.
  20432. */
  20433. direction2: Vector3;
  20434. /**
  20435. * Creates a new instance CylinderDirectedParticleEmitter
  20436. * @param radius the radius of the emission cylinder (1 by default)
  20437. * @param height the height of the emission cylinder (1 by default)
  20438. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20439. * @param direction1 the min limit of the emission direction (up vector by default)
  20440. * @param direction2 the max limit of the emission direction (up vector by default)
  20441. */
  20442. constructor(radius?: number, height?: number, radiusRange?: number,
  20443. /**
  20444. * The min limit of the emission direction.
  20445. */
  20446. direction1?: Vector3,
  20447. /**
  20448. * The max limit of the emission direction.
  20449. */
  20450. direction2?: Vector3);
  20451. /**
  20452. * Called by the particle System when the direction is computed for the created particle.
  20453. * @param worldMatrix is the world matrix of the particle system
  20454. * @param directionToUpdate is the direction vector to update with the result
  20455. * @param particle is the particle we are computed the direction for
  20456. */
  20457. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20458. /**
  20459. * Clones the current emitter and returns a copy of it
  20460. * @returns the new emitter
  20461. */
  20462. clone(): CylinderDirectedParticleEmitter;
  20463. /**
  20464. * Called by the GPUParticleSystem to setup the update shader
  20465. * @param effect defines the update shader
  20466. */
  20467. applyToShader(effect: Effect): void;
  20468. /**
  20469. * Returns a string to use to update the GPU particles update shader
  20470. * @returns a string containng the defines string
  20471. */
  20472. getEffectDefines(): string;
  20473. /**
  20474. * Returns the string "CylinderDirectedParticleEmitter"
  20475. * @returns a string containing the class name
  20476. */
  20477. getClassName(): string;
  20478. /**
  20479. * Serializes the particle system to a JSON object.
  20480. * @returns the JSON object
  20481. */
  20482. serialize(): any;
  20483. /**
  20484. * Parse properties from a JSON object
  20485. * @param serializationObject defines the JSON object
  20486. */
  20487. parse(serializationObject: any): void;
  20488. }
  20489. }
  20490. declare module BABYLON {
  20491. /**
  20492. * Particle emitter emitting particles from the inside of a hemisphere.
  20493. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  20494. */
  20495. export class HemisphericParticleEmitter implements IParticleEmitterType {
  20496. /**
  20497. * The radius of the emission hemisphere.
  20498. */
  20499. radius: number;
  20500. /**
  20501. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20502. */
  20503. radiusRange: number;
  20504. /**
  20505. * How much to randomize the particle direction [0-1].
  20506. */
  20507. directionRandomizer: number;
  20508. /**
  20509. * Creates a new instance HemisphericParticleEmitter
  20510. * @param radius the radius of the emission hemisphere (1 by default)
  20511. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20512. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20513. */
  20514. constructor(
  20515. /**
  20516. * The radius of the emission hemisphere.
  20517. */
  20518. radius?: number,
  20519. /**
  20520. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20521. */
  20522. radiusRange?: number,
  20523. /**
  20524. * How much to randomize the particle direction [0-1].
  20525. */
  20526. directionRandomizer?: number);
  20527. /**
  20528. * Called by the particle System when the direction is computed for the created particle.
  20529. * @param worldMatrix is the world matrix of the particle system
  20530. * @param directionToUpdate is the direction vector to update with the result
  20531. * @param particle is the particle we are computed the direction for
  20532. */
  20533. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20534. /**
  20535. * Called by the particle System when the position is computed for the created particle.
  20536. * @param worldMatrix is the world matrix of the particle system
  20537. * @param positionToUpdate is the position vector to update with the result
  20538. * @param particle is the particle we are computed the position for
  20539. */
  20540. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20541. /**
  20542. * Clones the current emitter and returns a copy of it
  20543. * @returns the new emitter
  20544. */
  20545. clone(): HemisphericParticleEmitter;
  20546. /**
  20547. * Called by the GPUParticleSystem to setup the update shader
  20548. * @param effect defines the update shader
  20549. */
  20550. applyToShader(effect: Effect): void;
  20551. /**
  20552. * Returns a string to use to update the GPU particles update shader
  20553. * @returns a string containng the defines string
  20554. */
  20555. getEffectDefines(): string;
  20556. /**
  20557. * Returns the string "HemisphericParticleEmitter"
  20558. * @returns a string containing the class name
  20559. */
  20560. getClassName(): string;
  20561. /**
  20562. * Serializes the particle system to a JSON object.
  20563. * @returns the JSON object
  20564. */
  20565. serialize(): any;
  20566. /**
  20567. * Parse properties from a JSON object
  20568. * @param serializationObject defines the JSON object
  20569. */
  20570. parse(serializationObject: any): void;
  20571. }
  20572. }
  20573. declare module BABYLON {
  20574. /**
  20575. * Particle emitter emitting particles from a point.
  20576. * It emits the particles randomly between 2 given directions.
  20577. */
  20578. export class PointParticleEmitter implements IParticleEmitterType {
  20579. /**
  20580. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20581. */
  20582. direction1: Vector3;
  20583. /**
  20584. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20585. */
  20586. direction2: Vector3;
  20587. /**
  20588. * Creates a new instance PointParticleEmitter
  20589. */
  20590. constructor();
  20591. /**
  20592. * Called by the particle System when the direction is computed for the created particle.
  20593. * @param worldMatrix is the world matrix of the particle system
  20594. * @param directionToUpdate is the direction vector to update with the result
  20595. * @param particle is the particle we are computed the direction for
  20596. */
  20597. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20598. /**
  20599. * Called by the particle System when the position is computed for the created particle.
  20600. * @param worldMatrix is the world matrix of the particle system
  20601. * @param positionToUpdate is the position vector to update with the result
  20602. * @param particle is the particle we are computed the position for
  20603. */
  20604. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20605. /**
  20606. * Clones the current emitter and returns a copy of it
  20607. * @returns the new emitter
  20608. */
  20609. clone(): PointParticleEmitter;
  20610. /**
  20611. * Called by the GPUParticleSystem to setup the update shader
  20612. * @param effect defines the update shader
  20613. */
  20614. applyToShader(effect: Effect): void;
  20615. /**
  20616. * Returns a string to use to update the GPU particles update shader
  20617. * @returns a string containng the defines string
  20618. */
  20619. getEffectDefines(): string;
  20620. /**
  20621. * Returns the string "PointParticleEmitter"
  20622. * @returns a string containing the class name
  20623. */
  20624. getClassName(): string;
  20625. /**
  20626. * Serializes the particle system to a JSON object.
  20627. * @returns the JSON object
  20628. */
  20629. serialize(): any;
  20630. /**
  20631. * Parse properties from a JSON object
  20632. * @param serializationObject defines the JSON object
  20633. */
  20634. parse(serializationObject: any): void;
  20635. }
  20636. }
  20637. declare module BABYLON {
  20638. /**
  20639. * Particle emitter emitting particles from the inside of a sphere.
  20640. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  20641. */
  20642. export class SphereParticleEmitter implements IParticleEmitterType {
  20643. /**
  20644. * The radius of the emission sphere.
  20645. */
  20646. radius: number;
  20647. /**
  20648. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20649. */
  20650. radiusRange: number;
  20651. /**
  20652. * How much to randomize the particle direction [0-1].
  20653. */
  20654. directionRandomizer: number;
  20655. /**
  20656. * Creates a new instance SphereParticleEmitter
  20657. * @param radius the radius of the emission sphere (1 by default)
  20658. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20659. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20660. */
  20661. constructor(
  20662. /**
  20663. * The radius of the emission sphere.
  20664. */
  20665. radius?: number,
  20666. /**
  20667. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20668. */
  20669. radiusRange?: number,
  20670. /**
  20671. * How much to randomize the particle direction [0-1].
  20672. */
  20673. directionRandomizer?: number);
  20674. /**
  20675. * Called by the particle System when the direction is computed for the created particle.
  20676. * @param worldMatrix is the world matrix of the particle system
  20677. * @param directionToUpdate is the direction vector to update with the result
  20678. * @param particle is the particle we are computed the direction for
  20679. */
  20680. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20681. /**
  20682. * Called by the particle System when the position is computed for the created particle.
  20683. * @param worldMatrix is the world matrix of the particle system
  20684. * @param positionToUpdate is the position vector to update with the result
  20685. * @param particle is the particle we are computed the position for
  20686. */
  20687. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20688. /**
  20689. * Clones the current emitter and returns a copy of it
  20690. * @returns the new emitter
  20691. */
  20692. clone(): SphereParticleEmitter;
  20693. /**
  20694. * Called by the GPUParticleSystem to setup the update shader
  20695. * @param effect defines the update shader
  20696. */
  20697. applyToShader(effect: Effect): void;
  20698. /**
  20699. * Returns a string to use to update the GPU particles update shader
  20700. * @returns a string containng the defines string
  20701. */
  20702. getEffectDefines(): string;
  20703. /**
  20704. * Returns the string "SphereParticleEmitter"
  20705. * @returns a string containing the class name
  20706. */
  20707. getClassName(): string;
  20708. /**
  20709. * Serializes the particle system to a JSON object.
  20710. * @returns the JSON object
  20711. */
  20712. serialize(): any;
  20713. /**
  20714. * Parse properties from a JSON object
  20715. * @param serializationObject defines the JSON object
  20716. */
  20717. parse(serializationObject: any): void;
  20718. }
  20719. /**
  20720. * Particle emitter emitting particles from the inside of a sphere.
  20721. * It emits the particles randomly between two vectors.
  20722. */
  20723. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  20724. /**
  20725. * The min limit of the emission direction.
  20726. */
  20727. direction1: Vector3;
  20728. /**
  20729. * The max limit of the emission direction.
  20730. */
  20731. direction2: Vector3;
  20732. /**
  20733. * Creates a new instance SphereDirectedParticleEmitter
  20734. * @param radius the radius of the emission sphere (1 by default)
  20735. * @param direction1 the min limit of the emission direction (up vector by default)
  20736. * @param direction2 the max limit of the emission direction (up vector by default)
  20737. */
  20738. constructor(radius?: number,
  20739. /**
  20740. * The min limit of the emission direction.
  20741. */
  20742. direction1?: Vector3,
  20743. /**
  20744. * The max limit of the emission direction.
  20745. */
  20746. direction2?: Vector3);
  20747. /**
  20748. * Called by the particle System when the direction is computed for the created particle.
  20749. * @param worldMatrix is the world matrix of the particle system
  20750. * @param directionToUpdate is the direction vector to update with the result
  20751. * @param particle is the particle we are computed the direction for
  20752. */
  20753. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20754. /**
  20755. * Clones the current emitter and returns a copy of it
  20756. * @returns the new emitter
  20757. */
  20758. clone(): SphereDirectedParticleEmitter;
  20759. /**
  20760. * Called by the GPUParticleSystem to setup the update shader
  20761. * @param effect defines the update shader
  20762. */
  20763. applyToShader(effect: Effect): void;
  20764. /**
  20765. * Returns a string to use to update the GPU particles update shader
  20766. * @returns a string containng the defines string
  20767. */
  20768. getEffectDefines(): string;
  20769. /**
  20770. * Returns the string "SphereDirectedParticleEmitter"
  20771. * @returns a string containing the class name
  20772. */
  20773. getClassName(): string;
  20774. /**
  20775. * Serializes the particle system to a JSON object.
  20776. * @returns the JSON object
  20777. */
  20778. serialize(): any;
  20779. /**
  20780. * Parse properties from a JSON object
  20781. * @param serializationObject defines the JSON object
  20782. */
  20783. parse(serializationObject: any): void;
  20784. }
  20785. }
  20786. declare module BABYLON {
  20787. /**
  20788. * Interface representing a particle system in Babylon.js.
  20789. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  20790. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  20791. */
  20792. export interface IParticleSystem {
  20793. /**
  20794. * List of animations used by the particle system.
  20795. */
  20796. animations: Animation[];
  20797. /**
  20798. * The id of the Particle system.
  20799. */
  20800. id: string;
  20801. /**
  20802. * The name of the Particle system.
  20803. */
  20804. name: string;
  20805. /**
  20806. * The emitter represents the Mesh or position we are attaching the particle system to.
  20807. */
  20808. emitter: Nullable<AbstractMesh | Vector3>;
  20809. /**
  20810. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  20811. */
  20812. isBillboardBased: boolean;
  20813. /**
  20814. * The rendering group used by the Particle system to chose when to render.
  20815. */
  20816. renderingGroupId: number;
  20817. /**
  20818. * The layer mask we are rendering the particles through.
  20819. */
  20820. layerMask: number;
  20821. /**
  20822. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  20823. */
  20824. updateSpeed: number;
  20825. /**
  20826. * The amount of time the particle system is running (depends of the overall update speed).
  20827. */
  20828. targetStopDuration: number;
  20829. /**
  20830. * The texture used to render each particle. (this can be a spritesheet)
  20831. */
  20832. particleTexture: Nullable<Texture>;
  20833. /**
  20834. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  20835. */
  20836. blendMode: number;
  20837. /**
  20838. * Minimum life time of emitting particles.
  20839. */
  20840. minLifeTime: number;
  20841. /**
  20842. * Maximum life time of emitting particles.
  20843. */
  20844. maxLifeTime: number;
  20845. /**
  20846. * Minimum Size of emitting particles.
  20847. */
  20848. minSize: number;
  20849. /**
  20850. * Maximum Size of emitting particles.
  20851. */
  20852. maxSize: number;
  20853. /**
  20854. * Minimum scale of emitting particles on X axis.
  20855. */
  20856. minScaleX: number;
  20857. /**
  20858. * Maximum scale of emitting particles on X axis.
  20859. */
  20860. maxScaleX: number;
  20861. /**
  20862. * Minimum scale of emitting particles on Y axis.
  20863. */
  20864. minScaleY: number;
  20865. /**
  20866. * Maximum scale of emitting particles on Y axis.
  20867. */
  20868. maxScaleY: number;
  20869. /**
  20870. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20871. */
  20872. color1: Color4;
  20873. /**
  20874. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20875. */
  20876. color2: Color4;
  20877. /**
  20878. * Color the particle will have at the end of its lifetime.
  20879. */
  20880. colorDead: Color4;
  20881. /**
  20882. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  20883. */
  20884. emitRate: number;
  20885. /**
  20886. * You can use gravity if you want to give an orientation to your particles.
  20887. */
  20888. gravity: Vector3;
  20889. /**
  20890. * Minimum power of emitting particles.
  20891. */
  20892. minEmitPower: number;
  20893. /**
  20894. * Maximum power of emitting particles.
  20895. */
  20896. maxEmitPower: number;
  20897. /**
  20898. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  20899. */
  20900. minAngularSpeed: number;
  20901. /**
  20902. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  20903. */
  20904. maxAngularSpeed: number;
  20905. /**
  20906. * Gets or sets the minimal initial rotation in radians.
  20907. */
  20908. minInitialRotation: number;
  20909. /**
  20910. * Gets or sets the maximal initial rotation in radians.
  20911. */
  20912. maxInitialRotation: number;
  20913. /**
  20914. * The particle emitter type defines the emitter used by the particle system.
  20915. * It can be for example box, sphere, or cone...
  20916. */
  20917. particleEmitterType: Nullable<IParticleEmitterType>;
  20918. /**
  20919. * Defines the delay in milliseconds before starting the system (0 by default)
  20920. */
  20921. startDelay: number;
  20922. /**
  20923. * 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
  20924. */
  20925. preWarmCycles: number;
  20926. /**
  20927. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  20928. */
  20929. preWarmStepOffset: number;
  20930. /**
  20931. * 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)
  20932. */
  20933. spriteCellChangeSpeed: number;
  20934. /**
  20935. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  20936. */
  20937. startSpriteCellID: number;
  20938. /**
  20939. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  20940. */
  20941. endSpriteCellID: number;
  20942. /**
  20943. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  20944. */
  20945. spriteCellWidth: number;
  20946. /**
  20947. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  20948. */
  20949. spriteCellHeight: number;
  20950. /**
  20951. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  20952. */
  20953. spriteRandomStartCell: boolean;
  20954. /**
  20955. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  20956. */
  20957. isAnimationSheetEnabled: boolean;
  20958. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  20959. translationPivot: Vector2;
  20960. /**
  20961. * Gets or sets a texture used to add random noise to particle positions
  20962. */
  20963. noiseTexture: Nullable<BaseTexture>;
  20964. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  20965. noiseStrength: Vector3;
  20966. /**
  20967. * Gets or sets the billboard mode to use when isBillboardBased = true.
  20968. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  20969. */
  20970. billboardMode: number;
  20971. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  20972. limitVelocityDamping: number;
  20973. /**
  20974. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  20975. */
  20976. beginAnimationOnStart: boolean;
  20977. /**
  20978. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  20979. */
  20980. beginAnimationFrom: number;
  20981. /**
  20982. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  20983. */
  20984. beginAnimationTo: number;
  20985. /**
  20986. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  20987. */
  20988. beginAnimationLoop: boolean;
  20989. /**
  20990. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  20991. */
  20992. disposeOnStop: boolean;
  20993. /**
  20994. * Gets the maximum number of particles active at the same time.
  20995. * @returns The max number of active particles.
  20996. */
  20997. getCapacity(): number;
  20998. /**
  20999. * Gets if the system has been started. (Note: this will still be true after stop is called)
  21000. * @returns True if it has been started, otherwise false.
  21001. */
  21002. isStarted(): boolean;
  21003. /**
  21004. * Animates the particle system for this frame.
  21005. */
  21006. animate(): void;
  21007. /**
  21008. * Renders the particle system in its current state.
  21009. * @returns the current number of particles
  21010. */
  21011. render(): number;
  21012. /**
  21013. * Dispose the particle system and frees its associated resources.
  21014. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21015. */
  21016. dispose(disposeTexture?: boolean): void;
  21017. /**
  21018. * Clones the particle system.
  21019. * @param name The name of the cloned object
  21020. * @param newEmitter The new emitter to use
  21021. * @returns the cloned particle system
  21022. */
  21023. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21024. /**
  21025. * Serializes the particle system to a JSON object.
  21026. * @returns the JSON object
  21027. */
  21028. serialize(): any;
  21029. /**
  21030. * Rebuild the particle system
  21031. */
  21032. rebuild(): void;
  21033. /**
  21034. * Starts the particle system and begins to emit
  21035. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21036. */
  21037. start(delay?: number): void;
  21038. /**
  21039. * Stops the particle system.
  21040. */
  21041. stop(): void;
  21042. /**
  21043. * Remove all active particles
  21044. */
  21045. reset(): void;
  21046. /**
  21047. * Is this system ready to be used/rendered
  21048. * @return true if the system is ready
  21049. */
  21050. isReady(): boolean;
  21051. /**
  21052. * Adds a new color gradient
  21053. * @param gradient defines the gradient to use (between 0 and 1)
  21054. * @param color1 defines the color to affect to the specified gradient
  21055. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21056. * @returns the current particle system
  21057. */
  21058. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21059. /**
  21060. * Remove a specific color gradient
  21061. * @param gradient defines the gradient to remove
  21062. * @returns the current particle system
  21063. */
  21064. removeColorGradient(gradient: number): IParticleSystem;
  21065. /**
  21066. * Adds a new size gradient
  21067. * @param gradient defines the gradient to use (between 0 and 1)
  21068. * @param factor defines the size factor to affect to the specified gradient
  21069. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21070. * @returns the current particle system
  21071. */
  21072. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21073. /**
  21074. * Remove a specific size gradient
  21075. * @param gradient defines the gradient to remove
  21076. * @returns the current particle system
  21077. */
  21078. removeSizeGradient(gradient: number): IParticleSystem;
  21079. /**
  21080. * Gets the current list of color gradients.
  21081. * You must use addColorGradient and removeColorGradient to udpate this list
  21082. * @returns the list of color gradients
  21083. */
  21084. getColorGradients(): Nullable<Array<ColorGradient>>;
  21085. /**
  21086. * Gets the current list of size gradients.
  21087. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21088. * @returns the list of size gradients
  21089. */
  21090. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21091. /**
  21092. * Gets the current list of angular speed gradients.
  21093. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21094. * @returns the list of angular speed gradients
  21095. */
  21096. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21097. /**
  21098. * Adds a new angular speed gradient
  21099. * @param gradient defines the gradient to use (between 0 and 1)
  21100. * @param factor defines the angular speed to affect to the specified gradient
  21101. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21102. * @returns the current particle system
  21103. */
  21104. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21105. /**
  21106. * Remove a specific angular speed gradient
  21107. * @param gradient defines the gradient to remove
  21108. * @returns the current particle system
  21109. */
  21110. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21111. /**
  21112. * Gets the current list of velocity gradients.
  21113. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21114. * @returns the list of velocity gradients
  21115. */
  21116. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21117. /**
  21118. * Adds a new velocity gradient
  21119. * @param gradient defines the gradient to use (between 0 and 1)
  21120. * @param factor defines the velocity to affect to the specified gradient
  21121. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21122. * @returns the current particle system
  21123. */
  21124. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21125. /**
  21126. * Remove a specific velocity gradient
  21127. * @param gradient defines the gradient to remove
  21128. * @returns the current particle system
  21129. */
  21130. removeVelocityGradient(gradient: number): IParticleSystem;
  21131. /**
  21132. * Gets the current list of limit velocity gradients.
  21133. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21134. * @returns the list of limit velocity gradients
  21135. */
  21136. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21137. /**
  21138. * Adds a new limit velocity gradient
  21139. * @param gradient defines the gradient to use (between 0 and 1)
  21140. * @param factor defines the limit velocity to affect to the specified gradient
  21141. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21142. * @returns the current particle system
  21143. */
  21144. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21145. /**
  21146. * Remove a specific limit velocity gradient
  21147. * @param gradient defines the gradient to remove
  21148. * @returns the current particle system
  21149. */
  21150. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21151. /**
  21152. * Adds a new drag gradient
  21153. * @param gradient defines the gradient to use (between 0 and 1)
  21154. * @param factor defines the drag to affect to the specified gradient
  21155. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21156. * @returns the current particle system
  21157. */
  21158. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21159. /**
  21160. * Remove a specific drag gradient
  21161. * @param gradient defines the gradient to remove
  21162. * @returns the current particle system
  21163. */
  21164. removeDragGradient(gradient: number): IParticleSystem;
  21165. /**
  21166. * Gets the current list of drag gradients.
  21167. * You must use addDragGradient and removeDragGradient to udpate this list
  21168. * @returns the list of drag gradients
  21169. */
  21170. getDragGradients(): Nullable<Array<FactorGradient>>;
  21171. /**
  21172. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21173. * @param gradient defines the gradient to use (between 0 and 1)
  21174. * @param factor defines the emit rate to affect to the specified gradient
  21175. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21176. * @returns the current particle system
  21177. */
  21178. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21179. /**
  21180. * Remove a specific emit rate gradient
  21181. * @param gradient defines the gradient to remove
  21182. * @returns the current particle system
  21183. */
  21184. removeEmitRateGradient(gradient: number): IParticleSystem;
  21185. /**
  21186. * Gets the current list of emit rate gradients.
  21187. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21188. * @returns the list of emit rate gradients
  21189. */
  21190. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21191. /**
  21192. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21193. * @param gradient defines the gradient to use (between 0 and 1)
  21194. * @param factor defines the start size to affect to the specified gradient
  21195. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21196. * @returns the current particle system
  21197. */
  21198. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21199. /**
  21200. * Remove a specific start size gradient
  21201. * @param gradient defines the gradient to remove
  21202. * @returns the current particle system
  21203. */
  21204. removeStartSizeGradient(gradient: number): IParticleSystem;
  21205. /**
  21206. * Gets the current list of start size gradients.
  21207. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21208. * @returns the list of start size gradients
  21209. */
  21210. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21211. /**
  21212. * Adds a new life time gradient
  21213. * @param gradient defines the gradient to use (between 0 and 1)
  21214. * @param factor defines the life time factor to affect to the specified gradient
  21215. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21216. * @returns the current particle system
  21217. */
  21218. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21219. /**
  21220. * Remove a specific life time gradient
  21221. * @param gradient defines the gradient to remove
  21222. * @returns the current particle system
  21223. */
  21224. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21225. /**
  21226. * Gets the current list of life time gradients.
  21227. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21228. * @returns the list of life time gradients
  21229. */
  21230. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21231. /**
  21232. * Gets the current list of color gradients.
  21233. * You must use addColorGradient and removeColorGradient to udpate this list
  21234. * @returns the list of color gradients
  21235. */
  21236. getColorGradients(): Nullable<Array<ColorGradient>>;
  21237. /**
  21238. * Adds a new ramp gradient used to remap particle colors
  21239. * @param gradient defines the gradient to use (between 0 and 1)
  21240. * @param color defines the color to affect to the specified gradient
  21241. * @returns the current particle system
  21242. */
  21243. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21244. /**
  21245. * Gets the current list of ramp gradients.
  21246. * You must use addRampGradient and removeRampGradient to udpate this list
  21247. * @returns the list of ramp gradients
  21248. */
  21249. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21250. /** Gets or sets a boolean indicating that ramp gradients must be used
  21251. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21252. */
  21253. useRampGradients: boolean;
  21254. /**
  21255. * Adds a new color remap gradient
  21256. * @param gradient defines the gradient to use (between 0 and 1)
  21257. * @param min defines the color remap minimal range
  21258. * @param max defines the color remap maximal range
  21259. * @returns the current particle system
  21260. */
  21261. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21262. /**
  21263. * Gets the current list of color remap gradients.
  21264. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21265. * @returns the list of color remap gradients
  21266. */
  21267. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21268. /**
  21269. * Adds a new alpha remap gradient
  21270. * @param gradient defines the gradient to use (between 0 and 1)
  21271. * @param min defines the alpha remap minimal range
  21272. * @param max defines the alpha remap maximal range
  21273. * @returns the current particle system
  21274. */
  21275. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21276. /**
  21277. * Gets the current list of alpha remap gradients.
  21278. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21279. * @returns the list of alpha remap gradients
  21280. */
  21281. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21282. /**
  21283. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21284. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21285. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21286. * @returns the emitter
  21287. */
  21288. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21289. /**
  21290. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21291. * @param radius The radius of the hemisphere to emit from
  21292. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21293. * @returns the emitter
  21294. */
  21295. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21296. /**
  21297. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21298. * @param radius The radius of the sphere to emit from
  21299. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21300. * @returns the emitter
  21301. */
  21302. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21303. /**
  21304. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21305. * @param radius The radius of the sphere to emit from
  21306. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21307. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21308. * @returns the emitter
  21309. */
  21310. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21311. /**
  21312. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21313. * @param radius The radius of the emission cylinder
  21314. * @param height The height of the emission cylinder
  21315. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21316. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21317. * @returns the emitter
  21318. */
  21319. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21320. /**
  21321. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21322. * @param radius The radius of the cylinder to emit from
  21323. * @param height The height of the emission cylinder
  21324. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21325. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21326. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21327. * @returns the emitter
  21328. */
  21329. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21330. /**
  21331. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21332. * @param radius The radius of the cone to emit from
  21333. * @param angle The base angle of the cone
  21334. * @returns the emitter
  21335. */
  21336. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21337. /**
  21338. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21339. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21340. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21341. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21342. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21343. * @returns the emitter
  21344. */
  21345. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21346. /**
  21347. * Get hosting scene
  21348. * @returns the scene
  21349. */
  21350. getScene(): Scene;
  21351. }
  21352. }
  21353. declare module BABYLON {
  21354. /** @hidden */
  21355. export var linePixelShader: {
  21356. name: string;
  21357. shader: string;
  21358. };
  21359. }
  21360. declare module BABYLON {
  21361. /** @hidden */
  21362. export var lineVertexShader: {
  21363. name: string;
  21364. shader: string;
  21365. };
  21366. }
  21367. declare module BABYLON {
  21368. interface AbstractMesh {
  21369. /**
  21370. * Gets the edgesRenderer associated with the mesh
  21371. */
  21372. edgesRenderer: Nullable<EdgesRenderer>;
  21373. }
  21374. interface LinesMesh {
  21375. /**
  21376. * Enables the edge rendering mode on the mesh.
  21377. * This mode makes the mesh edges visible
  21378. * @param epsilon defines the maximal distance between two angles to detect a face
  21379. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21380. * @returns the currentAbstractMesh
  21381. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21382. */
  21383. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21384. }
  21385. interface InstancedLinesMesh {
  21386. /**
  21387. * Enables the edge rendering mode on the mesh.
  21388. * This mode makes the mesh edges visible
  21389. * @param epsilon defines the maximal distance between two angles to detect a face
  21390. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21391. * @returns the current InstancedLinesMesh
  21392. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21393. */
  21394. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21395. }
  21396. /**
  21397. * Defines the minimum contract an Edges renderer should follow.
  21398. */
  21399. export interface IEdgesRenderer extends IDisposable {
  21400. /**
  21401. * Gets or sets a boolean indicating if the edgesRenderer is active
  21402. */
  21403. isEnabled: boolean;
  21404. /**
  21405. * Renders the edges of the attached mesh,
  21406. */
  21407. render(): void;
  21408. /**
  21409. * Checks wether or not the edges renderer is ready to render.
  21410. * @return true if ready, otherwise false.
  21411. */
  21412. isReady(): boolean;
  21413. }
  21414. /**
  21415. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  21416. */
  21417. export class EdgesRenderer implements IEdgesRenderer {
  21418. /**
  21419. * Define the size of the edges with an orthographic camera
  21420. */
  21421. edgesWidthScalerForOrthographic: number;
  21422. /**
  21423. * Define the size of the edges with a perspective camera
  21424. */
  21425. edgesWidthScalerForPerspective: number;
  21426. protected _source: AbstractMesh;
  21427. protected _linesPositions: number[];
  21428. protected _linesNormals: number[];
  21429. protected _linesIndices: number[];
  21430. protected _epsilon: number;
  21431. protected _indicesCount: number;
  21432. protected _lineShader: ShaderMaterial;
  21433. protected _ib: DataBuffer;
  21434. protected _buffers: {
  21435. [key: string]: Nullable<VertexBuffer>;
  21436. };
  21437. protected _checkVerticesInsteadOfIndices: boolean;
  21438. private _meshRebuildObserver;
  21439. private _meshDisposeObserver;
  21440. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  21441. isEnabled: boolean;
  21442. /**
  21443. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  21444. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  21445. * @param source Mesh used to create edges
  21446. * @param epsilon sum of angles in adjacency to check for edge
  21447. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  21448. * @param generateEdgesLines - should generate Lines or only prepare resources.
  21449. */
  21450. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  21451. protected _prepareRessources(): void;
  21452. /** @hidden */
  21453. _rebuild(): void;
  21454. /**
  21455. * Releases the required resources for the edges renderer
  21456. */
  21457. dispose(): void;
  21458. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  21459. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  21460. /**
  21461. * Checks if the pair of p0 and p1 is en edge
  21462. * @param faceIndex
  21463. * @param edge
  21464. * @param faceNormals
  21465. * @param p0
  21466. * @param p1
  21467. * @private
  21468. */
  21469. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  21470. /**
  21471. * push line into the position, normal and index buffer
  21472. * @protected
  21473. */
  21474. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  21475. /**
  21476. * Generates lines edges from adjacencjes
  21477. * @private
  21478. */
  21479. _generateEdgesLines(): void;
  21480. /**
  21481. * Checks wether or not the edges renderer is ready to render.
  21482. * @return true if ready, otherwise false.
  21483. */
  21484. isReady(): boolean;
  21485. /**
  21486. * Renders the edges of the attached mesh,
  21487. */
  21488. render(): void;
  21489. }
  21490. /**
  21491. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  21492. */
  21493. export class LineEdgesRenderer extends EdgesRenderer {
  21494. /**
  21495. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  21496. * @param source LineMesh used to generate edges
  21497. * @param epsilon not important (specified angle for edge detection)
  21498. * @param checkVerticesInsteadOfIndices not important for LineMesh
  21499. */
  21500. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  21501. /**
  21502. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  21503. */
  21504. _generateEdgesLines(): void;
  21505. }
  21506. }
  21507. declare module BABYLON {
  21508. /**
  21509. * This represents the object necessary to create a rendering group.
  21510. * This is exclusively used and created by the rendering manager.
  21511. * To modify the behavior, you use the available helpers in your scene or meshes.
  21512. * @hidden
  21513. */
  21514. export class RenderingGroup {
  21515. index: number;
  21516. private static _zeroVector;
  21517. private _scene;
  21518. private _opaqueSubMeshes;
  21519. private _transparentSubMeshes;
  21520. private _alphaTestSubMeshes;
  21521. private _depthOnlySubMeshes;
  21522. private _particleSystems;
  21523. private _spriteManagers;
  21524. private _opaqueSortCompareFn;
  21525. private _alphaTestSortCompareFn;
  21526. private _transparentSortCompareFn;
  21527. private _renderOpaque;
  21528. private _renderAlphaTest;
  21529. private _renderTransparent;
  21530. /** @hidden */
  21531. _edgesRenderers: SmartArray<IEdgesRenderer>;
  21532. onBeforeTransparentRendering: () => void;
  21533. /**
  21534. * Set the opaque sort comparison function.
  21535. * If null the sub meshes will be render in the order they were created
  21536. */
  21537. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21538. /**
  21539. * Set the alpha test sort comparison function.
  21540. * If null the sub meshes will be render in the order they were created
  21541. */
  21542. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21543. /**
  21544. * Set the transparent sort comparison function.
  21545. * If null the sub meshes will be render in the order they were created
  21546. */
  21547. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21548. /**
  21549. * Creates a new rendering group.
  21550. * @param index The rendering group index
  21551. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  21552. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  21553. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  21554. */
  21555. 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>);
  21556. /**
  21557. * Render all the sub meshes contained in the group.
  21558. * @param customRenderFunction Used to override the default render behaviour of the group.
  21559. * @returns true if rendered some submeshes.
  21560. */
  21561. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  21562. /**
  21563. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  21564. * @param subMeshes The submeshes to render
  21565. */
  21566. private renderOpaqueSorted;
  21567. /**
  21568. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  21569. * @param subMeshes The submeshes to render
  21570. */
  21571. private renderAlphaTestSorted;
  21572. /**
  21573. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  21574. * @param subMeshes The submeshes to render
  21575. */
  21576. private renderTransparentSorted;
  21577. /**
  21578. * Renders the submeshes in a specified order.
  21579. * @param subMeshes The submeshes to sort before render
  21580. * @param sortCompareFn The comparison function use to sort
  21581. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  21582. * @param transparent Specifies to activate blending if true
  21583. */
  21584. private static renderSorted;
  21585. /**
  21586. * Renders the submeshes in the order they were dispatched (no sort applied).
  21587. * @param subMeshes The submeshes to render
  21588. */
  21589. private static renderUnsorted;
  21590. /**
  21591. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21592. * are rendered back to front if in the same alpha index.
  21593. *
  21594. * @param a The first submesh
  21595. * @param b The second submesh
  21596. * @returns The result of the comparison
  21597. */
  21598. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  21599. /**
  21600. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21601. * are rendered back to front.
  21602. *
  21603. * @param a The first submesh
  21604. * @param b The second submesh
  21605. * @returns The result of the comparison
  21606. */
  21607. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  21608. /**
  21609. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21610. * are rendered front to back (prevent overdraw).
  21611. *
  21612. * @param a The first submesh
  21613. * @param b The second submesh
  21614. * @returns The result of the comparison
  21615. */
  21616. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  21617. /**
  21618. * Resets the different lists of submeshes to prepare a new frame.
  21619. */
  21620. prepare(): void;
  21621. dispose(): void;
  21622. /**
  21623. * Inserts the submesh in its correct queue depending on its material.
  21624. * @param subMesh The submesh to dispatch
  21625. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21626. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21627. */
  21628. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21629. dispatchSprites(spriteManager: ISpriteManager): void;
  21630. dispatchParticles(particleSystem: IParticleSystem): void;
  21631. private _renderParticles;
  21632. private _renderSprites;
  21633. }
  21634. }
  21635. declare module BABYLON {
  21636. /**
  21637. * Interface describing the different options available in the rendering manager
  21638. * regarding Auto Clear between groups.
  21639. */
  21640. export interface IRenderingManagerAutoClearSetup {
  21641. /**
  21642. * Defines whether or not autoclear is enable.
  21643. */
  21644. autoClear: boolean;
  21645. /**
  21646. * Defines whether or not to autoclear the depth buffer.
  21647. */
  21648. depth: boolean;
  21649. /**
  21650. * Defines whether or not to autoclear the stencil buffer.
  21651. */
  21652. stencil: boolean;
  21653. }
  21654. /**
  21655. * This class is used by the onRenderingGroupObservable
  21656. */
  21657. export class RenderingGroupInfo {
  21658. /**
  21659. * The Scene that being rendered
  21660. */
  21661. scene: Scene;
  21662. /**
  21663. * The camera currently used for the rendering pass
  21664. */
  21665. camera: Nullable<Camera>;
  21666. /**
  21667. * The ID of the renderingGroup being processed
  21668. */
  21669. renderingGroupId: number;
  21670. }
  21671. /**
  21672. * This is the manager responsible of all the rendering for meshes sprites and particles.
  21673. * It is enable to manage the different groups as well as the different necessary sort functions.
  21674. * This should not be used directly aside of the few static configurations
  21675. */
  21676. export class RenderingManager {
  21677. /**
  21678. * The max id used for rendering groups (not included)
  21679. */
  21680. static MAX_RENDERINGGROUPS: number;
  21681. /**
  21682. * The min id used for rendering groups (included)
  21683. */
  21684. static MIN_RENDERINGGROUPS: number;
  21685. /**
  21686. * Used to globally prevent autoclearing scenes.
  21687. */
  21688. static AUTOCLEAR: boolean;
  21689. /**
  21690. * @hidden
  21691. */
  21692. _useSceneAutoClearSetup: boolean;
  21693. private _scene;
  21694. private _renderingGroups;
  21695. private _depthStencilBufferAlreadyCleaned;
  21696. private _autoClearDepthStencil;
  21697. private _customOpaqueSortCompareFn;
  21698. private _customAlphaTestSortCompareFn;
  21699. private _customTransparentSortCompareFn;
  21700. private _renderingGroupInfo;
  21701. /**
  21702. * Instantiates a new rendering group for a particular scene
  21703. * @param scene Defines the scene the groups belongs to
  21704. */
  21705. constructor(scene: Scene);
  21706. private _clearDepthStencilBuffer;
  21707. /**
  21708. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  21709. * @hidden
  21710. */
  21711. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  21712. /**
  21713. * Resets the different information of the group to prepare a new frame
  21714. * @hidden
  21715. */
  21716. reset(): void;
  21717. /**
  21718. * Dispose and release the group and its associated resources.
  21719. * @hidden
  21720. */
  21721. dispose(): void;
  21722. /**
  21723. * Clear the info related to rendering groups preventing retention points during dispose.
  21724. */
  21725. freeRenderingGroups(): void;
  21726. private _prepareRenderingGroup;
  21727. /**
  21728. * Add a sprite manager to the rendering manager in order to render it this frame.
  21729. * @param spriteManager Define the sprite manager to render
  21730. */
  21731. dispatchSprites(spriteManager: ISpriteManager): void;
  21732. /**
  21733. * Add a particle system to the rendering manager in order to render it this frame.
  21734. * @param particleSystem Define the particle system to render
  21735. */
  21736. dispatchParticles(particleSystem: IParticleSystem): void;
  21737. /**
  21738. * Add a submesh to the manager in order to render it this frame
  21739. * @param subMesh The submesh to dispatch
  21740. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21741. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21742. */
  21743. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21744. /**
  21745. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21746. * This allowed control for front to back rendering or reversly depending of the special needs.
  21747. *
  21748. * @param renderingGroupId The rendering group id corresponding to its index
  21749. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21750. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21751. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21752. */
  21753. 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;
  21754. /**
  21755. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21756. *
  21757. * @param renderingGroupId The rendering group id corresponding to its index
  21758. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21759. * @param depth Automatically clears depth between groups if true and autoClear is true.
  21760. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  21761. */
  21762. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  21763. /**
  21764. * Gets the current auto clear configuration for one rendering group of the rendering
  21765. * manager.
  21766. * @param index the rendering group index to get the information for
  21767. * @returns The auto clear setup for the requested rendering group
  21768. */
  21769. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  21770. }
  21771. }
  21772. declare module BABYLON {
  21773. /**
  21774. * This Helps creating a texture that will be created from a camera in your scene.
  21775. * It is basically a dynamic texture that could be used to create special effects for instance.
  21776. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21777. */
  21778. export class RenderTargetTexture extends Texture {
  21779. isCube: boolean;
  21780. /**
  21781. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21782. */
  21783. static readonly REFRESHRATE_RENDER_ONCE: number;
  21784. /**
  21785. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21786. */
  21787. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21788. /**
  21789. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21790. * the central point of your effect and can save a lot of performances.
  21791. */
  21792. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21793. /**
  21794. * Use this predicate to dynamically define the list of mesh you want to render.
  21795. * If set, the renderList property will be overwritten.
  21796. */
  21797. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21798. private _renderList;
  21799. /**
  21800. * Use this list to define the list of mesh you want to render.
  21801. */
  21802. renderList: Nullable<Array<AbstractMesh>>;
  21803. private _hookArray;
  21804. /**
  21805. * Define if particles should be rendered in your texture.
  21806. */
  21807. renderParticles: boolean;
  21808. /**
  21809. * Define if sprites should be rendered in your texture.
  21810. */
  21811. renderSprites: boolean;
  21812. /**
  21813. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21814. */
  21815. coordinatesMode: number;
  21816. /**
  21817. * Define the camera used to render the texture.
  21818. */
  21819. activeCamera: Nullable<Camera>;
  21820. /**
  21821. * Override the render function of the texture with your own one.
  21822. */
  21823. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21824. /**
  21825. * Define if camera post processes should be use while rendering the texture.
  21826. */
  21827. useCameraPostProcesses: boolean;
  21828. /**
  21829. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21830. */
  21831. ignoreCameraViewport: boolean;
  21832. private _postProcessManager;
  21833. private _postProcesses;
  21834. private _resizeObserver;
  21835. /**
  21836. * An event triggered when the texture is unbind.
  21837. */
  21838. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21839. /**
  21840. * An event triggered when the texture is unbind.
  21841. */
  21842. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21843. private _onAfterUnbindObserver;
  21844. /**
  21845. * Set a after unbind callback in the texture.
  21846. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21847. */
  21848. onAfterUnbind: () => void;
  21849. /**
  21850. * An event triggered before rendering the texture
  21851. */
  21852. onBeforeRenderObservable: Observable<number>;
  21853. private _onBeforeRenderObserver;
  21854. /**
  21855. * Set a before render callback in the texture.
  21856. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21857. */
  21858. onBeforeRender: (faceIndex: number) => void;
  21859. /**
  21860. * An event triggered after rendering the texture
  21861. */
  21862. onAfterRenderObservable: Observable<number>;
  21863. private _onAfterRenderObserver;
  21864. /**
  21865. * Set a after render callback in the texture.
  21866. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21867. */
  21868. onAfterRender: (faceIndex: number) => void;
  21869. /**
  21870. * An event triggered after the texture clear
  21871. */
  21872. onClearObservable: Observable<Engine>;
  21873. private _onClearObserver;
  21874. /**
  21875. * Set a clear callback in the texture.
  21876. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21877. */
  21878. onClear: (Engine: Engine) => void;
  21879. /**
  21880. * Define the clear color of the Render Target if it should be different from the scene.
  21881. */
  21882. clearColor: Color4;
  21883. protected _size: number | {
  21884. width: number;
  21885. height: number;
  21886. };
  21887. protected _initialSizeParameter: number | {
  21888. width: number;
  21889. height: number;
  21890. } | {
  21891. ratio: number;
  21892. };
  21893. protected _sizeRatio: Nullable<number>;
  21894. /** @hidden */
  21895. _generateMipMaps: boolean;
  21896. protected _renderingManager: RenderingManager;
  21897. /** @hidden */
  21898. _waitingRenderList: string[];
  21899. protected _doNotChangeAspectRatio: boolean;
  21900. protected _currentRefreshId: number;
  21901. protected _refreshRate: number;
  21902. protected _textureMatrix: Matrix;
  21903. protected _samples: number;
  21904. protected _renderTargetOptions: RenderTargetCreationOptions;
  21905. /**
  21906. * Gets render target creation options that were used.
  21907. */
  21908. readonly renderTargetOptions: RenderTargetCreationOptions;
  21909. protected _engine: Engine;
  21910. protected _onRatioRescale(): void;
  21911. /**
  21912. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21913. * It must define where the camera used to render the texture is set
  21914. */
  21915. boundingBoxPosition: Vector3;
  21916. private _boundingBoxSize;
  21917. /**
  21918. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21919. * When defined, the cubemap will switch to local mode
  21920. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21921. * @example https://www.babylonjs-playground.com/#RNASML
  21922. */
  21923. boundingBoxSize: Vector3;
  21924. /**
  21925. * In case the RTT has been created with a depth texture, get the associated
  21926. * depth texture.
  21927. * Otherwise, return null.
  21928. */
  21929. depthStencilTexture: Nullable<InternalTexture>;
  21930. /**
  21931. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21932. * or used a shadow, depth texture...
  21933. * @param name The friendly name of the texture
  21934. * @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)
  21935. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21936. * @param generateMipMaps True if mip maps need to be generated after render.
  21937. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21938. * @param type The type of the buffer in the RTT (int, half float, float...)
  21939. * @param isCube True if a cube texture needs to be created
  21940. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21941. * @param generateDepthBuffer True to generate a depth buffer
  21942. * @param generateStencilBuffer True to generate a stencil buffer
  21943. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21944. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21945. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21946. */
  21947. constructor(name: string, size: number | {
  21948. width: number;
  21949. height: number;
  21950. } | {
  21951. ratio: number;
  21952. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21953. /**
  21954. * Creates a depth stencil texture.
  21955. * This is only available in WebGL 2 or with the depth texture extension available.
  21956. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21957. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21958. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21959. */
  21960. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21961. private _processSizeParameter;
  21962. /**
  21963. * Define the number of samples to use in case of MSAA.
  21964. * It defaults to one meaning no MSAA has been enabled.
  21965. */
  21966. samples: number;
  21967. /**
  21968. * Resets the refresh counter of the texture and start bak from scratch.
  21969. * Could be useful to regenerate the texture if it is setup to render only once.
  21970. */
  21971. resetRefreshCounter(): void;
  21972. /**
  21973. * Define the refresh rate of the texture or the rendering frequency.
  21974. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21975. */
  21976. refreshRate: number;
  21977. /**
  21978. * Adds a post process to the render target rendering passes.
  21979. * @param postProcess define the post process to add
  21980. */
  21981. addPostProcess(postProcess: PostProcess): void;
  21982. /**
  21983. * Clear all the post processes attached to the render target
  21984. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21985. */
  21986. clearPostProcesses(dispose?: boolean): void;
  21987. /**
  21988. * Remove one of the post process from the list of attached post processes to the texture
  21989. * @param postProcess define the post process to remove from the list
  21990. */
  21991. removePostProcess(postProcess: PostProcess): void;
  21992. /** @hidden */
  21993. _shouldRender(): boolean;
  21994. /**
  21995. * Gets the actual render size of the texture.
  21996. * @returns the width of the render size
  21997. */
  21998. getRenderSize(): number;
  21999. /**
  22000. * Gets the actual render width of the texture.
  22001. * @returns the width of the render size
  22002. */
  22003. getRenderWidth(): number;
  22004. /**
  22005. * Gets the actual render height of the texture.
  22006. * @returns the height of the render size
  22007. */
  22008. getRenderHeight(): number;
  22009. /**
  22010. * Get if the texture can be rescaled or not.
  22011. */
  22012. readonly canRescale: boolean;
  22013. /**
  22014. * Resize the texture using a ratio.
  22015. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  22016. */
  22017. scale(ratio: number): void;
  22018. /**
  22019. * Get the texture reflection matrix used to rotate/transform the reflection.
  22020. * @returns the reflection matrix
  22021. */
  22022. getReflectionTextureMatrix(): Matrix;
  22023. /**
  22024. * Resize the texture to a new desired size.
  22025. * Be carrefull as it will recreate all the data in the new texture.
  22026. * @param size Define the new size. It can be:
  22027. * - a number for squared texture,
  22028. * - an object containing { width: number, height: number }
  22029. * - or an object containing a ratio { ratio: number }
  22030. */
  22031. resize(size: number | {
  22032. width: number;
  22033. height: number;
  22034. } | {
  22035. ratio: number;
  22036. }): void;
  22037. /**
  22038. * Renders all the objects from the render list into the texture.
  22039. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  22040. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  22041. */
  22042. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  22043. private _bestReflectionRenderTargetDimension;
  22044. /**
  22045. * @hidden
  22046. * @param faceIndex face index to bind to if this is a cubetexture
  22047. */
  22048. _bindFrameBuffer(faceIndex?: number): void;
  22049. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22050. private renderToTarget;
  22051. /**
  22052. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22053. * This allowed control for front to back rendering or reversly depending of the special needs.
  22054. *
  22055. * @param renderingGroupId The rendering group id corresponding to its index
  22056. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22057. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22058. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22059. */
  22060. 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;
  22061. /**
  22062. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22063. *
  22064. * @param renderingGroupId The rendering group id corresponding to its index
  22065. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22066. */
  22067. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22068. /**
  22069. * Clones the texture.
  22070. * @returns the cloned texture
  22071. */
  22072. clone(): RenderTargetTexture;
  22073. /**
  22074. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  22075. * @returns The JSON representation of the texture
  22076. */
  22077. serialize(): any;
  22078. /**
  22079. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  22080. */
  22081. disposeFramebufferObjects(): void;
  22082. /**
  22083. * Dispose the texture and release its associated resources.
  22084. */
  22085. dispose(): void;
  22086. /** @hidden */
  22087. _rebuild(): void;
  22088. /**
  22089. * Clear the info related to rendering groups preventing retention point in material dispose.
  22090. */
  22091. freeRenderingGroups(): void;
  22092. /**
  22093. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22094. * @returns the view count
  22095. */
  22096. getViewCount(): number;
  22097. }
  22098. }
  22099. declare module BABYLON {
  22100. /**
  22101. * Base class for the main features of a material in Babylon.js
  22102. */
  22103. export class Material implements IAnimatable {
  22104. /**
  22105. * Returns the triangle fill mode
  22106. */
  22107. static readonly TriangleFillMode: number;
  22108. /**
  22109. * Returns the wireframe mode
  22110. */
  22111. static readonly WireFrameFillMode: number;
  22112. /**
  22113. * Returns the point fill mode
  22114. */
  22115. static readonly PointFillMode: number;
  22116. /**
  22117. * Returns the point list draw mode
  22118. */
  22119. static readonly PointListDrawMode: number;
  22120. /**
  22121. * Returns the line list draw mode
  22122. */
  22123. static readonly LineListDrawMode: number;
  22124. /**
  22125. * Returns the line loop draw mode
  22126. */
  22127. static readonly LineLoopDrawMode: number;
  22128. /**
  22129. * Returns the line strip draw mode
  22130. */
  22131. static readonly LineStripDrawMode: number;
  22132. /**
  22133. * Returns the triangle strip draw mode
  22134. */
  22135. static readonly TriangleStripDrawMode: number;
  22136. /**
  22137. * Returns the triangle fan draw mode
  22138. */
  22139. static readonly TriangleFanDrawMode: number;
  22140. /**
  22141. * Stores the clock-wise side orientation
  22142. */
  22143. static readonly ClockWiseSideOrientation: number;
  22144. /**
  22145. * Stores the counter clock-wise side orientation
  22146. */
  22147. static readonly CounterClockWiseSideOrientation: number;
  22148. /**
  22149. * The dirty texture flag value
  22150. */
  22151. static readonly TextureDirtyFlag: number;
  22152. /**
  22153. * The dirty light flag value
  22154. */
  22155. static readonly LightDirtyFlag: number;
  22156. /**
  22157. * The dirty fresnel flag value
  22158. */
  22159. static readonly FresnelDirtyFlag: number;
  22160. /**
  22161. * The dirty attribute flag value
  22162. */
  22163. static readonly AttributesDirtyFlag: number;
  22164. /**
  22165. * The dirty misc flag value
  22166. */
  22167. static readonly MiscDirtyFlag: number;
  22168. /**
  22169. * The all dirty flag value
  22170. */
  22171. static readonly AllDirtyFlag: number;
  22172. /**
  22173. * The ID of the material
  22174. */
  22175. id: string;
  22176. /**
  22177. * Gets or sets the unique id of the material
  22178. */
  22179. uniqueId: number;
  22180. /**
  22181. * The name of the material
  22182. */
  22183. name: string;
  22184. /**
  22185. * Gets or sets user defined metadata
  22186. */
  22187. metadata: any;
  22188. /**
  22189. * For internal use only. Please do not use.
  22190. */
  22191. reservedDataStore: any;
  22192. /**
  22193. * Specifies if the ready state should be checked on each call
  22194. */
  22195. checkReadyOnEveryCall: boolean;
  22196. /**
  22197. * Specifies if the ready state should be checked once
  22198. */
  22199. checkReadyOnlyOnce: boolean;
  22200. /**
  22201. * The state of the material
  22202. */
  22203. state: string;
  22204. /**
  22205. * The alpha value of the material
  22206. */
  22207. protected _alpha: number;
  22208. /**
  22209. * List of inspectable custom properties (used by the Inspector)
  22210. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22211. */
  22212. inspectableCustomProperties: IInspectable[];
  22213. /**
  22214. * Sets the alpha value of the material
  22215. */
  22216. /**
  22217. * Gets the alpha value of the material
  22218. */
  22219. alpha: number;
  22220. /**
  22221. * Specifies if back face culling is enabled
  22222. */
  22223. protected _backFaceCulling: boolean;
  22224. /**
  22225. * Sets the back-face culling state
  22226. */
  22227. /**
  22228. * Gets the back-face culling state
  22229. */
  22230. backFaceCulling: boolean;
  22231. /**
  22232. * Stores the value for side orientation
  22233. */
  22234. sideOrientation: number;
  22235. /**
  22236. * Callback triggered when the material is compiled
  22237. */
  22238. onCompiled: Nullable<(effect: Effect) => void>;
  22239. /**
  22240. * Callback triggered when an error occurs
  22241. */
  22242. onError: Nullable<(effect: Effect, errors: string) => void>;
  22243. /**
  22244. * Callback triggered to get the render target textures
  22245. */
  22246. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22247. /**
  22248. * Gets a boolean indicating that current material needs to register RTT
  22249. */
  22250. readonly hasRenderTargetTextures: boolean;
  22251. /**
  22252. * Specifies if the material should be serialized
  22253. */
  22254. doNotSerialize: boolean;
  22255. /**
  22256. * @hidden
  22257. */
  22258. _storeEffectOnSubMeshes: boolean;
  22259. /**
  22260. * Stores the animations for the material
  22261. */
  22262. animations: Nullable<Array<Animation>>;
  22263. /**
  22264. * An event triggered when the material is disposed
  22265. */
  22266. onDisposeObservable: Observable<Material>;
  22267. /**
  22268. * An observer which watches for dispose events
  22269. */
  22270. private _onDisposeObserver;
  22271. private _onUnBindObservable;
  22272. /**
  22273. * Called during a dispose event
  22274. */
  22275. onDispose: () => void;
  22276. private _onBindObservable;
  22277. /**
  22278. * An event triggered when the material is bound
  22279. */
  22280. readonly onBindObservable: Observable<AbstractMesh>;
  22281. /**
  22282. * An observer which watches for bind events
  22283. */
  22284. private _onBindObserver;
  22285. /**
  22286. * Called during a bind event
  22287. */
  22288. onBind: (Mesh: AbstractMesh) => void;
  22289. /**
  22290. * An event triggered when the material is unbound
  22291. */
  22292. readonly onUnBindObservable: Observable<Material>;
  22293. /**
  22294. * Stores the value of the alpha mode
  22295. */
  22296. private _alphaMode;
  22297. /**
  22298. * Sets the value of the alpha mode.
  22299. *
  22300. * | Value | Type | Description |
  22301. * | --- | --- | --- |
  22302. * | 0 | ALPHA_DISABLE | |
  22303. * | 1 | ALPHA_ADD | |
  22304. * | 2 | ALPHA_COMBINE | |
  22305. * | 3 | ALPHA_SUBTRACT | |
  22306. * | 4 | ALPHA_MULTIPLY | |
  22307. * | 5 | ALPHA_MAXIMIZED | |
  22308. * | 6 | ALPHA_ONEONE | |
  22309. * | 7 | ALPHA_PREMULTIPLIED | |
  22310. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22311. * | 9 | ALPHA_INTERPOLATE | |
  22312. * | 10 | ALPHA_SCREENMODE | |
  22313. *
  22314. */
  22315. /**
  22316. * Gets the value of the alpha mode
  22317. */
  22318. alphaMode: number;
  22319. /**
  22320. * Stores the state of the need depth pre-pass value
  22321. */
  22322. private _needDepthPrePass;
  22323. /**
  22324. * Sets the need depth pre-pass value
  22325. */
  22326. /**
  22327. * Gets the depth pre-pass value
  22328. */
  22329. needDepthPrePass: boolean;
  22330. /**
  22331. * Specifies if depth writing should be disabled
  22332. */
  22333. disableDepthWrite: boolean;
  22334. /**
  22335. * Specifies if depth writing should be forced
  22336. */
  22337. forceDepthWrite: boolean;
  22338. /**
  22339. * Specifies if there should be a separate pass for culling
  22340. */
  22341. separateCullingPass: boolean;
  22342. /**
  22343. * Stores the state specifing if fog should be enabled
  22344. */
  22345. private _fogEnabled;
  22346. /**
  22347. * Sets the state for enabling fog
  22348. */
  22349. /**
  22350. * Gets the value of the fog enabled state
  22351. */
  22352. fogEnabled: boolean;
  22353. /**
  22354. * Stores the size of points
  22355. */
  22356. pointSize: number;
  22357. /**
  22358. * Stores the z offset value
  22359. */
  22360. zOffset: number;
  22361. /**
  22362. * Gets a value specifying if wireframe mode is enabled
  22363. */
  22364. /**
  22365. * Sets the state of wireframe mode
  22366. */
  22367. wireframe: boolean;
  22368. /**
  22369. * Gets the value specifying if point clouds are enabled
  22370. */
  22371. /**
  22372. * Sets the state of point cloud mode
  22373. */
  22374. pointsCloud: boolean;
  22375. /**
  22376. * Gets the material fill mode
  22377. */
  22378. /**
  22379. * Sets the material fill mode
  22380. */
  22381. fillMode: number;
  22382. /**
  22383. * @hidden
  22384. * Stores the effects for the material
  22385. */
  22386. _effect: Nullable<Effect>;
  22387. /**
  22388. * @hidden
  22389. * Specifies if the material was previously ready
  22390. */
  22391. _wasPreviouslyReady: boolean;
  22392. /**
  22393. * Specifies if uniform buffers should be used
  22394. */
  22395. private _useUBO;
  22396. /**
  22397. * Stores a reference to the scene
  22398. */
  22399. private _scene;
  22400. /**
  22401. * Stores the fill mode state
  22402. */
  22403. private _fillMode;
  22404. /**
  22405. * Specifies if the depth write state should be cached
  22406. */
  22407. private _cachedDepthWriteState;
  22408. /**
  22409. * Stores the uniform buffer
  22410. */
  22411. protected _uniformBuffer: UniformBuffer;
  22412. /** @hidden */
  22413. _indexInSceneMaterialArray: number;
  22414. /** @hidden */
  22415. meshMap: Nullable<{
  22416. [id: string]: AbstractMesh | undefined;
  22417. }>;
  22418. /**
  22419. * Creates a material instance
  22420. * @param name defines the name of the material
  22421. * @param scene defines the scene to reference
  22422. * @param doNotAdd specifies if the material should be added to the scene
  22423. */
  22424. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22425. /**
  22426. * Returns a string representation of the current material
  22427. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22428. * @returns a string with material information
  22429. */
  22430. toString(fullDetails?: boolean): string;
  22431. /**
  22432. * Gets the class name of the material
  22433. * @returns a string with the class name of the material
  22434. */
  22435. getClassName(): string;
  22436. /**
  22437. * Specifies if updates for the material been locked
  22438. */
  22439. readonly isFrozen: boolean;
  22440. /**
  22441. * Locks updates for the material
  22442. */
  22443. freeze(): void;
  22444. /**
  22445. * Unlocks updates for the material
  22446. */
  22447. unfreeze(): void;
  22448. /**
  22449. * Specifies if the material is ready to be used
  22450. * @param mesh defines the mesh to check
  22451. * @param useInstances specifies if instances should be used
  22452. * @returns a boolean indicating if the material is ready to be used
  22453. */
  22454. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22455. /**
  22456. * Specifies that the submesh is ready to be used
  22457. * @param mesh defines the mesh to check
  22458. * @param subMesh defines which submesh to check
  22459. * @param useInstances specifies that instances should be used
  22460. * @returns a boolean indicating that the submesh is ready or not
  22461. */
  22462. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22463. /**
  22464. * Returns the material effect
  22465. * @returns the effect associated with the material
  22466. */
  22467. getEffect(): Nullable<Effect>;
  22468. /**
  22469. * Returns the current scene
  22470. * @returns a Scene
  22471. */
  22472. getScene(): Scene;
  22473. /**
  22474. * Specifies if the material will require alpha blending
  22475. * @returns a boolean specifying if alpha blending is needed
  22476. */
  22477. needAlphaBlending(): boolean;
  22478. /**
  22479. * Specifies if the mesh will require alpha blending
  22480. * @param mesh defines the mesh to check
  22481. * @returns a boolean specifying if alpha blending is needed for the mesh
  22482. */
  22483. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22484. /**
  22485. * Specifies if this material should be rendered in alpha test mode
  22486. * @returns a boolean specifying if an alpha test is needed.
  22487. */
  22488. needAlphaTesting(): boolean;
  22489. /**
  22490. * Gets the texture used for the alpha test
  22491. * @returns the texture to use for alpha testing
  22492. */
  22493. getAlphaTestTexture(): Nullable<BaseTexture>;
  22494. /**
  22495. * Marks the material to indicate that it needs to be re-calculated
  22496. */
  22497. markDirty(): void;
  22498. /** @hidden */
  22499. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22500. /**
  22501. * Binds the material to the mesh
  22502. * @param world defines the world transformation matrix
  22503. * @param mesh defines the mesh to bind the material to
  22504. */
  22505. bind(world: Matrix, mesh?: Mesh): void;
  22506. /**
  22507. * Binds the submesh to the material
  22508. * @param world defines the world transformation matrix
  22509. * @param mesh defines the mesh containing the submesh
  22510. * @param subMesh defines the submesh to bind the material to
  22511. */
  22512. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22513. /**
  22514. * Binds the world matrix to the material
  22515. * @param world defines the world transformation matrix
  22516. */
  22517. bindOnlyWorldMatrix(world: Matrix): void;
  22518. /**
  22519. * Binds the scene's uniform buffer to the effect.
  22520. * @param effect defines the effect to bind to the scene uniform buffer
  22521. * @param sceneUbo defines the uniform buffer storing scene data
  22522. */
  22523. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22524. /**
  22525. * Binds the view matrix to the effect
  22526. * @param effect defines the effect to bind the view matrix to
  22527. */
  22528. bindView(effect: Effect): void;
  22529. /**
  22530. * Binds the view projection matrix to the effect
  22531. * @param effect defines the effect to bind the view projection matrix to
  22532. */
  22533. bindViewProjection(effect: Effect): void;
  22534. /**
  22535. * Specifies if material alpha testing should be turned on for the mesh
  22536. * @param mesh defines the mesh to check
  22537. */
  22538. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22539. /**
  22540. * Processes to execute after binding the material to a mesh
  22541. * @param mesh defines the rendered mesh
  22542. */
  22543. protected _afterBind(mesh?: Mesh): void;
  22544. /**
  22545. * Unbinds the material from the mesh
  22546. */
  22547. unbind(): void;
  22548. /**
  22549. * Gets the active textures from the material
  22550. * @returns an array of textures
  22551. */
  22552. getActiveTextures(): BaseTexture[];
  22553. /**
  22554. * Specifies if the material uses a texture
  22555. * @param texture defines the texture to check against the material
  22556. * @returns a boolean specifying if the material uses the texture
  22557. */
  22558. hasTexture(texture: BaseTexture): boolean;
  22559. /**
  22560. * Makes a duplicate of the material, and gives it a new name
  22561. * @param name defines the new name for the duplicated material
  22562. * @returns the cloned material
  22563. */
  22564. clone(name: string): Nullable<Material>;
  22565. /**
  22566. * Gets the meshes bound to the material
  22567. * @returns an array of meshes bound to the material
  22568. */
  22569. getBindedMeshes(): AbstractMesh[];
  22570. /**
  22571. * Force shader compilation
  22572. * @param mesh defines the mesh associated with this material
  22573. * @param onCompiled defines a function to execute once the material is compiled
  22574. * @param options defines the options to configure the compilation
  22575. */
  22576. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22577. clipPlane: boolean;
  22578. }>): void;
  22579. /**
  22580. * Force shader compilation
  22581. * @param mesh defines the mesh that will use this material
  22582. * @param options defines additional options for compiling the shaders
  22583. * @returns a promise that resolves when the compilation completes
  22584. */
  22585. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22586. clipPlane: boolean;
  22587. }>): Promise<void>;
  22588. private static readonly _AllDirtyCallBack;
  22589. private static readonly _ImageProcessingDirtyCallBack;
  22590. private static readonly _TextureDirtyCallBack;
  22591. private static readonly _FresnelDirtyCallBack;
  22592. private static readonly _MiscDirtyCallBack;
  22593. private static readonly _LightsDirtyCallBack;
  22594. private static readonly _AttributeDirtyCallBack;
  22595. private static _FresnelAndMiscDirtyCallBack;
  22596. private static _TextureAndMiscDirtyCallBack;
  22597. private static readonly _DirtyCallbackArray;
  22598. private static readonly _RunDirtyCallBacks;
  22599. /**
  22600. * Marks a define in the material to indicate that it needs to be re-computed
  22601. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22602. */
  22603. markAsDirty(flag: number): void;
  22604. /**
  22605. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22606. * @param func defines a function which checks material defines against the submeshes
  22607. */
  22608. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22609. /**
  22610. * Indicates that we need to re-calculated for all submeshes
  22611. */
  22612. protected _markAllSubMeshesAsAllDirty(): void;
  22613. /**
  22614. * Indicates that image processing needs to be re-calculated for all submeshes
  22615. */
  22616. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22617. /**
  22618. * Indicates that textures need to be re-calculated for all submeshes
  22619. */
  22620. protected _markAllSubMeshesAsTexturesDirty(): void;
  22621. /**
  22622. * Indicates that fresnel needs to be re-calculated for all submeshes
  22623. */
  22624. protected _markAllSubMeshesAsFresnelDirty(): void;
  22625. /**
  22626. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22627. */
  22628. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22629. /**
  22630. * Indicates that lights need to be re-calculated for all submeshes
  22631. */
  22632. protected _markAllSubMeshesAsLightsDirty(): void;
  22633. /**
  22634. * Indicates that attributes need to be re-calculated for all submeshes
  22635. */
  22636. protected _markAllSubMeshesAsAttributesDirty(): void;
  22637. /**
  22638. * Indicates that misc needs to be re-calculated for all submeshes
  22639. */
  22640. protected _markAllSubMeshesAsMiscDirty(): void;
  22641. /**
  22642. * Indicates that textures and misc need to be re-calculated for all submeshes
  22643. */
  22644. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22645. /**
  22646. * Disposes the material
  22647. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22648. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22649. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22650. */
  22651. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22652. /** @hidden */
  22653. private releaseVertexArrayObject;
  22654. /**
  22655. * Serializes this material
  22656. * @returns the serialized material object
  22657. */
  22658. serialize(): any;
  22659. /**
  22660. * Creates a material from parsed material data
  22661. * @param parsedMaterial defines parsed material data
  22662. * @param scene defines the hosting scene
  22663. * @param rootUrl defines the root URL to use to load textures
  22664. * @returns a new material
  22665. */
  22666. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22667. }
  22668. }
  22669. declare module BABYLON {
  22670. /**
  22671. * Base class for submeshes
  22672. */
  22673. export class BaseSubMesh {
  22674. /** @hidden */
  22675. _materialDefines: Nullable<MaterialDefines>;
  22676. /** @hidden */
  22677. _materialEffect: Nullable<Effect>;
  22678. /**
  22679. * Gets associated effect
  22680. */
  22681. readonly effect: Nullable<Effect>;
  22682. /**
  22683. * Sets associated effect (effect used to render this submesh)
  22684. * @param effect defines the effect to associate with
  22685. * @param defines defines the set of defines used to compile this effect
  22686. */
  22687. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22688. }
  22689. /**
  22690. * Defines a subdivision inside a mesh
  22691. */
  22692. export class SubMesh extends BaseSubMesh implements ICullable {
  22693. /** the material index to use */
  22694. materialIndex: number;
  22695. /** vertex index start */
  22696. verticesStart: number;
  22697. /** vertices count */
  22698. verticesCount: number;
  22699. /** index start */
  22700. indexStart: number;
  22701. /** indices count */
  22702. indexCount: number;
  22703. /** @hidden */
  22704. _linesIndexCount: number;
  22705. private _mesh;
  22706. private _renderingMesh;
  22707. private _boundingInfo;
  22708. private _linesIndexBuffer;
  22709. /** @hidden */
  22710. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22711. /** @hidden */
  22712. _trianglePlanes: Plane[];
  22713. /** @hidden */
  22714. _lastColliderTransformMatrix: Nullable<Matrix>;
  22715. /** @hidden */
  22716. _renderId: number;
  22717. /** @hidden */
  22718. _alphaIndex: number;
  22719. /** @hidden */
  22720. _distanceToCamera: number;
  22721. /** @hidden */
  22722. _id: number;
  22723. private _currentMaterial;
  22724. /**
  22725. * Add a new submesh to a mesh
  22726. * @param materialIndex defines the material index to use
  22727. * @param verticesStart defines vertex index start
  22728. * @param verticesCount defines vertices count
  22729. * @param indexStart defines index start
  22730. * @param indexCount defines indices count
  22731. * @param mesh defines the parent mesh
  22732. * @param renderingMesh defines an optional rendering mesh
  22733. * @param createBoundingBox defines if bounding box should be created for this submesh
  22734. * @returns the new submesh
  22735. */
  22736. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22737. /**
  22738. * Creates a new submesh
  22739. * @param materialIndex defines the material index to use
  22740. * @param verticesStart defines vertex index start
  22741. * @param verticesCount defines vertices count
  22742. * @param indexStart defines index start
  22743. * @param indexCount defines indices count
  22744. * @param mesh defines the parent mesh
  22745. * @param renderingMesh defines an optional rendering mesh
  22746. * @param createBoundingBox defines if bounding box should be created for this submesh
  22747. */
  22748. constructor(
  22749. /** the material index to use */
  22750. materialIndex: number,
  22751. /** vertex index start */
  22752. verticesStart: number,
  22753. /** vertices count */
  22754. verticesCount: number,
  22755. /** index start */
  22756. indexStart: number,
  22757. /** indices count */
  22758. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22759. /**
  22760. * Returns true if this submesh covers the entire parent mesh
  22761. * @ignorenaming
  22762. */
  22763. readonly IsGlobal: boolean;
  22764. /**
  22765. * Returns the submesh BoudingInfo object
  22766. * @returns current bounding info (or mesh's one if the submesh is global)
  22767. */
  22768. getBoundingInfo(): BoundingInfo;
  22769. /**
  22770. * Sets the submesh BoundingInfo
  22771. * @param boundingInfo defines the new bounding info to use
  22772. * @returns the SubMesh
  22773. */
  22774. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22775. /**
  22776. * Returns the mesh of the current submesh
  22777. * @return the parent mesh
  22778. */
  22779. getMesh(): AbstractMesh;
  22780. /**
  22781. * Returns the rendering mesh of the submesh
  22782. * @returns the rendering mesh (could be different from parent mesh)
  22783. */
  22784. getRenderingMesh(): Mesh;
  22785. /**
  22786. * Returns the submesh material
  22787. * @returns null or the current material
  22788. */
  22789. getMaterial(): Nullable<Material>;
  22790. /**
  22791. * Sets a new updated BoundingInfo object to the submesh
  22792. * @param data defines an optional position array to use to determine the bounding info
  22793. * @returns the SubMesh
  22794. */
  22795. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22796. /** @hidden */
  22797. _checkCollision(collider: Collider): boolean;
  22798. /**
  22799. * Updates the submesh BoundingInfo
  22800. * @param world defines the world matrix to use to update the bounding info
  22801. * @returns the submesh
  22802. */
  22803. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22804. /**
  22805. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22806. * @param frustumPlanes defines the frustum planes
  22807. * @returns true if the submesh is intersecting with the frustum
  22808. */
  22809. isInFrustum(frustumPlanes: Plane[]): boolean;
  22810. /**
  22811. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22812. * @param frustumPlanes defines the frustum planes
  22813. * @returns true if the submesh is inside the frustum
  22814. */
  22815. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22816. /**
  22817. * Renders the submesh
  22818. * @param enableAlphaMode defines if alpha needs to be used
  22819. * @returns the submesh
  22820. */
  22821. render(enableAlphaMode: boolean): SubMesh;
  22822. /**
  22823. * @hidden
  22824. */
  22825. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22826. /**
  22827. * Checks if the submesh intersects with a ray
  22828. * @param ray defines the ray to test
  22829. * @returns true is the passed ray intersects the submesh bounding box
  22830. */
  22831. canIntersects(ray: Ray): boolean;
  22832. /**
  22833. * Intersects current submesh with a ray
  22834. * @param ray defines the ray to test
  22835. * @param positions defines mesh's positions array
  22836. * @param indices defines mesh's indices array
  22837. * @param fastCheck defines if only bounding info should be used
  22838. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22839. * @returns intersection info or null if no intersection
  22840. */
  22841. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22842. /** @hidden */
  22843. private _intersectLines;
  22844. /** @hidden */
  22845. private _intersectUnIndexedLines;
  22846. /** @hidden */
  22847. private _intersectTriangles;
  22848. /** @hidden */
  22849. private _intersectUnIndexedTriangles;
  22850. /** @hidden */
  22851. _rebuild(): void;
  22852. /**
  22853. * Creates a new submesh from the passed mesh
  22854. * @param newMesh defines the new hosting mesh
  22855. * @param newRenderingMesh defines an optional rendering mesh
  22856. * @returns the new submesh
  22857. */
  22858. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22859. /**
  22860. * Release associated resources
  22861. */
  22862. dispose(): void;
  22863. /**
  22864. * Gets the class name
  22865. * @returns the string "SubMesh".
  22866. */
  22867. getClassName(): string;
  22868. /**
  22869. * Creates a new submesh from indices data
  22870. * @param materialIndex the index of the main mesh material
  22871. * @param startIndex the index where to start the copy in the mesh indices array
  22872. * @param indexCount the number of indices to copy then from the startIndex
  22873. * @param mesh the main mesh to create the submesh from
  22874. * @param renderingMesh the optional rendering mesh
  22875. * @returns a new submesh
  22876. */
  22877. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22878. }
  22879. }
  22880. declare module BABYLON {
  22881. /**
  22882. * Class used to store geometry data (vertex buffers + index buffer)
  22883. */
  22884. export class Geometry implements IGetSetVerticesData {
  22885. /**
  22886. * Gets or sets the ID of the geometry
  22887. */
  22888. id: string;
  22889. /**
  22890. * Gets or sets the unique ID of the geometry
  22891. */
  22892. uniqueId: number;
  22893. /**
  22894. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22895. */
  22896. delayLoadState: number;
  22897. /**
  22898. * Gets the file containing the data to load when running in delay load state
  22899. */
  22900. delayLoadingFile: Nullable<string>;
  22901. /**
  22902. * Callback called when the geometry is updated
  22903. */
  22904. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22905. private _scene;
  22906. private _engine;
  22907. private _meshes;
  22908. private _totalVertices;
  22909. /** @hidden */
  22910. _indices: IndicesArray;
  22911. /** @hidden */
  22912. _vertexBuffers: {
  22913. [key: string]: VertexBuffer;
  22914. };
  22915. private _isDisposed;
  22916. private _extend;
  22917. private _boundingBias;
  22918. /** @hidden */
  22919. _delayInfo: Array<string>;
  22920. private _indexBuffer;
  22921. private _indexBufferIsUpdatable;
  22922. /** @hidden */
  22923. _boundingInfo: Nullable<BoundingInfo>;
  22924. /** @hidden */
  22925. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22926. /** @hidden */
  22927. _softwareSkinningFrameId: number;
  22928. private _vertexArrayObjects;
  22929. private _updatable;
  22930. /** @hidden */
  22931. _positions: Nullable<Vector3[]>;
  22932. /**
  22933. * 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
  22934. */
  22935. /**
  22936. * 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
  22937. */
  22938. boundingBias: Vector2;
  22939. /**
  22940. * Static function used to attach a new empty geometry to a mesh
  22941. * @param mesh defines the mesh to attach the geometry to
  22942. * @returns the new Geometry
  22943. */
  22944. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22945. /**
  22946. * Creates a new geometry
  22947. * @param id defines the unique ID
  22948. * @param scene defines the hosting scene
  22949. * @param vertexData defines the VertexData used to get geometry data
  22950. * @param updatable defines if geometry must be updatable (false by default)
  22951. * @param mesh defines the mesh that will be associated with the geometry
  22952. */
  22953. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22954. /**
  22955. * Gets the current extend of the geometry
  22956. */
  22957. readonly extend: {
  22958. minimum: Vector3;
  22959. maximum: Vector3;
  22960. };
  22961. /**
  22962. * Gets the hosting scene
  22963. * @returns the hosting Scene
  22964. */
  22965. getScene(): Scene;
  22966. /**
  22967. * Gets the hosting engine
  22968. * @returns the hosting Engine
  22969. */
  22970. getEngine(): Engine;
  22971. /**
  22972. * Defines if the geometry is ready to use
  22973. * @returns true if the geometry is ready to be used
  22974. */
  22975. isReady(): boolean;
  22976. /**
  22977. * Gets a value indicating that the geometry should not be serialized
  22978. */
  22979. readonly doNotSerialize: boolean;
  22980. /** @hidden */
  22981. _rebuild(): void;
  22982. /**
  22983. * Affects all geometry data in one call
  22984. * @param vertexData defines the geometry data
  22985. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22986. */
  22987. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22988. /**
  22989. * Set specific vertex data
  22990. * @param kind defines the data kind (Position, normal, etc...)
  22991. * @param data defines the vertex data to use
  22992. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22993. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22994. */
  22995. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22996. /**
  22997. * Removes a specific vertex data
  22998. * @param kind defines the data kind (Position, normal, etc...)
  22999. */
  23000. removeVerticesData(kind: string): void;
  23001. /**
  23002. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23003. * @param buffer defines the vertex buffer to use
  23004. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23005. */
  23006. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23007. /**
  23008. * Update a specific vertex buffer
  23009. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23010. * It will do nothing if the buffer is not updatable
  23011. * @param kind defines the data kind (Position, normal, etc...)
  23012. * @param data defines the data to use
  23013. * @param offset defines the offset in the target buffer where to store the data
  23014. * @param useBytes set to true if the offset is in bytes
  23015. */
  23016. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23017. /**
  23018. * Update a specific vertex buffer
  23019. * This function will create a new buffer if the current one is not updatable
  23020. * @param kind defines the data kind (Position, normal, etc...)
  23021. * @param data defines the data to use
  23022. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23023. */
  23024. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23025. private _updateBoundingInfo;
  23026. /** @hidden */
  23027. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23028. /**
  23029. * Gets total number of vertices
  23030. * @returns the total number of vertices
  23031. */
  23032. getTotalVertices(): number;
  23033. /**
  23034. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23035. * @param kind defines the data kind (Position, normal, etc...)
  23036. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23037. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23038. * @returns a float array containing vertex data
  23039. */
  23040. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23041. /**
  23042. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23043. * @param kind defines the data kind (Position, normal, etc...)
  23044. * @returns true if the vertex buffer with the specified kind is updatable
  23045. */
  23046. isVertexBufferUpdatable(kind: string): boolean;
  23047. /**
  23048. * Gets a specific vertex buffer
  23049. * @param kind defines the data kind (Position, normal, etc...)
  23050. * @returns a VertexBuffer
  23051. */
  23052. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23053. /**
  23054. * Returns all vertex buffers
  23055. * @return an object holding all vertex buffers indexed by kind
  23056. */
  23057. getVertexBuffers(): Nullable<{
  23058. [key: string]: VertexBuffer;
  23059. }>;
  23060. /**
  23061. * Gets a boolean indicating if specific vertex buffer is present
  23062. * @param kind defines the data kind (Position, normal, etc...)
  23063. * @returns true if data is present
  23064. */
  23065. isVerticesDataPresent(kind: string): boolean;
  23066. /**
  23067. * Gets a list of all attached data kinds (Position, normal, etc...)
  23068. * @returns a list of string containing all kinds
  23069. */
  23070. getVerticesDataKinds(): string[];
  23071. /**
  23072. * Update index buffer
  23073. * @param indices defines the indices to store in the index buffer
  23074. * @param offset defines the offset in the target buffer where to store the data
  23075. * @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)
  23076. */
  23077. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23078. /**
  23079. * Creates a new index buffer
  23080. * @param indices defines the indices to store in the index buffer
  23081. * @param totalVertices defines the total number of vertices (could be null)
  23082. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23083. */
  23084. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23085. /**
  23086. * Return the total number of indices
  23087. * @returns the total number of indices
  23088. */
  23089. getTotalIndices(): number;
  23090. /**
  23091. * Gets the index buffer array
  23092. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23093. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23094. * @returns the index buffer array
  23095. */
  23096. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23097. /**
  23098. * Gets the index buffer
  23099. * @return the index buffer
  23100. */
  23101. getIndexBuffer(): Nullable<DataBuffer>;
  23102. /** @hidden */
  23103. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23104. /**
  23105. * Release the associated resources for a specific mesh
  23106. * @param mesh defines the source mesh
  23107. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23108. */
  23109. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23110. /**
  23111. * Apply current geometry to a given mesh
  23112. * @param mesh defines the mesh to apply geometry to
  23113. */
  23114. applyToMesh(mesh: Mesh): void;
  23115. private _updateExtend;
  23116. private _applyToMesh;
  23117. private notifyUpdate;
  23118. /**
  23119. * Load the geometry if it was flagged as delay loaded
  23120. * @param scene defines the hosting scene
  23121. * @param onLoaded defines a callback called when the geometry is loaded
  23122. */
  23123. load(scene: Scene, onLoaded?: () => void): void;
  23124. private _queueLoad;
  23125. /**
  23126. * Invert the geometry to move from a right handed system to a left handed one.
  23127. */
  23128. toLeftHanded(): void;
  23129. /** @hidden */
  23130. _resetPointsArrayCache(): void;
  23131. /** @hidden */
  23132. _generatePointsArray(): boolean;
  23133. /**
  23134. * Gets a value indicating if the geometry is disposed
  23135. * @returns true if the geometry was disposed
  23136. */
  23137. isDisposed(): boolean;
  23138. private _disposeVertexArrayObjects;
  23139. /**
  23140. * Free all associated resources
  23141. */
  23142. dispose(): void;
  23143. /**
  23144. * Clone the current geometry into a new geometry
  23145. * @param id defines the unique ID of the new geometry
  23146. * @returns a new geometry object
  23147. */
  23148. copy(id: string): Geometry;
  23149. /**
  23150. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23151. * @return a JSON representation of the current geometry data (without the vertices data)
  23152. */
  23153. serialize(): any;
  23154. private toNumberArray;
  23155. /**
  23156. * Serialize all vertices data into a JSON oject
  23157. * @returns a JSON representation of the current geometry data
  23158. */
  23159. serializeVerticeData(): any;
  23160. /**
  23161. * Extracts a clone of a mesh geometry
  23162. * @param mesh defines the source mesh
  23163. * @param id defines the unique ID of the new geometry object
  23164. * @returns the new geometry object
  23165. */
  23166. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23167. /**
  23168. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23169. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23170. * Be aware Math.random() could cause collisions, but:
  23171. * "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"
  23172. * @returns a string containing a new GUID
  23173. */
  23174. static RandomId(): string;
  23175. /** @hidden */
  23176. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23177. private static _CleanMatricesWeights;
  23178. /**
  23179. * Create a new geometry from persisted data (Using .babylon file format)
  23180. * @param parsedVertexData defines the persisted data
  23181. * @param scene defines the hosting scene
  23182. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23183. * @returns the new geometry object
  23184. */
  23185. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23186. }
  23187. }
  23188. declare module BABYLON {
  23189. /**
  23190. * Define an interface for all classes that will get and set the data on vertices
  23191. */
  23192. export interface IGetSetVerticesData {
  23193. /**
  23194. * Gets a boolean indicating if specific vertex data is present
  23195. * @param kind defines the vertex data kind to use
  23196. * @returns true is data kind is present
  23197. */
  23198. isVerticesDataPresent(kind: string): boolean;
  23199. /**
  23200. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23201. * @param kind defines the data kind (Position, normal, etc...)
  23202. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23203. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23204. * @returns a float array containing vertex data
  23205. */
  23206. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23207. /**
  23208. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23209. * @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.
  23210. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23211. * @returns the indices array or an empty array if the mesh has no geometry
  23212. */
  23213. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23214. /**
  23215. * Set specific vertex data
  23216. * @param kind defines the data kind (Position, normal, etc...)
  23217. * @param data defines the vertex data to use
  23218. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23219. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23220. */
  23221. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23222. /**
  23223. * Update a specific associated vertex buffer
  23224. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23225. * - VertexBuffer.PositionKind
  23226. * - VertexBuffer.UVKind
  23227. * - VertexBuffer.UV2Kind
  23228. * - VertexBuffer.UV3Kind
  23229. * - VertexBuffer.UV4Kind
  23230. * - VertexBuffer.UV5Kind
  23231. * - VertexBuffer.UV6Kind
  23232. * - VertexBuffer.ColorKind
  23233. * - VertexBuffer.MatricesIndicesKind
  23234. * - VertexBuffer.MatricesIndicesExtraKind
  23235. * - VertexBuffer.MatricesWeightsKind
  23236. * - VertexBuffer.MatricesWeightsExtraKind
  23237. * @param data defines the data source
  23238. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23239. * @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)
  23240. */
  23241. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23242. /**
  23243. * Creates a new index buffer
  23244. * @param indices defines the indices to store in the index buffer
  23245. * @param totalVertices defines the total number of vertices (could be null)
  23246. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23247. */
  23248. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23249. }
  23250. /**
  23251. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23252. */
  23253. export class VertexData {
  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. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23272. */
  23273. positions: Nullable<FloatArray>;
  23274. /**
  23275. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23276. */
  23277. normals: Nullable<FloatArray>;
  23278. /**
  23279. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23280. */
  23281. tangents: Nullable<FloatArray>;
  23282. /**
  23283. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23284. */
  23285. uvs: Nullable<FloatArray>;
  23286. /**
  23287. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23288. */
  23289. uvs2: Nullable<FloatArray>;
  23290. /**
  23291. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23292. */
  23293. uvs3: Nullable<FloatArray>;
  23294. /**
  23295. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23296. */
  23297. uvs4: Nullable<FloatArray>;
  23298. /**
  23299. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23300. */
  23301. uvs5: Nullable<FloatArray>;
  23302. /**
  23303. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23304. */
  23305. uvs6: Nullable<FloatArray>;
  23306. /**
  23307. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23308. */
  23309. colors: Nullable<FloatArray>;
  23310. /**
  23311. * 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).
  23312. */
  23313. matricesIndices: Nullable<FloatArray>;
  23314. /**
  23315. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23316. */
  23317. matricesWeights: Nullable<FloatArray>;
  23318. /**
  23319. * An array extending the number of possible indices
  23320. */
  23321. matricesIndicesExtra: Nullable<FloatArray>;
  23322. /**
  23323. * An array extending the number of possible weights when the number of indices is extended
  23324. */
  23325. matricesWeightsExtra: Nullable<FloatArray>;
  23326. /**
  23327. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23328. */
  23329. indices: Nullable<IndicesArray>;
  23330. /**
  23331. * Uses the passed data array to set the set the values for the specified kind of data
  23332. * @param data a linear array of floating numbers
  23333. * @param kind the type of data that is being set, eg positions, colors etc
  23334. */
  23335. set(data: FloatArray, kind: string): void;
  23336. /**
  23337. * Associates the vertexData to the passed Mesh.
  23338. * Sets it as updatable or not (default `false`)
  23339. * @param mesh the mesh the vertexData is applied to
  23340. * @param updatable when used and having the value true allows new data to update the vertexData
  23341. * @returns the VertexData
  23342. */
  23343. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23344. /**
  23345. * Associates the vertexData to the passed Geometry.
  23346. * Sets it as updatable or not (default `false`)
  23347. * @param geometry the geometry the vertexData is applied to
  23348. * @param updatable when used and having the value true allows new data to update the vertexData
  23349. * @returns VertexData
  23350. */
  23351. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23352. /**
  23353. * Updates the associated mesh
  23354. * @param mesh the mesh to be updated
  23355. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23356. * @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
  23357. * @returns VertexData
  23358. */
  23359. updateMesh(mesh: Mesh): VertexData;
  23360. /**
  23361. * Updates the associated geometry
  23362. * @param geometry the geometry to be updated
  23363. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23364. * @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
  23365. * @returns VertexData.
  23366. */
  23367. updateGeometry(geometry: Geometry): VertexData;
  23368. private _applyTo;
  23369. private _update;
  23370. /**
  23371. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23372. * @param matrix the transforming matrix
  23373. * @returns the VertexData
  23374. */
  23375. transform(matrix: Matrix): VertexData;
  23376. /**
  23377. * Merges the passed VertexData into the current one
  23378. * @param other the VertexData to be merged into the current one
  23379. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23380. * @returns the modified VertexData
  23381. */
  23382. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23383. private _mergeElement;
  23384. private _validate;
  23385. /**
  23386. * Serializes the VertexData
  23387. * @returns a serialized object
  23388. */
  23389. serialize(): any;
  23390. /**
  23391. * Extracts the vertexData from a mesh
  23392. * @param mesh the mesh from which to extract the VertexData
  23393. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23394. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23395. * @returns the object VertexData associated to the passed mesh
  23396. */
  23397. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23398. /**
  23399. * Extracts the vertexData from the geometry
  23400. * @param geometry the geometry from which to extract the VertexData
  23401. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23402. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23403. * @returns the object VertexData associated to the passed mesh
  23404. */
  23405. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23406. private static _ExtractFrom;
  23407. /**
  23408. * Creates the VertexData for a Ribbon
  23409. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23410. * * pathArray array of paths, each of which an array of successive Vector3
  23411. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23412. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23413. * * 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
  23414. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23415. * * 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)
  23416. * * 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)
  23417. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23418. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23419. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23420. * @returns the VertexData of the ribbon
  23421. */
  23422. static CreateRibbon(options: {
  23423. pathArray: Vector3[][];
  23424. closeArray?: boolean;
  23425. closePath?: boolean;
  23426. offset?: number;
  23427. sideOrientation?: number;
  23428. frontUVs?: Vector4;
  23429. backUVs?: Vector4;
  23430. invertUV?: boolean;
  23431. uvs?: Vector2[];
  23432. colors?: Color4[];
  23433. }): VertexData;
  23434. /**
  23435. * Creates the VertexData for a box
  23436. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23437. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23438. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23439. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23440. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23441. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23442. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23443. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23444. * * 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)
  23445. * * 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)
  23446. * @returns the VertexData of the box
  23447. */
  23448. static CreateBox(options: {
  23449. size?: number;
  23450. width?: number;
  23451. height?: number;
  23452. depth?: number;
  23453. faceUV?: Vector4[];
  23454. faceColors?: Color4[];
  23455. sideOrientation?: number;
  23456. frontUVs?: Vector4;
  23457. backUVs?: Vector4;
  23458. }): VertexData;
  23459. /**
  23460. * Creates the VertexData for a tiled box
  23461. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23462. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23463. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23464. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23465. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23466. * @returns the VertexData of the box
  23467. */
  23468. static CreateTiledBox(options: {
  23469. pattern?: number;
  23470. width?: number;
  23471. height?: number;
  23472. depth?: number;
  23473. tileSize?: number;
  23474. tileWidth?: number;
  23475. tileHeight?: number;
  23476. alignHorizontal?: number;
  23477. alignVertical?: number;
  23478. faceUV?: Vector4[];
  23479. faceColors?: Color4[];
  23480. sideOrientation?: number;
  23481. }): VertexData;
  23482. /**
  23483. * Creates the VertexData for a tiled plane
  23484. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23485. * * pattern a limited pattern arrangement depending on the number
  23486. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23487. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23488. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23489. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23490. * * 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)
  23491. * * 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)
  23492. * @returns the VertexData of the tiled plane
  23493. */
  23494. static CreateTiledPlane(options: {
  23495. pattern?: number;
  23496. tileSize?: number;
  23497. tileWidth?: number;
  23498. tileHeight?: number;
  23499. size?: number;
  23500. width?: number;
  23501. height?: number;
  23502. alignHorizontal?: number;
  23503. alignVertical?: number;
  23504. sideOrientation?: number;
  23505. frontUVs?: Vector4;
  23506. backUVs?: Vector4;
  23507. }): VertexData;
  23508. /**
  23509. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23510. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23511. * * segments sets the number of horizontal strips optional, default 32
  23512. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23513. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23514. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23515. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23516. * * 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
  23517. * * 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
  23518. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23519. * * 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)
  23520. * * 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)
  23521. * @returns the VertexData of the ellipsoid
  23522. */
  23523. static CreateSphere(options: {
  23524. segments?: number;
  23525. diameter?: number;
  23526. diameterX?: number;
  23527. diameterY?: number;
  23528. diameterZ?: number;
  23529. arc?: number;
  23530. slice?: number;
  23531. sideOrientation?: number;
  23532. frontUVs?: Vector4;
  23533. backUVs?: Vector4;
  23534. }): VertexData;
  23535. /**
  23536. * Creates the VertexData for a cylinder, cone or prism
  23537. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23538. * * height sets the height (y direction) of the cylinder, optional, default 2
  23539. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23540. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23541. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23542. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23543. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23544. * * 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
  23545. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23546. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23547. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23548. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23549. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23550. * * 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)
  23551. * * 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)
  23552. * @returns the VertexData of the cylinder, cone or prism
  23553. */
  23554. static CreateCylinder(options: {
  23555. height?: number;
  23556. diameterTop?: number;
  23557. diameterBottom?: number;
  23558. diameter?: number;
  23559. tessellation?: number;
  23560. subdivisions?: number;
  23561. arc?: number;
  23562. faceColors?: Color4[];
  23563. faceUV?: Vector4[];
  23564. hasRings?: boolean;
  23565. enclose?: boolean;
  23566. sideOrientation?: number;
  23567. frontUVs?: Vector4;
  23568. backUVs?: Vector4;
  23569. }): VertexData;
  23570. /**
  23571. * Creates the VertexData for a torus
  23572. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23573. * * diameter the diameter of the torus, optional default 1
  23574. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23575. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23576. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23577. * * 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)
  23578. * * 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)
  23579. * @returns the VertexData of the torus
  23580. */
  23581. static CreateTorus(options: {
  23582. diameter?: number;
  23583. thickness?: number;
  23584. tessellation?: number;
  23585. sideOrientation?: number;
  23586. frontUVs?: Vector4;
  23587. backUVs?: Vector4;
  23588. }): VertexData;
  23589. /**
  23590. * Creates the VertexData of the LineSystem
  23591. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23592. * - lines an array of lines, each line being an array of successive Vector3
  23593. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23594. * @returns the VertexData of the LineSystem
  23595. */
  23596. static CreateLineSystem(options: {
  23597. lines: Vector3[][];
  23598. colors?: Nullable<Color4[][]>;
  23599. }): VertexData;
  23600. /**
  23601. * Create the VertexData for a DashedLines
  23602. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23603. * - points an array successive Vector3
  23604. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23605. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23606. * - dashNb the intended total number of dashes, optional, default 200
  23607. * @returns the VertexData for the DashedLines
  23608. */
  23609. static CreateDashedLines(options: {
  23610. points: Vector3[];
  23611. dashSize?: number;
  23612. gapSize?: number;
  23613. dashNb?: number;
  23614. }): VertexData;
  23615. /**
  23616. * Creates the VertexData for a Ground
  23617. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23618. * - width the width (x direction) of the ground, optional, default 1
  23619. * - height the height (z direction) of the ground, optional, default 1
  23620. * - subdivisions the number of subdivisions per side, optional, default 1
  23621. * @returns the VertexData of the Ground
  23622. */
  23623. static CreateGround(options: {
  23624. width?: number;
  23625. height?: number;
  23626. subdivisions?: number;
  23627. subdivisionsX?: number;
  23628. subdivisionsY?: number;
  23629. }): VertexData;
  23630. /**
  23631. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23632. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23633. * * xmin the ground minimum X coordinate, optional, default -1
  23634. * * zmin the ground minimum Z coordinate, optional, default -1
  23635. * * xmax the ground maximum X coordinate, optional, default 1
  23636. * * zmax the ground maximum Z coordinate, optional, default 1
  23637. * * 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}
  23638. * * 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}
  23639. * @returns the VertexData of the TiledGround
  23640. */
  23641. static CreateTiledGround(options: {
  23642. xmin: number;
  23643. zmin: number;
  23644. xmax: number;
  23645. zmax: number;
  23646. subdivisions?: {
  23647. w: number;
  23648. h: number;
  23649. };
  23650. precision?: {
  23651. w: number;
  23652. h: number;
  23653. };
  23654. }): VertexData;
  23655. /**
  23656. * Creates the VertexData of the Ground designed from a heightmap
  23657. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23658. * * width the width (x direction) of the ground
  23659. * * height the height (z direction) of the ground
  23660. * * subdivisions the number of subdivisions per side
  23661. * * minHeight the minimum altitude on the ground, optional, default 0
  23662. * * maxHeight the maximum altitude on the ground, optional default 1
  23663. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23664. * * buffer the array holding the image color data
  23665. * * bufferWidth the width of image
  23666. * * bufferHeight the height of image
  23667. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23668. * @returns the VertexData of the Ground designed from a heightmap
  23669. */
  23670. static CreateGroundFromHeightMap(options: {
  23671. width: number;
  23672. height: number;
  23673. subdivisions: number;
  23674. minHeight: number;
  23675. maxHeight: number;
  23676. colorFilter: Color3;
  23677. buffer: Uint8Array;
  23678. bufferWidth: number;
  23679. bufferHeight: number;
  23680. alphaFilter: number;
  23681. }): VertexData;
  23682. /**
  23683. * Creates the VertexData for a Plane
  23684. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23685. * * size sets the width and height of the plane to the value of size, optional default 1
  23686. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23687. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23688. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23689. * * 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)
  23690. * * 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)
  23691. * @returns the VertexData of the box
  23692. */
  23693. static CreatePlane(options: {
  23694. size?: number;
  23695. width?: number;
  23696. height?: number;
  23697. sideOrientation?: number;
  23698. frontUVs?: Vector4;
  23699. backUVs?: Vector4;
  23700. }): VertexData;
  23701. /**
  23702. * Creates the VertexData of the Disc or regular Polygon
  23703. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23704. * * radius the radius of the disc, optional default 0.5
  23705. * * tessellation the number of polygon sides, optional, default 64
  23706. * * 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
  23707. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23708. * * 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)
  23709. * * 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)
  23710. * @returns the VertexData of the box
  23711. */
  23712. static CreateDisc(options: {
  23713. radius?: number;
  23714. tessellation?: number;
  23715. arc?: number;
  23716. sideOrientation?: number;
  23717. frontUVs?: Vector4;
  23718. backUVs?: Vector4;
  23719. }): VertexData;
  23720. /**
  23721. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23722. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23723. * @param polygon a mesh built from polygonTriangulation.build()
  23724. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23725. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23726. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23727. * @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)
  23728. * @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)
  23729. * @returns the VertexData of the Polygon
  23730. */
  23731. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23732. /**
  23733. * Creates the VertexData of the IcoSphere
  23734. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23735. * * radius the radius of the IcoSphere, optional default 1
  23736. * * radiusX allows stretching in the x direction, optional, default radius
  23737. * * radiusY allows stretching in the y direction, optional, default radius
  23738. * * radiusZ allows stretching in the z direction, optional, default radius
  23739. * * flat when true creates a flat shaded mesh, optional, default true
  23740. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23741. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23742. * * 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)
  23743. * * 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)
  23744. * @returns the VertexData of the IcoSphere
  23745. */
  23746. static CreateIcoSphere(options: {
  23747. radius?: number;
  23748. radiusX?: number;
  23749. radiusY?: number;
  23750. radiusZ?: number;
  23751. flat?: boolean;
  23752. subdivisions?: number;
  23753. sideOrientation?: number;
  23754. frontUVs?: Vector4;
  23755. backUVs?: Vector4;
  23756. }): VertexData;
  23757. /**
  23758. * Creates the VertexData for a Polyhedron
  23759. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23760. * * type provided types are:
  23761. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23762. * * 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)
  23763. * * size the size of the IcoSphere, optional default 1
  23764. * * sizeX allows stretching in the x direction, optional, default size
  23765. * * sizeY allows stretching in the y direction, optional, default size
  23766. * * sizeZ allows stretching in the z direction, optional, default size
  23767. * * 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
  23768. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23769. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23770. * * flat when true creates a flat shaded mesh, optional, default true
  23771. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23772. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23773. * * 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)
  23774. * * 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)
  23775. * @returns the VertexData of the Polyhedron
  23776. */
  23777. static CreatePolyhedron(options: {
  23778. type?: number;
  23779. size?: number;
  23780. sizeX?: number;
  23781. sizeY?: number;
  23782. sizeZ?: number;
  23783. custom?: any;
  23784. faceUV?: Vector4[];
  23785. faceColors?: Color4[];
  23786. flat?: boolean;
  23787. sideOrientation?: number;
  23788. frontUVs?: Vector4;
  23789. backUVs?: Vector4;
  23790. }): VertexData;
  23791. /**
  23792. * Creates the VertexData for a TorusKnot
  23793. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23794. * * radius the radius of the torus knot, optional, default 2
  23795. * * tube the thickness of the tube, optional, default 0.5
  23796. * * radialSegments the number of sides on each tube segments, optional, default 32
  23797. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23798. * * p the number of windings around the z axis, optional, default 2
  23799. * * q the number of windings around the x axis, optional, default 3
  23800. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23801. * * 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)
  23802. * * 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)
  23803. * @returns the VertexData of the Torus Knot
  23804. */
  23805. static CreateTorusKnot(options: {
  23806. radius?: number;
  23807. tube?: number;
  23808. radialSegments?: number;
  23809. tubularSegments?: number;
  23810. p?: number;
  23811. q?: number;
  23812. sideOrientation?: number;
  23813. frontUVs?: Vector4;
  23814. backUVs?: Vector4;
  23815. }): VertexData;
  23816. /**
  23817. * Compute normals for given positions and indices
  23818. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23819. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23820. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23821. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23822. * * facetNormals : optional array of facet normals (vector3)
  23823. * * facetPositions : optional array of facet positions (vector3)
  23824. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23825. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23826. * * bInfo : optional bounding info, required for facetPartitioning computation
  23827. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23828. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23829. * * useRightHandedSystem: optional boolean to for right handed system computation
  23830. * * depthSort : optional boolean to enable the facet depth sort computation
  23831. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23832. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23833. */
  23834. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23835. facetNormals?: any;
  23836. facetPositions?: any;
  23837. facetPartitioning?: any;
  23838. ratio?: number;
  23839. bInfo?: any;
  23840. bbSize?: Vector3;
  23841. subDiv?: any;
  23842. useRightHandedSystem?: boolean;
  23843. depthSort?: boolean;
  23844. distanceTo?: Vector3;
  23845. depthSortedFacets?: any;
  23846. }): void;
  23847. /** @hidden */
  23848. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23849. /**
  23850. * Applies VertexData created from the imported parameters to the geometry
  23851. * @param parsedVertexData the parsed data from an imported file
  23852. * @param geometry the geometry to apply the VertexData to
  23853. */
  23854. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23855. }
  23856. }
  23857. declare module BABYLON {
  23858. /**
  23859. * Class containing static functions to help procedurally build meshes
  23860. */
  23861. export class DiscBuilder {
  23862. /**
  23863. * Creates a plane polygonal mesh. By default, this is a disc
  23864. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23865. * * 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
  23866. * * 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
  23867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23868. * * 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
  23869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23870. * @param name defines the name of the mesh
  23871. * @param options defines the options used to create the mesh
  23872. * @param scene defines the hosting scene
  23873. * @returns the plane polygonal mesh
  23874. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23875. */
  23876. static CreateDisc(name: string, options: {
  23877. radius?: number;
  23878. tessellation?: number;
  23879. arc?: number;
  23880. updatable?: boolean;
  23881. sideOrientation?: number;
  23882. frontUVs?: Vector4;
  23883. backUVs?: Vector4;
  23884. }, scene?: Nullable<Scene>): Mesh;
  23885. }
  23886. }
  23887. declare module BABYLON {
  23888. /**
  23889. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23890. *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.
  23891. * The SPS is also a particle system. It provides some methods to manage the particles.
  23892. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23893. *
  23894. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23895. */
  23896. export class SolidParticleSystem implements IDisposable {
  23897. /**
  23898. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23899. * Example : var p = SPS.particles[i];
  23900. */
  23901. particles: SolidParticle[];
  23902. /**
  23903. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23904. */
  23905. nbParticles: number;
  23906. /**
  23907. * If the particles must ever face the camera (default false). Useful for planar particles.
  23908. */
  23909. billboard: boolean;
  23910. /**
  23911. * Recompute normals when adding a shape
  23912. */
  23913. recomputeNormals: boolean;
  23914. /**
  23915. * This a counter ofr your own usage. It's not set by any SPS functions.
  23916. */
  23917. counter: number;
  23918. /**
  23919. * The SPS name. This name is also given to the underlying mesh.
  23920. */
  23921. name: string;
  23922. /**
  23923. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23924. */
  23925. mesh: Mesh;
  23926. /**
  23927. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23928. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23929. */
  23930. vars: any;
  23931. /**
  23932. * This array is populated when the SPS is set as 'pickable'.
  23933. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23934. * Each element of this array is an object `{idx: int, faceId: int}`.
  23935. * `idx` is the picked particle index in the `SPS.particles` array
  23936. * `faceId` is the picked face index counted within this particle.
  23937. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23938. */
  23939. pickedParticles: {
  23940. idx: number;
  23941. faceId: number;
  23942. }[];
  23943. /**
  23944. * This array is populated when `enableDepthSort` is set to true.
  23945. * Each element of this array is an instance of the class DepthSortedParticle.
  23946. */
  23947. depthSortedParticles: DepthSortedParticle[];
  23948. /**
  23949. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23950. * @hidden
  23951. */
  23952. _bSphereOnly: boolean;
  23953. /**
  23954. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23955. * @hidden
  23956. */
  23957. _bSphereRadiusFactor: number;
  23958. private _scene;
  23959. private _positions;
  23960. private _indices;
  23961. private _normals;
  23962. private _colors;
  23963. private _uvs;
  23964. private _indices32;
  23965. private _positions32;
  23966. private _normals32;
  23967. private _fixedNormal32;
  23968. private _colors32;
  23969. private _uvs32;
  23970. private _index;
  23971. private _updatable;
  23972. private _pickable;
  23973. private _isVisibilityBoxLocked;
  23974. private _alwaysVisible;
  23975. private _depthSort;
  23976. private _shapeCounter;
  23977. private _copy;
  23978. private _color;
  23979. private _computeParticleColor;
  23980. private _computeParticleTexture;
  23981. private _computeParticleRotation;
  23982. private _computeParticleVertex;
  23983. private _computeBoundingBox;
  23984. private _depthSortParticles;
  23985. private _camera;
  23986. private _mustUnrotateFixedNormals;
  23987. private _particlesIntersect;
  23988. private _needs32Bits;
  23989. /**
  23990. * Creates a SPS (Solid Particle System) object.
  23991. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23992. * @param scene (Scene) is the scene in which the SPS is added.
  23993. * @param options defines the options of the sps e.g.
  23994. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23995. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23996. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23997. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23998. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23999. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24000. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24001. */
  24002. constructor(name: string, scene: Scene, options?: {
  24003. updatable?: boolean;
  24004. isPickable?: boolean;
  24005. enableDepthSort?: boolean;
  24006. particleIntersection?: boolean;
  24007. boundingSphereOnly?: boolean;
  24008. bSphereRadiusFactor?: number;
  24009. });
  24010. /**
  24011. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24012. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24013. * @returns the created mesh
  24014. */
  24015. buildMesh(): Mesh;
  24016. /**
  24017. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24018. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24019. * Thus the particles generated from `digest()` have their property `position` set yet.
  24020. * @param mesh ( Mesh ) is the mesh to be digested
  24021. * @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
  24022. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24023. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24024. * @returns the current SPS
  24025. */
  24026. digest(mesh: Mesh, options?: {
  24027. facetNb?: number;
  24028. number?: number;
  24029. delta?: number;
  24030. }): SolidParticleSystem;
  24031. private _unrotateFixedNormals;
  24032. private _resetCopy;
  24033. private _meshBuilder;
  24034. private _posToShape;
  24035. private _uvsToShapeUV;
  24036. private _addParticle;
  24037. /**
  24038. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24039. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24040. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24041. * @param nb (positive integer) the number of particles to be created from this model
  24042. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24043. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24044. * @returns the number of shapes in the system
  24045. */
  24046. addShape(mesh: Mesh, nb: number, options?: {
  24047. positionFunction?: any;
  24048. vertexFunction?: any;
  24049. }): number;
  24050. private _rebuildParticle;
  24051. /**
  24052. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24053. * @returns the SPS.
  24054. */
  24055. rebuildMesh(): SolidParticleSystem;
  24056. /**
  24057. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24058. * This method calls `updateParticle()` for each particle of the SPS.
  24059. * For an animated SPS, it is usually called within the render loop.
  24060. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24061. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24062. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24063. * @returns the SPS.
  24064. */
  24065. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24066. /**
  24067. * Disposes the SPS.
  24068. */
  24069. dispose(): void;
  24070. /**
  24071. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24072. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24073. * @returns the SPS.
  24074. */
  24075. refreshVisibleSize(): SolidParticleSystem;
  24076. /**
  24077. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24078. * @param size the size (float) of the visibility box
  24079. * note : this doesn't lock the SPS mesh bounding box.
  24080. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24081. */
  24082. setVisibilityBox(size: number): void;
  24083. /**
  24084. * Gets whether the SPS as always visible or not
  24085. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24086. */
  24087. /**
  24088. * Sets the SPS as always visible or not
  24089. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24090. */
  24091. isAlwaysVisible: boolean;
  24092. /**
  24093. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24094. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24095. */
  24096. /**
  24097. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24098. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24099. */
  24100. isVisibilityBoxLocked: boolean;
  24101. /**
  24102. * Tells to `setParticles()` to compute the particle rotations or not.
  24103. * Default value : true. The SPS is faster when it's set to false.
  24104. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24105. */
  24106. /**
  24107. * Gets if `setParticles()` computes the particle rotations or not.
  24108. * Default value : true. The SPS is faster when it's set to false.
  24109. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24110. */
  24111. computeParticleRotation: boolean;
  24112. /**
  24113. * Tells to `setParticles()` to compute the particle colors or not.
  24114. * Default value : true. The SPS is faster when it's set to false.
  24115. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24116. */
  24117. /**
  24118. * Gets if `setParticles()` computes the particle colors or not.
  24119. * Default value : true. The SPS is faster when it's set to false.
  24120. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24121. */
  24122. computeParticleColor: boolean;
  24123. /**
  24124. * Gets if `setParticles()` computes the particle textures or not.
  24125. * Default value : true. The SPS is faster when it's set to false.
  24126. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24127. */
  24128. computeParticleTexture: boolean;
  24129. /**
  24130. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24131. * Default value : false. The SPS is faster when it's set to false.
  24132. * Note : the particle custom vertex positions aren't stored values.
  24133. */
  24134. /**
  24135. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24136. * Default value : false. The SPS is faster when it's set to false.
  24137. * Note : the particle custom vertex positions aren't stored values.
  24138. */
  24139. computeParticleVertex: boolean;
  24140. /**
  24141. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24142. */
  24143. /**
  24144. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24145. */
  24146. computeBoundingBox: boolean;
  24147. /**
  24148. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24149. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24150. * Default : `true`
  24151. */
  24152. /**
  24153. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24154. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24155. * Default : `true`
  24156. */
  24157. depthSortParticles: boolean;
  24158. /**
  24159. * This function does nothing. It may be overwritten to set all the particle first values.
  24160. * The SPS doesn't call this function, you may have to call it by your own.
  24161. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24162. */
  24163. initParticles(): void;
  24164. /**
  24165. * This function does nothing. It may be overwritten to recycle a particle.
  24166. * The SPS doesn't call this function, you may have to call it by your own.
  24167. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24168. * @param particle The particle to recycle
  24169. * @returns the recycled particle
  24170. */
  24171. recycleParticle(particle: SolidParticle): SolidParticle;
  24172. /**
  24173. * Updates a particle : this function should be overwritten by the user.
  24174. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24175. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24176. * @example : just set a particle position or velocity and recycle conditions
  24177. * @param particle The particle to update
  24178. * @returns the updated particle
  24179. */
  24180. updateParticle(particle: SolidParticle): SolidParticle;
  24181. /**
  24182. * Updates a vertex of a particle : it can be overwritten by the user.
  24183. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24184. * @param particle the current particle
  24185. * @param vertex the current index of the current particle
  24186. * @param pt the index of the current vertex in the particle shape
  24187. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24188. * @example : just set a vertex particle position
  24189. * @returns the updated vertex
  24190. */
  24191. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24192. /**
  24193. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24194. * This does nothing and may be overwritten by the user.
  24195. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24196. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24197. * @param update the boolean update value actually passed to setParticles()
  24198. */
  24199. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24200. /**
  24201. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24202. * This will be passed three parameters.
  24203. * This does nothing and may be overwritten by the user.
  24204. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24205. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24206. * @param update the boolean update value actually passed to setParticles()
  24207. */
  24208. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24209. }
  24210. }
  24211. declare module BABYLON {
  24212. /**
  24213. * Represents one particle of a solid particle system.
  24214. */
  24215. export class SolidParticle {
  24216. /**
  24217. * particle global index
  24218. */
  24219. idx: number;
  24220. /**
  24221. * The color of the particle
  24222. */
  24223. color: Nullable<Color4>;
  24224. /**
  24225. * The world space position of the particle.
  24226. */
  24227. position: Vector3;
  24228. /**
  24229. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24230. */
  24231. rotation: Vector3;
  24232. /**
  24233. * The world space rotation quaternion of the particle.
  24234. */
  24235. rotationQuaternion: Nullable<Quaternion>;
  24236. /**
  24237. * The scaling of the particle.
  24238. */
  24239. scaling: Vector3;
  24240. /**
  24241. * The uvs of the particle.
  24242. */
  24243. uvs: Vector4;
  24244. /**
  24245. * The current speed of the particle.
  24246. */
  24247. velocity: Vector3;
  24248. /**
  24249. * The pivot point in the particle local space.
  24250. */
  24251. pivot: Vector3;
  24252. /**
  24253. * Must the particle be translated from its pivot point in its local space ?
  24254. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24255. * Default : false
  24256. */
  24257. translateFromPivot: boolean;
  24258. /**
  24259. * Is the particle active or not ?
  24260. */
  24261. alive: boolean;
  24262. /**
  24263. * Is the particle visible or not ?
  24264. */
  24265. isVisible: boolean;
  24266. /**
  24267. * Index of this particle in the global "positions" array (Internal use)
  24268. * @hidden
  24269. */
  24270. _pos: number;
  24271. /**
  24272. * @hidden Index of this particle in the global "indices" array (Internal use)
  24273. */
  24274. _ind: number;
  24275. /**
  24276. * @hidden ModelShape of this particle (Internal use)
  24277. */
  24278. _model: ModelShape;
  24279. /**
  24280. * ModelShape id of this particle
  24281. */
  24282. shapeId: number;
  24283. /**
  24284. * Index of the particle in its shape id (Internal use)
  24285. */
  24286. idxInShape: number;
  24287. /**
  24288. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24289. */
  24290. _modelBoundingInfo: BoundingInfo;
  24291. /**
  24292. * @hidden Particle BoundingInfo object (Internal use)
  24293. */
  24294. _boundingInfo: BoundingInfo;
  24295. /**
  24296. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24297. */
  24298. _sps: SolidParticleSystem;
  24299. /**
  24300. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24301. */
  24302. _stillInvisible: boolean;
  24303. /**
  24304. * @hidden Last computed particle rotation matrix
  24305. */
  24306. _rotationMatrix: number[];
  24307. /**
  24308. * Parent particle Id, if any.
  24309. * Default null.
  24310. */
  24311. parentId: Nullable<number>;
  24312. /**
  24313. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24314. * The possible values are :
  24315. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24316. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24317. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24318. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24319. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24320. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24321. * */
  24322. cullingStrategy: number;
  24323. /**
  24324. * @hidden Internal global position in the SPS.
  24325. */
  24326. _globalPosition: Vector3;
  24327. /**
  24328. * Creates a Solid Particle object.
  24329. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24330. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24331. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24332. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24333. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24334. * @param shapeId (integer) is the model shape identifier in the SPS.
  24335. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24336. * @param sps defines the sps it is associated to
  24337. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24338. */
  24339. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24340. /**
  24341. * Legacy support, changed scale to scaling
  24342. */
  24343. /**
  24344. * Legacy support, changed scale to scaling
  24345. */
  24346. scale: Vector3;
  24347. /**
  24348. * Legacy support, changed quaternion to rotationQuaternion
  24349. */
  24350. /**
  24351. * Legacy support, changed quaternion to rotationQuaternion
  24352. */
  24353. quaternion: Nullable<Quaternion>;
  24354. /**
  24355. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24356. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24357. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24358. * @returns true if it intersects
  24359. */
  24360. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24361. /**
  24362. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24363. * A particle is in the frustum if its bounding box intersects the frustum
  24364. * @param frustumPlanes defines the frustum to test
  24365. * @returns true if the particle is in the frustum planes
  24366. */
  24367. isInFrustum(frustumPlanes: Plane[]): boolean;
  24368. /**
  24369. * get the rotation matrix of the particle
  24370. * @hidden
  24371. */
  24372. getRotationMatrix(m: Matrix): void;
  24373. }
  24374. /**
  24375. * Represents the shape of the model used by one particle of a solid particle system.
  24376. * SPS internal tool, don't use it manually.
  24377. */
  24378. export class ModelShape {
  24379. /**
  24380. * The shape id
  24381. * @hidden
  24382. */
  24383. shapeID: number;
  24384. /**
  24385. * flat array of model positions (internal use)
  24386. * @hidden
  24387. */
  24388. _shape: Vector3[];
  24389. /**
  24390. * flat array of model UVs (internal use)
  24391. * @hidden
  24392. */
  24393. _shapeUV: number[];
  24394. /**
  24395. * length of the shape in the model indices array (internal use)
  24396. * @hidden
  24397. */
  24398. _indicesLength: number;
  24399. /**
  24400. * Custom position function (internal use)
  24401. * @hidden
  24402. */
  24403. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24404. /**
  24405. * Custom vertex function (internal use)
  24406. * @hidden
  24407. */
  24408. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24409. /**
  24410. * 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.
  24411. * SPS internal tool, don't use it manually.
  24412. * @hidden
  24413. */
  24414. 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>);
  24415. }
  24416. /**
  24417. * Represents a Depth Sorted Particle in the solid particle system.
  24418. */
  24419. export class DepthSortedParticle {
  24420. /**
  24421. * Index of the particle in the "indices" array
  24422. */
  24423. ind: number;
  24424. /**
  24425. * Length of the particle shape in the "indices" array
  24426. */
  24427. indicesLength: number;
  24428. /**
  24429. * Squared distance from the particle to the camera
  24430. */
  24431. sqDistance: number;
  24432. }
  24433. }
  24434. declare module BABYLON {
  24435. /**
  24436. * @hidden
  24437. */
  24438. export class _MeshCollisionData {
  24439. _checkCollisions: boolean;
  24440. _collisionMask: number;
  24441. _collisionGroup: number;
  24442. _collider: Nullable<Collider>;
  24443. _oldPositionForCollisions: Vector3;
  24444. _diffPositionForCollisions: Vector3;
  24445. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24446. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24447. }
  24448. }
  24449. declare module BABYLON {
  24450. /** @hidden */
  24451. class _FacetDataStorage {
  24452. facetPositions: Vector3[];
  24453. facetNormals: Vector3[];
  24454. facetPartitioning: number[][];
  24455. facetNb: number;
  24456. partitioningSubdivisions: number;
  24457. partitioningBBoxRatio: number;
  24458. facetDataEnabled: boolean;
  24459. facetParameters: any;
  24460. bbSize: Vector3;
  24461. subDiv: {
  24462. max: number;
  24463. X: number;
  24464. Y: number;
  24465. Z: number;
  24466. };
  24467. facetDepthSort: boolean;
  24468. facetDepthSortEnabled: boolean;
  24469. depthSortedIndices: IndicesArray;
  24470. depthSortedFacets: {
  24471. ind: number;
  24472. sqDistance: number;
  24473. }[];
  24474. facetDepthSortFunction: (f1: {
  24475. ind: number;
  24476. sqDistance: number;
  24477. }, f2: {
  24478. ind: number;
  24479. sqDistance: number;
  24480. }) => number;
  24481. facetDepthSortFrom: Vector3;
  24482. facetDepthSortOrigin: Vector3;
  24483. invertedMatrix: Matrix;
  24484. }
  24485. /**
  24486. * @hidden
  24487. **/
  24488. class _InternalAbstractMeshDataInfo {
  24489. _hasVertexAlpha: boolean;
  24490. _useVertexColors: boolean;
  24491. _numBoneInfluencers: number;
  24492. _applyFog: boolean;
  24493. _receiveShadows: boolean;
  24494. _facetData: _FacetDataStorage;
  24495. _visibility: number;
  24496. _skeleton: Nullable<Skeleton>;
  24497. _layerMask: number;
  24498. _computeBonesUsingShaders: boolean;
  24499. _isActive: boolean;
  24500. _onlyForInstances: boolean;
  24501. _isActiveIntermediate: boolean;
  24502. _onlyForInstancesIntermediate: boolean;
  24503. }
  24504. /**
  24505. * Class used to store all common mesh properties
  24506. */
  24507. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24508. /** No occlusion */
  24509. static OCCLUSION_TYPE_NONE: number;
  24510. /** Occlusion set to optimisitic */
  24511. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24512. /** Occlusion set to strict */
  24513. static OCCLUSION_TYPE_STRICT: number;
  24514. /** Use an accurante occlusion algorithm */
  24515. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24516. /** Use a conservative occlusion algorithm */
  24517. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24518. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24519. * Test order :
  24520. * Is the bounding sphere outside the frustum ?
  24521. * If not, are the bounding box vertices outside the frustum ?
  24522. * It not, then the cullable object is in the frustum.
  24523. */
  24524. static readonly CULLINGSTRATEGY_STANDARD: number;
  24525. /** Culling strategy : Bounding Sphere Only.
  24526. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24527. * It's also less accurate than the standard because some not visible objects can still be selected.
  24528. * Test : is the bounding sphere outside the frustum ?
  24529. * If not, then the cullable object is in the frustum.
  24530. */
  24531. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24532. /** Culling strategy : Optimistic Inclusion.
  24533. * This in an inclusion test first, then the standard exclusion test.
  24534. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24535. * 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.
  24536. * Anyway, it's as accurate as the standard strategy.
  24537. * Test :
  24538. * Is the cullable object bounding sphere center in the frustum ?
  24539. * If not, apply the default culling strategy.
  24540. */
  24541. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24542. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24543. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24544. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24545. * 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.
  24546. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24547. * Test :
  24548. * Is the cullable object bounding sphere center in the frustum ?
  24549. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24550. */
  24551. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24552. /**
  24553. * No billboard
  24554. */
  24555. static readonly BILLBOARDMODE_NONE: number;
  24556. /** Billboard on X axis */
  24557. static readonly BILLBOARDMODE_X: number;
  24558. /** Billboard on Y axis */
  24559. static readonly BILLBOARDMODE_Y: number;
  24560. /** Billboard on Z axis */
  24561. static readonly BILLBOARDMODE_Z: number;
  24562. /** Billboard on all axes */
  24563. static readonly BILLBOARDMODE_ALL: number;
  24564. /** @hidden */
  24565. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  24566. /**
  24567. * The culling strategy to use to check whether the mesh must be rendered or not.
  24568. * This value can be changed at any time and will be used on the next render mesh selection.
  24569. * The possible values are :
  24570. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24571. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24572. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24573. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24574. * Please read each static variable documentation to get details about the culling process.
  24575. * */
  24576. cullingStrategy: number;
  24577. /**
  24578. * Gets the number of facets in the mesh
  24579. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24580. */
  24581. readonly facetNb: number;
  24582. /**
  24583. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24584. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24585. */
  24586. partitioningSubdivisions: number;
  24587. /**
  24588. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24589. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24590. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24591. */
  24592. partitioningBBoxRatio: number;
  24593. /**
  24594. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24595. * Works only for updatable meshes.
  24596. * Doesn't work with multi-materials
  24597. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24598. */
  24599. mustDepthSortFacets: boolean;
  24600. /**
  24601. * The location (Vector3) where the facet depth sort must be computed from.
  24602. * By default, the active camera position.
  24603. * Used only when facet depth sort is enabled
  24604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24605. */
  24606. facetDepthSortFrom: Vector3;
  24607. /**
  24608. * gets a boolean indicating if facetData is enabled
  24609. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24610. */
  24611. readonly isFacetDataEnabled: boolean;
  24612. /** @hidden */
  24613. _updateNonUniformScalingState(value: boolean): boolean;
  24614. /**
  24615. * An event triggered when this mesh collides with another one
  24616. */
  24617. onCollideObservable: Observable<AbstractMesh>;
  24618. /** Set a function to call when this mesh collides with another one */
  24619. onCollide: () => void;
  24620. /**
  24621. * An event triggered when the collision's position changes
  24622. */
  24623. onCollisionPositionChangeObservable: Observable<Vector3>;
  24624. /** Set a function to call when the collision's position changes */
  24625. onCollisionPositionChange: () => void;
  24626. /**
  24627. * An event triggered when material is changed
  24628. */
  24629. onMaterialChangedObservable: Observable<AbstractMesh>;
  24630. /**
  24631. * Gets or sets the orientation for POV movement & rotation
  24632. */
  24633. definedFacingForward: boolean;
  24634. /** @hidden */
  24635. _occlusionQuery: Nullable<WebGLQuery>;
  24636. /** @hidden */
  24637. _renderingGroup: Nullable<RenderingGroup>;
  24638. /**
  24639. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24640. */
  24641. /**
  24642. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24643. */
  24644. visibility: number;
  24645. /** Gets or sets the alpha index used to sort transparent meshes
  24646. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24647. */
  24648. alphaIndex: number;
  24649. /**
  24650. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24651. */
  24652. isVisible: boolean;
  24653. /**
  24654. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24655. */
  24656. isPickable: boolean;
  24657. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24658. showSubMeshesBoundingBox: boolean;
  24659. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24660. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24661. */
  24662. isBlocker: boolean;
  24663. /**
  24664. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24665. */
  24666. enablePointerMoveEvents: boolean;
  24667. /**
  24668. * Specifies the rendering group id for this mesh (0 by default)
  24669. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24670. */
  24671. renderingGroupId: number;
  24672. private _material;
  24673. /** Gets or sets current material */
  24674. material: Nullable<Material>;
  24675. /**
  24676. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24677. * @see http://doc.babylonjs.com/babylon101/shadows
  24678. */
  24679. receiveShadows: boolean;
  24680. /** Defines color to use when rendering outline */
  24681. outlineColor: Color3;
  24682. /** Define width to use when rendering outline */
  24683. outlineWidth: number;
  24684. /** Defines color to use when rendering overlay */
  24685. overlayColor: Color3;
  24686. /** Defines alpha to use when rendering overlay */
  24687. overlayAlpha: number;
  24688. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24689. hasVertexAlpha: boolean;
  24690. /** 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) */
  24691. useVertexColors: boolean;
  24692. /**
  24693. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24694. */
  24695. computeBonesUsingShaders: boolean;
  24696. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24697. numBoneInfluencers: number;
  24698. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24699. applyFog: boolean;
  24700. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24701. useOctreeForRenderingSelection: boolean;
  24702. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24703. useOctreeForPicking: boolean;
  24704. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24705. useOctreeForCollisions: boolean;
  24706. /**
  24707. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24708. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24709. */
  24710. layerMask: number;
  24711. /**
  24712. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24713. */
  24714. alwaysSelectAsActiveMesh: boolean;
  24715. /**
  24716. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24717. */
  24718. doNotSyncBoundingInfo: boolean;
  24719. /**
  24720. * Gets or sets the current action manager
  24721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24722. */
  24723. actionManager: Nullable<AbstractActionManager>;
  24724. private _meshCollisionData;
  24725. /**
  24726. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24727. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24728. */
  24729. ellipsoid: Vector3;
  24730. /**
  24731. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24732. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24733. */
  24734. ellipsoidOffset: Vector3;
  24735. /**
  24736. * Gets or sets a collision mask used to mask collisions (default is -1).
  24737. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24738. */
  24739. collisionMask: number;
  24740. /**
  24741. * Gets or sets the current collision group mask (-1 by default).
  24742. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24743. */
  24744. collisionGroup: number;
  24745. /**
  24746. * Defines edge width used when edgesRenderer is enabled
  24747. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24748. */
  24749. edgesWidth: number;
  24750. /**
  24751. * Defines edge color used when edgesRenderer is enabled
  24752. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24753. */
  24754. edgesColor: Color4;
  24755. /** @hidden */
  24756. _edgesRenderer: Nullable<IEdgesRenderer>;
  24757. /** @hidden */
  24758. _masterMesh: Nullable<AbstractMesh>;
  24759. /** @hidden */
  24760. _boundingInfo: Nullable<BoundingInfo>;
  24761. /** @hidden */
  24762. _renderId: number;
  24763. /**
  24764. * Gets or sets the list of subMeshes
  24765. * @see http://doc.babylonjs.com/how_to/multi_materials
  24766. */
  24767. subMeshes: SubMesh[];
  24768. /** @hidden */
  24769. _intersectionsInProgress: AbstractMesh[];
  24770. /** @hidden */
  24771. _unIndexed: boolean;
  24772. /** @hidden */
  24773. _lightSources: Light[];
  24774. /** Gets the list of lights affecting that mesh */
  24775. readonly lightSources: Light[];
  24776. /** @hidden */
  24777. readonly _positions: Nullable<Vector3[]>;
  24778. /** @hidden */
  24779. _waitingData: {
  24780. lods: Nullable<any>;
  24781. actions: Nullable<any>;
  24782. freezeWorldMatrix: Nullable<boolean>;
  24783. };
  24784. /** @hidden */
  24785. _bonesTransformMatrices: Nullable<Float32Array>;
  24786. /**
  24787. * Gets or sets a skeleton to apply skining transformations
  24788. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24789. */
  24790. skeleton: Nullable<Skeleton>;
  24791. /**
  24792. * An event triggered when the mesh is rebuilt.
  24793. */
  24794. onRebuildObservable: Observable<AbstractMesh>;
  24795. /**
  24796. * Creates a new AbstractMesh
  24797. * @param name defines the name of the mesh
  24798. * @param scene defines the hosting scene
  24799. */
  24800. constructor(name: string, scene?: Nullable<Scene>);
  24801. /**
  24802. * Returns the string "AbstractMesh"
  24803. * @returns "AbstractMesh"
  24804. */
  24805. getClassName(): string;
  24806. /**
  24807. * Gets a string representation of the current mesh
  24808. * @param fullDetails defines a boolean indicating if full details must be included
  24809. * @returns a string representation of the current mesh
  24810. */
  24811. toString(fullDetails?: boolean): string;
  24812. /**
  24813. * @hidden
  24814. */
  24815. protected _getEffectiveParent(): Nullable<Node>;
  24816. /** @hidden */
  24817. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24818. /** @hidden */
  24819. _rebuild(): void;
  24820. /** @hidden */
  24821. _resyncLightSources(): void;
  24822. /** @hidden */
  24823. _resyncLighSource(light: Light): void;
  24824. /** @hidden */
  24825. _unBindEffect(): void;
  24826. /** @hidden */
  24827. _removeLightSource(light: Light): void;
  24828. private _markSubMeshesAsDirty;
  24829. /** @hidden */
  24830. _markSubMeshesAsLightDirty(): void;
  24831. /** @hidden */
  24832. _markSubMeshesAsAttributesDirty(): void;
  24833. /** @hidden */
  24834. _markSubMeshesAsMiscDirty(): void;
  24835. /**
  24836. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24837. */
  24838. scaling: Vector3;
  24839. /**
  24840. * Returns true if the mesh is blocked. Implemented by child classes
  24841. */
  24842. readonly isBlocked: boolean;
  24843. /**
  24844. * Returns the mesh itself by default. Implemented by child classes
  24845. * @param camera defines the camera to use to pick the right LOD level
  24846. * @returns the currentAbstractMesh
  24847. */
  24848. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24849. /**
  24850. * Returns 0 by default. Implemented by child classes
  24851. * @returns an integer
  24852. */
  24853. getTotalVertices(): number;
  24854. /**
  24855. * Returns a positive integer : the total number of indices in this mesh geometry.
  24856. * @returns the numner of indices or zero if the mesh has no geometry.
  24857. */
  24858. getTotalIndices(): number;
  24859. /**
  24860. * Returns null by default. Implemented by child classes
  24861. * @returns null
  24862. */
  24863. getIndices(): Nullable<IndicesArray>;
  24864. /**
  24865. * Returns the array of the requested vertex data kind. Implemented by child classes
  24866. * @param kind defines the vertex data kind to use
  24867. * @returns null
  24868. */
  24869. getVerticesData(kind: string): Nullable<FloatArray>;
  24870. /**
  24871. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24872. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24873. * Note that a new underlying VertexBuffer object is created each call.
  24874. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24875. * @param kind defines vertex data kind:
  24876. * * VertexBuffer.PositionKind
  24877. * * VertexBuffer.UVKind
  24878. * * VertexBuffer.UV2Kind
  24879. * * VertexBuffer.UV3Kind
  24880. * * VertexBuffer.UV4Kind
  24881. * * VertexBuffer.UV5Kind
  24882. * * VertexBuffer.UV6Kind
  24883. * * VertexBuffer.ColorKind
  24884. * * VertexBuffer.MatricesIndicesKind
  24885. * * VertexBuffer.MatricesIndicesExtraKind
  24886. * * VertexBuffer.MatricesWeightsKind
  24887. * * VertexBuffer.MatricesWeightsExtraKind
  24888. * @param data defines the data source
  24889. * @param updatable defines if the data must be flagged as updatable (or static)
  24890. * @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
  24891. * @returns the current mesh
  24892. */
  24893. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24894. /**
  24895. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24896. * If the mesh has no geometry, it is simply returned as it is.
  24897. * @param kind defines vertex data kind:
  24898. * * VertexBuffer.PositionKind
  24899. * * VertexBuffer.UVKind
  24900. * * VertexBuffer.UV2Kind
  24901. * * VertexBuffer.UV3Kind
  24902. * * VertexBuffer.UV4Kind
  24903. * * VertexBuffer.UV5Kind
  24904. * * VertexBuffer.UV6Kind
  24905. * * VertexBuffer.ColorKind
  24906. * * VertexBuffer.MatricesIndicesKind
  24907. * * VertexBuffer.MatricesIndicesExtraKind
  24908. * * VertexBuffer.MatricesWeightsKind
  24909. * * VertexBuffer.MatricesWeightsExtraKind
  24910. * @param data defines the data source
  24911. * @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
  24912. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24913. * @returns the current mesh
  24914. */
  24915. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24916. /**
  24917. * Sets the mesh indices,
  24918. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24919. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24920. * @param totalVertices Defines the total number of vertices
  24921. * @returns the current mesh
  24922. */
  24923. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24924. /**
  24925. * Gets a boolean indicating if specific vertex data is present
  24926. * @param kind defines the vertex data kind to use
  24927. * @returns true is data kind is present
  24928. */
  24929. isVerticesDataPresent(kind: string): boolean;
  24930. /**
  24931. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  24932. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  24933. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  24934. * @returns a BoundingInfo
  24935. */
  24936. getBoundingInfo(): BoundingInfo;
  24937. /**
  24938. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24939. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24940. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24941. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  24942. * @returns the current mesh
  24943. */
  24944. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  24945. /**
  24946. * Overwrite the current bounding info
  24947. * @param boundingInfo defines the new bounding info
  24948. * @returns the current mesh
  24949. */
  24950. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24951. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24952. readonly useBones: boolean;
  24953. /** @hidden */
  24954. _preActivate(): void;
  24955. /** @hidden */
  24956. _preActivateForIntermediateRendering(renderId: number): void;
  24957. /** @hidden */
  24958. _activate(renderId: number, intermediateRendering: boolean): boolean;
  24959. /** @hidden */
  24960. _postActivate(): void;
  24961. /** @hidden */
  24962. _freeze(): void;
  24963. /** @hidden */
  24964. _unFreeze(): void;
  24965. /**
  24966. * Gets the current world matrix
  24967. * @returns a Matrix
  24968. */
  24969. getWorldMatrix(): Matrix;
  24970. /** @hidden */
  24971. _getWorldMatrixDeterminant(): number;
  24972. /**
  24973. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24974. */
  24975. readonly isAnInstance: boolean;
  24976. /**
  24977. * Perform relative position change from the point of view of behind the front of the mesh.
  24978. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24979. * Supports definition of mesh facing forward or backward
  24980. * @param amountRight defines the distance on the right axis
  24981. * @param amountUp defines the distance on the up axis
  24982. * @param amountForward defines the distance on the forward axis
  24983. * @returns the current mesh
  24984. */
  24985. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24986. /**
  24987. * Calculate relative position change from the point of view of behind the front of the mesh.
  24988. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24989. * Supports definition of mesh facing forward or backward
  24990. * @param amountRight defines the distance on the right axis
  24991. * @param amountUp defines the distance on the up axis
  24992. * @param amountForward defines the distance on the forward axis
  24993. * @returns the new displacement vector
  24994. */
  24995. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24996. /**
  24997. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24998. * Supports definition of mesh facing forward or backward
  24999. * @param flipBack defines the flip
  25000. * @param twirlClockwise defines the twirl
  25001. * @param tiltRight defines the tilt
  25002. * @returns the current mesh
  25003. */
  25004. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25005. /**
  25006. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25007. * Supports definition of mesh facing forward or backward.
  25008. * @param flipBack defines the flip
  25009. * @param twirlClockwise defines the twirl
  25010. * @param tiltRight defines the tilt
  25011. * @returns the new rotation vector
  25012. */
  25013. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25014. /**
  25015. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25016. * This means the mesh underlying bounding box and sphere are recomputed.
  25017. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25018. * @returns the current mesh
  25019. */
  25020. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25021. /** @hidden */
  25022. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25023. /** @hidden */
  25024. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25025. /** @hidden */
  25026. _updateBoundingInfo(): AbstractMesh;
  25027. /** @hidden */
  25028. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25029. /** @hidden */
  25030. protected _afterComputeWorldMatrix(): void;
  25031. /** @hidden */
  25032. readonly _effectiveMesh: AbstractMesh;
  25033. /**
  25034. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25035. * A mesh is in the frustum if its bounding box intersects the frustum
  25036. * @param frustumPlanes defines the frustum to test
  25037. * @returns true if the mesh is in the frustum planes
  25038. */
  25039. isInFrustum(frustumPlanes: Plane[]): boolean;
  25040. /**
  25041. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25042. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25043. * @param frustumPlanes defines the frustum to test
  25044. * @returns true if the mesh is completely in the frustum planes
  25045. */
  25046. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25047. /**
  25048. * True if the mesh intersects another mesh or a SolidParticle object
  25049. * @param mesh defines a target mesh or SolidParticle to test
  25050. * @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)
  25051. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25052. * @returns true if there is an intersection
  25053. */
  25054. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25055. /**
  25056. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25057. * @param point defines the point to test
  25058. * @returns true if there is an intersection
  25059. */
  25060. intersectsPoint(point: Vector3): boolean;
  25061. /**
  25062. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25063. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25064. */
  25065. checkCollisions: boolean;
  25066. /**
  25067. * Gets Collider object used to compute collisions (not physics)
  25068. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25069. */
  25070. readonly collider: Nullable<Collider>;
  25071. /**
  25072. * Move the mesh using collision engine
  25073. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25074. * @param displacement defines the requested displacement vector
  25075. * @returns the current mesh
  25076. */
  25077. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25078. private _onCollisionPositionChange;
  25079. /** @hidden */
  25080. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25081. /** @hidden */
  25082. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25083. /** @hidden */
  25084. _checkCollision(collider: Collider): AbstractMesh;
  25085. /** @hidden */
  25086. _generatePointsArray(): boolean;
  25087. /**
  25088. * Checks if the passed Ray intersects with the mesh
  25089. * @param ray defines the ray to use
  25090. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25091. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25092. * @returns the picking info
  25093. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25094. */
  25095. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25096. /**
  25097. * Clones the current mesh
  25098. * @param name defines the mesh name
  25099. * @param newParent defines the new mesh parent
  25100. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25101. * @returns the new mesh
  25102. */
  25103. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25104. /**
  25105. * Disposes all the submeshes of the current meshnp
  25106. * @returns the current mesh
  25107. */
  25108. releaseSubMeshes(): AbstractMesh;
  25109. /**
  25110. * Releases resources associated with this abstract mesh.
  25111. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25112. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25113. */
  25114. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25115. /**
  25116. * Adds the passed mesh as a child to the current mesh
  25117. * @param mesh defines the child mesh
  25118. * @returns the current mesh
  25119. */
  25120. addChild(mesh: AbstractMesh): AbstractMesh;
  25121. /**
  25122. * Removes the passed mesh from the current mesh children list
  25123. * @param mesh defines the child mesh
  25124. * @returns the current mesh
  25125. */
  25126. removeChild(mesh: AbstractMesh): AbstractMesh;
  25127. /** @hidden */
  25128. private _initFacetData;
  25129. /**
  25130. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25131. * This method can be called within the render loop.
  25132. * 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
  25133. * @returns the current mesh
  25134. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25135. */
  25136. updateFacetData(): AbstractMesh;
  25137. /**
  25138. * Returns the facetLocalNormals array.
  25139. * The normals are expressed in the mesh local spac
  25140. * @returns an array of Vector3
  25141. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25142. */
  25143. getFacetLocalNormals(): Vector3[];
  25144. /**
  25145. * Returns the facetLocalPositions array.
  25146. * The facet positions are expressed in the mesh local space
  25147. * @returns an array of Vector3
  25148. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25149. */
  25150. getFacetLocalPositions(): Vector3[];
  25151. /**
  25152. * Returns the facetLocalPartioning array
  25153. * @returns an array of array of numbers
  25154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25155. */
  25156. getFacetLocalPartitioning(): number[][];
  25157. /**
  25158. * Returns the i-th facet position in the world system.
  25159. * This method allocates a new Vector3 per call
  25160. * @param i defines the facet index
  25161. * @returns a new Vector3
  25162. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25163. */
  25164. getFacetPosition(i: number): Vector3;
  25165. /**
  25166. * Sets the reference Vector3 with the i-th facet position in the world system
  25167. * @param i defines the facet index
  25168. * @param ref defines the target vector
  25169. * @returns the current mesh
  25170. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25171. */
  25172. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25173. /**
  25174. * Returns the i-th facet normal in the world system.
  25175. * This method allocates a new Vector3 per call
  25176. * @param i defines the facet index
  25177. * @returns a new Vector3
  25178. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25179. */
  25180. getFacetNormal(i: number): Vector3;
  25181. /**
  25182. * Sets the reference Vector3 with the i-th facet normal in the world system
  25183. * @param i defines the facet index
  25184. * @param ref defines the target vector
  25185. * @returns the current mesh
  25186. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25187. */
  25188. getFacetNormalToRef(i: number, ref: Vector3): this;
  25189. /**
  25190. * 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)
  25191. * @param x defines x coordinate
  25192. * @param y defines y coordinate
  25193. * @param z defines z coordinate
  25194. * @returns the array of facet indexes
  25195. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25196. */
  25197. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25198. /**
  25199. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25200. * @param projected sets as the (x,y,z) world projection on the facet
  25201. * @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
  25202. * @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
  25203. * @param x defines x coordinate
  25204. * @param y defines y coordinate
  25205. * @param z defines z coordinate
  25206. * @returns the face index if found (or null instead)
  25207. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25208. */
  25209. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25210. /**
  25211. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25212. * @param projected sets as the (x,y,z) local projection on the facet
  25213. * @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
  25214. * @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
  25215. * @param x defines x coordinate
  25216. * @param y defines y coordinate
  25217. * @param z defines z coordinate
  25218. * @returns the face index if found (or null instead)
  25219. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25220. */
  25221. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25222. /**
  25223. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25224. * @returns the parameters
  25225. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25226. */
  25227. getFacetDataParameters(): any;
  25228. /**
  25229. * Disables the feature FacetData and frees the related memory
  25230. * @returns the current mesh
  25231. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25232. */
  25233. disableFacetData(): AbstractMesh;
  25234. /**
  25235. * Updates the AbstractMesh indices array
  25236. * @param indices defines the data source
  25237. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25238. * @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)
  25239. * @returns the current mesh
  25240. */
  25241. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25242. /**
  25243. * Creates new normals data for the mesh
  25244. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25245. * @returns the current mesh
  25246. */
  25247. createNormals(updatable: boolean): AbstractMesh;
  25248. /**
  25249. * Align the mesh with a normal
  25250. * @param normal defines the normal to use
  25251. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25252. * @returns the current mesh
  25253. */
  25254. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25255. /** @hidden */
  25256. _checkOcclusionQuery(): boolean;
  25257. /**
  25258. * Disables the mesh edge rendering mode
  25259. * @returns the currentAbstractMesh
  25260. */
  25261. disableEdgesRendering(): AbstractMesh;
  25262. /**
  25263. * Enables the edge rendering mode on the mesh.
  25264. * This mode makes the mesh edges visible
  25265. * @param epsilon defines the maximal distance between two angles to detect a face
  25266. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25267. * @returns the currentAbstractMesh
  25268. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25269. */
  25270. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25271. }
  25272. }
  25273. declare module BABYLON {
  25274. /**
  25275. * Interface used to define ActionEvent
  25276. */
  25277. export interface IActionEvent {
  25278. /** The mesh or sprite that triggered the action */
  25279. source: any;
  25280. /** The X mouse cursor position at the time of the event */
  25281. pointerX: number;
  25282. /** The Y mouse cursor position at the time of the event */
  25283. pointerY: number;
  25284. /** The mesh that is currently pointed at (can be null) */
  25285. meshUnderPointer: Nullable<AbstractMesh>;
  25286. /** the original (browser) event that triggered the ActionEvent */
  25287. sourceEvent?: any;
  25288. /** additional data for the event */
  25289. additionalData?: any;
  25290. }
  25291. /**
  25292. * ActionEvent is the event being sent when an action is triggered.
  25293. */
  25294. export class ActionEvent implements IActionEvent {
  25295. /** The mesh or sprite that triggered the action */
  25296. source: any;
  25297. /** The X mouse cursor position at the time of the event */
  25298. pointerX: number;
  25299. /** The Y mouse cursor position at the time of the event */
  25300. pointerY: number;
  25301. /** The mesh that is currently pointed at (can be null) */
  25302. meshUnderPointer: Nullable<AbstractMesh>;
  25303. /** the original (browser) event that triggered the ActionEvent */
  25304. sourceEvent?: any;
  25305. /** additional data for the event */
  25306. additionalData?: any;
  25307. /**
  25308. * Creates a new ActionEvent
  25309. * @param source The mesh or sprite that triggered the action
  25310. * @param pointerX The X mouse cursor position at the time of the event
  25311. * @param pointerY The Y mouse cursor position at the time of the event
  25312. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25313. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25314. * @param additionalData additional data for the event
  25315. */
  25316. constructor(
  25317. /** The mesh or sprite that triggered the action */
  25318. source: any,
  25319. /** The X mouse cursor position at the time of the event */
  25320. pointerX: number,
  25321. /** The Y mouse cursor position at the time of the event */
  25322. pointerY: number,
  25323. /** The mesh that is currently pointed at (can be null) */
  25324. meshUnderPointer: Nullable<AbstractMesh>,
  25325. /** the original (browser) event that triggered the ActionEvent */
  25326. sourceEvent?: any,
  25327. /** additional data for the event */
  25328. additionalData?: any);
  25329. /**
  25330. * Helper function to auto-create an ActionEvent from a source mesh.
  25331. * @param source The source mesh that triggered the event
  25332. * @param evt The original (browser) event
  25333. * @param additionalData additional data for the event
  25334. * @returns the new ActionEvent
  25335. */
  25336. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25337. /**
  25338. * Helper function to auto-create an ActionEvent from a source sprite
  25339. * @param source The source sprite that triggered the event
  25340. * @param scene Scene associated with the sprite
  25341. * @param evt The original (browser) event
  25342. * @param additionalData additional data for the event
  25343. * @returns the new ActionEvent
  25344. */
  25345. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25346. /**
  25347. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25348. * @param scene the scene where the event occurred
  25349. * @param evt The original (browser) event
  25350. * @returns the new ActionEvent
  25351. */
  25352. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25353. /**
  25354. * Helper function to auto-create an ActionEvent from a primitive
  25355. * @param prim defines the target primitive
  25356. * @param pointerPos defines the pointer position
  25357. * @param evt The original (browser) event
  25358. * @param additionalData additional data for the event
  25359. * @returns the new ActionEvent
  25360. */
  25361. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25362. }
  25363. }
  25364. declare module BABYLON {
  25365. /**
  25366. * Abstract class used to decouple action Manager from scene and meshes.
  25367. * Do not instantiate.
  25368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25369. */
  25370. export abstract class AbstractActionManager implements IDisposable {
  25371. /** Gets the list of active triggers */
  25372. static Triggers: {
  25373. [key: string]: number;
  25374. };
  25375. /** Gets the cursor to use when hovering items */
  25376. hoverCursor: string;
  25377. /** Gets the list of actions */
  25378. actions: IAction[];
  25379. /**
  25380. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25381. */
  25382. isRecursive: boolean;
  25383. /**
  25384. * Releases all associated resources
  25385. */
  25386. abstract dispose(): void;
  25387. /**
  25388. * Does this action manager has pointer triggers
  25389. */
  25390. abstract readonly hasPointerTriggers: boolean;
  25391. /**
  25392. * Does this action manager has pick triggers
  25393. */
  25394. abstract readonly hasPickTriggers: boolean;
  25395. /**
  25396. * Process a specific trigger
  25397. * @param trigger defines the trigger to process
  25398. * @param evt defines the event details to be processed
  25399. */
  25400. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25401. /**
  25402. * Does this action manager handles actions of any of the given triggers
  25403. * @param triggers defines the triggers to be tested
  25404. * @return a boolean indicating whether one (or more) of the triggers is handled
  25405. */
  25406. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25407. /**
  25408. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25409. * speed.
  25410. * @param triggerA defines the trigger to be tested
  25411. * @param triggerB defines the trigger to be tested
  25412. * @return a boolean indicating whether one (or more) of the triggers is handled
  25413. */
  25414. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25415. /**
  25416. * Does this action manager handles actions of a given trigger
  25417. * @param trigger defines the trigger to be tested
  25418. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25419. * @return whether the trigger is handled
  25420. */
  25421. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25422. /**
  25423. * Serialize this manager to a JSON object
  25424. * @param name defines the property name to store this manager
  25425. * @returns a JSON representation of this manager
  25426. */
  25427. abstract serialize(name: string): any;
  25428. /**
  25429. * Registers an action to this action manager
  25430. * @param action defines the action to be registered
  25431. * @return the action amended (prepared) after registration
  25432. */
  25433. abstract registerAction(action: IAction): Nullable<IAction>;
  25434. /**
  25435. * Unregisters an action to this action manager
  25436. * @param action defines the action to be unregistered
  25437. * @return a boolean indicating whether the action has been unregistered
  25438. */
  25439. abstract unregisterAction(action: IAction): Boolean;
  25440. /**
  25441. * Does exist one action manager with at least one trigger
  25442. **/
  25443. static readonly HasTriggers: boolean;
  25444. /**
  25445. * Does exist one action manager with at least one pick trigger
  25446. **/
  25447. static readonly HasPickTriggers: boolean;
  25448. /**
  25449. * Does exist one action manager that handles actions of a given trigger
  25450. * @param trigger defines the trigger to be tested
  25451. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25452. **/
  25453. static HasSpecificTrigger(trigger: number): boolean;
  25454. }
  25455. }
  25456. declare module BABYLON {
  25457. /**
  25458. * Defines how a node can be built from a string name.
  25459. */
  25460. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25461. /**
  25462. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25463. */
  25464. export class Node implements IBehaviorAware<Node> {
  25465. /** @hidden */
  25466. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25467. private static _NodeConstructors;
  25468. /**
  25469. * Add a new node constructor
  25470. * @param type defines the type name of the node to construct
  25471. * @param constructorFunc defines the constructor function
  25472. */
  25473. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25474. /**
  25475. * Returns a node constructor based on type name
  25476. * @param type defines the type name
  25477. * @param name defines the new node name
  25478. * @param scene defines the hosting scene
  25479. * @param options defines optional options to transmit to constructors
  25480. * @returns the new constructor or null
  25481. */
  25482. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25483. /**
  25484. * Gets or sets the name of the node
  25485. */
  25486. name: string;
  25487. /**
  25488. * Gets or sets the id of the node
  25489. */
  25490. id: string;
  25491. /**
  25492. * Gets or sets the unique id of the node
  25493. */
  25494. uniqueId: number;
  25495. /**
  25496. * Gets or sets a string used to store user defined state for the node
  25497. */
  25498. state: string;
  25499. /**
  25500. * Gets or sets an object used to store user defined information for the node
  25501. */
  25502. metadata: any;
  25503. /**
  25504. * For internal use only. Please do not use.
  25505. */
  25506. reservedDataStore: any;
  25507. /**
  25508. * List of inspectable custom properties (used by the Inspector)
  25509. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25510. */
  25511. inspectableCustomProperties: IInspectable[];
  25512. /**
  25513. * Gets or sets a boolean used to define if the node must be serialized
  25514. */
  25515. doNotSerialize: boolean;
  25516. /** @hidden */
  25517. _isDisposed: boolean;
  25518. /**
  25519. * Gets a list of Animations associated with the node
  25520. */
  25521. animations: Animation[];
  25522. protected _ranges: {
  25523. [name: string]: Nullable<AnimationRange>;
  25524. };
  25525. /**
  25526. * Callback raised when the node is ready to be used
  25527. */
  25528. onReady: Nullable<(node: Node) => void>;
  25529. private _isEnabled;
  25530. private _isParentEnabled;
  25531. private _isReady;
  25532. /** @hidden */
  25533. _currentRenderId: number;
  25534. private _parentUpdateId;
  25535. /** @hidden */
  25536. _childUpdateId: number;
  25537. /** @hidden */
  25538. _waitingParentId: Nullable<string>;
  25539. /** @hidden */
  25540. _scene: Scene;
  25541. /** @hidden */
  25542. _cache: any;
  25543. private _parentNode;
  25544. private _children;
  25545. /** @hidden */
  25546. _worldMatrix: Matrix;
  25547. /** @hidden */
  25548. _worldMatrixDeterminant: number;
  25549. /** @hidden */
  25550. _worldMatrixDeterminantIsDirty: boolean;
  25551. /** @hidden */
  25552. private _sceneRootNodesIndex;
  25553. /**
  25554. * Gets a boolean indicating if the node has been disposed
  25555. * @returns true if the node was disposed
  25556. */
  25557. isDisposed(): boolean;
  25558. /**
  25559. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25560. * @see https://doc.babylonjs.com/how_to/parenting
  25561. */
  25562. parent: Nullable<Node>;
  25563. private addToSceneRootNodes;
  25564. private removeFromSceneRootNodes;
  25565. private _animationPropertiesOverride;
  25566. /**
  25567. * Gets or sets the animation properties override
  25568. */
  25569. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25570. /**
  25571. * Gets a string idenfifying the name of the class
  25572. * @returns "Node" string
  25573. */
  25574. getClassName(): string;
  25575. /** @hidden */
  25576. readonly _isNode: boolean;
  25577. /**
  25578. * An event triggered when the mesh is disposed
  25579. */
  25580. onDisposeObservable: Observable<Node>;
  25581. private _onDisposeObserver;
  25582. /**
  25583. * Sets a callback that will be raised when the node will be disposed
  25584. */
  25585. onDispose: () => void;
  25586. /**
  25587. * Creates a new Node
  25588. * @param name the name and id to be given to this node
  25589. * @param scene the scene this node will be added to
  25590. * @param addToRootNodes the node will be added to scene.rootNodes
  25591. */
  25592. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25593. /**
  25594. * Gets the scene of the node
  25595. * @returns a scene
  25596. */
  25597. getScene(): Scene;
  25598. /**
  25599. * Gets the engine of the node
  25600. * @returns a Engine
  25601. */
  25602. getEngine(): Engine;
  25603. private _behaviors;
  25604. /**
  25605. * Attach a behavior to the node
  25606. * @see http://doc.babylonjs.com/features/behaviour
  25607. * @param behavior defines the behavior to attach
  25608. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25609. * @returns the current Node
  25610. */
  25611. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25612. /**
  25613. * Remove an attached behavior
  25614. * @see http://doc.babylonjs.com/features/behaviour
  25615. * @param behavior defines the behavior to attach
  25616. * @returns the current Node
  25617. */
  25618. removeBehavior(behavior: Behavior<Node>): Node;
  25619. /**
  25620. * Gets the list of attached behaviors
  25621. * @see http://doc.babylonjs.com/features/behaviour
  25622. */
  25623. readonly behaviors: Behavior<Node>[];
  25624. /**
  25625. * Gets an attached behavior by name
  25626. * @param name defines the name of the behavior to look for
  25627. * @see http://doc.babylonjs.com/features/behaviour
  25628. * @returns null if behavior was not found else the requested behavior
  25629. */
  25630. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25631. /**
  25632. * Returns the latest update of the World matrix
  25633. * @returns a Matrix
  25634. */
  25635. getWorldMatrix(): Matrix;
  25636. /** @hidden */
  25637. _getWorldMatrixDeterminant(): number;
  25638. /**
  25639. * Returns directly the latest state of the mesh World matrix.
  25640. * A Matrix is returned.
  25641. */
  25642. readonly worldMatrixFromCache: Matrix;
  25643. /** @hidden */
  25644. _initCache(): void;
  25645. /** @hidden */
  25646. updateCache(force?: boolean): void;
  25647. /** @hidden */
  25648. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25649. /** @hidden */
  25650. _updateCache(ignoreParentClass?: boolean): void;
  25651. /** @hidden */
  25652. _isSynchronized(): boolean;
  25653. /** @hidden */
  25654. _markSyncedWithParent(): void;
  25655. /** @hidden */
  25656. isSynchronizedWithParent(): boolean;
  25657. /** @hidden */
  25658. isSynchronized(): boolean;
  25659. /**
  25660. * Is this node ready to be used/rendered
  25661. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25662. * @return true if the node is ready
  25663. */
  25664. isReady(completeCheck?: boolean): boolean;
  25665. /**
  25666. * Is this node enabled?
  25667. * 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
  25668. * @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
  25669. * @return whether this node (and its parent) is enabled
  25670. */
  25671. isEnabled(checkAncestors?: boolean): boolean;
  25672. /** @hidden */
  25673. protected _syncParentEnabledState(): void;
  25674. /**
  25675. * Set the enabled state of this node
  25676. * @param value defines the new enabled state
  25677. */
  25678. setEnabled(value: boolean): void;
  25679. /**
  25680. * Is this node a descendant of the given node?
  25681. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25682. * @param ancestor defines the parent node to inspect
  25683. * @returns a boolean indicating if this node is a descendant of the given node
  25684. */
  25685. isDescendantOf(ancestor: Node): boolean;
  25686. /** @hidden */
  25687. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25688. /**
  25689. * Will return all nodes that have this node as ascendant
  25690. * @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
  25691. * @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
  25692. * @return all children nodes of all types
  25693. */
  25694. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25695. /**
  25696. * Get all child-meshes of this node
  25697. * @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)
  25698. * @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
  25699. * @returns an array of AbstractMesh
  25700. */
  25701. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25702. /**
  25703. * Get all direct children of this node
  25704. * @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
  25705. * @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)
  25706. * @returns an array of Node
  25707. */
  25708. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25709. /** @hidden */
  25710. _setReady(state: boolean): void;
  25711. /**
  25712. * Get an animation by name
  25713. * @param name defines the name of the animation to look for
  25714. * @returns null if not found else the requested animation
  25715. */
  25716. getAnimationByName(name: string): Nullable<Animation>;
  25717. /**
  25718. * Creates an animation range for this node
  25719. * @param name defines the name of the range
  25720. * @param from defines the starting key
  25721. * @param to defines the end key
  25722. */
  25723. createAnimationRange(name: string, from: number, to: number): void;
  25724. /**
  25725. * Delete a specific animation range
  25726. * @param name defines the name of the range to delete
  25727. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25728. */
  25729. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25730. /**
  25731. * Get an animation range by name
  25732. * @param name defines the name of the animation range to look for
  25733. * @returns null if not found else the requested animation range
  25734. */
  25735. getAnimationRange(name: string): Nullable<AnimationRange>;
  25736. /**
  25737. * Gets the list of all animation ranges defined on this node
  25738. * @returns an array
  25739. */
  25740. getAnimationRanges(): Nullable<AnimationRange>[];
  25741. /**
  25742. * Will start the animation sequence
  25743. * @param name defines the range frames for animation sequence
  25744. * @param loop defines if the animation should loop (false by default)
  25745. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25746. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25747. * @returns the object created for this animation. If range does not exist, it will return null
  25748. */
  25749. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25750. /**
  25751. * Serialize animation ranges into a JSON compatible object
  25752. * @returns serialization object
  25753. */
  25754. serializeAnimationRanges(): any;
  25755. /**
  25756. * Computes the world matrix of the node
  25757. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25758. * @returns the world matrix
  25759. */
  25760. computeWorldMatrix(force?: boolean): Matrix;
  25761. /**
  25762. * Releases resources associated with this node.
  25763. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25764. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25765. */
  25766. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25767. /**
  25768. * Parse animation range data from a serialization object and store them into a given node
  25769. * @param node defines where to store the animation ranges
  25770. * @param parsedNode defines the serialization object to read data from
  25771. * @param scene defines the hosting scene
  25772. */
  25773. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25774. /**
  25775. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25776. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25777. * @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
  25778. * @returns the new bounding vectors
  25779. */
  25780. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25781. min: Vector3;
  25782. max: Vector3;
  25783. };
  25784. }
  25785. }
  25786. declare module BABYLON {
  25787. /**
  25788. * @hidden
  25789. */
  25790. export class _IAnimationState {
  25791. key: number;
  25792. repeatCount: number;
  25793. workValue?: any;
  25794. loopMode?: number;
  25795. offsetValue?: any;
  25796. highLimitValue?: any;
  25797. }
  25798. /**
  25799. * Class used to store any kind of animation
  25800. */
  25801. export class Animation {
  25802. /**Name of the animation */
  25803. name: string;
  25804. /**Property to animate */
  25805. targetProperty: string;
  25806. /**The frames per second of the animation */
  25807. framePerSecond: number;
  25808. /**The data type of the animation */
  25809. dataType: number;
  25810. /**The loop mode of the animation */
  25811. loopMode?: number | undefined;
  25812. /**Specifies if blending should be enabled */
  25813. enableBlending?: boolean | undefined;
  25814. /**
  25815. * Use matrix interpolation instead of using direct key value when animating matrices
  25816. */
  25817. static AllowMatricesInterpolation: boolean;
  25818. /**
  25819. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25820. */
  25821. static AllowMatrixDecomposeForInterpolation: boolean;
  25822. /**
  25823. * Stores the key frames of the animation
  25824. */
  25825. private _keys;
  25826. /**
  25827. * Stores the easing function of the animation
  25828. */
  25829. private _easingFunction;
  25830. /**
  25831. * @hidden Internal use only
  25832. */
  25833. _runtimeAnimations: RuntimeAnimation[];
  25834. /**
  25835. * The set of event that will be linked to this animation
  25836. */
  25837. private _events;
  25838. /**
  25839. * Stores an array of target property paths
  25840. */
  25841. targetPropertyPath: string[];
  25842. /**
  25843. * Stores the blending speed of the animation
  25844. */
  25845. blendingSpeed: number;
  25846. /**
  25847. * Stores the animation ranges for the animation
  25848. */
  25849. private _ranges;
  25850. /**
  25851. * @hidden Internal use
  25852. */
  25853. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25854. /**
  25855. * Sets up an animation
  25856. * @param property The property to animate
  25857. * @param animationType The animation type to apply
  25858. * @param framePerSecond The frames per second of the animation
  25859. * @param easingFunction The easing function used in the animation
  25860. * @returns The created animation
  25861. */
  25862. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25863. /**
  25864. * Create and start an animation on a node
  25865. * @param name defines the name of the global animation that will be run on all nodes
  25866. * @param node defines the root node where the animation will take place
  25867. * @param targetProperty defines property to animate
  25868. * @param framePerSecond defines the number of frame per second yo use
  25869. * @param totalFrame defines the number of frames in total
  25870. * @param from defines the initial value
  25871. * @param to defines the final value
  25872. * @param loopMode defines which loop mode you want to use (off by default)
  25873. * @param easingFunction defines the easing function to use (linear by default)
  25874. * @param onAnimationEnd defines the callback to call when animation end
  25875. * @returns the animatable created for this animation
  25876. */
  25877. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25878. /**
  25879. * Create and start an animation on a node and its descendants
  25880. * @param name defines the name of the global animation that will be run on all nodes
  25881. * @param node defines the root node where the animation will take place
  25882. * @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
  25883. * @param targetProperty defines property to animate
  25884. * @param framePerSecond defines the number of frame per second to use
  25885. * @param totalFrame defines the number of frames in total
  25886. * @param from defines the initial value
  25887. * @param to defines the final value
  25888. * @param loopMode defines which loop mode you want to use (off by default)
  25889. * @param easingFunction defines the easing function to use (linear by default)
  25890. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25891. * @returns the list of animatables created for all nodes
  25892. * @example https://www.babylonjs-playground.com/#MH0VLI
  25893. */
  25894. 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[]>;
  25895. /**
  25896. * Creates a new animation, merges it with the existing animations and starts it
  25897. * @param name Name of the animation
  25898. * @param node Node which contains the scene that begins the animations
  25899. * @param targetProperty Specifies which property to animate
  25900. * @param framePerSecond The frames per second of the animation
  25901. * @param totalFrame The total number of frames
  25902. * @param from The frame at the beginning of the animation
  25903. * @param to The frame at the end of the animation
  25904. * @param loopMode Specifies the loop mode of the animation
  25905. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25906. * @param onAnimationEnd Callback to run once the animation is complete
  25907. * @returns Nullable animation
  25908. */
  25909. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25910. /**
  25911. * Transition property of an host to the target Value
  25912. * @param property The property to transition
  25913. * @param targetValue The target Value of the property
  25914. * @param host The object where the property to animate belongs
  25915. * @param scene Scene used to run the animation
  25916. * @param frameRate Framerate (in frame/s) to use
  25917. * @param transition The transition type we want to use
  25918. * @param duration The duration of the animation, in milliseconds
  25919. * @param onAnimationEnd Callback trigger at the end of the animation
  25920. * @returns Nullable animation
  25921. */
  25922. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25923. /**
  25924. * Return the array of runtime animations currently using this animation
  25925. */
  25926. readonly runtimeAnimations: RuntimeAnimation[];
  25927. /**
  25928. * Specifies if any of the runtime animations are currently running
  25929. */
  25930. readonly hasRunningRuntimeAnimations: boolean;
  25931. /**
  25932. * Initializes the animation
  25933. * @param name Name of the animation
  25934. * @param targetProperty Property to animate
  25935. * @param framePerSecond The frames per second of the animation
  25936. * @param dataType The data type of the animation
  25937. * @param loopMode The loop mode of the animation
  25938. * @param enableBlending Specifies if blending should be enabled
  25939. */
  25940. constructor(
  25941. /**Name of the animation */
  25942. name: string,
  25943. /**Property to animate */
  25944. targetProperty: string,
  25945. /**The frames per second of the animation */
  25946. framePerSecond: number,
  25947. /**The data type of the animation */
  25948. dataType: number,
  25949. /**The loop mode of the animation */
  25950. loopMode?: number | undefined,
  25951. /**Specifies if blending should be enabled */
  25952. enableBlending?: boolean | undefined);
  25953. /**
  25954. * Converts the animation to a string
  25955. * @param fullDetails support for multiple levels of logging within scene loading
  25956. * @returns String form of the animation
  25957. */
  25958. toString(fullDetails?: boolean): string;
  25959. /**
  25960. * Add an event to this animation
  25961. * @param event Event to add
  25962. */
  25963. addEvent(event: AnimationEvent): void;
  25964. /**
  25965. * Remove all events found at the given frame
  25966. * @param frame The frame to remove events from
  25967. */
  25968. removeEvents(frame: number): void;
  25969. /**
  25970. * Retrieves all the events from the animation
  25971. * @returns Events from the animation
  25972. */
  25973. getEvents(): AnimationEvent[];
  25974. /**
  25975. * Creates an animation range
  25976. * @param name Name of the animation range
  25977. * @param from Starting frame of the animation range
  25978. * @param to Ending frame of the animation
  25979. */
  25980. createRange(name: string, from: number, to: number): void;
  25981. /**
  25982. * Deletes an animation range by name
  25983. * @param name Name of the animation range to delete
  25984. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25985. */
  25986. deleteRange(name: string, deleteFrames?: boolean): void;
  25987. /**
  25988. * Gets the animation range by name, or null if not defined
  25989. * @param name Name of the animation range
  25990. * @returns Nullable animation range
  25991. */
  25992. getRange(name: string): Nullable<AnimationRange>;
  25993. /**
  25994. * Gets the key frames from the animation
  25995. * @returns The key frames of the animation
  25996. */
  25997. getKeys(): Array<IAnimationKey>;
  25998. /**
  25999. * Gets the highest frame rate of the animation
  26000. * @returns Highest frame rate of the animation
  26001. */
  26002. getHighestFrame(): number;
  26003. /**
  26004. * Gets the easing function of the animation
  26005. * @returns Easing function of the animation
  26006. */
  26007. getEasingFunction(): IEasingFunction;
  26008. /**
  26009. * Sets the easing function of the animation
  26010. * @param easingFunction A custom mathematical formula for animation
  26011. */
  26012. setEasingFunction(easingFunction: EasingFunction): void;
  26013. /**
  26014. * Interpolates a scalar linearly
  26015. * @param startValue Start value of the animation curve
  26016. * @param endValue End value of the animation curve
  26017. * @param gradient Scalar amount to interpolate
  26018. * @returns Interpolated scalar value
  26019. */
  26020. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26021. /**
  26022. * Interpolates a scalar cubically
  26023. * @param startValue Start value of the animation curve
  26024. * @param outTangent End tangent of the animation
  26025. * @param endValue End value of the animation curve
  26026. * @param inTangent Start tangent of the animation curve
  26027. * @param gradient Scalar amount to interpolate
  26028. * @returns Interpolated scalar value
  26029. */
  26030. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26031. /**
  26032. * Interpolates a quaternion using a spherical linear interpolation
  26033. * @param startValue Start value of the animation curve
  26034. * @param endValue End value of the animation curve
  26035. * @param gradient Scalar amount to interpolate
  26036. * @returns Interpolated quaternion value
  26037. */
  26038. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26039. /**
  26040. * Interpolates a quaternion cubically
  26041. * @param startValue Start value of the animation curve
  26042. * @param outTangent End tangent of the animation curve
  26043. * @param endValue End value of the animation curve
  26044. * @param inTangent Start tangent of the animation curve
  26045. * @param gradient Scalar amount to interpolate
  26046. * @returns Interpolated quaternion value
  26047. */
  26048. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26049. /**
  26050. * Interpolates a Vector3 linearl
  26051. * @param startValue Start value of the animation curve
  26052. * @param endValue End value of the animation curve
  26053. * @param gradient Scalar amount to interpolate
  26054. * @returns Interpolated scalar value
  26055. */
  26056. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26057. /**
  26058. * Interpolates a Vector3 cubically
  26059. * @param startValue Start value of the animation curve
  26060. * @param outTangent End tangent of the animation
  26061. * @param endValue End value of the animation curve
  26062. * @param inTangent Start tangent of the animation curve
  26063. * @param gradient Scalar amount to interpolate
  26064. * @returns InterpolatedVector3 value
  26065. */
  26066. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26067. /**
  26068. * Interpolates a Vector2 linearly
  26069. * @param startValue Start value of the animation curve
  26070. * @param endValue End value of the animation curve
  26071. * @param gradient Scalar amount to interpolate
  26072. * @returns Interpolated Vector2 value
  26073. */
  26074. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26075. /**
  26076. * Interpolates a Vector2 cubically
  26077. * @param startValue Start value of the animation curve
  26078. * @param outTangent End tangent of the animation
  26079. * @param endValue End value of the animation curve
  26080. * @param inTangent Start tangent of the animation curve
  26081. * @param gradient Scalar amount to interpolate
  26082. * @returns Interpolated Vector2 value
  26083. */
  26084. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26085. /**
  26086. * Interpolates a size linearly
  26087. * @param startValue Start value of the animation curve
  26088. * @param endValue End value of the animation curve
  26089. * @param gradient Scalar amount to interpolate
  26090. * @returns Interpolated Size value
  26091. */
  26092. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26093. /**
  26094. * Interpolates a Color3 linearly
  26095. * @param startValue Start value of the animation curve
  26096. * @param endValue End value of the animation curve
  26097. * @param gradient Scalar amount to interpolate
  26098. * @returns Interpolated Color3 value
  26099. */
  26100. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26101. /**
  26102. * @hidden Internal use only
  26103. */
  26104. _getKeyValue(value: any): any;
  26105. /**
  26106. * @hidden Internal use only
  26107. */
  26108. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26109. /**
  26110. * Defines the function to use to interpolate matrices
  26111. * @param startValue defines the start matrix
  26112. * @param endValue defines the end matrix
  26113. * @param gradient defines the gradient between both matrices
  26114. * @param result defines an optional target matrix where to store the interpolation
  26115. * @returns the interpolated matrix
  26116. */
  26117. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26118. /**
  26119. * Makes a copy of the animation
  26120. * @returns Cloned animation
  26121. */
  26122. clone(): Animation;
  26123. /**
  26124. * Sets the key frames of the animation
  26125. * @param values The animation key frames to set
  26126. */
  26127. setKeys(values: Array<IAnimationKey>): void;
  26128. /**
  26129. * Serializes the animation to an object
  26130. * @returns Serialized object
  26131. */
  26132. serialize(): any;
  26133. /**
  26134. * Float animation type
  26135. */
  26136. private static _ANIMATIONTYPE_FLOAT;
  26137. /**
  26138. * Vector3 animation type
  26139. */
  26140. private static _ANIMATIONTYPE_VECTOR3;
  26141. /**
  26142. * Quaternion animation type
  26143. */
  26144. private static _ANIMATIONTYPE_QUATERNION;
  26145. /**
  26146. * Matrix animation type
  26147. */
  26148. private static _ANIMATIONTYPE_MATRIX;
  26149. /**
  26150. * Color3 animation type
  26151. */
  26152. private static _ANIMATIONTYPE_COLOR3;
  26153. /**
  26154. * Vector2 animation type
  26155. */
  26156. private static _ANIMATIONTYPE_VECTOR2;
  26157. /**
  26158. * Size animation type
  26159. */
  26160. private static _ANIMATIONTYPE_SIZE;
  26161. /**
  26162. * Relative Loop Mode
  26163. */
  26164. private static _ANIMATIONLOOPMODE_RELATIVE;
  26165. /**
  26166. * Cycle Loop Mode
  26167. */
  26168. private static _ANIMATIONLOOPMODE_CYCLE;
  26169. /**
  26170. * Constant Loop Mode
  26171. */
  26172. private static _ANIMATIONLOOPMODE_CONSTANT;
  26173. /**
  26174. * Get the float animation type
  26175. */
  26176. static readonly ANIMATIONTYPE_FLOAT: number;
  26177. /**
  26178. * Get the Vector3 animation type
  26179. */
  26180. static readonly ANIMATIONTYPE_VECTOR3: number;
  26181. /**
  26182. * Get the Vector2 animation type
  26183. */
  26184. static readonly ANIMATIONTYPE_VECTOR2: number;
  26185. /**
  26186. * Get the Size animation type
  26187. */
  26188. static readonly ANIMATIONTYPE_SIZE: number;
  26189. /**
  26190. * Get the Quaternion animation type
  26191. */
  26192. static readonly ANIMATIONTYPE_QUATERNION: number;
  26193. /**
  26194. * Get the Matrix animation type
  26195. */
  26196. static readonly ANIMATIONTYPE_MATRIX: number;
  26197. /**
  26198. * Get the Color3 animation type
  26199. */
  26200. static readonly ANIMATIONTYPE_COLOR3: number;
  26201. /**
  26202. * Get the Relative Loop Mode
  26203. */
  26204. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26205. /**
  26206. * Get the Cycle Loop Mode
  26207. */
  26208. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26209. /**
  26210. * Get the Constant Loop Mode
  26211. */
  26212. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26213. /** @hidden */
  26214. static _UniversalLerp(left: any, right: any, amount: number): any;
  26215. /**
  26216. * Parses an animation object and creates an animation
  26217. * @param parsedAnimation Parsed animation object
  26218. * @returns Animation object
  26219. */
  26220. static Parse(parsedAnimation: any): Animation;
  26221. /**
  26222. * Appends the serialized animations from the source animations
  26223. * @param source Source containing the animations
  26224. * @param destination Target to store the animations
  26225. */
  26226. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26227. }
  26228. }
  26229. declare module BABYLON {
  26230. /**
  26231. * Base class of all the textures in babylon.
  26232. * It groups all the common properties the materials, post process, lights... might need
  26233. * in order to make a correct use of the texture.
  26234. */
  26235. export class BaseTexture implements IAnimatable {
  26236. /**
  26237. * Default anisotropic filtering level for the application.
  26238. * It is set to 4 as a good tradeoff between perf and quality.
  26239. */
  26240. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26241. /**
  26242. * Gets or sets the unique id of the texture
  26243. */
  26244. uniqueId: number;
  26245. /**
  26246. * Define the name of the texture.
  26247. */
  26248. name: string;
  26249. /**
  26250. * Gets or sets an object used to store user defined information.
  26251. */
  26252. metadata: any;
  26253. /**
  26254. * For internal use only. Please do not use.
  26255. */
  26256. reservedDataStore: any;
  26257. private _hasAlpha;
  26258. /**
  26259. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26260. */
  26261. hasAlpha: boolean;
  26262. /**
  26263. * Defines if the alpha value should be determined via the rgb values.
  26264. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26265. */
  26266. getAlphaFromRGB: boolean;
  26267. /**
  26268. * Intensity or strength of the texture.
  26269. * It is commonly used by materials to fine tune the intensity of the texture
  26270. */
  26271. level: number;
  26272. /**
  26273. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26274. * This is part of the texture as textures usually maps to one uv set.
  26275. */
  26276. coordinatesIndex: number;
  26277. private _coordinatesMode;
  26278. /**
  26279. * How a texture is mapped.
  26280. *
  26281. * | Value | Type | Description |
  26282. * | ----- | ----------------------------------- | ----------- |
  26283. * | 0 | EXPLICIT_MODE | |
  26284. * | 1 | SPHERICAL_MODE | |
  26285. * | 2 | PLANAR_MODE | |
  26286. * | 3 | CUBIC_MODE | |
  26287. * | 4 | PROJECTION_MODE | |
  26288. * | 5 | SKYBOX_MODE | |
  26289. * | 6 | INVCUBIC_MODE | |
  26290. * | 7 | EQUIRECTANGULAR_MODE | |
  26291. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26292. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26293. */
  26294. coordinatesMode: number;
  26295. /**
  26296. * | Value | Type | Description |
  26297. * | ----- | ------------------ | ----------- |
  26298. * | 0 | CLAMP_ADDRESSMODE | |
  26299. * | 1 | WRAP_ADDRESSMODE | |
  26300. * | 2 | MIRROR_ADDRESSMODE | |
  26301. */
  26302. wrapU: number;
  26303. /**
  26304. * | Value | Type | Description |
  26305. * | ----- | ------------------ | ----------- |
  26306. * | 0 | CLAMP_ADDRESSMODE | |
  26307. * | 1 | WRAP_ADDRESSMODE | |
  26308. * | 2 | MIRROR_ADDRESSMODE | |
  26309. */
  26310. wrapV: number;
  26311. /**
  26312. * | Value | Type | Description |
  26313. * | ----- | ------------------ | ----------- |
  26314. * | 0 | CLAMP_ADDRESSMODE | |
  26315. * | 1 | WRAP_ADDRESSMODE | |
  26316. * | 2 | MIRROR_ADDRESSMODE | |
  26317. */
  26318. wrapR: number;
  26319. /**
  26320. * With compliant hardware and browser (supporting anisotropic filtering)
  26321. * this defines the level of anisotropic filtering in the texture.
  26322. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26323. */
  26324. anisotropicFilteringLevel: number;
  26325. /**
  26326. * Define if the texture is a cube texture or if false a 2d texture.
  26327. */
  26328. isCube: boolean;
  26329. /**
  26330. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26331. */
  26332. is3D: boolean;
  26333. /**
  26334. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26335. * HDR texture are usually stored in linear space.
  26336. * This only impacts the PBR and Background materials
  26337. */
  26338. gammaSpace: boolean;
  26339. /**
  26340. * Gets whether or not the texture contains RGBD data.
  26341. */
  26342. readonly isRGBD: boolean;
  26343. /**
  26344. * Is Z inverted in the texture (useful in a cube texture).
  26345. */
  26346. invertZ: boolean;
  26347. /**
  26348. * Are mip maps generated for this texture or not.
  26349. */
  26350. readonly noMipmap: boolean;
  26351. /**
  26352. * @hidden
  26353. */
  26354. lodLevelInAlpha: boolean;
  26355. /**
  26356. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26357. */
  26358. lodGenerationOffset: number;
  26359. /**
  26360. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26361. */
  26362. lodGenerationScale: number;
  26363. /**
  26364. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  26365. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  26366. * average roughness values.
  26367. */
  26368. linearSpecularLOD: boolean;
  26369. /**
  26370. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  26371. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  26372. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  26373. */
  26374. irradianceTexture: Nullable<BaseTexture>;
  26375. /**
  26376. * Define if the texture is a render target.
  26377. */
  26378. isRenderTarget: boolean;
  26379. /**
  26380. * Define the unique id of the texture in the scene.
  26381. */
  26382. readonly uid: string;
  26383. /**
  26384. * Return a string representation of the texture.
  26385. * @returns the texture as a string
  26386. */
  26387. toString(): string;
  26388. /**
  26389. * Get the class name of the texture.
  26390. * @returns "BaseTexture"
  26391. */
  26392. getClassName(): string;
  26393. /**
  26394. * Define the list of animation attached to the texture.
  26395. */
  26396. animations: Animation[];
  26397. /**
  26398. * An event triggered when the texture is disposed.
  26399. */
  26400. onDisposeObservable: Observable<BaseTexture>;
  26401. private _onDisposeObserver;
  26402. /**
  26403. * Callback triggered when the texture has been disposed.
  26404. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26405. */
  26406. onDispose: () => void;
  26407. /**
  26408. * Define the current state of the loading sequence when in delayed load mode.
  26409. */
  26410. delayLoadState: number;
  26411. private _scene;
  26412. /** @hidden */
  26413. _texture: Nullable<InternalTexture>;
  26414. private _uid;
  26415. /**
  26416. * Define if the texture is preventinga material to render or not.
  26417. * If not and the texture is not ready, the engine will use a default black texture instead.
  26418. */
  26419. readonly isBlocking: boolean;
  26420. /**
  26421. * Instantiates a new BaseTexture.
  26422. * Base class of all the textures in babylon.
  26423. * It groups all the common properties the materials, post process, lights... might need
  26424. * in order to make a correct use of the texture.
  26425. * @param scene Define the scene the texture blongs to
  26426. */
  26427. constructor(scene: Nullable<Scene>);
  26428. /**
  26429. * Get the scene the texture belongs to.
  26430. * @returns the scene or null if undefined
  26431. */
  26432. getScene(): Nullable<Scene>;
  26433. /**
  26434. * Get the texture transform matrix used to offset tile the texture for istance.
  26435. * @returns the transformation matrix
  26436. */
  26437. getTextureMatrix(): Matrix;
  26438. /**
  26439. * Get the texture reflection matrix used to rotate/transform the reflection.
  26440. * @returns the reflection matrix
  26441. */
  26442. getReflectionTextureMatrix(): Matrix;
  26443. /**
  26444. * Get the underlying lower level texture from Babylon.
  26445. * @returns the insternal texture
  26446. */
  26447. getInternalTexture(): Nullable<InternalTexture>;
  26448. /**
  26449. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26450. * @returns true if ready or not blocking
  26451. */
  26452. isReadyOrNotBlocking(): boolean;
  26453. /**
  26454. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26455. * @returns true if fully ready
  26456. */
  26457. isReady(): boolean;
  26458. private _cachedSize;
  26459. /**
  26460. * Get the size of the texture.
  26461. * @returns the texture size.
  26462. */
  26463. getSize(): ISize;
  26464. /**
  26465. * Get the base size of the texture.
  26466. * It can be different from the size if the texture has been resized for POT for instance
  26467. * @returns the base size
  26468. */
  26469. getBaseSize(): ISize;
  26470. /**
  26471. * Update the sampling mode of the texture.
  26472. * Default is Trilinear mode.
  26473. *
  26474. * | Value | Type | Description |
  26475. * | ----- | ------------------ | ----------- |
  26476. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26477. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26478. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26479. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26480. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26481. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26482. * | 7 | NEAREST_LINEAR | |
  26483. * | 8 | NEAREST_NEAREST | |
  26484. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26485. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26486. * | 11 | LINEAR_LINEAR | |
  26487. * | 12 | LINEAR_NEAREST | |
  26488. *
  26489. * > _mag_: magnification filter (close to the viewer)
  26490. * > _min_: minification filter (far from the viewer)
  26491. * > _mip_: filter used between mip map levels
  26492. *@param samplingMode Define the new sampling mode of the texture
  26493. */
  26494. updateSamplingMode(samplingMode: number): void;
  26495. /**
  26496. * Scales the texture if is `canRescale()`
  26497. * @param ratio the resize factor we want to use to rescale
  26498. */
  26499. scale(ratio: number): void;
  26500. /**
  26501. * Get if the texture can rescale.
  26502. */
  26503. readonly canRescale: boolean;
  26504. /** @hidden */
  26505. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26506. /** @hidden */
  26507. _rebuild(): void;
  26508. /**
  26509. * Triggers the load sequence in delayed load mode.
  26510. */
  26511. delayLoad(): void;
  26512. /**
  26513. * Clones the texture.
  26514. * @returns the cloned texture
  26515. */
  26516. clone(): Nullable<BaseTexture>;
  26517. /**
  26518. * Get the texture underlying type (INT, FLOAT...)
  26519. */
  26520. readonly textureType: number;
  26521. /**
  26522. * Get the texture underlying format (RGB, RGBA...)
  26523. */
  26524. readonly textureFormat: number;
  26525. /**
  26526. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26527. * This will returns an RGBA array buffer containing either in values (0-255) or
  26528. * float values (0-1) depending of the underlying buffer type.
  26529. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26530. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26531. * @param buffer defines a user defined buffer to fill with data (can be null)
  26532. * @returns The Array buffer containing the pixels data.
  26533. */
  26534. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26535. /**
  26536. * Release and destroy the underlying lower level texture aka internalTexture.
  26537. */
  26538. releaseInternalTexture(): void;
  26539. /**
  26540. * Get the polynomial representation of the texture data.
  26541. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26542. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26543. */
  26544. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26545. /** @hidden */
  26546. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26547. /** @hidden */
  26548. readonly _lodTextureMid: Nullable<BaseTexture>;
  26549. /** @hidden */
  26550. readonly _lodTextureLow: Nullable<BaseTexture>;
  26551. /**
  26552. * Dispose the texture and release its associated resources.
  26553. */
  26554. dispose(): void;
  26555. /**
  26556. * Serialize the texture into a JSON representation that can be parsed later on.
  26557. * @returns the JSON representation of the texture
  26558. */
  26559. serialize(): any;
  26560. /**
  26561. * Helper function to be called back once a list of texture contains only ready textures.
  26562. * @param textures Define the list of textures to wait for
  26563. * @param callback Define the callback triggered once the entire list will be ready
  26564. */
  26565. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26566. }
  26567. }
  26568. declare module BABYLON {
  26569. /**
  26570. * Uniform buffer objects.
  26571. *
  26572. * Handles blocks of uniform on the GPU.
  26573. *
  26574. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26575. *
  26576. * For more information, please refer to :
  26577. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26578. */
  26579. export class UniformBuffer {
  26580. private _engine;
  26581. private _buffer;
  26582. private _data;
  26583. private _bufferData;
  26584. private _dynamic?;
  26585. private _uniformLocations;
  26586. private _uniformSizes;
  26587. private _uniformLocationPointer;
  26588. private _needSync;
  26589. private _noUBO;
  26590. private _currentEffect;
  26591. private static _MAX_UNIFORM_SIZE;
  26592. private static _tempBuffer;
  26593. /**
  26594. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26595. * This is dynamic to allow compat with webgl 1 and 2.
  26596. * You will need to pass the name of the uniform as well as the value.
  26597. */
  26598. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26599. /**
  26600. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26601. * This is dynamic to allow compat with webgl 1 and 2.
  26602. * You will need to pass the name of the uniform as well as the value.
  26603. */
  26604. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26605. /**
  26606. * Lambda to Update a single float in a uniform buffer.
  26607. * This is dynamic to allow compat with webgl 1 and 2.
  26608. * You will need to pass the name of the uniform as well as the value.
  26609. */
  26610. updateFloat: (name: string, x: number) => void;
  26611. /**
  26612. * Lambda to Update a vec2 of float in a uniform buffer.
  26613. * This is dynamic to allow compat with webgl 1 and 2.
  26614. * You will need to pass the name of the uniform as well as the value.
  26615. */
  26616. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26617. /**
  26618. * Lambda to Update a vec3 of float in a uniform buffer.
  26619. * This is dynamic to allow compat with webgl 1 and 2.
  26620. * You will need to pass the name of the uniform as well as the value.
  26621. */
  26622. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26623. /**
  26624. * Lambda to Update a vec4 of float in a uniform buffer.
  26625. * This is dynamic to allow compat with webgl 1 and 2.
  26626. * You will need to pass the name of the uniform as well as the value.
  26627. */
  26628. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26629. /**
  26630. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26631. * This is dynamic to allow compat with webgl 1 and 2.
  26632. * You will need to pass the name of the uniform as well as the value.
  26633. */
  26634. updateMatrix: (name: string, mat: Matrix) => void;
  26635. /**
  26636. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26637. * This is dynamic to allow compat with webgl 1 and 2.
  26638. * You will need to pass the name of the uniform as well as the value.
  26639. */
  26640. updateVector3: (name: string, vector: Vector3) => void;
  26641. /**
  26642. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26643. * This is dynamic to allow compat with webgl 1 and 2.
  26644. * You will need to pass the name of the uniform as well as the value.
  26645. */
  26646. updateVector4: (name: string, vector: Vector4) => void;
  26647. /**
  26648. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26649. * This is dynamic to allow compat with webgl 1 and 2.
  26650. * You will need to pass the name of the uniform as well as the value.
  26651. */
  26652. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26653. /**
  26654. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26655. * This is dynamic to allow compat with webgl 1 and 2.
  26656. * You will need to pass the name of the uniform as well as the value.
  26657. */
  26658. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26659. /**
  26660. * Instantiates a new Uniform buffer objects.
  26661. *
  26662. * Handles blocks of uniform on the GPU.
  26663. *
  26664. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26665. *
  26666. * For more information, please refer to :
  26667. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26668. * @param engine Define the engine the buffer is associated with
  26669. * @param data Define the data contained in the buffer
  26670. * @param dynamic Define if the buffer is updatable
  26671. */
  26672. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26673. /**
  26674. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26675. * or just falling back on setUniformXXX calls.
  26676. */
  26677. readonly useUbo: boolean;
  26678. /**
  26679. * Indicates if the WebGL underlying uniform buffer is in sync
  26680. * with the javascript cache data.
  26681. */
  26682. readonly isSync: boolean;
  26683. /**
  26684. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26685. * Also, a dynamic UniformBuffer will disable cache verification and always
  26686. * update the underlying WebGL uniform buffer to the GPU.
  26687. * @returns if Dynamic, otherwise false
  26688. */
  26689. isDynamic(): boolean;
  26690. /**
  26691. * The data cache on JS side.
  26692. * @returns the underlying data as a float array
  26693. */
  26694. getData(): Float32Array;
  26695. /**
  26696. * The underlying WebGL Uniform buffer.
  26697. * @returns the webgl buffer
  26698. */
  26699. getBuffer(): Nullable<DataBuffer>;
  26700. /**
  26701. * std140 layout specifies how to align data within an UBO structure.
  26702. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26703. * for specs.
  26704. */
  26705. private _fillAlignment;
  26706. /**
  26707. * Adds an uniform in the buffer.
  26708. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26709. * for the layout to be correct !
  26710. * @param name Name of the uniform, as used in the uniform block in the shader.
  26711. * @param size Data size, or data directly.
  26712. */
  26713. addUniform(name: string, size: number | number[]): void;
  26714. /**
  26715. * Adds a Matrix 4x4 to the uniform buffer.
  26716. * @param name Name of the uniform, as used in the uniform block in the shader.
  26717. * @param mat A 4x4 matrix.
  26718. */
  26719. addMatrix(name: string, mat: Matrix): void;
  26720. /**
  26721. * Adds a vec2 to the uniform buffer.
  26722. * @param name Name of the uniform, as used in the uniform block in the shader.
  26723. * @param x Define the x component value of the vec2
  26724. * @param y Define the y component value of the vec2
  26725. */
  26726. addFloat2(name: string, x: number, y: number): void;
  26727. /**
  26728. * Adds a vec3 to the uniform buffer.
  26729. * @param name Name of the uniform, as used in the uniform block in the shader.
  26730. * @param x Define the x component value of the vec3
  26731. * @param y Define the y component value of the vec3
  26732. * @param z Define the z component value of the vec3
  26733. */
  26734. addFloat3(name: string, x: number, y: number, z: number): void;
  26735. /**
  26736. * Adds a vec3 to the uniform buffer.
  26737. * @param name Name of the uniform, as used in the uniform block in the shader.
  26738. * @param color Define the vec3 from a Color
  26739. */
  26740. addColor3(name: string, color: Color3): void;
  26741. /**
  26742. * Adds a vec4 to the uniform buffer.
  26743. * @param name Name of the uniform, as used in the uniform block in the shader.
  26744. * @param color Define the rgb components from a Color
  26745. * @param alpha Define the a component of the vec4
  26746. */
  26747. addColor4(name: string, color: Color3, alpha: number): void;
  26748. /**
  26749. * Adds a vec3 to the uniform buffer.
  26750. * @param name Name of the uniform, as used in the uniform block in the shader.
  26751. * @param vector Define the vec3 components from a Vector
  26752. */
  26753. addVector3(name: string, vector: Vector3): void;
  26754. /**
  26755. * Adds a Matrix 3x3 to the uniform buffer.
  26756. * @param name Name of the uniform, as used in the uniform block in the shader.
  26757. */
  26758. addMatrix3x3(name: string): void;
  26759. /**
  26760. * Adds a Matrix 2x2 to the uniform buffer.
  26761. * @param name Name of the uniform, as used in the uniform block in the shader.
  26762. */
  26763. addMatrix2x2(name: string): void;
  26764. /**
  26765. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26766. */
  26767. create(): void;
  26768. /** @hidden */
  26769. _rebuild(): void;
  26770. /**
  26771. * Updates the WebGL Uniform Buffer on the GPU.
  26772. * If the `dynamic` flag is set to true, no cache comparison is done.
  26773. * Otherwise, the buffer will be updated only if the cache differs.
  26774. */
  26775. update(): void;
  26776. /**
  26777. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26778. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26779. * @param data Define the flattened data
  26780. * @param size Define the size of the data.
  26781. */
  26782. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26783. private _updateMatrix3x3ForUniform;
  26784. private _updateMatrix3x3ForEffect;
  26785. private _updateMatrix2x2ForEffect;
  26786. private _updateMatrix2x2ForUniform;
  26787. private _updateFloatForEffect;
  26788. private _updateFloatForUniform;
  26789. private _updateFloat2ForEffect;
  26790. private _updateFloat2ForUniform;
  26791. private _updateFloat3ForEffect;
  26792. private _updateFloat3ForUniform;
  26793. private _updateFloat4ForEffect;
  26794. private _updateFloat4ForUniform;
  26795. private _updateMatrixForEffect;
  26796. private _updateMatrixForUniform;
  26797. private _updateVector3ForEffect;
  26798. private _updateVector3ForUniform;
  26799. private _updateVector4ForEffect;
  26800. private _updateVector4ForUniform;
  26801. private _updateColor3ForEffect;
  26802. private _updateColor3ForUniform;
  26803. private _updateColor4ForEffect;
  26804. private _updateColor4ForUniform;
  26805. /**
  26806. * Sets a sampler uniform on the effect.
  26807. * @param name Define the name of the sampler.
  26808. * @param texture Define the texture to set in the sampler
  26809. */
  26810. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26811. /**
  26812. * Directly updates the value of the uniform in the cache AND on the GPU.
  26813. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26814. * @param data Define the flattened data
  26815. */
  26816. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26817. /**
  26818. * Binds this uniform buffer to an effect.
  26819. * @param effect Define the effect to bind the buffer to
  26820. * @param name Name of the uniform block in the shader.
  26821. */
  26822. bindToEffect(effect: Effect, name: string): void;
  26823. /**
  26824. * Disposes the uniform buffer.
  26825. */
  26826. dispose(): void;
  26827. }
  26828. }
  26829. declare module BABYLON {
  26830. /**
  26831. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26833. */
  26834. export class Analyser {
  26835. /**
  26836. * Gets or sets the smoothing
  26837. * @ignorenaming
  26838. */
  26839. SMOOTHING: number;
  26840. /**
  26841. * Gets or sets the FFT table size
  26842. * @ignorenaming
  26843. */
  26844. FFT_SIZE: number;
  26845. /**
  26846. * Gets or sets the bar graph amplitude
  26847. * @ignorenaming
  26848. */
  26849. BARGRAPHAMPLITUDE: number;
  26850. /**
  26851. * Gets or sets the position of the debug canvas
  26852. * @ignorenaming
  26853. */
  26854. DEBUGCANVASPOS: {
  26855. x: number;
  26856. y: number;
  26857. };
  26858. /**
  26859. * Gets or sets the debug canvas size
  26860. * @ignorenaming
  26861. */
  26862. DEBUGCANVASSIZE: {
  26863. width: number;
  26864. height: number;
  26865. };
  26866. private _byteFreqs;
  26867. private _byteTime;
  26868. private _floatFreqs;
  26869. private _webAudioAnalyser;
  26870. private _debugCanvas;
  26871. private _debugCanvasContext;
  26872. private _scene;
  26873. private _registerFunc;
  26874. private _audioEngine;
  26875. /**
  26876. * Creates a new analyser
  26877. * @param scene defines hosting scene
  26878. */
  26879. constructor(scene: Scene);
  26880. /**
  26881. * Get the number of data values you will have to play with for the visualization
  26882. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26883. * @returns a number
  26884. */
  26885. getFrequencyBinCount(): number;
  26886. /**
  26887. * Gets the current frequency data as a byte array
  26888. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26889. * @returns a Uint8Array
  26890. */
  26891. getByteFrequencyData(): Uint8Array;
  26892. /**
  26893. * Gets the current waveform as a byte array
  26894. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26895. * @returns a Uint8Array
  26896. */
  26897. getByteTimeDomainData(): Uint8Array;
  26898. /**
  26899. * Gets the current frequency data as a float array
  26900. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26901. * @returns a Float32Array
  26902. */
  26903. getFloatFrequencyData(): Float32Array;
  26904. /**
  26905. * Renders the debug canvas
  26906. */
  26907. drawDebugCanvas(): void;
  26908. /**
  26909. * Stops rendering the debug canvas and removes it
  26910. */
  26911. stopDebugCanvas(): void;
  26912. /**
  26913. * Connects two audio nodes
  26914. * @param inputAudioNode defines first node to connect
  26915. * @param outputAudioNode defines second node to connect
  26916. */
  26917. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26918. /**
  26919. * Releases all associated resources
  26920. */
  26921. dispose(): void;
  26922. }
  26923. }
  26924. declare module BABYLON {
  26925. /**
  26926. * This represents an audio engine and it is responsible
  26927. * to play, synchronize and analyse sounds throughout the application.
  26928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26929. */
  26930. export interface IAudioEngine extends IDisposable {
  26931. /**
  26932. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26933. */
  26934. readonly canUseWebAudio: boolean;
  26935. /**
  26936. * Gets the current AudioContext if available.
  26937. */
  26938. readonly audioContext: Nullable<AudioContext>;
  26939. /**
  26940. * The master gain node defines the global audio volume of your audio engine.
  26941. */
  26942. readonly masterGain: GainNode;
  26943. /**
  26944. * Gets whether or not mp3 are supported by your browser.
  26945. */
  26946. readonly isMP3supported: boolean;
  26947. /**
  26948. * Gets whether or not ogg are supported by your browser.
  26949. */
  26950. readonly isOGGsupported: boolean;
  26951. /**
  26952. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26953. * @ignoreNaming
  26954. */
  26955. WarnedWebAudioUnsupported: boolean;
  26956. /**
  26957. * Defines if the audio engine relies on a custom unlocked button.
  26958. * In this case, the embedded button will not be displayed.
  26959. */
  26960. useCustomUnlockedButton: boolean;
  26961. /**
  26962. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26963. */
  26964. readonly unlocked: boolean;
  26965. /**
  26966. * Event raised when audio has been unlocked on the browser.
  26967. */
  26968. onAudioUnlockedObservable: Observable<AudioEngine>;
  26969. /**
  26970. * Event raised when audio has been locked on the browser.
  26971. */
  26972. onAudioLockedObservable: Observable<AudioEngine>;
  26973. /**
  26974. * Flags the audio engine in Locked state.
  26975. * This happens due to new browser policies preventing audio to autoplay.
  26976. */
  26977. lock(): void;
  26978. /**
  26979. * Unlocks the audio engine once a user action has been done on the dom.
  26980. * This is helpful to resume play once browser policies have been satisfied.
  26981. */
  26982. unlock(): void;
  26983. }
  26984. /**
  26985. * This represents the default audio engine used in babylon.
  26986. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26988. */
  26989. export class AudioEngine implements IAudioEngine {
  26990. private _audioContext;
  26991. private _audioContextInitialized;
  26992. private _muteButton;
  26993. private _hostElement;
  26994. /**
  26995. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26996. */
  26997. canUseWebAudio: boolean;
  26998. /**
  26999. * The master gain node defines the global audio volume of your audio engine.
  27000. */
  27001. masterGain: GainNode;
  27002. /**
  27003. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27004. * @ignoreNaming
  27005. */
  27006. WarnedWebAudioUnsupported: boolean;
  27007. /**
  27008. * Gets whether or not mp3 are supported by your browser.
  27009. */
  27010. isMP3supported: boolean;
  27011. /**
  27012. * Gets whether or not ogg are supported by your browser.
  27013. */
  27014. isOGGsupported: boolean;
  27015. /**
  27016. * Gets whether audio has been unlocked on the device.
  27017. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27018. * a user interaction has happened.
  27019. */
  27020. unlocked: boolean;
  27021. /**
  27022. * Defines if the audio engine relies on a custom unlocked button.
  27023. * In this case, the embedded button will not be displayed.
  27024. */
  27025. useCustomUnlockedButton: boolean;
  27026. /**
  27027. * Event raised when audio has been unlocked on the browser.
  27028. */
  27029. onAudioUnlockedObservable: Observable<AudioEngine>;
  27030. /**
  27031. * Event raised when audio has been locked on the browser.
  27032. */
  27033. onAudioLockedObservable: Observable<AudioEngine>;
  27034. /**
  27035. * Gets the current AudioContext if available.
  27036. */
  27037. readonly audioContext: Nullable<AudioContext>;
  27038. private _connectedAnalyser;
  27039. /**
  27040. * Instantiates a new audio engine.
  27041. *
  27042. * There should be only one per page as some browsers restrict the number
  27043. * of audio contexts you can create.
  27044. * @param hostElement defines the host element where to display the mute icon if necessary
  27045. */
  27046. constructor(hostElement?: Nullable<HTMLElement>);
  27047. /**
  27048. * Flags the audio engine in Locked state.
  27049. * This happens due to new browser policies preventing audio to autoplay.
  27050. */
  27051. lock(): void;
  27052. /**
  27053. * Unlocks the audio engine once a user action has been done on the dom.
  27054. * This is helpful to resume play once browser policies have been satisfied.
  27055. */
  27056. unlock(): void;
  27057. private _resumeAudioContext;
  27058. private _initializeAudioContext;
  27059. private _tryToRun;
  27060. private _triggerRunningState;
  27061. private _triggerSuspendedState;
  27062. private _displayMuteButton;
  27063. private _moveButtonToTopLeft;
  27064. private _onResize;
  27065. private _hideMuteButton;
  27066. /**
  27067. * Destroy and release the resources associated with the audio ccontext.
  27068. */
  27069. dispose(): void;
  27070. /**
  27071. * Gets the global volume sets on the master gain.
  27072. * @returns the global volume if set or -1 otherwise
  27073. */
  27074. getGlobalVolume(): number;
  27075. /**
  27076. * Sets the global volume of your experience (sets on the master gain).
  27077. * @param newVolume Defines the new global volume of the application
  27078. */
  27079. setGlobalVolume(newVolume: number): void;
  27080. /**
  27081. * Connect the audio engine to an audio analyser allowing some amazing
  27082. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27083. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27084. * @param analyser The analyser to connect to the engine
  27085. */
  27086. connectToAnalyser(analyser: Analyser): void;
  27087. }
  27088. }
  27089. declare module BABYLON {
  27090. /**
  27091. * Interface used to present a loading screen while loading a scene
  27092. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27093. */
  27094. export interface ILoadingScreen {
  27095. /**
  27096. * Function called to display the loading screen
  27097. */
  27098. displayLoadingUI: () => void;
  27099. /**
  27100. * Function called to hide the loading screen
  27101. */
  27102. hideLoadingUI: () => void;
  27103. /**
  27104. * Gets or sets the color to use for the background
  27105. */
  27106. loadingUIBackgroundColor: string;
  27107. /**
  27108. * Gets or sets the text to display while loading
  27109. */
  27110. loadingUIText: string;
  27111. }
  27112. /**
  27113. * Class used for the default loading screen
  27114. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27115. */
  27116. export class DefaultLoadingScreen implements ILoadingScreen {
  27117. private _renderingCanvas;
  27118. private _loadingText;
  27119. private _loadingDivBackgroundColor;
  27120. private _loadingDiv;
  27121. private _loadingTextDiv;
  27122. /** Gets or sets the logo url to use for the default loading screen */
  27123. static DefaultLogoUrl: string;
  27124. /** Gets or sets the spinner url to use for the default loading screen */
  27125. static DefaultSpinnerUrl: string;
  27126. /**
  27127. * Creates a new default loading screen
  27128. * @param _renderingCanvas defines the canvas used to render the scene
  27129. * @param _loadingText defines the default text to display
  27130. * @param _loadingDivBackgroundColor defines the default background color
  27131. */
  27132. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27133. /**
  27134. * Function called to display the loading screen
  27135. */
  27136. displayLoadingUI(): void;
  27137. /**
  27138. * Function called to hide the loading screen
  27139. */
  27140. hideLoadingUI(): void;
  27141. /**
  27142. * Gets or sets the text to display while loading
  27143. */
  27144. loadingUIText: string;
  27145. /**
  27146. * Gets or sets the color to use for the background
  27147. */
  27148. loadingUIBackgroundColor: string;
  27149. private _resizeLoadingUI;
  27150. }
  27151. }
  27152. declare module BABYLON {
  27153. /** @hidden */
  27154. export class WebGLPipelineContext implements IPipelineContext {
  27155. engine: Engine;
  27156. program: Nullable<WebGLProgram>;
  27157. context?: WebGLRenderingContext;
  27158. vertexShader?: WebGLShader;
  27159. fragmentShader?: WebGLShader;
  27160. isParallelCompiled: boolean;
  27161. onCompiled?: () => void;
  27162. transformFeedback?: WebGLTransformFeedback | null;
  27163. readonly isAsync: boolean;
  27164. readonly isReady: boolean;
  27165. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27166. }
  27167. }
  27168. declare module BABYLON {
  27169. /** @hidden */
  27170. export class WebGLDataBuffer extends DataBuffer {
  27171. private _buffer;
  27172. constructor(resource: WebGLBuffer);
  27173. readonly underlyingResource: any;
  27174. }
  27175. }
  27176. declare module BABYLON {
  27177. /** @hidden */
  27178. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27179. attributeProcessor(attribute: string): string;
  27180. varyingProcessor(varying: string, isFragment: boolean): string;
  27181. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27182. }
  27183. }
  27184. declare module BABYLON {
  27185. /**
  27186. * Settings for finer control over video usage
  27187. */
  27188. export interface VideoTextureSettings {
  27189. /**
  27190. * Applies `autoplay` to video, if specified
  27191. */
  27192. autoPlay?: boolean;
  27193. /**
  27194. * Applies `loop` to video, if specified
  27195. */
  27196. loop?: boolean;
  27197. /**
  27198. * Automatically updates internal texture from video at every frame in the render loop
  27199. */
  27200. autoUpdateTexture: boolean;
  27201. /**
  27202. * Image src displayed during the video loading or until the user interacts with the video.
  27203. */
  27204. poster?: string;
  27205. }
  27206. /**
  27207. * If you want to display a video in your scene, this is the special texture for that.
  27208. * This special texture works similar to other textures, with the exception of a few parameters.
  27209. * @see https://doc.babylonjs.com/how_to/video_texture
  27210. */
  27211. export class VideoTexture extends Texture {
  27212. /**
  27213. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27214. */
  27215. readonly autoUpdateTexture: boolean;
  27216. /**
  27217. * The video instance used by the texture internally
  27218. */
  27219. readonly video: HTMLVideoElement;
  27220. private _onUserActionRequestedObservable;
  27221. /**
  27222. * Event triggerd when a dom action is required by the user to play the video.
  27223. * This happens due to recent changes in browser policies preventing video to auto start.
  27224. */
  27225. readonly onUserActionRequestedObservable: Observable<Texture>;
  27226. private _generateMipMaps;
  27227. private _engine;
  27228. private _stillImageCaptured;
  27229. private _displayingPosterTexture;
  27230. private _settings;
  27231. private _createInternalTextureOnEvent;
  27232. /**
  27233. * Creates a video texture.
  27234. * If you want to display a video in your scene, this is the special texture for that.
  27235. * This special texture works similar to other textures, with the exception of a few parameters.
  27236. * @see https://doc.babylonjs.com/how_to/video_texture
  27237. * @param name optional name, will detect from video source, if not defined
  27238. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27239. * @param scene is obviously the current scene.
  27240. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27241. * @param invertY is false by default but can be used to invert video on Y axis
  27242. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27243. * @param settings allows finer control over video usage
  27244. */
  27245. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27246. private _getName;
  27247. private _getVideo;
  27248. private _createInternalTexture;
  27249. private reset;
  27250. /**
  27251. * @hidden Internal method to initiate `update`.
  27252. */
  27253. _rebuild(): void;
  27254. /**
  27255. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27256. */
  27257. update(): void;
  27258. /**
  27259. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27260. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27261. */
  27262. updateTexture(isVisible: boolean): void;
  27263. protected _updateInternalTexture: () => void;
  27264. /**
  27265. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27266. * @param url New url.
  27267. */
  27268. updateURL(url: string): void;
  27269. /**
  27270. * Dispose the texture and release its associated resources.
  27271. */
  27272. dispose(): void;
  27273. /**
  27274. * Creates a video texture straight from a stream.
  27275. * @param scene Define the scene the texture should be created in
  27276. * @param stream Define the stream the texture should be created from
  27277. * @returns The created video texture as a promise
  27278. */
  27279. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27280. /**
  27281. * Creates a video texture straight from your WebCam video feed.
  27282. * @param scene Define the scene the texture should be created in
  27283. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27284. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27285. * @returns The created video texture as a promise
  27286. */
  27287. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27288. minWidth: number;
  27289. maxWidth: number;
  27290. minHeight: number;
  27291. maxHeight: number;
  27292. deviceId: string;
  27293. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27294. /**
  27295. * Creates a video texture straight from your WebCam video feed.
  27296. * @param scene Define the scene the texture should be created in
  27297. * @param onReady Define a callback to triggered once the texture will be ready
  27298. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27299. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27300. */
  27301. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27302. minWidth: number;
  27303. maxWidth: number;
  27304. minHeight: number;
  27305. maxHeight: number;
  27306. deviceId: string;
  27307. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27308. }
  27309. }
  27310. declare module BABYLON {
  27311. /**
  27312. * Interface for attribute information associated with buffer instanciation
  27313. */
  27314. export class InstancingAttributeInfo {
  27315. /**
  27316. * Index/offset of the attribute in the vertex shader
  27317. */
  27318. index: number;
  27319. /**
  27320. * size of the attribute, 1, 2, 3 or 4
  27321. */
  27322. attributeSize: number;
  27323. /**
  27324. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27325. * default is FLOAT
  27326. */
  27327. attribyteType: number;
  27328. /**
  27329. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27330. */
  27331. normalized: boolean;
  27332. /**
  27333. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27334. */
  27335. offset: number;
  27336. /**
  27337. * Name of the GLSL attribute, for debugging purpose only
  27338. */
  27339. attributeName: string;
  27340. }
  27341. /**
  27342. * Define options used to create a depth texture
  27343. */
  27344. export class DepthTextureCreationOptions {
  27345. /** Specifies whether or not a stencil should be allocated in the texture */
  27346. generateStencil?: boolean;
  27347. /** Specifies whether or not bilinear filtering is enable on the texture */
  27348. bilinearFiltering?: boolean;
  27349. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27350. comparisonFunction?: number;
  27351. /** Specifies if the created texture is a cube texture */
  27352. isCube?: boolean;
  27353. }
  27354. /**
  27355. * Class used to describe the capabilities of the engine relatively to the current browser
  27356. */
  27357. export class EngineCapabilities {
  27358. /** Maximum textures units per fragment shader */
  27359. maxTexturesImageUnits: number;
  27360. /** Maximum texture units per vertex shader */
  27361. maxVertexTextureImageUnits: number;
  27362. /** Maximum textures units in the entire pipeline */
  27363. maxCombinedTexturesImageUnits: number;
  27364. /** Maximum texture size */
  27365. maxTextureSize: number;
  27366. /** Maximum cube texture size */
  27367. maxCubemapTextureSize: number;
  27368. /** Maximum render texture size */
  27369. maxRenderTextureSize: number;
  27370. /** Maximum number of vertex attributes */
  27371. maxVertexAttribs: number;
  27372. /** Maximum number of varyings */
  27373. maxVaryingVectors: number;
  27374. /** Maximum number of uniforms per vertex shader */
  27375. maxVertexUniformVectors: number;
  27376. /** Maximum number of uniforms per fragment shader */
  27377. maxFragmentUniformVectors: number;
  27378. /** Defines if standard derivates (dx/dy) are supported */
  27379. standardDerivatives: boolean;
  27380. /** Defines if s3tc texture compression is supported */
  27381. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27382. /** Defines if pvrtc texture compression is supported */
  27383. pvrtc: any;
  27384. /** Defines if etc1 texture compression is supported */
  27385. etc1: any;
  27386. /** Defines if etc2 texture compression is supported */
  27387. etc2: any;
  27388. /** Defines if astc texture compression is supported */
  27389. astc: any;
  27390. /** Defines if float textures are supported */
  27391. textureFloat: boolean;
  27392. /** Defines if vertex array objects are supported */
  27393. vertexArrayObject: boolean;
  27394. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27395. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27396. /** Gets the maximum level of anisotropy supported */
  27397. maxAnisotropy: number;
  27398. /** Defines if instancing is supported */
  27399. instancedArrays: boolean;
  27400. /** Defines if 32 bits indices are supported */
  27401. uintIndices: boolean;
  27402. /** Defines if high precision shaders are supported */
  27403. highPrecisionShaderSupported: boolean;
  27404. /** Defines if depth reading in the fragment shader is supported */
  27405. fragmentDepthSupported: boolean;
  27406. /** Defines if float texture linear filtering is supported*/
  27407. textureFloatLinearFiltering: boolean;
  27408. /** Defines if rendering to float textures is supported */
  27409. textureFloatRender: boolean;
  27410. /** Defines if half float textures are supported*/
  27411. textureHalfFloat: boolean;
  27412. /** Defines if half float texture linear filtering is supported*/
  27413. textureHalfFloatLinearFiltering: boolean;
  27414. /** Defines if rendering to half float textures is supported */
  27415. textureHalfFloatRender: boolean;
  27416. /** Defines if textureLOD shader command is supported */
  27417. textureLOD: boolean;
  27418. /** Defines if draw buffers extension is supported */
  27419. drawBuffersExtension: boolean;
  27420. /** Defines if depth textures are supported */
  27421. depthTextureExtension: boolean;
  27422. /** Defines if float color buffer are supported */
  27423. colorBufferFloat: boolean;
  27424. /** Gets disjoint timer query extension (null if not supported) */
  27425. timerQuery: EXT_disjoint_timer_query;
  27426. /** Defines if timestamp can be used with timer query */
  27427. canUseTimestampForTimerQuery: boolean;
  27428. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27429. multiview: any;
  27430. /** Function used to let the system compiles shaders in background */
  27431. parallelShaderCompile: {
  27432. COMPLETION_STATUS_KHR: number;
  27433. };
  27434. }
  27435. /** Interface defining initialization parameters for Engine class */
  27436. export interface EngineOptions extends WebGLContextAttributes {
  27437. /**
  27438. * Defines if the engine should no exceed a specified device ratio
  27439. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27440. */
  27441. limitDeviceRatio?: number;
  27442. /**
  27443. * Defines if webvr should be enabled automatically
  27444. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27445. */
  27446. autoEnableWebVR?: boolean;
  27447. /**
  27448. * Defines if webgl2 should be turned off even if supported
  27449. * @see http://doc.babylonjs.com/features/webgl2
  27450. */
  27451. disableWebGL2Support?: boolean;
  27452. /**
  27453. * Defines if webaudio should be initialized as well
  27454. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27455. */
  27456. audioEngine?: boolean;
  27457. /**
  27458. * Defines if animations should run using a deterministic lock step
  27459. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27460. */
  27461. deterministicLockstep?: boolean;
  27462. /** Defines the maximum steps to use with deterministic lock step mode */
  27463. lockstepMaxSteps?: number;
  27464. /**
  27465. * Defines that engine should ignore context lost events
  27466. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27467. */
  27468. doNotHandleContextLost?: boolean;
  27469. /**
  27470. * Defines that engine should ignore modifying touch action attribute and style
  27471. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27472. */
  27473. doNotHandleTouchAction?: boolean;
  27474. /**
  27475. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27476. */
  27477. useHighPrecisionFloats?: boolean;
  27478. }
  27479. /**
  27480. * Defines the interface used by display changed events
  27481. */
  27482. export interface IDisplayChangedEventArgs {
  27483. /** Gets the vrDisplay object (if any) */
  27484. vrDisplay: Nullable<any>;
  27485. /** Gets a boolean indicating if webVR is supported */
  27486. vrSupported: boolean;
  27487. }
  27488. /**
  27489. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27490. */
  27491. export class Engine {
  27492. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27493. static ExceptionList: ({
  27494. key: string;
  27495. capture: string;
  27496. captureConstraint: number;
  27497. targets: string[];
  27498. } | {
  27499. key: string;
  27500. capture: null;
  27501. captureConstraint: null;
  27502. targets: string[];
  27503. })[];
  27504. /** Gets the list of created engines */
  27505. static readonly Instances: Engine[];
  27506. /**
  27507. * Gets the latest created engine
  27508. */
  27509. static readonly LastCreatedEngine: Nullable<Engine>;
  27510. /**
  27511. * Gets the latest created scene
  27512. */
  27513. static readonly LastCreatedScene: Nullable<Scene>;
  27514. /**
  27515. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27516. * @param flag defines which part of the materials must be marked as dirty
  27517. * @param predicate defines a predicate used to filter which materials should be affected
  27518. */
  27519. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27520. /** @hidden */
  27521. static _TextureLoaders: IInternalTextureLoader[];
  27522. /** Defines that alpha blending is disabled */
  27523. static readonly ALPHA_DISABLE: number;
  27524. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27525. static readonly ALPHA_ADD: number;
  27526. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27527. static readonly ALPHA_COMBINE: number;
  27528. /** Defines that alpha blending to DEST - SRC * DEST */
  27529. static readonly ALPHA_SUBTRACT: number;
  27530. /** Defines that alpha blending to SRC * DEST */
  27531. static readonly ALPHA_MULTIPLY: number;
  27532. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27533. static readonly ALPHA_MAXIMIZED: number;
  27534. /** Defines that alpha blending to SRC + DEST */
  27535. static readonly ALPHA_ONEONE: number;
  27536. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27537. static readonly ALPHA_PREMULTIPLIED: number;
  27538. /**
  27539. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27540. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27541. */
  27542. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27543. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27544. static readonly ALPHA_INTERPOLATE: number;
  27545. /**
  27546. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27547. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27548. */
  27549. static readonly ALPHA_SCREENMODE: number;
  27550. /** Defines that the ressource is not delayed*/
  27551. static readonly DELAYLOADSTATE_NONE: number;
  27552. /** Defines that the ressource was successfully delay loaded */
  27553. static readonly DELAYLOADSTATE_LOADED: number;
  27554. /** Defines that the ressource is currently delay loading */
  27555. static readonly DELAYLOADSTATE_LOADING: number;
  27556. /** Defines that the ressource is delayed and has not started loading */
  27557. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27558. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27559. static readonly NEVER: number;
  27560. /** 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 */
  27561. static readonly ALWAYS: number;
  27562. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27563. static readonly LESS: number;
  27564. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27565. static readonly EQUAL: number;
  27566. /** 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 */
  27567. static readonly LEQUAL: number;
  27568. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27569. static readonly GREATER: number;
  27570. /** 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 */
  27571. static readonly GEQUAL: number;
  27572. /** 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 */
  27573. static readonly NOTEQUAL: number;
  27574. /** Passed to stencilOperation to specify that stencil value must be kept */
  27575. static readonly KEEP: number;
  27576. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27577. static readonly REPLACE: number;
  27578. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27579. static readonly INCR: number;
  27580. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27581. static readonly DECR: number;
  27582. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27583. static readonly INVERT: number;
  27584. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27585. static readonly INCR_WRAP: number;
  27586. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27587. static readonly DECR_WRAP: number;
  27588. /** Texture is not repeating outside of 0..1 UVs */
  27589. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27590. /** Texture is repeating outside of 0..1 UVs */
  27591. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27592. /** Texture is repeating and mirrored */
  27593. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27594. /** ALPHA */
  27595. static readonly TEXTUREFORMAT_ALPHA: number;
  27596. /** LUMINANCE */
  27597. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27598. /** LUMINANCE_ALPHA */
  27599. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27600. /** RGB */
  27601. static readonly TEXTUREFORMAT_RGB: number;
  27602. /** RGBA */
  27603. static readonly TEXTUREFORMAT_RGBA: number;
  27604. /** RED */
  27605. static readonly TEXTUREFORMAT_RED: number;
  27606. /** RED (2nd reference) */
  27607. static readonly TEXTUREFORMAT_R: number;
  27608. /** RG */
  27609. static readonly TEXTUREFORMAT_RG: number;
  27610. /** RED_INTEGER */
  27611. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27612. /** RED_INTEGER (2nd reference) */
  27613. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27614. /** RG_INTEGER */
  27615. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27616. /** RGB_INTEGER */
  27617. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27618. /** RGBA_INTEGER */
  27619. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27620. /** UNSIGNED_BYTE */
  27621. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27622. /** UNSIGNED_BYTE (2nd reference) */
  27623. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27624. /** FLOAT */
  27625. static readonly TEXTURETYPE_FLOAT: number;
  27626. /** HALF_FLOAT */
  27627. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27628. /** BYTE */
  27629. static readonly TEXTURETYPE_BYTE: number;
  27630. /** SHORT */
  27631. static readonly TEXTURETYPE_SHORT: number;
  27632. /** UNSIGNED_SHORT */
  27633. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27634. /** INT */
  27635. static readonly TEXTURETYPE_INT: number;
  27636. /** UNSIGNED_INT */
  27637. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27638. /** UNSIGNED_SHORT_4_4_4_4 */
  27639. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27640. /** UNSIGNED_SHORT_5_5_5_1 */
  27641. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27642. /** UNSIGNED_SHORT_5_6_5 */
  27643. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27644. /** UNSIGNED_INT_2_10_10_10_REV */
  27645. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27646. /** UNSIGNED_INT_24_8 */
  27647. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27648. /** UNSIGNED_INT_10F_11F_11F_REV */
  27649. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27650. /** UNSIGNED_INT_5_9_9_9_REV */
  27651. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27652. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27653. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27654. /** nearest is mag = nearest and min = nearest and mip = linear */
  27655. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27656. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27657. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27658. /** Trilinear is mag = linear and min = linear and mip = linear */
  27659. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27660. /** nearest is mag = nearest and min = nearest and mip = linear */
  27661. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27662. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27663. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27664. /** Trilinear is mag = linear and min = linear and mip = linear */
  27665. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27666. /** mag = nearest and min = nearest and mip = nearest */
  27667. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27668. /** mag = nearest and min = linear and mip = nearest */
  27669. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27670. /** mag = nearest and min = linear and mip = linear */
  27671. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27672. /** mag = nearest and min = linear and mip = none */
  27673. static readonly TEXTURE_NEAREST_LINEAR: number;
  27674. /** mag = nearest and min = nearest and mip = none */
  27675. static readonly TEXTURE_NEAREST_NEAREST: number;
  27676. /** mag = linear and min = nearest and mip = nearest */
  27677. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27678. /** mag = linear and min = nearest and mip = linear */
  27679. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27680. /** mag = linear and min = linear and mip = none */
  27681. static readonly TEXTURE_LINEAR_LINEAR: number;
  27682. /** mag = linear and min = nearest and mip = none */
  27683. static readonly TEXTURE_LINEAR_NEAREST: number;
  27684. /** Explicit coordinates mode */
  27685. static readonly TEXTURE_EXPLICIT_MODE: number;
  27686. /** Spherical coordinates mode */
  27687. static readonly TEXTURE_SPHERICAL_MODE: number;
  27688. /** Planar coordinates mode */
  27689. static readonly TEXTURE_PLANAR_MODE: number;
  27690. /** Cubic coordinates mode */
  27691. static readonly TEXTURE_CUBIC_MODE: number;
  27692. /** Projection coordinates mode */
  27693. static readonly TEXTURE_PROJECTION_MODE: number;
  27694. /** Skybox coordinates mode */
  27695. static readonly TEXTURE_SKYBOX_MODE: number;
  27696. /** Inverse Cubic coordinates mode */
  27697. static readonly TEXTURE_INVCUBIC_MODE: number;
  27698. /** Equirectangular coordinates mode */
  27699. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27700. /** Equirectangular Fixed coordinates mode */
  27701. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27702. /** Equirectangular Fixed Mirrored coordinates mode */
  27703. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27704. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27705. static readonly SCALEMODE_FLOOR: number;
  27706. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27707. static readonly SCALEMODE_NEAREST: number;
  27708. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27709. static readonly SCALEMODE_CEILING: number;
  27710. /**
  27711. * Returns the current npm package of the sdk
  27712. */
  27713. static readonly NpmPackage: string;
  27714. /**
  27715. * Returns the current version of the framework
  27716. */
  27717. static readonly Version: string;
  27718. /**
  27719. * Returns a string describing the current engine
  27720. */
  27721. readonly description: string;
  27722. /**
  27723. * Gets or sets the epsilon value used by collision engine
  27724. */
  27725. static CollisionsEpsilon: number;
  27726. /**
  27727. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27728. */
  27729. static ShadersRepository: string;
  27730. /**
  27731. * Method called to create the default loading screen.
  27732. * This can be overriden in your own app.
  27733. * @param canvas The rendering canvas element
  27734. * @returns The loading screen
  27735. */
  27736. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27737. /**
  27738. * Method called to create the default rescale post process on each engine.
  27739. */
  27740. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27741. /** @hidden */
  27742. _shaderProcessor: IShaderProcessor;
  27743. /**
  27744. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27745. */
  27746. forcePOTTextures: boolean;
  27747. /**
  27748. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27749. */
  27750. isFullscreen: boolean;
  27751. /**
  27752. * Gets a boolean indicating if the pointer is currently locked
  27753. */
  27754. isPointerLock: boolean;
  27755. /**
  27756. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27757. */
  27758. cullBackFaces: boolean;
  27759. /**
  27760. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27761. */
  27762. renderEvenInBackground: boolean;
  27763. /**
  27764. * Gets or sets a boolean indicating that cache can be kept between frames
  27765. */
  27766. preventCacheWipeBetweenFrames: boolean;
  27767. /**
  27768. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27769. **/
  27770. enableOfflineSupport: boolean;
  27771. /**
  27772. * 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)
  27773. **/
  27774. disableManifestCheck: boolean;
  27775. /**
  27776. * Gets the list of created scenes
  27777. */
  27778. scenes: Scene[];
  27779. /**
  27780. * Event raised when a new scene is created
  27781. */
  27782. onNewSceneAddedObservable: Observable<Scene>;
  27783. /**
  27784. * Gets the list of created postprocesses
  27785. */
  27786. postProcesses: PostProcess[];
  27787. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27788. validateShaderPrograms: boolean;
  27789. /**
  27790. * Observable event triggered each time the rendering canvas is resized
  27791. */
  27792. onResizeObservable: Observable<Engine>;
  27793. /**
  27794. * Observable event triggered each time the canvas loses focus
  27795. */
  27796. onCanvasBlurObservable: Observable<Engine>;
  27797. /**
  27798. * Observable event triggered each time the canvas gains focus
  27799. */
  27800. onCanvasFocusObservable: Observable<Engine>;
  27801. /**
  27802. * Observable event triggered each time the canvas receives pointerout event
  27803. */
  27804. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27805. /**
  27806. * Observable event triggered before each texture is initialized
  27807. */
  27808. onBeforeTextureInitObservable: Observable<Texture>;
  27809. /**
  27810. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27811. */
  27812. disableUniformBuffers: boolean;
  27813. /** @hidden */
  27814. _uniformBuffers: UniformBuffer[];
  27815. /**
  27816. * Gets a boolean indicating that the engine supports uniform buffers
  27817. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27818. */
  27819. readonly supportsUniformBuffers: boolean;
  27820. /**
  27821. * Observable raised when the engine begins a new frame
  27822. */
  27823. onBeginFrameObservable: Observable<Engine>;
  27824. /**
  27825. * If set, will be used to request the next animation frame for the render loop
  27826. */
  27827. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27828. /**
  27829. * Observable raised when the engine ends the current frame
  27830. */
  27831. onEndFrameObservable: Observable<Engine>;
  27832. /**
  27833. * Observable raised when the engine is about to compile a shader
  27834. */
  27835. onBeforeShaderCompilationObservable: Observable<Engine>;
  27836. /**
  27837. * Observable raised when the engine has jsut compiled a shader
  27838. */
  27839. onAfterShaderCompilationObservable: Observable<Engine>;
  27840. /** @hidden */
  27841. _gl: WebGLRenderingContext;
  27842. private _renderingCanvas;
  27843. private _windowIsBackground;
  27844. private _webGLVersion;
  27845. protected _highPrecisionShadersAllowed: boolean;
  27846. /** @hidden */
  27847. readonly _shouldUseHighPrecisionShader: boolean;
  27848. /**
  27849. * Gets a boolean indicating that only power of 2 textures are supported
  27850. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27851. */
  27852. readonly needPOTTextures: boolean;
  27853. /** @hidden */
  27854. _badOS: boolean;
  27855. /** @hidden */
  27856. _badDesktopOS: boolean;
  27857. /**
  27858. * Gets the audio engine
  27859. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27860. * @ignorenaming
  27861. */
  27862. static audioEngine: IAudioEngine;
  27863. /**
  27864. * Default AudioEngine factory responsible of creating the Audio Engine.
  27865. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27866. */
  27867. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27868. /**
  27869. * Default offline support factory responsible of creating a tool used to store data locally.
  27870. * By default, this will create a Database object if the workload has been embedded.
  27871. */
  27872. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27873. private _onFocus;
  27874. private _onBlur;
  27875. private _onCanvasPointerOut;
  27876. private _onCanvasBlur;
  27877. private _onCanvasFocus;
  27878. private _onFullscreenChange;
  27879. private _onPointerLockChange;
  27880. private _hardwareScalingLevel;
  27881. /** @hidden */
  27882. _caps: EngineCapabilities;
  27883. private _pointerLockRequested;
  27884. private _isStencilEnable;
  27885. private _colorWrite;
  27886. private _loadingScreen;
  27887. /** @hidden */
  27888. _drawCalls: PerfCounter;
  27889. private _glVersion;
  27890. private _glRenderer;
  27891. private _glVendor;
  27892. private _videoTextureSupported;
  27893. private _renderingQueueLaunched;
  27894. private _activeRenderLoops;
  27895. private _deterministicLockstep;
  27896. private _lockstepMaxSteps;
  27897. /**
  27898. * Observable signaled when a context lost event is raised
  27899. */
  27900. onContextLostObservable: Observable<Engine>;
  27901. /**
  27902. * Observable signaled when a context restored event is raised
  27903. */
  27904. onContextRestoredObservable: Observable<Engine>;
  27905. private _onContextLost;
  27906. private _onContextRestored;
  27907. private _contextWasLost;
  27908. /** @hidden */
  27909. _doNotHandleContextLost: boolean;
  27910. /**
  27911. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27912. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27913. */
  27914. doNotHandleContextLost: boolean;
  27915. private _performanceMonitor;
  27916. private _fps;
  27917. private _deltaTime;
  27918. /**
  27919. * Turn this value on if you want to pause FPS computation when in background
  27920. */
  27921. disablePerformanceMonitorInBackground: boolean;
  27922. /**
  27923. * Gets the performance monitor attached to this engine
  27924. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27925. */
  27926. readonly performanceMonitor: PerformanceMonitor;
  27927. /**
  27928. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27929. */
  27930. disableVertexArrayObjects: boolean;
  27931. /** @hidden */
  27932. protected _depthCullingState: _DepthCullingState;
  27933. /** @hidden */
  27934. protected _stencilState: _StencilState;
  27935. /** @hidden */
  27936. protected _alphaState: _AlphaState;
  27937. /** @hidden */
  27938. protected _alphaMode: number;
  27939. /** @hidden */
  27940. _internalTexturesCache: InternalTexture[];
  27941. /** @hidden */
  27942. protected _activeChannel: number;
  27943. private _currentTextureChannel;
  27944. /** @hidden */
  27945. protected _boundTexturesCache: {
  27946. [key: string]: Nullable<InternalTexture>;
  27947. };
  27948. /** @hidden */
  27949. protected _currentEffect: Nullable<Effect>;
  27950. /** @hidden */
  27951. protected _currentProgram: Nullable<WebGLProgram>;
  27952. private _compiledEffects;
  27953. private _vertexAttribArraysEnabled;
  27954. /** @hidden */
  27955. protected _cachedViewport: Nullable<Viewport>;
  27956. private _cachedVertexArrayObject;
  27957. /** @hidden */
  27958. protected _cachedVertexBuffers: any;
  27959. /** @hidden */
  27960. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27961. /** @hidden */
  27962. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27963. /** @hidden */
  27964. _currentRenderTarget: Nullable<InternalTexture>;
  27965. private _uintIndicesCurrentlySet;
  27966. private _currentBoundBuffer;
  27967. /** @hidden */
  27968. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27969. private _currentBufferPointers;
  27970. private _currentInstanceLocations;
  27971. private _currentInstanceBuffers;
  27972. private _textureUnits;
  27973. /** @hidden */
  27974. _workingCanvas: Nullable<HTMLCanvasElement>;
  27975. /** @hidden */
  27976. _workingContext: Nullable<CanvasRenderingContext2D>;
  27977. private _rescalePostProcess;
  27978. private _dummyFramebuffer;
  27979. private _externalData;
  27980. /** @hidden */
  27981. _bindedRenderFunction: any;
  27982. private _vaoRecordInProgress;
  27983. private _mustWipeVertexAttributes;
  27984. private _emptyTexture;
  27985. private _emptyCubeTexture;
  27986. private _emptyTexture3D;
  27987. /** @hidden */
  27988. _frameHandler: number;
  27989. private _nextFreeTextureSlots;
  27990. private _maxSimultaneousTextures;
  27991. private _activeRequests;
  27992. private _texturesSupported;
  27993. /** @hidden */
  27994. _textureFormatInUse: Nullable<string>;
  27995. /**
  27996. * Gets the list of texture formats supported
  27997. */
  27998. readonly texturesSupported: Array<string>;
  27999. /**
  28000. * Gets the list of texture formats in use
  28001. */
  28002. readonly textureFormatInUse: Nullable<string>;
  28003. /**
  28004. * Gets the current viewport
  28005. */
  28006. readonly currentViewport: Nullable<Viewport>;
  28007. /**
  28008. * Gets the default empty texture
  28009. */
  28010. readonly emptyTexture: InternalTexture;
  28011. /**
  28012. * Gets the default empty 3D texture
  28013. */
  28014. readonly emptyTexture3D: InternalTexture;
  28015. /**
  28016. * Gets the default empty cube texture
  28017. */
  28018. readonly emptyCubeTexture: InternalTexture;
  28019. /**
  28020. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28021. */
  28022. readonly premultipliedAlpha: boolean;
  28023. /**
  28024. * Creates a new engine
  28025. * @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
  28026. * @param antialias defines enable antialiasing (default: false)
  28027. * @param options defines further options to be sent to the getContext() function
  28028. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28029. */
  28030. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28031. /**
  28032. * Initializes a webVR display and starts listening to display change events
  28033. * The onVRDisplayChangedObservable will be notified upon these changes
  28034. * @returns The onVRDisplayChangedObservable
  28035. */
  28036. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28037. /** @hidden */
  28038. _prepareVRComponent(): void;
  28039. /** @hidden */
  28040. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28041. /** @hidden */
  28042. _submitVRFrame(): void;
  28043. /**
  28044. * Call this function to leave webVR mode
  28045. * Will do nothing if webVR is not supported or if there is no webVR device
  28046. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28047. */
  28048. disableVR(): void;
  28049. /**
  28050. * Gets a boolean indicating that the system is in VR mode and is presenting
  28051. * @returns true if VR mode is engaged
  28052. */
  28053. isVRPresenting(): boolean;
  28054. /** @hidden */
  28055. _requestVRFrame(): void;
  28056. private _disableTouchAction;
  28057. private _rebuildInternalTextures;
  28058. private _rebuildEffects;
  28059. /**
  28060. * Gets a boolean indicating if all created effects are ready
  28061. * @returns true if all effects are ready
  28062. */
  28063. areAllEffectsReady(): boolean;
  28064. private _rebuildBuffers;
  28065. private _initGLContext;
  28066. /**
  28067. * Gets version of the current webGL context
  28068. */
  28069. readonly webGLVersion: number;
  28070. /**
  28071. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28072. */
  28073. readonly isStencilEnable: boolean;
  28074. /** @hidden */
  28075. _prepareWorkingCanvas(): void;
  28076. /**
  28077. * Reset the texture cache to empty state
  28078. */
  28079. resetTextureCache(): void;
  28080. /**
  28081. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28082. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28083. * @returns true if engine is in deterministic lock step mode
  28084. */
  28085. isDeterministicLockStep(): boolean;
  28086. /**
  28087. * Gets the max steps when engine is running in deterministic lock step
  28088. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28089. * @returns the max steps
  28090. */
  28091. getLockstepMaxSteps(): number;
  28092. /**
  28093. * Gets an object containing information about the current webGL context
  28094. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28095. */
  28096. getGlInfo(): {
  28097. vendor: string;
  28098. renderer: string;
  28099. version: string;
  28100. };
  28101. /**
  28102. * Gets current aspect ratio
  28103. * @param camera defines the camera to use to get the aspect ratio
  28104. * @param useScreen defines if screen size must be used (or the current render target if any)
  28105. * @returns a number defining the aspect ratio
  28106. */
  28107. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28108. /**
  28109. * Gets current screen aspect ratio
  28110. * @returns a number defining the aspect ratio
  28111. */
  28112. getScreenAspectRatio(): number;
  28113. /**
  28114. * Gets the current render width
  28115. * @param useScreen defines if screen size must be used (or the current render target if any)
  28116. * @returns a number defining the current render width
  28117. */
  28118. getRenderWidth(useScreen?: boolean): number;
  28119. /**
  28120. * Gets the current render height
  28121. * @param useScreen defines if screen size must be used (or the current render target if any)
  28122. * @returns a number defining the current render height
  28123. */
  28124. getRenderHeight(useScreen?: boolean): number;
  28125. /**
  28126. * Gets the HTML canvas attached with the current webGL context
  28127. * @returns a HTML canvas
  28128. */
  28129. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28130. /**
  28131. * Gets the client rect of the HTML canvas attached with the current webGL context
  28132. * @returns a client rectanglee
  28133. */
  28134. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28135. /**
  28136. * Defines the hardware scaling level.
  28137. * By default the hardware scaling level is computed from the window device ratio.
  28138. * 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.
  28139. * @param level defines the level to use
  28140. */
  28141. setHardwareScalingLevel(level: number): void;
  28142. /**
  28143. * Gets the current hardware scaling level.
  28144. * By default the hardware scaling level is computed from the window device ratio.
  28145. * 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.
  28146. * @returns a number indicating the current hardware scaling level
  28147. */
  28148. getHardwareScalingLevel(): number;
  28149. /**
  28150. * Gets the list of loaded textures
  28151. * @returns an array containing all loaded textures
  28152. */
  28153. getLoadedTexturesCache(): InternalTexture[];
  28154. /**
  28155. * Gets the object containing all engine capabilities
  28156. * @returns the EngineCapabilities object
  28157. */
  28158. getCaps(): EngineCapabilities;
  28159. /**
  28160. * Gets the current depth function
  28161. * @returns a number defining the depth function
  28162. */
  28163. getDepthFunction(): Nullable<number>;
  28164. /**
  28165. * Sets the current depth function
  28166. * @param depthFunc defines the function to use
  28167. */
  28168. setDepthFunction(depthFunc: number): void;
  28169. /**
  28170. * Sets the current depth function to GREATER
  28171. */
  28172. setDepthFunctionToGreater(): void;
  28173. /**
  28174. * Sets the current depth function to GEQUAL
  28175. */
  28176. setDepthFunctionToGreaterOrEqual(): void;
  28177. /**
  28178. * Sets the current depth function to LESS
  28179. */
  28180. setDepthFunctionToLess(): void;
  28181. private _cachedStencilBuffer;
  28182. private _cachedStencilFunction;
  28183. private _cachedStencilMask;
  28184. private _cachedStencilOperationPass;
  28185. private _cachedStencilOperationFail;
  28186. private _cachedStencilOperationDepthFail;
  28187. private _cachedStencilReference;
  28188. /**
  28189. * Caches the the state of the stencil buffer
  28190. */
  28191. cacheStencilState(): void;
  28192. /**
  28193. * Restores the state of the stencil buffer
  28194. */
  28195. restoreStencilState(): void;
  28196. /**
  28197. * Sets the current depth function to LEQUAL
  28198. */
  28199. setDepthFunctionToLessOrEqual(): void;
  28200. /**
  28201. * Gets a boolean indicating if stencil buffer is enabled
  28202. * @returns the current stencil buffer state
  28203. */
  28204. getStencilBuffer(): boolean;
  28205. /**
  28206. * Enable or disable the stencil buffer
  28207. * @param enable defines if the stencil buffer must be enabled or disabled
  28208. */
  28209. setStencilBuffer(enable: boolean): void;
  28210. /**
  28211. * Gets the current stencil mask
  28212. * @returns a number defining the new stencil mask to use
  28213. */
  28214. getStencilMask(): number;
  28215. /**
  28216. * Sets the current stencil mask
  28217. * @param mask defines the new stencil mask to use
  28218. */
  28219. setStencilMask(mask: number): void;
  28220. /**
  28221. * Gets the current stencil function
  28222. * @returns a number defining the stencil function to use
  28223. */
  28224. getStencilFunction(): number;
  28225. /**
  28226. * Gets the current stencil reference value
  28227. * @returns a number defining the stencil reference value to use
  28228. */
  28229. getStencilFunctionReference(): number;
  28230. /**
  28231. * Gets the current stencil mask
  28232. * @returns a number defining the stencil mask to use
  28233. */
  28234. getStencilFunctionMask(): number;
  28235. /**
  28236. * Sets the current stencil function
  28237. * @param stencilFunc defines the new stencil function to use
  28238. */
  28239. setStencilFunction(stencilFunc: number): void;
  28240. /**
  28241. * Sets the current stencil reference
  28242. * @param reference defines the new stencil reference to use
  28243. */
  28244. setStencilFunctionReference(reference: number): void;
  28245. /**
  28246. * Sets the current stencil mask
  28247. * @param mask defines the new stencil mask to use
  28248. */
  28249. setStencilFunctionMask(mask: number): void;
  28250. /**
  28251. * Gets the current stencil operation when stencil fails
  28252. * @returns a number defining stencil operation to use when stencil fails
  28253. */
  28254. getStencilOperationFail(): number;
  28255. /**
  28256. * Gets the current stencil operation when depth fails
  28257. * @returns a number defining stencil operation to use when depth fails
  28258. */
  28259. getStencilOperationDepthFail(): number;
  28260. /**
  28261. * Gets the current stencil operation when stencil passes
  28262. * @returns a number defining stencil operation to use when stencil passes
  28263. */
  28264. getStencilOperationPass(): number;
  28265. /**
  28266. * Sets the stencil operation to use when stencil fails
  28267. * @param operation defines the stencil operation to use when stencil fails
  28268. */
  28269. setStencilOperationFail(operation: number): void;
  28270. /**
  28271. * Sets the stencil operation to use when depth fails
  28272. * @param operation defines the stencil operation to use when depth fails
  28273. */
  28274. setStencilOperationDepthFail(operation: number): void;
  28275. /**
  28276. * Sets the stencil operation to use when stencil passes
  28277. * @param operation defines the stencil operation to use when stencil passes
  28278. */
  28279. setStencilOperationPass(operation: number): void;
  28280. /**
  28281. * Sets a boolean indicating if the dithering state is enabled or disabled
  28282. * @param value defines the dithering state
  28283. */
  28284. setDitheringState(value: boolean): void;
  28285. /**
  28286. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28287. * @param value defines the rasterizer state
  28288. */
  28289. setRasterizerState(value: boolean): void;
  28290. /**
  28291. * stop executing a render loop function and remove it from the execution array
  28292. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28293. */
  28294. stopRenderLoop(renderFunction?: () => void): void;
  28295. /** @hidden */
  28296. _renderLoop(): void;
  28297. /**
  28298. * Register and execute a render loop. The engine can have more than one render function
  28299. * @param renderFunction defines the function to continuously execute
  28300. */
  28301. runRenderLoop(renderFunction: () => void): void;
  28302. /**
  28303. * Toggle full screen mode
  28304. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28305. */
  28306. switchFullscreen(requestPointerLock: boolean): void;
  28307. /**
  28308. * Enters full screen mode
  28309. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28310. */
  28311. enterFullscreen(requestPointerLock: boolean): void;
  28312. /**
  28313. * Exits full screen mode
  28314. */
  28315. exitFullscreen(): void;
  28316. /**
  28317. * Enters Pointerlock mode
  28318. */
  28319. enterPointerlock(): void;
  28320. /**
  28321. * Exits Pointerlock mode
  28322. */
  28323. exitPointerlock(): void;
  28324. /**
  28325. * Clear the current render buffer or the current render target (if any is set up)
  28326. * @param color defines the color to use
  28327. * @param backBuffer defines if the back buffer must be cleared
  28328. * @param depth defines if the depth buffer must be cleared
  28329. * @param stencil defines if the stencil buffer must be cleared
  28330. */
  28331. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28332. /**
  28333. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28334. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28335. * @param y defines the y-coordinate of the corner of the clear rectangle
  28336. * @param width defines the width of the clear rectangle
  28337. * @param height defines the height of the clear rectangle
  28338. * @param clearColor defines the clear color
  28339. */
  28340. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28341. /**
  28342. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28343. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28344. * @param y defines the y-coordinate of the corner of the clear rectangle
  28345. * @param width defines the width of the clear rectangle
  28346. * @param height defines the height of the clear rectangle
  28347. */
  28348. enableScissor(x: number, y: number, width: number, height: number): void;
  28349. /**
  28350. * Disable previously set scissor test rectangle
  28351. */
  28352. disableScissor(): void;
  28353. private _viewportCached;
  28354. /** @hidden */
  28355. _viewport(x: number, y: number, width: number, height: number): void;
  28356. /**
  28357. * Set the WebGL's viewport
  28358. * @param viewport defines the viewport element to be used
  28359. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28360. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28361. */
  28362. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28363. /**
  28364. * Directly set the WebGL Viewport
  28365. * @param x defines the x coordinate of the viewport (in screen space)
  28366. * @param y defines the y coordinate of the viewport (in screen space)
  28367. * @param width defines the width of the viewport (in screen space)
  28368. * @param height defines the height of the viewport (in screen space)
  28369. * @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
  28370. */
  28371. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28372. /**
  28373. * Begin a new frame
  28374. */
  28375. beginFrame(): void;
  28376. /**
  28377. * Enf the current frame
  28378. */
  28379. endFrame(): void;
  28380. /**
  28381. * Resize the view according to the canvas' size
  28382. */
  28383. resize(): void;
  28384. /**
  28385. * Force a specific size of the canvas
  28386. * @param width defines the new canvas' width
  28387. * @param height defines the new canvas' height
  28388. */
  28389. setSize(width: number, height: number): void;
  28390. /**
  28391. * Binds the frame buffer to the specified texture.
  28392. * @param texture The texture to render to or null for the default canvas
  28393. * @param faceIndex The face of the texture to render to in case of cube texture
  28394. * @param requiredWidth The width of the target to render to
  28395. * @param requiredHeight The height of the target to render to
  28396. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28397. * @param depthStencilTexture The depth stencil texture to use to render
  28398. * @param lodLevel defines le lod level to bind to the frame buffer
  28399. */
  28400. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28401. /** @hidden */
  28402. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28403. /**
  28404. * Unbind the current render target texture from the webGL context
  28405. * @param texture defines the render target texture to unbind
  28406. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28407. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28408. */
  28409. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28410. /**
  28411. * Force the mipmap generation for the given render target texture
  28412. * @param texture defines the render target texture to use
  28413. */
  28414. generateMipMapsForCubemap(texture: InternalTexture): void;
  28415. /**
  28416. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28417. */
  28418. flushFramebuffer(): void;
  28419. /**
  28420. * Unbind the current render target and bind the default framebuffer
  28421. */
  28422. restoreDefaultFramebuffer(): void;
  28423. /**
  28424. * Create an uniform buffer
  28425. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28426. * @param elements defines the content of the uniform buffer
  28427. * @returns the webGL uniform buffer
  28428. */
  28429. createUniformBuffer(elements: FloatArray): DataBuffer;
  28430. /**
  28431. * Create a dynamic uniform buffer
  28432. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28433. * @param elements defines the content of the uniform buffer
  28434. * @returns the webGL uniform buffer
  28435. */
  28436. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28437. /**
  28438. * Update an existing uniform buffer
  28439. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28440. * @param uniformBuffer defines the target uniform buffer
  28441. * @param elements defines the content to update
  28442. * @param offset defines the offset in the uniform buffer where update should start
  28443. * @param count defines the size of the data to update
  28444. */
  28445. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28446. private _resetVertexBufferBinding;
  28447. /**
  28448. * Creates a vertex buffer
  28449. * @param data the data for the vertex buffer
  28450. * @returns the new WebGL static buffer
  28451. */
  28452. createVertexBuffer(data: DataArray): DataBuffer;
  28453. /**
  28454. * Creates a dynamic vertex buffer
  28455. * @param data the data for the dynamic vertex buffer
  28456. * @returns the new WebGL dynamic buffer
  28457. */
  28458. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28459. /**
  28460. * Update a dynamic index buffer
  28461. * @param indexBuffer defines the target index buffer
  28462. * @param indices defines the data to update
  28463. * @param offset defines the offset in the target index buffer where update should start
  28464. */
  28465. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28466. /**
  28467. * Updates a dynamic vertex buffer.
  28468. * @param vertexBuffer the vertex buffer to update
  28469. * @param data the data used to update the vertex buffer
  28470. * @param byteOffset the byte offset of the data
  28471. * @param byteLength the byte length of the data
  28472. */
  28473. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28474. private _resetIndexBufferBinding;
  28475. /**
  28476. * Creates a new index buffer
  28477. * @param indices defines the content of the index buffer
  28478. * @param updatable defines if the index buffer must be updatable
  28479. * @returns a new webGL buffer
  28480. */
  28481. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28482. /**
  28483. * Bind a webGL buffer to the webGL context
  28484. * @param buffer defines the buffer to bind
  28485. */
  28486. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28487. /**
  28488. * Bind an uniform buffer to the current webGL context
  28489. * @param buffer defines the buffer to bind
  28490. */
  28491. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28492. /**
  28493. * Bind a buffer to the current webGL context at a given location
  28494. * @param buffer defines the buffer to bind
  28495. * @param location defines the index where to bind the buffer
  28496. */
  28497. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28498. /**
  28499. * Bind a specific block at a given index in a specific shader program
  28500. * @param pipelineContext defines the pipeline context to use
  28501. * @param blockName defines the block name
  28502. * @param index defines the index where to bind the block
  28503. */
  28504. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28505. private bindIndexBuffer;
  28506. private bindBuffer;
  28507. /**
  28508. * update the bound buffer with the given data
  28509. * @param data defines the data to update
  28510. */
  28511. updateArrayBuffer(data: Float32Array): void;
  28512. private _vertexAttribPointer;
  28513. private _bindIndexBufferWithCache;
  28514. private _bindVertexBuffersAttributes;
  28515. /**
  28516. * Records a vertex array object
  28517. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28518. * @param vertexBuffers defines the list of vertex buffers to store
  28519. * @param indexBuffer defines the index buffer to store
  28520. * @param effect defines the effect to store
  28521. * @returns the new vertex array object
  28522. */
  28523. recordVertexArrayObject(vertexBuffers: {
  28524. [key: string]: VertexBuffer;
  28525. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28526. /**
  28527. * Bind a specific vertex array object
  28528. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28529. * @param vertexArrayObject defines the vertex array object to bind
  28530. * @param indexBuffer defines the index buffer to bind
  28531. */
  28532. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28533. /**
  28534. * Bind webGl buffers directly to the webGL context
  28535. * @param vertexBuffer defines the vertex buffer to bind
  28536. * @param indexBuffer defines the index buffer to bind
  28537. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28538. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28539. * @param effect defines the effect associated with the vertex buffer
  28540. */
  28541. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28542. private _unbindVertexArrayObject;
  28543. /**
  28544. * Bind a list of vertex buffers to the webGL context
  28545. * @param vertexBuffers defines the list of vertex buffers to bind
  28546. * @param indexBuffer defines the index buffer to bind
  28547. * @param effect defines the effect associated with the vertex buffers
  28548. */
  28549. bindBuffers(vertexBuffers: {
  28550. [key: string]: Nullable<VertexBuffer>;
  28551. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28552. /**
  28553. * Unbind all instance attributes
  28554. */
  28555. unbindInstanceAttributes(): void;
  28556. /**
  28557. * Release and free the memory of a vertex array object
  28558. * @param vao defines the vertex array object to delete
  28559. */
  28560. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28561. /** @hidden */
  28562. _releaseBuffer(buffer: DataBuffer): boolean;
  28563. /**
  28564. * Creates a webGL buffer to use with instanciation
  28565. * @param capacity defines the size of the buffer
  28566. * @returns the webGL buffer
  28567. */
  28568. createInstancesBuffer(capacity: number): DataBuffer;
  28569. /**
  28570. * Delete a webGL buffer used with instanciation
  28571. * @param buffer defines the webGL buffer to delete
  28572. */
  28573. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28574. /**
  28575. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28576. * @param instancesBuffer defines the webGL buffer to update and bind
  28577. * @param data defines the data to store in the buffer
  28578. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28579. */
  28580. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28581. /**
  28582. * Apply all cached states (depth, culling, stencil and alpha)
  28583. */
  28584. applyStates(): void;
  28585. /**
  28586. * Send a draw order
  28587. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28588. * @param indexStart defines the starting index
  28589. * @param indexCount defines the number of index to draw
  28590. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28591. */
  28592. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28593. /**
  28594. * Draw a list of points
  28595. * @param verticesStart defines the index of first vertex to draw
  28596. * @param verticesCount defines the count of vertices to draw
  28597. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28598. */
  28599. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28600. /**
  28601. * Draw a list of unindexed primitives
  28602. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28603. * @param verticesStart defines the index of first vertex to draw
  28604. * @param verticesCount defines the count of vertices to draw
  28605. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28606. */
  28607. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28608. /**
  28609. * Draw a list of indexed primitives
  28610. * @param fillMode defines the primitive to use
  28611. * @param indexStart defines the starting index
  28612. * @param indexCount defines the number of index to draw
  28613. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28614. */
  28615. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28616. /**
  28617. * Draw a list of unindexed primitives
  28618. * @param fillMode defines the primitive to use
  28619. * @param verticesStart defines the index of first vertex to draw
  28620. * @param verticesCount defines the count of vertices to draw
  28621. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28622. */
  28623. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28624. private _drawMode;
  28625. /** @hidden */
  28626. _releaseEffect(effect: Effect): void;
  28627. /** @hidden */
  28628. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28629. /**
  28630. * Create a new effect (used to store vertex/fragment shaders)
  28631. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28632. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28633. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28634. * @param samplers defines an array of string used to represent textures
  28635. * @param defines defines the string containing the defines to use to compile the shaders
  28636. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28637. * @param onCompiled defines a function to call when the effect creation is successful
  28638. * @param onError defines a function to call when the effect creation has failed
  28639. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28640. * @returns the new Effect
  28641. */
  28642. 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;
  28643. private _compileShader;
  28644. private _compileRawShader;
  28645. /**
  28646. * Directly creates a webGL program
  28647. * @param pipelineContext defines the pipeline context to attach to
  28648. * @param vertexCode defines the vertex shader code to use
  28649. * @param fragmentCode defines the fragment shader code to use
  28650. * @param context defines the webGL context to use (if not set, the current one will be used)
  28651. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28652. * @returns the new webGL program
  28653. */
  28654. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28655. /**
  28656. * Creates a webGL program
  28657. * @param pipelineContext defines the pipeline context to attach to
  28658. * @param vertexCode defines the vertex shader code to use
  28659. * @param fragmentCode defines the fragment shader code to use
  28660. * @param defines defines the string containing the defines to use to compile the shaders
  28661. * @param context defines the webGL context to use (if not set, the current one will be used)
  28662. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28663. * @returns the new webGL program
  28664. */
  28665. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28666. /**
  28667. * Creates a new pipeline context
  28668. * @returns the new pipeline
  28669. */
  28670. createPipelineContext(): WebGLPipelineContext;
  28671. private _createShaderProgram;
  28672. private _finalizePipelineContext;
  28673. /** @hidden */
  28674. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28675. /** @hidden */
  28676. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28677. /** @hidden */
  28678. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28679. /**
  28680. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28681. * @param pipelineContext defines the pipeline context to use
  28682. * @param uniformsNames defines the list of uniform names
  28683. * @returns an array of webGL uniform locations
  28684. */
  28685. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28686. /**
  28687. * Gets the lsit of active attributes for a given webGL program
  28688. * @param pipelineContext defines the pipeline context to use
  28689. * @param attributesNames defines the list of attribute names to get
  28690. * @returns an array of indices indicating the offset of each attribute
  28691. */
  28692. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28693. /**
  28694. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28695. * @param effect defines the effect to activate
  28696. */
  28697. enableEffect(effect: Nullable<Effect>): void;
  28698. /**
  28699. * Set the value of an uniform to an array of int32
  28700. * @param uniform defines the webGL uniform location where to store the value
  28701. * @param array defines the array of int32 to store
  28702. */
  28703. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28704. /**
  28705. * Set the value of an uniform to an array of int32 (stored as vec2)
  28706. * @param uniform defines the webGL uniform location where to store the value
  28707. * @param array defines the array of int32 to store
  28708. */
  28709. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28710. /**
  28711. * Set the value of an uniform to an array of int32 (stored as vec3)
  28712. * @param uniform defines the webGL uniform location where to store the value
  28713. * @param array defines the array of int32 to store
  28714. */
  28715. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28716. /**
  28717. * Set the value of an uniform to an array of int32 (stored as vec4)
  28718. * @param uniform defines the webGL uniform location where to store the value
  28719. * @param array defines the array of int32 to store
  28720. */
  28721. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28722. /**
  28723. * Set the value of an uniform to an array of float32
  28724. * @param uniform defines the webGL uniform location where to store the value
  28725. * @param array defines the array of float32 to store
  28726. */
  28727. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28728. /**
  28729. * Set the value of an uniform to an array of float32 (stored as vec2)
  28730. * @param uniform defines the webGL uniform location where to store the value
  28731. * @param array defines the array of float32 to store
  28732. */
  28733. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28734. /**
  28735. * Set the value of an uniform to an array of float32 (stored as vec3)
  28736. * @param uniform defines the webGL uniform location where to store the value
  28737. * @param array defines the array of float32 to store
  28738. */
  28739. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28740. /**
  28741. * Set the value of an uniform to an array of float32 (stored as vec4)
  28742. * @param uniform defines the webGL uniform location where to store the value
  28743. * @param array defines the array of float32 to store
  28744. */
  28745. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28746. /**
  28747. * Set the value of an uniform to an array of number
  28748. * @param uniform defines the webGL uniform location where to store the value
  28749. * @param array defines the array of number to store
  28750. */
  28751. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28752. /**
  28753. * Set the value of an uniform to an array of number (stored as vec2)
  28754. * @param uniform defines the webGL uniform location where to store the value
  28755. * @param array defines the array of number to store
  28756. */
  28757. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28758. /**
  28759. * Set the value of an uniform to an array of number (stored as vec3)
  28760. * @param uniform defines the webGL uniform location where to store the value
  28761. * @param array defines the array of number to store
  28762. */
  28763. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28764. /**
  28765. * Set the value of an uniform to an array of number (stored as vec4)
  28766. * @param uniform defines the webGL uniform location where to store the value
  28767. * @param array defines the array of number to store
  28768. */
  28769. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28770. /**
  28771. * Set the value of an uniform to an array of float32 (stored as matrices)
  28772. * @param uniform defines the webGL uniform location where to store the value
  28773. * @param matrices defines the array of float32 to store
  28774. */
  28775. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28776. /**
  28777. * Set the value of an uniform to a matrix
  28778. * @param uniform defines the webGL uniform location where to store the value
  28779. * @param matrix defines the matrix to store
  28780. */
  28781. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28782. /**
  28783. * Set the value of an uniform to a matrix (3x3)
  28784. * @param uniform defines the webGL uniform location where to store the value
  28785. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28786. */
  28787. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28788. /**
  28789. * Set the value of an uniform to a matrix (2x2)
  28790. * @param uniform defines the webGL uniform location where to store the value
  28791. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28792. */
  28793. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28794. /**
  28795. * Set the value of an uniform to a number (int)
  28796. * @param uniform defines the webGL uniform location where to store the value
  28797. * @param value defines the int number to store
  28798. */
  28799. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28800. /**
  28801. * Set the value of an uniform to a number (float)
  28802. * @param uniform defines the webGL uniform location where to store the value
  28803. * @param value defines the float number to store
  28804. */
  28805. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28806. /**
  28807. * Set the value of an uniform to a vec2
  28808. * @param uniform defines the webGL uniform location where to store the value
  28809. * @param x defines the 1st component of the value
  28810. * @param y defines the 2nd component of the value
  28811. */
  28812. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28813. /**
  28814. * Set the value of an uniform to a vec3
  28815. * @param uniform defines the webGL uniform location where to store the value
  28816. * @param x defines the 1st component of the value
  28817. * @param y defines the 2nd component of the value
  28818. * @param z defines the 3rd component of the value
  28819. */
  28820. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28821. /**
  28822. * Set the value of an uniform to a boolean
  28823. * @param uniform defines the webGL uniform location where to store the value
  28824. * @param bool defines the boolean to store
  28825. */
  28826. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28827. /**
  28828. * Set the value of an uniform to a vec4
  28829. * @param uniform defines the webGL uniform location where to store the value
  28830. * @param x defines the 1st component of the value
  28831. * @param y defines the 2nd component of the value
  28832. * @param z defines the 3rd component of the value
  28833. * @param w defines the 4th component of the value
  28834. */
  28835. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28836. /**
  28837. * Set the value of an uniform to a Color3
  28838. * @param uniform defines the webGL uniform location where to store the value
  28839. * @param color3 defines the color to store
  28840. */
  28841. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28842. /**
  28843. * Set the value of an uniform to a Color3 and an alpha value
  28844. * @param uniform defines the webGL uniform location where to store the value
  28845. * @param color3 defines the color to store
  28846. * @param alpha defines the alpha component to store
  28847. */
  28848. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28849. /**
  28850. * Sets a Color4 on a uniform variable
  28851. * @param uniform defines the uniform location
  28852. * @param color4 defines the value to be set
  28853. */
  28854. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28855. /**
  28856. * Set various states to the webGL context
  28857. * @param culling defines backface culling state
  28858. * @param zOffset defines the value to apply to zOffset (0 by default)
  28859. * @param force defines if states must be applied even if cache is up to date
  28860. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28861. */
  28862. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28863. /**
  28864. * Set the z offset to apply to current rendering
  28865. * @param value defines the offset to apply
  28866. */
  28867. setZOffset(value: number): void;
  28868. /**
  28869. * Gets the current value of the zOffset
  28870. * @returns the current zOffset state
  28871. */
  28872. getZOffset(): number;
  28873. /**
  28874. * Enable or disable depth buffering
  28875. * @param enable defines the state to set
  28876. */
  28877. setDepthBuffer(enable: boolean): void;
  28878. /**
  28879. * Gets a boolean indicating if depth writing is enabled
  28880. * @returns the current depth writing state
  28881. */
  28882. getDepthWrite(): boolean;
  28883. /**
  28884. * Enable or disable depth writing
  28885. * @param enable defines the state to set
  28886. */
  28887. setDepthWrite(enable: boolean): void;
  28888. /**
  28889. * Enable or disable color writing
  28890. * @param enable defines the state to set
  28891. */
  28892. setColorWrite(enable: boolean): void;
  28893. /**
  28894. * Gets a boolean indicating if color writing is enabled
  28895. * @returns the current color writing state
  28896. */
  28897. getColorWrite(): boolean;
  28898. /**
  28899. * Sets alpha constants used by some alpha blending modes
  28900. * @param r defines the red component
  28901. * @param g defines the green component
  28902. * @param b defines the blue component
  28903. * @param a defines the alpha component
  28904. */
  28905. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28906. /**
  28907. * Sets the current alpha mode
  28908. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28909. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28910. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28911. */
  28912. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28913. /**
  28914. * Gets the current alpha mode
  28915. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28916. * @returns the current alpha mode
  28917. */
  28918. getAlphaMode(): number;
  28919. /**
  28920. * Clears the list of texture accessible through engine.
  28921. * This can help preventing texture load conflict due to name collision.
  28922. */
  28923. clearInternalTexturesCache(): void;
  28924. /**
  28925. * Force the entire cache to be cleared
  28926. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28927. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28928. */
  28929. wipeCaches(bruteForce?: boolean): void;
  28930. /**
  28931. * Set the compressed texture format to use, based on the formats you have, and the formats
  28932. * supported by the hardware / browser.
  28933. *
  28934. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28935. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28936. * to API arguments needed to compressed textures. This puts the burden on the container
  28937. * generator to house the arcane code for determining these for current & future formats.
  28938. *
  28939. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28940. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28941. *
  28942. * Note: The result of this call is not taken into account when a texture is base64.
  28943. *
  28944. * @param formatsAvailable defines the list of those format families you have created
  28945. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28946. *
  28947. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28948. * @returns The extension selected.
  28949. */
  28950. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28951. /** @hidden */
  28952. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28953. min: number;
  28954. mag: number;
  28955. };
  28956. /** @hidden */
  28957. _createTexture(): WebGLTexture;
  28958. /**
  28959. * Usually called from Texture.ts.
  28960. * Passed information to create a WebGLTexture
  28961. * @param urlArg defines a value which contains one of the following:
  28962. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28963. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28964. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28965. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28966. * @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)
  28967. * @param scene needed for loading to the correct scene
  28968. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28969. * @param onLoad optional callback to be called upon successful completion
  28970. * @param onError optional callback to be called upon failure
  28971. * @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
  28972. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28973. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28974. * @param forcedExtension defines the extension to use to pick the right loader
  28975. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28976. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28977. */
  28978. 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;
  28979. /**
  28980. * @hidden
  28981. * Rescales a texture
  28982. * @param source input texutre
  28983. * @param destination destination texture
  28984. * @param scene scene to use to render the resize
  28985. * @param internalFormat format to use when resizing
  28986. * @param onComplete callback to be called when resize has completed
  28987. */
  28988. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  28989. private _unpackFlipYCached;
  28990. /**
  28991. * In case you are sharing the context with other applications, it might
  28992. * be interested to not cache the unpack flip y state to ensure a consistent
  28993. * value would be set.
  28994. */
  28995. enableUnpackFlipYCached: boolean;
  28996. /** @hidden */
  28997. _unpackFlipY(value: boolean): void;
  28998. /** @hidden */
  28999. _getUnpackAlignement(): number;
  29000. /**
  29001. * Creates a dynamic texture
  29002. * @param width defines the width of the texture
  29003. * @param height defines the height of the texture
  29004. * @param generateMipMaps defines if the engine should generate the mip levels
  29005. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29006. * @returns the dynamic texture inside an InternalTexture
  29007. */
  29008. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29009. /**
  29010. * Update the sampling mode of a given texture
  29011. * @param samplingMode defines the required sampling mode
  29012. * @param texture defines the texture to update
  29013. */
  29014. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29015. /**
  29016. * Update the content of a dynamic texture
  29017. * @param texture defines the texture to update
  29018. * @param canvas defines the canvas containing the source
  29019. * @param invertY defines if data must be stored with Y axis inverted
  29020. * @param premulAlpha defines if alpha is stored as premultiplied
  29021. * @param format defines the format of the data
  29022. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29023. */
  29024. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29025. /**
  29026. * Update a video texture
  29027. * @param texture defines the texture to update
  29028. * @param video defines the video element to use
  29029. * @param invertY defines if data must be stored with Y axis inverted
  29030. */
  29031. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29032. /**
  29033. * Updates a depth texture Comparison Mode and Function.
  29034. * If the comparison Function is equal to 0, the mode will be set to none.
  29035. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29036. * @param texture The texture to set the comparison function for
  29037. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29038. */
  29039. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29040. /** @hidden */
  29041. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29042. width: number;
  29043. height: number;
  29044. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29045. /**
  29046. * Creates a depth stencil texture.
  29047. * This is only available in WebGL 2 or with the depth texture extension available.
  29048. * @param size The size of face edge in the texture.
  29049. * @param options The options defining the texture.
  29050. * @returns The texture
  29051. */
  29052. createDepthStencilTexture(size: number | {
  29053. width: number;
  29054. height: number;
  29055. }, options: DepthTextureCreationOptions): InternalTexture;
  29056. /**
  29057. * Creates a depth stencil texture.
  29058. * This is only available in WebGL 2 or with the depth texture extension available.
  29059. * @param size The size of face edge in the texture.
  29060. * @param options The options defining the texture.
  29061. * @returns The texture
  29062. */
  29063. private _createDepthStencilTexture;
  29064. /**
  29065. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29066. * @param renderTarget The render target to set the frame buffer for
  29067. */
  29068. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29069. /**
  29070. * Creates a new render target texture
  29071. * @param size defines the size of the texture
  29072. * @param options defines the options used to create the texture
  29073. * @returns a new render target texture stored in an InternalTexture
  29074. */
  29075. createRenderTargetTexture(size: number | {
  29076. width: number;
  29077. height: number;
  29078. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29079. /** @hidden */
  29080. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29081. /**
  29082. * Updates the sample count of a render target texture
  29083. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29084. * @param texture defines the texture to update
  29085. * @param samples defines the sample count to set
  29086. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29087. */
  29088. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29089. /** @hidden */
  29090. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29091. /** @hidden */
  29092. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29093. /** @hidden */
  29094. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29095. /** @hidden */
  29096. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29097. /**
  29098. * @hidden
  29099. */
  29100. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29101. private _prepareWebGLTextureContinuation;
  29102. private _prepareWebGLTexture;
  29103. /** @hidden */
  29104. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29105. /** @hidden */
  29106. _releaseFramebufferObjects(texture: InternalTexture): void;
  29107. /** @hidden */
  29108. _releaseTexture(texture: InternalTexture): void;
  29109. private setProgram;
  29110. private _boundUniforms;
  29111. /**
  29112. * Binds an effect to the webGL context
  29113. * @param effect defines the effect to bind
  29114. */
  29115. bindSamplers(effect: Effect): void;
  29116. private _activateCurrentTexture;
  29117. /** @hidden */
  29118. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29119. /** @hidden */
  29120. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29121. /**
  29122. * Sets a texture to the webGL context from a postprocess
  29123. * @param channel defines the channel to use
  29124. * @param postProcess defines the source postprocess
  29125. */
  29126. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29127. /**
  29128. * Binds the output of the passed in post process to the texture channel specified
  29129. * @param channel The channel the texture should be bound to
  29130. * @param postProcess The post process which's output should be bound
  29131. */
  29132. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29133. /**
  29134. * Unbind all textures from the webGL context
  29135. */
  29136. unbindAllTextures(): void;
  29137. /**
  29138. * Sets a texture to the according uniform.
  29139. * @param channel The texture channel
  29140. * @param uniform The uniform to set
  29141. * @param texture The texture to apply
  29142. */
  29143. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29144. /**
  29145. * Sets a depth stencil texture from a render target to the according uniform.
  29146. * @param channel The texture channel
  29147. * @param uniform The uniform to set
  29148. * @param texture The render target texture containing the depth stencil texture to apply
  29149. */
  29150. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29151. private _bindSamplerUniformToChannel;
  29152. private _getTextureWrapMode;
  29153. private _setTexture;
  29154. /**
  29155. * Sets an array of texture to the webGL context
  29156. * @param channel defines the channel where the texture array must be set
  29157. * @param uniform defines the associated uniform location
  29158. * @param textures defines the array of textures to bind
  29159. */
  29160. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29161. /** @hidden */
  29162. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29163. private _setTextureParameterFloat;
  29164. private _setTextureParameterInteger;
  29165. /**
  29166. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29167. * @param x defines the x coordinate of the rectangle where pixels must be read
  29168. * @param y defines the y coordinate of the rectangle where pixels must be read
  29169. * @param width defines the width of the rectangle where pixels must be read
  29170. * @param height defines the height of the rectangle where pixels must be read
  29171. * @returns a Uint8Array containing RGBA colors
  29172. */
  29173. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29174. /**
  29175. * Add an externaly attached data from its key.
  29176. * This method call will fail and return false, if such key already exists.
  29177. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29178. * @param key the unique key that identifies the data
  29179. * @param data the data object to associate to the key for this Engine instance
  29180. * @return true if no such key were already present and the data was added successfully, false otherwise
  29181. */
  29182. addExternalData<T>(key: string, data: T): boolean;
  29183. /**
  29184. * Get an externaly attached data from its key
  29185. * @param key the unique key that identifies the data
  29186. * @return the associated data, if present (can be null), or undefined if not present
  29187. */
  29188. getExternalData<T>(key: string): T;
  29189. /**
  29190. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29191. * @param key the unique key that identifies the data
  29192. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29193. * @return the associated data, can be null if the factory returned null.
  29194. */
  29195. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29196. /**
  29197. * Remove an externaly attached data from the Engine instance
  29198. * @param key the unique key that identifies the data
  29199. * @return true if the data was successfully removed, false if it doesn't exist
  29200. */
  29201. removeExternalData(key: string): boolean;
  29202. /**
  29203. * Unbind all vertex attributes from the webGL context
  29204. */
  29205. unbindAllAttributes(): void;
  29206. /**
  29207. * 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
  29208. */
  29209. releaseEffects(): void;
  29210. /**
  29211. * Dispose and release all associated resources
  29212. */
  29213. dispose(): void;
  29214. /**
  29215. * Display the loading screen
  29216. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29217. */
  29218. displayLoadingUI(): void;
  29219. /**
  29220. * Hide the loading screen
  29221. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29222. */
  29223. hideLoadingUI(): void;
  29224. /**
  29225. * Gets the current loading screen object
  29226. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29227. */
  29228. /**
  29229. * Sets the current loading screen object
  29230. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29231. */
  29232. loadingScreen: ILoadingScreen;
  29233. /**
  29234. * Sets the current loading screen text
  29235. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29236. */
  29237. loadingUIText: string;
  29238. /**
  29239. * Sets the current loading screen background color
  29240. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29241. */
  29242. loadingUIBackgroundColor: string;
  29243. /**
  29244. * Attach a new callback raised when context lost event is fired
  29245. * @param callback defines the callback to call
  29246. */
  29247. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29248. /**
  29249. * Attach a new callback raised when context restored event is fired
  29250. * @param callback defines the callback to call
  29251. */
  29252. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29253. /**
  29254. * Gets the source code of the vertex shader associated with a specific webGL program
  29255. * @param program defines the program to use
  29256. * @returns a string containing the source code of the vertex shader associated with the program
  29257. */
  29258. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29259. /**
  29260. * Gets the source code of the fragment shader associated with a specific webGL program
  29261. * @param program defines the program to use
  29262. * @returns a string containing the source code of the fragment shader associated with the program
  29263. */
  29264. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29265. /**
  29266. * Get the current error code of the webGL context
  29267. * @returns the error code
  29268. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29269. */
  29270. getError(): number;
  29271. /**
  29272. * Gets the current framerate
  29273. * @returns a number representing the framerate
  29274. */
  29275. getFps(): number;
  29276. /**
  29277. * Gets the time spent between current and previous frame
  29278. * @returns a number representing the delta time in ms
  29279. */
  29280. getDeltaTime(): number;
  29281. private _measureFps;
  29282. /** @hidden */
  29283. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29284. private _canRenderToFloatFramebuffer;
  29285. private _canRenderToHalfFloatFramebuffer;
  29286. private _canRenderToFramebuffer;
  29287. /** @hidden */
  29288. _getWebGLTextureType(type: number): number;
  29289. /** @hidden */
  29290. _getInternalFormat(format: number): number;
  29291. /** @hidden */
  29292. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29293. /** @hidden */
  29294. _getRGBAMultiSampleBufferFormat(type: number): number;
  29295. /** @hidden */
  29296. _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;
  29297. /** @hidden */
  29298. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29299. /**
  29300. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29301. * @returns true if the engine can be created
  29302. * @ignorenaming
  29303. */
  29304. static isSupported(): boolean;
  29305. }
  29306. }
  29307. declare module BABYLON {
  29308. /**
  29309. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29310. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29311. */
  29312. export class EffectFallbacks {
  29313. private _defines;
  29314. private _currentRank;
  29315. private _maxRank;
  29316. private _mesh;
  29317. /**
  29318. * Removes the fallback from the bound mesh.
  29319. */
  29320. unBindMesh(): void;
  29321. /**
  29322. * Adds a fallback on the specified property.
  29323. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29324. * @param define The name of the define in the shader
  29325. */
  29326. addFallback(rank: number, define: string): void;
  29327. /**
  29328. * Sets the mesh to use CPU skinning when needing to fallback.
  29329. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29330. * @param mesh The mesh to use the fallbacks.
  29331. */
  29332. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29333. /**
  29334. * Checks to see if more fallbacks are still availible.
  29335. */
  29336. readonly isMoreFallbacks: boolean;
  29337. /**
  29338. * Removes the defines that should be removed when falling back.
  29339. * @param currentDefines defines the current define statements for the shader.
  29340. * @param effect defines the current effect we try to compile
  29341. * @returns The resulting defines with defines of the current rank removed.
  29342. */
  29343. reduce(currentDefines: string, effect: Effect): string;
  29344. }
  29345. /**
  29346. * Options to be used when creating an effect.
  29347. */
  29348. export class EffectCreationOptions {
  29349. /**
  29350. * Atrributes that will be used in the shader.
  29351. */
  29352. attributes: string[];
  29353. /**
  29354. * Uniform varible names that will be set in the shader.
  29355. */
  29356. uniformsNames: string[];
  29357. /**
  29358. * Uniform buffer varible names that will be set in the shader.
  29359. */
  29360. uniformBuffersNames: string[];
  29361. /**
  29362. * Sampler texture variable names that will be set in the shader.
  29363. */
  29364. samplers: string[];
  29365. /**
  29366. * Define statements that will be set in the shader.
  29367. */
  29368. defines: any;
  29369. /**
  29370. * Possible fallbacks for this effect to improve performance when needed.
  29371. */
  29372. fallbacks: Nullable<EffectFallbacks>;
  29373. /**
  29374. * Callback that will be called when the shader is compiled.
  29375. */
  29376. onCompiled: Nullable<(effect: Effect) => void>;
  29377. /**
  29378. * Callback that will be called if an error occurs during shader compilation.
  29379. */
  29380. onError: Nullable<(effect: Effect, errors: string) => void>;
  29381. /**
  29382. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29383. */
  29384. indexParameters: any;
  29385. /**
  29386. * Max number of lights that can be used in the shader.
  29387. */
  29388. maxSimultaneousLights: number;
  29389. /**
  29390. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29391. */
  29392. transformFeedbackVaryings: Nullable<string[]>;
  29393. }
  29394. /**
  29395. * Effect containing vertex and fragment shader that can be executed on an object.
  29396. */
  29397. export class Effect implements IDisposable {
  29398. /**
  29399. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29400. */
  29401. static ShadersRepository: string;
  29402. /**
  29403. * Name of the effect.
  29404. */
  29405. name: any;
  29406. /**
  29407. * String container all the define statements that should be set on the shader.
  29408. */
  29409. defines: string;
  29410. /**
  29411. * Callback that will be called when the shader is compiled.
  29412. */
  29413. onCompiled: Nullable<(effect: Effect) => void>;
  29414. /**
  29415. * Callback that will be called if an error occurs during shader compilation.
  29416. */
  29417. onError: Nullable<(effect: Effect, errors: string) => void>;
  29418. /**
  29419. * Callback that will be called when effect is bound.
  29420. */
  29421. onBind: Nullable<(effect: Effect) => void>;
  29422. /**
  29423. * Unique ID of the effect.
  29424. */
  29425. uniqueId: number;
  29426. /**
  29427. * Observable that will be called when the shader is compiled.
  29428. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29429. */
  29430. onCompileObservable: Observable<Effect>;
  29431. /**
  29432. * Observable that will be called if an error occurs during shader compilation.
  29433. */
  29434. onErrorObservable: Observable<Effect>;
  29435. /** @hidden */
  29436. _onBindObservable: Nullable<Observable<Effect>>;
  29437. /**
  29438. * Observable that will be called when effect is bound.
  29439. */
  29440. readonly onBindObservable: Observable<Effect>;
  29441. /** @hidden */
  29442. _bonesComputationForcedToCPU: boolean;
  29443. private static _uniqueIdSeed;
  29444. private _engine;
  29445. private _uniformBuffersNames;
  29446. private _uniformsNames;
  29447. private _samplerList;
  29448. private _samplers;
  29449. private _isReady;
  29450. private _compilationError;
  29451. private _attributesNames;
  29452. private _attributes;
  29453. private _uniforms;
  29454. /**
  29455. * Key for the effect.
  29456. * @hidden
  29457. */
  29458. _key: string;
  29459. private _indexParameters;
  29460. private _fallbacks;
  29461. private _vertexSourceCode;
  29462. private _fragmentSourceCode;
  29463. private _vertexSourceCodeOverride;
  29464. private _fragmentSourceCodeOverride;
  29465. private _transformFeedbackVaryings;
  29466. /**
  29467. * Compiled shader to webGL program.
  29468. * @hidden
  29469. */
  29470. _pipelineContext: Nullable<IPipelineContext>;
  29471. private _valueCache;
  29472. private static _baseCache;
  29473. /**
  29474. * Instantiates an effect.
  29475. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29476. * @param baseName Name of the effect.
  29477. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29478. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29479. * @param samplers List of sampler variables that will be passed to the shader.
  29480. * @param engine Engine to be used to render the effect
  29481. * @param defines Define statements to be added to the shader.
  29482. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29483. * @param onCompiled Callback that will be called when the shader is compiled.
  29484. * @param onError Callback that will be called if an error occurs during shader compilation.
  29485. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29486. */
  29487. 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);
  29488. private _useFinalCode;
  29489. /**
  29490. * Unique key for this effect
  29491. */
  29492. readonly key: string;
  29493. /**
  29494. * If the effect has been compiled and prepared.
  29495. * @returns if the effect is compiled and prepared.
  29496. */
  29497. isReady(): boolean;
  29498. /**
  29499. * The engine the effect was initialized with.
  29500. * @returns the engine.
  29501. */
  29502. getEngine(): Engine;
  29503. /**
  29504. * The pipeline context for this effect
  29505. * @returns the associated pipeline context
  29506. */
  29507. getPipelineContext(): Nullable<IPipelineContext>;
  29508. /**
  29509. * The set of names of attribute variables for the shader.
  29510. * @returns An array of attribute names.
  29511. */
  29512. getAttributesNames(): string[];
  29513. /**
  29514. * Returns the attribute at the given index.
  29515. * @param index The index of the attribute.
  29516. * @returns The location of the attribute.
  29517. */
  29518. getAttributeLocation(index: number): number;
  29519. /**
  29520. * Returns the attribute based on the name of the variable.
  29521. * @param name of the attribute to look up.
  29522. * @returns the attribute location.
  29523. */
  29524. getAttributeLocationByName(name: string): number;
  29525. /**
  29526. * The number of attributes.
  29527. * @returns the numnber of attributes.
  29528. */
  29529. getAttributesCount(): number;
  29530. /**
  29531. * Gets the index of a uniform variable.
  29532. * @param uniformName of the uniform to look up.
  29533. * @returns the index.
  29534. */
  29535. getUniformIndex(uniformName: string): number;
  29536. /**
  29537. * Returns the attribute based on the name of the variable.
  29538. * @param uniformName of the uniform to look up.
  29539. * @returns the location of the uniform.
  29540. */
  29541. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29542. /**
  29543. * Returns an array of sampler variable names
  29544. * @returns The array of sampler variable neames.
  29545. */
  29546. getSamplers(): string[];
  29547. /**
  29548. * The error from the last compilation.
  29549. * @returns the error string.
  29550. */
  29551. getCompilationError(): string;
  29552. /**
  29553. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29554. * @param func The callback to be used.
  29555. */
  29556. executeWhenCompiled(func: (effect: Effect) => void): void;
  29557. private _checkIsReady;
  29558. /** @hidden */
  29559. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29560. /** @hidden */
  29561. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29562. /** @hidden */
  29563. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29564. /**
  29565. * Recompiles the webGL program
  29566. * @param vertexSourceCode The source code for the vertex shader.
  29567. * @param fragmentSourceCode The source code for the fragment shader.
  29568. * @param onCompiled Callback called when completed.
  29569. * @param onError Callback called on error.
  29570. * @hidden
  29571. */
  29572. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29573. /**
  29574. * Prepares the effect
  29575. * @hidden
  29576. */
  29577. _prepareEffect(): void;
  29578. /**
  29579. * Checks if the effect is supported. (Must be called after compilation)
  29580. */
  29581. readonly isSupported: boolean;
  29582. /**
  29583. * Binds a texture to the engine to be used as output of the shader.
  29584. * @param channel Name of the output variable.
  29585. * @param texture Texture to bind.
  29586. * @hidden
  29587. */
  29588. _bindTexture(channel: string, texture: InternalTexture): void;
  29589. /**
  29590. * Sets a texture on the engine to be used in the shader.
  29591. * @param channel Name of the sampler variable.
  29592. * @param texture Texture to set.
  29593. */
  29594. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29595. /**
  29596. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29597. * @param channel Name of the sampler variable.
  29598. * @param texture Texture to set.
  29599. */
  29600. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29601. /**
  29602. * Sets an array of textures on the engine to be used in the shader.
  29603. * @param channel Name of the variable.
  29604. * @param textures Textures to set.
  29605. */
  29606. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29607. /**
  29608. * 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)
  29609. * @param channel Name of the sampler variable.
  29610. * @param postProcess Post process to get the input texture from.
  29611. */
  29612. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29613. /**
  29614. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29615. * 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)
  29616. * @param channel Name of the sampler variable.
  29617. * @param postProcess Post process to get the output texture from.
  29618. */
  29619. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29620. /** @hidden */
  29621. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29622. /** @hidden */
  29623. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29624. /** @hidden */
  29625. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29626. /** @hidden */
  29627. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29628. /**
  29629. * Binds a buffer to a uniform.
  29630. * @param buffer Buffer to bind.
  29631. * @param name Name of the uniform variable to bind to.
  29632. */
  29633. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29634. /**
  29635. * Binds block to a uniform.
  29636. * @param blockName Name of the block to bind.
  29637. * @param index Index to bind.
  29638. */
  29639. bindUniformBlock(blockName: string, index: number): void;
  29640. /**
  29641. * Sets an interger value on a uniform variable.
  29642. * @param uniformName Name of the variable.
  29643. * @param value Value to be set.
  29644. * @returns this effect.
  29645. */
  29646. setInt(uniformName: string, value: number): Effect;
  29647. /**
  29648. * Sets an int array on a uniform variable.
  29649. * @param uniformName Name of the variable.
  29650. * @param array array to be set.
  29651. * @returns this effect.
  29652. */
  29653. setIntArray(uniformName: string, array: Int32Array): Effect;
  29654. /**
  29655. * 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)
  29656. * @param uniformName Name of the variable.
  29657. * @param array array to be set.
  29658. * @returns this effect.
  29659. */
  29660. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29661. /**
  29662. * 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)
  29663. * @param uniformName Name of the variable.
  29664. * @param array array to be set.
  29665. * @returns this effect.
  29666. */
  29667. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29668. /**
  29669. * 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)
  29670. * @param uniformName Name of the variable.
  29671. * @param array array to be set.
  29672. * @returns this effect.
  29673. */
  29674. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29675. /**
  29676. * Sets an float array on a uniform variable.
  29677. * @param uniformName Name of the variable.
  29678. * @param array array to be set.
  29679. * @returns this effect.
  29680. */
  29681. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29682. /**
  29683. * 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)
  29684. * @param uniformName Name of the variable.
  29685. * @param array array to be set.
  29686. * @returns this effect.
  29687. */
  29688. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29689. /**
  29690. * 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)
  29691. * @param uniformName Name of the variable.
  29692. * @param array array to be set.
  29693. * @returns this effect.
  29694. */
  29695. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29696. /**
  29697. * 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)
  29698. * @param uniformName Name of the variable.
  29699. * @param array array to be set.
  29700. * @returns this effect.
  29701. */
  29702. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29703. /**
  29704. * Sets an array on a uniform variable.
  29705. * @param uniformName Name of the variable.
  29706. * @param array array to be set.
  29707. * @returns this effect.
  29708. */
  29709. setArray(uniformName: string, array: number[]): Effect;
  29710. /**
  29711. * 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)
  29712. * @param uniformName Name of the variable.
  29713. * @param array array to be set.
  29714. * @returns this effect.
  29715. */
  29716. setArray2(uniformName: string, array: number[]): Effect;
  29717. /**
  29718. * 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)
  29719. * @param uniformName Name of the variable.
  29720. * @param array array to be set.
  29721. * @returns this effect.
  29722. */
  29723. setArray3(uniformName: string, array: number[]): Effect;
  29724. /**
  29725. * 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)
  29726. * @param uniformName Name of the variable.
  29727. * @param array array to be set.
  29728. * @returns this effect.
  29729. */
  29730. setArray4(uniformName: string, array: number[]): Effect;
  29731. /**
  29732. * Sets matrices on a uniform variable.
  29733. * @param uniformName Name of the variable.
  29734. * @param matrices matrices to be set.
  29735. * @returns this effect.
  29736. */
  29737. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29738. /**
  29739. * Sets matrix on a uniform variable.
  29740. * @param uniformName Name of the variable.
  29741. * @param matrix matrix to be set.
  29742. * @returns this effect.
  29743. */
  29744. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29745. /**
  29746. * 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)
  29747. * @param uniformName Name of the variable.
  29748. * @param matrix matrix to be set.
  29749. * @returns this effect.
  29750. */
  29751. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29752. /**
  29753. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29754. * @param uniformName Name of the variable.
  29755. * @param matrix matrix to be set.
  29756. * @returns this effect.
  29757. */
  29758. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29759. /**
  29760. * Sets a float on a uniform variable.
  29761. * @param uniformName Name of the variable.
  29762. * @param value value to be set.
  29763. * @returns this effect.
  29764. */
  29765. setFloat(uniformName: string, value: number): Effect;
  29766. /**
  29767. * Sets a boolean on a uniform variable.
  29768. * @param uniformName Name of the variable.
  29769. * @param bool value to be set.
  29770. * @returns this effect.
  29771. */
  29772. setBool(uniformName: string, bool: boolean): Effect;
  29773. /**
  29774. * Sets a Vector2 on a uniform variable.
  29775. * @param uniformName Name of the variable.
  29776. * @param vector2 vector2 to be set.
  29777. * @returns this effect.
  29778. */
  29779. setVector2(uniformName: string, vector2: Vector2): Effect;
  29780. /**
  29781. * Sets a float2 on a uniform variable.
  29782. * @param uniformName Name of the variable.
  29783. * @param x First float in float2.
  29784. * @param y Second float in float2.
  29785. * @returns this effect.
  29786. */
  29787. setFloat2(uniformName: string, x: number, y: number): Effect;
  29788. /**
  29789. * Sets a Vector3 on a uniform variable.
  29790. * @param uniformName Name of the variable.
  29791. * @param vector3 Value to be set.
  29792. * @returns this effect.
  29793. */
  29794. setVector3(uniformName: string, vector3: Vector3): Effect;
  29795. /**
  29796. * Sets a float3 on a uniform variable.
  29797. * @param uniformName Name of the variable.
  29798. * @param x First float in float3.
  29799. * @param y Second float in float3.
  29800. * @param z Third float in float3.
  29801. * @returns this effect.
  29802. */
  29803. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29804. /**
  29805. * Sets a Vector4 on a uniform variable.
  29806. * @param uniformName Name of the variable.
  29807. * @param vector4 Value to be set.
  29808. * @returns this effect.
  29809. */
  29810. setVector4(uniformName: string, vector4: Vector4): Effect;
  29811. /**
  29812. * Sets a float4 on a uniform variable.
  29813. * @param uniformName Name of the variable.
  29814. * @param x First float in float4.
  29815. * @param y Second float in float4.
  29816. * @param z Third float in float4.
  29817. * @param w Fourth float in float4.
  29818. * @returns this effect.
  29819. */
  29820. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29821. /**
  29822. * Sets a Color3 on a uniform variable.
  29823. * @param uniformName Name of the variable.
  29824. * @param color3 Value to be set.
  29825. * @returns this effect.
  29826. */
  29827. setColor3(uniformName: string, color3: Color3): Effect;
  29828. /**
  29829. * Sets a Color4 on a uniform variable.
  29830. * @param uniformName Name of the variable.
  29831. * @param color3 Value to be set.
  29832. * @param alpha Alpha value to be set.
  29833. * @returns this effect.
  29834. */
  29835. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29836. /**
  29837. * Sets a Color4 on a uniform variable
  29838. * @param uniformName defines the name of the variable
  29839. * @param color4 defines the value to be set
  29840. * @returns this effect.
  29841. */
  29842. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29843. /** Release all associated resources */
  29844. dispose(): void;
  29845. /**
  29846. * This function will add a new shader to the shader store
  29847. * @param name the name of the shader
  29848. * @param pixelShader optional pixel shader content
  29849. * @param vertexShader optional vertex shader content
  29850. */
  29851. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29852. /**
  29853. * Store of each shader (The can be looked up using effect.key)
  29854. */
  29855. static ShadersStore: {
  29856. [key: string]: string;
  29857. };
  29858. /**
  29859. * Store of each included file for a shader (The can be looked up using effect.key)
  29860. */
  29861. static IncludesShadersStore: {
  29862. [key: string]: string;
  29863. };
  29864. /**
  29865. * Resets the cache of effects.
  29866. */
  29867. static ResetCache(): void;
  29868. }
  29869. }
  29870. declare module BABYLON {
  29871. /**
  29872. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29873. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29874. * 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;
  29875. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29876. */
  29877. export class ColorCurves {
  29878. private _dirty;
  29879. private _tempColor;
  29880. private _globalCurve;
  29881. private _highlightsCurve;
  29882. private _midtonesCurve;
  29883. private _shadowsCurve;
  29884. private _positiveCurve;
  29885. private _negativeCurve;
  29886. private _globalHue;
  29887. private _globalDensity;
  29888. private _globalSaturation;
  29889. private _globalExposure;
  29890. /**
  29891. * Gets the global Hue value.
  29892. * 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).
  29893. */
  29894. /**
  29895. * Sets the global Hue value.
  29896. * 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).
  29897. */
  29898. globalHue: number;
  29899. /**
  29900. * Gets the global Density value.
  29901. * 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.
  29902. * Values less than zero provide a filter of opposite hue.
  29903. */
  29904. /**
  29905. * Sets the global Density value.
  29906. * 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.
  29907. * Values less than zero provide a filter of opposite hue.
  29908. */
  29909. globalDensity: number;
  29910. /**
  29911. * Gets the global Saturation value.
  29912. * 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.
  29913. */
  29914. /**
  29915. * Sets the global Saturation value.
  29916. * 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.
  29917. */
  29918. globalSaturation: number;
  29919. /**
  29920. * Gets the global Exposure value.
  29921. * 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.
  29922. */
  29923. /**
  29924. * Sets the global Exposure value.
  29925. * 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.
  29926. */
  29927. globalExposure: number;
  29928. private _highlightsHue;
  29929. private _highlightsDensity;
  29930. private _highlightsSaturation;
  29931. private _highlightsExposure;
  29932. /**
  29933. * Gets the highlights Hue value.
  29934. * 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).
  29935. */
  29936. /**
  29937. * Sets the highlights Hue value.
  29938. * 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).
  29939. */
  29940. highlightsHue: number;
  29941. /**
  29942. * Gets the highlights Density value.
  29943. * 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.
  29944. * Values less than zero provide a filter of opposite hue.
  29945. */
  29946. /**
  29947. * Sets the highlights Density value.
  29948. * 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.
  29949. * Values less than zero provide a filter of opposite hue.
  29950. */
  29951. highlightsDensity: number;
  29952. /**
  29953. * Gets the highlights Saturation value.
  29954. * 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.
  29955. */
  29956. /**
  29957. * Sets the highlights Saturation value.
  29958. * 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.
  29959. */
  29960. highlightsSaturation: number;
  29961. /**
  29962. * Gets the highlights Exposure value.
  29963. * 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.
  29964. */
  29965. /**
  29966. * Sets the highlights Exposure value.
  29967. * 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.
  29968. */
  29969. highlightsExposure: number;
  29970. private _midtonesHue;
  29971. private _midtonesDensity;
  29972. private _midtonesSaturation;
  29973. private _midtonesExposure;
  29974. /**
  29975. * Gets the midtones Hue value.
  29976. * 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).
  29977. */
  29978. /**
  29979. * Sets the midtones Hue value.
  29980. * 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).
  29981. */
  29982. midtonesHue: number;
  29983. /**
  29984. * Gets the midtones Density value.
  29985. * 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.
  29986. * Values less than zero provide a filter of opposite hue.
  29987. */
  29988. /**
  29989. * Sets the midtones Density value.
  29990. * 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.
  29991. * Values less than zero provide a filter of opposite hue.
  29992. */
  29993. midtonesDensity: number;
  29994. /**
  29995. * Gets the midtones Saturation value.
  29996. * 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.
  29997. */
  29998. /**
  29999. * Sets the midtones Saturation value.
  30000. * 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.
  30001. */
  30002. midtonesSaturation: number;
  30003. /**
  30004. * Gets the midtones Exposure value.
  30005. * 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.
  30006. */
  30007. /**
  30008. * Sets the midtones Exposure value.
  30009. * 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.
  30010. */
  30011. midtonesExposure: number;
  30012. private _shadowsHue;
  30013. private _shadowsDensity;
  30014. private _shadowsSaturation;
  30015. private _shadowsExposure;
  30016. /**
  30017. * Gets the shadows Hue value.
  30018. * 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).
  30019. */
  30020. /**
  30021. * Sets the shadows Hue value.
  30022. * 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).
  30023. */
  30024. shadowsHue: number;
  30025. /**
  30026. * Gets the shadows Density value.
  30027. * 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.
  30028. * Values less than zero provide a filter of opposite hue.
  30029. */
  30030. /**
  30031. * Sets the shadows Density value.
  30032. * 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.
  30033. * Values less than zero provide a filter of opposite hue.
  30034. */
  30035. shadowsDensity: number;
  30036. /**
  30037. * Gets the shadows Saturation value.
  30038. * 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.
  30039. */
  30040. /**
  30041. * Sets the shadows Saturation value.
  30042. * 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.
  30043. */
  30044. shadowsSaturation: number;
  30045. /**
  30046. * Gets the shadows Exposure value.
  30047. * 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.
  30048. */
  30049. /**
  30050. * Sets the shadows Exposure value.
  30051. * 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.
  30052. */
  30053. shadowsExposure: number;
  30054. /**
  30055. * Returns the class name
  30056. * @returns The class name
  30057. */
  30058. getClassName(): string;
  30059. /**
  30060. * Binds the color curves to the shader.
  30061. * @param colorCurves The color curve to bind
  30062. * @param effect The effect to bind to
  30063. * @param positiveUniform The positive uniform shader parameter
  30064. * @param neutralUniform The neutral uniform shader parameter
  30065. * @param negativeUniform The negative uniform shader parameter
  30066. */
  30067. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30068. /**
  30069. * Prepare the list of uniforms associated with the ColorCurves effects.
  30070. * @param uniformsList The list of uniforms used in the effect
  30071. */
  30072. static PrepareUniforms(uniformsList: string[]): void;
  30073. /**
  30074. * Returns color grading data based on a hue, density, saturation and exposure value.
  30075. * @param filterHue The hue of the color filter.
  30076. * @param filterDensity The density of the color filter.
  30077. * @param saturation The saturation.
  30078. * @param exposure The exposure.
  30079. * @param result The result data container.
  30080. */
  30081. private getColorGradingDataToRef;
  30082. /**
  30083. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30084. * @param value The input slider value in range [-100,100].
  30085. * @returns Adjusted value.
  30086. */
  30087. private static applyColorGradingSliderNonlinear;
  30088. /**
  30089. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30090. * @param hue The hue (H) input.
  30091. * @param saturation The saturation (S) input.
  30092. * @param brightness The brightness (B) input.
  30093. * @result An RGBA color represented as Vector4.
  30094. */
  30095. private static fromHSBToRef;
  30096. /**
  30097. * Returns a value clamped between min and max
  30098. * @param value The value to clamp
  30099. * @param min The minimum of value
  30100. * @param max The maximum of value
  30101. * @returns The clamped value.
  30102. */
  30103. private static clamp;
  30104. /**
  30105. * Clones the current color curve instance.
  30106. * @return The cloned curves
  30107. */
  30108. clone(): ColorCurves;
  30109. /**
  30110. * Serializes the current color curve instance to a json representation.
  30111. * @return a JSON representation
  30112. */
  30113. serialize(): any;
  30114. /**
  30115. * Parses the color curve from a json representation.
  30116. * @param source the JSON source to parse
  30117. * @return The parsed curves
  30118. */
  30119. static Parse(source: any): ColorCurves;
  30120. }
  30121. }
  30122. declare module BABYLON {
  30123. /**
  30124. * Interface to follow in your material defines to integrate easily the
  30125. * Image proccessing functions.
  30126. * @hidden
  30127. */
  30128. export interface IImageProcessingConfigurationDefines {
  30129. IMAGEPROCESSING: boolean;
  30130. VIGNETTE: boolean;
  30131. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30132. VIGNETTEBLENDMODEOPAQUE: boolean;
  30133. TONEMAPPING: boolean;
  30134. TONEMAPPING_ACES: boolean;
  30135. CONTRAST: boolean;
  30136. EXPOSURE: boolean;
  30137. COLORCURVES: boolean;
  30138. COLORGRADING: boolean;
  30139. COLORGRADING3D: boolean;
  30140. SAMPLER3DGREENDEPTH: boolean;
  30141. SAMPLER3DBGRMAP: boolean;
  30142. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30143. }
  30144. /**
  30145. * @hidden
  30146. */
  30147. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30148. IMAGEPROCESSING: boolean;
  30149. VIGNETTE: boolean;
  30150. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30151. VIGNETTEBLENDMODEOPAQUE: boolean;
  30152. TONEMAPPING: boolean;
  30153. TONEMAPPING_ACES: boolean;
  30154. CONTRAST: boolean;
  30155. COLORCURVES: boolean;
  30156. COLORGRADING: boolean;
  30157. COLORGRADING3D: boolean;
  30158. SAMPLER3DGREENDEPTH: boolean;
  30159. SAMPLER3DBGRMAP: boolean;
  30160. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30161. EXPOSURE: boolean;
  30162. constructor();
  30163. }
  30164. /**
  30165. * This groups together the common properties used for image processing either in direct forward pass
  30166. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30167. * or not.
  30168. */
  30169. export class ImageProcessingConfiguration {
  30170. /**
  30171. * Default tone mapping applied in BabylonJS.
  30172. */
  30173. static readonly TONEMAPPING_STANDARD: number;
  30174. /**
  30175. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30176. * to other engines rendering to increase portability.
  30177. */
  30178. static readonly TONEMAPPING_ACES: number;
  30179. /**
  30180. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30181. */
  30182. colorCurves: Nullable<ColorCurves>;
  30183. private _colorCurvesEnabled;
  30184. /**
  30185. * Gets wether the color curves effect is enabled.
  30186. */
  30187. /**
  30188. * Sets wether the color curves effect is enabled.
  30189. */
  30190. colorCurvesEnabled: boolean;
  30191. private _colorGradingTexture;
  30192. /**
  30193. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30194. */
  30195. /**
  30196. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30197. */
  30198. colorGradingTexture: Nullable<BaseTexture>;
  30199. private _colorGradingEnabled;
  30200. /**
  30201. * Gets wether the color grading effect is enabled.
  30202. */
  30203. /**
  30204. * Sets wether the color grading effect is enabled.
  30205. */
  30206. colorGradingEnabled: boolean;
  30207. private _colorGradingWithGreenDepth;
  30208. /**
  30209. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30210. */
  30211. /**
  30212. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30213. */
  30214. colorGradingWithGreenDepth: boolean;
  30215. private _colorGradingBGR;
  30216. /**
  30217. * Gets wether the color grading texture contains BGR values.
  30218. */
  30219. /**
  30220. * Sets wether the color grading texture contains BGR values.
  30221. */
  30222. colorGradingBGR: boolean;
  30223. /** @hidden */
  30224. _exposure: number;
  30225. /**
  30226. * Gets the Exposure used in the effect.
  30227. */
  30228. /**
  30229. * Sets the Exposure used in the effect.
  30230. */
  30231. exposure: number;
  30232. private _toneMappingEnabled;
  30233. /**
  30234. * Gets wether the tone mapping effect is enabled.
  30235. */
  30236. /**
  30237. * Sets wether the tone mapping effect is enabled.
  30238. */
  30239. toneMappingEnabled: boolean;
  30240. private _toneMappingType;
  30241. /**
  30242. * Gets the type of tone mapping effect.
  30243. */
  30244. /**
  30245. * Sets the type of tone mapping effect used in BabylonJS.
  30246. */
  30247. toneMappingType: number;
  30248. protected _contrast: number;
  30249. /**
  30250. * Gets the contrast used in the effect.
  30251. */
  30252. /**
  30253. * Sets the contrast used in the effect.
  30254. */
  30255. contrast: number;
  30256. /**
  30257. * Vignette stretch size.
  30258. */
  30259. vignetteStretch: number;
  30260. /**
  30261. * Vignette centre X Offset.
  30262. */
  30263. vignetteCentreX: number;
  30264. /**
  30265. * Vignette centre Y Offset.
  30266. */
  30267. vignetteCentreY: number;
  30268. /**
  30269. * Vignette weight or intensity of the vignette effect.
  30270. */
  30271. vignetteWeight: number;
  30272. /**
  30273. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30274. * if vignetteEnabled is set to true.
  30275. */
  30276. vignetteColor: Color4;
  30277. /**
  30278. * Camera field of view used by the Vignette effect.
  30279. */
  30280. vignetteCameraFov: number;
  30281. private _vignetteBlendMode;
  30282. /**
  30283. * Gets the vignette blend mode allowing different kind of effect.
  30284. */
  30285. /**
  30286. * Sets the vignette blend mode allowing different kind of effect.
  30287. */
  30288. vignetteBlendMode: number;
  30289. private _vignetteEnabled;
  30290. /**
  30291. * Gets wether the vignette effect is enabled.
  30292. */
  30293. /**
  30294. * Sets wether the vignette effect is enabled.
  30295. */
  30296. vignetteEnabled: boolean;
  30297. private _applyByPostProcess;
  30298. /**
  30299. * Gets wether the image processing is applied through a post process or not.
  30300. */
  30301. /**
  30302. * Sets wether the image processing is applied through a post process or not.
  30303. */
  30304. applyByPostProcess: boolean;
  30305. private _isEnabled;
  30306. /**
  30307. * Gets wether the image processing is enabled or not.
  30308. */
  30309. /**
  30310. * Sets wether the image processing is enabled or not.
  30311. */
  30312. isEnabled: boolean;
  30313. /**
  30314. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30315. */
  30316. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30317. /**
  30318. * Method called each time the image processing information changes requires to recompile the effect.
  30319. */
  30320. protected _updateParameters(): void;
  30321. /**
  30322. * Gets the current class name.
  30323. * @return "ImageProcessingConfiguration"
  30324. */
  30325. getClassName(): string;
  30326. /**
  30327. * Prepare the list of uniforms associated with the Image Processing effects.
  30328. * @param uniforms The list of uniforms used in the effect
  30329. * @param defines the list of defines currently in use
  30330. */
  30331. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30332. /**
  30333. * Prepare the list of samplers associated with the Image Processing effects.
  30334. * @param samplersList The list of uniforms used in the effect
  30335. * @param defines the list of defines currently in use
  30336. */
  30337. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30338. /**
  30339. * Prepare the list of defines associated to the shader.
  30340. * @param defines the list of defines to complete
  30341. * @param forPostProcess Define if we are currently in post process mode or not
  30342. */
  30343. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30344. /**
  30345. * Returns true if all the image processing information are ready.
  30346. * @returns True if ready, otherwise, false
  30347. */
  30348. isReady(): boolean;
  30349. /**
  30350. * Binds the image processing to the shader.
  30351. * @param effect The effect to bind to
  30352. * @param aspectRatio Define the current aspect ratio of the effect
  30353. */
  30354. bind(effect: Effect, aspectRatio?: number): void;
  30355. /**
  30356. * Clones the current image processing instance.
  30357. * @return The cloned image processing
  30358. */
  30359. clone(): ImageProcessingConfiguration;
  30360. /**
  30361. * Serializes the current image processing instance to a json representation.
  30362. * @return a JSON representation
  30363. */
  30364. serialize(): any;
  30365. /**
  30366. * Parses the image processing from a json representation.
  30367. * @param source the JSON source to parse
  30368. * @return The parsed image processing
  30369. */
  30370. static Parse(source: any): ImageProcessingConfiguration;
  30371. private static _VIGNETTEMODE_MULTIPLY;
  30372. private static _VIGNETTEMODE_OPAQUE;
  30373. /**
  30374. * Used to apply the vignette as a mix with the pixel color.
  30375. */
  30376. static readonly VIGNETTEMODE_MULTIPLY: number;
  30377. /**
  30378. * Used to apply the vignette as a replacement of the pixel color.
  30379. */
  30380. static readonly VIGNETTEMODE_OPAQUE: number;
  30381. }
  30382. }
  30383. declare module BABYLON {
  30384. /**
  30385. * This represents all the required information to add a fresnel effect on a material:
  30386. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30387. */
  30388. export class FresnelParameters {
  30389. private _isEnabled;
  30390. /**
  30391. * Define if the fresnel effect is enable or not.
  30392. */
  30393. isEnabled: boolean;
  30394. /**
  30395. * Define the color used on edges (grazing angle)
  30396. */
  30397. leftColor: Color3;
  30398. /**
  30399. * Define the color used on center
  30400. */
  30401. rightColor: Color3;
  30402. /**
  30403. * Define bias applied to computed fresnel term
  30404. */
  30405. bias: number;
  30406. /**
  30407. * Defined the power exponent applied to fresnel term
  30408. */
  30409. power: number;
  30410. /**
  30411. * Clones the current fresnel and its valuues
  30412. * @returns a clone fresnel configuration
  30413. */
  30414. clone(): FresnelParameters;
  30415. /**
  30416. * Serializes the current fresnel parameters to a JSON representation.
  30417. * @return the JSON serialization
  30418. */
  30419. serialize(): any;
  30420. /**
  30421. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30422. * @param parsedFresnelParameters Define the JSON representation
  30423. * @returns the parsed parameters
  30424. */
  30425. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30426. }
  30427. }
  30428. declare module BABYLON {
  30429. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30430. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30431. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30432. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30433. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30434. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30435. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30436. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30437. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30438. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30439. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30440. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30441. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30442. /**
  30443. * Decorator used to define property that can be serialized as reference to a camera
  30444. * @param sourceName defines the name of the property to decorate
  30445. */
  30446. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30447. /**
  30448. * Class used to help serialization objects
  30449. */
  30450. export class SerializationHelper {
  30451. /** @hidden */
  30452. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30453. /** @hidden */
  30454. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30455. /** @hidden */
  30456. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30457. /** @hidden */
  30458. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30459. /**
  30460. * Appends the serialized animations from the source animations
  30461. * @param source Source containing the animations
  30462. * @param destination Target to store the animations
  30463. */
  30464. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30465. /**
  30466. * Static function used to serialized a specific entity
  30467. * @param entity defines the entity to serialize
  30468. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30469. * @returns a JSON compatible object representing the serialization of the entity
  30470. */
  30471. static Serialize<T>(entity: T, serializationObject?: any): any;
  30472. /**
  30473. * Creates a new entity from a serialization data object
  30474. * @param creationFunction defines a function used to instanciated the new entity
  30475. * @param source defines the source serialization data
  30476. * @param scene defines the hosting scene
  30477. * @param rootUrl defines the root url for resources
  30478. * @returns a new entity
  30479. */
  30480. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30481. /**
  30482. * Clones an object
  30483. * @param creationFunction defines the function used to instanciate the new object
  30484. * @param source defines the source object
  30485. * @returns the cloned object
  30486. */
  30487. static Clone<T>(creationFunction: () => T, source: T): T;
  30488. /**
  30489. * Instanciates a new object based on a source one (some data will be shared between both object)
  30490. * @param creationFunction defines the function used to instanciate the new object
  30491. * @param source defines the source object
  30492. * @returns the new object
  30493. */
  30494. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30495. }
  30496. }
  30497. declare module BABYLON {
  30498. /**
  30499. * This is the base class of all the camera used in the application.
  30500. * @see http://doc.babylonjs.com/features/cameras
  30501. */
  30502. export class Camera extends Node {
  30503. /** @hidden */
  30504. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30505. /**
  30506. * This is the default projection mode used by the cameras.
  30507. * It helps recreating a feeling of perspective and better appreciate depth.
  30508. * This is the best way to simulate real life cameras.
  30509. */
  30510. static readonly PERSPECTIVE_CAMERA: number;
  30511. /**
  30512. * This helps creating camera with an orthographic mode.
  30513. * 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.
  30514. */
  30515. static readonly ORTHOGRAPHIC_CAMERA: number;
  30516. /**
  30517. * This is the default FOV mode for perspective cameras.
  30518. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30519. */
  30520. static readonly FOVMODE_VERTICAL_FIXED: number;
  30521. /**
  30522. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30523. */
  30524. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30525. /**
  30526. * This specifies ther is no need for a camera rig.
  30527. * Basically only one eye is rendered corresponding to the camera.
  30528. */
  30529. static readonly RIG_MODE_NONE: number;
  30530. /**
  30531. * Simulates a camera Rig with one blue eye and one red eye.
  30532. * This can be use with 3d blue and red glasses.
  30533. */
  30534. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30535. /**
  30536. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30537. */
  30538. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30539. /**
  30540. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30541. */
  30542. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30543. /**
  30544. * Defines that both eyes of the camera will be rendered over under each other.
  30545. */
  30546. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30547. /**
  30548. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30549. */
  30550. static readonly RIG_MODE_VR: number;
  30551. /**
  30552. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30553. */
  30554. static readonly RIG_MODE_WEBVR: number;
  30555. /**
  30556. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30557. */
  30558. static readonly RIG_MODE_CUSTOM: number;
  30559. /**
  30560. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30561. */
  30562. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30563. /**
  30564. * Define the input manager associated with the camera.
  30565. */
  30566. inputs: CameraInputsManager<Camera>;
  30567. /** @hidden */
  30568. _position: Vector3;
  30569. /**
  30570. * Define the current local position of the camera in the scene
  30571. */
  30572. position: Vector3;
  30573. /**
  30574. * The vector the camera should consider as up.
  30575. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30576. */
  30577. upVector: Vector3;
  30578. /**
  30579. * Define the current limit on the left side for an orthographic camera
  30580. * In scene unit
  30581. */
  30582. orthoLeft: Nullable<number>;
  30583. /**
  30584. * Define the current limit on the right side for an orthographic camera
  30585. * In scene unit
  30586. */
  30587. orthoRight: Nullable<number>;
  30588. /**
  30589. * Define the current limit on the bottom side for an orthographic camera
  30590. * In scene unit
  30591. */
  30592. orthoBottom: Nullable<number>;
  30593. /**
  30594. * Define the current limit on the top side for an orthographic camera
  30595. * In scene unit
  30596. */
  30597. orthoTop: Nullable<number>;
  30598. /**
  30599. * Field Of View is set in Radians. (default is 0.8)
  30600. */
  30601. fov: number;
  30602. /**
  30603. * Define the minimum distance the camera can see from.
  30604. * This is important to note that the depth buffer are not infinite and the closer it starts
  30605. * the more your scene might encounter depth fighting issue.
  30606. */
  30607. minZ: number;
  30608. /**
  30609. * Define the maximum distance the camera can see to.
  30610. * This is important to note that the depth buffer are not infinite and the further it end
  30611. * the more your scene might encounter depth fighting issue.
  30612. */
  30613. maxZ: number;
  30614. /**
  30615. * Define the default inertia of the camera.
  30616. * This helps giving a smooth feeling to the camera movement.
  30617. */
  30618. inertia: number;
  30619. /**
  30620. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30621. */
  30622. mode: number;
  30623. /**
  30624. * Define wether the camera is intermediate.
  30625. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30626. */
  30627. isIntermediate: boolean;
  30628. /**
  30629. * Define the viewport of the camera.
  30630. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30631. */
  30632. viewport: Viewport;
  30633. /**
  30634. * Restricts the camera to viewing objects with the same layerMask.
  30635. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30636. */
  30637. layerMask: number;
  30638. /**
  30639. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30640. */
  30641. fovMode: number;
  30642. /**
  30643. * Rig mode of the camera.
  30644. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30645. * This is normally controlled byt the camera themselves as internal use.
  30646. */
  30647. cameraRigMode: number;
  30648. /**
  30649. * Defines the distance between both "eyes" in case of a RIG
  30650. */
  30651. interaxialDistance: number;
  30652. /**
  30653. * Defines if stereoscopic rendering is done side by side or over under.
  30654. */
  30655. isStereoscopicSideBySide: boolean;
  30656. /**
  30657. * 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
  30658. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30659. * else in the scene.
  30660. */
  30661. customRenderTargets: RenderTargetTexture[];
  30662. /**
  30663. * When set, the camera will render to this render target instead of the default canvas
  30664. */
  30665. outputRenderTarget: Nullable<RenderTargetTexture>;
  30666. /**
  30667. * Observable triggered when the camera view matrix has changed.
  30668. */
  30669. onViewMatrixChangedObservable: Observable<Camera>;
  30670. /**
  30671. * Observable triggered when the camera Projection matrix has changed.
  30672. */
  30673. onProjectionMatrixChangedObservable: Observable<Camera>;
  30674. /**
  30675. * Observable triggered when the inputs have been processed.
  30676. */
  30677. onAfterCheckInputsObservable: Observable<Camera>;
  30678. /**
  30679. * Observable triggered when reset has been called and applied to the camera.
  30680. */
  30681. onRestoreStateObservable: Observable<Camera>;
  30682. /** @hidden */
  30683. _cameraRigParams: any;
  30684. /** @hidden */
  30685. _rigCameras: Camera[];
  30686. /** @hidden */
  30687. _rigPostProcess: Nullable<PostProcess>;
  30688. protected _webvrViewMatrix: Matrix;
  30689. /** @hidden */
  30690. _skipRendering: boolean;
  30691. /** @hidden */
  30692. _projectionMatrix: Matrix;
  30693. /** @hidden */
  30694. _postProcesses: Nullable<PostProcess>[];
  30695. /** @hidden */
  30696. _activeMeshes: SmartArray<AbstractMesh>;
  30697. protected _globalPosition: Vector3;
  30698. /** @hidden */
  30699. _computedViewMatrix: Matrix;
  30700. private _doNotComputeProjectionMatrix;
  30701. private _transformMatrix;
  30702. private _frustumPlanes;
  30703. private _refreshFrustumPlanes;
  30704. private _storedFov;
  30705. private _stateStored;
  30706. /**
  30707. * Instantiates a new camera object.
  30708. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30709. * @see http://doc.babylonjs.com/features/cameras
  30710. * @param name Defines the name of the camera in the scene
  30711. * @param position Defines the position of the camera
  30712. * @param scene Defines the scene the camera belongs too
  30713. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30714. */
  30715. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30716. /**
  30717. * Store current camera state (fov, position, etc..)
  30718. * @returns the camera
  30719. */
  30720. storeState(): Camera;
  30721. /**
  30722. * Restores the camera state values if it has been stored. You must call storeState() first
  30723. */
  30724. protected _restoreStateValues(): boolean;
  30725. /**
  30726. * Restored camera state. You must call storeState() first.
  30727. * @returns true if restored and false otherwise
  30728. */
  30729. restoreState(): boolean;
  30730. /**
  30731. * Gets the class name of the camera.
  30732. * @returns the class name
  30733. */
  30734. getClassName(): string;
  30735. /** @hidden */
  30736. readonly _isCamera: boolean;
  30737. /**
  30738. * Gets a string representation of the camera useful for debug purpose.
  30739. * @param fullDetails Defines that a more verboe level of logging is required
  30740. * @returns the string representation
  30741. */
  30742. toString(fullDetails?: boolean): string;
  30743. /**
  30744. * Gets the current world space position of the camera.
  30745. */
  30746. readonly globalPosition: Vector3;
  30747. /**
  30748. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30749. * @returns the active meshe list
  30750. */
  30751. getActiveMeshes(): SmartArray<AbstractMesh>;
  30752. /**
  30753. * Check wether a mesh is part of the current active mesh list of the camera
  30754. * @param mesh Defines the mesh to check
  30755. * @returns true if active, false otherwise
  30756. */
  30757. isActiveMesh(mesh: Mesh): boolean;
  30758. /**
  30759. * Is this camera ready to be used/rendered
  30760. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30761. * @return true if the camera is ready
  30762. */
  30763. isReady(completeCheck?: boolean): boolean;
  30764. /** @hidden */
  30765. _initCache(): void;
  30766. /** @hidden */
  30767. _updateCache(ignoreParentClass?: boolean): void;
  30768. /** @hidden */
  30769. _isSynchronized(): boolean;
  30770. /** @hidden */
  30771. _isSynchronizedViewMatrix(): boolean;
  30772. /** @hidden */
  30773. _isSynchronizedProjectionMatrix(): boolean;
  30774. /**
  30775. * Attach the input controls to a specific dom element to get the input from.
  30776. * @param element Defines the element the controls should be listened from
  30777. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30778. */
  30779. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30780. /**
  30781. * Detach the current controls from the specified dom element.
  30782. * @param element Defines the element to stop listening the inputs from
  30783. */
  30784. detachControl(element: HTMLElement): void;
  30785. /**
  30786. * Update the camera state according to the different inputs gathered during the frame.
  30787. */
  30788. update(): void;
  30789. /** @hidden */
  30790. _checkInputs(): void;
  30791. /** @hidden */
  30792. readonly rigCameras: Camera[];
  30793. /**
  30794. * Gets the post process used by the rig cameras
  30795. */
  30796. readonly rigPostProcess: Nullable<PostProcess>;
  30797. /**
  30798. * Internal, gets the first post proces.
  30799. * @returns the first post process to be run on this camera.
  30800. */
  30801. _getFirstPostProcess(): Nullable<PostProcess>;
  30802. private _cascadePostProcessesToRigCams;
  30803. /**
  30804. * Attach a post process to the camera.
  30805. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30806. * @param postProcess The post process to attach to the camera
  30807. * @param insertAt The position of the post process in case several of them are in use in the scene
  30808. * @returns the position the post process has been inserted at
  30809. */
  30810. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30811. /**
  30812. * Detach a post process to the camera.
  30813. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30814. * @param postProcess The post process to detach from the camera
  30815. */
  30816. detachPostProcess(postProcess: PostProcess): void;
  30817. /**
  30818. * Gets the current world matrix of the camera
  30819. */
  30820. getWorldMatrix(): Matrix;
  30821. /** @hidden */
  30822. _getViewMatrix(): Matrix;
  30823. /**
  30824. * Gets the current view matrix of the camera.
  30825. * @param force forces the camera to recompute the matrix without looking at the cached state
  30826. * @returns the view matrix
  30827. */
  30828. getViewMatrix(force?: boolean): Matrix;
  30829. /**
  30830. * Freeze the projection matrix.
  30831. * It will prevent the cache check of the camera projection compute and can speed up perf
  30832. * if no parameter of the camera are meant to change
  30833. * @param projection Defines manually a projection if necessary
  30834. */
  30835. freezeProjectionMatrix(projection?: Matrix): void;
  30836. /**
  30837. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30838. */
  30839. unfreezeProjectionMatrix(): void;
  30840. /**
  30841. * Gets the current projection matrix of the camera.
  30842. * @param force forces the camera to recompute the matrix without looking at the cached state
  30843. * @returns the projection matrix
  30844. */
  30845. getProjectionMatrix(force?: boolean): Matrix;
  30846. /**
  30847. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30848. * @returns a Matrix
  30849. */
  30850. getTransformationMatrix(): Matrix;
  30851. private _updateFrustumPlanes;
  30852. /**
  30853. * Checks if a cullable object (mesh...) is in the camera frustum
  30854. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30855. * @param target The object to check
  30856. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30857. * @returns true if the object is in frustum otherwise false
  30858. */
  30859. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30860. /**
  30861. * Checks if a cullable object (mesh...) is in the camera frustum
  30862. * Unlike isInFrustum this cheks the full bounding box
  30863. * @param target The object to check
  30864. * @returns true if the object is in frustum otherwise false
  30865. */
  30866. isCompletelyInFrustum(target: ICullable): boolean;
  30867. /**
  30868. * Gets a ray in the forward direction from the camera.
  30869. * @param length Defines the length of the ray to create
  30870. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30871. * @param origin Defines the start point of the ray which defaults to the camera position
  30872. * @returns the forward ray
  30873. */
  30874. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30875. /**
  30876. * Releases resources associated with this node.
  30877. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30878. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30879. */
  30880. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30881. /** @hidden */
  30882. _isLeftCamera: boolean;
  30883. /**
  30884. * Gets the left camera of a rig setup in case of Rigged Camera
  30885. */
  30886. readonly isLeftCamera: boolean;
  30887. /** @hidden */
  30888. _isRightCamera: boolean;
  30889. /**
  30890. * Gets the right camera of a rig setup in case of Rigged Camera
  30891. */
  30892. readonly isRightCamera: boolean;
  30893. /**
  30894. * Gets the left camera of a rig setup in case of Rigged Camera
  30895. */
  30896. readonly leftCamera: Nullable<FreeCamera>;
  30897. /**
  30898. * Gets the right camera of a rig setup in case of Rigged Camera
  30899. */
  30900. readonly rightCamera: Nullable<FreeCamera>;
  30901. /**
  30902. * Gets the left camera target of a rig setup in case of Rigged Camera
  30903. * @returns the target position
  30904. */
  30905. getLeftTarget(): Nullable<Vector3>;
  30906. /**
  30907. * Gets the right camera target of a rig setup in case of Rigged Camera
  30908. * @returns the target position
  30909. */
  30910. getRightTarget(): Nullable<Vector3>;
  30911. /**
  30912. * @hidden
  30913. */
  30914. setCameraRigMode(mode: number, rigParams: any): void;
  30915. /** @hidden */
  30916. static _setStereoscopicRigMode(camera: Camera): void;
  30917. /** @hidden */
  30918. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30919. /** @hidden */
  30920. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30921. /** @hidden */
  30922. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30923. /** @hidden */
  30924. _getVRProjectionMatrix(): Matrix;
  30925. protected _updateCameraRotationMatrix(): void;
  30926. protected _updateWebVRCameraRotationMatrix(): void;
  30927. /**
  30928. * This function MUST be overwritten by the different WebVR cameras available.
  30929. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30930. * @hidden
  30931. */
  30932. _getWebVRProjectionMatrix(): Matrix;
  30933. /**
  30934. * This function MUST be overwritten by the different WebVR cameras available.
  30935. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30936. * @hidden
  30937. */
  30938. _getWebVRViewMatrix(): Matrix;
  30939. /** @hidden */
  30940. setCameraRigParameter(name: string, value: any): void;
  30941. /**
  30942. * needs to be overridden by children so sub has required properties to be copied
  30943. * @hidden
  30944. */
  30945. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30946. /**
  30947. * May need to be overridden by children
  30948. * @hidden
  30949. */
  30950. _updateRigCameras(): void;
  30951. /** @hidden */
  30952. _setupInputs(): void;
  30953. /**
  30954. * Serialiaze the camera setup to a json represention
  30955. * @returns the JSON representation
  30956. */
  30957. serialize(): any;
  30958. /**
  30959. * Clones the current camera.
  30960. * @param name The cloned camera name
  30961. * @returns the cloned camera
  30962. */
  30963. clone(name: string): Camera;
  30964. /**
  30965. * Gets the direction of the camera relative to a given local axis.
  30966. * @param localAxis Defines the reference axis to provide a relative direction.
  30967. * @return the direction
  30968. */
  30969. getDirection(localAxis: Vector3): Vector3;
  30970. /**
  30971. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30972. * @param localAxis Defines the reference axis to provide a relative direction.
  30973. * @param result Defines the vector to store the result in
  30974. */
  30975. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30976. /**
  30977. * Gets a camera constructor for a given camera type
  30978. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30979. * @param name The name of the camera the result will be able to instantiate
  30980. * @param scene The scene the result will construct the camera in
  30981. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30982. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30983. * @returns a factory method to construc the camera
  30984. */
  30985. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30986. /**
  30987. * Compute the world matrix of the camera.
  30988. * @returns the camera workd matrix
  30989. */
  30990. computeWorldMatrix(): Matrix;
  30991. /**
  30992. * Parse a JSON and creates the camera from the parsed information
  30993. * @param parsedCamera The JSON to parse
  30994. * @param scene The scene to instantiate the camera in
  30995. * @returns the newly constructed camera
  30996. */
  30997. static Parse(parsedCamera: any, scene: Scene): Camera;
  30998. }
  30999. }
  31000. declare module BABYLON {
  31001. /**
  31002. * Interface for any object that can request an animation frame
  31003. */
  31004. export interface ICustomAnimationFrameRequester {
  31005. /**
  31006. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31007. */
  31008. renderFunction?: Function;
  31009. /**
  31010. * Called to request the next frame to render to
  31011. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31012. */
  31013. requestAnimationFrame: Function;
  31014. /**
  31015. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31016. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31017. */
  31018. requestID?: number;
  31019. }
  31020. /**
  31021. * Interface containing an array of animations
  31022. */
  31023. export interface IAnimatable {
  31024. /**
  31025. * Array of animations
  31026. */
  31027. animations: Nullable<Array<Animation>>;
  31028. }
  31029. /** Interface used by value gradients (color, factor, ...) */
  31030. export interface IValueGradient {
  31031. /**
  31032. * Gets or sets the gradient value (between 0 and 1)
  31033. */
  31034. gradient: number;
  31035. }
  31036. /** Class used to store color4 gradient */
  31037. export class ColorGradient implements IValueGradient {
  31038. /**
  31039. * Gets or sets the gradient value (between 0 and 1)
  31040. */
  31041. gradient: number;
  31042. /**
  31043. * Gets or sets first associated color
  31044. */
  31045. color1: Color4;
  31046. /**
  31047. * Gets or sets second associated color
  31048. */
  31049. color2?: Color4;
  31050. /**
  31051. * Will get a color picked randomly between color1 and color2.
  31052. * If color2 is undefined then color1 will be used
  31053. * @param result defines the target Color4 to store the result in
  31054. */
  31055. getColorToRef(result: Color4): void;
  31056. }
  31057. /** Class used to store color 3 gradient */
  31058. export class Color3Gradient implements IValueGradient {
  31059. /**
  31060. * Gets or sets the gradient value (between 0 and 1)
  31061. */
  31062. gradient: number;
  31063. /**
  31064. * Gets or sets the associated color
  31065. */
  31066. color: Color3;
  31067. }
  31068. /** Class used to store factor gradient */
  31069. export class FactorGradient implements IValueGradient {
  31070. /**
  31071. * Gets or sets the gradient value (between 0 and 1)
  31072. */
  31073. gradient: number;
  31074. /**
  31075. * Gets or sets first associated factor
  31076. */
  31077. factor1: number;
  31078. /**
  31079. * Gets or sets second associated factor
  31080. */
  31081. factor2?: number;
  31082. /**
  31083. * Will get a number picked randomly between factor1 and factor2.
  31084. * If factor2 is undefined then factor1 will be used
  31085. * @returns the picked number
  31086. */
  31087. getFactor(): number;
  31088. }
  31089. /**
  31090. * @ignore
  31091. * Application error to support additional information when loading a file
  31092. */
  31093. export class LoadFileError extends Error {
  31094. /** defines the optional web request */
  31095. request?: WebRequest | undefined;
  31096. private static _setPrototypeOf;
  31097. /**
  31098. * Creates a new LoadFileError
  31099. * @param message defines the message of the error
  31100. * @param request defines the optional web request
  31101. */
  31102. constructor(message: string,
  31103. /** defines the optional web request */
  31104. request?: WebRequest | undefined);
  31105. }
  31106. /**
  31107. * Class used to define a retry strategy when error happens while loading assets
  31108. */
  31109. export class RetryStrategy {
  31110. /**
  31111. * Function used to defines an exponential back off strategy
  31112. * @param maxRetries defines the maximum number of retries (3 by default)
  31113. * @param baseInterval defines the interval between retries
  31114. * @returns the strategy function to use
  31115. */
  31116. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31117. }
  31118. /**
  31119. * File request interface
  31120. */
  31121. export interface IFileRequest {
  31122. /**
  31123. * Raised when the request is complete (success or error).
  31124. */
  31125. onCompleteObservable: Observable<IFileRequest>;
  31126. /**
  31127. * Aborts the request for a file.
  31128. */
  31129. abort: () => void;
  31130. }
  31131. /**
  31132. * Class containing a set of static utilities functions
  31133. */
  31134. export class Tools {
  31135. /**
  31136. * Gets or sets the base URL to use to load assets
  31137. */
  31138. static BaseUrl: string;
  31139. /**
  31140. * Enable/Disable Custom HTTP Request Headers globally.
  31141. * default = false
  31142. * @see CustomRequestHeaders
  31143. */
  31144. static UseCustomRequestHeaders: boolean;
  31145. /**
  31146. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31147. * i.e. when loading files, where the server/service expects an Authorization header
  31148. */
  31149. static CustomRequestHeaders: {
  31150. [key: string]: string;
  31151. };
  31152. /**
  31153. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31154. */
  31155. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31156. /**
  31157. * Default behaviour for cors in the application.
  31158. * It can be a string if the expected behavior is identical in the entire app.
  31159. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31160. */
  31161. static CorsBehavior: string | ((url: string | string[]) => string);
  31162. /**
  31163. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31164. * @ignorenaming
  31165. */
  31166. static UseFallbackTexture: boolean;
  31167. /**
  31168. * Use this object to register external classes like custom textures or material
  31169. * to allow the laoders to instantiate them
  31170. */
  31171. static RegisteredExternalClasses: {
  31172. [key: string]: Object;
  31173. };
  31174. /**
  31175. * Texture content used if a texture cannot loaded
  31176. * @ignorenaming
  31177. */
  31178. static fallbackTexture: string;
  31179. /**
  31180. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31181. * @param u defines the coordinate on X axis
  31182. * @param v defines the coordinate on Y axis
  31183. * @param width defines the width of the source data
  31184. * @param height defines the height of the source data
  31185. * @param pixels defines the source byte array
  31186. * @param color defines the output color
  31187. */
  31188. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31189. /**
  31190. * Interpolates between a and b via alpha
  31191. * @param a The lower value (returned when alpha = 0)
  31192. * @param b The upper value (returned when alpha = 1)
  31193. * @param alpha The interpolation-factor
  31194. * @return The mixed value
  31195. */
  31196. static Mix(a: number, b: number, alpha: number): number;
  31197. /**
  31198. * Tries to instantiate a new object from a given class name
  31199. * @param className defines the class name to instantiate
  31200. * @returns the new object or null if the system was not able to do the instantiation
  31201. */
  31202. static Instantiate(className: string): any;
  31203. /**
  31204. * Provides a slice function that will work even on IE
  31205. * @param data defines the array to slice
  31206. * @param start defines the start of the data (optional)
  31207. * @param end defines the end of the data (optional)
  31208. * @returns the new sliced array
  31209. */
  31210. static Slice<T>(data: T, start?: number, end?: number): T;
  31211. /**
  31212. * Polyfill for setImmediate
  31213. * @param action defines the action to execute after the current execution block
  31214. */
  31215. static SetImmediate(action: () => void): void;
  31216. /**
  31217. * Function indicating if a number is an exponent of 2
  31218. * @param value defines the value to test
  31219. * @returns true if the value is an exponent of 2
  31220. */
  31221. static IsExponentOfTwo(value: number): boolean;
  31222. private static _tmpFloatArray;
  31223. /**
  31224. * Returns the nearest 32-bit single precision float representation of a Number
  31225. * @param value A Number. If the parameter is of a different type, it will get converted
  31226. * to a number or to NaN if it cannot be converted
  31227. * @returns number
  31228. */
  31229. static FloatRound(value: number): number;
  31230. /**
  31231. * Find the next highest power of two.
  31232. * @param x Number to start search from.
  31233. * @return Next highest power of two.
  31234. */
  31235. static CeilingPOT(x: number): number;
  31236. /**
  31237. * Find the next lowest power of two.
  31238. * @param x Number to start search from.
  31239. * @return Next lowest power of two.
  31240. */
  31241. static FloorPOT(x: number): number;
  31242. /**
  31243. * Find the nearest power of two.
  31244. * @param x Number to start search from.
  31245. * @return Next nearest power of two.
  31246. */
  31247. static NearestPOT(x: number): number;
  31248. /**
  31249. * Get the closest exponent of two
  31250. * @param value defines the value to approximate
  31251. * @param max defines the maximum value to return
  31252. * @param mode defines how to define the closest value
  31253. * @returns closest exponent of two of the given value
  31254. */
  31255. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31256. /**
  31257. * Extracts the filename from a path
  31258. * @param path defines the path to use
  31259. * @returns the filename
  31260. */
  31261. static GetFilename(path: string): string;
  31262. /**
  31263. * Extracts the "folder" part of a path (everything before the filename).
  31264. * @param uri The URI to extract the info from
  31265. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31266. * @returns The "folder" part of the path
  31267. */
  31268. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31269. /**
  31270. * Extracts text content from a DOM element hierarchy
  31271. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31272. */
  31273. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31274. /**
  31275. * Convert an angle in radians to degrees
  31276. * @param angle defines the angle to convert
  31277. * @returns the angle in degrees
  31278. */
  31279. static ToDegrees(angle: number): number;
  31280. /**
  31281. * Convert an angle in degrees to radians
  31282. * @param angle defines the angle to convert
  31283. * @returns the angle in radians
  31284. */
  31285. static ToRadians(angle: number): number;
  31286. /**
  31287. * Encode a buffer to a base64 string
  31288. * @param buffer defines the buffer to encode
  31289. * @returns the encoded string
  31290. */
  31291. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31292. /**
  31293. * Extracts minimum and maximum values from a list of indexed positions
  31294. * @param positions defines the positions to use
  31295. * @param indices defines the indices to the positions
  31296. * @param indexStart defines the start index
  31297. * @param indexCount defines the end index
  31298. * @param bias defines bias value to add to the result
  31299. * @return minimum and maximum values
  31300. */
  31301. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31302. minimum: Vector3;
  31303. maximum: Vector3;
  31304. };
  31305. /**
  31306. * Extracts minimum and maximum values from a list of positions
  31307. * @param positions defines the positions to use
  31308. * @param start defines the start index in the positions array
  31309. * @param count defines the number of positions to handle
  31310. * @param bias defines bias value to add to the result
  31311. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31312. * @return minimum and maximum values
  31313. */
  31314. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31315. minimum: Vector3;
  31316. maximum: Vector3;
  31317. };
  31318. /**
  31319. * Returns an array if obj is not an array
  31320. * @param obj defines the object to evaluate as an array
  31321. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31322. * @returns either obj directly if obj is an array or a new array containing obj
  31323. */
  31324. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31325. /**
  31326. * Gets the pointer prefix to use
  31327. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31328. */
  31329. static GetPointerPrefix(): string;
  31330. /**
  31331. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31332. * @param func - the function to be called
  31333. * @param requester - the object that will request the next frame. Falls back to window.
  31334. * @returns frame number
  31335. */
  31336. static QueueNewFrame(func: () => void, requester?: any): number;
  31337. /**
  31338. * Ask the browser to promote the current element to fullscreen rendering mode
  31339. * @param element defines the DOM element to promote
  31340. */
  31341. static RequestFullscreen(element: HTMLElement): void;
  31342. /**
  31343. * Asks the browser to exit fullscreen mode
  31344. */
  31345. static ExitFullscreen(): void;
  31346. /**
  31347. * Ask the browser to promote the current element to pointerlock mode
  31348. * @param element defines the DOM element to promote
  31349. */
  31350. static RequestPointerlock(element: HTMLElement): void;
  31351. /**
  31352. * Asks the browser to exit pointerlock mode
  31353. */
  31354. static ExitPointerlock(): void;
  31355. /**
  31356. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31357. * @param url define the url we are trying
  31358. * @param element define the dom element where to configure the cors policy
  31359. */
  31360. static SetCorsBehavior(url: string | string[], element: {
  31361. crossOrigin: string | null;
  31362. }): void;
  31363. /**
  31364. * Removes unwanted characters from an url
  31365. * @param url defines the url to clean
  31366. * @returns the cleaned url
  31367. */
  31368. static CleanUrl(url: string): string;
  31369. /**
  31370. * Gets or sets a function used to pre-process url before using them to load assets
  31371. */
  31372. static PreprocessUrl: (url: string) => string;
  31373. /**
  31374. * Loads an image as an HTMLImageElement.
  31375. * @param input url string, ArrayBuffer, or Blob to load
  31376. * @param onLoad callback called when the image successfully loads
  31377. * @param onError callback called when the image fails to load
  31378. * @param offlineProvider offline provider for caching
  31379. * @returns the HTMLImageElement of the loaded image
  31380. */
  31381. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31382. /**
  31383. * Loads a file
  31384. * @param url url string, ArrayBuffer, or Blob to load
  31385. * @param onSuccess callback called when the file successfully loads
  31386. * @param onProgress callback called while file is loading (if the server supports this mode)
  31387. * @param offlineProvider defines the offline provider for caching
  31388. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31389. * @param onError callback called when the file fails to load
  31390. * @returns a file request object
  31391. */
  31392. 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;
  31393. /**
  31394. * Loads a file from a url
  31395. * @param url the file url to load
  31396. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31397. */
  31398. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31399. /**
  31400. * Load a script (identified by an url). When the url returns, the
  31401. * content of this file is added into a new script element, attached to the DOM (body element)
  31402. * @param scriptUrl defines the url of the script to laod
  31403. * @param onSuccess defines the callback called when the script is loaded
  31404. * @param onError defines the callback to call if an error occurs
  31405. * @param scriptId defines the id of the script element
  31406. */
  31407. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31408. /**
  31409. * Load an asynchronous script (identified by an url). When the url returns, the
  31410. * content of this file is added into a new script element, attached to the DOM (body element)
  31411. * @param scriptUrl defines the url of the script to laod
  31412. * @param scriptId defines the id of the script element
  31413. * @returns a promise request object
  31414. */
  31415. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31416. /**
  31417. * Loads a file from a blob
  31418. * @param fileToLoad defines the blob to use
  31419. * @param callback defines the callback to call when data is loaded
  31420. * @param progressCallback defines the callback to call during loading process
  31421. * @returns a file request object
  31422. */
  31423. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31424. /**
  31425. * Loads a file
  31426. * @param fileToLoad defines the file to load
  31427. * @param callback defines the callback to call when data is loaded
  31428. * @param progressCallBack defines the callback to call during loading process
  31429. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31430. * @returns a file request object
  31431. */
  31432. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31433. /**
  31434. * Creates a data url from a given string content
  31435. * @param content defines the content to convert
  31436. * @returns the new data url link
  31437. */
  31438. static FileAsURL(content: string): string;
  31439. /**
  31440. * Format the given number to a specific decimal format
  31441. * @param value defines the number to format
  31442. * @param decimals defines the number of decimals to use
  31443. * @returns the formatted string
  31444. */
  31445. static Format(value: number, decimals?: number): string;
  31446. /**
  31447. * Checks if a given vector is inside a specific range
  31448. * @param v defines the vector to test
  31449. * @param min defines the minimum range
  31450. * @param max defines the maximum range
  31451. */
  31452. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31453. /**
  31454. * Tries to copy an object by duplicating every property
  31455. * @param source defines the source object
  31456. * @param destination defines the target object
  31457. * @param doNotCopyList defines a list of properties to avoid
  31458. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31459. */
  31460. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31461. /**
  31462. * Gets a boolean indicating if the given object has no own property
  31463. * @param obj defines the object to test
  31464. * @returns true if object has no own property
  31465. */
  31466. static IsEmpty(obj: any): boolean;
  31467. /**
  31468. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31469. * @param str Source string
  31470. * @param suffix Suffix to search for in the source string
  31471. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31472. */
  31473. static EndsWith(str: string, suffix: string): boolean;
  31474. /**
  31475. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  31476. * @param str Source string
  31477. * @param suffix Suffix to search for in the source string
  31478. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31479. */
  31480. static StartsWith(str: string, suffix: string): boolean;
  31481. /**
  31482. * Function used to register events at window level
  31483. * @param events defines the events to register
  31484. */
  31485. static RegisterTopRootEvents(events: {
  31486. name: string;
  31487. handler: Nullable<(e: FocusEvent) => any>;
  31488. }[]): void;
  31489. /**
  31490. * Function used to unregister events from window level
  31491. * @param events defines the events to unregister
  31492. */
  31493. static UnregisterTopRootEvents(events: {
  31494. name: string;
  31495. handler: Nullable<(e: FocusEvent) => any>;
  31496. }[]): void;
  31497. /**
  31498. * @ignore
  31499. */
  31500. static _ScreenshotCanvas: HTMLCanvasElement;
  31501. /**
  31502. * Dumps the current bound framebuffer
  31503. * @param width defines the rendering width
  31504. * @param height defines the rendering height
  31505. * @param engine defines the hosting engine
  31506. * @param successCallback defines the callback triggered once the data are available
  31507. * @param mimeType defines the mime type of the result
  31508. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31509. */
  31510. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31511. /**
  31512. * Converts the canvas data to blob.
  31513. * This acts as a polyfill for browsers not supporting the to blob function.
  31514. * @param canvas Defines the canvas to extract the data from
  31515. * @param successCallback Defines the callback triggered once the data are available
  31516. * @param mimeType Defines the mime type of the result
  31517. */
  31518. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31519. /**
  31520. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31521. * @param successCallback defines the callback triggered once the data are available
  31522. * @param mimeType defines the mime type of the result
  31523. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31524. */
  31525. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31526. /**
  31527. * Downloads a blob in the browser
  31528. * @param blob defines the blob to download
  31529. * @param fileName defines the name of the downloaded file
  31530. */
  31531. static Download(blob: Blob, fileName: string): void;
  31532. /**
  31533. * Captures a screenshot of the current rendering
  31534. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31535. * @param engine defines the rendering engine
  31536. * @param camera defines the source camera
  31537. * @param size This parameter can be set to a single number or to an object with the
  31538. * following (optional) properties: precision, width, height. If a single number is passed,
  31539. * it will be used for both width and height. If an object is passed, the screenshot size
  31540. * will be derived from the parameters. The precision property is a multiplier allowing
  31541. * rendering at a higher or lower resolution
  31542. * @param successCallback defines the callback receives a single parameter which contains the
  31543. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31544. * src parameter of an <img> to display it
  31545. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31546. * Check your browser for supported MIME types
  31547. */
  31548. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31549. /**
  31550. * Generates an image screenshot from the specified camera.
  31551. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31552. * @param engine The engine to use for rendering
  31553. * @param camera The camera to use for rendering
  31554. * @param size This parameter can be set to a single number or to an object with the
  31555. * following (optional) properties: precision, width, height. If a single number is passed,
  31556. * it will be used for both width and height. If an object is passed, the screenshot size
  31557. * will be derived from the parameters. The precision property is a multiplier allowing
  31558. * rendering at a higher or lower resolution
  31559. * @param successCallback The callback receives a single parameter which contains the
  31560. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31561. * src parameter of an <img> to display it
  31562. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31563. * Check your browser for supported MIME types
  31564. * @param samples Texture samples (default: 1)
  31565. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31566. * @param fileName A name for for the downloaded file.
  31567. */
  31568. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31569. /**
  31570. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31571. * Be aware Math.random() could cause collisions, but:
  31572. * "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"
  31573. * @returns a pseudo random id
  31574. */
  31575. static RandomId(): string;
  31576. /**
  31577. * Test if the given uri is a base64 string
  31578. * @param uri The uri to test
  31579. * @return True if the uri is a base64 string or false otherwise
  31580. */
  31581. static IsBase64(uri: string): boolean;
  31582. /**
  31583. * Decode the given base64 uri.
  31584. * @param uri The uri to decode
  31585. * @return The decoded base64 data.
  31586. */
  31587. static DecodeBase64(uri: string): ArrayBuffer;
  31588. /**
  31589. * Gets the absolute url.
  31590. * @param url the input url
  31591. * @return the absolute url
  31592. */
  31593. static GetAbsoluteUrl(url: string): string;
  31594. /**
  31595. * No log
  31596. */
  31597. static readonly NoneLogLevel: number;
  31598. /**
  31599. * Only message logs
  31600. */
  31601. static readonly MessageLogLevel: number;
  31602. /**
  31603. * Only warning logs
  31604. */
  31605. static readonly WarningLogLevel: number;
  31606. /**
  31607. * Only error logs
  31608. */
  31609. static readonly ErrorLogLevel: number;
  31610. /**
  31611. * All logs
  31612. */
  31613. static readonly AllLogLevel: number;
  31614. /**
  31615. * Gets a value indicating the number of loading errors
  31616. * @ignorenaming
  31617. */
  31618. static readonly errorsCount: number;
  31619. /**
  31620. * Callback called when a new log is added
  31621. */
  31622. static OnNewCacheEntry: (entry: string) => void;
  31623. /**
  31624. * Log a message to the console
  31625. * @param message defines the message to log
  31626. */
  31627. static Log(message: string): void;
  31628. /**
  31629. * Write a warning message to the console
  31630. * @param message defines the message to log
  31631. */
  31632. static Warn(message: string): void;
  31633. /**
  31634. * Write an error message to the console
  31635. * @param message defines the message to log
  31636. */
  31637. static Error(message: string): void;
  31638. /**
  31639. * Gets current log cache (list of logs)
  31640. */
  31641. static readonly LogCache: string;
  31642. /**
  31643. * Clears the log cache
  31644. */
  31645. static ClearLogCache(): void;
  31646. /**
  31647. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31648. */
  31649. static LogLevels: number;
  31650. /**
  31651. * Checks if the loaded document was accessed via `file:`-Protocol.
  31652. * @returns boolean
  31653. */
  31654. static IsFileURL(): boolean;
  31655. /**
  31656. * Checks if the window object exists
  31657. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31658. */
  31659. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31660. /**
  31661. * No performance log
  31662. */
  31663. static readonly PerformanceNoneLogLevel: number;
  31664. /**
  31665. * Use user marks to log performance
  31666. */
  31667. static readonly PerformanceUserMarkLogLevel: number;
  31668. /**
  31669. * Log performance to the console
  31670. */
  31671. static readonly PerformanceConsoleLogLevel: number;
  31672. private static _performance;
  31673. /**
  31674. * Sets the current performance log level
  31675. */
  31676. static PerformanceLogLevel: number;
  31677. private static _StartPerformanceCounterDisabled;
  31678. private static _EndPerformanceCounterDisabled;
  31679. private static _StartUserMark;
  31680. private static _EndUserMark;
  31681. private static _StartPerformanceConsole;
  31682. private static _EndPerformanceConsole;
  31683. /**
  31684. * Starts a performance counter
  31685. */
  31686. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31687. /**
  31688. * Ends a specific performance coutner
  31689. */
  31690. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31691. /**
  31692. * Gets either window.performance.now() if supported or Date.now() else
  31693. */
  31694. static readonly Now: number;
  31695. /**
  31696. * This method will return the name of the class used to create the instance of the given object.
  31697. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31698. * @param object the object to get the class name from
  31699. * @param isType defines if the object is actually a type
  31700. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31701. */
  31702. static GetClassName(object: any, isType?: boolean): string;
  31703. /**
  31704. * Gets the first element of an array satisfying a given predicate
  31705. * @param array defines the array to browse
  31706. * @param predicate defines the predicate to use
  31707. * @returns null if not found or the element
  31708. */
  31709. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31710. /**
  31711. * This method will return the name of the full name of the class, including its owning module (if any).
  31712. * 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).
  31713. * @param object the object to get the class name from
  31714. * @param isType defines if the object is actually a type
  31715. * @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.
  31716. * @ignorenaming
  31717. */
  31718. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31719. /**
  31720. * Returns a promise that resolves after the given amount of time.
  31721. * @param delay Number of milliseconds to delay
  31722. * @returns Promise that resolves after the given amount of time
  31723. */
  31724. static DelayAsync(delay: number): Promise<void>;
  31725. /**
  31726. * Gets the current gradient from an array of IValueGradient
  31727. * @param ratio defines the current ratio to get
  31728. * @param gradients defines the array of IValueGradient
  31729. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31730. */
  31731. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31732. }
  31733. /**
  31734. * This class is used to track a performance counter which is number based.
  31735. * The user has access to many properties which give statistics of different nature.
  31736. *
  31737. * The implementer can track two kinds of Performance Counter: time and count.
  31738. * 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.
  31739. * 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.
  31740. */
  31741. export class PerfCounter {
  31742. /**
  31743. * Gets or sets a global boolean to turn on and off all the counters
  31744. */
  31745. static Enabled: boolean;
  31746. /**
  31747. * Returns the smallest value ever
  31748. */
  31749. readonly min: number;
  31750. /**
  31751. * Returns the biggest value ever
  31752. */
  31753. readonly max: number;
  31754. /**
  31755. * Returns the average value since the performance counter is running
  31756. */
  31757. readonly average: number;
  31758. /**
  31759. * Returns the average value of the last second the counter was monitored
  31760. */
  31761. readonly lastSecAverage: number;
  31762. /**
  31763. * Returns the current value
  31764. */
  31765. readonly current: number;
  31766. /**
  31767. * Gets the accumulated total
  31768. */
  31769. readonly total: number;
  31770. /**
  31771. * Gets the total value count
  31772. */
  31773. readonly count: number;
  31774. /**
  31775. * Creates a new counter
  31776. */
  31777. constructor();
  31778. /**
  31779. * Call this method to start monitoring a new frame.
  31780. * 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.
  31781. */
  31782. fetchNewFrame(): void;
  31783. /**
  31784. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31785. * @param newCount the count value to add to the monitored count
  31786. * @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.
  31787. */
  31788. addCount(newCount: number, fetchResult: boolean): void;
  31789. /**
  31790. * Start monitoring this performance counter
  31791. */
  31792. beginMonitoring(): void;
  31793. /**
  31794. * Compute the time lapsed since the previous beginMonitoring() call.
  31795. * @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
  31796. */
  31797. endMonitoring(newFrame?: boolean): void;
  31798. private _fetchResult;
  31799. private _startMonitoringTime;
  31800. private _min;
  31801. private _max;
  31802. private _average;
  31803. private _current;
  31804. private _totalValueCount;
  31805. private _totalAccumulated;
  31806. private _lastSecAverage;
  31807. private _lastSecAccumulated;
  31808. private _lastSecTime;
  31809. private _lastSecValueCount;
  31810. }
  31811. /**
  31812. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31813. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31814. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31815. * @param name The name of the class, case should be preserved
  31816. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31817. */
  31818. export function className(name: string, module?: string): (target: Object) => void;
  31819. /**
  31820. * An implementation of a loop for asynchronous functions.
  31821. */
  31822. export class AsyncLoop {
  31823. /**
  31824. * Defines the number of iterations for the loop
  31825. */
  31826. iterations: number;
  31827. /**
  31828. * Defines the current index of the loop.
  31829. */
  31830. index: number;
  31831. private _done;
  31832. private _fn;
  31833. private _successCallback;
  31834. /**
  31835. * Constructor.
  31836. * @param iterations the number of iterations.
  31837. * @param func the function to run each iteration
  31838. * @param successCallback the callback that will be called upon succesful execution
  31839. * @param offset starting offset.
  31840. */
  31841. constructor(
  31842. /**
  31843. * Defines the number of iterations for the loop
  31844. */
  31845. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31846. /**
  31847. * Execute the next iteration. Must be called after the last iteration was finished.
  31848. */
  31849. executeNext(): void;
  31850. /**
  31851. * Break the loop and run the success callback.
  31852. */
  31853. breakLoop(): void;
  31854. /**
  31855. * Create and run an async loop.
  31856. * @param iterations the number of iterations.
  31857. * @param fn the function to run each iteration
  31858. * @param successCallback the callback that will be called upon succesful execution
  31859. * @param offset starting offset.
  31860. * @returns the created async loop object
  31861. */
  31862. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31863. /**
  31864. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31865. * @param iterations total number of iterations
  31866. * @param syncedIterations number of synchronous iterations in each async iteration.
  31867. * @param fn the function to call each iteration.
  31868. * @param callback a success call back that will be called when iterating stops.
  31869. * @param breakFunction a break condition (optional)
  31870. * @param timeout timeout settings for the setTimeout function. default - 0.
  31871. * @returns the created async loop object
  31872. */
  31873. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31874. }
  31875. }
  31876. declare module BABYLON {
  31877. /** @hidden */
  31878. export interface ICollisionCoordinator {
  31879. createCollider(): Collider;
  31880. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31881. init(scene: Scene): void;
  31882. }
  31883. /** @hidden */
  31884. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31885. private _scene;
  31886. private _scaledPosition;
  31887. private _scaledVelocity;
  31888. private _finalPosition;
  31889. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31890. createCollider(): Collider;
  31891. init(scene: Scene): void;
  31892. private _collideWithWorld;
  31893. }
  31894. }
  31895. declare module BABYLON {
  31896. /**
  31897. * Class used to manage all inputs for the scene.
  31898. */
  31899. export class InputManager {
  31900. /** The distance in pixel that you have to move to prevent some events */
  31901. static DragMovementThreshold: number;
  31902. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31903. static LongPressDelay: number;
  31904. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31905. static DoubleClickDelay: number;
  31906. /** If you need to check double click without raising a single click at first click, enable this flag */
  31907. static ExclusiveDoubleClickMode: boolean;
  31908. private _wheelEventName;
  31909. private _onPointerMove;
  31910. private _onPointerDown;
  31911. private _onPointerUp;
  31912. private _initClickEvent;
  31913. private _initActionManager;
  31914. private _delayedSimpleClick;
  31915. private _delayedSimpleClickTimeout;
  31916. private _previousDelayedSimpleClickTimeout;
  31917. private _meshPickProceed;
  31918. private _previousButtonPressed;
  31919. private _currentPickResult;
  31920. private _previousPickResult;
  31921. private _totalPointersPressed;
  31922. private _doubleClickOccured;
  31923. private _pointerOverMesh;
  31924. private _pickedDownMesh;
  31925. private _pickedUpMesh;
  31926. private _pointerX;
  31927. private _pointerY;
  31928. private _unTranslatedPointerX;
  31929. private _unTranslatedPointerY;
  31930. private _startingPointerPosition;
  31931. private _previousStartingPointerPosition;
  31932. private _startingPointerTime;
  31933. private _previousStartingPointerTime;
  31934. private _pointerCaptures;
  31935. private _onKeyDown;
  31936. private _onKeyUp;
  31937. private _onCanvasFocusObserver;
  31938. private _onCanvasBlurObserver;
  31939. private _scene;
  31940. /**
  31941. * Creates a new InputManager
  31942. * @param scene defines the hosting scene
  31943. */
  31944. constructor(scene: Scene);
  31945. /**
  31946. * Gets the mesh that is currently under the pointer
  31947. */
  31948. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31949. /**
  31950. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31951. */
  31952. readonly unTranslatedPointer: Vector2;
  31953. /**
  31954. * Gets or sets the current on-screen X position of the pointer
  31955. */
  31956. pointerX: number;
  31957. /**
  31958. * Gets or sets the current on-screen Y position of the pointer
  31959. */
  31960. pointerY: number;
  31961. private _updatePointerPosition;
  31962. private _processPointerMove;
  31963. private _setRayOnPointerInfo;
  31964. private _checkPrePointerObservable;
  31965. /**
  31966. * Use this method to simulate a pointer move on a mesh
  31967. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31968. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31969. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31970. */
  31971. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31972. /**
  31973. * Use this method to simulate a pointer down on a mesh
  31974. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31975. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31976. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31977. */
  31978. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31979. private _processPointerDown;
  31980. /** @hidden */
  31981. _isPointerSwiping(): boolean;
  31982. /**
  31983. * Use this method to simulate a pointer up on a mesh
  31984. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31985. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31986. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31987. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31988. */
  31989. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31990. private _processPointerUp;
  31991. /**
  31992. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31993. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31994. * @returns true if the pointer was captured
  31995. */
  31996. isPointerCaptured(pointerId?: number): boolean;
  31997. /**
  31998. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31999. * @param attachUp defines if you want to attach events to pointerup
  32000. * @param attachDown defines if you want to attach events to pointerdown
  32001. * @param attachMove defines if you want to attach events to pointermove
  32002. */
  32003. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32004. /**
  32005. * Detaches all event handlers
  32006. */
  32007. detachControl(): void;
  32008. /**
  32009. * Force the value of meshUnderPointer
  32010. * @param mesh defines the mesh to use
  32011. */
  32012. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32013. /**
  32014. * Gets the mesh under the pointer
  32015. * @returns a Mesh or null if no mesh is under the pointer
  32016. */
  32017. getPointerOverMesh(): Nullable<AbstractMesh>;
  32018. }
  32019. }
  32020. declare module BABYLON {
  32021. /**
  32022. * This class defines the direct association between an animation and a target
  32023. */
  32024. export class TargetedAnimation {
  32025. /**
  32026. * Animation to perform
  32027. */
  32028. animation: Animation;
  32029. /**
  32030. * Target to animate
  32031. */
  32032. target: any;
  32033. /**
  32034. * Serialize the object
  32035. * @returns the JSON object representing the current entity
  32036. */
  32037. serialize(): any;
  32038. }
  32039. /**
  32040. * Use this class to create coordinated animations on multiple targets
  32041. */
  32042. export class AnimationGroup implements IDisposable {
  32043. /** The name of the animation group */
  32044. name: string;
  32045. private _scene;
  32046. private _targetedAnimations;
  32047. private _animatables;
  32048. private _from;
  32049. private _to;
  32050. private _isStarted;
  32051. private _isPaused;
  32052. private _speedRatio;
  32053. private _loopAnimation;
  32054. /**
  32055. * Gets or sets the unique id of the node
  32056. */
  32057. uniqueId: number;
  32058. /**
  32059. * This observable will notify when one animation have ended
  32060. */
  32061. onAnimationEndObservable: Observable<TargetedAnimation>;
  32062. /**
  32063. * Observer raised when one animation loops
  32064. */
  32065. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32066. /**
  32067. * This observable will notify when all animations have ended.
  32068. */
  32069. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32070. /**
  32071. * This observable will notify when all animations have paused.
  32072. */
  32073. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32074. /**
  32075. * This observable will notify when all animations are playing.
  32076. */
  32077. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32078. /**
  32079. * Gets the first frame
  32080. */
  32081. readonly from: number;
  32082. /**
  32083. * Gets the last frame
  32084. */
  32085. readonly to: number;
  32086. /**
  32087. * Define if the animations are started
  32088. */
  32089. readonly isStarted: boolean;
  32090. /**
  32091. * Gets a value indicating that the current group is playing
  32092. */
  32093. readonly isPlaying: boolean;
  32094. /**
  32095. * Gets or sets the speed ratio to use for all animations
  32096. */
  32097. /**
  32098. * Gets or sets the speed ratio to use for all animations
  32099. */
  32100. speedRatio: number;
  32101. /**
  32102. * Gets or sets if all animations should loop or not
  32103. */
  32104. loopAnimation: boolean;
  32105. /**
  32106. * Gets the targeted animations for this animation group
  32107. */
  32108. readonly targetedAnimations: Array<TargetedAnimation>;
  32109. /**
  32110. * returning the list of animatables controlled by this animation group.
  32111. */
  32112. readonly animatables: Array<Animatable>;
  32113. /**
  32114. * Instantiates a new Animation Group.
  32115. * This helps managing several animations at once.
  32116. * @see http://doc.babylonjs.com/how_to/group
  32117. * @param name Defines the name of the group
  32118. * @param scene Defines the scene the group belongs to
  32119. */
  32120. constructor(
  32121. /** The name of the animation group */
  32122. name: string, scene?: Nullable<Scene>);
  32123. /**
  32124. * Add an animation (with its target) in the group
  32125. * @param animation defines the animation we want to add
  32126. * @param target defines the target of the animation
  32127. * @returns the TargetedAnimation object
  32128. */
  32129. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32130. /**
  32131. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32132. * It can add constant keys at begin or end
  32133. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32134. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32135. * @returns the animation group
  32136. */
  32137. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32138. /**
  32139. * Start all animations on given targets
  32140. * @param loop defines if animations must loop
  32141. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32142. * @param from defines the from key (optional)
  32143. * @param to defines the to key (optional)
  32144. * @returns the current animation group
  32145. */
  32146. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32147. /**
  32148. * Pause all animations
  32149. * @returns the animation group
  32150. */
  32151. pause(): AnimationGroup;
  32152. /**
  32153. * Play all animations to initial state
  32154. * This function will start() the animations if they were not started or will restart() them if they were paused
  32155. * @param loop defines if animations must loop
  32156. * @returns the animation group
  32157. */
  32158. play(loop?: boolean): AnimationGroup;
  32159. /**
  32160. * Reset all animations to initial state
  32161. * @returns the animation group
  32162. */
  32163. reset(): AnimationGroup;
  32164. /**
  32165. * Restart animations from key 0
  32166. * @returns the animation group
  32167. */
  32168. restart(): AnimationGroup;
  32169. /**
  32170. * Stop all animations
  32171. * @returns the animation group
  32172. */
  32173. stop(): AnimationGroup;
  32174. /**
  32175. * Set animation weight for all animatables
  32176. * @param weight defines the weight to use
  32177. * @return the animationGroup
  32178. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32179. */
  32180. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32181. /**
  32182. * Synchronize and normalize all animatables with a source animatable
  32183. * @param root defines the root animatable to synchronize with
  32184. * @return the animationGroup
  32185. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32186. */
  32187. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32188. /**
  32189. * Goes to a specific frame in this animation group
  32190. * @param frame the frame number to go to
  32191. * @return the animationGroup
  32192. */
  32193. goToFrame(frame: number): AnimationGroup;
  32194. /**
  32195. * Dispose all associated resources
  32196. */
  32197. dispose(): void;
  32198. private _checkAnimationGroupEnded;
  32199. /**
  32200. * Clone the current animation group and returns a copy
  32201. * @param newName defines the name of the new group
  32202. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32203. * @returns the new aniamtion group
  32204. */
  32205. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32206. /**
  32207. * Serializes the animationGroup to an object
  32208. * @returns Serialized object
  32209. */
  32210. serialize(): any;
  32211. /**
  32212. * Returns a new AnimationGroup object parsed from the source provided.
  32213. * @param parsedAnimationGroup defines the source
  32214. * @param scene defines the scene that will receive the animationGroup
  32215. * @returns a new AnimationGroup
  32216. */
  32217. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32218. /**
  32219. * Returns the string "AnimationGroup"
  32220. * @returns "AnimationGroup"
  32221. */
  32222. getClassName(): string;
  32223. /**
  32224. * Creates a detailled string about the object
  32225. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32226. * @returns a string representing the object
  32227. */
  32228. toString(fullDetails?: boolean): string;
  32229. }
  32230. }
  32231. declare module BABYLON {
  32232. /**
  32233. * Define an interface for all classes that will hold resources
  32234. */
  32235. export interface IDisposable {
  32236. /**
  32237. * Releases all held resources
  32238. */
  32239. dispose(): void;
  32240. }
  32241. /** Interface defining initialization parameters for Scene class */
  32242. export interface SceneOptions {
  32243. /**
  32244. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32245. * It will improve performance when the number of geometries becomes important.
  32246. */
  32247. useGeometryUniqueIdsMap?: boolean;
  32248. /**
  32249. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32250. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32251. */
  32252. useMaterialMeshMap?: boolean;
  32253. /**
  32254. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32255. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32256. */
  32257. useClonedMeshhMap?: boolean;
  32258. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32259. virtual?: boolean;
  32260. }
  32261. /**
  32262. * Represents a scene to be rendered by the engine.
  32263. * @see http://doc.babylonjs.com/features/scene
  32264. */
  32265. export class Scene extends AbstractScene implements IAnimatable {
  32266. private static _uniqueIdCounter;
  32267. /** The fog is deactivated */
  32268. static readonly FOGMODE_NONE: number;
  32269. /** The fog density is following an exponential function */
  32270. static readonly FOGMODE_EXP: number;
  32271. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32272. static readonly FOGMODE_EXP2: number;
  32273. /** The fog density is following a linear function. */
  32274. static readonly FOGMODE_LINEAR: number;
  32275. /**
  32276. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32277. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32278. */
  32279. static MinDeltaTime: number;
  32280. /**
  32281. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32282. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32283. */
  32284. static MaxDeltaTime: number;
  32285. /**
  32286. * Factory used to create the default material.
  32287. * @param name The name of the material to create
  32288. * @param scene The scene to create the material for
  32289. * @returns The default material
  32290. */
  32291. static DefaultMaterialFactory(scene: Scene): Material;
  32292. /**
  32293. * Factory used to create the a collision coordinator.
  32294. * @returns The collision coordinator
  32295. */
  32296. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32297. /** @hidden */
  32298. _inputManager: InputManager;
  32299. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32300. cameraToUseForPointers: Nullable<Camera>;
  32301. /** @hidden */
  32302. readonly _isScene: boolean;
  32303. /**
  32304. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32305. */
  32306. autoClear: boolean;
  32307. /**
  32308. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32309. */
  32310. autoClearDepthAndStencil: boolean;
  32311. /**
  32312. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32313. */
  32314. clearColor: Color4;
  32315. /**
  32316. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32317. */
  32318. ambientColor: Color3;
  32319. /**
  32320. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32321. * It should only be one of the following (if not the default embedded one):
  32322. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32323. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32324. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32325. * The material properties need to be setup according to the type of texture in use.
  32326. */
  32327. environmentBRDFTexture: BaseTexture;
  32328. /** @hidden */
  32329. protected _environmentTexture: Nullable<BaseTexture>;
  32330. /**
  32331. * Texture used in all pbr material as the reflection texture.
  32332. * As in the majority of the scene they are the same (exception for multi room and so on),
  32333. * this is easier to reference from here than from all the materials.
  32334. */
  32335. /**
  32336. * Texture used in all pbr material as the reflection texture.
  32337. * As in the majority of the scene they are the same (exception for multi room and so on),
  32338. * this is easier to set here than in all the materials.
  32339. */
  32340. environmentTexture: Nullable<BaseTexture>;
  32341. /** @hidden */
  32342. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32343. /**
  32344. * Default image processing configuration used either in the rendering
  32345. * Forward main pass or through the imageProcessingPostProcess if present.
  32346. * As in the majority of the scene they are the same (exception for multi camera),
  32347. * this is easier to reference from here than from all the materials and post process.
  32348. *
  32349. * No setter as we it is a shared configuration, you can set the values instead.
  32350. */
  32351. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32352. private _forceWireframe;
  32353. /**
  32354. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32355. */
  32356. forceWireframe: boolean;
  32357. private _forcePointsCloud;
  32358. /**
  32359. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32360. */
  32361. forcePointsCloud: boolean;
  32362. /**
  32363. * Gets or sets the active clipplane 1
  32364. */
  32365. clipPlane: Nullable<Plane>;
  32366. /**
  32367. * Gets or sets the active clipplane 2
  32368. */
  32369. clipPlane2: Nullable<Plane>;
  32370. /**
  32371. * Gets or sets the active clipplane 3
  32372. */
  32373. clipPlane3: Nullable<Plane>;
  32374. /**
  32375. * Gets or sets the active clipplane 4
  32376. */
  32377. clipPlane4: Nullable<Plane>;
  32378. /**
  32379. * Gets or sets a boolean indicating if animations are enabled
  32380. */
  32381. animationsEnabled: boolean;
  32382. private _animationPropertiesOverride;
  32383. /**
  32384. * Gets or sets the animation properties override
  32385. */
  32386. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32387. /**
  32388. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32389. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32390. */
  32391. useConstantAnimationDeltaTime: boolean;
  32392. /**
  32393. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32394. * Please note that it requires to run a ray cast through the scene on every frame
  32395. */
  32396. constantlyUpdateMeshUnderPointer: boolean;
  32397. /**
  32398. * Defines the HTML cursor to use when hovering over interactive elements
  32399. */
  32400. hoverCursor: string;
  32401. /**
  32402. * Defines the HTML default cursor to use (empty by default)
  32403. */
  32404. defaultCursor: string;
  32405. /**
  32406. * This is used to call preventDefault() on pointer down
  32407. * in order to block unwanted artifacts like system double clicks
  32408. */
  32409. preventDefaultOnPointerDown: boolean;
  32410. /**
  32411. * This is used to call preventDefault() on pointer up
  32412. * in order to block unwanted artifacts like system double clicks
  32413. */
  32414. preventDefaultOnPointerUp: boolean;
  32415. /**
  32416. * Gets or sets user defined metadata
  32417. */
  32418. metadata: any;
  32419. /**
  32420. * For internal use only. Please do not use.
  32421. */
  32422. reservedDataStore: any;
  32423. /**
  32424. * Gets the name of the plugin used to load this scene (null by default)
  32425. */
  32426. loadingPluginName: string;
  32427. /**
  32428. * Use this array to add regular expressions used to disable offline support for specific urls
  32429. */
  32430. disableOfflineSupportExceptionRules: RegExp[];
  32431. /**
  32432. * An event triggered when the scene is disposed.
  32433. */
  32434. onDisposeObservable: Observable<Scene>;
  32435. private _onDisposeObserver;
  32436. /** Sets a function to be executed when this scene is disposed. */
  32437. onDispose: () => void;
  32438. /**
  32439. * An event triggered before rendering the scene (right after animations and physics)
  32440. */
  32441. onBeforeRenderObservable: Observable<Scene>;
  32442. private _onBeforeRenderObserver;
  32443. /** Sets a function to be executed before rendering this scene */
  32444. beforeRender: Nullable<() => void>;
  32445. /**
  32446. * An event triggered after rendering the scene
  32447. */
  32448. onAfterRenderObservable: Observable<Scene>;
  32449. /**
  32450. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32451. */
  32452. onAfterRenderCameraObservable: Observable<Camera>;
  32453. private _onAfterRenderObserver;
  32454. /** Sets a function to be executed after rendering this scene */
  32455. afterRender: Nullable<() => void>;
  32456. /**
  32457. * An event triggered before animating the scene
  32458. */
  32459. onBeforeAnimationsObservable: Observable<Scene>;
  32460. /**
  32461. * An event triggered after animations processing
  32462. */
  32463. onAfterAnimationsObservable: Observable<Scene>;
  32464. /**
  32465. * An event triggered before draw calls are ready to be sent
  32466. */
  32467. onBeforeDrawPhaseObservable: Observable<Scene>;
  32468. /**
  32469. * An event triggered after draw calls have been sent
  32470. */
  32471. onAfterDrawPhaseObservable: Observable<Scene>;
  32472. /**
  32473. * An event triggered when the scene is ready
  32474. */
  32475. onReadyObservable: Observable<Scene>;
  32476. /**
  32477. * An event triggered before rendering a camera
  32478. */
  32479. onBeforeCameraRenderObservable: Observable<Camera>;
  32480. private _onBeforeCameraRenderObserver;
  32481. /** Sets a function to be executed before rendering a camera*/
  32482. beforeCameraRender: () => void;
  32483. /**
  32484. * An event triggered after rendering a camera
  32485. */
  32486. onAfterCameraRenderObservable: Observable<Camera>;
  32487. private _onAfterCameraRenderObserver;
  32488. /** Sets a function to be executed after rendering a camera*/
  32489. afterCameraRender: () => void;
  32490. /**
  32491. * An event triggered when active meshes evaluation is about to start
  32492. */
  32493. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32494. /**
  32495. * An event triggered when active meshes evaluation is done
  32496. */
  32497. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32498. /**
  32499. * An event triggered when particles rendering is about to start
  32500. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32501. */
  32502. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32503. /**
  32504. * An event triggered when particles rendering is done
  32505. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32506. */
  32507. onAfterParticlesRenderingObservable: Observable<Scene>;
  32508. /**
  32509. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32510. */
  32511. onDataLoadedObservable: Observable<Scene>;
  32512. /**
  32513. * An event triggered when a camera is created
  32514. */
  32515. onNewCameraAddedObservable: Observable<Camera>;
  32516. /**
  32517. * An event triggered when a camera is removed
  32518. */
  32519. onCameraRemovedObservable: Observable<Camera>;
  32520. /**
  32521. * An event triggered when a light is created
  32522. */
  32523. onNewLightAddedObservable: Observable<Light>;
  32524. /**
  32525. * An event triggered when a light is removed
  32526. */
  32527. onLightRemovedObservable: Observable<Light>;
  32528. /**
  32529. * An event triggered when a geometry is created
  32530. */
  32531. onNewGeometryAddedObservable: Observable<Geometry>;
  32532. /**
  32533. * An event triggered when a geometry is removed
  32534. */
  32535. onGeometryRemovedObservable: Observable<Geometry>;
  32536. /**
  32537. * An event triggered when a transform node is created
  32538. */
  32539. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32540. /**
  32541. * An event triggered when a transform node is removed
  32542. */
  32543. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32544. /**
  32545. * An event triggered when a mesh is created
  32546. */
  32547. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32548. /**
  32549. * An event triggered when a mesh is removed
  32550. */
  32551. onMeshRemovedObservable: Observable<AbstractMesh>;
  32552. /**
  32553. * An event triggered when a skeleton is created
  32554. */
  32555. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32556. /**
  32557. * An event triggered when a skeleton is removed
  32558. */
  32559. onSkeletonRemovedObservable: Observable<Skeleton>;
  32560. /**
  32561. * An event triggered when a material is created
  32562. */
  32563. onNewMaterialAddedObservable: Observable<Material>;
  32564. /**
  32565. * An event triggered when a material is removed
  32566. */
  32567. onMaterialRemovedObservable: Observable<Material>;
  32568. /**
  32569. * An event triggered when a texture is created
  32570. */
  32571. onNewTextureAddedObservable: Observable<BaseTexture>;
  32572. /**
  32573. * An event triggered when a texture is removed
  32574. */
  32575. onTextureRemovedObservable: Observable<BaseTexture>;
  32576. /**
  32577. * An event triggered when render targets are about to be rendered
  32578. * Can happen multiple times per frame.
  32579. */
  32580. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32581. /**
  32582. * An event triggered when render targets were rendered.
  32583. * Can happen multiple times per frame.
  32584. */
  32585. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32586. /**
  32587. * An event triggered before calculating deterministic simulation step
  32588. */
  32589. onBeforeStepObservable: Observable<Scene>;
  32590. /**
  32591. * An event triggered after calculating deterministic simulation step
  32592. */
  32593. onAfterStepObservable: Observable<Scene>;
  32594. /**
  32595. * An event triggered when the activeCamera property is updated
  32596. */
  32597. onActiveCameraChanged: Observable<Scene>;
  32598. /**
  32599. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32600. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32601. * 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)
  32602. */
  32603. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32604. /**
  32605. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32606. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32607. * 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)
  32608. */
  32609. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32610. /**
  32611. * This Observable will when a mesh has been imported into the scene.
  32612. */
  32613. onMeshImportedObservable: Observable<AbstractMesh>;
  32614. /**
  32615. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32616. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32617. */
  32618. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32619. /** @hidden */
  32620. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32621. /**
  32622. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32623. */
  32624. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32625. /**
  32626. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32627. */
  32628. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32629. /**
  32630. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32631. */
  32632. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32633. /** Callback called when a pointer move is detected */
  32634. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32635. /** Callback called when a pointer down is detected */
  32636. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32637. /** Callback called when a pointer up is detected */
  32638. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32639. /** Callback called when a pointer pick is detected */
  32640. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32641. /**
  32642. * 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).
  32643. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32644. */
  32645. onPrePointerObservable: Observable<PointerInfoPre>;
  32646. /**
  32647. * Observable event triggered each time an input event is received from the rendering canvas
  32648. */
  32649. onPointerObservable: Observable<PointerInfo>;
  32650. /**
  32651. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32652. */
  32653. readonly unTranslatedPointer: Vector2;
  32654. /**
  32655. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32656. */
  32657. static DragMovementThreshold: number;
  32658. /**
  32659. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32660. */
  32661. static LongPressDelay: number;
  32662. /**
  32663. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32664. */
  32665. static DoubleClickDelay: number;
  32666. /** If you need to check double click without raising a single click at first click, enable this flag */
  32667. static ExclusiveDoubleClickMode: boolean;
  32668. /** @hidden */
  32669. _mirroredCameraPosition: Nullable<Vector3>;
  32670. /**
  32671. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32672. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32673. */
  32674. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32675. /**
  32676. * Observable event triggered each time an keyboard event is received from the hosting window
  32677. */
  32678. onKeyboardObservable: Observable<KeyboardInfo>;
  32679. private _useRightHandedSystem;
  32680. /**
  32681. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32682. */
  32683. useRightHandedSystem: boolean;
  32684. private _timeAccumulator;
  32685. private _currentStepId;
  32686. private _currentInternalStep;
  32687. /**
  32688. * Sets the step Id used by deterministic lock step
  32689. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32690. * @param newStepId defines the step Id
  32691. */
  32692. setStepId(newStepId: number): void;
  32693. /**
  32694. * Gets the step Id used by deterministic lock step
  32695. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32696. * @returns the step Id
  32697. */
  32698. getStepId(): number;
  32699. /**
  32700. * Gets the internal step used by deterministic lock step
  32701. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32702. * @returns the internal step
  32703. */
  32704. getInternalStep(): number;
  32705. private _fogEnabled;
  32706. /**
  32707. * Gets or sets a boolean indicating if fog is enabled on this scene
  32708. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32709. * (Default is true)
  32710. */
  32711. fogEnabled: boolean;
  32712. private _fogMode;
  32713. /**
  32714. * Gets or sets the fog mode to use
  32715. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32716. * | mode | value |
  32717. * | --- | --- |
  32718. * | FOGMODE_NONE | 0 |
  32719. * | FOGMODE_EXP | 1 |
  32720. * | FOGMODE_EXP2 | 2 |
  32721. * | FOGMODE_LINEAR | 3 |
  32722. */
  32723. fogMode: number;
  32724. /**
  32725. * Gets or sets the fog color to use
  32726. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32727. * (Default is Color3(0.2, 0.2, 0.3))
  32728. */
  32729. fogColor: Color3;
  32730. /**
  32731. * Gets or sets the fog density to use
  32732. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32733. * (Default is 0.1)
  32734. */
  32735. fogDensity: number;
  32736. /**
  32737. * Gets or sets the fog start distance to use
  32738. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32739. * (Default is 0)
  32740. */
  32741. fogStart: number;
  32742. /**
  32743. * Gets or sets the fog end distance to use
  32744. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32745. * (Default is 1000)
  32746. */
  32747. fogEnd: number;
  32748. private _shadowsEnabled;
  32749. /**
  32750. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32751. */
  32752. shadowsEnabled: boolean;
  32753. private _lightsEnabled;
  32754. /**
  32755. * Gets or sets a boolean indicating if lights are enabled on this scene
  32756. */
  32757. lightsEnabled: boolean;
  32758. /** All of the active cameras added to this scene. */
  32759. activeCameras: Camera[];
  32760. /** @hidden */
  32761. _activeCamera: Nullable<Camera>;
  32762. /** Gets or sets the current active camera */
  32763. activeCamera: Nullable<Camera>;
  32764. private _defaultMaterial;
  32765. /** The default material used on meshes when no material is affected */
  32766. /** The default material used on meshes when no material is affected */
  32767. defaultMaterial: Material;
  32768. private _texturesEnabled;
  32769. /**
  32770. * Gets or sets a boolean indicating if textures are enabled on this scene
  32771. */
  32772. texturesEnabled: boolean;
  32773. /**
  32774. * Gets or sets a boolean indicating if particles are enabled on this scene
  32775. */
  32776. particlesEnabled: boolean;
  32777. /**
  32778. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32779. */
  32780. spritesEnabled: boolean;
  32781. private _skeletonsEnabled;
  32782. /**
  32783. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32784. */
  32785. skeletonsEnabled: boolean;
  32786. /**
  32787. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32788. */
  32789. lensFlaresEnabled: boolean;
  32790. /**
  32791. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32792. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32793. */
  32794. collisionsEnabled: boolean;
  32795. private _collisionCoordinator;
  32796. /** @hidden */
  32797. readonly collisionCoordinator: ICollisionCoordinator;
  32798. /**
  32799. * Defines the gravity applied to this scene (used only for collisions)
  32800. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32801. */
  32802. gravity: Vector3;
  32803. /**
  32804. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32805. */
  32806. postProcessesEnabled: boolean;
  32807. /**
  32808. * The list of postprocesses added to the scene
  32809. */
  32810. postProcesses: PostProcess[];
  32811. /**
  32812. * Gets the current postprocess manager
  32813. */
  32814. postProcessManager: PostProcessManager;
  32815. /**
  32816. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32817. */
  32818. renderTargetsEnabled: boolean;
  32819. /**
  32820. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32821. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32822. */
  32823. dumpNextRenderTargets: boolean;
  32824. /**
  32825. * The list of user defined render targets added to the scene
  32826. */
  32827. customRenderTargets: RenderTargetTexture[];
  32828. /**
  32829. * Defines if texture loading must be delayed
  32830. * If true, textures will only be loaded when they need to be rendered
  32831. */
  32832. useDelayedTextureLoading: boolean;
  32833. /**
  32834. * Gets the list of meshes imported to the scene through SceneLoader
  32835. */
  32836. importedMeshesFiles: String[];
  32837. /**
  32838. * Gets or sets a boolean indicating if probes are enabled on this scene
  32839. */
  32840. probesEnabled: boolean;
  32841. /**
  32842. * Gets or sets the current offline provider to use to store scene data
  32843. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32844. */
  32845. offlineProvider: IOfflineProvider;
  32846. /**
  32847. * Gets or sets the action manager associated with the scene
  32848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32849. */
  32850. actionManager: AbstractActionManager;
  32851. private _meshesForIntersections;
  32852. /**
  32853. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32854. */
  32855. proceduralTexturesEnabled: boolean;
  32856. private _engine;
  32857. private _totalVertices;
  32858. /** @hidden */
  32859. _activeIndices: PerfCounter;
  32860. /** @hidden */
  32861. _activeParticles: PerfCounter;
  32862. /** @hidden */
  32863. _activeBones: PerfCounter;
  32864. private _animationRatio;
  32865. /** @hidden */
  32866. _animationTimeLast: number;
  32867. /** @hidden */
  32868. _animationTime: number;
  32869. /**
  32870. * Gets or sets a general scale for animation speed
  32871. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32872. */
  32873. animationTimeScale: number;
  32874. /** @hidden */
  32875. _cachedMaterial: Nullable<Material>;
  32876. /** @hidden */
  32877. _cachedEffect: Nullable<Effect>;
  32878. /** @hidden */
  32879. _cachedVisibility: Nullable<number>;
  32880. private _renderId;
  32881. private _frameId;
  32882. private _executeWhenReadyTimeoutId;
  32883. private _intermediateRendering;
  32884. private _viewUpdateFlag;
  32885. private _projectionUpdateFlag;
  32886. /** @hidden */
  32887. _toBeDisposed: Nullable<IDisposable>[];
  32888. private _activeRequests;
  32889. /** @hidden */
  32890. _pendingData: any[];
  32891. private _isDisposed;
  32892. /**
  32893. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32894. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32895. */
  32896. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32897. private _activeMeshes;
  32898. private _processedMaterials;
  32899. private _renderTargets;
  32900. /** @hidden */
  32901. _activeParticleSystems: SmartArray<IParticleSystem>;
  32902. private _activeSkeletons;
  32903. private _softwareSkinnedMeshes;
  32904. private _renderingManager;
  32905. /** @hidden */
  32906. _activeAnimatables: Animatable[];
  32907. private _transformMatrix;
  32908. private _sceneUbo;
  32909. /** @hidden */
  32910. _viewMatrix: Matrix;
  32911. private _projectionMatrix;
  32912. /** @hidden */
  32913. _forcedViewPosition: Nullable<Vector3>;
  32914. /** @hidden */
  32915. _frustumPlanes: Plane[];
  32916. /**
  32917. * Gets the list of frustum planes (built from the active camera)
  32918. */
  32919. readonly frustumPlanes: Plane[];
  32920. /**
  32921. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32922. * This is useful if there are more lights that the maximum simulteanous authorized
  32923. */
  32924. requireLightSorting: boolean;
  32925. /** @hidden */
  32926. readonly useMaterialMeshMap: boolean;
  32927. /** @hidden */
  32928. readonly useClonedMeshhMap: boolean;
  32929. private _externalData;
  32930. private _uid;
  32931. /**
  32932. * @hidden
  32933. * Backing store of defined scene components.
  32934. */
  32935. _components: ISceneComponent[];
  32936. /**
  32937. * @hidden
  32938. * Backing store of defined scene components.
  32939. */
  32940. _serializableComponents: ISceneSerializableComponent[];
  32941. /**
  32942. * List of components to register on the next registration step.
  32943. */
  32944. private _transientComponents;
  32945. /**
  32946. * Registers the transient components if needed.
  32947. */
  32948. private _registerTransientComponents;
  32949. /**
  32950. * @hidden
  32951. * Add a component to the scene.
  32952. * Note that the ccomponent could be registered on th next frame if this is called after
  32953. * the register component stage.
  32954. * @param component Defines the component to add to the scene
  32955. */
  32956. _addComponent(component: ISceneComponent): void;
  32957. /**
  32958. * @hidden
  32959. * Gets a component from the scene.
  32960. * @param name defines the name of the component to retrieve
  32961. * @returns the component or null if not present
  32962. */
  32963. _getComponent(name: string): Nullable<ISceneComponent>;
  32964. /**
  32965. * @hidden
  32966. * Defines the actions happening before camera updates.
  32967. */
  32968. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32969. /**
  32970. * @hidden
  32971. * Defines the actions happening before clear the canvas.
  32972. */
  32973. _beforeClearStage: Stage<SimpleStageAction>;
  32974. /**
  32975. * @hidden
  32976. * Defines the actions when collecting render targets for the frame.
  32977. */
  32978. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32979. /**
  32980. * @hidden
  32981. * Defines the actions happening for one camera in the frame.
  32982. */
  32983. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32984. /**
  32985. * @hidden
  32986. * Defines the actions happening during the per mesh ready checks.
  32987. */
  32988. _isReadyForMeshStage: Stage<MeshStageAction>;
  32989. /**
  32990. * @hidden
  32991. * Defines the actions happening before evaluate active mesh checks.
  32992. */
  32993. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32994. /**
  32995. * @hidden
  32996. * Defines the actions happening during the evaluate sub mesh checks.
  32997. */
  32998. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32999. /**
  33000. * @hidden
  33001. * Defines the actions happening during the active mesh stage.
  33002. */
  33003. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33004. /**
  33005. * @hidden
  33006. * Defines the actions happening during the per camera render target step.
  33007. */
  33008. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33009. /**
  33010. * @hidden
  33011. * Defines the actions happening just before the active camera is drawing.
  33012. */
  33013. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33014. /**
  33015. * @hidden
  33016. * Defines the actions happening just before a render target is drawing.
  33017. */
  33018. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33019. /**
  33020. * @hidden
  33021. * Defines the actions happening just before a rendering group is drawing.
  33022. */
  33023. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33024. /**
  33025. * @hidden
  33026. * Defines the actions happening just before a mesh is drawing.
  33027. */
  33028. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33029. /**
  33030. * @hidden
  33031. * Defines the actions happening just after a mesh has been drawn.
  33032. */
  33033. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33034. /**
  33035. * @hidden
  33036. * Defines the actions happening just after a rendering group has been drawn.
  33037. */
  33038. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33039. /**
  33040. * @hidden
  33041. * Defines the actions happening just after the active camera has been drawn.
  33042. */
  33043. _afterCameraDrawStage: Stage<CameraStageAction>;
  33044. /**
  33045. * @hidden
  33046. * Defines the actions happening just after a render target has been drawn.
  33047. */
  33048. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33049. /**
  33050. * @hidden
  33051. * Defines the actions happening just after rendering all cameras and computing intersections.
  33052. */
  33053. _afterRenderStage: Stage<SimpleStageAction>;
  33054. /**
  33055. * @hidden
  33056. * Defines the actions happening when a pointer move event happens.
  33057. */
  33058. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33059. /**
  33060. * @hidden
  33061. * Defines the actions happening when a pointer down event happens.
  33062. */
  33063. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33064. /**
  33065. * @hidden
  33066. * Defines the actions happening when a pointer up event happens.
  33067. */
  33068. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33069. /**
  33070. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33071. */
  33072. private geometriesByUniqueId;
  33073. /**
  33074. * Creates a new Scene
  33075. * @param engine defines the engine to use to render this scene
  33076. * @param options defines the scene options
  33077. */
  33078. constructor(engine: Engine, options?: SceneOptions);
  33079. /**
  33080. * Gets a string idenfifying the name of the class
  33081. * @returns "Scene" string
  33082. */
  33083. getClassName(): string;
  33084. private _defaultMeshCandidates;
  33085. /**
  33086. * @hidden
  33087. */
  33088. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33089. private _defaultSubMeshCandidates;
  33090. /**
  33091. * @hidden
  33092. */
  33093. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33094. /**
  33095. * Sets the default candidate providers for the scene.
  33096. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33097. * and getCollidingSubMeshCandidates to their default function
  33098. */
  33099. setDefaultCandidateProviders(): void;
  33100. /**
  33101. * Gets the mesh that is currently under the pointer
  33102. */
  33103. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33104. /**
  33105. * Gets or sets the current on-screen X position of the pointer
  33106. */
  33107. pointerX: number;
  33108. /**
  33109. * Gets or sets the current on-screen Y position of the pointer
  33110. */
  33111. pointerY: number;
  33112. /**
  33113. * Gets the cached material (ie. the latest rendered one)
  33114. * @returns the cached material
  33115. */
  33116. getCachedMaterial(): Nullable<Material>;
  33117. /**
  33118. * Gets the cached effect (ie. the latest rendered one)
  33119. * @returns the cached effect
  33120. */
  33121. getCachedEffect(): Nullable<Effect>;
  33122. /**
  33123. * Gets the cached visibility state (ie. the latest rendered one)
  33124. * @returns the cached visibility state
  33125. */
  33126. getCachedVisibility(): Nullable<number>;
  33127. /**
  33128. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33129. * @param material defines the current material
  33130. * @param effect defines the current effect
  33131. * @param visibility defines the current visibility state
  33132. * @returns true if one parameter is not cached
  33133. */
  33134. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33135. /**
  33136. * Gets the engine associated with the scene
  33137. * @returns an Engine
  33138. */
  33139. getEngine(): Engine;
  33140. /**
  33141. * Gets the total number of vertices rendered per frame
  33142. * @returns the total number of vertices rendered per frame
  33143. */
  33144. getTotalVertices(): number;
  33145. /**
  33146. * Gets the performance counter for total vertices
  33147. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33148. */
  33149. readonly totalVerticesPerfCounter: PerfCounter;
  33150. /**
  33151. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33152. * @returns the total number of active indices rendered per frame
  33153. */
  33154. getActiveIndices(): number;
  33155. /**
  33156. * Gets the performance counter for active indices
  33157. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33158. */
  33159. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33160. /**
  33161. * Gets the total number of active particles rendered per frame
  33162. * @returns the total number of active particles rendered per frame
  33163. */
  33164. getActiveParticles(): number;
  33165. /**
  33166. * Gets the performance counter for active particles
  33167. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33168. */
  33169. readonly activeParticlesPerfCounter: PerfCounter;
  33170. /**
  33171. * Gets the total number of active bones rendered per frame
  33172. * @returns the total number of active bones rendered per frame
  33173. */
  33174. getActiveBones(): number;
  33175. /**
  33176. * Gets the performance counter for active bones
  33177. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33178. */
  33179. readonly activeBonesPerfCounter: PerfCounter;
  33180. /**
  33181. * Gets the array of active meshes
  33182. * @returns an array of AbstractMesh
  33183. */
  33184. getActiveMeshes(): SmartArray<AbstractMesh>;
  33185. /**
  33186. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33187. * @returns a number
  33188. */
  33189. getAnimationRatio(): number;
  33190. /**
  33191. * Gets an unique Id for the current render phase
  33192. * @returns a number
  33193. */
  33194. getRenderId(): number;
  33195. /**
  33196. * Gets an unique Id for the current frame
  33197. * @returns a number
  33198. */
  33199. getFrameId(): number;
  33200. /** Call this function if you want to manually increment the render Id*/
  33201. incrementRenderId(): void;
  33202. private _createUbo;
  33203. /**
  33204. * Use this method to simulate a pointer move on a mesh
  33205. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33206. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33207. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33208. * @returns the current scene
  33209. */
  33210. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33211. /**
  33212. * Use this method to simulate a pointer down on a mesh
  33213. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33214. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33215. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33216. * @returns the current scene
  33217. */
  33218. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33219. /**
  33220. * Use this method to simulate a pointer up on a mesh
  33221. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33222. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33223. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33224. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33225. * @returns the current scene
  33226. */
  33227. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33228. /**
  33229. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33230. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33231. * @returns true if the pointer was captured
  33232. */
  33233. isPointerCaptured(pointerId?: number): boolean;
  33234. /**
  33235. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33236. * @param attachUp defines if you want to attach events to pointerup
  33237. * @param attachDown defines if you want to attach events to pointerdown
  33238. * @param attachMove defines if you want to attach events to pointermove
  33239. */
  33240. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33241. /** Detaches all event handlers*/
  33242. detachControl(): void;
  33243. /**
  33244. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33245. * Delay loaded resources are not taking in account
  33246. * @return true if all required resources are ready
  33247. */
  33248. isReady(): boolean;
  33249. /** Resets all cached information relative to material (including effect and visibility) */
  33250. resetCachedMaterial(): void;
  33251. /**
  33252. * Registers a function to be called before every frame render
  33253. * @param func defines the function to register
  33254. */
  33255. registerBeforeRender(func: () => void): void;
  33256. /**
  33257. * Unregisters a function called before every frame render
  33258. * @param func defines the function to unregister
  33259. */
  33260. unregisterBeforeRender(func: () => void): void;
  33261. /**
  33262. * Registers a function to be called after every frame render
  33263. * @param func defines the function to register
  33264. */
  33265. registerAfterRender(func: () => void): void;
  33266. /**
  33267. * Unregisters a function called after every frame render
  33268. * @param func defines the function to unregister
  33269. */
  33270. unregisterAfterRender(func: () => void): void;
  33271. private _executeOnceBeforeRender;
  33272. /**
  33273. * The provided function will run before render once and will be disposed afterwards.
  33274. * A timeout delay can be provided so that the function will be executed in N ms.
  33275. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33276. * @param func The function to be executed.
  33277. * @param timeout optional delay in ms
  33278. */
  33279. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33280. /** @hidden */
  33281. _addPendingData(data: any): void;
  33282. /** @hidden */
  33283. _removePendingData(data: any): void;
  33284. /**
  33285. * Returns the number of items waiting to be loaded
  33286. * @returns the number of items waiting to be loaded
  33287. */
  33288. getWaitingItemsCount(): number;
  33289. /**
  33290. * Returns a boolean indicating if the scene is still loading data
  33291. */
  33292. readonly isLoading: boolean;
  33293. /**
  33294. * Registers a function to be executed when the scene is ready
  33295. * @param {Function} func - the function to be executed
  33296. */
  33297. executeWhenReady(func: () => void): void;
  33298. /**
  33299. * Returns a promise that resolves when the scene is ready
  33300. * @returns A promise that resolves when the scene is ready
  33301. */
  33302. whenReadyAsync(): Promise<void>;
  33303. /** @hidden */
  33304. _checkIsReady(): void;
  33305. /**
  33306. * Gets all animatable attached to the scene
  33307. */
  33308. readonly animatables: Animatable[];
  33309. /**
  33310. * Resets the last animation time frame.
  33311. * Useful to override when animations start running when loading a scene for the first time.
  33312. */
  33313. resetLastAnimationTimeFrame(): void;
  33314. /**
  33315. * Gets the current view matrix
  33316. * @returns a Matrix
  33317. */
  33318. getViewMatrix(): Matrix;
  33319. /**
  33320. * Gets the current projection matrix
  33321. * @returns a Matrix
  33322. */
  33323. getProjectionMatrix(): Matrix;
  33324. /**
  33325. * Gets the current transform matrix
  33326. * @returns a Matrix made of View * Projection
  33327. */
  33328. getTransformMatrix(): Matrix;
  33329. /**
  33330. * Sets the current transform matrix
  33331. * @param viewL defines the View matrix to use
  33332. * @param projectionL defines the Projection matrix to use
  33333. * @param viewR defines the right View matrix to use (if provided)
  33334. * @param projectionR defines the right Projection matrix to use (if provided)
  33335. */
  33336. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33337. /**
  33338. * Gets the uniform buffer used to store scene data
  33339. * @returns a UniformBuffer
  33340. */
  33341. getSceneUniformBuffer(): UniformBuffer;
  33342. /**
  33343. * Gets an unique (relatively to the current scene) Id
  33344. * @returns an unique number for the scene
  33345. */
  33346. getUniqueId(): number;
  33347. /**
  33348. * Add a mesh to the list of scene's meshes
  33349. * @param newMesh defines the mesh to add
  33350. * @param recursive if all child meshes should also be added to the scene
  33351. */
  33352. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33353. /**
  33354. * Remove a mesh for the list of scene's meshes
  33355. * @param toRemove defines the mesh to remove
  33356. * @param recursive if all child meshes should also be removed from the scene
  33357. * @returns the index where the mesh was in the mesh list
  33358. */
  33359. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33360. /**
  33361. * Add a transform node to the list of scene's transform nodes
  33362. * @param newTransformNode defines the transform node to add
  33363. */
  33364. addTransformNode(newTransformNode: TransformNode): void;
  33365. /**
  33366. * Remove a transform node for the list of scene's transform nodes
  33367. * @param toRemove defines the transform node to remove
  33368. * @returns the index where the transform node was in the transform node list
  33369. */
  33370. removeTransformNode(toRemove: TransformNode): number;
  33371. /**
  33372. * Remove a skeleton for the list of scene's skeletons
  33373. * @param toRemove defines the skeleton to remove
  33374. * @returns the index where the skeleton was in the skeleton list
  33375. */
  33376. removeSkeleton(toRemove: Skeleton): number;
  33377. /**
  33378. * Remove a morph target for the list of scene's morph targets
  33379. * @param toRemove defines the morph target to remove
  33380. * @returns the index where the morph target was in the morph target list
  33381. */
  33382. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33383. /**
  33384. * Remove a light for the list of scene's lights
  33385. * @param toRemove defines the light to remove
  33386. * @returns the index where the light was in the light list
  33387. */
  33388. removeLight(toRemove: Light): number;
  33389. /**
  33390. * Remove a camera for the list of scene's cameras
  33391. * @param toRemove defines the camera to remove
  33392. * @returns the index where the camera was in the camera list
  33393. */
  33394. removeCamera(toRemove: Camera): number;
  33395. /**
  33396. * Remove a particle system for the list of scene's particle systems
  33397. * @param toRemove defines the particle system to remove
  33398. * @returns the index where the particle system was in the particle system list
  33399. */
  33400. removeParticleSystem(toRemove: IParticleSystem): number;
  33401. /**
  33402. * Remove a animation for the list of scene's animations
  33403. * @param toRemove defines the animation to remove
  33404. * @returns the index where the animation was in the animation list
  33405. */
  33406. removeAnimation(toRemove: Animation): number;
  33407. /**
  33408. * Will stop the animation of the given target
  33409. * @param target - the target
  33410. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33411. * @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)
  33412. */
  33413. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33414. /**
  33415. * Removes the given animation group from this scene.
  33416. * @param toRemove The animation group to remove
  33417. * @returns The index of the removed animation group
  33418. */
  33419. removeAnimationGroup(toRemove: AnimationGroup): number;
  33420. /**
  33421. * Removes the given multi-material from this scene.
  33422. * @param toRemove The multi-material to remove
  33423. * @returns The index of the removed multi-material
  33424. */
  33425. removeMultiMaterial(toRemove: MultiMaterial): number;
  33426. /**
  33427. * Removes the given material from this scene.
  33428. * @param toRemove The material to remove
  33429. * @returns The index of the removed material
  33430. */
  33431. removeMaterial(toRemove: Material): number;
  33432. /**
  33433. * Removes the given action manager from this scene.
  33434. * @param toRemove The action manager to remove
  33435. * @returns The index of the removed action manager
  33436. */
  33437. removeActionManager(toRemove: AbstractActionManager): number;
  33438. /**
  33439. * Removes the given texture from this scene.
  33440. * @param toRemove The texture to remove
  33441. * @returns The index of the removed texture
  33442. */
  33443. removeTexture(toRemove: BaseTexture): number;
  33444. /**
  33445. * Adds the given light to this scene
  33446. * @param newLight The light to add
  33447. */
  33448. addLight(newLight: Light): void;
  33449. /**
  33450. * Sorts the list list based on light priorities
  33451. */
  33452. sortLightsByPriority(): void;
  33453. /**
  33454. * Adds the given camera to this scene
  33455. * @param newCamera The camera to add
  33456. */
  33457. addCamera(newCamera: Camera): void;
  33458. /**
  33459. * Adds the given skeleton to this scene
  33460. * @param newSkeleton The skeleton to add
  33461. */
  33462. addSkeleton(newSkeleton: Skeleton): void;
  33463. /**
  33464. * Adds the given particle system to this scene
  33465. * @param newParticleSystem The particle system to add
  33466. */
  33467. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33468. /**
  33469. * Adds the given animation to this scene
  33470. * @param newAnimation The animation to add
  33471. */
  33472. addAnimation(newAnimation: Animation): void;
  33473. /**
  33474. * Adds the given animation group to this scene.
  33475. * @param newAnimationGroup The animation group to add
  33476. */
  33477. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33478. /**
  33479. * Adds the given multi-material to this scene
  33480. * @param newMultiMaterial The multi-material to add
  33481. */
  33482. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33483. /**
  33484. * Adds the given material to this scene
  33485. * @param newMaterial The material to add
  33486. */
  33487. addMaterial(newMaterial: Material): void;
  33488. /**
  33489. * Adds the given morph target to this scene
  33490. * @param newMorphTargetManager The morph target to add
  33491. */
  33492. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33493. /**
  33494. * Adds the given geometry to this scene
  33495. * @param newGeometry The geometry to add
  33496. */
  33497. addGeometry(newGeometry: Geometry): void;
  33498. /**
  33499. * Adds the given action manager to this scene
  33500. * @param newActionManager The action manager to add
  33501. */
  33502. addActionManager(newActionManager: AbstractActionManager): void;
  33503. /**
  33504. * Adds the given texture to this scene.
  33505. * @param newTexture The texture to add
  33506. */
  33507. addTexture(newTexture: BaseTexture): void;
  33508. /**
  33509. * Switch active camera
  33510. * @param newCamera defines the new active camera
  33511. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33512. */
  33513. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33514. /**
  33515. * sets the active camera of the scene using its ID
  33516. * @param id defines the camera's ID
  33517. * @return the new active camera or null if none found.
  33518. */
  33519. setActiveCameraByID(id: string): Nullable<Camera>;
  33520. /**
  33521. * sets the active camera of the scene using its name
  33522. * @param name defines the camera's name
  33523. * @returns the new active camera or null if none found.
  33524. */
  33525. setActiveCameraByName(name: string): Nullable<Camera>;
  33526. /**
  33527. * get an animation group using its name
  33528. * @param name defines the material's name
  33529. * @return the animation group or null if none found.
  33530. */
  33531. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33532. /**
  33533. * Get a material using its unique id
  33534. * @param uniqueId defines the material's unique id
  33535. * @return the material or null if none found.
  33536. */
  33537. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33538. /**
  33539. * get a material using its id
  33540. * @param id defines the material's ID
  33541. * @return the material or null if none found.
  33542. */
  33543. getMaterialByID(id: string): Nullable<Material>;
  33544. /**
  33545. * Gets a material using its name
  33546. * @param name defines the material's name
  33547. * @return the material or null if none found.
  33548. */
  33549. getMaterialByName(name: string): Nullable<Material>;
  33550. /**
  33551. * Gets a camera using its id
  33552. * @param id defines the id to look for
  33553. * @returns the camera or null if not found
  33554. */
  33555. getCameraByID(id: string): Nullable<Camera>;
  33556. /**
  33557. * Gets a camera using its unique id
  33558. * @param uniqueId defines the unique id to look for
  33559. * @returns the camera or null if not found
  33560. */
  33561. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33562. /**
  33563. * Gets a camera using its name
  33564. * @param name defines the camera's name
  33565. * @return the camera or null if none found.
  33566. */
  33567. getCameraByName(name: string): Nullable<Camera>;
  33568. /**
  33569. * Gets a bone using its id
  33570. * @param id defines the bone's id
  33571. * @return the bone or null if not found
  33572. */
  33573. getBoneByID(id: string): Nullable<Bone>;
  33574. /**
  33575. * Gets a bone using its id
  33576. * @param name defines the bone's name
  33577. * @return the bone or null if not found
  33578. */
  33579. getBoneByName(name: string): Nullable<Bone>;
  33580. /**
  33581. * Gets a light node using its name
  33582. * @param name defines the the light's name
  33583. * @return the light or null if none found.
  33584. */
  33585. getLightByName(name: string): Nullable<Light>;
  33586. /**
  33587. * Gets a light node using its id
  33588. * @param id defines the light's id
  33589. * @return the light or null if none found.
  33590. */
  33591. getLightByID(id: string): Nullable<Light>;
  33592. /**
  33593. * Gets a light node using its scene-generated unique ID
  33594. * @param uniqueId defines the light's unique id
  33595. * @return the light or null if none found.
  33596. */
  33597. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33598. /**
  33599. * Gets a particle system by id
  33600. * @param id defines the particle system id
  33601. * @return the corresponding system or null if none found
  33602. */
  33603. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33604. /**
  33605. * Gets a geometry using its ID
  33606. * @param id defines the geometry's id
  33607. * @return the geometry or null if none found.
  33608. */
  33609. getGeometryByID(id: string): Nullable<Geometry>;
  33610. private _getGeometryByUniqueID;
  33611. /**
  33612. * Add a new geometry to this scene
  33613. * @param geometry defines the geometry to be added to the scene.
  33614. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33615. * @return a boolean defining if the geometry was added or not
  33616. */
  33617. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33618. /**
  33619. * Removes an existing geometry
  33620. * @param geometry defines the geometry to be removed from the scene
  33621. * @return a boolean defining if the geometry was removed or not
  33622. */
  33623. removeGeometry(geometry: Geometry): boolean;
  33624. /**
  33625. * Gets the list of geometries attached to the scene
  33626. * @returns an array of Geometry
  33627. */
  33628. getGeometries(): Geometry[];
  33629. /**
  33630. * Gets the first added mesh found of a given ID
  33631. * @param id defines the id to search for
  33632. * @return the mesh found or null if not found at all
  33633. */
  33634. getMeshByID(id: string): Nullable<AbstractMesh>;
  33635. /**
  33636. * Gets a list of meshes using their id
  33637. * @param id defines the id to search for
  33638. * @returns a list of meshes
  33639. */
  33640. getMeshesByID(id: string): Array<AbstractMesh>;
  33641. /**
  33642. * Gets the first added transform node found of a given ID
  33643. * @param id defines the id to search for
  33644. * @return the found transform node or null if not found at all.
  33645. */
  33646. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33647. /**
  33648. * Gets a transform node with its auto-generated unique id
  33649. * @param uniqueId efines the unique id to search for
  33650. * @return the found transform node or null if not found at all.
  33651. */
  33652. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33653. /**
  33654. * Gets a list of transform nodes using their id
  33655. * @param id defines the id to search for
  33656. * @returns a list of transform nodes
  33657. */
  33658. getTransformNodesByID(id: string): Array<TransformNode>;
  33659. /**
  33660. * Gets a mesh with its auto-generated unique id
  33661. * @param uniqueId defines the unique id to search for
  33662. * @return the found mesh or null if not found at all.
  33663. */
  33664. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33665. /**
  33666. * Gets a the last added mesh using a given id
  33667. * @param id defines the id to search for
  33668. * @return the found mesh or null if not found at all.
  33669. */
  33670. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33671. /**
  33672. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33673. * @param id defines the id to search for
  33674. * @return the found node or null if not found at all
  33675. */
  33676. getLastEntryByID(id: string): Nullable<Node>;
  33677. /**
  33678. * Gets a node (Mesh, Camera, Light) using a given id
  33679. * @param id defines the id to search for
  33680. * @return the found node or null if not found at all
  33681. */
  33682. getNodeByID(id: string): Nullable<Node>;
  33683. /**
  33684. * Gets a node (Mesh, Camera, Light) using a given name
  33685. * @param name defines the name to search for
  33686. * @return the found node or null if not found at all.
  33687. */
  33688. getNodeByName(name: string): Nullable<Node>;
  33689. /**
  33690. * Gets a mesh using a given name
  33691. * @param name defines the name to search for
  33692. * @return the found mesh or null if not found at all.
  33693. */
  33694. getMeshByName(name: string): Nullable<AbstractMesh>;
  33695. /**
  33696. * Gets a transform node using a given name
  33697. * @param name defines the name to search for
  33698. * @return the found transform node or null if not found at all.
  33699. */
  33700. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33701. /**
  33702. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33703. * @param id defines the id to search for
  33704. * @return the found skeleton or null if not found at all.
  33705. */
  33706. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33707. /**
  33708. * Gets a skeleton using a given auto generated unique id
  33709. * @param uniqueId defines the unique id to search for
  33710. * @return the found skeleton or null if not found at all.
  33711. */
  33712. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33713. /**
  33714. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33715. * @param id defines the id to search for
  33716. * @return the found skeleton or null if not found at all.
  33717. */
  33718. getSkeletonById(id: string): Nullable<Skeleton>;
  33719. /**
  33720. * Gets a skeleton using a given name
  33721. * @param name defines the name to search for
  33722. * @return the found skeleton or null if not found at all.
  33723. */
  33724. getSkeletonByName(name: string): Nullable<Skeleton>;
  33725. /**
  33726. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33727. * @param id defines the id to search for
  33728. * @return the found morph target manager or null if not found at all.
  33729. */
  33730. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33731. /**
  33732. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33733. * @param id defines the id to search for
  33734. * @return the found morph target or null if not found at all.
  33735. */
  33736. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33737. /**
  33738. * Gets a boolean indicating if the given mesh is active
  33739. * @param mesh defines the mesh to look for
  33740. * @returns true if the mesh is in the active list
  33741. */
  33742. isActiveMesh(mesh: AbstractMesh): boolean;
  33743. /**
  33744. * Return a unique id as a string which can serve as an identifier for the scene
  33745. */
  33746. readonly uid: string;
  33747. /**
  33748. * Add an externaly attached data from its key.
  33749. * This method call will fail and return false, if such key already exists.
  33750. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33751. * @param key the unique key that identifies the data
  33752. * @param data the data object to associate to the key for this Engine instance
  33753. * @return true if no such key were already present and the data was added successfully, false otherwise
  33754. */
  33755. addExternalData<T>(key: string, data: T): boolean;
  33756. /**
  33757. * Get an externaly attached data from its key
  33758. * @param key the unique key that identifies the data
  33759. * @return the associated data, if present (can be null), or undefined if not present
  33760. */
  33761. getExternalData<T>(key: string): Nullable<T>;
  33762. /**
  33763. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33764. * @param key the unique key that identifies the data
  33765. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33766. * @return the associated data, can be null if the factory returned null.
  33767. */
  33768. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33769. /**
  33770. * Remove an externaly attached data from the Engine instance
  33771. * @param key the unique key that identifies the data
  33772. * @return true if the data was successfully removed, false if it doesn't exist
  33773. */
  33774. removeExternalData(key: string): boolean;
  33775. private _evaluateSubMesh;
  33776. /**
  33777. * Clear the processed materials smart array preventing retention point in material dispose.
  33778. */
  33779. freeProcessedMaterials(): void;
  33780. private _preventFreeActiveMeshesAndRenderingGroups;
  33781. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33782. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33783. * when disposing several meshes in a row or a hierarchy of meshes.
  33784. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33785. */
  33786. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33787. /**
  33788. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33789. */
  33790. freeActiveMeshes(): void;
  33791. /**
  33792. * Clear the info related to rendering groups preventing retention points during dispose.
  33793. */
  33794. freeRenderingGroups(): void;
  33795. /** @hidden */
  33796. _isInIntermediateRendering(): boolean;
  33797. /**
  33798. * Lambda returning the list of potentially active meshes.
  33799. */
  33800. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33801. /**
  33802. * Lambda returning the list of potentially active sub meshes.
  33803. */
  33804. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33805. /**
  33806. * Lambda returning the list of potentially intersecting sub meshes.
  33807. */
  33808. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33809. /**
  33810. * Lambda returning the list of potentially colliding sub meshes.
  33811. */
  33812. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33813. private _activeMeshesFrozen;
  33814. /**
  33815. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33816. * @returns the current scene
  33817. */
  33818. freezeActiveMeshes(): Scene;
  33819. /**
  33820. * Use this function to restart evaluating active meshes on every frame
  33821. * @returns the current scene
  33822. */
  33823. unfreezeActiveMeshes(): Scene;
  33824. private _evaluateActiveMeshes;
  33825. private _activeMesh;
  33826. /**
  33827. * Update the transform matrix to update from the current active camera
  33828. * @param force defines a boolean used to force the update even if cache is up to date
  33829. */
  33830. updateTransformMatrix(force?: boolean): void;
  33831. private _bindFrameBuffer;
  33832. /** @hidden */
  33833. _allowPostProcessClearColor: boolean;
  33834. /** @hidden */
  33835. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33836. private _processSubCameras;
  33837. private _checkIntersections;
  33838. /** @hidden */
  33839. _advancePhysicsEngineStep(step: number): void;
  33840. /**
  33841. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33842. */
  33843. getDeterministicFrameTime: () => number;
  33844. /** @hidden */
  33845. _animate(): void;
  33846. /** Execute all animations (for a frame) */
  33847. animate(): void;
  33848. /**
  33849. * Render the scene
  33850. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33851. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33852. */
  33853. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33854. /**
  33855. * Freeze all materials
  33856. * A frozen material will not be updatable but should be faster to render
  33857. */
  33858. freezeMaterials(): void;
  33859. /**
  33860. * Unfreeze all materials
  33861. * A frozen material will not be updatable but should be faster to render
  33862. */
  33863. unfreezeMaterials(): void;
  33864. /**
  33865. * Releases all held ressources
  33866. */
  33867. dispose(): void;
  33868. /**
  33869. * Gets if the scene is already disposed
  33870. */
  33871. readonly isDisposed: boolean;
  33872. /**
  33873. * Call this function to reduce memory footprint of the scene.
  33874. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33875. */
  33876. clearCachedVertexData(): void;
  33877. /**
  33878. * This function will remove the local cached buffer data from texture.
  33879. * It will save memory but will prevent the texture from being rebuilt
  33880. */
  33881. cleanCachedTextureBuffer(): void;
  33882. /**
  33883. * Get the world extend vectors with an optional filter
  33884. *
  33885. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33886. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33887. */
  33888. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33889. min: Vector3;
  33890. max: Vector3;
  33891. };
  33892. /**
  33893. * Creates a ray that can be used to pick in the scene
  33894. * @param x defines the x coordinate of the origin (on-screen)
  33895. * @param y defines the y coordinate of the origin (on-screen)
  33896. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33897. * @param camera defines the camera to use for the picking
  33898. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33899. * @returns a Ray
  33900. */
  33901. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33902. /**
  33903. * Creates a ray that can be used to pick in the scene
  33904. * @param x defines the x coordinate of the origin (on-screen)
  33905. * @param y defines the y coordinate of the origin (on-screen)
  33906. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33907. * @param result defines the ray where to store the picking ray
  33908. * @param camera defines the camera to use for the picking
  33909. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33910. * @returns the current scene
  33911. */
  33912. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33913. /**
  33914. * Creates a ray that can be used to pick in the scene
  33915. * @param x defines the x coordinate of the origin (on-screen)
  33916. * @param y defines the y coordinate of the origin (on-screen)
  33917. * @param camera defines the camera to use for the picking
  33918. * @returns a Ray
  33919. */
  33920. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33921. /**
  33922. * Creates a ray that can be used to pick in the scene
  33923. * @param x defines the x coordinate of the origin (on-screen)
  33924. * @param y defines the y coordinate of the origin (on-screen)
  33925. * @param result defines the ray where to store the picking ray
  33926. * @param camera defines the camera to use for the picking
  33927. * @returns the current scene
  33928. */
  33929. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33930. /** Launch a ray to try to pick a mesh in the scene
  33931. * @param x position on screen
  33932. * @param y position on screen
  33933. * @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
  33934. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33935. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33936. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33937. * @returns a PickingInfo
  33938. */
  33939. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33940. /** Use the given ray to pick a mesh in the scene
  33941. * @param ray The ray to use to pick meshes
  33942. * @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
  33943. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33944. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33945. * @returns a PickingInfo
  33946. */
  33947. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33948. /**
  33949. * Launch a ray to try to pick a mesh in the scene
  33950. * @param x X position on screen
  33951. * @param y Y position on screen
  33952. * @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
  33953. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33954. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33955. * @returns an array of PickingInfo
  33956. */
  33957. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33958. /**
  33959. * Launch a ray to try to pick a mesh in the scene
  33960. * @param ray Ray to use
  33961. * @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
  33962. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33963. * @returns an array of PickingInfo
  33964. */
  33965. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33966. /**
  33967. * Force the value of meshUnderPointer
  33968. * @param mesh defines the mesh to use
  33969. */
  33970. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33971. /**
  33972. * Gets the mesh under the pointer
  33973. * @returns a Mesh or null if no mesh is under the pointer
  33974. */
  33975. getPointerOverMesh(): Nullable<AbstractMesh>;
  33976. /** @hidden */
  33977. _rebuildGeometries(): void;
  33978. /** @hidden */
  33979. _rebuildTextures(): void;
  33980. private _getByTags;
  33981. /**
  33982. * Get a list of meshes by tags
  33983. * @param tagsQuery defines the tags query to use
  33984. * @param forEach defines a predicate used to filter results
  33985. * @returns an array of Mesh
  33986. */
  33987. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33988. /**
  33989. * Get a list of cameras by tags
  33990. * @param tagsQuery defines the tags query to use
  33991. * @param forEach defines a predicate used to filter results
  33992. * @returns an array of Camera
  33993. */
  33994. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33995. /**
  33996. * Get a list of lights by tags
  33997. * @param tagsQuery defines the tags query to use
  33998. * @param forEach defines a predicate used to filter results
  33999. * @returns an array of Light
  34000. */
  34001. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34002. /**
  34003. * Get a list of materials by tags
  34004. * @param tagsQuery defines the tags query to use
  34005. * @param forEach defines a predicate used to filter results
  34006. * @returns an array of Material
  34007. */
  34008. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34009. /**
  34010. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34011. * This allowed control for front to back rendering or reversly depending of the special needs.
  34012. *
  34013. * @param renderingGroupId The rendering group id corresponding to its index
  34014. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34015. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34016. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34017. */
  34018. 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;
  34019. /**
  34020. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34021. *
  34022. * @param renderingGroupId The rendering group id corresponding to its index
  34023. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34024. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34025. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34026. */
  34027. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34028. /**
  34029. * Gets the current auto clear configuration for one rendering group of the rendering
  34030. * manager.
  34031. * @param index the rendering group index to get the information for
  34032. * @returns The auto clear setup for the requested rendering group
  34033. */
  34034. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34035. private _blockMaterialDirtyMechanism;
  34036. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34037. blockMaterialDirtyMechanism: boolean;
  34038. /**
  34039. * Will flag all materials as dirty to trigger new shader compilation
  34040. * @param flag defines the flag used to specify which material part must be marked as dirty
  34041. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34042. */
  34043. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34044. /** @hidden */
  34045. _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;
  34046. /** @hidden */
  34047. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34048. }
  34049. }
  34050. declare module BABYLON {
  34051. /**
  34052. * Set of assets to keep when moving a scene into an asset container.
  34053. */
  34054. export class KeepAssets extends AbstractScene {
  34055. }
  34056. /**
  34057. * Container with a set of assets that can be added or removed from a scene.
  34058. */
  34059. export class AssetContainer extends AbstractScene {
  34060. /**
  34061. * The scene the AssetContainer belongs to.
  34062. */
  34063. scene: Scene;
  34064. /**
  34065. * Instantiates an AssetContainer.
  34066. * @param scene The scene the AssetContainer belongs to.
  34067. */
  34068. constructor(scene: Scene);
  34069. /**
  34070. * Adds all the assets from the container to the scene.
  34071. */
  34072. addAllToScene(): void;
  34073. /**
  34074. * Removes all the assets in the container from the scene
  34075. */
  34076. removeAllFromScene(): void;
  34077. /**
  34078. * Disposes all the assets in the container
  34079. */
  34080. dispose(): void;
  34081. private _moveAssets;
  34082. /**
  34083. * Removes all the assets contained in the scene and adds them to the container.
  34084. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34085. */
  34086. moveAllFromScene(keepAssets?: KeepAssets): void;
  34087. /**
  34088. * 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.
  34089. * @returns the root mesh
  34090. */
  34091. createRootMesh(): Mesh;
  34092. }
  34093. }
  34094. declare module BABYLON {
  34095. /**
  34096. * Defines how the parser contract is defined.
  34097. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34098. */
  34099. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34100. /**
  34101. * Defines how the individual parser contract is defined.
  34102. * These parser can parse an individual asset
  34103. */
  34104. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34105. /**
  34106. * Base class of the scene acting as a container for the different elements composing a scene.
  34107. * This class is dynamically extended by the different components of the scene increasing
  34108. * flexibility and reducing coupling
  34109. */
  34110. export abstract class AbstractScene {
  34111. /**
  34112. * Stores the list of available parsers in the application.
  34113. */
  34114. private static _BabylonFileParsers;
  34115. /**
  34116. * Stores the list of available individual parsers in the application.
  34117. */
  34118. private static _IndividualBabylonFileParsers;
  34119. /**
  34120. * Adds a parser in the list of available ones
  34121. * @param name Defines the name of the parser
  34122. * @param parser Defines the parser to add
  34123. */
  34124. static AddParser(name: string, parser: BabylonFileParser): void;
  34125. /**
  34126. * Gets a general parser from the list of avaialble ones
  34127. * @param name Defines the name of the parser
  34128. * @returns the requested parser or null
  34129. */
  34130. static GetParser(name: string): Nullable<BabylonFileParser>;
  34131. /**
  34132. * Adds n individual parser in the list of available ones
  34133. * @param name Defines the name of the parser
  34134. * @param parser Defines the parser to add
  34135. */
  34136. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34137. /**
  34138. * Gets an individual parser from the list of avaialble ones
  34139. * @param name Defines the name of the parser
  34140. * @returns the requested parser or null
  34141. */
  34142. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34143. /**
  34144. * Parser json data and populate both a scene and its associated container object
  34145. * @param jsonData Defines the data to parse
  34146. * @param scene Defines the scene to parse the data for
  34147. * @param container Defines the container attached to the parsing sequence
  34148. * @param rootUrl Defines the root url of the data
  34149. */
  34150. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34151. /**
  34152. * Gets the list of root nodes (ie. nodes with no parent)
  34153. */
  34154. rootNodes: Node[];
  34155. /** All of the cameras added to this scene
  34156. * @see http://doc.babylonjs.com/babylon101/cameras
  34157. */
  34158. cameras: Camera[];
  34159. /**
  34160. * All of the lights added to this scene
  34161. * @see http://doc.babylonjs.com/babylon101/lights
  34162. */
  34163. lights: Light[];
  34164. /**
  34165. * All of the (abstract) meshes added to this scene
  34166. */
  34167. meshes: AbstractMesh[];
  34168. /**
  34169. * The list of skeletons added to the scene
  34170. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34171. */
  34172. skeletons: Skeleton[];
  34173. /**
  34174. * All of the particle systems added to this scene
  34175. * @see http://doc.babylonjs.com/babylon101/particles
  34176. */
  34177. particleSystems: IParticleSystem[];
  34178. /**
  34179. * Gets a list of Animations associated with the scene
  34180. */
  34181. animations: Animation[];
  34182. /**
  34183. * All of the animation groups added to this scene
  34184. * @see http://doc.babylonjs.com/how_to/group
  34185. */
  34186. animationGroups: AnimationGroup[];
  34187. /**
  34188. * All of the multi-materials added to this scene
  34189. * @see http://doc.babylonjs.com/how_to/multi_materials
  34190. */
  34191. multiMaterials: MultiMaterial[];
  34192. /**
  34193. * All of the materials added to this scene
  34194. * In the context of a Scene, it is not supposed to be modified manually.
  34195. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34196. * Note also that the order of the Material wihin the array is not significant and might change.
  34197. * @see http://doc.babylonjs.com/babylon101/materials
  34198. */
  34199. materials: Material[];
  34200. /**
  34201. * The list of morph target managers added to the scene
  34202. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34203. */
  34204. morphTargetManagers: MorphTargetManager[];
  34205. /**
  34206. * The list of geometries used in the scene.
  34207. */
  34208. geometries: Geometry[];
  34209. /**
  34210. * All of the tranform nodes added to this scene
  34211. * In the context of a Scene, it is not supposed to be modified manually.
  34212. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34213. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34214. * @see http://doc.babylonjs.com/how_to/transformnode
  34215. */
  34216. transformNodes: TransformNode[];
  34217. /**
  34218. * ActionManagers available on the scene.
  34219. */
  34220. actionManagers: AbstractActionManager[];
  34221. /**
  34222. * Textures to keep.
  34223. */
  34224. textures: BaseTexture[];
  34225. /**
  34226. * Environment texture for the scene
  34227. */
  34228. environmentTexture: Nullable<BaseTexture>;
  34229. }
  34230. }
  34231. declare module BABYLON {
  34232. /**
  34233. * Interface used to define options for Sound class
  34234. */
  34235. export interface ISoundOptions {
  34236. /**
  34237. * Does the sound autoplay once loaded.
  34238. */
  34239. autoplay?: boolean;
  34240. /**
  34241. * Does the sound loop after it finishes playing once.
  34242. */
  34243. loop?: boolean;
  34244. /**
  34245. * Sound's volume
  34246. */
  34247. volume?: number;
  34248. /**
  34249. * Is it a spatial sound?
  34250. */
  34251. spatialSound?: boolean;
  34252. /**
  34253. * Maximum distance to hear that sound
  34254. */
  34255. maxDistance?: number;
  34256. /**
  34257. * Uses user defined attenuation function
  34258. */
  34259. useCustomAttenuation?: boolean;
  34260. /**
  34261. * Define the roll off factor of spatial sounds.
  34262. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34263. */
  34264. rolloffFactor?: number;
  34265. /**
  34266. * Define the reference distance the sound should be heard perfectly.
  34267. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34268. */
  34269. refDistance?: number;
  34270. /**
  34271. * Define the distance attenuation model the sound will follow.
  34272. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34273. */
  34274. distanceModel?: string;
  34275. /**
  34276. * Defines the playback speed (1 by default)
  34277. */
  34278. playbackRate?: number;
  34279. /**
  34280. * Defines if the sound is from a streaming source
  34281. */
  34282. streaming?: boolean;
  34283. /**
  34284. * Defines an optional length (in seconds) inside the sound file
  34285. */
  34286. length?: number;
  34287. /**
  34288. * Defines an optional offset (in seconds) inside the sound file
  34289. */
  34290. offset?: number;
  34291. }
  34292. /**
  34293. * Defines a sound that can be played in the application.
  34294. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34296. */
  34297. export class Sound {
  34298. /**
  34299. * The name of the sound in the scene.
  34300. */
  34301. name: string;
  34302. /**
  34303. * Does the sound autoplay once loaded.
  34304. */
  34305. autoplay: boolean;
  34306. /**
  34307. * Does the sound loop after it finishes playing once.
  34308. */
  34309. loop: boolean;
  34310. /**
  34311. * Does the sound use a custom attenuation curve to simulate the falloff
  34312. * happening when the source gets further away from the camera.
  34313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34314. */
  34315. useCustomAttenuation: boolean;
  34316. /**
  34317. * The sound track id this sound belongs to.
  34318. */
  34319. soundTrackId: number;
  34320. /**
  34321. * Is this sound currently played.
  34322. */
  34323. isPlaying: boolean;
  34324. /**
  34325. * Is this sound currently paused.
  34326. */
  34327. isPaused: boolean;
  34328. /**
  34329. * Does this sound enables spatial sound.
  34330. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34331. */
  34332. spatialSound: boolean;
  34333. /**
  34334. * Define the reference distance the sound should be heard perfectly.
  34335. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34336. */
  34337. refDistance: number;
  34338. /**
  34339. * Define the roll off factor of spatial sounds.
  34340. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34341. */
  34342. rolloffFactor: number;
  34343. /**
  34344. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34345. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34346. */
  34347. maxDistance: number;
  34348. /**
  34349. * Define the distance attenuation model the sound will follow.
  34350. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34351. */
  34352. distanceModel: string;
  34353. /**
  34354. * @hidden
  34355. * Back Compat
  34356. **/
  34357. onended: () => any;
  34358. /**
  34359. * Observable event when the current playing sound finishes.
  34360. */
  34361. onEndedObservable: Observable<Sound>;
  34362. private _panningModel;
  34363. private _playbackRate;
  34364. private _streaming;
  34365. private _startTime;
  34366. private _startOffset;
  34367. private _position;
  34368. /** @hidden */
  34369. _positionInEmitterSpace: boolean;
  34370. private _localDirection;
  34371. private _volume;
  34372. private _isReadyToPlay;
  34373. private _isDirectional;
  34374. private _readyToPlayCallback;
  34375. private _audioBuffer;
  34376. private _soundSource;
  34377. private _streamingSource;
  34378. private _soundPanner;
  34379. private _soundGain;
  34380. private _inputAudioNode;
  34381. private _outputAudioNode;
  34382. private _coneInnerAngle;
  34383. private _coneOuterAngle;
  34384. private _coneOuterGain;
  34385. private _scene;
  34386. private _connectedTransformNode;
  34387. private _customAttenuationFunction;
  34388. private _registerFunc;
  34389. private _isOutputConnected;
  34390. private _htmlAudioElement;
  34391. private _urlType;
  34392. private _length?;
  34393. private _offset?;
  34394. /** @hidden */
  34395. static _SceneComponentInitialization: (scene: Scene) => void;
  34396. /**
  34397. * Create a sound and attach it to a scene
  34398. * @param name Name of your sound
  34399. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34400. * @param scene defines the scene the sound belongs to
  34401. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34402. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34403. */
  34404. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34405. /**
  34406. * Release the sound and its associated resources
  34407. */
  34408. dispose(): void;
  34409. /**
  34410. * Gets if the sounds is ready to be played or not.
  34411. * @returns true if ready, otherwise false
  34412. */
  34413. isReady(): boolean;
  34414. private _soundLoaded;
  34415. /**
  34416. * Sets the data of the sound from an audiobuffer
  34417. * @param audioBuffer The audioBuffer containing the data
  34418. */
  34419. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34420. /**
  34421. * Updates the current sounds options such as maxdistance, loop...
  34422. * @param options A JSON object containing values named as the object properties
  34423. */
  34424. updateOptions(options: ISoundOptions): void;
  34425. private _createSpatialParameters;
  34426. private _updateSpatialParameters;
  34427. /**
  34428. * Switch the panning model to HRTF:
  34429. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34430. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34431. */
  34432. switchPanningModelToHRTF(): void;
  34433. /**
  34434. * Switch the panning model to Equal Power:
  34435. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34437. */
  34438. switchPanningModelToEqualPower(): void;
  34439. private _switchPanningModel;
  34440. /**
  34441. * Connect this sound to a sound track audio node like gain...
  34442. * @param soundTrackAudioNode the sound track audio node to connect to
  34443. */
  34444. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34445. /**
  34446. * Transform this sound into a directional source
  34447. * @param coneInnerAngle Size of the inner cone in degree
  34448. * @param coneOuterAngle Size of the outer cone in degree
  34449. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34450. */
  34451. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34452. /**
  34453. * Gets or sets the inner angle for the directional cone.
  34454. */
  34455. /**
  34456. * Gets or sets the inner angle for the directional cone.
  34457. */
  34458. directionalConeInnerAngle: number;
  34459. /**
  34460. * Gets or sets the outer angle for the directional cone.
  34461. */
  34462. /**
  34463. * Gets or sets the outer angle for the directional cone.
  34464. */
  34465. directionalConeOuterAngle: number;
  34466. /**
  34467. * Sets the position of the emitter if spatial sound is enabled
  34468. * @param newPosition Defines the new posisiton
  34469. */
  34470. setPosition(newPosition: Vector3): void;
  34471. /**
  34472. * Sets the local direction of the emitter if spatial sound is enabled
  34473. * @param newLocalDirection Defines the new local direction
  34474. */
  34475. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34476. private _updateDirection;
  34477. /** @hidden */
  34478. updateDistanceFromListener(): void;
  34479. /**
  34480. * Sets a new custom attenuation function for the sound.
  34481. * @param callback Defines the function used for the attenuation
  34482. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34483. */
  34484. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34485. /**
  34486. * Play the sound
  34487. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34488. * @param offset (optional) Start the sound at a specific time in seconds
  34489. * @param length (optional) Sound duration (in seconds)
  34490. */
  34491. play(time?: number, offset?: number, length?: number): void;
  34492. private _onended;
  34493. /**
  34494. * Stop the sound
  34495. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34496. */
  34497. stop(time?: number): void;
  34498. /**
  34499. * Put the sound in pause
  34500. */
  34501. pause(): void;
  34502. /**
  34503. * Sets a dedicated volume for this sounds
  34504. * @param newVolume Define the new volume of the sound
  34505. * @param time Define time for gradual change to new volume
  34506. */
  34507. setVolume(newVolume: number, time?: number): void;
  34508. /**
  34509. * Set the sound play back rate
  34510. * @param newPlaybackRate Define the playback rate the sound should be played at
  34511. */
  34512. setPlaybackRate(newPlaybackRate: number): void;
  34513. /**
  34514. * Gets the volume of the sound.
  34515. * @returns the volume of the sound
  34516. */
  34517. getVolume(): number;
  34518. /**
  34519. * Attach the sound to a dedicated mesh
  34520. * @param transformNode The transform node to connect the sound with
  34521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34522. */
  34523. attachToMesh(transformNode: TransformNode): void;
  34524. /**
  34525. * Detach the sound from the previously attached mesh
  34526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34527. */
  34528. detachFromMesh(): void;
  34529. private _onRegisterAfterWorldMatrixUpdate;
  34530. /**
  34531. * Clone the current sound in the scene.
  34532. * @returns the new sound clone
  34533. */
  34534. clone(): Nullable<Sound>;
  34535. /**
  34536. * Gets the current underlying audio buffer containing the data
  34537. * @returns the audio buffer
  34538. */
  34539. getAudioBuffer(): Nullable<AudioBuffer>;
  34540. /**
  34541. * Serializes the Sound in a JSON representation
  34542. * @returns the JSON representation of the sound
  34543. */
  34544. serialize(): any;
  34545. /**
  34546. * Parse a JSON representation of a sound to innstantiate in a given scene
  34547. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34548. * @param scene Define the scene the new parsed sound should be created in
  34549. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34550. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34551. * @returns the newly parsed sound
  34552. */
  34553. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34554. }
  34555. }
  34556. declare module BABYLON {
  34557. /**
  34558. * This defines an action helpful to play a defined sound on a triggered action.
  34559. */
  34560. export class PlaySoundAction extends Action {
  34561. private _sound;
  34562. /**
  34563. * Instantiate the action
  34564. * @param triggerOptions defines the trigger options
  34565. * @param sound defines the sound to play
  34566. * @param condition defines the trigger related conditions
  34567. */
  34568. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34569. /** @hidden */
  34570. _prepare(): void;
  34571. /**
  34572. * Execute the action and play the sound.
  34573. */
  34574. execute(): void;
  34575. /**
  34576. * Serializes the actions and its related information.
  34577. * @param parent defines the object to serialize in
  34578. * @returns the serialized object
  34579. */
  34580. serialize(parent: any): any;
  34581. }
  34582. /**
  34583. * This defines an action helpful to stop a defined sound on a triggered action.
  34584. */
  34585. export class StopSoundAction extends Action {
  34586. private _sound;
  34587. /**
  34588. * Instantiate the action
  34589. * @param triggerOptions defines the trigger options
  34590. * @param sound defines the sound to stop
  34591. * @param condition defines the trigger related conditions
  34592. */
  34593. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34594. /** @hidden */
  34595. _prepare(): void;
  34596. /**
  34597. * Execute the action and stop the sound.
  34598. */
  34599. execute(): void;
  34600. /**
  34601. * Serializes the actions and its related information.
  34602. * @param parent defines the object to serialize in
  34603. * @returns the serialized object
  34604. */
  34605. serialize(parent: any): any;
  34606. }
  34607. }
  34608. declare module BABYLON {
  34609. /**
  34610. * This defines an action responsible to change the value of a property
  34611. * by interpolating between its current value and the newly set one once triggered.
  34612. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34613. */
  34614. export class InterpolateValueAction extends Action {
  34615. /**
  34616. * Defines the path of the property where the value should be interpolated
  34617. */
  34618. propertyPath: string;
  34619. /**
  34620. * Defines the target value at the end of the interpolation.
  34621. */
  34622. value: any;
  34623. /**
  34624. * Defines the time it will take for the property to interpolate to the value.
  34625. */
  34626. duration: number;
  34627. /**
  34628. * Defines if the other scene animations should be stopped when the action has been triggered
  34629. */
  34630. stopOtherAnimations?: boolean;
  34631. /**
  34632. * Defines a callback raised once the interpolation animation has been done.
  34633. */
  34634. onInterpolationDone?: () => void;
  34635. /**
  34636. * Observable triggered once the interpolation animation has been done.
  34637. */
  34638. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34639. private _target;
  34640. private _effectiveTarget;
  34641. private _property;
  34642. /**
  34643. * Instantiate the action
  34644. * @param triggerOptions defines the trigger options
  34645. * @param target defines the object containing the value to interpolate
  34646. * @param propertyPath defines the path to the property in the target object
  34647. * @param value defines the target value at the end of the interpolation
  34648. * @param duration deines the time it will take for the property to interpolate to the value.
  34649. * @param condition defines the trigger related conditions
  34650. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34651. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34652. */
  34653. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34654. /** @hidden */
  34655. _prepare(): void;
  34656. /**
  34657. * Execute the action starts the value interpolation.
  34658. */
  34659. execute(): void;
  34660. /**
  34661. * Serializes the actions and its related information.
  34662. * @param parent defines the object to serialize in
  34663. * @returns the serialized object
  34664. */
  34665. serialize(parent: any): any;
  34666. }
  34667. }
  34668. declare module BABYLON {
  34669. /**
  34670. * Options allowed during the creation of a sound track.
  34671. */
  34672. export interface ISoundTrackOptions {
  34673. /**
  34674. * The volume the sound track should take during creation
  34675. */
  34676. volume?: number;
  34677. /**
  34678. * Define if the sound track is the main sound track of the scene
  34679. */
  34680. mainTrack?: boolean;
  34681. }
  34682. /**
  34683. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34684. * It will be also used in a future release to apply effects on a specific track.
  34685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34686. */
  34687. export class SoundTrack {
  34688. /**
  34689. * The unique identifier of the sound track in the scene.
  34690. */
  34691. id: number;
  34692. /**
  34693. * The list of sounds included in the sound track.
  34694. */
  34695. soundCollection: Array<Sound>;
  34696. private _outputAudioNode;
  34697. private _scene;
  34698. private _isMainTrack;
  34699. private _connectedAnalyser;
  34700. private _options;
  34701. private _isInitialized;
  34702. /**
  34703. * Creates a new sound track.
  34704. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34705. * @param scene Define the scene the sound track belongs to
  34706. * @param options
  34707. */
  34708. constructor(scene: Scene, options?: ISoundTrackOptions);
  34709. private _initializeSoundTrackAudioGraph;
  34710. /**
  34711. * Release the sound track and its associated resources
  34712. */
  34713. dispose(): void;
  34714. /**
  34715. * Adds a sound to this sound track
  34716. * @param sound define the cound to add
  34717. * @ignoreNaming
  34718. */
  34719. AddSound(sound: Sound): void;
  34720. /**
  34721. * Removes a sound to this sound track
  34722. * @param sound define the cound to remove
  34723. * @ignoreNaming
  34724. */
  34725. RemoveSound(sound: Sound): void;
  34726. /**
  34727. * Set a global volume for the full sound track.
  34728. * @param newVolume Define the new volume of the sound track
  34729. */
  34730. setVolume(newVolume: number): void;
  34731. /**
  34732. * Switch the panning model to HRTF:
  34733. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34734. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34735. */
  34736. switchPanningModelToHRTF(): void;
  34737. /**
  34738. * Switch the panning model to Equal Power:
  34739. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34741. */
  34742. switchPanningModelToEqualPower(): void;
  34743. /**
  34744. * Connect the sound track to an audio analyser allowing some amazing
  34745. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34747. * @param analyser The analyser to connect to the engine
  34748. */
  34749. connectToAnalyser(analyser: Analyser): void;
  34750. }
  34751. }
  34752. declare module BABYLON {
  34753. interface AbstractScene {
  34754. /**
  34755. * The list of sounds used in the scene.
  34756. */
  34757. sounds: Nullable<Array<Sound>>;
  34758. }
  34759. interface Scene {
  34760. /**
  34761. * @hidden
  34762. * Backing field
  34763. */
  34764. _mainSoundTrack: SoundTrack;
  34765. /**
  34766. * The main sound track played by the scene.
  34767. * It cotains your primary collection of sounds.
  34768. */
  34769. mainSoundTrack: SoundTrack;
  34770. /**
  34771. * The list of sound tracks added to the scene
  34772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34773. */
  34774. soundTracks: Nullable<Array<SoundTrack>>;
  34775. /**
  34776. * Gets a sound using a given name
  34777. * @param name defines the name to search for
  34778. * @return the found sound or null if not found at all.
  34779. */
  34780. getSoundByName(name: string): Nullable<Sound>;
  34781. /**
  34782. * Gets or sets if audio support is enabled
  34783. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34784. */
  34785. audioEnabled: boolean;
  34786. /**
  34787. * Gets or sets if audio will be output to headphones
  34788. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34789. */
  34790. headphone: boolean;
  34791. }
  34792. /**
  34793. * Defines the sound scene component responsible to manage any sounds
  34794. * in a given scene.
  34795. */
  34796. export class AudioSceneComponent implements ISceneSerializableComponent {
  34797. /**
  34798. * The component name helpfull to identify the component in the list of scene components.
  34799. */
  34800. readonly name: string;
  34801. /**
  34802. * The scene the component belongs to.
  34803. */
  34804. scene: Scene;
  34805. private _audioEnabled;
  34806. /**
  34807. * Gets whether audio is enabled or not.
  34808. * Please use related enable/disable method to switch state.
  34809. */
  34810. readonly audioEnabled: boolean;
  34811. private _headphone;
  34812. /**
  34813. * Gets whether audio is outputing to headphone or not.
  34814. * Please use the according Switch methods to change output.
  34815. */
  34816. readonly headphone: boolean;
  34817. /**
  34818. * Creates a new instance of the component for the given scene
  34819. * @param scene Defines the scene to register the component in
  34820. */
  34821. constructor(scene: Scene);
  34822. /**
  34823. * Registers the component in a given scene
  34824. */
  34825. register(): void;
  34826. /**
  34827. * Rebuilds the elements related to this component in case of
  34828. * context lost for instance.
  34829. */
  34830. rebuild(): void;
  34831. /**
  34832. * Serializes the component data to the specified json object
  34833. * @param serializationObject The object to serialize to
  34834. */
  34835. serialize(serializationObject: any): void;
  34836. /**
  34837. * Adds all the elements from the container to the scene
  34838. * @param container the container holding the elements
  34839. */
  34840. addFromContainer(container: AbstractScene): void;
  34841. /**
  34842. * Removes all the elements in the container from the scene
  34843. * @param container contains the elements to remove
  34844. * @param dispose if the removed element should be disposed (default: false)
  34845. */
  34846. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34847. /**
  34848. * Disposes the component and the associated ressources.
  34849. */
  34850. dispose(): void;
  34851. /**
  34852. * Disables audio in the associated scene.
  34853. */
  34854. disableAudio(): void;
  34855. /**
  34856. * Enables audio in the associated scene.
  34857. */
  34858. enableAudio(): void;
  34859. /**
  34860. * Switch audio to headphone output.
  34861. */
  34862. switchAudioModeForHeadphones(): void;
  34863. /**
  34864. * Switch audio to normal speakers.
  34865. */
  34866. switchAudioModeForNormalSpeakers(): void;
  34867. private _afterRender;
  34868. }
  34869. }
  34870. declare module BABYLON {
  34871. /**
  34872. * Wraps one or more Sound objects and selects one with random weight for playback.
  34873. */
  34874. export class WeightedSound {
  34875. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34876. loop: boolean;
  34877. private _coneInnerAngle;
  34878. private _coneOuterAngle;
  34879. private _volume;
  34880. /** A Sound is currently playing. */
  34881. isPlaying: boolean;
  34882. /** A Sound is currently paused. */
  34883. isPaused: boolean;
  34884. private _sounds;
  34885. private _weights;
  34886. private _currentIndex?;
  34887. /**
  34888. * Creates a new WeightedSound from the list of sounds given.
  34889. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34890. * @param sounds Array of Sounds that will be selected from.
  34891. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34892. */
  34893. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34894. /**
  34895. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34896. */
  34897. /**
  34898. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34899. */
  34900. directionalConeInnerAngle: number;
  34901. /**
  34902. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34903. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34904. */
  34905. /**
  34906. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34907. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34908. */
  34909. directionalConeOuterAngle: number;
  34910. /**
  34911. * Playback volume.
  34912. */
  34913. /**
  34914. * Playback volume.
  34915. */
  34916. volume: number;
  34917. private _onended;
  34918. /**
  34919. * Suspend playback
  34920. */
  34921. pause(): void;
  34922. /**
  34923. * Stop playback
  34924. */
  34925. stop(): void;
  34926. /**
  34927. * Start playback.
  34928. * @param startOffset Position the clip head at a specific time in seconds.
  34929. */
  34930. play(startOffset?: number): void;
  34931. }
  34932. }
  34933. declare module BABYLON {
  34934. /**
  34935. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34936. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34937. */
  34938. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34939. /**
  34940. * Gets the name of the behavior.
  34941. */
  34942. readonly name: string;
  34943. /**
  34944. * The easing function used by animations
  34945. */
  34946. static EasingFunction: BackEase;
  34947. /**
  34948. * The easing mode used by animations
  34949. */
  34950. static EasingMode: number;
  34951. /**
  34952. * The duration of the animation, in milliseconds
  34953. */
  34954. transitionDuration: number;
  34955. /**
  34956. * Length of the distance animated by the transition when lower radius is reached
  34957. */
  34958. lowerRadiusTransitionRange: number;
  34959. /**
  34960. * Length of the distance animated by the transition when upper radius is reached
  34961. */
  34962. upperRadiusTransitionRange: number;
  34963. private _autoTransitionRange;
  34964. /**
  34965. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34966. */
  34967. /**
  34968. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34969. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34970. */
  34971. autoTransitionRange: boolean;
  34972. private _attachedCamera;
  34973. private _onAfterCheckInputsObserver;
  34974. private _onMeshTargetChangedObserver;
  34975. /**
  34976. * Initializes the behavior.
  34977. */
  34978. init(): void;
  34979. /**
  34980. * Attaches the behavior to its arc rotate camera.
  34981. * @param camera Defines the camera to attach the behavior to
  34982. */
  34983. attach(camera: ArcRotateCamera): void;
  34984. /**
  34985. * Detaches the behavior from its current arc rotate camera.
  34986. */
  34987. detach(): void;
  34988. private _radiusIsAnimating;
  34989. private _radiusBounceTransition;
  34990. private _animatables;
  34991. private _cachedWheelPrecision;
  34992. /**
  34993. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34994. * @param radiusLimit The limit to check against.
  34995. * @return Bool to indicate if at limit.
  34996. */
  34997. private _isRadiusAtLimit;
  34998. /**
  34999. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35000. * @param radiusDelta The delta by which to animate to. Can be negative.
  35001. */
  35002. private _applyBoundRadiusAnimation;
  35003. /**
  35004. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35005. */
  35006. protected _clearAnimationLocks(): void;
  35007. /**
  35008. * Stops and removes all animations that have been applied to the camera
  35009. */
  35010. stopAllAnimations(): void;
  35011. }
  35012. }
  35013. declare module BABYLON {
  35014. /**
  35015. * 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.
  35016. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35017. */
  35018. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35019. /**
  35020. * Gets the name of the behavior.
  35021. */
  35022. readonly name: string;
  35023. private _mode;
  35024. private _radiusScale;
  35025. private _positionScale;
  35026. private _defaultElevation;
  35027. private _elevationReturnTime;
  35028. private _elevationReturnWaitTime;
  35029. private _zoomStopsAnimation;
  35030. private _framingTime;
  35031. /**
  35032. * The easing function used by animations
  35033. */
  35034. static EasingFunction: ExponentialEase;
  35035. /**
  35036. * The easing mode used by animations
  35037. */
  35038. static EasingMode: number;
  35039. /**
  35040. * Sets the current mode used by the behavior
  35041. */
  35042. /**
  35043. * Gets current mode used by the behavior.
  35044. */
  35045. mode: number;
  35046. /**
  35047. * Sets the scale applied to the radius (1 by default)
  35048. */
  35049. /**
  35050. * Gets the scale applied to the radius
  35051. */
  35052. radiusScale: number;
  35053. /**
  35054. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35055. */
  35056. /**
  35057. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35058. */
  35059. positionScale: number;
  35060. /**
  35061. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35062. * behaviour is triggered, in radians.
  35063. */
  35064. /**
  35065. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35066. * behaviour is triggered, in radians.
  35067. */
  35068. defaultElevation: number;
  35069. /**
  35070. * Sets the time (in milliseconds) taken to return to the default beta position.
  35071. * Negative value indicates camera should not return to default.
  35072. */
  35073. /**
  35074. * Gets the time (in milliseconds) taken to return to the default beta position.
  35075. * Negative value indicates camera should not return to default.
  35076. */
  35077. elevationReturnTime: number;
  35078. /**
  35079. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35080. */
  35081. /**
  35082. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35083. */
  35084. elevationReturnWaitTime: number;
  35085. /**
  35086. * Sets the flag that indicates if user zooming should stop animation.
  35087. */
  35088. /**
  35089. * Gets the flag that indicates if user zooming should stop animation.
  35090. */
  35091. zoomStopsAnimation: boolean;
  35092. /**
  35093. * Sets the transition time when framing the mesh, in milliseconds
  35094. */
  35095. /**
  35096. * Gets the transition time when framing the mesh, in milliseconds
  35097. */
  35098. framingTime: number;
  35099. /**
  35100. * Define if the behavior should automatically change the configured
  35101. * camera limits and sensibilities.
  35102. */
  35103. autoCorrectCameraLimitsAndSensibility: boolean;
  35104. private _onPrePointerObservableObserver;
  35105. private _onAfterCheckInputsObserver;
  35106. private _onMeshTargetChangedObserver;
  35107. private _attachedCamera;
  35108. private _isPointerDown;
  35109. private _lastInteractionTime;
  35110. /**
  35111. * Initializes the behavior.
  35112. */
  35113. init(): void;
  35114. /**
  35115. * Attaches the behavior to its arc rotate camera.
  35116. * @param camera Defines the camera to attach the behavior to
  35117. */
  35118. attach(camera: ArcRotateCamera): void;
  35119. /**
  35120. * Detaches the behavior from its current arc rotate camera.
  35121. */
  35122. detach(): void;
  35123. private _animatables;
  35124. private _betaIsAnimating;
  35125. private _betaTransition;
  35126. private _radiusTransition;
  35127. private _vectorTransition;
  35128. /**
  35129. * Targets the given mesh and updates zoom level accordingly.
  35130. * @param mesh The mesh to target.
  35131. * @param radius Optional. If a cached radius position already exists, overrides default.
  35132. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35133. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35134. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35135. */
  35136. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35137. /**
  35138. * Targets the given mesh with its children and updates zoom level accordingly.
  35139. * @param mesh The mesh to target.
  35140. * @param radius Optional. If a cached radius position already exists, overrides default.
  35141. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35142. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35143. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35144. */
  35145. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35146. /**
  35147. * Targets the given meshes with their children and updates zoom level accordingly.
  35148. * @param meshes The mesh to target.
  35149. * @param radius Optional. If a cached radius position already exists, overrides default.
  35150. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35151. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35152. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35153. */
  35154. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35155. /**
  35156. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35157. * @param minimumWorld Determines the smaller position of the bounding box extend
  35158. * @param maximumWorld Determines the bigger position of the bounding box extend
  35159. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35160. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35161. */
  35162. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35163. /**
  35164. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35165. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35166. * frustum width.
  35167. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35168. * to fully enclose the mesh in the viewing frustum.
  35169. */
  35170. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35171. /**
  35172. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35173. * is automatically returned to its default position (expected to be above ground plane).
  35174. */
  35175. private _maintainCameraAboveGround;
  35176. /**
  35177. * Returns the frustum slope based on the canvas ratio and camera FOV
  35178. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35179. */
  35180. private _getFrustumSlope;
  35181. /**
  35182. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35183. */
  35184. private _clearAnimationLocks;
  35185. /**
  35186. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35187. */
  35188. private _applyUserInteraction;
  35189. /**
  35190. * Stops and removes all animations that have been applied to the camera
  35191. */
  35192. stopAllAnimations(): void;
  35193. /**
  35194. * Gets a value indicating if the user is moving the camera
  35195. */
  35196. readonly isUserIsMoving: boolean;
  35197. /**
  35198. * The camera can move all the way towards the mesh.
  35199. */
  35200. static IgnoreBoundsSizeMode: number;
  35201. /**
  35202. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35203. */
  35204. static FitFrustumSidesMode: number;
  35205. }
  35206. }
  35207. declare module BABYLON {
  35208. /**
  35209. * Base class for Camera Pointer Inputs.
  35210. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35211. * for example usage.
  35212. */
  35213. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35214. /**
  35215. * Defines the camera the input is attached to.
  35216. */
  35217. abstract camera: Camera;
  35218. /**
  35219. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35220. */
  35221. protected _altKey: boolean;
  35222. protected _ctrlKey: boolean;
  35223. protected _metaKey: boolean;
  35224. protected _shiftKey: boolean;
  35225. /**
  35226. * Which mouse buttons were pressed at time of last mouse event.
  35227. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35228. */
  35229. protected _buttonsPressed: number;
  35230. /**
  35231. * Defines the buttons associated with the input to handle camera move.
  35232. */
  35233. buttons: number[];
  35234. /**
  35235. * Attach the input controls to a specific dom element to get the input from.
  35236. * @param element Defines the element the controls should be listened from
  35237. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35238. */
  35239. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35240. /**
  35241. * Detach the current controls from the specified dom element.
  35242. * @param element Defines the element to stop listening the inputs from
  35243. */
  35244. detachControl(element: Nullable<HTMLElement>): void;
  35245. /**
  35246. * Gets the class name of the current input.
  35247. * @returns the class name
  35248. */
  35249. getClassName(): string;
  35250. /**
  35251. * Get the friendly name associated with the input class.
  35252. * @returns the input friendly name
  35253. */
  35254. getSimpleName(): string;
  35255. /**
  35256. * Called on pointer POINTERDOUBLETAP event.
  35257. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35258. */
  35259. protected onDoubleTap(type: string): void;
  35260. /**
  35261. * Called on pointer POINTERMOVE event if only a single touch is active.
  35262. * Override this method to provide functionality.
  35263. */
  35264. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35265. /**
  35266. * Called on pointer POINTERMOVE event if multiple touches are active.
  35267. * Override this method to provide functionality.
  35268. */
  35269. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35270. /**
  35271. * Called on JS contextmenu event.
  35272. * Override this method to provide functionality.
  35273. */
  35274. protected onContextMenu(evt: PointerEvent): void;
  35275. /**
  35276. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35277. * press.
  35278. * Override this method to provide functionality.
  35279. */
  35280. protected onButtonDown(evt: PointerEvent): void;
  35281. /**
  35282. * Called each time a new POINTERUP event occurs. Ie, for each button
  35283. * release.
  35284. * Override this method to provide functionality.
  35285. */
  35286. protected onButtonUp(evt: PointerEvent): void;
  35287. /**
  35288. * Called when window becomes inactive.
  35289. * Override this method to provide functionality.
  35290. */
  35291. protected onLostFocus(): void;
  35292. private _pointerInput;
  35293. private _observer;
  35294. private _onLostFocus;
  35295. private pointA;
  35296. private pointB;
  35297. }
  35298. }
  35299. declare module BABYLON {
  35300. /**
  35301. * Manage the pointers inputs to control an arc rotate camera.
  35302. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35303. */
  35304. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35305. /**
  35306. * Defines the camera the input is attached to.
  35307. */
  35308. camera: ArcRotateCamera;
  35309. /**
  35310. * Gets the class name of the current input.
  35311. * @returns the class name
  35312. */
  35313. getClassName(): string;
  35314. /**
  35315. * Defines the buttons associated with the input to handle camera move.
  35316. */
  35317. buttons: number[];
  35318. /**
  35319. * Defines the pointer angular sensibility along the X axis or how fast is
  35320. * the camera rotating.
  35321. */
  35322. angularSensibilityX: number;
  35323. /**
  35324. * Defines the pointer angular sensibility along the Y axis or how fast is
  35325. * the camera rotating.
  35326. */
  35327. angularSensibilityY: number;
  35328. /**
  35329. * Defines the pointer pinch precision or how fast is the camera zooming.
  35330. */
  35331. pinchPrecision: number;
  35332. /**
  35333. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35334. * from 0.
  35335. * It defines the percentage of current camera.radius to use as delta when
  35336. * pinch zoom is used.
  35337. */
  35338. pinchDeltaPercentage: number;
  35339. /**
  35340. * Defines the pointer panning sensibility or how fast is the camera moving.
  35341. */
  35342. panningSensibility: number;
  35343. /**
  35344. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35345. */
  35346. multiTouchPanning: boolean;
  35347. /**
  35348. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35349. * zoom (pinch) through multitouch.
  35350. */
  35351. multiTouchPanAndZoom: boolean;
  35352. /**
  35353. * Revers pinch action direction.
  35354. */
  35355. pinchInwards: boolean;
  35356. private _isPanClick;
  35357. private _twoFingerActivityCount;
  35358. private _isPinching;
  35359. /**
  35360. * Called on pointer POINTERMOVE event if only a single touch is active.
  35361. */
  35362. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35363. /**
  35364. * Called on pointer POINTERDOUBLETAP event.
  35365. */
  35366. protected onDoubleTap(type: string): void;
  35367. /**
  35368. * Called on pointer POINTERMOVE event if multiple touches are active.
  35369. */
  35370. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35371. /**
  35372. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35373. * press.
  35374. */
  35375. protected onButtonDown(evt: PointerEvent): void;
  35376. /**
  35377. * Called each time a new POINTERUP event occurs. Ie, for each button
  35378. * release.
  35379. */
  35380. protected onButtonUp(evt: PointerEvent): void;
  35381. /**
  35382. * Called when window becomes inactive.
  35383. */
  35384. protected onLostFocus(): void;
  35385. }
  35386. }
  35387. declare module BABYLON {
  35388. /**
  35389. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35390. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35391. */
  35392. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35393. /**
  35394. * Defines the camera the input is attached to.
  35395. */
  35396. camera: ArcRotateCamera;
  35397. /**
  35398. * Defines the list of key codes associated with the up action (increase alpha)
  35399. */
  35400. keysUp: number[];
  35401. /**
  35402. * Defines the list of key codes associated with the down action (decrease alpha)
  35403. */
  35404. keysDown: number[];
  35405. /**
  35406. * Defines the list of key codes associated with the left action (increase beta)
  35407. */
  35408. keysLeft: number[];
  35409. /**
  35410. * Defines the list of key codes associated with the right action (decrease beta)
  35411. */
  35412. keysRight: number[];
  35413. /**
  35414. * Defines the list of key codes associated with the reset action.
  35415. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35416. */
  35417. keysReset: number[];
  35418. /**
  35419. * Defines the panning sensibility of the inputs.
  35420. * (How fast is the camera paning)
  35421. */
  35422. panningSensibility: number;
  35423. /**
  35424. * Defines the zooming sensibility of the inputs.
  35425. * (How fast is the camera zooming)
  35426. */
  35427. zoomingSensibility: number;
  35428. /**
  35429. * Defines wether maintaining the alt key down switch the movement mode from
  35430. * orientation to zoom.
  35431. */
  35432. useAltToZoom: boolean;
  35433. /**
  35434. * Rotation speed of the camera
  35435. */
  35436. angularSpeed: number;
  35437. private _keys;
  35438. private _ctrlPressed;
  35439. private _altPressed;
  35440. private _onCanvasBlurObserver;
  35441. private _onKeyboardObserver;
  35442. private _engine;
  35443. private _scene;
  35444. /**
  35445. * Attach the input controls to a specific dom element to get the input from.
  35446. * @param element Defines the element the controls should be listened from
  35447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35448. */
  35449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35450. /**
  35451. * Detach the current controls from the specified dom element.
  35452. * @param element Defines the element to stop listening the inputs from
  35453. */
  35454. detachControl(element: Nullable<HTMLElement>): void;
  35455. /**
  35456. * Update the current camera state depending on the inputs that have been used this frame.
  35457. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35458. */
  35459. checkInputs(): void;
  35460. /**
  35461. * Gets the class name of the current intput.
  35462. * @returns the class name
  35463. */
  35464. getClassName(): string;
  35465. /**
  35466. * Get the friendly name associated with the input class.
  35467. * @returns the input friendly name
  35468. */
  35469. getSimpleName(): string;
  35470. }
  35471. }
  35472. declare module BABYLON {
  35473. /**
  35474. * Manage the mouse wheel inputs to control an arc rotate camera.
  35475. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35476. */
  35477. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35478. /**
  35479. * Defines the camera the input is attached to.
  35480. */
  35481. camera: ArcRotateCamera;
  35482. /**
  35483. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35484. */
  35485. wheelPrecision: number;
  35486. /**
  35487. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35488. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35489. */
  35490. wheelDeltaPercentage: number;
  35491. private _wheel;
  35492. private _observer;
  35493. private computeDeltaFromMouseWheelLegacyEvent;
  35494. /**
  35495. * Attach the input controls to a specific dom element to get the input from.
  35496. * @param element Defines the element the controls should be listened from
  35497. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35498. */
  35499. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35500. /**
  35501. * Detach the current controls from the specified dom element.
  35502. * @param element Defines the element to stop listening the inputs from
  35503. */
  35504. detachControl(element: Nullable<HTMLElement>): void;
  35505. /**
  35506. * Gets the class name of the current intput.
  35507. * @returns the class name
  35508. */
  35509. getClassName(): string;
  35510. /**
  35511. * Get the friendly name associated with the input class.
  35512. * @returns the input friendly name
  35513. */
  35514. getSimpleName(): string;
  35515. }
  35516. }
  35517. declare module BABYLON {
  35518. /**
  35519. * Default Inputs manager for the ArcRotateCamera.
  35520. * It groups all the default supported inputs for ease of use.
  35521. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35522. */
  35523. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35524. /**
  35525. * Instantiates a new ArcRotateCameraInputsManager.
  35526. * @param camera Defines the camera the inputs belong to
  35527. */
  35528. constructor(camera: ArcRotateCamera);
  35529. /**
  35530. * Add mouse wheel input support to the input manager.
  35531. * @returns the current input manager
  35532. */
  35533. addMouseWheel(): ArcRotateCameraInputsManager;
  35534. /**
  35535. * Add pointers input support to the input manager.
  35536. * @returns the current input manager
  35537. */
  35538. addPointers(): ArcRotateCameraInputsManager;
  35539. /**
  35540. * Add keyboard input support to the input manager.
  35541. * @returns the current input manager
  35542. */
  35543. addKeyboard(): ArcRotateCameraInputsManager;
  35544. }
  35545. }
  35546. declare module BABYLON {
  35547. /**
  35548. * This represents an orbital type of camera.
  35549. *
  35550. * 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.
  35551. * 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.
  35552. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35553. */
  35554. export class ArcRotateCamera extends TargetCamera {
  35555. /**
  35556. * Defines the rotation angle of the camera along the longitudinal axis.
  35557. */
  35558. alpha: number;
  35559. /**
  35560. * Defines the rotation angle of the camera along the latitudinal axis.
  35561. */
  35562. beta: number;
  35563. /**
  35564. * Defines the radius of the camera from it s target point.
  35565. */
  35566. radius: number;
  35567. protected _target: Vector3;
  35568. protected _targetHost: Nullable<AbstractMesh>;
  35569. /**
  35570. * Defines the target point of the camera.
  35571. * The camera looks towards it form the radius distance.
  35572. */
  35573. target: Vector3;
  35574. /**
  35575. * Define the current local position of the camera in the scene
  35576. */
  35577. position: Vector3;
  35578. protected _upVector: Vector3;
  35579. protected _upToYMatrix: Matrix;
  35580. protected _YToUpMatrix: Matrix;
  35581. /**
  35582. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35583. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35584. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35585. */
  35586. upVector: Vector3;
  35587. /**
  35588. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35589. */
  35590. setMatUp(): void;
  35591. /**
  35592. * Current inertia value on the longitudinal axis.
  35593. * The bigger this number the longer it will take for the camera to stop.
  35594. */
  35595. inertialAlphaOffset: number;
  35596. /**
  35597. * Current inertia value on the latitudinal axis.
  35598. * The bigger this number the longer it will take for the camera to stop.
  35599. */
  35600. inertialBetaOffset: number;
  35601. /**
  35602. * Current inertia value on the radius axis.
  35603. * The bigger this number the longer it will take for the camera to stop.
  35604. */
  35605. inertialRadiusOffset: number;
  35606. /**
  35607. * Minimum allowed angle on the longitudinal axis.
  35608. * This can help limiting how the Camera is able to move in the scene.
  35609. */
  35610. lowerAlphaLimit: Nullable<number>;
  35611. /**
  35612. * Maximum allowed angle on the longitudinal axis.
  35613. * This can help limiting how the Camera is able to move in the scene.
  35614. */
  35615. upperAlphaLimit: Nullable<number>;
  35616. /**
  35617. * Minimum allowed angle on the latitudinal axis.
  35618. * This can help limiting how the Camera is able to move in the scene.
  35619. */
  35620. lowerBetaLimit: number;
  35621. /**
  35622. * Maximum allowed angle on the latitudinal axis.
  35623. * This can help limiting how the Camera is able to move in the scene.
  35624. */
  35625. upperBetaLimit: number;
  35626. /**
  35627. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35628. * This can help limiting how the Camera is able to move in the scene.
  35629. */
  35630. lowerRadiusLimit: Nullable<number>;
  35631. /**
  35632. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35633. * This can help limiting how the Camera is able to move in the scene.
  35634. */
  35635. upperRadiusLimit: Nullable<number>;
  35636. /**
  35637. * Defines the current inertia value used during panning of the camera along the X axis.
  35638. */
  35639. inertialPanningX: number;
  35640. /**
  35641. * Defines the current inertia value used during panning of the camera along the Y axis.
  35642. */
  35643. inertialPanningY: number;
  35644. /**
  35645. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35646. * Basically if your fingers moves away from more than this distance you will be considered
  35647. * in pinch mode.
  35648. */
  35649. pinchToPanMaxDistance: number;
  35650. /**
  35651. * Defines the maximum distance the camera can pan.
  35652. * This could help keeping the cammera always in your scene.
  35653. */
  35654. panningDistanceLimit: Nullable<number>;
  35655. /**
  35656. * Defines the target of the camera before paning.
  35657. */
  35658. panningOriginTarget: Vector3;
  35659. /**
  35660. * Defines the value of the inertia used during panning.
  35661. * 0 would mean stop inertia and one would mean no decelleration at all.
  35662. */
  35663. panningInertia: number;
  35664. /**
  35665. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35666. */
  35667. angularSensibilityX: number;
  35668. /**
  35669. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35670. */
  35671. angularSensibilityY: number;
  35672. /**
  35673. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35674. */
  35675. pinchPrecision: number;
  35676. /**
  35677. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35678. * It will be used instead of pinchDeltaPrecision if different from 0.
  35679. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35680. */
  35681. pinchDeltaPercentage: number;
  35682. /**
  35683. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35684. */
  35685. panningSensibility: number;
  35686. /**
  35687. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35688. */
  35689. keysUp: number[];
  35690. /**
  35691. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35692. */
  35693. keysDown: number[];
  35694. /**
  35695. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35696. */
  35697. keysLeft: number[];
  35698. /**
  35699. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35700. */
  35701. keysRight: number[];
  35702. /**
  35703. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35704. */
  35705. wheelPrecision: number;
  35706. /**
  35707. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35708. * It will be used instead of pinchDeltaPrecision if different from 0.
  35709. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35710. */
  35711. wheelDeltaPercentage: number;
  35712. /**
  35713. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35714. */
  35715. zoomOnFactor: number;
  35716. /**
  35717. * Defines a screen offset for the camera position.
  35718. */
  35719. targetScreenOffset: Vector2;
  35720. /**
  35721. * Allows the camera to be completely reversed.
  35722. * If false the camera can not arrive upside down.
  35723. */
  35724. allowUpsideDown: boolean;
  35725. /**
  35726. * Define if double tap/click is used to restore the previously saved state of the camera.
  35727. */
  35728. useInputToRestoreState: boolean;
  35729. /** @hidden */
  35730. _viewMatrix: Matrix;
  35731. /** @hidden */
  35732. _useCtrlForPanning: boolean;
  35733. /** @hidden */
  35734. _panningMouseButton: number;
  35735. /**
  35736. * Defines the input associated to the camera.
  35737. */
  35738. inputs: ArcRotateCameraInputsManager;
  35739. /** @hidden */
  35740. _reset: () => void;
  35741. /**
  35742. * Defines the allowed panning axis.
  35743. */
  35744. panningAxis: Vector3;
  35745. protected _localDirection: Vector3;
  35746. protected _transformedDirection: Vector3;
  35747. private _bouncingBehavior;
  35748. /**
  35749. * Gets the bouncing behavior of the camera if it has been enabled.
  35750. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35751. */
  35752. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35753. /**
  35754. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35755. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35756. */
  35757. useBouncingBehavior: boolean;
  35758. private _framingBehavior;
  35759. /**
  35760. * Gets the framing behavior of the camera if it has been enabled.
  35761. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35762. */
  35763. readonly framingBehavior: Nullable<FramingBehavior>;
  35764. /**
  35765. * Defines if the framing behavior of the camera is enabled on the camera.
  35766. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35767. */
  35768. useFramingBehavior: boolean;
  35769. private _autoRotationBehavior;
  35770. /**
  35771. * Gets the auto rotation behavior of the camera if it has been enabled.
  35772. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35773. */
  35774. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35775. /**
  35776. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35777. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35778. */
  35779. useAutoRotationBehavior: boolean;
  35780. /**
  35781. * Observable triggered when the mesh target has been changed on the camera.
  35782. */
  35783. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35784. /**
  35785. * Event raised when the camera is colliding with a mesh.
  35786. */
  35787. onCollide: (collidedMesh: AbstractMesh) => void;
  35788. /**
  35789. * Defines whether the camera should check collision with the objects oh the scene.
  35790. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35791. */
  35792. checkCollisions: boolean;
  35793. /**
  35794. * Defines the collision radius of the camera.
  35795. * This simulates a sphere around the camera.
  35796. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35797. */
  35798. collisionRadius: Vector3;
  35799. protected _collider: Collider;
  35800. protected _previousPosition: Vector3;
  35801. protected _collisionVelocity: Vector3;
  35802. protected _newPosition: Vector3;
  35803. protected _previousAlpha: number;
  35804. protected _previousBeta: number;
  35805. protected _previousRadius: number;
  35806. protected _collisionTriggered: boolean;
  35807. protected _targetBoundingCenter: Nullable<Vector3>;
  35808. private _computationVector;
  35809. /**
  35810. * Instantiates a new ArcRotateCamera in a given scene
  35811. * @param name Defines the name of the camera
  35812. * @param alpha Defines the camera rotation along the logitudinal axis
  35813. * @param beta Defines the camera rotation along the latitudinal axis
  35814. * @param radius Defines the camera distance from its target
  35815. * @param target Defines the camera target
  35816. * @param scene Defines the scene the camera belongs to
  35817. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35818. */
  35819. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35820. /** @hidden */
  35821. _initCache(): void;
  35822. /** @hidden */
  35823. _updateCache(ignoreParentClass?: boolean): void;
  35824. protected _getTargetPosition(): Vector3;
  35825. private _storedAlpha;
  35826. private _storedBeta;
  35827. private _storedRadius;
  35828. private _storedTarget;
  35829. /**
  35830. * Stores the current state of the camera (alpha, beta, radius and target)
  35831. * @returns the camera itself
  35832. */
  35833. storeState(): Camera;
  35834. /**
  35835. * @hidden
  35836. * Restored camera state. You must call storeState() first
  35837. */
  35838. _restoreStateValues(): boolean;
  35839. /** @hidden */
  35840. _isSynchronizedViewMatrix(): boolean;
  35841. /**
  35842. * Attached controls to the current camera.
  35843. * @param element Defines the element the controls should be listened from
  35844. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35845. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35846. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35847. */
  35848. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35849. /**
  35850. * Detach the current controls from the camera.
  35851. * The camera will stop reacting to inputs.
  35852. * @param element Defines the element to stop listening the inputs from
  35853. */
  35854. detachControl(element: HTMLElement): void;
  35855. /** @hidden */
  35856. _checkInputs(): void;
  35857. protected _checkLimits(): void;
  35858. /**
  35859. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35860. */
  35861. rebuildAnglesAndRadius(): void;
  35862. /**
  35863. * Use a position to define the current camera related information like aplha, beta and radius
  35864. * @param position Defines the position to set the camera at
  35865. */
  35866. setPosition(position: Vector3): void;
  35867. /**
  35868. * Defines the target the camera should look at.
  35869. * This will automatically adapt alpha beta and radius to fit within the new target.
  35870. * @param target Defines the new target as a Vector or a mesh
  35871. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35872. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35873. */
  35874. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35875. /** @hidden */
  35876. _getViewMatrix(): Matrix;
  35877. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35878. /**
  35879. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35880. * @param meshes Defines the mesh to zoom on
  35881. * @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)
  35882. */
  35883. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35884. /**
  35885. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35886. * The target will be changed but the radius
  35887. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35888. * @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)
  35889. */
  35890. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35891. min: Vector3;
  35892. max: Vector3;
  35893. distance: number;
  35894. }, doNotUpdateMaxZ?: boolean): void;
  35895. /**
  35896. * @override
  35897. * Override Camera.createRigCamera
  35898. */
  35899. createRigCamera(name: string, cameraIndex: number): Camera;
  35900. /**
  35901. * @hidden
  35902. * @override
  35903. * Override Camera._updateRigCameras
  35904. */
  35905. _updateRigCameras(): void;
  35906. /**
  35907. * Destroy the camera and release the current resources hold by it.
  35908. */
  35909. dispose(): void;
  35910. /**
  35911. * Gets the current object class name.
  35912. * @return the class name
  35913. */
  35914. getClassName(): string;
  35915. }
  35916. }
  35917. declare module BABYLON {
  35918. /**
  35919. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35920. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35921. */
  35922. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35923. /**
  35924. * Gets the name of the behavior.
  35925. */
  35926. readonly name: string;
  35927. private _zoomStopsAnimation;
  35928. private _idleRotationSpeed;
  35929. private _idleRotationWaitTime;
  35930. private _idleRotationSpinupTime;
  35931. /**
  35932. * Sets the flag that indicates if user zooming should stop animation.
  35933. */
  35934. /**
  35935. * Gets the flag that indicates if user zooming should stop animation.
  35936. */
  35937. zoomStopsAnimation: boolean;
  35938. /**
  35939. * Sets the default speed at which the camera rotates around the model.
  35940. */
  35941. /**
  35942. * Gets the default speed at which the camera rotates around the model.
  35943. */
  35944. idleRotationSpeed: number;
  35945. /**
  35946. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35947. */
  35948. /**
  35949. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35950. */
  35951. idleRotationWaitTime: number;
  35952. /**
  35953. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35954. */
  35955. /**
  35956. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35957. */
  35958. idleRotationSpinupTime: number;
  35959. /**
  35960. * Gets a value indicating if the camera is currently rotating because of this behavior
  35961. */
  35962. readonly rotationInProgress: boolean;
  35963. private _onPrePointerObservableObserver;
  35964. private _onAfterCheckInputsObserver;
  35965. private _attachedCamera;
  35966. private _isPointerDown;
  35967. private _lastFrameTime;
  35968. private _lastInteractionTime;
  35969. private _cameraRotationSpeed;
  35970. /**
  35971. * Initializes the behavior.
  35972. */
  35973. init(): void;
  35974. /**
  35975. * Attaches the behavior to its arc rotate camera.
  35976. * @param camera Defines the camera to attach the behavior to
  35977. */
  35978. attach(camera: ArcRotateCamera): void;
  35979. /**
  35980. * Detaches the behavior from its current arc rotate camera.
  35981. */
  35982. detach(): void;
  35983. /**
  35984. * Returns true if user is scrolling.
  35985. * @return true if user is scrolling.
  35986. */
  35987. private _userIsZooming;
  35988. private _lastFrameRadius;
  35989. private _shouldAnimationStopForInteraction;
  35990. /**
  35991. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35992. */
  35993. private _applyUserInteraction;
  35994. private _userIsMoving;
  35995. }
  35996. }
  35997. declare module BABYLON {
  35998. /**
  35999. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36000. */
  36001. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36002. private ui;
  36003. /**
  36004. * The name of the behavior
  36005. */
  36006. name: string;
  36007. /**
  36008. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36009. */
  36010. distanceAwayFromFace: number;
  36011. /**
  36012. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36013. */
  36014. distanceAwayFromBottomOfFace: number;
  36015. private _faceVectors;
  36016. private _target;
  36017. private _scene;
  36018. private _onRenderObserver;
  36019. private _tmpMatrix;
  36020. private _tmpVector;
  36021. /**
  36022. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36023. * @param ui The transform node that should be attched to the mesh
  36024. */
  36025. constructor(ui: TransformNode);
  36026. /**
  36027. * Initializes the behavior
  36028. */
  36029. init(): void;
  36030. private _closestFace;
  36031. private _zeroVector;
  36032. private _lookAtTmpMatrix;
  36033. private _lookAtToRef;
  36034. /**
  36035. * Attaches the AttachToBoxBehavior to the passed in mesh
  36036. * @param target The mesh that the specified node will be attached to
  36037. */
  36038. attach(target: Mesh): void;
  36039. /**
  36040. * Detaches the behavior from the mesh
  36041. */
  36042. detach(): void;
  36043. }
  36044. }
  36045. declare module BABYLON {
  36046. /**
  36047. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36048. */
  36049. export class FadeInOutBehavior implements Behavior<Mesh> {
  36050. /**
  36051. * Time in milliseconds to delay before fading in (Default: 0)
  36052. */
  36053. delay: number;
  36054. /**
  36055. * Time in milliseconds for the mesh to fade in (Default: 300)
  36056. */
  36057. fadeInTime: number;
  36058. private _millisecondsPerFrame;
  36059. private _hovered;
  36060. private _hoverValue;
  36061. private _ownerNode;
  36062. /**
  36063. * Instatiates the FadeInOutBehavior
  36064. */
  36065. constructor();
  36066. /**
  36067. * The name of the behavior
  36068. */
  36069. readonly name: string;
  36070. /**
  36071. * Initializes the behavior
  36072. */
  36073. init(): void;
  36074. /**
  36075. * Attaches the fade behavior on the passed in mesh
  36076. * @param ownerNode The mesh that will be faded in/out once attached
  36077. */
  36078. attach(ownerNode: Mesh): void;
  36079. /**
  36080. * Detaches the behavior from the mesh
  36081. */
  36082. detach(): void;
  36083. /**
  36084. * Triggers the mesh to begin fading in or out
  36085. * @param value if the object should fade in or out (true to fade in)
  36086. */
  36087. fadeIn(value: boolean): void;
  36088. private _update;
  36089. private _setAllVisibility;
  36090. }
  36091. }
  36092. declare module BABYLON {
  36093. /**
  36094. * Class containing a set of static utilities functions for managing Pivots
  36095. * @hidden
  36096. */
  36097. export class PivotTools {
  36098. private static _PivotCached;
  36099. private static _OldPivotPoint;
  36100. private static _PivotTranslation;
  36101. private static _PivotTmpVector;
  36102. /** @hidden */
  36103. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36104. /** @hidden */
  36105. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36106. }
  36107. }
  36108. declare module BABYLON {
  36109. /**
  36110. * Class containing static functions to help procedurally build meshes
  36111. */
  36112. export class PlaneBuilder {
  36113. /**
  36114. * Creates a plane mesh
  36115. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36116. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36117. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36119. * * 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
  36120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36121. * @param name defines the name of the mesh
  36122. * @param options defines the options used to create the mesh
  36123. * @param scene defines the hosting scene
  36124. * @returns the plane mesh
  36125. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36126. */
  36127. static CreatePlane(name: string, options: {
  36128. size?: number;
  36129. width?: number;
  36130. height?: number;
  36131. sideOrientation?: number;
  36132. frontUVs?: Vector4;
  36133. backUVs?: Vector4;
  36134. updatable?: boolean;
  36135. sourcePlane?: Plane;
  36136. }, scene?: Nullable<Scene>): Mesh;
  36137. }
  36138. }
  36139. declare module BABYLON {
  36140. /**
  36141. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36142. */
  36143. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36144. private static _AnyMouseID;
  36145. /**
  36146. * Abstract mesh the behavior is set on
  36147. */
  36148. attachedNode: AbstractMesh;
  36149. private _dragPlane;
  36150. private _scene;
  36151. private _pointerObserver;
  36152. private _beforeRenderObserver;
  36153. private static _planeScene;
  36154. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36155. /**
  36156. * 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)
  36157. */
  36158. maxDragAngle: number;
  36159. /**
  36160. * @hidden
  36161. */
  36162. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36163. /**
  36164. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36165. */
  36166. currentDraggingPointerID: number;
  36167. /**
  36168. * The last position where the pointer hit the drag plane in world space
  36169. */
  36170. lastDragPosition: Vector3;
  36171. /**
  36172. * If the behavior is currently in a dragging state
  36173. */
  36174. dragging: boolean;
  36175. /**
  36176. * 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)
  36177. */
  36178. dragDeltaRatio: number;
  36179. /**
  36180. * If the drag plane orientation should be updated during the dragging (Default: true)
  36181. */
  36182. updateDragPlane: boolean;
  36183. private _debugMode;
  36184. private _moving;
  36185. /**
  36186. * Fires each time the attached mesh is dragged with the pointer
  36187. * * delta between last drag position and current drag position in world space
  36188. * * dragDistance along the drag axis
  36189. * * dragPlaneNormal normal of the current drag plane used during the drag
  36190. * * dragPlanePoint in world space where the drag intersects the drag plane
  36191. */
  36192. onDragObservable: Observable<{
  36193. delta: Vector3;
  36194. dragPlanePoint: Vector3;
  36195. dragPlaneNormal: Vector3;
  36196. dragDistance: number;
  36197. pointerId: number;
  36198. }>;
  36199. /**
  36200. * Fires each time a drag begins (eg. mouse down on mesh)
  36201. */
  36202. onDragStartObservable: Observable<{
  36203. dragPlanePoint: Vector3;
  36204. pointerId: number;
  36205. }>;
  36206. /**
  36207. * Fires each time a drag ends (eg. mouse release after drag)
  36208. */
  36209. onDragEndObservable: Observable<{
  36210. dragPlanePoint: Vector3;
  36211. pointerId: number;
  36212. }>;
  36213. /**
  36214. * If the attached mesh should be moved when dragged
  36215. */
  36216. moveAttached: boolean;
  36217. /**
  36218. * If the drag behavior will react to drag events (Default: true)
  36219. */
  36220. enabled: boolean;
  36221. /**
  36222. * If camera controls should be detached during the drag
  36223. */
  36224. detachCameraControls: boolean;
  36225. /**
  36226. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36227. */
  36228. useObjectOrienationForDragging: boolean;
  36229. private _options;
  36230. /**
  36231. * Creates a pointer drag behavior that can be attached to a mesh
  36232. * @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)
  36233. */
  36234. constructor(options?: {
  36235. dragAxis?: Vector3;
  36236. dragPlaneNormal?: Vector3;
  36237. });
  36238. /**
  36239. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36240. */
  36241. validateDrag: (targetPosition: Vector3) => boolean;
  36242. /**
  36243. * The name of the behavior
  36244. */
  36245. readonly name: string;
  36246. /**
  36247. * Initializes the behavior
  36248. */
  36249. init(): void;
  36250. private _tmpVector;
  36251. private _alternatePickedPoint;
  36252. private _worldDragAxis;
  36253. private _targetPosition;
  36254. private _attachedElement;
  36255. /**
  36256. * Attaches the drag behavior the passed in mesh
  36257. * @param ownerNode The mesh that will be dragged around once attached
  36258. */
  36259. attach(ownerNode: AbstractMesh): void;
  36260. /**
  36261. * Force relase the drag action by code.
  36262. */
  36263. releaseDrag(): void;
  36264. private _startDragRay;
  36265. private _lastPointerRay;
  36266. /**
  36267. * Simulates the start of a pointer drag event on the behavior
  36268. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36269. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36270. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36271. */
  36272. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36273. private _startDrag;
  36274. private _dragDelta;
  36275. private _moveDrag;
  36276. private _pickWithRayOnDragPlane;
  36277. private _pointA;
  36278. private _pointB;
  36279. private _pointC;
  36280. private _lineA;
  36281. private _lineB;
  36282. private _localAxis;
  36283. private _lookAt;
  36284. private _updateDragPlanePosition;
  36285. /**
  36286. * Detaches the behavior from the mesh
  36287. */
  36288. detach(): void;
  36289. }
  36290. }
  36291. declare module BABYLON {
  36292. /**
  36293. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36294. */
  36295. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36296. private _dragBehaviorA;
  36297. private _dragBehaviorB;
  36298. private _startDistance;
  36299. private _initialScale;
  36300. private _targetScale;
  36301. private _ownerNode;
  36302. private _sceneRenderObserver;
  36303. /**
  36304. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36305. */
  36306. constructor();
  36307. /**
  36308. * The name of the behavior
  36309. */
  36310. readonly name: string;
  36311. /**
  36312. * Initializes the behavior
  36313. */
  36314. init(): void;
  36315. private _getCurrentDistance;
  36316. /**
  36317. * Attaches the scale behavior the passed in mesh
  36318. * @param ownerNode The mesh that will be scaled around once attached
  36319. */
  36320. attach(ownerNode: Mesh): void;
  36321. /**
  36322. * Detaches the behavior from the mesh
  36323. */
  36324. detach(): void;
  36325. }
  36326. }
  36327. declare module BABYLON {
  36328. /**
  36329. * 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
  36330. */
  36331. export class SixDofDragBehavior implements Behavior<Mesh> {
  36332. private static _virtualScene;
  36333. private _ownerNode;
  36334. private _sceneRenderObserver;
  36335. private _scene;
  36336. private _targetPosition;
  36337. private _virtualOriginMesh;
  36338. private _virtualDragMesh;
  36339. private _pointerObserver;
  36340. private _moving;
  36341. private _startingOrientation;
  36342. /**
  36343. * 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)
  36344. */
  36345. private zDragFactor;
  36346. /**
  36347. * If the object should rotate to face the drag origin
  36348. */
  36349. rotateDraggedObject: boolean;
  36350. /**
  36351. * If the behavior is currently in a dragging state
  36352. */
  36353. dragging: boolean;
  36354. /**
  36355. * 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)
  36356. */
  36357. dragDeltaRatio: number;
  36358. /**
  36359. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36360. */
  36361. currentDraggingPointerID: number;
  36362. /**
  36363. * If camera controls should be detached during the drag
  36364. */
  36365. detachCameraControls: boolean;
  36366. /**
  36367. * Fires each time a drag starts
  36368. */
  36369. onDragStartObservable: Observable<{}>;
  36370. /**
  36371. * Fires each time a drag ends (eg. mouse release after drag)
  36372. */
  36373. onDragEndObservable: Observable<{}>;
  36374. /**
  36375. * 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
  36376. */
  36377. constructor();
  36378. /**
  36379. * The name of the behavior
  36380. */
  36381. readonly name: string;
  36382. /**
  36383. * Initializes the behavior
  36384. */
  36385. init(): void;
  36386. /**
  36387. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36388. */
  36389. private readonly _pointerCamera;
  36390. /**
  36391. * Attaches the scale behavior the passed in mesh
  36392. * @param ownerNode The mesh that will be scaled around once attached
  36393. */
  36394. attach(ownerNode: Mesh): void;
  36395. /**
  36396. * Detaches the behavior from the mesh
  36397. */
  36398. detach(): void;
  36399. }
  36400. }
  36401. declare module BABYLON {
  36402. /**
  36403. * Class used to apply inverse kinematics to bones
  36404. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36405. */
  36406. export class BoneIKController {
  36407. private static _tmpVecs;
  36408. private static _tmpQuat;
  36409. private static _tmpMats;
  36410. /**
  36411. * Gets or sets the target mesh
  36412. */
  36413. targetMesh: AbstractMesh;
  36414. /** Gets or sets the mesh used as pole */
  36415. poleTargetMesh: AbstractMesh;
  36416. /**
  36417. * Gets or sets the bone used as pole
  36418. */
  36419. poleTargetBone: Nullable<Bone>;
  36420. /**
  36421. * Gets or sets the target position
  36422. */
  36423. targetPosition: Vector3;
  36424. /**
  36425. * Gets or sets the pole target position
  36426. */
  36427. poleTargetPosition: Vector3;
  36428. /**
  36429. * Gets or sets the pole target local offset
  36430. */
  36431. poleTargetLocalOffset: Vector3;
  36432. /**
  36433. * Gets or sets the pole angle
  36434. */
  36435. poleAngle: number;
  36436. /**
  36437. * Gets or sets the mesh associated with the controller
  36438. */
  36439. mesh: AbstractMesh;
  36440. /**
  36441. * 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)
  36442. */
  36443. slerpAmount: number;
  36444. private _bone1Quat;
  36445. private _bone1Mat;
  36446. private _bone2Ang;
  36447. private _bone1;
  36448. private _bone2;
  36449. private _bone1Length;
  36450. private _bone2Length;
  36451. private _maxAngle;
  36452. private _maxReach;
  36453. private _rightHandedSystem;
  36454. private _bendAxis;
  36455. private _slerping;
  36456. private _adjustRoll;
  36457. /**
  36458. * Gets or sets maximum allowed angle
  36459. */
  36460. maxAngle: number;
  36461. /**
  36462. * Creates a new BoneIKController
  36463. * @param mesh defines the mesh to control
  36464. * @param bone defines the bone to control
  36465. * @param options defines options to set up the controller
  36466. */
  36467. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36468. targetMesh?: AbstractMesh;
  36469. poleTargetMesh?: AbstractMesh;
  36470. poleTargetBone?: Bone;
  36471. poleTargetLocalOffset?: Vector3;
  36472. poleAngle?: number;
  36473. bendAxis?: Vector3;
  36474. maxAngle?: number;
  36475. slerpAmount?: number;
  36476. });
  36477. private _setMaxAngle;
  36478. /**
  36479. * Force the controller to update the bones
  36480. */
  36481. update(): void;
  36482. }
  36483. }
  36484. declare module BABYLON {
  36485. /**
  36486. * Class used to make a bone look toward a point in space
  36487. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36488. */
  36489. export class BoneLookController {
  36490. private static _tmpVecs;
  36491. private static _tmpQuat;
  36492. private static _tmpMats;
  36493. /**
  36494. * The target Vector3 that the bone will look at
  36495. */
  36496. target: Vector3;
  36497. /**
  36498. * The mesh that the bone is attached to
  36499. */
  36500. mesh: AbstractMesh;
  36501. /**
  36502. * The bone that will be looking to the target
  36503. */
  36504. bone: Bone;
  36505. /**
  36506. * The up axis of the coordinate system that is used when the bone is rotated
  36507. */
  36508. upAxis: Vector3;
  36509. /**
  36510. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36511. */
  36512. upAxisSpace: Space;
  36513. /**
  36514. * Used to make an adjustment to the yaw of the bone
  36515. */
  36516. adjustYaw: number;
  36517. /**
  36518. * Used to make an adjustment to the pitch of the bone
  36519. */
  36520. adjustPitch: number;
  36521. /**
  36522. * Used to make an adjustment to the roll of the bone
  36523. */
  36524. adjustRoll: number;
  36525. /**
  36526. * 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)
  36527. */
  36528. slerpAmount: number;
  36529. private _minYaw;
  36530. private _maxYaw;
  36531. private _minPitch;
  36532. private _maxPitch;
  36533. private _minYawSin;
  36534. private _minYawCos;
  36535. private _maxYawSin;
  36536. private _maxYawCos;
  36537. private _midYawConstraint;
  36538. private _minPitchTan;
  36539. private _maxPitchTan;
  36540. private _boneQuat;
  36541. private _slerping;
  36542. private _transformYawPitch;
  36543. private _transformYawPitchInv;
  36544. private _firstFrameSkipped;
  36545. private _yawRange;
  36546. private _fowardAxis;
  36547. /**
  36548. * Gets or sets the minimum yaw angle that the bone can look to
  36549. */
  36550. minYaw: number;
  36551. /**
  36552. * Gets or sets the maximum yaw angle that the bone can look to
  36553. */
  36554. maxYaw: number;
  36555. /**
  36556. * Gets or sets the minimum pitch angle that the bone can look to
  36557. */
  36558. minPitch: number;
  36559. /**
  36560. * Gets or sets the maximum pitch angle that the bone can look to
  36561. */
  36562. maxPitch: number;
  36563. /**
  36564. * Create a BoneLookController
  36565. * @param mesh the mesh that the bone belongs to
  36566. * @param bone the bone that will be looking to the target
  36567. * @param target the target Vector3 to look at
  36568. * @param options optional settings:
  36569. * * maxYaw: the maximum angle the bone will yaw to
  36570. * * minYaw: the minimum angle the bone will yaw to
  36571. * * maxPitch: the maximum angle the bone will pitch to
  36572. * * minPitch: the minimum angle the bone will yaw to
  36573. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36574. * * upAxis: the up axis of the coordinate system
  36575. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36576. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36577. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36578. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36579. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36580. * * adjustRoll: used to make an adjustment to the roll of the bone
  36581. **/
  36582. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36583. maxYaw?: number;
  36584. minYaw?: number;
  36585. maxPitch?: number;
  36586. minPitch?: number;
  36587. slerpAmount?: number;
  36588. upAxis?: Vector3;
  36589. upAxisSpace?: Space;
  36590. yawAxis?: Vector3;
  36591. pitchAxis?: Vector3;
  36592. adjustYaw?: number;
  36593. adjustPitch?: number;
  36594. adjustRoll?: number;
  36595. });
  36596. /**
  36597. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36598. */
  36599. update(): void;
  36600. private _getAngleDiff;
  36601. private _getAngleBetween;
  36602. private _isAngleBetween;
  36603. }
  36604. }
  36605. declare module BABYLON {
  36606. /**
  36607. * Manage the gamepad inputs to control an arc rotate camera.
  36608. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36609. */
  36610. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36611. /**
  36612. * Defines the camera the input is attached to.
  36613. */
  36614. camera: ArcRotateCamera;
  36615. /**
  36616. * Defines the gamepad the input is gathering event from.
  36617. */
  36618. gamepad: Nullable<Gamepad>;
  36619. /**
  36620. * Defines the gamepad rotation sensiblity.
  36621. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36622. */
  36623. gamepadRotationSensibility: number;
  36624. /**
  36625. * Defines the gamepad move sensiblity.
  36626. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36627. */
  36628. gamepadMoveSensibility: number;
  36629. private _onGamepadConnectedObserver;
  36630. private _onGamepadDisconnectedObserver;
  36631. /**
  36632. * Attach the input controls to a specific dom element to get the input from.
  36633. * @param element Defines the element the controls should be listened from
  36634. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36635. */
  36636. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36637. /**
  36638. * Detach the current controls from the specified dom element.
  36639. * @param element Defines the element to stop listening the inputs from
  36640. */
  36641. detachControl(element: Nullable<HTMLElement>): void;
  36642. /**
  36643. * Update the current camera state depending on the inputs that have been used this frame.
  36644. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36645. */
  36646. checkInputs(): void;
  36647. /**
  36648. * Gets the class name of the current intput.
  36649. * @returns the class name
  36650. */
  36651. getClassName(): string;
  36652. /**
  36653. * Get the friendly name associated with the input class.
  36654. * @returns the input friendly name
  36655. */
  36656. getSimpleName(): string;
  36657. }
  36658. }
  36659. declare module BABYLON {
  36660. interface ArcRotateCameraInputsManager {
  36661. /**
  36662. * Add orientation input support to the input manager.
  36663. * @returns the current input manager
  36664. */
  36665. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36666. }
  36667. /**
  36668. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36669. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36670. */
  36671. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36672. /**
  36673. * Defines the camera the input is attached to.
  36674. */
  36675. camera: ArcRotateCamera;
  36676. /**
  36677. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36678. */
  36679. alphaCorrection: number;
  36680. /**
  36681. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36682. */
  36683. gammaCorrection: number;
  36684. private _alpha;
  36685. private _gamma;
  36686. private _dirty;
  36687. private _deviceOrientationHandler;
  36688. /**
  36689. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36690. */
  36691. constructor();
  36692. /**
  36693. * Attach the input controls to a specific dom element to get the input from.
  36694. * @param element Defines the element the controls should be listened from
  36695. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36696. */
  36697. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36698. /** @hidden */
  36699. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36700. /**
  36701. * Update the current camera state depending on the inputs that have been used this frame.
  36702. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36703. */
  36704. checkInputs(): void;
  36705. /**
  36706. * Detach the current controls from the specified dom element.
  36707. * @param element Defines the element to stop listening the inputs from
  36708. */
  36709. detachControl(element: Nullable<HTMLElement>): void;
  36710. /**
  36711. * Gets the class name of the current intput.
  36712. * @returns the class name
  36713. */
  36714. getClassName(): string;
  36715. /**
  36716. * Get the friendly name associated with the input class.
  36717. * @returns the input friendly name
  36718. */
  36719. getSimpleName(): string;
  36720. }
  36721. }
  36722. declare module BABYLON {
  36723. /**
  36724. * Listen to mouse events to control the camera.
  36725. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36726. */
  36727. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36728. /**
  36729. * Defines the camera the input is attached to.
  36730. */
  36731. camera: FlyCamera;
  36732. /**
  36733. * Defines if touch is enabled. (Default is true.)
  36734. */
  36735. touchEnabled: boolean;
  36736. /**
  36737. * Defines the buttons associated with the input to handle camera rotation.
  36738. */
  36739. buttons: number[];
  36740. /**
  36741. * Assign buttons for Yaw control.
  36742. */
  36743. buttonsYaw: number[];
  36744. /**
  36745. * Assign buttons for Pitch control.
  36746. */
  36747. buttonsPitch: number[];
  36748. /**
  36749. * Assign buttons for Roll control.
  36750. */
  36751. buttonsRoll: number[];
  36752. /**
  36753. * Detect if any button is being pressed while mouse is moved.
  36754. * -1 = Mouse locked.
  36755. * 0 = Left button.
  36756. * 1 = Middle Button.
  36757. * 2 = Right Button.
  36758. */
  36759. activeButton: number;
  36760. /**
  36761. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36762. * Higher values reduce its sensitivity.
  36763. */
  36764. angularSensibility: number;
  36765. private _mousemoveCallback;
  36766. private _observer;
  36767. private _rollObserver;
  36768. private previousPosition;
  36769. private noPreventDefault;
  36770. private element;
  36771. /**
  36772. * Listen to mouse events to control the camera.
  36773. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36774. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36775. */
  36776. constructor(touchEnabled?: boolean);
  36777. /**
  36778. * Attach the mouse control to the HTML DOM element.
  36779. * @param element Defines the element that listens to the input events.
  36780. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36781. */
  36782. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36783. /**
  36784. * Detach the current controls from the specified dom element.
  36785. * @param element Defines the element to stop listening the inputs from
  36786. */
  36787. detachControl(element: Nullable<HTMLElement>): void;
  36788. /**
  36789. * Gets the class name of the current input.
  36790. * @returns the class name.
  36791. */
  36792. getClassName(): string;
  36793. /**
  36794. * Get the friendly name associated with the input class.
  36795. * @returns the input's friendly name.
  36796. */
  36797. getSimpleName(): string;
  36798. private _pointerInput;
  36799. private _onMouseMove;
  36800. /**
  36801. * Rotate camera by mouse offset.
  36802. */
  36803. private rotateCamera;
  36804. }
  36805. }
  36806. declare module BABYLON {
  36807. /**
  36808. * Default Inputs manager for the FlyCamera.
  36809. * It groups all the default supported inputs for ease of use.
  36810. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36811. */
  36812. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36813. /**
  36814. * Instantiates a new FlyCameraInputsManager.
  36815. * @param camera Defines the camera the inputs belong to.
  36816. */
  36817. constructor(camera: FlyCamera);
  36818. /**
  36819. * Add keyboard input support to the input manager.
  36820. * @returns the new FlyCameraKeyboardMoveInput().
  36821. */
  36822. addKeyboard(): FlyCameraInputsManager;
  36823. /**
  36824. * Add mouse input support to the input manager.
  36825. * @param touchEnabled Enable touch screen support.
  36826. * @returns the new FlyCameraMouseInput().
  36827. */
  36828. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36829. }
  36830. }
  36831. declare module BABYLON {
  36832. /**
  36833. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36834. * such as in a 3D Space Shooter or a Flight Simulator.
  36835. */
  36836. export class FlyCamera extends TargetCamera {
  36837. /**
  36838. * Define the collision ellipsoid of the camera.
  36839. * This is helpful for simulating a camera body, like a player's body.
  36840. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36841. */
  36842. ellipsoid: Vector3;
  36843. /**
  36844. * Define an offset for the position of the ellipsoid around the camera.
  36845. * This can be helpful if the camera is attached away from the player's body center,
  36846. * such as at its head.
  36847. */
  36848. ellipsoidOffset: Vector3;
  36849. /**
  36850. * Enable or disable collisions of the camera with the rest of the scene objects.
  36851. */
  36852. checkCollisions: boolean;
  36853. /**
  36854. * Enable or disable gravity on the camera.
  36855. */
  36856. applyGravity: boolean;
  36857. /**
  36858. * Define the current direction the camera is moving to.
  36859. */
  36860. cameraDirection: Vector3;
  36861. /**
  36862. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36863. * This overrides and empties cameraRotation.
  36864. */
  36865. rotationQuaternion: Quaternion;
  36866. /**
  36867. * Track Roll to maintain the wanted Rolling when looking around.
  36868. */
  36869. _trackRoll: number;
  36870. /**
  36871. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36872. */
  36873. rollCorrect: number;
  36874. /**
  36875. * Mimic a banked turn, Rolling the camera when Yawing.
  36876. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36877. */
  36878. bankedTurn: boolean;
  36879. /**
  36880. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36881. */
  36882. bankedTurnLimit: number;
  36883. /**
  36884. * Value of 0 disables the banked Roll.
  36885. * Value of 1 is equal to the Yaw angle in radians.
  36886. */
  36887. bankedTurnMultiplier: number;
  36888. /**
  36889. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36890. */
  36891. inputs: FlyCameraInputsManager;
  36892. /**
  36893. * Gets the input sensibility for mouse input.
  36894. * Higher values reduce sensitivity.
  36895. */
  36896. /**
  36897. * Sets the input sensibility for a mouse input.
  36898. * Higher values reduce sensitivity.
  36899. */
  36900. angularSensibility: number;
  36901. /**
  36902. * Get the keys for camera movement forward.
  36903. */
  36904. /**
  36905. * Set the keys for camera movement forward.
  36906. */
  36907. keysForward: number[];
  36908. /**
  36909. * Get the keys for camera movement backward.
  36910. */
  36911. keysBackward: number[];
  36912. /**
  36913. * Get the keys for camera movement up.
  36914. */
  36915. /**
  36916. * Set the keys for camera movement up.
  36917. */
  36918. keysUp: number[];
  36919. /**
  36920. * Get the keys for camera movement down.
  36921. */
  36922. /**
  36923. * Set the keys for camera movement down.
  36924. */
  36925. keysDown: number[];
  36926. /**
  36927. * Get the keys for camera movement left.
  36928. */
  36929. /**
  36930. * Set the keys for camera movement left.
  36931. */
  36932. keysLeft: number[];
  36933. /**
  36934. * Set the keys for camera movement right.
  36935. */
  36936. /**
  36937. * Set the keys for camera movement right.
  36938. */
  36939. keysRight: number[];
  36940. /**
  36941. * Event raised when the camera collides with a mesh in the scene.
  36942. */
  36943. onCollide: (collidedMesh: AbstractMesh) => void;
  36944. private _collider;
  36945. private _needMoveForGravity;
  36946. private _oldPosition;
  36947. private _diffPosition;
  36948. private _newPosition;
  36949. /** @hidden */
  36950. _localDirection: Vector3;
  36951. /** @hidden */
  36952. _transformedDirection: Vector3;
  36953. /**
  36954. * Instantiates a FlyCamera.
  36955. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36956. * such as in a 3D Space Shooter or a Flight Simulator.
  36957. * @param name Define the name of the camera in the scene.
  36958. * @param position Define the starting position of the camera in the scene.
  36959. * @param scene Define the scene the camera belongs to.
  36960. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36961. */
  36962. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36963. /**
  36964. * Attach a control to the HTML DOM element.
  36965. * @param element Defines the element that listens to the input events.
  36966. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36967. */
  36968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36969. /**
  36970. * Detach a control from the HTML DOM element.
  36971. * The camera will stop reacting to that input.
  36972. * @param element Defines the element that listens to the input events.
  36973. */
  36974. detachControl(element: HTMLElement): void;
  36975. private _collisionMask;
  36976. /**
  36977. * Get the mask that the camera ignores in collision events.
  36978. */
  36979. /**
  36980. * Set the mask that the camera ignores in collision events.
  36981. */
  36982. collisionMask: number;
  36983. /** @hidden */
  36984. _collideWithWorld(displacement: Vector3): void;
  36985. /** @hidden */
  36986. private _onCollisionPositionChange;
  36987. /** @hidden */
  36988. _checkInputs(): void;
  36989. /** @hidden */
  36990. _decideIfNeedsToMove(): boolean;
  36991. /** @hidden */
  36992. _updatePosition(): void;
  36993. /**
  36994. * Restore the Roll to its target value at the rate specified.
  36995. * @param rate - Higher means slower restoring.
  36996. * @hidden
  36997. */
  36998. restoreRoll(rate: number): void;
  36999. /**
  37000. * Destroy the camera and release the current resources held by it.
  37001. */
  37002. dispose(): void;
  37003. /**
  37004. * Get the current object class name.
  37005. * @returns the class name.
  37006. */
  37007. getClassName(): string;
  37008. }
  37009. }
  37010. declare module BABYLON {
  37011. /**
  37012. * Listen to keyboard events to control the camera.
  37013. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37014. */
  37015. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37016. /**
  37017. * Defines the camera the input is attached to.
  37018. */
  37019. camera: FlyCamera;
  37020. /**
  37021. * The list of keyboard keys used to control the forward move of the camera.
  37022. */
  37023. keysForward: number[];
  37024. /**
  37025. * The list of keyboard keys used to control the backward move of the camera.
  37026. */
  37027. keysBackward: number[];
  37028. /**
  37029. * The list of keyboard keys used to control the forward move of the camera.
  37030. */
  37031. keysUp: number[];
  37032. /**
  37033. * The list of keyboard keys used to control the backward move of the camera.
  37034. */
  37035. keysDown: number[];
  37036. /**
  37037. * The list of keyboard keys used to control the right strafe move of the camera.
  37038. */
  37039. keysRight: number[];
  37040. /**
  37041. * The list of keyboard keys used to control the left strafe move of the camera.
  37042. */
  37043. keysLeft: number[];
  37044. private _keys;
  37045. private _onCanvasBlurObserver;
  37046. private _onKeyboardObserver;
  37047. private _engine;
  37048. private _scene;
  37049. /**
  37050. * Attach the input controls to a specific dom element to get the input from.
  37051. * @param element Defines the element the controls should be listened from
  37052. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37053. */
  37054. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37055. /**
  37056. * Detach the current controls from the specified dom element.
  37057. * @param element Defines the element to stop listening the inputs from
  37058. */
  37059. detachControl(element: Nullable<HTMLElement>): void;
  37060. /**
  37061. * Gets the class name of the current intput.
  37062. * @returns the class name
  37063. */
  37064. getClassName(): string;
  37065. /** @hidden */
  37066. _onLostFocus(e: FocusEvent): void;
  37067. /**
  37068. * Get the friendly name associated with the input class.
  37069. * @returns the input friendly name
  37070. */
  37071. getSimpleName(): string;
  37072. /**
  37073. * Update the current camera state depending on the inputs that have been used this frame.
  37074. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37075. */
  37076. checkInputs(): void;
  37077. }
  37078. }
  37079. declare module BABYLON {
  37080. /**
  37081. * Manage the mouse wheel inputs to control a follow camera.
  37082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37083. */
  37084. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37085. /**
  37086. * Defines the camera the input is attached to.
  37087. */
  37088. camera: FollowCamera;
  37089. /**
  37090. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37091. */
  37092. axisControlRadius: boolean;
  37093. /**
  37094. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37095. */
  37096. axisControlHeight: boolean;
  37097. /**
  37098. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37099. */
  37100. axisControlRotation: boolean;
  37101. /**
  37102. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37103. * relation to mouseWheel events.
  37104. */
  37105. wheelPrecision: number;
  37106. /**
  37107. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37108. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37109. */
  37110. wheelDeltaPercentage: number;
  37111. private _wheel;
  37112. private _observer;
  37113. /**
  37114. * Attach the input controls to a specific dom element to get the input from.
  37115. * @param element Defines the element the controls should be listened from
  37116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37117. */
  37118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37119. /**
  37120. * Detach the current controls from the specified dom element.
  37121. * @param element Defines the element to stop listening the inputs from
  37122. */
  37123. detachControl(element: Nullable<HTMLElement>): void;
  37124. /**
  37125. * Gets the class name of the current intput.
  37126. * @returns the class name
  37127. */
  37128. getClassName(): string;
  37129. /**
  37130. * Get the friendly name associated with the input class.
  37131. * @returns the input friendly name
  37132. */
  37133. getSimpleName(): string;
  37134. }
  37135. }
  37136. declare module BABYLON {
  37137. /**
  37138. * Manage the pointers inputs to control an follow camera.
  37139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37140. */
  37141. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37142. /**
  37143. * Defines the camera the input is attached to.
  37144. */
  37145. camera: FollowCamera;
  37146. /**
  37147. * Gets the class name of the current input.
  37148. * @returns the class name
  37149. */
  37150. getClassName(): string;
  37151. /**
  37152. * Defines the pointer angular sensibility along the X axis or how fast is
  37153. * the camera rotating.
  37154. * A negative number will reverse the axis direction.
  37155. */
  37156. angularSensibilityX: number;
  37157. /**
  37158. * Defines the pointer angular sensibility along the Y axis or how fast is
  37159. * the camera rotating.
  37160. * A negative number will reverse the axis direction.
  37161. */
  37162. angularSensibilityY: number;
  37163. /**
  37164. * Defines the pointer pinch precision or how fast is the camera zooming.
  37165. * A negative number will reverse the axis direction.
  37166. */
  37167. pinchPrecision: number;
  37168. /**
  37169. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37170. * from 0.
  37171. * It defines the percentage of current camera.radius to use as delta when
  37172. * pinch zoom is used.
  37173. */
  37174. pinchDeltaPercentage: number;
  37175. /**
  37176. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37177. */
  37178. axisXControlRadius: boolean;
  37179. /**
  37180. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37181. */
  37182. axisXControlHeight: boolean;
  37183. /**
  37184. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37185. */
  37186. axisXControlRotation: boolean;
  37187. /**
  37188. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37189. */
  37190. axisYControlRadius: boolean;
  37191. /**
  37192. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37193. */
  37194. axisYControlHeight: boolean;
  37195. /**
  37196. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37197. */
  37198. axisYControlRotation: boolean;
  37199. /**
  37200. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37201. */
  37202. axisPinchControlRadius: boolean;
  37203. /**
  37204. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37205. */
  37206. axisPinchControlHeight: boolean;
  37207. /**
  37208. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37209. */
  37210. axisPinchControlRotation: boolean;
  37211. /**
  37212. * Log error messages if basic misconfiguration has occurred.
  37213. */
  37214. warningEnable: boolean;
  37215. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37216. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37217. private _warningCounter;
  37218. private _warning;
  37219. }
  37220. }
  37221. declare module BABYLON {
  37222. /**
  37223. * Default Inputs manager for the FollowCamera.
  37224. * It groups all the default supported inputs for ease of use.
  37225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37226. */
  37227. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37228. /**
  37229. * Instantiates a new FollowCameraInputsManager.
  37230. * @param camera Defines the camera the inputs belong to
  37231. */
  37232. constructor(camera: FollowCamera);
  37233. /**
  37234. * Add keyboard input support to the input manager.
  37235. * @returns the current input manager
  37236. */
  37237. addKeyboard(): FollowCameraInputsManager;
  37238. /**
  37239. * Add mouse wheel input support to the input manager.
  37240. * @returns the current input manager
  37241. */
  37242. addMouseWheel(): FollowCameraInputsManager;
  37243. /**
  37244. * Add pointers input support to the input manager.
  37245. * @returns the current input manager
  37246. */
  37247. addPointers(): FollowCameraInputsManager;
  37248. /**
  37249. * Add orientation input support to the input manager.
  37250. * @returns the current input manager
  37251. */
  37252. addVRDeviceOrientation(): FollowCameraInputsManager;
  37253. }
  37254. }
  37255. declare module BABYLON {
  37256. /**
  37257. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37258. * an arc rotate version arcFollowCamera are available.
  37259. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37260. */
  37261. export class FollowCamera extends TargetCamera {
  37262. /**
  37263. * Distance the follow camera should follow an object at
  37264. */
  37265. radius: number;
  37266. /**
  37267. * Minimum allowed distance of the camera to the axis of rotation
  37268. * (The camera can not get closer).
  37269. * This can help limiting how the Camera is able to move in the scene.
  37270. */
  37271. lowerRadiusLimit: Nullable<number>;
  37272. /**
  37273. * Maximum allowed distance of the camera to the axis of rotation
  37274. * (The camera can not get further).
  37275. * This can help limiting how the Camera is able to move in the scene.
  37276. */
  37277. upperRadiusLimit: Nullable<number>;
  37278. /**
  37279. * Define a rotation offset between the camera and the object it follows
  37280. */
  37281. rotationOffset: number;
  37282. /**
  37283. * Minimum allowed angle to camera position relative to target object.
  37284. * This can help limiting how the Camera is able to move in the scene.
  37285. */
  37286. lowerRotationOffsetLimit: Nullable<number>;
  37287. /**
  37288. * Maximum allowed angle to camera position relative to target object.
  37289. * This can help limiting how the Camera is able to move in the scene.
  37290. */
  37291. upperRotationOffsetLimit: Nullable<number>;
  37292. /**
  37293. * Define a height offset between the camera and the object it follows.
  37294. * It can help following an object from the top (like a car chaing a plane)
  37295. */
  37296. heightOffset: number;
  37297. /**
  37298. * Minimum allowed height of camera position relative to target object.
  37299. * This can help limiting how the Camera is able to move in the scene.
  37300. */
  37301. lowerHeightOffsetLimit: Nullable<number>;
  37302. /**
  37303. * Maximum allowed height of camera position relative to target object.
  37304. * This can help limiting how the Camera is able to move in the scene.
  37305. */
  37306. upperHeightOffsetLimit: Nullable<number>;
  37307. /**
  37308. * Define how fast the camera can accelerate to follow it s target.
  37309. */
  37310. cameraAcceleration: number;
  37311. /**
  37312. * Define the speed limit of the camera following an object.
  37313. */
  37314. maxCameraSpeed: number;
  37315. /**
  37316. * Define the target of the camera.
  37317. */
  37318. lockedTarget: Nullable<AbstractMesh>;
  37319. /**
  37320. * Defines the input associated with the camera.
  37321. */
  37322. inputs: FollowCameraInputsManager;
  37323. /**
  37324. * Instantiates the follow camera.
  37325. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37326. * @param name Define the name of the camera in the scene
  37327. * @param position Define the position of the camera
  37328. * @param scene Define the scene the camera belong to
  37329. * @param lockedTarget Define the target of the camera
  37330. */
  37331. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37332. private _follow;
  37333. /**
  37334. * Attached controls to the current camera.
  37335. * @param element Defines the element the controls should be listened from
  37336. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37337. */
  37338. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37339. /**
  37340. * Detach the current controls from the camera.
  37341. * The camera will stop reacting to inputs.
  37342. * @param element Defines the element to stop listening the inputs from
  37343. */
  37344. detachControl(element: HTMLElement): void;
  37345. /** @hidden */
  37346. _checkInputs(): void;
  37347. private _checkLimits;
  37348. /**
  37349. * Gets the camera class name.
  37350. * @returns the class name
  37351. */
  37352. getClassName(): string;
  37353. }
  37354. /**
  37355. * Arc Rotate version of the follow camera.
  37356. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37357. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37358. */
  37359. export class ArcFollowCamera extends TargetCamera {
  37360. /** The longitudinal angle of the camera */
  37361. alpha: number;
  37362. /** The latitudinal angle of the camera */
  37363. beta: number;
  37364. /** The radius of the camera from its target */
  37365. radius: number;
  37366. /** Define the camera target (the messh it should follow) */
  37367. target: Nullable<AbstractMesh>;
  37368. private _cartesianCoordinates;
  37369. /**
  37370. * Instantiates a new ArcFollowCamera
  37371. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37372. * @param name Define the name of the camera
  37373. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37374. * @param beta Define the rotation angle of the camera around the elevation axis
  37375. * @param radius Define the radius of the camera from its target point
  37376. * @param target Define the target of the camera
  37377. * @param scene Define the scene the camera belongs to
  37378. */
  37379. constructor(name: string,
  37380. /** The longitudinal angle of the camera */
  37381. alpha: number,
  37382. /** The latitudinal angle of the camera */
  37383. beta: number,
  37384. /** The radius of the camera from its target */
  37385. radius: number,
  37386. /** Define the camera target (the messh it should follow) */
  37387. target: Nullable<AbstractMesh>, scene: Scene);
  37388. private _follow;
  37389. /** @hidden */
  37390. _checkInputs(): void;
  37391. /**
  37392. * Returns the class name of the object.
  37393. * It is mostly used internally for serialization purposes.
  37394. */
  37395. getClassName(): string;
  37396. }
  37397. }
  37398. declare module BABYLON {
  37399. /**
  37400. * Manage the keyboard inputs to control the movement of a follow camera.
  37401. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37402. */
  37403. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37404. /**
  37405. * Defines the camera the input is attached to.
  37406. */
  37407. camera: FollowCamera;
  37408. /**
  37409. * Defines the list of key codes associated with the up action (increase heightOffset)
  37410. */
  37411. keysHeightOffsetIncr: number[];
  37412. /**
  37413. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37414. */
  37415. keysHeightOffsetDecr: number[];
  37416. /**
  37417. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37418. */
  37419. keysHeightOffsetModifierAlt: boolean;
  37420. /**
  37421. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37422. */
  37423. keysHeightOffsetModifierCtrl: boolean;
  37424. /**
  37425. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37426. */
  37427. keysHeightOffsetModifierShift: boolean;
  37428. /**
  37429. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37430. */
  37431. keysRotationOffsetIncr: number[];
  37432. /**
  37433. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37434. */
  37435. keysRotationOffsetDecr: number[];
  37436. /**
  37437. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37438. */
  37439. keysRotationOffsetModifierAlt: boolean;
  37440. /**
  37441. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37442. */
  37443. keysRotationOffsetModifierCtrl: boolean;
  37444. /**
  37445. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37446. */
  37447. keysRotationOffsetModifierShift: boolean;
  37448. /**
  37449. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37450. */
  37451. keysRadiusIncr: number[];
  37452. /**
  37453. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37454. */
  37455. keysRadiusDecr: number[];
  37456. /**
  37457. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37458. */
  37459. keysRadiusModifierAlt: boolean;
  37460. /**
  37461. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37462. */
  37463. keysRadiusModifierCtrl: boolean;
  37464. /**
  37465. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37466. */
  37467. keysRadiusModifierShift: boolean;
  37468. /**
  37469. * Defines the rate of change of heightOffset.
  37470. */
  37471. heightSensibility: number;
  37472. /**
  37473. * Defines the rate of change of rotationOffset.
  37474. */
  37475. rotationSensibility: number;
  37476. /**
  37477. * Defines the rate of change of radius.
  37478. */
  37479. radiusSensibility: number;
  37480. private _keys;
  37481. private _ctrlPressed;
  37482. private _altPressed;
  37483. private _shiftPressed;
  37484. private _onCanvasBlurObserver;
  37485. private _onKeyboardObserver;
  37486. private _engine;
  37487. private _scene;
  37488. /**
  37489. * Attach the input controls to a specific dom element to get the input from.
  37490. * @param element Defines the element the controls should be listened from
  37491. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37492. */
  37493. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37494. /**
  37495. * Detach the current controls from the specified dom element.
  37496. * @param element Defines the element to stop listening the inputs from
  37497. */
  37498. detachControl(element: Nullable<HTMLElement>): void;
  37499. /**
  37500. * Update the current camera state depending on the inputs that have been used this frame.
  37501. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37502. */
  37503. checkInputs(): void;
  37504. /**
  37505. * Gets the class name of the current input.
  37506. * @returns the class name
  37507. */
  37508. getClassName(): string;
  37509. /**
  37510. * Get the friendly name associated with the input class.
  37511. * @returns the input friendly name
  37512. */
  37513. getSimpleName(): string;
  37514. /**
  37515. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37516. * allow modification of the heightOffset value.
  37517. */
  37518. private _modifierHeightOffset;
  37519. /**
  37520. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37521. * allow modification of the rotationOffset value.
  37522. */
  37523. private _modifierRotationOffset;
  37524. /**
  37525. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37526. * allow modification of the radius value.
  37527. */
  37528. private _modifierRadius;
  37529. }
  37530. }
  37531. declare module BABYLON {
  37532. interface FreeCameraInputsManager {
  37533. /**
  37534. * @hidden
  37535. */
  37536. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37537. /**
  37538. * Add orientation input support to the input manager.
  37539. * @returns the current input manager
  37540. */
  37541. addDeviceOrientation(): FreeCameraInputsManager;
  37542. }
  37543. /**
  37544. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37545. * Screen rotation is taken into account.
  37546. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37547. */
  37548. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37549. private _camera;
  37550. private _screenOrientationAngle;
  37551. private _constantTranform;
  37552. private _screenQuaternion;
  37553. private _alpha;
  37554. private _beta;
  37555. private _gamma;
  37556. /**
  37557. * Can be used to detect if a device orientation sensor is availible on a device
  37558. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37559. * @returns a promise that will resolve on orientation change
  37560. */
  37561. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37562. /**
  37563. * @hidden
  37564. */
  37565. _onDeviceOrientationChangedObservable: Observable<void>;
  37566. /**
  37567. * Instantiates a new input
  37568. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37569. */
  37570. constructor();
  37571. /**
  37572. * Define the camera controlled by the input.
  37573. */
  37574. camera: FreeCamera;
  37575. /**
  37576. * Attach the input controls to a specific dom element to get the input from.
  37577. * @param element Defines the element the controls should be listened from
  37578. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37579. */
  37580. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37581. private _orientationChanged;
  37582. private _deviceOrientation;
  37583. /**
  37584. * Detach the current controls from the specified dom element.
  37585. * @param element Defines the element to stop listening the inputs from
  37586. */
  37587. detachControl(element: Nullable<HTMLElement>): void;
  37588. /**
  37589. * Update the current camera state depending on the inputs that have been used this frame.
  37590. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37591. */
  37592. checkInputs(): void;
  37593. /**
  37594. * Gets the class name of the current intput.
  37595. * @returns the class name
  37596. */
  37597. getClassName(): string;
  37598. /**
  37599. * Get the friendly name associated with the input class.
  37600. * @returns the input friendly name
  37601. */
  37602. getSimpleName(): string;
  37603. }
  37604. }
  37605. declare module BABYLON {
  37606. /**
  37607. * Manage the gamepad inputs to control a free camera.
  37608. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37609. */
  37610. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37611. /**
  37612. * Define the camera the input is attached to.
  37613. */
  37614. camera: FreeCamera;
  37615. /**
  37616. * Define the Gamepad controlling the input
  37617. */
  37618. gamepad: Nullable<Gamepad>;
  37619. /**
  37620. * Defines the gamepad rotation sensiblity.
  37621. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37622. */
  37623. gamepadAngularSensibility: number;
  37624. /**
  37625. * Defines the gamepad move sensiblity.
  37626. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37627. */
  37628. gamepadMoveSensibility: number;
  37629. private _onGamepadConnectedObserver;
  37630. private _onGamepadDisconnectedObserver;
  37631. private _cameraTransform;
  37632. private _deltaTransform;
  37633. private _vector3;
  37634. private _vector2;
  37635. /**
  37636. * Attach the input controls to a specific dom element to get the input from.
  37637. * @param element Defines the element the controls should be listened from
  37638. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37639. */
  37640. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37641. /**
  37642. * Detach the current controls from the specified dom element.
  37643. * @param element Defines the element to stop listening the inputs from
  37644. */
  37645. detachControl(element: Nullable<HTMLElement>): void;
  37646. /**
  37647. * Update the current camera state depending on the inputs that have been used this frame.
  37648. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37649. */
  37650. checkInputs(): void;
  37651. /**
  37652. * Gets the class name of the current intput.
  37653. * @returns the class name
  37654. */
  37655. getClassName(): string;
  37656. /**
  37657. * Get the friendly name associated with the input class.
  37658. * @returns the input friendly name
  37659. */
  37660. getSimpleName(): string;
  37661. }
  37662. }
  37663. declare module BABYLON {
  37664. /**
  37665. * Defines the potential axis of a Joystick
  37666. */
  37667. export enum JoystickAxis {
  37668. /** X axis */
  37669. X = 0,
  37670. /** Y axis */
  37671. Y = 1,
  37672. /** Z axis */
  37673. Z = 2
  37674. }
  37675. /**
  37676. * Class used to define virtual joystick (used in touch mode)
  37677. */
  37678. export class VirtualJoystick {
  37679. /**
  37680. * Gets or sets a boolean indicating that left and right values must be inverted
  37681. */
  37682. reverseLeftRight: boolean;
  37683. /**
  37684. * Gets or sets a boolean indicating that up and down values must be inverted
  37685. */
  37686. reverseUpDown: boolean;
  37687. /**
  37688. * Gets the offset value for the position (ie. the change of the position value)
  37689. */
  37690. deltaPosition: Vector3;
  37691. /**
  37692. * Gets a boolean indicating if the virtual joystick was pressed
  37693. */
  37694. pressed: boolean;
  37695. /**
  37696. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37697. */
  37698. static Canvas: Nullable<HTMLCanvasElement>;
  37699. private static _globalJoystickIndex;
  37700. private static vjCanvasContext;
  37701. private static vjCanvasWidth;
  37702. private static vjCanvasHeight;
  37703. private static halfWidth;
  37704. private _action;
  37705. private _axisTargetedByLeftAndRight;
  37706. private _axisTargetedByUpAndDown;
  37707. private _joystickSensibility;
  37708. private _inversedSensibility;
  37709. private _joystickPointerID;
  37710. private _joystickColor;
  37711. private _joystickPointerPos;
  37712. private _joystickPreviousPointerPos;
  37713. private _joystickPointerStartPos;
  37714. private _deltaJoystickVector;
  37715. private _leftJoystick;
  37716. private _touches;
  37717. private _onPointerDownHandlerRef;
  37718. private _onPointerMoveHandlerRef;
  37719. private _onPointerUpHandlerRef;
  37720. private _onResize;
  37721. /**
  37722. * Creates a new virtual joystick
  37723. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37724. */
  37725. constructor(leftJoystick?: boolean);
  37726. /**
  37727. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37728. * @param newJoystickSensibility defines the new sensibility
  37729. */
  37730. setJoystickSensibility(newJoystickSensibility: number): void;
  37731. private _onPointerDown;
  37732. private _onPointerMove;
  37733. private _onPointerUp;
  37734. /**
  37735. * Change the color of the virtual joystick
  37736. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37737. */
  37738. setJoystickColor(newColor: string): void;
  37739. /**
  37740. * Defines a callback to call when the joystick is touched
  37741. * @param action defines the callback
  37742. */
  37743. setActionOnTouch(action: () => any): void;
  37744. /**
  37745. * Defines which axis you'd like to control for left & right
  37746. * @param axis defines the axis to use
  37747. */
  37748. setAxisForLeftRight(axis: JoystickAxis): void;
  37749. /**
  37750. * Defines which axis you'd like to control for up & down
  37751. * @param axis defines the axis to use
  37752. */
  37753. setAxisForUpDown(axis: JoystickAxis): void;
  37754. private _drawVirtualJoystick;
  37755. /**
  37756. * Release internal HTML canvas
  37757. */
  37758. releaseCanvas(): void;
  37759. }
  37760. }
  37761. declare module BABYLON {
  37762. interface FreeCameraInputsManager {
  37763. /**
  37764. * Add virtual joystick input support to the input manager.
  37765. * @returns the current input manager
  37766. */
  37767. addVirtualJoystick(): FreeCameraInputsManager;
  37768. }
  37769. /**
  37770. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37772. */
  37773. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37774. /**
  37775. * Defines the camera the input is attached to.
  37776. */
  37777. camera: FreeCamera;
  37778. private _leftjoystick;
  37779. private _rightjoystick;
  37780. /**
  37781. * Gets the left stick of the virtual joystick.
  37782. * @returns The virtual Joystick
  37783. */
  37784. getLeftJoystick(): VirtualJoystick;
  37785. /**
  37786. * Gets the right stick of the virtual joystick.
  37787. * @returns The virtual Joystick
  37788. */
  37789. getRightJoystick(): VirtualJoystick;
  37790. /**
  37791. * Update the current camera state depending on the inputs that have been used this frame.
  37792. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37793. */
  37794. checkInputs(): void;
  37795. /**
  37796. * Attach the input controls to a specific dom element to get the input from.
  37797. * @param element Defines the element the controls should be listened from
  37798. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37799. */
  37800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37801. /**
  37802. * Detach the current controls from the specified dom element.
  37803. * @param element Defines the element to stop listening the inputs from
  37804. */
  37805. detachControl(element: Nullable<HTMLElement>): void;
  37806. /**
  37807. * Gets the class name of the current intput.
  37808. * @returns the class name
  37809. */
  37810. getClassName(): string;
  37811. /**
  37812. * Get the friendly name associated with the input class.
  37813. * @returns the input friendly name
  37814. */
  37815. getSimpleName(): string;
  37816. }
  37817. }
  37818. declare module BABYLON {
  37819. /**
  37820. * This represents a FPS type of camera controlled by touch.
  37821. * This is like a universal camera minus the Gamepad controls.
  37822. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37823. */
  37824. export class TouchCamera extends FreeCamera {
  37825. /**
  37826. * Defines the touch sensibility for rotation.
  37827. * The higher the faster.
  37828. */
  37829. touchAngularSensibility: number;
  37830. /**
  37831. * Defines the touch sensibility for move.
  37832. * The higher the faster.
  37833. */
  37834. touchMoveSensibility: number;
  37835. /**
  37836. * Instantiates a new touch camera.
  37837. * This represents a FPS type of camera controlled by touch.
  37838. * This is like a universal camera minus the Gamepad controls.
  37839. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37840. * @param name Define the name of the camera in the scene
  37841. * @param position Define the start position of the camera in the scene
  37842. * @param scene Define the scene the camera belongs to
  37843. */
  37844. constructor(name: string, position: Vector3, scene: Scene);
  37845. /**
  37846. * Gets the current object class name.
  37847. * @return the class name
  37848. */
  37849. getClassName(): string;
  37850. /** @hidden */
  37851. _setupInputs(): void;
  37852. }
  37853. }
  37854. declare module BABYLON {
  37855. /**
  37856. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37857. * being tilted forward or back and left or right.
  37858. */
  37859. export class DeviceOrientationCamera extends FreeCamera {
  37860. private _initialQuaternion;
  37861. private _quaternionCache;
  37862. private _tmpDragQuaternion;
  37863. /**
  37864. * Creates a new device orientation camera
  37865. * @param name The name of the camera
  37866. * @param position The start position camera
  37867. * @param scene The scene the camera belongs to
  37868. */
  37869. constructor(name: string, position: Vector3, scene: Scene);
  37870. /**
  37871. * @hidden
  37872. * Disabled pointer input on first orientation sensor update (Default: true)
  37873. */
  37874. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37875. private _dragFactor;
  37876. /**
  37877. * Enabled turning on the y axis when the orientation sensor is active
  37878. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37879. */
  37880. enableHorizontalDragging(dragFactor?: number): void;
  37881. /**
  37882. * Gets the current instance class name ("DeviceOrientationCamera").
  37883. * This helps avoiding instanceof at run time.
  37884. * @returns the class name
  37885. */
  37886. getClassName(): string;
  37887. /**
  37888. * @hidden
  37889. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37890. */
  37891. _checkInputs(): void;
  37892. /**
  37893. * Reset the camera to its default orientation on the specified axis only.
  37894. * @param axis The axis to reset
  37895. */
  37896. resetToCurrentRotation(axis?: Axis): void;
  37897. }
  37898. }
  37899. declare module BABYLON {
  37900. /**
  37901. * Defines supported buttons for XBox360 compatible gamepads
  37902. */
  37903. export enum Xbox360Button {
  37904. /** A */
  37905. A = 0,
  37906. /** B */
  37907. B = 1,
  37908. /** X */
  37909. X = 2,
  37910. /** Y */
  37911. Y = 3,
  37912. /** Start */
  37913. Start = 4,
  37914. /** Back */
  37915. Back = 5,
  37916. /** Left button */
  37917. LB = 6,
  37918. /** Right button */
  37919. RB = 7,
  37920. /** Left stick */
  37921. LeftStick = 8,
  37922. /** Right stick */
  37923. RightStick = 9
  37924. }
  37925. /** Defines values for XBox360 DPad */
  37926. export enum Xbox360Dpad {
  37927. /** Up */
  37928. Up = 0,
  37929. /** Down */
  37930. Down = 1,
  37931. /** Left */
  37932. Left = 2,
  37933. /** Right */
  37934. Right = 3
  37935. }
  37936. /**
  37937. * Defines a XBox360 gamepad
  37938. */
  37939. export class Xbox360Pad extends Gamepad {
  37940. private _leftTrigger;
  37941. private _rightTrigger;
  37942. private _onlefttriggerchanged;
  37943. private _onrighttriggerchanged;
  37944. private _onbuttondown;
  37945. private _onbuttonup;
  37946. private _ondpaddown;
  37947. private _ondpadup;
  37948. /** Observable raised when a button is pressed */
  37949. onButtonDownObservable: Observable<Xbox360Button>;
  37950. /** Observable raised when a button is released */
  37951. onButtonUpObservable: Observable<Xbox360Button>;
  37952. /** Observable raised when a pad is pressed */
  37953. onPadDownObservable: Observable<Xbox360Dpad>;
  37954. /** Observable raised when a pad is released */
  37955. onPadUpObservable: Observable<Xbox360Dpad>;
  37956. private _buttonA;
  37957. private _buttonB;
  37958. private _buttonX;
  37959. private _buttonY;
  37960. private _buttonBack;
  37961. private _buttonStart;
  37962. private _buttonLB;
  37963. private _buttonRB;
  37964. private _buttonLeftStick;
  37965. private _buttonRightStick;
  37966. private _dPadUp;
  37967. private _dPadDown;
  37968. private _dPadLeft;
  37969. private _dPadRight;
  37970. private _isXboxOnePad;
  37971. /**
  37972. * Creates a new XBox360 gamepad object
  37973. * @param id defines the id of this gamepad
  37974. * @param index defines its index
  37975. * @param gamepad defines the internal HTML gamepad object
  37976. * @param xboxOne defines if it is a XBox One gamepad
  37977. */
  37978. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37979. /**
  37980. * Defines the callback to call when left trigger is pressed
  37981. * @param callback defines the callback to use
  37982. */
  37983. onlefttriggerchanged(callback: (value: number) => void): void;
  37984. /**
  37985. * Defines the callback to call when right trigger is pressed
  37986. * @param callback defines the callback to use
  37987. */
  37988. onrighttriggerchanged(callback: (value: number) => void): void;
  37989. /**
  37990. * Gets the left trigger value
  37991. */
  37992. /**
  37993. * Sets the left trigger value
  37994. */
  37995. leftTrigger: number;
  37996. /**
  37997. * Gets the right trigger value
  37998. */
  37999. /**
  38000. * Sets the right trigger value
  38001. */
  38002. rightTrigger: number;
  38003. /**
  38004. * Defines the callback to call when a button is pressed
  38005. * @param callback defines the callback to use
  38006. */
  38007. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38008. /**
  38009. * Defines the callback to call when a button is released
  38010. * @param callback defines the callback to use
  38011. */
  38012. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38013. /**
  38014. * Defines the callback to call when a pad is pressed
  38015. * @param callback defines the callback to use
  38016. */
  38017. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38018. /**
  38019. * Defines the callback to call when a pad is released
  38020. * @param callback defines the callback to use
  38021. */
  38022. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38023. private _setButtonValue;
  38024. private _setDPadValue;
  38025. /**
  38026. * Gets the value of the `A` button
  38027. */
  38028. /**
  38029. * Sets the value of the `A` button
  38030. */
  38031. buttonA: number;
  38032. /**
  38033. * Gets the value of the `B` button
  38034. */
  38035. /**
  38036. * Sets the value of the `B` button
  38037. */
  38038. buttonB: number;
  38039. /**
  38040. * Gets the value of the `X` button
  38041. */
  38042. /**
  38043. * Sets the value of the `X` button
  38044. */
  38045. buttonX: number;
  38046. /**
  38047. * Gets the value of the `Y` button
  38048. */
  38049. /**
  38050. * Sets the value of the `Y` button
  38051. */
  38052. buttonY: number;
  38053. /**
  38054. * Gets the value of the `Start` button
  38055. */
  38056. /**
  38057. * Sets the value of the `Start` button
  38058. */
  38059. buttonStart: number;
  38060. /**
  38061. * Gets the value of the `Back` button
  38062. */
  38063. /**
  38064. * Sets the value of the `Back` button
  38065. */
  38066. buttonBack: number;
  38067. /**
  38068. * Gets the value of the `Left` button
  38069. */
  38070. /**
  38071. * Sets the value of the `Left` button
  38072. */
  38073. buttonLB: number;
  38074. /**
  38075. * Gets the value of the `Right` button
  38076. */
  38077. /**
  38078. * Sets the value of the `Right` button
  38079. */
  38080. buttonRB: number;
  38081. /**
  38082. * Gets the value of the Left joystick
  38083. */
  38084. /**
  38085. * Sets the value of the Left joystick
  38086. */
  38087. buttonLeftStick: number;
  38088. /**
  38089. * Gets the value of the Right joystick
  38090. */
  38091. /**
  38092. * Sets the value of the Right joystick
  38093. */
  38094. buttonRightStick: number;
  38095. /**
  38096. * Gets the value of D-pad up
  38097. */
  38098. /**
  38099. * Sets the value of D-pad up
  38100. */
  38101. dPadUp: number;
  38102. /**
  38103. * Gets the value of D-pad down
  38104. */
  38105. /**
  38106. * Sets the value of D-pad down
  38107. */
  38108. dPadDown: number;
  38109. /**
  38110. * Gets the value of D-pad left
  38111. */
  38112. /**
  38113. * Sets the value of D-pad left
  38114. */
  38115. dPadLeft: number;
  38116. /**
  38117. * Gets the value of D-pad right
  38118. */
  38119. /**
  38120. * Sets the value of D-pad right
  38121. */
  38122. dPadRight: number;
  38123. /**
  38124. * Force the gamepad to synchronize with device values
  38125. */
  38126. update(): void;
  38127. /**
  38128. * Disposes the gamepad
  38129. */
  38130. dispose(): void;
  38131. }
  38132. }
  38133. declare module BABYLON {
  38134. /**
  38135. * Manager for handling gamepads
  38136. */
  38137. export class GamepadManager {
  38138. private _scene?;
  38139. private _babylonGamepads;
  38140. private _oneGamepadConnected;
  38141. /** @hidden */
  38142. _isMonitoring: boolean;
  38143. private _gamepadEventSupported;
  38144. private _gamepadSupport;
  38145. /**
  38146. * observable to be triggered when the gamepad controller has been connected
  38147. */
  38148. onGamepadConnectedObservable: Observable<Gamepad>;
  38149. /**
  38150. * observable to be triggered when the gamepad controller has been disconnected
  38151. */
  38152. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38153. private _onGamepadConnectedEvent;
  38154. private _onGamepadDisconnectedEvent;
  38155. /**
  38156. * Initializes the gamepad manager
  38157. * @param _scene BabylonJS scene
  38158. */
  38159. constructor(_scene?: Scene | undefined);
  38160. /**
  38161. * The gamepads in the game pad manager
  38162. */
  38163. readonly gamepads: Gamepad[];
  38164. /**
  38165. * Get the gamepad controllers based on type
  38166. * @param type The type of gamepad controller
  38167. * @returns Nullable gamepad
  38168. */
  38169. getGamepadByType(type?: number): Nullable<Gamepad>;
  38170. /**
  38171. * Disposes the gamepad manager
  38172. */
  38173. dispose(): void;
  38174. private _addNewGamepad;
  38175. private _startMonitoringGamepads;
  38176. private _stopMonitoringGamepads;
  38177. /** @hidden */
  38178. _checkGamepadsStatus(): void;
  38179. private _updateGamepadObjects;
  38180. }
  38181. }
  38182. declare module BABYLON {
  38183. interface Scene {
  38184. /** @hidden */
  38185. _gamepadManager: Nullable<GamepadManager>;
  38186. /**
  38187. * Gets the gamepad manager associated with the scene
  38188. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38189. */
  38190. gamepadManager: GamepadManager;
  38191. }
  38192. /**
  38193. * Interface representing a free camera inputs manager
  38194. */
  38195. interface FreeCameraInputsManager {
  38196. /**
  38197. * Adds gamepad input support to the FreeCameraInputsManager.
  38198. * @returns the FreeCameraInputsManager
  38199. */
  38200. addGamepad(): FreeCameraInputsManager;
  38201. }
  38202. /**
  38203. * Interface representing an arc rotate camera inputs manager
  38204. */
  38205. interface ArcRotateCameraInputsManager {
  38206. /**
  38207. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38208. * @returns the camera inputs manager
  38209. */
  38210. addGamepad(): ArcRotateCameraInputsManager;
  38211. }
  38212. /**
  38213. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38214. */
  38215. export class GamepadSystemSceneComponent implements ISceneComponent {
  38216. /**
  38217. * The component name helpfull to identify the component in the list of scene components.
  38218. */
  38219. readonly name: string;
  38220. /**
  38221. * The scene the component belongs to.
  38222. */
  38223. scene: Scene;
  38224. /**
  38225. * Creates a new instance of the component for the given scene
  38226. * @param scene Defines the scene to register the component in
  38227. */
  38228. constructor(scene: Scene);
  38229. /**
  38230. * Registers the component in a given scene
  38231. */
  38232. register(): void;
  38233. /**
  38234. * Rebuilds the elements related to this component in case of
  38235. * context lost for instance.
  38236. */
  38237. rebuild(): void;
  38238. /**
  38239. * Disposes the component and the associated ressources
  38240. */
  38241. dispose(): void;
  38242. private _beforeCameraUpdate;
  38243. }
  38244. }
  38245. declare module BABYLON {
  38246. /**
  38247. * 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,
  38248. * which still works and will still be found in many Playgrounds.
  38249. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38250. */
  38251. export class UniversalCamera extends TouchCamera {
  38252. /**
  38253. * Defines the gamepad rotation sensiblity.
  38254. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38255. */
  38256. gamepadAngularSensibility: number;
  38257. /**
  38258. * Defines the gamepad move sensiblity.
  38259. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38260. */
  38261. gamepadMoveSensibility: number;
  38262. /**
  38263. * 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,
  38264. * which still works and will still be found in many Playgrounds.
  38265. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38266. * @param name Define the name of the camera in the scene
  38267. * @param position Define the start position of the camera in the scene
  38268. * @param scene Define the scene the camera belongs to
  38269. */
  38270. constructor(name: string, position: Vector3, scene: Scene);
  38271. /**
  38272. * Gets the current object class name.
  38273. * @return the class name
  38274. */
  38275. getClassName(): string;
  38276. }
  38277. }
  38278. declare module BABYLON {
  38279. /**
  38280. * This represents a FPS type of camera. This is only here for back compat purpose.
  38281. * Please use the UniversalCamera instead as both are identical.
  38282. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38283. */
  38284. export class GamepadCamera extends UniversalCamera {
  38285. /**
  38286. * Instantiates a new Gamepad Camera
  38287. * This represents a FPS type of camera. This is only here for back compat purpose.
  38288. * Please use the UniversalCamera instead as both are identical.
  38289. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38290. * @param name Define the name of the camera in the scene
  38291. * @param position Define the start position of the camera in the scene
  38292. * @param scene Define the scene the camera belongs to
  38293. */
  38294. constructor(name: string, position: Vector3, scene: Scene);
  38295. /**
  38296. * Gets the current object class name.
  38297. * @return the class name
  38298. */
  38299. getClassName(): string;
  38300. }
  38301. }
  38302. declare module BABYLON {
  38303. /** @hidden */
  38304. export var passPixelShader: {
  38305. name: string;
  38306. shader: string;
  38307. };
  38308. }
  38309. declare module BABYLON {
  38310. /** @hidden */
  38311. export var passCubePixelShader: {
  38312. name: string;
  38313. shader: string;
  38314. };
  38315. }
  38316. declare module BABYLON {
  38317. /**
  38318. * PassPostProcess which produces an output the same as it's input
  38319. */
  38320. export class PassPostProcess extends PostProcess {
  38321. /**
  38322. * Creates the PassPostProcess
  38323. * @param name The name of the effect.
  38324. * @param options The required width/height ratio to downsize to before computing the render pass.
  38325. * @param camera The camera to apply the render pass to.
  38326. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38327. * @param engine The engine which the post process will be applied. (default: current engine)
  38328. * @param reusable If the post process can be reused on the same frame. (default: false)
  38329. * @param textureType The type of texture to be used when performing the post processing.
  38330. * @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)
  38331. */
  38332. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38333. }
  38334. /**
  38335. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38336. */
  38337. export class PassCubePostProcess extends PostProcess {
  38338. private _face;
  38339. /**
  38340. * Gets or sets the cube face to display.
  38341. * * 0 is +X
  38342. * * 1 is -X
  38343. * * 2 is +Y
  38344. * * 3 is -Y
  38345. * * 4 is +Z
  38346. * * 5 is -Z
  38347. */
  38348. face: number;
  38349. /**
  38350. * Creates the PassCubePostProcess
  38351. * @param name The name of the effect.
  38352. * @param options The required width/height ratio to downsize to before computing the render pass.
  38353. * @param camera The camera to apply the render pass to.
  38354. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38355. * @param engine The engine which the post process will be applied. (default: current engine)
  38356. * @param reusable If the post process can be reused on the same frame. (default: false)
  38357. * @param textureType The type of texture to be used when performing the post processing.
  38358. * @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)
  38359. */
  38360. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38361. }
  38362. }
  38363. declare module BABYLON {
  38364. /** @hidden */
  38365. export var anaglyphPixelShader: {
  38366. name: string;
  38367. shader: string;
  38368. };
  38369. }
  38370. declare module BABYLON {
  38371. /**
  38372. * Postprocess used to generate anaglyphic rendering
  38373. */
  38374. export class AnaglyphPostProcess extends PostProcess {
  38375. private _passedProcess;
  38376. /**
  38377. * Creates a new AnaglyphPostProcess
  38378. * @param name defines postprocess name
  38379. * @param options defines creation options or target ratio scale
  38380. * @param rigCameras defines cameras using this postprocess
  38381. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38382. * @param engine defines hosting engine
  38383. * @param reusable defines if the postprocess will be reused multiple times per frame
  38384. */
  38385. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38386. }
  38387. }
  38388. declare module BABYLON {
  38389. /**
  38390. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38391. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38392. */
  38393. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38394. /**
  38395. * Creates a new AnaglyphArcRotateCamera
  38396. * @param name defines camera name
  38397. * @param alpha defines alpha angle (in radians)
  38398. * @param beta defines beta angle (in radians)
  38399. * @param radius defines radius
  38400. * @param target defines camera target
  38401. * @param interaxialDistance defines distance between each color axis
  38402. * @param scene defines the hosting scene
  38403. */
  38404. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38405. /**
  38406. * Gets camera class name
  38407. * @returns AnaglyphArcRotateCamera
  38408. */
  38409. getClassName(): string;
  38410. }
  38411. }
  38412. declare module BABYLON {
  38413. /**
  38414. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38415. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38416. */
  38417. export class AnaglyphFreeCamera extends FreeCamera {
  38418. /**
  38419. * Creates a new AnaglyphFreeCamera
  38420. * @param name defines camera name
  38421. * @param position defines initial position
  38422. * @param interaxialDistance defines distance between each color axis
  38423. * @param scene defines the hosting scene
  38424. */
  38425. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38426. /**
  38427. * Gets camera class name
  38428. * @returns AnaglyphFreeCamera
  38429. */
  38430. getClassName(): string;
  38431. }
  38432. }
  38433. declare module BABYLON {
  38434. /**
  38435. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38436. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38437. */
  38438. export class AnaglyphGamepadCamera extends GamepadCamera {
  38439. /**
  38440. * Creates a new AnaglyphGamepadCamera
  38441. * @param name defines camera name
  38442. * @param position defines initial position
  38443. * @param interaxialDistance defines distance between each color axis
  38444. * @param scene defines the hosting scene
  38445. */
  38446. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38447. /**
  38448. * Gets camera class name
  38449. * @returns AnaglyphGamepadCamera
  38450. */
  38451. getClassName(): string;
  38452. }
  38453. }
  38454. declare module BABYLON {
  38455. /**
  38456. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38457. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38458. */
  38459. export class AnaglyphUniversalCamera extends UniversalCamera {
  38460. /**
  38461. * Creates a new AnaglyphUniversalCamera
  38462. * @param name defines camera name
  38463. * @param position defines initial position
  38464. * @param interaxialDistance defines distance between each color axis
  38465. * @param scene defines the hosting scene
  38466. */
  38467. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38468. /**
  38469. * Gets camera class name
  38470. * @returns AnaglyphUniversalCamera
  38471. */
  38472. getClassName(): string;
  38473. }
  38474. }
  38475. declare module BABYLON {
  38476. /** @hidden */
  38477. export var stereoscopicInterlacePixelShader: {
  38478. name: string;
  38479. shader: string;
  38480. };
  38481. }
  38482. declare module BABYLON {
  38483. /**
  38484. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38485. */
  38486. export class StereoscopicInterlacePostProcess extends PostProcess {
  38487. private _stepSize;
  38488. private _passedProcess;
  38489. /**
  38490. * Initializes a StereoscopicInterlacePostProcess
  38491. * @param name The name of the effect.
  38492. * @param rigCameras The rig cameras to be appled to the post process
  38493. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38495. * @param engine The engine which the post process will be applied. (default: current engine)
  38496. * @param reusable If the post process can be reused on the same frame. (default: false)
  38497. */
  38498. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38499. }
  38500. }
  38501. declare module BABYLON {
  38502. /**
  38503. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38504. * @see http://doc.babylonjs.com/features/cameras
  38505. */
  38506. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38507. /**
  38508. * Creates a new StereoscopicArcRotateCamera
  38509. * @param name defines camera name
  38510. * @param alpha defines alpha angle (in radians)
  38511. * @param beta defines beta angle (in radians)
  38512. * @param radius defines radius
  38513. * @param target defines camera target
  38514. * @param interaxialDistance defines distance between each color axis
  38515. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38516. * @param scene defines the hosting scene
  38517. */
  38518. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38519. /**
  38520. * Gets camera class name
  38521. * @returns StereoscopicArcRotateCamera
  38522. */
  38523. getClassName(): string;
  38524. }
  38525. }
  38526. declare module BABYLON {
  38527. /**
  38528. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38529. * @see http://doc.babylonjs.com/features/cameras
  38530. */
  38531. export class StereoscopicFreeCamera extends FreeCamera {
  38532. /**
  38533. * Creates a new StereoscopicFreeCamera
  38534. * @param name defines camera name
  38535. * @param position defines initial position
  38536. * @param interaxialDistance defines distance between each color axis
  38537. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38538. * @param scene defines the hosting scene
  38539. */
  38540. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38541. /**
  38542. * Gets camera class name
  38543. * @returns StereoscopicFreeCamera
  38544. */
  38545. getClassName(): string;
  38546. }
  38547. }
  38548. declare module BABYLON {
  38549. /**
  38550. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38551. * @see http://doc.babylonjs.com/features/cameras
  38552. */
  38553. export class StereoscopicGamepadCamera extends GamepadCamera {
  38554. /**
  38555. * Creates a new StereoscopicGamepadCamera
  38556. * @param name defines camera name
  38557. * @param position defines initial position
  38558. * @param interaxialDistance defines distance between each color axis
  38559. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38560. * @param scene defines the hosting scene
  38561. */
  38562. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38563. /**
  38564. * Gets camera class name
  38565. * @returns StereoscopicGamepadCamera
  38566. */
  38567. getClassName(): string;
  38568. }
  38569. }
  38570. declare module BABYLON {
  38571. /**
  38572. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38573. * @see http://doc.babylonjs.com/features/cameras
  38574. */
  38575. export class StereoscopicUniversalCamera extends UniversalCamera {
  38576. /**
  38577. * Creates a new StereoscopicUniversalCamera
  38578. * @param name defines camera name
  38579. * @param position defines initial position
  38580. * @param interaxialDistance defines distance between each color axis
  38581. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38582. * @param scene defines the hosting scene
  38583. */
  38584. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38585. /**
  38586. * Gets camera class name
  38587. * @returns StereoscopicUniversalCamera
  38588. */
  38589. getClassName(): string;
  38590. }
  38591. }
  38592. declare module BABYLON {
  38593. /**
  38594. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38595. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38596. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38597. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38598. */
  38599. export class VirtualJoysticksCamera extends FreeCamera {
  38600. /**
  38601. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38602. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38603. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38604. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38605. * @param name Define the name of the camera in the scene
  38606. * @param position Define the start position of the camera in the scene
  38607. * @param scene Define the scene the camera belongs to
  38608. */
  38609. constructor(name: string, position: Vector3, scene: Scene);
  38610. /**
  38611. * Gets the current object class name.
  38612. * @return the class name
  38613. */
  38614. getClassName(): string;
  38615. }
  38616. }
  38617. declare module BABYLON {
  38618. /**
  38619. * This represents all the required metrics to create a VR camera.
  38620. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38621. */
  38622. export class VRCameraMetrics {
  38623. /**
  38624. * Define the horizontal resolution off the screen.
  38625. */
  38626. hResolution: number;
  38627. /**
  38628. * Define the vertical resolution off the screen.
  38629. */
  38630. vResolution: number;
  38631. /**
  38632. * Define the horizontal screen size.
  38633. */
  38634. hScreenSize: number;
  38635. /**
  38636. * Define the vertical screen size.
  38637. */
  38638. vScreenSize: number;
  38639. /**
  38640. * Define the vertical screen center position.
  38641. */
  38642. vScreenCenter: number;
  38643. /**
  38644. * Define the distance of the eyes to the screen.
  38645. */
  38646. eyeToScreenDistance: number;
  38647. /**
  38648. * Define the distance between both lenses
  38649. */
  38650. lensSeparationDistance: number;
  38651. /**
  38652. * Define the distance between both viewer's eyes.
  38653. */
  38654. interpupillaryDistance: number;
  38655. /**
  38656. * Define the distortion factor of the VR postprocess.
  38657. * Please, touch with care.
  38658. */
  38659. distortionK: number[];
  38660. /**
  38661. * Define the chromatic aberration correction factors for the VR post process.
  38662. */
  38663. chromaAbCorrection: number[];
  38664. /**
  38665. * Define the scale factor of the post process.
  38666. * The smaller the better but the slower.
  38667. */
  38668. postProcessScaleFactor: number;
  38669. /**
  38670. * Define an offset for the lens center.
  38671. */
  38672. lensCenterOffset: number;
  38673. /**
  38674. * Define if the current vr camera should compensate the distortion of the lense or not.
  38675. */
  38676. compensateDistortion: boolean;
  38677. /**
  38678. * Defines if multiview should be enabled when rendering (Default: false)
  38679. */
  38680. multiviewEnabled: boolean;
  38681. /**
  38682. * Gets the rendering aspect ratio based on the provided resolutions.
  38683. */
  38684. readonly aspectRatio: number;
  38685. /**
  38686. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38687. */
  38688. readonly aspectRatioFov: number;
  38689. /**
  38690. * @hidden
  38691. */
  38692. readonly leftHMatrix: Matrix;
  38693. /**
  38694. * @hidden
  38695. */
  38696. readonly rightHMatrix: Matrix;
  38697. /**
  38698. * @hidden
  38699. */
  38700. readonly leftPreViewMatrix: Matrix;
  38701. /**
  38702. * @hidden
  38703. */
  38704. readonly rightPreViewMatrix: Matrix;
  38705. /**
  38706. * Get the default VRMetrics based on the most generic setup.
  38707. * @returns the default vr metrics
  38708. */
  38709. static GetDefault(): VRCameraMetrics;
  38710. }
  38711. }
  38712. declare module BABYLON {
  38713. /** @hidden */
  38714. export var vrDistortionCorrectionPixelShader: {
  38715. name: string;
  38716. shader: string;
  38717. };
  38718. }
  38719. declare module BABYLON {
  38720. /**
  38721. * VRDistortionCorrectionPostProcess used for mobile VR
  38722. */
  38723. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38724. private _isRightEye;
  38725. private _distortionFactors;
  38726. private _postProcessScaleFactor;
  38727. private _lensCenterOffset;
  38728. private _scaleIn;
  38729. private _scaleFactor;
  38730. private _lensCenter;
  38731. /**
  38732. * Initializes the VRDistortionCorrectionPostProcess
  38733. * @param name The name of the effect.
  38734. * @param camera The camera to apply the render pass to.
  38735. * @param isRightEye If this is for the right eye distortion
  38736. * @param vrMetrics All the required metrics for the VR camera
  38737. */
  38738. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38739. }
  38740. }
  38741. declare module BABYLON {
  38742. /**
  38743. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38744. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38745. */
  38746. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38747. /**
  38748. * Creates a new VRDeviceOrientationArcRotateCamera
  38749. * @param name defines camera name
  38750. * @param alpha defines the camera rotation along the logitudinal axis
  38751. * @param beta defines the camera rotation along the latitudinal axis
  38752. * @param radius defines the camera distance from its target
  38753. * @param target defines the camera target
  38754. * @param scene defines the scene the camera belongs to
  38755. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38756. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38757. */
  38758. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38759. /**
  38760. * Gets camera class name
  38761. * @returns VRDeviceOrientationArcRotateCamera
  38762. */
  38763. getClassName(): string;
  38764. }
  38765. }
  38766. declare module BABYLON {
  38767. /**
  38768. * Camera used to simulate VR rendering (based on FreeCamera)
  38769. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38770. */
  38771. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38772. /**
  38773. * Creates a new VRDeviceOrientationFreeCamera
  38774. * @param name defines camera name
  38775. * @param position defines the start position of the camera
  38776. * @param scene defines the scene the camera belongs to
  38777. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38778. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38779. */
  38780. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38781. /**
  38782. * Gets camera class name
  38783. * @returns VRDeviceOrientationFreeCamera
  38784. */
  38785. getClassName(): string;
  38786. }
  38787. }
  38788. declare module BABYLON {
  38789. /**
  38790. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38791. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38792. */
  38793. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38794. /**
  38795. * Creates a new VRDeviceOrientationGamepadCamera
  38796. * @param name defines camera name
  38797. * @param position defines the start position of the camera
  38798. * @param scene defines the scene the camera belongs to
  38799. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38800. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38801. */
  38802. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38803. /**
  38804. * Gets camera class name
  38805. * @returns VRDeviceOrientationGamepadCamera
  38806. */
  38807. getClassName(): string;
  38808. }
  38809. }
  38810. declare module BABYLON {
  38811. /**
  38812. * Base class of materials working in push mode in babylon JS
  38813. * @hidden
  38814. */
  38815. export class PushMaterial extends Material {
  38816. protected _activeEffect: Effect;
  38817. protected _normalMatrix: Matrix;
  38818. /**
  38819. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38820. * This means that the material can keep using a previous shader while a new one is being compiled.
  38821. * This is mostly used when shader parallel compilation is supported (true by default)
  38822. */
  38823. allowShaderHotSwapping: boolean;
  38824. constructor(name: string, scene: Scene);
  38825. getEffect(): Effect;
  38826. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38827. /**
  38828. * Binds the given world matrix to the active effect
  38829. *
  38830. * @param world the matrix to bind
  38831. */
  38832. bindOnlyWorldMatrix(world: Matrix): void;
  38833. /**
  38834. * Binds the given normal matrix to the active effect
  38835. *
  38836. * @param normalMatrix the matrix to bind
  38837. */
  38838. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38839. bind(world: Matrix, mesh?: Mesh): void;
  38840. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38841. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38842. }
  38843. }
  38844. declare module BABYLON {
  38845. /**
  38846. * This groups all the flags used to control the materials channel.
  38847. */
  38848. export class MaterialFlags {
  38849. private static _DiffuseTextureEnabled;
  38850. /**
  38851. * Are diffuse textures enabled in the application.
  38852. */
  38853. static DiffuseTextureEnabled: boolean;
  38854. private static _AmbientTextureEnabled;
  38855. /**
  38856. * Are ambient textures enabled in the application.
  38857. */
  38858. static AmbientTextureEnabled: boolean;
  38859. private static _OpacityTextureEnabled;
  38860. /**
  38861. * Are opacity textures enabled in the application.
  38862. */
  38863. static OpacityTextureEnabled: boolean;
  38864. private static _ReflectionTextureEnabled;
  38865. /**
  38866. * Are reflection textures enabled in the application.
  38867. */
  38868. static ReflectionTextureEnabled: boolean;
  38869. private static _EmissiveTextureEnabled;
  38870. /**
  38871. * Are emissive textures enabled in the application.
  38872. */
  38873. static EmissiveTextureEnabled: boolean;
  38874. private static _SpecularTextureEnabled;
  38875. /**
  38876. * Are specular textures enabled in the application.
  38877. */
  38878. static SpecularTextureEnabled: boolean;
  38879. private static _BumpTextureEnabled;
  38880. /**
  38881. * Are bump textures enabled in the application.
  38882. */
  38883. static BumpTextureEnabled: boolean;
  38884. private static _LightmapTextureEnabled;
  38885. /**
  38886. * Are lightmap textures enabled in the application.
  38887. */
  38888. static LightmapTextureEnabled: boolean;
  38889. private static _RefractionTextureEnabled;
  38890. /**
  38891. * Are refraction textures enabled in the application.
  38892. */
  38893. static RefractionTextureEnabled: boolean;
  38894. private static _ColorGradingTextureEnabled;
  38895. /**
  38896. * Are color grading textures enabled in the application.
  38897. */
  38898. static ColorGradingTextureEnabled: boolean;
  38899. private static _FresnelEnabled;
  38900. /**
  38901. * Are fresnels enabled in the application.
  38902. */
  38903. static FresnelEnabled: boolean;
  38904. private static _ClearCoatTextureEnabled;
  38905. /**
  38906. * Are clear coat textures enabled in the application.
  38907. */
  38908. static ClearCoatTextureEnabled: boolean;
  38909. private static _ClearCoatBumpTextureEnabled;
  38910. /**
  38911. * Are clear coat bump textures enabled in the application.
  38912. */
  38913. static ClearCoatBumpTextureEnabled: boolean;
  38914. private static _ClearCoatTintTextureEnabled;
  38915. /**
  38916. * Are clear coat tint textures enabled in the application.
  38917. */
  38918. static ClearCoatTintTextureEnabled: boolean;
  38919. private static _SheenTextureEnabled;
  38920. /**
  38921. * Are sheen textures enabled in the application.
  38922. */
  38923. static SheenTextureEnabled: boolean;
  38924. private static _AnisotropicTextureEnabled;
  38925. /**
  38926. * Are anisotropic textures enabled in the application.
  38927. */
  38928. static AnisotropicTextureEnabled: boolean;
  38929. private static _ThicknessTextureEnabled;
  38930. /**
  38931. * Are thickness textures enabled in the application.
  38932. */
  38933. static ThicknessTextureEnabled: boolean;
  38934. }
  38935. }
  38936. declare module BABYLON {
  38937. /** @hidden */
  38938. export var defaultFragmentDeclaration: {
  38939. name: string;
  38940. shader: string;
  38941. };
  38942. }
  38943. declare module BABYLON {
  38944. /** @hidden */
  38945. export var defaultUboDeclaration: {
  38946. name: string;
  38947. shader: string;
  38948. };
  38949. }
  38950. declare module BABYLON {
  38951. /** @hidden */
  38952. export var lightFragmentDeclaration: {
  38953. name: string;
  38954. shader: string;
  38955. };
  38956. }
  38957. declare module BABYLON {
  38958. /** @hidden */
  38959. export var lightUboDeclaration: {
  38960. name: string;
  38961. shader: string;
  38962. };
  38963. }
  38964. declare module BABYLON {
  38965. /** @hidden */
  38966. export var lightsFragmentFunctions: {
  38967. name: string;
  38968. shader: string;
  38969. };
  38970. }
  38971. declare module BABYLON {
  38972. /** @hidden */
  38973. export var shadowsFragmentFunctions: {
  38974. name: string;
  38975. shader: string;
  38976. };
  38977. }
  38978. declare module BABYLON {
  38979. /** @hidden */
  38980. export var fresnelFunction: {
  38981. name: string;
  38982. shader: string;
  38983. };
  38984. }
  38985. declare module BABYLON {
  38986. /** @hidden */
  38987. export var reflectionFunction: {
  38988. name: string;
  38989. shader: string;
  38990. };
  38991. }
  38992. declare module BABYLON {
  38993. /** @hidden */
  38994. export var bumpFragmentFunctions: {
  38995. name: string;
  38996. shader: string;
  38997. };
  38998. }
  38999. declare module BABYLON {
  39000. /** @hidden */
  39001. export var logDepthDeclaration: {
  39002. name: string;
  39003. shader: string;
  39004. };
  39005. }
  39006. declare module BABYLON {
  39007. /** @hidden */
  39008. export var bumpFragment: {
  39009. name: string;
  39010. shader: string;
  39011. };
  39012. }
  39013. declare module BABYLON {
  39014. /** @hidden */
  39015. export var depthPrePass: {
  39016. name: string;
  39017. shader: string;
  39018. };
  39019. }
  39020. declare module BABYLON {
  39021. /** @hidden */
  39022. export var lightFragment: {
  39023. name: string;
  39024. shader: string;
  39025. };
  39026. }
  39027. declare module BABYLON {
  39028. /** @hidden */
  39029. export var logDepthFragment: {
  39030. name: string;
  39031. shader: string;
  39032. };
  39033. }
  39034. declare module BABYLON {
  39035. /** @hidden */
  39036. export var defaultPixelShader: {
  39037. name: string;
  39038. shader: string;
  39039. };
  39040. }
  39041. declare module BABYLON {
  39042. /** @hidden */
  39043. export var defaultVertexDeclaration: {
  39044. name: string;
  39045. shader: string;
  39046. };
  39047. }
  39048. declare module BABYLON {
  39049. /** @hidden */
  39050. export var bumpVertexDeclaration: {
  39051. name: string;
  39052. shader: string;
  39053. };
  39054. }
  39055. declare module BABYLON {
  39056. /** @hidden */
  39057. export var bumpVertex: {
  39058. name: string;
  39059. shader: string;
  39060. };
  39061. }
  39062. declare module BABYLON {
  39063. /** @hidden */
  39064. export var fogVertex: {
  39065. name: string;
  39066. shader: string;
  39067. };
  39068. }
  39069. declare module BABYLON {
  39070. /** @hidden */
  39071. export var shadowsVertex: {
  39072. name: string;
  39073. shader: string;
  39074. };
  39075. }
  39076. declare module BABYLON {
  39077. /** @hidden */
  39078. export var pointCloudVertex: {
  39079. name: string;
  39080. shader: string;
  39081. };
  39082. }
  39083. declare module BABYLON {
  39084. /** @hidden */
  39085. export var logDepthVertex: {
  39086. name: string;
  39087. shader: string;
  39088. };
  39089. }
  39090. declare module BABYLON {
  39091. /** @hidden */
  39092. export var defaultVertexShader: {
  39093. name: string;
  39094. shader: string;
  39095. };
  39096. }
  39097. declare module BABYLON {
  39098. /** @hidden */
  39099. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39100. MAINUV1: boolean;
  39101. MAINUV2: boolean;
  39102. DIFFUSE: boolean;
  39103. DIFFUSEDIRECTUV: number;
  39104. AMBIENT: boolean;
  39105. AMBIENTDIRECTUV: number;
  39106. OPACITY: boolean;
  39107. OPACITYDIRECTUV: number;
  39108. OPACITYRGB: boolean;
  39109. REFLECTION: boolean;
  39110. EMISSIVE: boolean;
  39111. EMISSIVEDIRECTUV: number;
  39112. SPECULAR: boolean;
  39113. SPECULARDIRECTUV: number;
  39114. BUMP: boolean;
  39115. BUMPDIRECTUV: number;
  39116. PARALLAX: boolean;
  39117. PARALLAXOCCLUSION: boolean;
  39118. SPECULAROVERALPHA: boolean;
  39119. CLIPPLANE: boolean;
  39120. CLIPPLANE2: boolean;
  39121. CLIPPLANE3: boolean;
  39122. CLIPPLANE4: boolean;
  39123. ALPHATEST: boolean;
  39124. DEPTHPREPASS: boolean;
  39125. ALPHAFROMDIFFUSE: boolean;
  39126. POINTSIZE: boolean;
  39127. FOG: boolean;
  39128. SPECULARTERM: boolean;
  39129. DIFFUSEFRESNEL: boolean;
  39130. OPACITYFRESNEL: boolean;
  39131. REFLECTIONFRESNEL: boolean;
  39132. REFRACTIONFRESNEL: boolean;
  39133. EMISSIVEFRESNEL: boolean;
  39134. FRESNEL: boolean;
  39135. NORMAL: boolean;
  39136. UV1: boolean;
  39137. UV2: boolean;
  39138. VERTEXCOLOR: boolean;
  39139. VERTEXALPHA: boolean;
  39140. NUM_BONE_INFLUENCERS: number;
  39141. BonesPerMesh: number;
  39142. BONETEXTURE: boolean;
  39143. INSTANCES: boolean;
  39144. GLOSSINESS: boolean;
  39145. ROUGHNESS: boolean;
  39146. EMISSIVEASILLUMINATION: boolean;
  39147. LINKEMISSIVEWITHDIFFUSE: boolean;
  39148. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39149. LIGHTMAP: boolean;
  39150. LIGHTMAPDIRECTUV: number;
  39151. OBJECTSPACE_NORMALMAP: boolean;
  39152. USELIGHTMAPASSHADOWMAP: boolean;
  39153. REFLECTIONMAP_3D: boolean;
  39154. REFLECTIONMAP_SPHERICAL: boolean;
  39155. REFLECTIONMAP_PLANAR: boolean;
  39156. REFLECTIONMAP_CUBIC: boolean;
  39157. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39158. REFLECTIONMAP_PROJECTION: boolean;
  39159. REFLECTIONMAP_SKYBOX: boolean;
  39160. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39161. REFLECTIONMAP_EXPLICIT: boolean;
  39162. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39163. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39164. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39165. INVERTCUBICMAP: boolean;
  39166. LOGARITHMICDEPTH: boolean;
  39167. REFRACTION: boolean;
  39168. REFRACTIONMAP_3D: boolean;
  39169. REFLECTIONOVERALPHA: boolean;
  39170. TWOSIDEDLIGHTING: boolean;
  39171. SHADOWFLOAT: boolean;
  39172. MORPHTARGETS: boolean;
  39173. MORPHTARGETS_NORMAL: boolean;
  39174. MORPHTARGETS_TANGENT: boolean;
  39175. MORPHTARGETS_UV: boolean;
  39176. NUM_MORPH_INFLUENCERS: number;
  39177. NONUNIFORMSCALING: boolean;
  39178. PREMULTIPLYALPHA: boolean;
  39179. IMAGEPROCESSING: boolean;
  39180. VIGNETTE: boolean;
  39181. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39182. VIGNETTEBLENDMODEOPAQUE: boolean;
  39183. TONEMAPPING: boolean;
  39184. TONEMAPPING_ACES: boolean;
  39185. CONTRAST: boolean;
  39186. COLORCURVES: boolean;
  39187. COLORGRADING: boolean;
  39188. COLORGRADING3D: boolean;
  39189. SAMPLER3DGREENDEPTH: boolean;
  39190. SAMPLER3DBGRMAP: boolean;
  39191. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39192. MULTIVIEW: boolean;
  39193. /**
  39194. * If the reflection texture on this material is in linear color space
  39195. * @hidden
  39196. */
  39197. IS_REFLECTION_LINEAR: boolean;
  39198. /**
  39199. * If the refraction texture on this material is in linear color space
  39200. * @hidden
  39201. */
  39202. IS_REFRACTION_LINEAR: boolean;
  39203. EXPOSURE: boolean;
  39204. constructor();
  39205. setReflectionMode(modeToEnable: string): void;
  39206. }
  39207. /**
  39208. * This is the default material used in Babylon. It is the best trade off between quality
  39209. * and performances.
  39210. * @see http://doc.babylonjs.com/babylon101/materials
  39211. */
  39212. export class StandardMaterial extends PushMaterial {
  39213. private _diffuseTexture;
  39214. /**
  39215. * The basic texture of the material as viewed under a light.
  39216. */
  39217. diffuseTexture: Nullable<BaseTexture>;
  39218. private _ambientTexture;
  39219. /**
  39220. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39221. */
  39222. ambientTexture: Nullable<BaseTexture>;
  39223. private _opacityTexture;
  39224. /**
  39225. * Define the transparency of the material from a texture.
  39226. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39227. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39228. */
  39229. opacityTexture: Nullable<BaseTexture>;
  39230. private _reflectionTexture;
  39231. /**
  39232. * Define the texture used to display the reflection.
  39233. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39234. */
  39235. reflectionTexture: Nullable<BaseTexture>;
  39236. private _emissiveTexture;
  39237. /**
  39238. * Define texture of the material as if self lit.
  39239. * This will be mixed in the final result even in the absence of light.
  39240. */
  39241. emissiveTexture: Nullable<BaseTexture>;
  39242. private _specularTexture;
  39243. /**
  39244. * Define how the color and intensity of the highlight given by the light in the material.
  39245. */
  39246. specularTexture: Nullable<BaseTexture>;
  39247. private _bumpTexture;
  39248. /**
  39249. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39250. * 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.
  39251. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39252. */
  39253. bumpTexture: Nullable<BaseTexture>;
  39254. private _lightmapTexture;
  39255. /**
  39256. * Complex lighting can be computationally expensive to compute at runtime.
  39257. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39258. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39259. */
  39260. lightmapTexture: Nullable<BaseTexture>;
  39261. private _refractionTexture;
  39262. /**
  39263. * Define the texture used to display the refraction.
  39264. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39265. */
  39266. refractionTexture: Nullable<BaseTexture>;
  39267. /**
  39268. * The color of the material lit by the environmental background lighting.
  39269. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39270. */
  39271. ambientColor: Color3;
  39272. /**
  39273. * The basic color of the material as viewed under a light.
  39274. */
  39275. diffuseColor: Color3;
  39276. /**
  39277. * Define how the color and intensity of the highlight given by the light in the material.
  39278. */
  39279. specularColor: Color3;
  39280. /**
  39281. * Define the color of the material as if self lit.
  39282. * This will be mixed in the final result even in the absence of light.
  39283. */
  39284. emissiveColor: Color3;
  39285. /**
  39286. * Defines how sharp are the highlights in the material.
  39287. * The bigger the value the sharper giving a more glossy feeling to the result.
  39288. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39289. */
  39290. specularPower: number;
  39291. private _useAlphaFromDiffuseTexture;
  39292. /**
  39293. * Does the transparency come from the diffuse texture alpha channel.
  39294. */
  39295. useAlphaFromDiffuseTexture: boolean;
  39296. private _useEmissiveAsIllumination;
  39297. /**
  39298. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39299. */
  39300. useEmissiveAsIllumination: boolean;
  39301. private _linkEmissiveWithDiffuse;
  39302. /**
  39303. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39304. * the emissive level when the final color is close to one.
  39305. */
  39306. linkEmissiveWithDiffuse: boolean;
  39307. private _useSpecularOverAlpha;
  39308. /**
  39309. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39310. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39311. */
  39312. useSpecularOverAlpha: boolean;
  39313. private _useReflectionOverAlpha;
  39314. /**
  39315. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39316. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39317. */
  39318. useReflectionOverAlpha: boolean;
  39319. private _disableLighting;
  39320. /**
  39321. * Does lights from the scene impacts this material.
  39322. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39323. */
  39324. disableLighting: boolean;
  39325. private _useObjectSpaceNormalMap;
  39326. /**
  39327. * Allows using an object space normal map (instead of tangent space).
  39328. */
  39329. useObjectSpaceNormalMap: boolean;
  39330. private _useParallax;
  39331. /**
  39332. * Is parallax enabled or not.
  39333. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39334. */
  39335. useParallax: boolean;
  39336. private _useParallaxOcclusion;
  39337. /**
  39338. * Is parallax occlusion enabled or not.
  39339. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39340. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39341. */
  39342. useParallaxOcclusion: boolean;
  39343. /**
  39344. * 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.
  39345. */
  39346. parallaxScaleBias: number;
  39347. private _roughness;
  39348. /**
  39349. * Helps to define how blurry the reflections should appears in the material.
  39350. */
  39351. roughness: number;
  39352. /**
  39353. * In case of refraction, define the value of the index of refraction.
  39354. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39355. */
  39356. indexOfRefraction: number;
  39357. /**
  39358. * Invert the refraction texture alongside the y axis.
  39359. * It can be useful with procedural textures or probe for instance.
  39360. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39361. */
  39362. invertRefractionY: boolean;
  39363. /**
  39364. * Defines the alpha limits in alpha test mode.
  39365. */
  39366. alphaCutOff: number;
  39367. private _useLightmapAsShadowmap;
  39368. /**
  39369. * In case of light mapping, define whether the map contains light or shadow informations.
  39370. */
  39371. useLightmapAsShadowmap: boolean;
  39372. private _diffuseFresnelParameters;
  39373. /**
  39374. * Define the diffuse fresnel parameters of the material.
  39375. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39376. */
  39377. diffuseFresnelParameters: FresnelParameters;
  39378. private _opacityFresnelParameters;
  39379. /**
  39380. * Define the opacity fresnel parameters of the material.
  39381. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39382. */
  39383. opacityFresnelParameters: FresnelParameters;
  39384. private _reflectionFresnelParameters;
  39385. /**
  39386. * Define the reflection fresnel parameters of the material.
  39387. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39388. */
  39389. reflectionFresnelParameters: FresnelParameters;
  39390. private _refractionFresnelParameters;
  39391. /**
  39392. * Define the refraction fresnel parameters of the material.
  39393. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39394. */
  39395. refractionFresnelParameters: FresnelParameters;
  39396. private _emissiveFresnelParameters;
  39397. /**
  39398. * Define the emissive fresnel parameters of the material.
  39399. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39400. */
  39401. emissiveFresnelParameters: FresnelParameters;
  39402. private _useReflectionFresnelFromSpecular;
  39403. /**
  39404. * If true automatically deducts the fresnels values from the material specularity.
  39405. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39406. */
  39407. useReflectionFresnelFromSpecular: boolean;
  39408. private _useGlossinessFromSpecularMapAlpha;
  39409. /**
  39410. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39411. */
  39412. useGlossinessFromSpecularMapAlpha: boolean;
  39413. private _maxSimultaneousLights;
  39414. /**
  39415. * Defines the maximum number of lights that can be used in the material
  39416. */
  39417. maxSimultaneousLights: number;
  39418. private _invertNormalMapX;
  39419. /**
  39420. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39421. */
  39422. invertNormalMapX: boolean;
  39423. private _invertNormalMapY;
  39424. /**
  39425. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39426. */
  39427. invertNormalMapY: boolean;
  39428. private _twoSidedLighting;
  39429. /**
  39430. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39431. */
  39432. twoSidedLighting: boolean;
  39433. /**
  39434. * Default configuration related to image processing available in the standard Material.
  39435. */
  39436. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39437. /**
  39438. * Gets the image processing configuration used either in this material.
  39439. */
  39440. /**
  39441. * Sets the Default image processing configuration used either in the this material.
  39442. *
  39443. * If sets to null, the scene one is in use.
  39444. */
  39445. imageProcessingConfiguration: ImageProcessingConfiguration;
  39446. /**
  39447. * Keep track of the image processing observer to allow dispose and replace.
  39448. */
  39449. private _imageProcessingObserver;
  39450. /**
  39451. * Attaches a new image processing configuration to the Standard Material.
  39452. * @param configuration
  39453. */
  39454. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39455. /**
  39456. * Gets wether the color curves effect is enabled.
  39457. */
  39458. /**
  39459. * Sets wether the color curves effect is enabled.
  39460. */
  39461. cameraColorCurvesEnabled: boolean;
  39462. /**
  39463. * Gets wether the color grading effect is enabled.
  39464. */
  39465. /**
  39466. * Gets wether the color grading effect is enabled.
  39467. */
  39468. cameraColorGradingEnabled: boolean;
  39469. /**
  39470. * Gets wether tonemapping is enabled or not.
  39471. */
  39472. /**
  39473. * Sets wether tonemapping is enabled or not
  39474. */
  39475. cameraToneMappingEnabled: boolean;
  39476. /**
  39477. * The camera exposure used on this material.
  39478. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39479. * This corresponds to a photographic exposure.
  39480. */
  39481. /**
  39482. * The camera exposure used on this material.
  39483. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39484. * This corresponds to a photographic exposure.
  39485. */
  39486. cameraExposure: number;
  39487. /**
  39488. * Gets The camera contrast used on this material.
  39489. */
  39490. /**
  39491. * Sets The camera contrast used on this material.
  39492. */
  39493. cameraContrast: number;
  39494. /**
  39495. * Gets the Color Grading 2D Lookup Texture.
  39496. */
  39497. /**
  39498. * Sets the Color Grading 2D Lookup Texture.
  39499. */
  39500. cameraColorGradingTexture: Nullable<BaseTexture>;
  39501. /**
  39502. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39503. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39504. * 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;
  39505. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39506. */
  39507. /**
  39508. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39509. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39510. * 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;
  39511. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39512. */
  39513. cameraColorCurves: Nullable<ColorCurves>;
  39514. /**
  39515. * Custom callback helping to override the default shader used in the material.
  39516. */
  39517. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39518. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39519. protected _worldViewProjectionMatrix: Matrix;
  39520. protected _globalAmbientColor: Color3;
  39521. protected _useLogarithmicDepth: boolean;
  39522. /**
  39523. * Instantiates a new standard material.
  39524. * This is the default material used in Babylon. It is the best trade off between quality
  39525. * and performances.
  39526. * @see http://doc.babylonjs.com/babylon101/materials
  39527. * @param name Define the name of the material in the scene
  39528. * @param scene Define the scene the material belong to
  39529. */
  39530. constructor(name: string, scene: Scene);
  39531. /**
  39532. * Gets a boolean indicating that current material needs to register RTT
  39533. */
  39534. readonly hasRenderTargetTextures: boolean;
  39535. /**
  39536. * Gets the current class name of the material e.g. "StandardMaterial"
  39537. * Mainly use in serialization.
  39538. * @returns the class name
  39539. */
  39540. getClassName(): string;
  39541. /**
  39542. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39543. * You can try switching to logarithmic depth.
  39544. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39545. */
  39546. useLogarithmicDepth: boolean;
  39547. /**
  39548. * Specifies if the material will require alpha blending
  39549. * @returns a boolean specifying if alpha blending is needed
  39550. */
  39551. needAlphaBlending(): boolean;
  39552. /**
  39553. * Specifies if this material should be rendered in alpha test mode
  39554. * @returns a boolean specifying if an alpha test is needed.
  39555. */
  39556. needAlphaTesting(): boolean;
  39557. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39558. /**
  39559. * Get the texture used for alpha test purpose.
  39560. * @returns the diffuse texture in case of the standard material.
  39561. */
  39562. getAlphaTestTexture(): Nullable<BaseTexture>;
  39563. /**
  39564. * Get if the submesh is ready to be used and all its information available.
  39565. * Child classes can use it to update shaders
  39566. * @param mesh defines the mesh to check
  39567. * @param subMesh defines which submesh to check
  39568. * @param useInstances specifies that instances should be used
  39569. * @returns a boolean indicating that the submesh is ready or not
  39570. */
  39571. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39572. /**
  39573. * Builds the material UBO layouts.
  39574. * Used internally during the effect preparation.
  39575. */
  39576. buildUniformLayout(): void;
  39577. /**
  39578. * Unbinds the material from the mesh
  39579. */
  39580. unbind(): void;
  39581. /**
  39582. * Binds the submesh to this material by preparing the effect and shader to draw
  39583. * @param world defines the world transformation matrix
  39584. * @param mesh defines the mesh containing the submesh
  39585. * @param subMesh defines the submesh to bind the material to
  39586. */
  39587. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39588. /**
  39589. * Get the list of animatables in the material.
  39590. * @returns the list of animatables object used in the material
  39591. */
  39592. getAnimatables(): IAnimatable[];
  39593. /**
  39594. * Gets the active textures from the material
  39595. * @returns an array of textures
  39596. */
  39597. getActiveTextures(): BaseTexture[];
  39598. /**
  39599. * Specifies if the material uses a texture
  39600. * @param texture defines the texture to check against the material
  39601. * @returns a boolean specifying if the material uses the texture
  39602. */
  39603. hasTexture(texture: BaseTexture): boolean;
  39604. /**
  39605. * Disposes the material
  39606. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39607. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39608. */
  39609. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39610. /**
  39611. * Makes a duplicate of the material, and gives it a new name
  39612. * @param name defines the new name for the duplicated material
  39613. * @returns the cloned material
  39614. */
  39615. clone(name: string): StandardMaterial;
  39616. /**
  39617. * Serializes this material in a JSON representation
  39618. * @returns the serialized material object
  39619. */
  39620. serialize(): any;
  39621. /**
  39622. * Creates a standard material from parsed material data
  39623. * @param source defines the JSON representation of the material
  39624. * @param scene defines the hosting scene
  39625. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39626. * @returns a new standard material
  39627. */
  39628. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39629. /**
  39630. * Are diffuse textures enabled in the application.
  39631. */
  39632. static DiffuseTextureEnabled: boolean;
  39633. /**
  39634. * Are ambient textures enabled in the application.
  39635. */
  39636. static AmbientTextureEnabled: boolean;
  39637. /**
  39638. * Are opacity textures enabled in the application.
  39639. */
  39640. static OpacityTextureEnabled: boolean;
  39641. /**
  39642. * Are reflection textures enabled in the application.
  39643. */
  39644. static ReflectionTextureEnabled: boolean;
  39645. /**
  39646. * Are emissive textures enabled in the application.
  39647. */
  39648. static EmissiveTextureEnabled: boolean;
  39649. /**
  39650. * Are specular textures enabled in the application.
  39651. */
  39652. static SpecularTextureEnabled: boolean;
  39653. /**
  39654. * Are bump textures enabled in the application.
  39655. */
  39656. static BumpTextureEnabled: boolean;
  39657. /**
  39658. * Are lightmap textures enabled in the application.
  39659. */
  39660. static LightmapTextureEnabled: boolean;
  39661. /**
  39662. * Are refraction textures enabled in the application.
  39663. */
  39664. static RefractionTextureEnabled: boolean;
  39665. /**
  39666. * Are color grading textures enabled in the application.
  39667. */
  39668. static ColorGradingTextureEnabled: boolean;
  39669. /**
  39670. * Are fresnels enabled in the application.
  39671. */
  39672. static FresnelEnabled: boolean;
  39673. }
  39674. }
  39675. declare module BABYLON {
  39676. /**
  39677. * A class extending Texture allowing drawing on a texture
  39678. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39679. */
  39680. export class DynamicTexture extends Texture {
  39681. private _generateMipMaps;
  39682. private _canvas;
  39683. private _context;
  39684. private _engine;
  39685. /**
  39686. * Creates a DynamicTexture
  39687. * @param name defines the name of the texture
  39688. * @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
  39689. * @param scene defines the scene where you want the texture
  39690. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39691. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39692. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39693. */
  39694. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39695. /**
  39696. * Get the current class name of the texture useful for serialization or dynamic coding.
  39697. * @returns "DynamicTexture"
  39698. */
  39699. getClassName(): string;
  39700. /**
  39701. * Gets the current state of canRescale
  39702. */
  39703. readonly canRescale: boolean;
  39704. private _recreate;
  39705. /**
  39706. * Scales the texture
  39707. * @param ratio the scale factor to apply to both width and height
  39708. */
  39709. scale(ratio: number): void;
  39710. /**
  39711. * Resizes the texture
  39712. * @param width the new width
  39713. * @param height the new height
  39714. */
  39715. scaleTo(width: number, height: number): void;
  39716. /**
  39717. * Gets the context of the canvas used by the texture
  39718. * @returns the canvas context of the dynamic texture
  39719. */
  39720. getContext(): CanvasRenderingContext2D;
  39721. /**
  39722. * Clears the texture
  39723. */
  39724. clear(): void;
  39725. /**
  39726. * Updates the texture
  39727. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39728. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39729. */
  39730. update(invertY?: boolean, premulAlpha?: boolean): void;
  39731. /**
  39732. * Draws text onto the texture
  39733. * @param text defines the text to be drawn
  39734. * @param x defines the placement of the text from the left
  39735. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39736. * @param font defines the font to be used with font-style, font-size, font-name
  39737. * @param color defines the color used for the text
  39738. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39739. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39740. * @param update defines whether texture is immediately update (default is true)
  39741. */
  39742. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39743. /**
  39744. * Clones the texture
  39745. * @returns the clone of the texture.
  39746. */
  39747. clone(): DynamicTexture;
  39748. /**
  39749. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39750. * @returns a serialized dynamic texture object
  39751. */
  39752. serialize(): any;
  39753. /** @hidden */
  39754. _rebuild(): void;
  39755. }
  39756. }
  39757. declare module BABYLON {
  39758. /** @hidden */
  39759. export var imageProcessingPixelShader: {
  39760. name: string;
  39761. shader: string;
  39762. };
  39763. }
  39764. declare module BABYLON {
  39765. /**
  39766. * ImageProcessingPostProcess
  39767. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39768. */
  39769. export class ImageProcessingPostProcess extends PostProcess {
  39770. /**
  39771. * Default configuration related to image processing available in the PBR Material.
  39772. */
  39773. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39774. /**
  39775. * Gets the image processing configuration used either in this material.
  39776. */
  39777. /**
  39778. * Sets the Default image processing configuration used either in the this material.
  39779. *
  39780. * If sets to null, the scene one is in use.
  39781. */
  39782. imageProcessingConfiguration: ImageProcessingConfiguration;
  39783. /**
  39784. * Keep track of the image processing observer to allow dispose and replace.
  39785. */
  39786. private _imageProcessingObserver;
  39787. /**
  39788. * Attaches a new image processing configuration to the PBR Material.
  39789. * @param configuration
  39790. */
  39791. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39792. /**
  39793. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39794. */
  39795. /**
  39796. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39797. */
  39798. colorCurves: Nullable<ColorCurves>;
  39799. /**
  39800. * Gets wether the color curves effect is enabled.
  39801. */
  39802. /**
  39803. * Sets wether the color curves effect is enabled.
  39804. */
  39805. colorCurvesEnabled: boolean;
  39806. /**
  39807. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39808. */
  39809. /**
  39810. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39811. */
  39812. colorGradingTexture: Nullable<BaseTexture>;
  39813. /**
  39814. * Gets wether the color grading effect is enabled.
  39815. */
  39816. /**
  39817. * Gets wether the color grading effect is enabled.
  39818. */
  39819. colorGradingEnabled: boolean;
  39820. /**
  39821. * Gets exposure used in the effect.
  39822. */
  39823. /**
  39824. * Sets exposure used in the effect.
  39825. */
  39826. exposure: number;
  39827. /**
  39828. * Gets wether tonemapping is enabled or not.
  39829. */
  39830. /**
  39831. * Sets wether tonemapping is enabled or not
  39832. */
  39833. toneMappingEnabled: boolean;
  39834. /**
  39835. * Gets the type of tone mapping effect.
  39836. */
  39837. /**
  39838. * Sets the type of tone mapping effect.
  39839. */
  39840. toneMappingType: number;
  39841. /**
  39842. * Gets contrast used in the effect.
  39843. */
  39844. /**
  39845. * Sets contrast used in the effect.
  39846. */
  39847. contrast: number;
  39848. /**
  39849. * Gets Vignette stretch size.
  39850. */
  39851. /**
  39852. * Sets Vignette stretch size.
  39853. */
  39854. vignetteStretch: number;
  39855. /**
  39856. * Gets Vignette centre X Offset.
  39857. */
  39858. /**
  39859. * Sets Vignette centre X Offset.
  39860. */
  39861. vignetteCentreX: number;
  39862. /**
  39863. * Gets Vignette centre Y Offset.
  39864. */
  39865. /**
  39866. * Sets Vignette centre Y Offset.
  39867. */
  39868. vignetteCentreY: number;
  39869. /**
  39870. * Gets Vignette weight or intensity of the vignette effect.
  39871. */
  39872. /**
  39873. * Sets Vignette weight or intensity of the vignette effect.
  39874. */
  39875. vignetteWeight: number;
  39876. /**
  39877. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39878. * if vignetteEnabled is set to true.
  39879. */
  39880. /**
  39881. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39882. * if vignetteEnabled is set to true.
  39883. */
  39884. vignetteColor: Color4;
  39885. /**
  39886. * Gets Camera field of view used by the Vignette effect.
  39887. */
  39888. /**
  39889. * Sets Camera field of view used by the Vignette effect.
  39890. */
  39891. vignetteCameraFov: number;
  39892. /**
  39893. * Gets the vignette blend mode allowing different kind of effect.
  39894. */
  39895. /**
  39896. * Sets the vignette blend mode allowing different kind of effect.
  39897. */
  39898. vignetteBlendMode: number;
  39899. /**
  39900. * Gets wether the vignette effect is enabled.
  39901. */
  39902. /**
  39903. * Sets wether the vignette effect is enabled.
  39904. */
  39905. vignetteEnabled: boolean;
  39906. private _fromLinearSpace;
  39907. /**
  39908. * Gets wether the input of the processing is in Gamma or Linear Space.
  39909. */
  39910. /**
  39911. * Sets wether the input of the processing is in Gamma or Linear Space.
  39912. */
  39913. fromLinearSpace: boolean;
  39914. /**
  39915. * Defines cache preventing GC.
  39916. */
  39917. private _defines;
  39918. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39919. /**
  39920. * "ImageProcessingPostProcess"
  39921. * @returns "ImageProcessingPostProcess"
  39922. */
  39923. getClassName(): string;
  39924. protected _updateParameters(): void;
  39925. dispose(camera?: Camera): void;
  39926. }
  39927. }
  39928. declare module BABYLON {
  39929. /**
  39930. * Class containing static functions to help procedurally build meshes
  39931. */
  39932. export class GroundBuilder {
  39933. /**
  39934. * Creates a ground mesh
  39935. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39936. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39938. * @param name defines the name of the mesh
  39939. * @param options defines the options used to create the mesh
  39940. * @param scene defines the hosting scene
  39941. * @returns the ground mesh
  39942. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39943. */
  39944. static CreateGround(name: string, options: {
  39945. width?: number;
  39946. height?: number;
  39947. subdivisions?: number;
  39948. subdivisionsX?: number;
  39949. subdivisionsY?: number;
  39950. updatable?: boolean;
  39951. }, scene: any): Mesh;
  39952. /**
  39953. * Creates a tiled ground mesh
  39954. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39955. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39956. * * 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
  39957. * * 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
  39958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39959. * @param name defines the name of the mesh
  39960. * @param options defines the options used to create the mesh
  39961. * @param scene defines the hosting scene
  39962. * @returns the tiled ground mesh
  39963. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39964. */
  39965. static CreateTiledGround(name: string, options: {
  39966. xmin: number;
  39967. zmin: number;
  39968. xmax: number;
  39969. zmax: number;
  39970. subdivisions?: {
  39971. w: number;
  39972. h: number;
  39973. };
  39974. precision?: {
  39975. w: number;
  39976. h: number;
  39977. };
  39978. updatable?: boolean;
  39979. }, scene?: Nullable<Scene>): Mesh;
  39980. /**
  39981. * Creates a ground mesh from a height map
  39982. * * The parameter `url` sets the URL of the height map image resource.
  39983. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39984. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39985. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39986. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39987. * * 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.
  39988. * * 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).
  39989. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39991. * @param name defines the name of the mesh
  39992. * @param url defines the url to the height map
  39993. * @param options defines the options used to create the mesh
  39994. * @param scene defines the hosting scene
  39995. * @returns the ground mesh
  39996. * @see https://doc.babylonjs.com/babylon101/height_map
  39997. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39998. */
  39999. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40000. width?: number;
  40001. height?: number;
  40002. subdivisions?: number;
  40003. minHeight?: number;
  40004. maxHeight?: number;
  40005. colorFilter?: Color3;
  40006. alphaFilter?: number;
  40007. updatable?: boolean;
  40008. onReady?: (mesh: GroundMesh) => void;
  40009. }, scene?: Nullable<Scene>): GroundMesh;
  40010. }
  40011. }
  40012. declare module BABYLON {
  40013. /**
  40014. * Class containing static functions to help procedurally build meshes
  40015. */
  40016. export class TorusBuilder {
  40017. /**
  40018. * Creates a torus mesh
  40019. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40020. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40021. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40023. * * 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
  40024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40025. * @param name defines the name of the mesh
  40026. * @param options defines the options used to create the mesh
  40027. * @param scene defines the hosting scene
  40028. * @returns the torus mesh
  40029. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40030. */
  40031. static CreateTorus(name: string, options: {
  40032. diameter?: number;
  40033. thickness?: number;
  40034. tessellation?: number;
  40035. updatable?: boolean;
  40036. sideOrientation?: number;
  40037. frontUVs?: Vector4;
  40038. backUVs?: Vector4;
  40039. }, scene: any): Mesh;
  40040. }
  40041. }
  40042. declare module BABYLON {
  40043. /**
  40044. * Class containing static functions to help procedurally build meshes
  40045. */
  40046. export class CylinderBuilder {
  40047. /**
  40048. * Creates a cylinder or a cone mesh
  40049. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40050. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40051. * * 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.
  40052. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40053. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40054. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40055. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40056. * * 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).
  40057. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40058. * * 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).
  40059. * * 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
  40060. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40061. * * 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
  40062. * * 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.
  40063. * * If `enclose` is false, a ring surface is one element.
  40064. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40065. * * 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
  40066. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40067. * * 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
  40068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40069. * @param name defines the name of the mesh
  40070. * @param options defines the options used to create the mesh
  40071. * @param scene defines the hosting scene
  40072. * @returns the cylinder mesh
  40073. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40074. */
  40075. static CreateCylinder(name: string, options: {
  40076. height?: number;
  40077. diameterTop?: number;
  40078. diameterBottom?: number;
  40079. diameter?: number;
  40080. tessellation?: number;
  40081. subdivisions?: number;
  40082. arc?: number;
  40083. faceColors?: Color4[];
  40084. faceUV?: Vector4[];
  40085. updatable?: boolean;
  40086. hasRings?: boolean;
  40087. enclose?: boolean;
  40088. cap?: number;
  40089. sideOrientation?: number;
  40090. frontUVs?: Vector4;
  40091. backUVs?: Vector4;
  40092. }, scene: any): Mesh;
  40093. }
  40094. }
  40095. declare module BABYLON {
  40096. /**
  40097. * Options to modify the vr teleportation behavior.
  40098. */
  40099. export interface VRTeleportationOptions {
  40100. /**
  40101. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40102. */
  40103. floorMeshName?: string;
  40104. /**
  40105. * A list of meshes to be used as the teleportation floor. (default: empty)
  40106. */
  40107. floorMeshes?: Mesh[];
  40108. }
  40109. /**
  40110. * Options to modify the vr experience helper's behavior.
  40111. */
  40112. export interface VRExperienceHelperOptions extends WebVROptions {
  40113. /**
  40114. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40115. */
  40116. createDeviceOrientationCamera?: boolean;
  40117. /**
  40118. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40119. */
  40120. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40121. /**
  40122. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40123. */
  40124. laserToggle?: boolean;
  40125. /**
  40126. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40127. */
  40128. floorMeshes?: Mesh[];
  40129. /**
  40130. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40131. */
  40132. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40133. }
  40134. /**
  40135. * Event containing information after VR has been entered
  40136. */
  40137. export class OnAfterEnteringVRObservableEvent {
  40138. /**
  40139. * If entering vr was successful
  40140. */
  40141. success: boolean;
  40142. }
  40143. /**
  40144. * Helps to quickly add VR support to an existing scene.
  40145. * See http://doc.babylonjs.com/how_to/webvr_helper
  40146. */
  40147. export class VRExperienceHelper {
  40148. /** Options to modify the vr experience helper's behavior. */
  40149. webVROptions: VRExperienceHelperOptions;
  40150. private _scene;
  40151. private _position;
  40152. private _btnVR;
  40153. private _btnVRDisplayed;
  40154. private _webVRsupported;
  40155. private _webVRready;
  40156. private _webVRrequesting;
  40157. private _webVRpresenting;
  40158. private _hasEnteredVR;
  40159. private _fullscreenVRpresenting;
  40160. private _canvas;
  40161. private _webVRCamera;
  40162. private _vrDeviceOrientationCamera;
  40163. private _deviceOrientationCamera;
  40164. private _existingCamera;
  40165. private _onKeyDown;
  40166. private _onVrDisplayPresentChange;
  40167. private _onVRDisplayChanged;
  40168. private _onVRRequestPresentStart;
  40169. private _onVRRequestPresentComplete;
  40170. /**
  40171. * Observable raised right before entering VR.
  40172. */
  40173. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40174. /**
  40175. * Observable raised when entering VR has completed.
  40176. */
  40177. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40178. /**
  40179. * Observable raised when exiting VR.
  40180. */
  40181. onExitingVRObservable: Observable<VRExperienceHelper>;
  40182. /**
  40183. * Observable raised when controller mesh is loaded.
  40184. */
  40185. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40186. /** Return this.onEnteringVRObservable
  40187. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40188. */
  40189. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40190. /** Return this.onExitingVRObservable
  40191. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40192. */
  40193. readonly onExitingVR: Observable<VRExperienceHelper>;
  40194. /** Return this.onControllerMeshLoadedObservable
  40195. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40196. */
  40197. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40198. private _rayLength;
  40199. private _useCustomVRButton;
  40200. private _teleportationRequested;
  40201. private _teleportActive;
  40202. private _floorMeshName;
  40203. private _floorMeshesCollection;
  40204. private _rotationAllowed;
  40205. private _teleportBackwardsVector;
  40206. private _teleportationTarget;
  40207. private _isDefaultTeleportationTarget;
  40208. private _postProcessMove;
  40209. private _teleportationFillColor;
  40210. private _teleportationBorderColor;
  40211. private _rotationAngle;
  40212. private _haloCenter;
  40213. private _cameraGazer;
  40214. private _padSensibilityUp;
  40215. private _padSensibilityDown;
  40216. private _leftController;
  40217. private _rightController;
  40218. /**
  40219. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40220. */
  40221. onNewMeshSelected: Observable<AbstractMesh>;
  40222. /**
  40223. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40224. */
  40225. onNewMeshPicked: Observable<PickingInfo>;
  40226. private _circleEase;
  40227. /**
  40228. * Observable raised before camera teleportation
  40229. */
  40230. onBeforeCameraTeleport: Observable<Vector3>;
  40231. /**
  40232. * Observable raised after camera teleportation
  40233. */
  40234. onAfterCameraTeleport: Observable<Vector3>;
  40235. /**
  40236. * Observable raised when current selected mesh gets unselected
  40237. */
  40238. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40239. private _raySelectionPredicate;
  40240. /**
  40241. * To be optionaly changed by user to define custom ray selection
  40242. */
  40243. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40244. /**
  40245. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40246. */
  40247. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40248. /**
  40249. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40250. */
  40251. teleportationEnabled: boolean;
  40252. private _defaultHeight;
  40253. private _teleportationInitialized;
  40254. private _interactionsEnabled;
  40255. private _interactionsRequested;
  40256. private _displayGaze;
  40257. private _displayLaserPointer;
  40258. /**
  40259. * The mesh used to display where the user is going to teleport.
  40260. */
  40261. /**
  40262. * Sets the mesh to be used to display where the user is going to teleport.
  40263. */
  40264. teleportationTarget: Mesh;
  40265. /**
  40266. * 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
  40267. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40268. * See http://doc.babylonjs.com/resources/baking_transformations
  40269. */
  40270. gazeTrackerMesh: Mesh;
  40271. /**
  40272. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40273. */
  40274. updateGazeTrackerScale: boolean;
  40275. /**
  40276. * If the gaze trackers color should be updated when selecting meshes
  40277. */
  40278. updateGazeTrackerColor: boolean;
  40279. /**
  40280. * The gaze tracking mesh corresponding to the left controller
  40281. */
  40282. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40283. /**
  40284. * The gaze tracking mesh corresponding to the right controller
  40285. */
  40286. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40287. /**
  40288. * If the ray of the gaze should be displayed.
  40289. */
  40290. /**
  40291. * Sets if the ray of the gaze should be displayed.
  40292. */
  40293. displayGaze: boolean;
  40294. /**
  40295. * If the ray of the LaserPointer should be displayed.
  40296. */
  40297. /**
  40298. * Sets if the ray of the LaserPointer should be displayed.
  40299. */
  40300. displayLaserPointer: boolean;
  40301. /**
  40302. * The deviceOrientationCamera used as the camera when not in VR.
  40303. */
  40304. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40305. /**
  40306. * Based on the current WebVR support, returns the current VR camera used.
  40307. */
  40308. readonly currentVRCamera: Nullable<Camera>;
  40309. /**
  40310. * The webVRCamera which is used when in VR.
  40311. */
  40312. readonly webVRCamera: WebVRFreeCamera;
  40313. /**
  40314. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40315. */
  40316. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40317. private readonly _teleportationRequestInitiated;
  40318. /**
  40319. * Defines wether or not Pointer lock should be requested when switching to
  40320. * full screen.
  40321. */
  40322. requestPointerLockOnFullScreen: boolean;
  40323. /**
  40324. * Instantiates a VRExperienceHelper.
  40325. * Helps to quickly add VR support to an existing scene.
  40326. * @param scene The scene the VRExperienceHelper belongs to.
  40327. * @param webVROptions Options to modify the vr experience helper's behavior.
  40328. */
  40329. constructor(scene: Scene,
  40330. /** Options to modify the vr experience helper's behavior. */
  40331. webVROptions?: VRExperienceHelperOptions);
  40332. private _onDefaultMeshLoaded;
  40333. private _onResize;
  40334. private _onFullscreenChange;
  40335. /**
  40336. * Gets a value indicating if we are currently in VR mode.
  40337. */
  40338. readonly isInVRMode: boolean;
  40339. private onVrDisplayPresentChange;
  40340. private onVRDisplayChanged;
  40341. private moveButtonToBottomRight;
  40342. private displayVRButton;
  40343. private updateButtonVisibility;
  40344. private _cachedAngularSensibility;
  40345. /**
  40346. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40347. * Otherwise, will use the fullscreen API.
  40348. */
  40349. enterVR(): void;
  40350. /**
  40351. * Attempt to exit VR, or fullscreen.
  40352. */
  40353. exitVR(): void;
  40354. /**
  40355. * The position of the vr experience helper.
  40356. */
  40357. /**
  40358. * Sets the position of the vr experience helper.
  40359. */
  40360. position: Vector3;
  40361. /**
  40362. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40363. */
  40364. enableInteractions(): void;
  40365. private readonly _noControllerIsActive;
  40366. private beforeRender;
  40367. private _isTeleportationFloor;
  40368. /**
  40369. * Adds a floor mesh to be used for teleportation.
  40370. * @param floorMesh the mesh to be used for teleportation.
  40371. */
  40372. addFloorMesh(floorMesh: Mesh): void;
  40373. /**
  40374. * Removes a floor mesh from being used for teleportation.
  40375. * @param floorMesh the mesh to be removed.
  40376. */
  40377. removeFloorMesh(floorMesh: Mesh): void;
  40378. /**
  40379. * Enables interactions and teleportation using the VR controllers and gaze.
  40380. * @param vrTeleportationOptions options to modify teleportation behavior.
  40381. */
  40382. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40383. private _onNewGamepadConnected;
  40384. private _tryEnableInteractionOnController;
  40385. private _onNewGamepadDisconnected;
  40386. private _enableInteractionOnController;
  40387. private _checkTeleportWithRay;
  40388. private _checkRotate;
  40389. private _checkTeleportBackwards;
  40390. private _enableTeleportationOnController;
  40391. private _createTeleportationCircles;
  40392. private _displayTeleportationTarget;
  40393. private _hideTeleportationTarget;
  40394. private _rotateCamera;
  40395. private _moveTeleportationSelectorTo;
  40396. private _workingVector;
  40397. private _workingQuaternion;
  40398. private _workingMatrix;
  40399. /**
  40400. * Teleports the users feet to the desired location
  40401. * @param location The location where the user's feet should be placed
  40402. */
  40403. teleportCamera(location: Vector3): void;
  40404. private _convertNormalToDirectionOfRay;
  40405. private _castRayAndSelectObject;
  40406. private _notifySelectedMeshUnselected;
  40407. /**
  40408. * Sets the color of the laser ray from the vr controllers.
  40409. * @param color new color for the ray.
  40410. */
  40411. changeLaserColor(color: Color3): void;
  40412. /**
  40413. * Sets the color of the ray from the vr headsets gaze.
  40414. * @param color new color for the ray.
  40415. */
  40416. changeGazeColor(color: Color3): void;
  40417. /**
  40418. * Exits VR and disposes of the vr experience helper
  40419. */
  40420. dispose(): void;
  40421. /**
  40422. * Gets the name of the VRExperienceHelper class
  40423. * @returns "VRExperienceHelper"
  40424. */
  40425. getClassName(): string;
  40426. }
  40427. }
  40428. declare module BABYLON {
  40429. /**
  40430. * Manages an XRSession
  40431. * @see https://doc.babylonjs.com/how_to/webxr
  40432. */
  40433. export class WebXRSessionManager implements IDisposable {
  40434. private scene;
  40435. /**
  40436. * Fires every time a new xrFrame arrives which can be used to update the camera
  40437. */
  40438. onXRFrameObservable: Observable<any>;
  40439. /**
  40440. * Fires when the xr session is ended either by the device or manually done
  40441. */
  40442. onXRSessionEnded: Observable<any>;
  40443. /** @hidden */
  40444. _xrSession: XRSession;
  40445. /** @hidden */
  40446. _frameOfReference: XRFrameOfReference;
  40447. /** @hidden */
  40448. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40449. /** @hidden */
  40450. _currentXRFrame: Nullable<XRFrame>;
  40451. private _xrNavigator;
  40452. private _xrDevice;
  40453. private _tmpMatrix;
  40454. /**
  40455. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40456. * @param scene The scene which the session should be created for
  40457. */
  40458. constructor(scene: Scene);
  40459. /**
  40460. * Initializes the manager
  40461. * After initialization enterXR can be called to start an XR session
  40462. * @returns Promise which resolves after it is initialized
  40463. */
  40464. initializeAsync(): Promise<void>;
  40465. /**
  40466. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40467. * @param sessionCreationOptions xr options to create the session with
  40468. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40469. * @returns Promise which resolves after it enters XR
  40470. */
  40471. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40472. /**
  40473. * Stops the xrSession and restores the renderloop
  40474. * @returns Promise which resolves after it exits XR
  40475. */
  40476. exitXRAsync(): Promise<void>;
  40477. /**
  40478. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40479. * @param ray ray to cast into the environment
  40480. * @returns Promise which resolves with a collision point in the environment if it exists
  40481. */
  40482. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40483. /**
  40484. * Checks if a session would be supported for the creation options specified
  40485. * @param options creation options to check if they are supported
  40486. * @returns true if supported
  40487. */
  40488. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40489. /**
  40490. * @hidden
  40491. * Converts the render layer of xrSession to a render target
  40492. * @param session session to create render target for
  40493. * @param scene scene the new render target should be created for
  40494. */
  40495. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40496. /**
  40497. * Disposes of the session manager
  40498. */
  40499. dispose(): void;
  40500. }
  40501. }
  40502. declare module BABYLON {
  40503. /**
  40504. * WebXR Camera which holds the views for the xrSession
  40505. * @see https://doc.babylonjs.com/how_to/webxr
  40506. */
  40507. export class WebXRCamera extends FreeCamera {
  40508. private static _TmpMatrix;
  40509. /**
  40510. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40511. * @param name the name of the camera
  40512. * @param scene the scene to add the camera to
  40513. */
  40514. constructor(name: string, scene: Scene);
  40515. private _updateNumberOfRigCameras;
  40516. /** @hidden */
  40517. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40518. /**
  40519. * Updates the cameras position from the current pose information of the XR session
  40520. * @param xrSessionManager the session containing pose information
  40521. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40522. */
  40523. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40524. }
  40525. }
  40526. declare module BABYLON {
  40527. /**
  40528. * States of the webXR experience
  40529. */
  40530. export enum WebXRState {
  40531. /**
  40532. * Transitioning to being in XR mode
  40533. */
  40534. ENTERING_XR = 0,
  40535. /**
  40536. * Transitioning to non XR mode
  40537. */
  40538. EXITING_XR = 1,
  40539. /**
  40540. * In XR mode and presenting
  40541. */
  40542. IN_XR = 2,
  40543. /**
  40544. * Not entered XR mode
  40545. */
  40546. NOT_IN_XR = 3
  40547. }
  40548. /**
  40549. * Helper class used to enable XR
  40550. * @see https://doc.babylonjs.com/how_to/webxr
  40551. */
  40552. export class WebXRExperienceHelper implements IDisposable {
  40553. private scene;
  40554. /**
  40555. * 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
  40556. */
  40557. container: AbstractMesh;
  40558. /**
  40559. * Camera used to render xr content
  40560. */
  40561. camera: WebXRCamera;
  40562. /**
  40563. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40564. */
  40565. state: WebXRState;
  40566. private _setState;
  40567. private static _TmpVector;
  40568. /**
  40569. * Fires when the state of the experience helper has changed
  40570. */
  40571. onStateChangedObservable: Observable<WebXRState>;
  40572. /** @hidden */
  40573. _sessionManager: WebXRSessionManager;
  40574. private _nonVRCamera;
  40575. private _originalSceneAutoClear;
  40576. private _supported;
  40577. /**
  40578. * Creates the experience helper
  40579. * @param scene the scene to attach the experience helper to
  40580. * @returns a promise for the experience helper
  40581. */
  40582. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40583. /**
  40584. * Creates a WebXRExperienceHelper
  40585. * @param scene The scene the helper should be created in
  40586. */
  40587. private constructor();
  40588. /**
  40589. * Exits XR mode and returns the scene to its original state
  40590. * @returns promise that resolves after xr mode has exited
  40591. */
  40592. exitXRAsync(): Promise<void>;
  40593. /**
  40594. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40595. * @param sessionCreationOptions options for the XR session
  40596. * @param frameOfReference frame of reference of the XR session
  40597. * @returns promise that resolves after xr mode has entered
  40598. */
  40599. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40600. /**
  40601. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40602. * @param ray ray to cast into the environment
  40603. * @returns Promise which resolves with a collision point in the environment if it exists
  40604. */
  40605. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40606. /**
  40607. * Updates the global position of the camera by moving the camera's container
  40608. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40609. * @param position The desired global position of the camera
  40610. */
  40611. setPositionOfCameraUsingContainer(position: Vector3): void;
  40612. /**
  40613. * Rotates the xr camera by rotating the camera's container around the camera's position
  40614. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40615. * @param rotation the desired quaternion rotation to apply to the camera
  40616. */
  40617. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40618. /**
  40619. * Checks if the creation options are supported by the xr session
  40620. * @param options creation options
  40621. * @returns true if supported
  40622. */
  40623. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40624. /**
  40625. * Disposes of the experience helper
  40626. */
  40627. dispose(): void;
  40628. }
  40629. }
  40630. declare module BABYLON {
  40631. /**
  40632. * Button which can be used to enter a different mode of XR
  40633. */
  40634. export class WebXREnterExitUIButton {
  40635. /** button element */
  40636. element: HTMLElement;
  40637. /** XR initialization options for the button */
  40638. initializationOptions: XRSessionCreationOptions;
  40639. /**
  40640. * Creates a WebXREnterExitUIButton
  40641. * @param element button element
  40642. * @param initializationOptions XR initialization options for the button
  40643. */
  40644. constructor(
  40645. /** button element */
  40646. element: HTMLElement,
  40647. /** XR initialization options for the button */
  40648. initializationOptions: XRSessionCreationOptions);
  40649. /**
  40650. * Overwritable function which can be used to update the button's visuals when the state changes
  40651. * @param activeButton the current active button in the UI
  40652. */
  40653. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40654. }
  40655. /**
  40656. * Options to create the webXR UI
  40657. */
  40658. export class WebXREnterExitUIOptions {
  40659. /**
  40660. * Context to enter xr with
  40661. */
  40662. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40663. /**
  40664. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40665. */
  40666. customButtons?: Array<WebXREnterExitUIButton>;
  40667. }
  40668. /**
  40669. * UI to allow the user to enter/exit XR mode
  40670. */
  40671. export class WebXREnterExitUI implements IDisposable {
  40672. private scene;
  40673. private _overlay;
  40674. private _buttons;
  40675. private _activeButton;
  40676. /**
  40677. * Fired every time the active button is changed.
  40678. *
  40679. * When xr is entered via a button that launches xr that button will be the callback parameter
  40680. *
  40681. * When exiting xr the callback parameter will be null)
  40682. */
  40683. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40684. /**
  40685. * Creates UI to allow the user to enter/exit XR mode
  40686. * @param scene the scene to add the ui to
  40687. * @param helper the xr experience helper to enter/exit xr with
  40688. * @param options options to configure the UI
  40689. * @returns the created ui
  40690. */
  40691. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40692. private constructor();
  40693. private _updateButtons;
  40694. /**
  40695. * Disposes of the object
  40696. */
  40697. dispose(): void;
  40698. }
  40699. }
  40700. declare module BABYLON {
  40701. /**
  40702. * Represents an XR input
  40703. */
  40704. export class WebXRController {
  40705. /**
  40706. * 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
  40707. */
  40708. grip?: AbstractMesh;
  40709. /**
  40710. * Pointer which can be used to select objects or attach a visible laser to
  40711. */
  40712. pointer: AbstractMesh;
  40713. /**
  40714. * Creates the controller
  40715. * @see https://doc.babylonjs.com/how_to/webxr
  40716. * @param scene the scene which the controller should be associated to
  40717. */
  40718. constructor(scene: Scene);
  40719. /**
  40720. * Disposes of the object
  40721. */
  40722. dispose(): void;
  40723. }
  40724. /**
  40725. * XR input used to track XR inputs such as controllers/rays
  40726. */
  40727. export class WebXRInput implements IDisposable {
  40728. private helper;
  40729. /**
  40730. * XR controllers being tracked
  40731. */
  40732. controllers: Array<WebXRController>;
  40733. private _tmpMatrix;
  40734. private _frameObserver;
  40735. /**
  40736. * Initializes the WebXRInput
  40737. * @param helper experience helper which the input should be created for
  40738. */
  40739. constructor(helper: WebXRExperienceHelper);
  40740. /**
  40741. * Disposes of the object
  40742. */
  40743. dispose(): void;
  40744. }
  40745. }
  40746. declare module BABYLON {
  40747. /**
  40748. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40749. */
  40750. export class WebXRManagedOutputCanvas implements IDisposable {
  40751. private _canvas;
  40752. /**
  40753. * xrpresent context of the canvas which can be used to display/mirror xr content
  40754. */
  40755. canvasContext: Nullable<WebGLRenderingContext>;
  40756. /**
  40757. * Initializes the canvas to be added/removed upon entering/exiting xr
  40758. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40759. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40760. */
  40761. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40762. /**
  40763. * Disposes of the object
  40764. */
  40765. dispose(): void;
  40766. private _setManagedOutputCanvas;
  40767. private _addCanvas;
  40768. private _removeCanvas;
  40769. }
  40770. }
  40771. declare module BABYLON {
  40772. /**
  40773. * Contains an array of blocks representing the octree
  40774. */
  40775. export interface IOctreeContainer<T> {
  40776. /**
  40777. * Blocks within the octree
  40778. */
  40779. blocks: Array<OctreeBlock<T>>;
  40780. }
  40781. /**
  40782. * Class used to store a cell in an octree
  40783. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40784. */
  40785. export class OctreeBlock<T> {
  40786. /**
  40787. * Gets the content of the current block
  40788. */
  40789. entries: T[];
  40790. /**
  40791. * Gets the list of block children
  40792. */
  40793. blocks: Array<OctreeBlock<T>>;
  40794. private _depth;
  40795. private _maxDepth;
  40796. private _capacity;
  40797. private _minPoint;
  40798. private _maxPoint;
  40799. private _boundingVectors;
  40800. private _creationFunc;
  40801. /**
  40802. * Creates a new block
  40803. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40804. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40805. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40806. * @param depth defines the current depth of this block in the octree
  40807. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40808. * @param creationFunc defines a callback to call when an element is added to the block
  40809. */
  40810. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40811. /**
  40812. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40813. */
  40814. readonly capacity: number;
  40815. /**
  40816. * Gets the minimum vector (in world space) of the block's bounding box
  40817. */
  40818. readonly minPoint: Vector3;
  40819. /**
  40820. * Gets the maximum vector (in world space) of the block's bounding box
  40821. */
  40822. readonly maxPoint: Vector3;
  40823. /**
  40824. * Add a new element to this block
  40825. * @param entry defines the element to add
  40826. */
  40827. addEntry(entry: T): void;
  40828. /**
  40829. * Remove an element from this block
  40830. * @param entry defines the element to remove
  40831. */
  40832. removeEntry(entry: T): void;
  40833. /**
  40834. * Add an array of elements to this block
  40835. * @param entries defines the array of elements to add
  40836. */
  40837. addEntries(entries: T[]): void;
  40838. /**
  40839. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40840. * @param frustumPlanes defines the frustum planes to test
  40841. * @param selection defines the array to store current content if selection is positive
  40842. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40843. */
  40844. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40845. /**
  40846. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40847. * @param sphereCenter defines the bounding sphere center
  40848. * @param sphereRadius defines the bounding sphere radius
  40849. * @param selection defines the array to store current content if selection is positive
  40850. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40851. */
  40852. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40853. /**
  40854. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40855. * @param ray defines the ray to test with
  40856. * @param selection defines the array to store current content if selection is positive
  40857. */
  40858. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40859. /**
  40860. * Subdivide the content into child blocks (this block will then be empty)
  40861. */
  40862. createInnerBlocks(): void;
  40863. /**
  40864. * @hidden
  40865. */
  40866. 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;
  40867. }
  40868. }
  40869. declare module BABYLON {
  40870. /**
  40871. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40872. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40873. */
  40874. export class Octree<T> {
  40875. /** 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.) */
  40876. maxDepth: number;
  40877. /**
  40878. * Blocks within the octree containing objects
  40879. */
  40880. blocks: Array<OctreeBlock<T>>;
  40881. /**
  40882. * Content stored in the octree
  40883. */
  40884. dynamicContent: T[];
  40885. private _maxBlockCapacity;
  40886. private _selectionContent;
  40887. private _creationFunc;
  40888. /**
  40889. * Creates a octree
  40890. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40891. * @param creationFunc function to be used to instatiate the octree
  40892. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40893. * @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.)
  40894. */
  40895. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40896. /** 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.) */
  40897. maxDepth?: number);
  40898. /**
  40899. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40900. * @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);
  40901. * @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);
  40902. * @param entries meshes to be added to the octree blocks
  40903. */
  40904. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40905. /**
  40906. * Adds a mesh to the octree
  40907. * @param entry Mesh to add to the octree
  40908. */
  40909. addMesh(entry: T): void;
  40910. /**
  40911. * Remove an element from the octree
  40912. * @param entry defines the element to remove
  40913. */
  40914. removeMesh(entry: T): void;
  40915. /**
  40916. * Selects an array of meshes within the frustum
  40917. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40918. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40919. * @returns array of meshes within the frustum
  40920. */
  40921. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40922. /**
  40923. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40924. * @param sphereCenter defines the bounding sphere center
  40925. * @param sphereRadius defines the bounding sphere radius
  40926. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40927. * @returns an array of objects that intersect the sphere
  40928. */
  40929. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40930. /**
  40931. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40932. * @param ray defines the ray to test with
  40933. * @returns array of intersected objects
  40934. */
  40935. intersectsRay(ray: Ray): SmartArray<T>;
  40936. /**
  40937. * Adds a mesh into the octree block if it intersects the block
  40938. */
  40939. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40940. /**
  40941. * Adds a submesh into the octree block if it intersects the block
  40942. */
  40943. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40944. }
  40945. }
  40946. declare module BABYLON {
  40947. interface Scene {
  40948. /**
  40949. * @hidden
  40950. * Backing Filed
  40951. */
  40952. _selectionOctree: Octree<AbstractMesh>;
  40953. /**
  40954. * Gets the octree used to boost mesh selection (picking)
  40955. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40956. */
  40957. selectionOctree: Octree<AbstractMesh>;
  40958. /**
  40959. * Creates or updates the octree used to boost selection (picking)
  40960. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40961. * @param maxCapacity defines the maximum capacity per leaf
  40962. * @param maxDepth defines the maximum depth of the octree
  40963. * @returns an octree of AbstractMesh
  40964. */
  40965. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40966. }
  40967. interface AbstractMesh {
  40968. /**
  40969. * @hidden
  40970. * Backing Field
  40971. */
  40972. _submeshesOctree: Octree<SubMesh>;
  40973. /**
  40974. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40975. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40976. * @param maxCapacity defines the maximum size of each block (64 by default)
  40977. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40978. * @returns the new octree
  40979. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40980. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40981. */
  40982. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40983. }
  40984. /**
  40985. * Defines the octree scene component responsible to manage any octrees
  40986. * in a given scene.
  40987. */
  40988. export class OctreeSceneComponent {
  40989. /**
  40990. * The component name help to identify the component in the list of scene components.
  40991. */
  40992. readonly name: string;
  40993. /**
  40994. * The scene the component belongs to.
  40995. */
  40996. scene: Scene;
  40997. /**
  40998. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40999. */
  41000. readonly checksIsEnabled: boolean;
  41001. /**
  41002. * Creates a new instance of the component for the given scene
  41003. * @param scene Defines the scene to register the component in
  41004. */
  41005. constructor(scene: Scene);
  41006. /**
  41007. * Registers the component in a given scene
  41008. */
  41009. register(): void;
  41010. /**
  41011. * Return the list of active meshes
  41012. * @returns the list of active meshes
  41013. */
  41014. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41015. /**
  41016. * Return the list of active sub meshes
  41017. * @param mesh The mesh to get the candidates sub meshes from
  41018. * @returns the list of active sub meshes
  41019. */
  41020. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41021. private _tempRay;
  41022. /**
  41023. * Return the list of sub meshes intersecting with a given local ray
  41024. * @param mesh defines the mesh to find the submesh for
  41025. * @param localRay defines the ray in local space
  41026. * @returns the list of intersecting sub meshes
  41027. */
  41028. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41029. /**
  41030. * Return the list of sub meshes colliding with a collider
  41031. * @param mesh defines the mesh to find the submesh for
  41032. * @param collider defines the collider to evaluate the collision against
  41033. * @returns the list of colliding sub meshes
  41034. */
  41035. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41036. /**
  41037. * Rebuilds the elements related to this component in case of
  41038. * context lost for instance.
  41039. */
  41040. rebuild(): void;
  41041. /**
  41042. * Disposes the component and the associated ressources.
  41043. */
  41044. dispose(): void;
  41045. }
  41046. }
  41047. declare module BABYLON {
  41048. /**
  41049. * Renders a layer on top of an existing scene
  41050. */
  41051. export class UtilityLayerRenderer implements IDisposable {
  41052. /** the original scene that will be rendered on top of */
  41053. originalScene: Scene;
  41054. private _pointerCaptures;
  41055. private _lastPointerEvents;
  41056. private static _DefaultUtilityLayer;
  41057. private static _DefaultKeepDepthUtilityLayer;
  41058. private _sharedGizmoLight;
  41059. private _renderCamera;
  41060. /**
  41061. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  41062. * @returns the camera that is used when rendering the utility layer
  41063. */
  41064. getRenderCamera(): Nullable<Camera>;
  41065. /**
  41066. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  41067. * @param cam the camera that should be used when rendering the utility layer
  41068. */
  41069. setRenderCamera(cam: Nullable<Camera>): void;
  41070. /**
  41071. * @hidden
  41072. * Light which used by gizmos to get light shading
  41073. */
  41074. _getSharedGizmoLight(): HemisphericLight;
  41075. /**
  41076. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41077. */
  41078. pickUtilitySceneFirst: boolean;
  41079. /**
  41080. * 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)
  41081. */
  41082. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41083. /**
  41084. * 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)
  41085. */
  41086. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41087. /**
  41088. * The scene that is rendered on top of the original scene
  41089. */
  41090. utilityLayerScene: Scene;
  41091. /**
  41092. * If the utility layer should automatically be rendered on top of existing scene
  41093. */
  41094. shouldRender: boolean;
  41095. /**
  41096. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41097. */
  41098. onlyCheckPointerDownEvents: boolean;
  41099. /**
  41100. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41101. */
  41102. processAllEvents: boolean;
  41103. /**
  41104. * Observable raised when the pointer move from the utility layer scene to the main scene
  41105. */
  41106. onPointerOutObservable: Observable<number>;
  41107. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41108. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41109. private _afterRenderObserver;
  41110. private _sceneDisposeObserver;
  41111. private _originalPointerObserver;
  41112. /**
  41113. * Instantiates a UtilityLayerRenderer
  41114. * @param originalScene the original scene that will be rendered on top of
  41115. * @param handleEvents boolean indicating if the utility layer should handle events
  41116. */
  41117. constructor(
  41118. /** the original scene that will be rendered on top of */
  41119. originalScene: Scene, handleEvents?: boolean);
  41120. private _notifyObservers;
  41121. /**
  41122. * Renders the utility layers scene on top of the original scene
  41123. */
  41124. render(): void;
  41125. /**
  41126. * Disposes of the renderer
  41127. */
  41128. dispose(): void;
  41129. private _updateCamera;
  41130. }
  41131. }
  41132. declare module BABYLON {
  41133. /**
  41134. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41135. */
  41136. export class Gizmo implements IDisposable {
  41137. /** The utility layer the gizmo will be added to */
  41138. gizmoLayer: UtilityLayerRenderer;
  41139. /**
  41140. * The root mesh of the gizmo
  41141. */
  41142. _rootMesh: Mesh;
  41143. private _attachedMesh;
  41144. /**
  41145. * Ratio for the scale of the gizmo (Default: 1)
  41146. */
  41147. scaleRatio: number;
  41148. /**
  41149. * If a custom mesh has been set (Default: false)
  41150. */
  41151. protected _customMeshSet: boolean;
  41152. /**
  41153. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41154. * * When set, interactions will be enabled
  41155. */
  41156. attachedMesh: Nullable<AbstractMesh>;
  41157. /**
  41158. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41159. * @param mesh The mesh to replace the default mesh of the gizmo
  41160. */
  41161. setCustomMesh(mesh: Mesh): void;
  41162. /**
  41163. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41164. */
  41165. updateGizmoRotationToMatchAttachedMesh: boolean;
  41166. /**
  41167. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41168. */
  41169. updateGizmoPositionToMatchAttachedMesh: boolean;
  41170. /**
  41171. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41172. */
  41173. protected _updateScale: boolean;
  41174. protected _interactionsEnabled: boolean;
  41175. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41176. private _beforeRenderObserver;
  41177. private _tempVector;
  41178. /**
  41179. * Creates a gizmo
  41180. * @param gizmoLayer The utility layer the gizmo will be added to
  41181. */
  41182. constructor(
  41183. /** The utility layer the gizmo will be added to */
  41184. gizmoLayer?: UtilityLayerRenderer);
  41185. /**
  41186. * Updates the gizmo to match the attached mesh's position/rotation
  41187. */
  41188. protected _update(): void;
  41189. /**
  41190. * Disposes of the gizmo
  41191. */
  41192. dispose(): void;
  41193. }
  41194. }
  41195. declare module BABYLON {
  41196. /**
  41197. * Single plane drag gizmo
  41198. */
  41199. export class PlaneDragGizmo extends Gizmo {
  41200. /**
  41201. * Drag behavior responsible for the gizmos dragging interactions
  41202. */
  41203. dragBehavior: PointerDragBehavior;
  41204. private _pointerObserver;
  41205. /**
  41206. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41207. */
  41208. snapDistance: number;
  41209. /**
  41210. * Event that fires each time the gizmo snaps to a new location.
  41211. * * snapDistance is the the change in distance
  41212. */
  41213. onSnapObservable: Observable<{
  41214. snapDistance: number;
  41215. }>;
  41216. private _plane;
  41217. private _coloredMaterial;
  41218. private _hoverMaterial;
  41219. private _isEnabled;
  41220. private _parent;
  41221. /** @hidden */
  41222. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  41223. /** @hidden */
  41224. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41225. /**
  41226. * Creates a PlaneDragGizmo
  41227. * @param gizmoLayer The utility layer the gizmo will be added to
  41228. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  41229. * @param color The color of the gizmo
  41230. */
  41231. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41232. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41233. /**
  41234. * If the gizmo is enabled
  41235. */
  41236. isEnabled: boolean;
  41237. /**
  41238. * Disposes of the gizmo
  41239. */
  41240. dispose(): void;
  41241. }
  41242. }
  41243. declare module BABYLON {
  41244. /**
  41245. * Gizmo that enables dragging a mesh along 3 axis
  41246. */
  41247. export class PositionGizmo extends Gizmo {
  41248. /**
  41249. * Internal gizmo used for interactions on the x axis
  41250. */
  41251. xGizmo: AxisDragGizmo;
  41252. /**
  41253. * Internal gizmo used for interactions on the y axis
  41254. */
  41255. yGizmo: AxisDragGizmo;
  41256. /**
  41257. * Internal gizmo used for interactions on the z axis
  41258. */
  41259. zGizmo: AxisDragGizmo;
  41260. /**
  41261. * Internal gizmo used for interactions on the yz plane
  41262. */
  41263. xPlaneGizmo: PlaneDragGizmo;
  41264. /**
  41265. * Internal gizmo used for interactions on the xz plane
  41266. */
  41267. yPlaneGizmo: PlaneDragGizmo;
  41268. /**
  41269. * Internal gizmo used for interactions on the xy plane
  41270. */
  41271. zPlaneGizmo: PlaneDragGizmo;
  41272. /**
  41273. * private variables
  41274. */
  41275. private _meshAttached;
  41276. private _updateGizmoRotationToMatchAttachedMesh;
  41277. private _snapDistance;
  41278. private _scaleRatio;
  41279. /** Fires an event when any of it's sub gizmos are dragged */
  41280. onDragStartObservable: Observable<unknown>;
  41281. /** Fires an event when any of it's sub gizmos are released from dragging */
  41282. onDragEndObservable: Observable<unknown>;
  41283. /**
  41284. * If set to true, planar drag is enabled
  41285. */
  41286. private _planarGizmoEnabled;
  41287. attachedMesh: Nullable<AbstractMesh>;
  41288. /**
  41289. * Creates a PositionGizmo
  41290. * @param gizmoLayer The utility layer the gizmo will be added to
  41291. */
  41292. constructor(gizmoLayer?: UtilityLayerRenderer);
  41293. /**
  41294. * If the planar drag gizmo is enabled
  41295. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  41296. */
  41297. planarGizmoEnabled: boolean;
  41298. updateGizmoRotationToMatchAttachedMesh: boolean;
  41299. /**
  41300. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41301. */
  41302. snapDistance: number;
  41303. /**
  41304. * Ratio for the scale of the gizmo (Default: 1)
  41305. */
  41306. scaleRatio: number;
  41307. /**
  41308. * Disposes of the gizmo
  41309. */
  41310. dispose(): void;
  41311. /**
  41312. * CustomMeshes are not supported by this gizmo
  41313. * @param mesh The mesh to replace the default mesh of the gizmo
  41314. */
  41315. setCustomMesh(mesh: Mesh): void;
  41316. }
  41317. }
  41318. declare module BABYLON {
  41319. /**
  41320. * Single axis drag gizmo
  41321. */
  41322. export class AxisDragGizmo extends Gizmo {
  41323. /**
  41324. * Drag behavior responsible for the gizmos dragging interactions
  41325. */
  41326. dragBehavior: PointerDragBehavior;
  41327. private _pointerObserver;
  41328. /**
  41329. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41330. */
  41331. snapDistance: number;
  41332. /**
  41333. * Event that fires each time the gizmo snaps to a new location.
  41334. * * snapDistance is the the change in distance
  41335. */
  41336. onSnapObservable: Observable<{
  41337. snapDistance: number;
  41338. }>;
  41339. private _isEnabled;
  41340. private _parent;
  41341. private _arrow;
  41342. private _coloredMaterial;
  41343. private _hoverMaterial;
  41344. /** @hidden */
  41345. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41346. /** @hidden */
  41347. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41348. /**
  41349. * Creates an AxisDragGizmo
  41350. * @param gizmoLayer The utility layer the gizmo will be added to
  41351. * @param dragAxis The axis which the gizmo will be able to drag on
  41352. * @param color The color of the gizmo
  41353. */
  41354. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41355. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41356. /**
  41357. * If the gizmo is enabled
  41358. */
  41359. isEnabled: boolean;
  41360. /**
  41361. * Disposes of the gizmo
  41362. */
  41363. dispose(): void;
  41364. }
  41365. }
  41366. declare module BABYLON.Debug {
  41367. /**
  41368. * The Axes viewer will show 3 axes in a specific point in space
  41369. */
  41370. export class AxesViewer {
  41371. private _xAxis;
  41372. private _yAxis;
  41373. private _zAxis;
  41374. private _scaleLinesFactor;
  41375. private _instanced;
  41376. /**
  41377. * Gets the hosting scene
  41378. */
  41379. scene: Scene;
  41380. /**
  41381. * Gets or sets a number used to scale line length
  41382. */
  41383. scaleLines: number;
  41384. /** Gets the node hierarchy used to render x-axis */
  41385. readonly xAxis: TransformNode;
  41386. /** Gets the node hierarchy used to render y-axis */
  41387. readonly yAxis: TransformNode;
  41388. /** Gets the node hierarchy used to render z-axis */
  41389. readonly zAxis: TransformNode;
  41390. /**
  41391. * Creates a new AxesViewer
  41392. * @param scene defines the hosting scene
  41393. * @param scaleLines defines a number used to scale line length (1 by default)
  41394. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41395. * @param xAxis defines the node hierarchy used to render the x-axis
  41396. * @param yAxis defines the node hierarchy used to render the y-axis
  41397. * @param zAxis defines the node hierarchy used to render the z-axis
  41398. */
  41399. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41400. /**
  41401. * Force the viewer to update
  41402. * @param position defines the position of the viewer
  41403. * @param xaxis defines the x axis of the viewer
  41404. * @param yaxis defines the y axis of the viewer
  41405. * @param zaxis defines the z axis of the viewer
  41406. */
  41407. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41408. /**
  41409. * Creates an instance of this axes viewer.
  41410. * @returns a new axes viewer with instanced meshes
  41411. */
  41412. createInstance(): AxesViewer;
  41413. /** Releases resources */
  41414. dispose(): void;
  41415. private static _SetRenderingGroupId;
  41416. }
  41417. }
  41418. declare module BABYLON.Debug {
  41419. /**
  41420. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41421. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41422. */
  41423. export class BoneAxesViewer extends AxesViewer {
  41424. /**
  41425. * Gets or sets the target mesh where to display the axes viewer
  41426. */
  41427. mesh: Nullable<Mesh>;
  41428. /**
  41429. * Gets or sets the target bone where to display the axes viewer
  41430. */
  41431. bone: Nullable<Bone>;
  41432. /** Gets current position */
  41433. pos: Vector3;
  41434. /** Gets direction of X axis */
  41435. xaxis: Vector3;
  41436. /** Gets direction of Y axis */
  41437. yaxis: Vector3;
  41438. /** Gets direction of Z axis */
  41439. zaxis: Vector3;
  41440. /**
  41441. * Creates a new BoneAxesViewer
  41442. * @param scene defines the hosting scene
  41443. * @param bone defines the target bone
  41444. * @param mesh defines the target mesh
  41445. * @param scaleLines defines a scaling factor for line length (1 by default)
  41446. */
  41447. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41448. /**
  41449. * Force the viewer to update
  41450. */
  41451. update(): void;
  41452. /** Releases resources */
  41453. dispose(): void;
  41454. }
  41455. }
  41456. declare module BABYLON {
  41457. /**
  41458. * Interface used to define scene explorer extensibility option
  41459. */
  41460. export interface IExplorerExtensibilityOption {
  41461. /**
  41462. * Define the option label
  41463. */
  41464. label: string;
  41465. /**
  41466. * Defines the action to execute on click
  41467. */
  41468. action: (entity: any) => void;
  41469. }
  41470. /**
  41471. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41472. */
  41473. export interface IExplorerExtensibilityGroup {
  41474. /**
  41475. * Defines a predicate to test if a given type mut be extended
  41476. */
  41477. predicate: (entity: any) => boolean;
  41478. /**
  41479. * Gets the list of options added to a type
  41480. */
  41481. entries: IExplorerExtensibilityOption[];
  41482. }
  41483. /**
  41484. * Interface used to define the options to use to create the Inspector
  41485. */
  41486. export interface IInspectorOptions {
  41487. /**
  41488. * Display in overlay mode (default: false)
  41489. */
  41490. overlay?: boolean;
  41491. /**
  41492. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41493. */
  41494. globalRoot?: HTMLElement;
  41495. /**
  41496. * Display the Scene explorer
  41497. */
  41498. showExplorer?: boolean;
  41499. /**
  41500. * Display the property inspector
  41501. */
  41502. showInspector?: boolean;
  41503. /**
  41504. * Display in embed mode (both panes on the right)
  41505. */
  41506. embedMode?: boolean;
  41507. /**
  41508. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41509. */
  41510. handleResize?: boolean;
  41511. /**
  41512. * Allow the panes to popup (default: true)
  41513. */
  41514. enablePopup?: boolean;
  41515. /**
  41516. * Allow the panes to be closed by users (default: true)
  41517. */
  41518. enableClose?: boolean;
  41519. /**
  41520. * Optional list of extensibility entries
  41521. */
  41522. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41523. /**
  41524. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41525. */
  41526. inspectorURL?: string;
  41527. }
  41528. interface Scene {
  41529. /**
  41530. * @hidden
  41531. * Backing field
  41532. */
  41533. _debugLayer: DebugLayer;
  41534. /**
  41535. * Gets the debug layer (aka Inspector) associated with the scene
  41536. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41537. */
  41538. debugLayer: DebugLayer;
  41539. }
  41540. /**
  41541. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41542. * what is happening in your scene
  41543. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41544. */
  41545. export class DebugLayer {
  41546. /**
  41547. * Define the url to get the inspector script from.
  41548. * By default it uses the babylonjs CDN.
  41549. * @ignoreNaming
  41550. */
  41551. static InspectorURL: string;
  41552. private _scene;
  41553. private BJSINSPECTOR;
  41554. /**
  41555. * Observable triggered when a property is changed through the inspector.
  41556. */
  41557. onPropertyChangedObservable: Observable<{
  41558. object: any;
  41559. property: string;
  41560. value: any;
  41561. initialValue: any;
  41562. }>;
  41563. /**
  41564. * Instantiates a new debug layer.
  41565. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41566. * what is happening in your scene
  41567. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41568. * @param scene Defines the scene to inspect
  41569. */
  41570. constructor(scene: Scene);
  41571. /** Creates the inspector window. */
  41572. private _createInspector;
  41573. /**
  41574. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41575. * @param entity defines the entity to select
  41576. * @param lineContainerTitle defines the specific block to highlight
  41577. */
  41578. select(entity: any, lineContainerTitle?: string): void;
  41579. /** Get the inspector from bundle or global */
  41580. private _getGlobalInspector;
  41581. /**
  41582. * Get if the inspector is visible or not.
  41583. * @returns true if visible otherwise, false
  41584. */
  41585. isVisible(): boolean;
  41586. /**
  41587. * Hide the inspector and close its window.
  41588. */
  41589. hide(): void;
  41590. /**
  41591. * Launch the debugLayer.
  41592. * @param config Define the configuration of the inspector
  41593. * @return a promise fulfilled when the debug layer is visible
  41594. */
  41595. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41596. }
  41597. }
  41598. declare module BABYLON {
  41599. /**
  41600. * Class containing static functions to help procedurally build meshes
  41601. */
  41602. export class BoxBuilder {
  41603. /**
  41604. * Creates a box mesh
  41605. * * The parameter `size` sets the size (float) of each box side (default 1)
  41606. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41607. * * 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)
  41608. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41610. * * 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
  41611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41612. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41613. * @param name defines the name of the mesh
  41614. * @param options defines the options used to create the mesh
  41615. * @param scene defines the hosting scene
  41616. * @returns the box mesh
  41617. */
  41618. static CreateBox(name: string, options: {
  41619. size?: number;
  41620. width?: number;
  41621. height?: number;
  41622. depth?: number;
  41623. faceUV?: Vector4[];
  41624. faceColors?: Color4[];
  41625. sideOrientation?: number;
  41626. frontUVs?: Vector4;
  41627. backUVs?: Vector4;
  41628. wrap?: boolean;
  41629. topBaseAt?: number;
  41630. bottomBaseAt?: number;
  41631. updatable?: boolean;
  41632. }, scene?: Nullable<Scene>): Mesh;
  41633. }
  41634. }
  41635. declare module BABYLON {
  41636. /**
  41637. * Class containing static functions to help procedurally build meshes
  41638. */
  41639. export class SphereBuilder {
  41640. /**
  41641. * Creates a sphere mesh
  41642. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41643. * * 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`)
  41644. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41645. * * 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
  41646. * * 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)
  41647. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41648. * * 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
  41649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41650. * @param name defines the name of the mesh
  41651. * @param options defines the options used to create the mesh
  41652. * @param scene defines the hosting scene
  41653. * @returns the sphere mesh
  41654. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41655. */
  41656. static CreateSphere(name: string, options: {
  41657. segments?: number;
  41658. diameter?: number;
  41659. diameterX?: number;
  41660. diameterY?: number;
  41661. diameterZ?: number;
  41662. arc?: number;
  41663. slice?: number;
  41664. sideOrientation?: number;
  41665. frontUVs?: Vector4;
  41666. backUVs?: Vector4;
  41667. updatable?: boolean;
  41668. }, scene: any): Mesh;
  41669. }
  41670. }
  41671. declare module BABYLON.Debug {
  41672. /**
  41673. * Used to show the physics impostor around the specific mesh
  41674. */
  41675. export class PhysicsViewer {
  41676. /** @hidden */
  41677. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41678. /** @hidden */
  41679. protected _meshes: Array<Nullable<AbstractMesh>>;
  41680. /** @hidden */
  41681. protected _scene: Nullable<Scene>;
  41682. /** @hidden */
  41683. protected _numMeshes: number;
  41684. /** @hidden */
  41685. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41686. private _renderFunction;
  41687. private _utilityLayer;
  41688. private _debugBoxMesh;
  41689. private _debugSphereMesh;
  41690. private _debugCylinderMesh;
  41691. private _debugMaterial;
  41692. private _debugMeshMeshes;
  41693. /**
  41694. * Creates a new PhysicsViewer
  41695. * @param scene defines the hosting scene
  41696. */
  41697. constructor(scene: Scene);
  41698. /** @hidden */
  41699. protected _updateDebugMeshes(): void;
  41700. /**
  41701. * Renders a specified physic impostor
  41702. * @param impostor defines the impostor to render
  41703. * @param targetMesh defines the mesh represented by the impostor
  41704. * @returns the new debug mesh used to render the impostor
  41705. */
  41706. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  41707. /**
  41708. * Hides a specified physic impostor
  41709. * @param impostor defines the impostor to hide
  41710. */
  41711. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41712. private _getDebugMaterial;
  41713. private _getDebugBoxMesh;
  41714. private _getDebugSphereMesh;
  41715. private _getDebugCylinderMesh;
  41716. private _getDebugMeshMesh;
  41717. private _getDebugMesh;
  41718. /** Releases all resources */
  41719. dispose(): void;
  41720. }
  41721. }
  41722. declare module BABYLON {
  41723. /**
  41724. * Class containing static functions to help procedurally build meshes
  41725. */
  41726. export class LinesBuilder {
  41727. /**
  41728. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41729. * * 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
  41730. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41731. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41732. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41733. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41734. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41735. * * 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
  41736. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41738. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41739. * @param name defines the name of the new line system
  41740. * @param options defines the options used to create the line system
  41741. * @param scene defines the hosting scene
  41742. * @returns a new line system mesh
  41743. */
  41744. static CreateLineSystem(name: string, options: {
  41745. lines: Vector3[][];
  41746. updatable?: boolean;
  41747. instance?: Nullable<LinesMesh>;
  41748. colors?: Nullable<Color4[][]>;
  41749. useVertexAlpha?: boolean;
  41750. }, scene: Nullable<Scene>): LinesMesh;
  41751. /**
  41752. * Creates a line mesh
  41753. * 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
  41754. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41755. * * The parameter `points` is an array successive Vector3
  41756. * * 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
  41757. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41758. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41759. * * When updating an instance, remember that only point positions can change, not the number of points
  41760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41761. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41762. * @param name defines the name of the new line system
  41763. * @param options defines the options used to create the line system
  41764. * @param scene defines the hosting scene
  41765. * @returns a new line mesh
  41766. */
  41767. static CreateLines(name: string, options: {
  41768. points: Vector3[];
  41769. updatable?: boolean;
  41770. instance?: Nullable<LinesMesh>;
  41771. colors?: Color4[];
  41772. useVertexAlpha?: boolean;
  41773. }, scene?: Nullable<Scene>): LinesMesh;
  41774. /**
  41775. * Creates a dashed line mesh
  41776. * * 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
  41777. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41778. * * The parameter `points` is an array successive Vector3
  41779. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41780. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41781. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41782. * * 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
  41783. * * When updating an instance, remember that only point positions can change, not the number of points
  41784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41785. * @param name defines the name of the mesh
  41786. * @param options defines the options used to create the mesh
  41787. * @param scene defines the hosting scene
  41788. * @returns the dashed line mesh
  41789. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41790. */
  41791. static CreateDashedLines(name: string, options: {
  41792. points: Vector3[];
  41793. dashSize?: number;
  41794. gapSize?: number;
  41795. dashNb?: number;
  41796. updatable?: boolean;
  41797. instance?: LinesMesh;
  41798. }, scene?: Nullable<Scene>): LinesMesh;
  41799. }
  41800. }
  41801. declare module BABYLON {
  41802. /**
  41803. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41804. * in order to better appreciate the issue one might have.
  41805. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41806. */
  41807. export class RayHelper {
  41808. /**
  41809. * Defines the ray we are currently tryin to visualize.
  41810. */
  41811. ray: Nullable<Ray>;
  41812. private _renderPoints;
  41813. private _renderLine;
  41814. private _renderFunction;
  41815. private _scene;
  41816. private _updateToMeshFunction;
  41817. private _attachedToMesh;
  41818. private _meshSpaceDirection;
  41819. private _meshSpaceOrigin;
  41820. /**
  41821. * Helper function to create a colored helper in a scene in one line.
  41822. * @param ray Defines the ray we are currently tryin to visualize
  41823. * @param scene Defines the scene the ray is used in
  41824. * @param color Defines the color we want to see the ray in
  41825. * @returns The newly created ray helper.
  41826. */
  41827. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41828. /**
  41829. * Instantiate a new ray helper.
  41830. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41831. * in order to better appreciate the issue one might have.
  41832. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41833. * @param ray Defines the ray we are currently tryin to visualize
  41834. */
  41835. constructor(ray: Ray);
  41836. /**
  41837. * Shows the ray we are willing to debug.
  41838. * @param scene Defines the scene the ray needs to be rendered in
  41839. * @param color Defines the color the ray needs to be rendered in
  41840. */
  41841. show(scene: Scene, color?: Color3): void;
  41842. /**
  41843. * Hides the ray we are debugging.
  41844. */
  41845. hide(): void;
  41846. private _render;
  41847. /**
  41848. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41849. * @param mesh Defines the mesh we want the helper attached to
  41850. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41851. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41852. * @param length Defines the length of the ray
  41853. */
  41854. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41855. /**
  41856. * Detach the ray helper from the mesh it has previously been attached to.
  41857. */
  41858. detachFromMesh(): void;
  41859. private _updateToMesh;
  41860. /**
  41861. * Dispose the helper and release its associated resources.
  41862. */
  41863. dispose(): void;
  41864. }
  41865. }
  41866. declare module BABYLON.Debug {
  41867. /**
  41868. * Class used to render a debug view of a given skeleton
  41869. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41870. */
  41871. export class SkeletonViewer {
  41872. /** defines the skeleton to render */
  41873. skeleton: Skeleton;
  41874. /** defines the mesh attached to the skeleton */
  41875. mesh: AbstractMesh;
  41876. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41877. autoUpdateBonesMatrices: boolean;
  41878. /** defines the rendering group id to use with the viewer */
  41879. renderingGroupId: number;
  41880. /** Gets or sets the color used to render the skeleton */
  41881. color: Color3;
  41882. private _scene;
  41883. private _debugLines;
  41884. private _debugMesh;
  41885. private _isEnabled;
  41886. private _renderFunction;
  41887. private _utilityLayer;
  41888. /**
  41889. * Returns the mesh used to render the bones
  41890. */
  41891. readonly debugMesh: Nullable<LinesMesh>;
  41892. /**
  41893. * Creates a new SkeletonViewer
  41894. * @param skeleton defines the skeleton to render
  41895. * @param mesh defines the mesh attached to the skeleton
  41896. * @param scene defines the hosting scene
  41897. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41898. * @param renderingGroupId defines the rendering group id to use with the viewer
  41899. */
  41900. constructor(
  41901. /** defines the skeleton to render */
  41902. skeleton: Skeleton,
  41903. /** defines the mesh attached to the skeleton */
  41904. mesh: AbstractMesh, scene: Scene,
  41905. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41906. autoUpdateBonesMatrices?: boolean,
  41907. /** defines the rendering group id to use with the viewer */
  41908. renderingGroupId?: number);
  41909. /** Gets or sets a boolean indicating if the viewer is enabled */
  41910. isEnabled: boolean;
  41911. private _getBonePosition;
  41912. private _getLinesForBonesWithLength;
  41913. private _getLinesForBonesNoLength;
  41914. /** Update the viewer to sync with current skeleton state */
  41915. update(): void;
  41916. /** Release associated resources */
  41917. dispose(): void;
  41918. }
  41919. }
  41920. declare module BABYLON {
  41921. /**
  41922. * Options to create the null engine
  41923. */
  41924. export class NullEngineOptions {
  41925. /**
  41926. * Render width (Default: 512)
  41927. */
  41928. renderWidth: number;
  41929. /**
  41930. * Render height (Default: 256)
  41931. */
  41932. renderHeight: number;
  41933. /**
  41934. * Texture size (Default: 512)
  41935. */
  41936. textureSize: number;
  41937. /**
  41938. * If delta time between frames should be constant
  41939. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41940. */
  41941. deterministicLockstep: boolean;
  41942. /**
  41943. * Maximum about of steps between frames (Default: 4)
  41944. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41945. */
  41946. lockstepMaxSteps: number;
  41947. }
  41948. /**
  41949. * The null engine class provides support for headless version of babylon.js.
  41950. * This can be used in server side scenario or for testing purposes
  41951. */
  41952. export class NullEngine extends Engine {
  41953. private _options;
  41954. /**
  41955. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41956. */
  41957. isDeterministicLockStep(): boolean;
  41958. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41959. getLockstepMaxSteps(): number;
  41960. /**
  41961. * Sets hardware scaling, used to save performance if needed
  41962. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41963. */
  41964. getHardwareScalingLevel(): number;
  41965. constructor(options?: NullEngineOptions);
  41966. createVertexBuffer(vertices: FloatArray): DataBuffer;
  41967. createIndexBuffer(indices: IndicesArray): DataBuffer;
  41968. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41969. getRenderWidth(useScreen?: boolean): number;
  41970. getRenderHeight(useScreen?: boolean): number;
  41971. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41972. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41973. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41974. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41975. bindSamplers(effect: Effect): void;
  41976. enableEffect(effect: Effect): void;
  41977. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41978. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41979. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41980. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41981. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41982. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41983. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41984. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41985. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41986. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41987. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41988. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41989. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41990. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41991. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41992. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41993. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41994. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41995. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41996. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41997. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41998. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41999. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42000. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42001. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42002. bindBuffers(vertexBuffers: {
  42003. [key: string]: VertexBuffer;
  42004. }, indexBuffer: DataBuffer, effect: Effect): void;
  42005. wipeCaches(bruteForce?: boolean): void;
  42006. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42007. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42008. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42009. /** @hidden */
  42010. _createTexture(): WebGLTexture;
  42011. /** @hidden */
  42012. _releaseTexture(texture: InternalTexture): void;
  42013. 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;
  42014. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42015. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42016. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42017. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42018. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42019. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42020. areAllEffectsReady(): boolean;
  42021. /**
  42022. * @hidden
  42023. * Get the current error code of the webGL context
  42024. * @returns the error code
  42025. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42026. */
  42027. getError(): number;
  42028. /** @hidden */
  42029. _getUnpackAlignement(): number;
  42030. /** @hidden */
  42031. _unpackFlipY(value: boolean): void;
  42032. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42033. /**
  42034. * Updates a dynamic vertex buffer.
  42035. * @param vertexBuffer the vertex buffer to update
  42036. * @param data the data used to update the vertex buffer
  42037. * @param byteOffset the byte offset of the data (optional)
  42038. * @param byteLength the byte length of the data (optional)
  42039. */
  42040. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42041. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42042. /** @hidden */
  42043. _bindTexture(channel: number, texture: InternalTexture): void;
  42044. /** @hidden */
  42045. _releaseBuffer(buffer: DataBuffer): boolean;
  42046. releaseEffects(): void;
  42047. displayLoadingUI(): void;
  42048. hideLoadingUI(): void;
  42049. /** @hidden */
  42050. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42051. /** @hidden */
  42052. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42053. /** @hidden */
  42054. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42055. /** @hidden */
  42056. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42057. }
  42058. }
  42059. declare module BABYLON {
  42060. /** @hidden */
  42061. export class _OcclusionDataStorage {
  42062. /** @hidden */
  42063. occlusionInternalRetryCounter: number;
  42064. /** @hidden */
  42065. isOcclusionQueryInProgress: boolean;
  42066. /** @hidden */
  42067. isOccluded: boolean;
  42068. /** @hidden */
  42069. occlusionRetryCount: number;
  42070. /** @hidden */
  42071. occlusionType: number;
  42072. /** @hidden */
  42073. occlusionQueryAlgorithmType: number;
  42074. }
  42075. interface Engine {
  42076. /**
  42077. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42078. * @return the new query
  42079. */
  42080. createQuery(): WebGLQuery;
  42081. /**
  42082. * Delete and release a webGL query
  42083. * @param query defines the query to delete
  42084. * @return the current engine
  42085. */
  42086. deleteQuery(query: WebGLQuery): Engine;
  42087. /**
  42088. * Check if a given query has resolved and got its value
  42089. * @param query defines the query to check
  42090. * @returns true if the query got its value
  42091. */
  42092. isQueryResultAvailable(query: WebGLQuery): boolean;
  42093. /**
  42094. * Gets the value of a given query
  42095. * @param query defines the query to check
  42096. * @returns the value of the query
  42097. */
  42098. getQueryResult(query: WebGLQuery): number;
  42099. /**
  42100. * Initiates an occlusion query
  42101. * @param algorithmType defines the algorithm to use
  42102. * @param query defines the query to use
  42103. * @returns the current engine
  42104. * @see http://doc.babylonjs.com/features/occlusionquery
  42105. */
  42106. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42107. /**
  42108. * Ends an occlusion query
  42109. * @see http://doc.babylonjs.com/features/occlusionquery
  42110. * @param algorithmType defines the algorithm to use
  42111. * @returns the current engine
  42112. */
  42113. endOcclusionQuery(algorithmType: number): Engine;
  42114. /**
  42115. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42116. * Please note that only one query can be issued at a time
  42117. * @returns a time token used to track the time span
  42118. */
  42119. startTimeQuery(): Nullable<_TimeToken>;
  42120. /**
  42121. * Ends a time query
  42122. * @param token defines the token used to measure the time span
  42123. * @returns the time spent (in ns)
  42124. */
  42125. endTimeQuery(token: _TimeToken): int;
  42126. /** @hidden */
  42127. _currentNonTimestampToken: Nullable<_TimeToken>;
  42128. /** @hidden */
  42129. _createTimeQuery(): WebGLQuery;
  42130. /** @hidden */
  42131. _deleteTimeQuery(query: WebGLQuery): void;
  42132. /** @hidden */
  42133. _getGlAlgorithmType(algorithmType: number): number;
  42134. /** @hidden */
  42135. _getTimeQueryResult(query: WebGLQuery): any;
  42136. /** @hidden */
  42137. _getTimeQueryAvailability(query: WebGLQuery): any;
  42138. }
  42139. interface AbstractMesh {
  42140. /**
  42141. * Backing filed
  42142. * @hidden
  42143. */
  42144. __occlusionDataStorage: _OcclusionDataStorage;
  42145. /**
  42146. * Access property
  42147. * @hidden
  42148. */
  42149. _occlusionDataStorage: _OcclusionDataStorage;
  42150. /**
  42151. * 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.
  42152. * The default value is -1 which means don't break the query and wait till the result
  42153. * @see http://doc.babylonjs.com/features/occlusionquery
  42154. */
  42155. occlusionRetryCount: number;
  42156. /**
  42157. * 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:
  42158. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42159. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42160. * * 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.
  42161. * @see http://doc.babylonjs.com/features/occlusionquery
  42162. */
  42163. occlusionType: number;
  42164. /**
  42165. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42166. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42167. * * 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.
  42168. * @see http://doc.babylonjs.com/features/occlusionquery
  42169. */
  42170. occlusionQueryAlgorithmType: number;
  42171. /**
  42172. * 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
  42173. * @see http://doc.babylonjs.com/features/occlusionquery
  42174. */
  42175. isOccluded: boolean;
  42176. /**
  42177. * Flag to check the progress status of the query
  42178. * @see http://doc.babylonjs.com/features/occlusionquery
  42179. */
  42180. isOcclusionQueryInProgress: boolean;
  42181. }
  42182. }
  42183. declare module BABYLON {
  42184. /** @hidden */
  42185. export var _forceTransformFeedbackToBundle: boolean;
  42186. interface Engine {
  42187. /**
  42188. * Creates a webGL transform feedback object
  42189. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42190. * @returns the webGL transform feedback object
  42191. */
  42192. createTransformFeedback(): WebGLTransformFeedback;
  42193. /**
  42194. * Delete a webGL transform feedback object
  42195. * @param value defines the webGL transform feedback object to delete
  42196. */
  42197. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42198. /**
  42199. * Bind a webGL transform feedback object to the webgl context
  42200. * @param value defines the webGL transform feedback object to bind
  42201. */
  42202. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42203. /**
  42204. * Begins a transform feedback operation
  42205. * @param usePoints defines if points or triangles must be used
  42206. */
  42207. beginTransformFeedback(usePoints: boolean): void;
  42208. /**
  42209. * Ends a transform feedback operation
  42210. */
  42211. endTransformFeedback(): void;
  42212. /**
  42213. * Specify the varyings to use with transform feedback
  42214. * @param program defines the associated webGL program
  42215. * @param value defines the list of strings representing the varying names
  42216. */
  42217. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42218. /**
  42219. * Bind a webGL buffer for a transform feedback operation
  42220. * @param value defines the webGL buffer to bind
  42221. */
  42222. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  42223. }
  42224. }
  42225. declare module BABYLON {
  42226. /**
  42227. * Creation options of the multi render target texture.
  42228. */
  42229. export interface IMultiRenderTargetOptions {
  42230. /**
  42231. * Define if the texture needs to create mip maps after render.
  42232. */
  42233. generateMipMaps?: boolean;
  42234. /**
  42235. * Define the types of all the draw buffers we want to create
  42236. */
  42237. types?: number[];
  42238. /**
  42239. * Define the sampling modes of all the draw buffers we want to create
  42240. */
  42241. samplingModes?: number[];
  42242. /**
  42243. * Define if a depth buffer is required
  42244. */
  42245. generateDepthBuffer?: boolean;
  42246. /**
  42247. * Define if a stencil buffer is required
  42248. */
  42249. generateStencilBuffer?: boolean;
  42250. /**
  42251. * Define if a depth texture is required instead of a depth buffer
  42252. */
  42253. generateDepthTexture?: boolean;
  42254. /**
  42255. * Define the number of desired draw buffers
  42256. */
  42257. textureCount?: number;
  42258. /**
  42259. * Define if aspect ratio should be adapted to the texture or stay the scene one
  42260. */
  42261. doNotChangeAspectRatio?: boolean;
  42262. /**
  42263. * Define the default type of the buffers we are creating
  42264. */
  42265. defaultType?: number;
  42266. }
  42267. /**
  42268. * A multi render target, like a render target provides the ability to render to a texture.
  42269. * Unlike the render target, it can render to several draw buffers in one draw.
  42270. * This is specially interesting in deferred rendering or for any effects requiring more than
  42271. * just one color from a single pass.
  42272. */
  42273. export class MultiRenderTarget extends RenderTargetTexture {
  42274. private _internalTextures;
  42275. private _textures;
  42276. private _multiRenderTargetOptions;
  42277. /**
  42278. * Get if draw buffers are currently supported by the used hardware and browser.
  42279. */
  42280. readonly isSupported: boolean;
  42281. /**
  42282. * Get the list of textures generated by the multi render target.
  42283. */
  42284. readonly textures: Texture[];
  42285. /**
  42286. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  42287. */
  42288. readonly depthTexture: Texture;
  42289. /**
  42290. * Set the wrapping mode on U of all the textures we are rendering to.
  42291. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42292. */
  42293. wrapU: number;
  42294. /**
  42295. * Set the wrapping mode on V of all the textures we are rendering to.
  42296. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42297. */
  42298. wrapV: number;
  42299. /**
  42300. * Instantiate a new multi render target texture.
  42301. * A multi render target, like a render target provides the ability to render to a texture.
  42302. * Unlike the render target, it can render to several draw buffers in one draw.
  42303. * This is specially interesting in deferred rendering or for any effects requiring more than
  42304. * just one color from a single pass.
  42305. * @param name Define the name of the texture
  42306. * @param size Define the size of the buffers to render to
  42307. * @param count Define the number of target we are rendering into
  42308. * @param scene Define the scene the texture belongs to
  42309. * @param options Define the options used to create the multi render target
  42310. */
  42311. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  42312. /** @hidden */
  42313. _rebuild(): void;
  42314. private _createInternalTextures;
  42315. private _createTextures;
  42316. /**
  42317. * Define the number of samples used if MSAA is enabled.
  42318. */
  42319. samples: number;
  42320. /**
  42321. * Resize all the textures in the multi render target.
  42322. * Be carrefull as it will recreate all the data in the new texture.
  42323. * @param size Define the new size
  42324. */
  42325. resize(size: any): void;
  42326. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  42327. /**
  42328. * Dispose the render targets and their associated resources
  42329. */
  42330. dispose(): void;
  42331. /**
  42332. * Release all the underlying texture used as draw buffers.
  42333. */
  42334. releaseInternalTextures(): void;
  42335. }
  42336. }
  42337. declare module BABYLON {
  42338. interface Engine {
  42339. /**
  42340. * Unbind a list of render target textures from the webGL context
  42341. * This is used only when drawBuffer extension or webGL2 are active
  42342. * @param textures defines the render target textures to unbind
  42343. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  42344. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  42345. */
  42346. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  42347. /**
  42348. * Create a multi render target texture
  42349. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  42350. * @param size defines the size of the texture
  42351. * @param options defines the creation options
  42352. * @returns the cube texture as an InternalTexture
  42353. */
  42354. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  42355. /**
  42356. * Update the sample count for a given multiple render target texture
  42357. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42358. * @param textures defines the textures to update
  42359. * @param samples defines the sample count to set
  42360. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42361. */
  42362. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  42363. }
  42364. }
  42365. declare module BABYLON {
  42366. /**
  42367. * Gather the list of clipboard event types as constants.
  42368. */
  42369. export class ClipboardEventTypes {
  42370. /**
  42371. * The clipboard event is fired when a copy command is active (pressed).
  42372. */
  42373. static readonly COPY: number;
  42374. /**
  42375. * The clipboard event is fired when a cut command is active (pressed).
  42376. */
  42377. static readonly CUT: number;
  42378. /**
  42379. * The clipboard event is fired when a paste command is active (pressed).
  42380. */
  42381. static readonly PASTE: number;
  42382. }
  42383. /**
  42384. * This class is used to store clipboard related info for the onClipboardObservable event.
  42385. */
  42386. export class ClipboardInfo {
  42387. /**
  42388. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42389. */
  42390. type: number;
  42391. /**
  42392. * Defines the related dom event
  42393. */
  42394. event: ClipboardEvent;
  42395. /**
  42396. *Creates an instance of ClipboardInfo.
  42397. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42398. * @param event Defines the related dom event
  42399. */
  42400. constructor(
  42401. /**
  42402. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42403. */
  42404. type: number,
  42405. /**
  42406. * Defines the related dom event
  42407. */
  42408. event: ClipboardEvent);
  42409. /**
  42410. * Get the clipboard event's type from the keycode.
  42411. * @param keyCode Defines the keyCode for the current keyboard event.
  42412. * @return {number}
  42413. */
  42414. static GetTypeFromCharacter(keyCode: number): number;
  42415. }
  42416. }
  42417. declare module BABYLON {
  42418. /**
  42419. * Class used to represent data loading progression
  42420. */
  42421. export class SceneLoaderProgressEvent {
  42422. /** defines if data length to load can be evaluated */
  42423. readonly lengthComputable: boolean;
  42424. /** defines the loaded data length */
  42425. readonly loaded: number;
  42426. /** defines the data length to load */
  42427. readonly total: number;
  42428. /**
  42429. * Create a new progress event
  42430. * @param lengthComputable defines if data length to load can be evaluated
  42431. * @param loaded defines the loaded data length
  42432. * @param total defines the data length to load
  42433. */
  42434. constructor(
  42435. /** defines if data length to load can be evaluated */
  42436. lengthComputable: boolean,
  42437. /** defines the loaded data length */
  42438. loaded: number,
  42439. /** defines the data length to load */
  42440. total: number);
  42441. /**
  42442. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42443. * @param event defines the source event
  42444. * @returns a new SceneLoaderProgressEvent
  42445. */
  42446. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42447. }
  42448. /**
  42449. * Interface used by SceneLoader plugins to define supported file extensions
  42450. */
  42451. export interface ISceneLoaderPluginExtensions {
  42452. /**
  42453. * Defines the list of supported extensions
  42454. */
  42455. [extension: string]: {
  42456. isBinary: boolean;
  42457. };
  42458. }
  42459. /**
  42460. * Interface used by SceneLoader plugin factory
  42461. */
  42462. export interface ISceneLoaderPluginFactory {
  42463. /**
  42464. * Defines the name of the factory
  42465. */
  42466. name: string;
  42467. /**
  42468. * Function called to create a new plugin
  42469. * @return the new plugin
  42470. */
  42471. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42472. /**
  42473. * Boolean indicating if the plugin can direct load specific data
  42474. */
  42475. canDirectLoad?: (data: string) => boolean;
  42476. }
  42477. /**
  42478. * Interface used to define a SceneLoader plugin
  42479. */
  42480. export interface ISceneLoaderPlugin {
  42481. /**
  42482. * The friendly name of this plugin.
  42483. */
  42484. name: string;
  42485. /**
  42486. * The file extensions supported by this plugin.
  42487. */
  42488. extensions: string | ISceneLoaderPluginExtensions;
  42489. /**
  42490. * Import meshes into a scene.
  42491. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42492. * @param scene The scene to import into
  42493. * @param data The data to import
  42494. * @param rootUrl The root url for scene and resources
  42495. * @param meshes The meshes array to import into
  42496. * @param particleSystems The particle systems array to import into
  42497. * @param skeletons The skeletons array to import into
  42498. * @param onError The callback when import fails
  42499. * @returns True if successful or false otherwise
  42500. */
  42501. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42502. /**
  42503. * Load into a scene.
  42504. * @param scene The scene to load into
  42505. * @param data The data to import
  42506. * @param rootUrl The root url for scene and resources
  42507. * @param onError The callback when import fails
  42508. * @returns true if successful or false otherwise
  42509. */
  42510. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42511. /**
  42512. * The callback that returns true if the data can be directly loaded.
  42513. */
  42514. canDirectLoad?: (data: string) => boolean;
  42515. /**
  42516. * The callback that allows custom handling of the root url based on the response url.
  42517. */
  42518. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42519. /**
  42520. * Load into an asset container.
  42521. * @param scene The scene to load into
  42522. * @param data The data to import
  42523. * @param rootUrl The root url for scene and resources
  42524. * @param onError The callback when import fails
  42525. * @returns The loaded asset container
  42526. */
  42527. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42528. }
  42529. /**
  42530. * Interface used to define an async SceneLoader plugin
  42531. */
  42532. export interface ISceneLoaderPluginAsync {
  42533. /**
  42534. * The friendly name of this plugin.
  42535. */
  42536. name: string;
  42537. /**
  42538. * The file extensions supported by this plugin.
  42539. */
  42540. extensions: string | ISceneLoaderPluginExtensions;
  42541. /**
  42542. * Import meshes into a scene.
  42543. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42544. * @param scene The scene to import into
  42545. * @param data The data to import
  42546. * @param rootUrl The root url for scene and resources
  42547. * @param onProgress The callback when the load progresses
  42548. * @param fileName Defines the name of the file to load
  42549. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42550. */
  42551. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42552. meshes: AbstractMesh[];
  42553. particleSystems: IParticleSystem[];
  42554. skeletons: Skeleton[];
  42555. animationGroups: AnimationGroup[];
  42556. }>;
  42557. /**
  42558. * Load into a scene.
  42559. * @param scene The scene to load into
  42560. * @param data The data to import
  42561. * @param rootUrl The root url for scene and resources
  42562. * @param onProgress The callback when the load progresses
  42563. * @param fileName Defines the name of the file to load
  42564. * @returns Nothing
  42565. */
  42566. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42567. /**
  42568. * The callback that returns true if the data can be directly loaded.
  42569. */
  42570. canDirectLoad?: (data: string) => boolean;
  42571. /**
  42572. * The callback that allows custom handling of the root url based on the response url.
  42573. */
  42574. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42575. /**
  42576. * Load into an asset container.
  42577. * @param scene The scene to load into
  42578. * @param data The data to import
  42579. * @param rootUrl The root url for scene and resources
  42580. * @param onProgress The callback when the load progresses
  42581. * @param fileName Defines the name of the file to load
  42582. * @returns The loaded asset container
  42583. */
  42584. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42585. }
  42586. /**
  42587. * Class used to load scene from various file formats using registered plugins
  42588. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42589. */
  42590. export class SceneLoader {
  42591. /**
  42592. * No logging while loading
  42593. */
  42594. static readonly NO_LOGGING: number;
  42595. /**
  42596. * Minimal logging while loading
  42597. */
  42598. static readonly MINIMAL_LOGGING: number;
  42599. /**
  42600. * Summary logging while loading
  42601. */
  42602. static readonly SUMMARY_LOGGING: number;
  42603. /**
  42604. * Detailled logging while loading
  42605. */
  42606. static readonly DETAILED_LOGGING: number;
  42607. /**
  42608. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42609. */
  42610. static ForceFullSceneLoadingForIncremental: boolean;
  42611. /**
  42612. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42613. */
  42614. static ShowLoadingScreen: boolean;
  42615. /**
  42616. * Defines the current logging level (while loading the scene)
  42617. * @ignorenaming
  42618. */
  42619. static loggingLevel: number;
  42620. /**
  42621. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42622. */
  42623. static CleanBoneMatrixWeights: boolean;
  42624. /**
  42625. * Event raised when a plugin is used to load a scene
  42626. */
  42627. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42628. private static _registeredPlugins;
  42629. private static _getDefaultPlugin;
  42630. private static _getPluginForExtension;
  42631. private static _getPluginForDirectLoad;
  42632. private static _getPluginForFilename;
  42633. private static _getDirectLoad;
  42634. private static _loadData;
  42635. private static _getFileInfo;
  42636. /**
  42637. * Gets a plugin that can load the given extension
  42638. * @param extension defines the extension to load
  42639. * @returns a plugin or null if none works
  42640. */
  42641. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42642. /**
  42643. * Gets a boolean indicating that the given extension can be loaded
  42644. * @param extension defines the extension to load
  42645. * @returns true if the extension is supported
  42646. */
  42647. static IsPluginForExtensionAvailable(extension: string): boolean;
  42648. /**
  42649. * Adds a new plugin to the list of registered plugins
  42650. * @param plugin defines the plugin to add
  42651. */
  42652. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42653. /**
  42654. * Import meshes into a scene
  42655. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42656. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  42657. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  42658. * @param scene the instance of BABYLON.Scene to append to
  42659. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42660. * @param onProgress a callback with a progress event for each file being loaded
  42661. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42662. * @param pluginExtension the extension used to determine the plugin
  42663. * @returns The loaded plugin
  42664. */
  42665. 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>;
  42666. /**
  42667. * Import meshes into a scene
  42668. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42669. * @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)
  42670. * @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)
  42671. * @param scene the instance of BABYLON.Scene to append to
  42672. * @param onProgress a callback with a progress event for each file being loaded
  42673. * @param pluginExtension the extension used to determine the plugin
  42674. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42675. */
  42676. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42677. meshes: AbstractMesh[];
  42678. particleSystems: IParticleSystem[];
  42679. skeletons: Skeleton[];
  42680. animationGroups: AnimationGroup[];
  42681. }>;
  42682. /**
  42683. * Load a scene
  42684. * @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)
  42685. * @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)
  42686. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42687. * @param onSuccess a callback with the scene when import succeeds
  42688. * @param onProgress a callback with a progress event for each file being loaded
  42689. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42690. * @param pluginExtension the extension used to determine the plugin
  42691. * @returns The loaded plugin
  42692. */
  42693. 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>;
  42694. /**
  42695. * Load a scene
  42696. * @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)
  42697. * @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)
  42698. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42699. * @param onProgress a callback with a progress event for each file being loaded
  42700. * @param pluginExtension the extension used to determine the plugin
  42701. * @returns The loaded scene
  42702. */
  42703. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42704. /**
  42705. * Append a scene
  42706. * @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)
  42707. * @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)
  42708. * @param scene is the instance of BABYLON.Scene to append to
  42709. * @param onSuccess a callback with the scene when import succeeds
  42710. * @param onProgress a callback with a progress event for each file being loaded
  42711. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42712. * @param pluginExtension the extension used to determine the plugin
  42713. * @returns The loaded plugin
  42714. */
  42715. 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>;
  42716. /**
  42717. * Append a scene
  42718. * @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)
  42719. * @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)
  42720. * @param scene is the instance of BABYLON.Scene to append to
  42721. * @param onProgress a callback with a progress event for each file being loaded
  42722. * @param pluginExtension the extension used to determine the plugin
  42723. * @returns The given scene
  42724. */
  42725. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42726. /**
  42727. * Load a scene into an asset container
  42728. * @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)
  42729. * @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)
  42730. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42731. * @param onSuccess a callback with the scene when import succeeds
  42732. * @param onProgress a callback with a progress event for each file being loaded
  42733. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42734. * @param pluginExtension the extension used to determine the plugin
  42735. * @returns The loaded plugin
  42736. */
  42737. 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>;
  42738. /**
  42739. * Load a scene into an asset container
  42740. * @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)
  42741. * @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)
  42742. * @param scene is the instance of Scene to append to
  42743. * @param onProgress a callback with a progress event for each file being loaded
  42744. * @param pluginExtension the extension used to determine the plugin
  42745. * @returns The loaded asset container
  42746. */
  42747. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42748. }
  42749. }
  42750. declare module BABYLON {
  42751. /**
  42752. * Google Daydream controller
  42753. */
  42754. export class DaydreamController extends WebVRController {
  42755. /**
  42756. * Base Url for the controller model.
  42757. */
  42758. static MODEL_BASE_URL: string;
  42759. /**
  42760. * File name for the controller model.
  42761. */
  42762. static MODEL_FILENAME: string;
  42763. /**
  42764. * Gamepad Id prefix used to identify Daydream Controller.
  42765. */
  42766. static readonly GAMEPAD_ID_PREFIX: string;
  42767. /**
  42768. * Creates a new DaydreamController from a gamepad
  42769. * @param vrGamepad the gamepad that the controller should be created from
  42770. */
  42771. constructor(vrGamepad: any);
  42772. /**
  42773. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42774. * @param scene scene in which to add meshes
  42775. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42776. */
  42777. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42778. /**
  42779. * Called once for each button that changed state since the last frame
  42780. * @param buttonIdx Which button index changed
  42781. * @param state New state of the button
  42782. * @param changes Which properties on the state changed since last frame
  42783. */
  42784. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42785. }
  42786. }
  42787. declare module BABYLON {
  42788. /**
  42789. * Gear VR Controller
  42790. */
  42791. export class GearVRController extends WebVRController {
  42792. /**
  42793. * Base Url for the controller model.
  42794. */
  42795. static MODEL_BASE_URL: string;
  42796. /**
  42797. * File name for the controller model.
  42798. */
  42799. static MODEL_FILENAME: string;
  42800. /**
  42801. * Gamepad Id prefix used to identify this controller.
  42802. */
  42803. static readonly GAMEPAD_ID_PREFIX: string;
  42804. private readonly _buttonIndexToObservableNameMap;
  42805. /**
  42806. * Creates a new GearVRController from a gamepad
  42807. * @param vrGamepad the gamepad that the controller should be created from
  42808. */
  42809. constructor(vrGamepad: any);
  42810. /**
  42811. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42812. * @param scene scene in which to add meshes
  42813. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42814. */
  42815. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42816. /**
  42817. * Called once for each button that changed state since the last frame
  42818. * @param buttonIdx Which button index changed
  42819. * @param state New state of the button
  42820. * @param changes Which properties on the state changed since last frame
  42821. */
  42822. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42823. }
  42824. }
  42825. declare module BABYLON {
  42826. /**
  42827. * Generic Controller
  42828. */
  42829. export class GenericController extends WebVRController {
  42830. /**
  42831. * Base Url for the controller model.
  42832. */
  42833. static readonly MODEL_BASE_URL: string;
  42834. /**
  42835. * File name for the controller model.
  42836. */
  42837. static readonly MODEL_FILENAME: string;
  42838. /**
  42839. * Creates a new GenericController from a gamepad
  42840. * @param vrGamepad the gamepad that the controller should be created from
  42841. */
  42842. constructor(vrGamepad: any);
  42843. /**
  42844. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42845. * @param scene scene in which to add meshes
  42846. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42847. */
  42848. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42849. /**
  42850. * Called once for each button that changed state since the last frame
  42851. * @param buttonIdx Which button index changed
  42852. * @param state New state of the button
  42853. * @param changes Which properties on the state changed since last frame
  42854. */
  42855. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42856. }
  42857. }
  42858. declare module BABYLON {
  42859. /**
  42860. * Oculus Touch Controller
  42861. */
  42862. export class OculusTouchController extends WebVRController {
  42863. /**
  42864. * Base Url for the controller model.
  42865. */
  42866. static MODEL_BASE_URL: string;
  42867. /**
  42868. * File name for the left controller model.
  42869. */
  42870. static MODEL_LEFT_FILENAME: string;
  42871. /**
  42872. * File name for the right controller model.
  42873. */
  42874. static MODEL_RIGHT_FILENAME: string;
  42875. /**
  42876. * Base Url for the Quest controller model.
  42877. */
  42878. static QUEST_MODEL_BASE_URL: string;
  42879. /**
  42880. * @hidden
  42881. * If the controllers are running on a device that needs the updated Quest controller models
  42882. */
  42883. static _IsQuest: boolean;
  42884. /**
  42885. * Fired when the secondary trigger on this controller is modified
  42886. */
  42887. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42888. /**
  42889. * Fired when the thumb rest on this controller is modified
  42890. */
  42891. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42892. /**
  42893. * Creates a new OculusTouchController from a gamepad
  42894. * @param vrGamepad the gamepad that the controller should be created from
  42895. */
  42896. constructor(vrGamepad: any);
  42897. /**
  42898. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42899. * @param scene scene in which to add meshes
  42900. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42901. */
  42902. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42903. /**
  42904. * Fired when the A button on this controller is modified
  42905. */
  42906. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42907. /**
  42908. * Fired when the B button on this controller is modified
  42909. */
  42910. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42911. /**
  42912. * Fired when the X button on this controller is modified
  42913. */
  42914. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42915. /**
  42916. * Fired when the Y button on this controller is modified
  42917. */
  42918. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42919. /**
  42920. * Called once for each button that changed state since the last frame
  42921. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42922. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42923. * 2) secondary trigger (same)
  42924. * 3) A (right) X (left), touch, pressed = value
  42925. * 4) B / Y
  42926. * 5) thumb rest
  42927. * @param buttonIdx Which button index changed
  42928. * @param state New state of the button
  42929. * @param changes Which properties on the state changed since last frame
  42930. */
  42931. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42932. }
  42933. }
  42934. declare module BABYLON {
  42935. /**
  42936. * Vive Controller
  42937. */
  42938. export class ViveController extends WebVRController {
  42939. /**
  42940. * Base Url for the controller model.
  42941. */
  42942. static MODEL_BASE_URL: string;
  42943. /**
  42944. * File name for the controller model.
  42945. */
  42946. static MODEL_FILENAME: string;
  42947. /**
  42948. * Creates a new ViveController from a gamepad
  42949. * @param vrGamepad the gamepad that the controller should be created from
  42950. */
  42951. constructor(vrGamepad: any);
  42952. /**
  42953. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42954. * @param scene scene in which to add meshes
  42955. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42956. */
  42957. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42958. /**
  42959. * Fired when the left button on this controller is modified
  42960. */
  42961. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42962. /**
  42963. * Fired when the right button on this controller is modified
  42964. */
  42965. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42966. /**
  42967. * Fired when the menu button on this controller is modified
  42968. */
  42969. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42970. /**
  42971. * Called once for each button that changed state since the last frame
  42972. * Vive mapping:
  42973. * 0: touchpad
  42974. * 1: trigger
  42975. * 2: left AND right buttons
  42976. * 3: menu button
  42977. * @param buttonIdx Which button index changed
  42978. * @param state New state of the button
  42979. * @param changes Which properties on the state changed since last frame
  42980. */
  42981. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42982. }
  42983. }
  42984. declare module BABYLON {
  42985. /**
  42986. * Defines the WindowsMotionController object that the state of the windows motion controller
  42987. */
  42988. export class WindowsMotionController extends WebVRController {
  42989. /**
  42990. * The base url used to load the left and right controller models
  42991. */
  42992. static MODEL_BASE_URL: string;
  42993. /**
  42994. * The name of the left controller model file
  42995. */
  42996. static MODEL_LEFT_FILENAME: string;
  42997. /**
  42998. * The name of the right controller model file
  42999. */
  43000. static MODEL_RIGHT_FILENAME: string;
  43001. /**
  43002. * The controller name prefix for this controller type
  43003. */
  43004. static readonly GAMEPAD_ID_PREFIX: string;
  43005. /**
  43006. * The controller id pattern for this controller type
  43007. */
  43008. private static readonly GAMEPAD_ID_PATTERN;
  43009. private _loadedMeshInfo;
  43010. private readonly _mapping;
  43011. /**
  43012. * Fired when the trackpad on this controller is clicked
  43013. */
  43014. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43015. /**
  43016. * Fired when the trackpad on this controller is modified
  43017. */
  43018. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43019. /**
  43020. * The current x and y values of this controller's trackpad
  43021. */
  43022. trackpad: StickValues;
  43023. /**
  43024. * Creates a new WindowsMotionController from a gamepad
  43025. * @param vrGamepad the gamepad that the controller should be created from
  43026. */
  43027. constructor(vrGamepad: any);
  43028. /**
  43029. * Fired when the trigger on this controller is modified
  43030. */
  43031. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43032. /**
  43033. * Fired when the menu button on this controller is modified
  43034. */
  43035. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43036. /**
  43037. * Fired when the grip button on this controller is modified
  43038. */
  43039. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43040. /**
  43041. * Fired when the thumbstick button on this controller is modified
  43042. */
  43043. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43044. /**
  43045. * Fired when the touchpad button on this controller is modified
  43046. */
  43047. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43048. /**
  43049. * Fired when the touchpad values on this controller are modified
  43050. */
  43051. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43052. private _updateTrackpad;
  43053. /**
  43054. * Called once per frame by the engine.
  43055. */
  43056. update(): void;
  43057. /**
  43058. * Called once for each button that changed state since the last frame
  43059. * @param buttonIdx Which button index changed
  43060. * @param state New state of the button
  43061. * @param changes Which properties on the state changed since last frame
  43062. */
  43063. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43064. /**
  43065. * Moves the buttons on the controller mesh based on their current state
  43066. * @param buttonName the name of the button to move
  43067. * @param buttonValue the value of the button which determines the buttons new position
  43068. */
  43069. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43070. /**
  43071. * Moves the axis on the controller mesh based on its current state
  43072. * @param axis the index of the axis
  43073. * @param axisValue the value of the axis which determines the meshes new position
  43074. * @hidden
  43075. */
  43076. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43077. /**
  43078. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43079. * @param scene scene in which to add meshes
  43080. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43081. */
  43082. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43083. /**
  43084. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43085. * can be transformed by button presses and axes values, based on this._mapping.
  43086. *
  43087. * @param scene scene in which the meshes exist
  43088. * @param meshes list of meshes that make up the controller model to process
  43089. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43090. */
  43091. private processModel;
  43092. private createMeshInfo;
  43093. /**
  43094. * Gets the ray of the controller in the direction the controller is pointing
  43095. * @param length the length the resulting ray should be
  43096. * @returns a ray in the direction the controller is pointing
  43097. */
  43098. getForwardRay(length?: number): Ray;
  43099. /**
  43100. * Disposes of the controller
  43101. */
  43102. dispose(): void;
  43103. }
  43104. }
  43105. declare module BABYLON {
  43106. /**
  43107. * Class containing static functions to help procedurally build meshes
  43108. */
  43109. export class PolyhedronBuilder {
  43110. /**
  43111. * Creates a polyhedron mesh
  43112. * * 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
  43113. * * The parameter `size` (positive float, default 1) sets the polygon size
  43114. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43115. * * 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`
  43116. * * 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
  43117. * * 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)`)
  43118. * * 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
  43119. * * 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
  43120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43121. * * 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
  43122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43123. * @param name defines the name of the mesh
  43124. * @param options defines the options used to create the mesh
  43125. * @param scene defines the hosting scene
  43126. * @returns the polyhedron mesh
  43127. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43128. */
  43129. static CreatePolyhedron(name: string, options: {
  43130. type?: number;
  43131. size?: number;
  43132. sizeX?: number;
  43133. sizeY?: number;
  43134. sizeZ?: number;
  43135. custom?: any;
  43136. faceUV?: Vector4[];
  43137. faceColors?: Color4[];
  43138. flat?: boolean;
  43139. updatable?: boolean;
  43140. sideOrientation?: number;
  43141. frontUVs?: Vector4;
  43142. backUVs?: Vector4;
  43143. }, scene?: Nullable<Scene>): Mesh;
  43144. }
  43145. }
  43146. declare module BABYLON {
  43147. /**
  43148. * Gizmo that enables scaling a mesh along 3 axis
  43149. */
  43150. export class ScaleGizmo extends Gizmo {
  43151. /**
  43152. * Internal gizmo used for interactions on the x axis
  43153. */
  43154. xGizmo: AxisScaleGizmo;
  43155. /**
  43156. * Internal gizmo used for interactions on the y axis
  43157. */
  43158. yGizmo: AxisScaleGizmo;
  43159. /**
  43160. * Internal gizmo used for interactions on the z axis
  43161. */
  43162. zGizmo: AxisScaleGizmo;
  43163. /**
  43164. * Internal gizmo used to scale all axis equally
  43165. */
  43166. uniformScaleGizmo: AxisScaleGizmo;
  43167. private _meshAttached;
  43168. private _updateGizmoRotationToMatchAttachedMesh;
  43169. private _snapDistance;
  43170. private _scaleRatio;
  43171. private _uniformScalingMesh;
  43172. private _octahedron;
  43173. /** Fires an event when any of it's sub gizmos are dragged */
  43174. onDragStartObservable: Observable<unknown>;
  43175. /** Fires an event when any of it's sub gizmos are released from dragging */
  43176. onDragEndObservable: Observable<unknown>;
  43177. attachedMesh: Nullable<AbstractMesh>;
  43178. /**
  43179. * Creates a ScaleGizmo
  43180. * @param gizmoLayer The utility layer the gizmo will be added to
  43181. */
  43182. constructor(gizmoLayer?: UtilityLayerRenderer);
  43183. updateGizmoRotationToMatchAttachedMesh: boolean;
  43184. /**
  43185. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43186. */
  43187. snapDistance: number;
  43188. /**
  43189. * Ratio for the scale of the gizmo (Default: 1)
  43190. */
  43191. scaleRatio: number;
  43192. /**
  43193. * Disposes of the gizmo
  43194. */
  43195. dispose(): void;
  43196. }
  43197. }
  43198. declare module BABYLON {
  43199. /**
  43200. * Single axis scale gizmo
  43201. */
  43202. export class AxisScaleGizmo extends Gizmo {
  43203. /**
  43204. * Drag behavior responsible for the gizmos dragging interactions
  43205. */
  43206. dragBehavior: PointerDragBehavior;
  43207. private _pointerObserver;
  43208. /**
  43209. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43210. */
  43211. snapDistance: number;
  43212. /**
  43213. * Event that fires each time the gizmo snaps to a new location.
  43214. * * snapDistance is the the change in distance
  43215. */
  43216. onSnapObservable: Observable<{
  43217. snapDistance: number;
  43218. }>;
  43219. /**
  43220. * If the scaling operation should be done on all axis (default: false)
  43221. */
  43222. uniformScaling: boolean;
  43223. private _isEnabled;
  43224. private _parent;
  43225. private _arrow;
  43226. private _coloredMaterial;
  43227. private _hoverMaterial;
  43228. /**
  43229. * Creates an AxisScaleGizmo
  43230. * @param gizmoLayer The utility layer the gizmo will be added to
  43231. * @param dragAxis The axis which the gizmo will be able to scale on
  43232. * @param color The color of the gizmo
  43233. */
  43234. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43235. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43236. /**
  43237. * If the gizmo is enabled
  43238. */
  43239. isEnabled: boolean;
  43240. /**
  43241. * Disposes of the gizmo
  43242. */
  43243. dispose(): void;
  43244. /**
  43245. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43246. * @param mesh The mesh to replace the default mesh of the gizmo
  43247. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43248. */
  43249. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43250. }
  43251. }
  43252. declare module BABYLON {
  43253. /**
  43254. * Bounding box gizmo
  43255. */
  43256. export class BoundingBoxGizmo extends Gizmo {
  43257. private _lineBoundingBox;
  43258. private _rotateSpheresParent;
  43259. private _scaleBoxesParent;
  43260. private _boundingDimensions;
  43261. private _renderObserver;
  43262. private _pointerObserver;
  43263. private _scaleDragSpeed;
  43264. private _tmpQuaternion;
  43265. private _tmpVector;
  43266. private _tmpRotationMatrix;
  43267. /**
  43268. * 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)
  43269. */
  43270. ignoreChildren: boolean;
  43271. /**
  43272. * 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)
  43273. */
  43274. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43275. /**
  43276. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43277. */
  43278. rotationSphereSize: number;
  43279. /**
  43280. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43281. */
  43282. scaleBoxSize: number;
  43283. /**
  43284. * 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)
  43285. */
  43286. fixedDragMeshScreenSize: boolean;
  43287. /**
  43288. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43289. */
  43290. fixedDragMeshScreenSizeDistanceFactor: number;
  43291. /**
  43292. * Fired when a rotation sphere or scale box is dragged
  43293. */
  43294. onDragStartObservable: Observable<{}>;
  43295. /**
  43296. * Fired when a scale box is dragged
  43297. */
  43298. onScaleBoxDragObservable: Observable<{}>;
  43299. /**
  43300. * Fired when a scale box drag is ended
  43301. */
  43302. onScaleBoxDragEndObservable: Observable<{}>;
  43303. /**
  43304. * Fired when a rotation sphere is dragged
  43305. */
  43306. onRotationSphereDragObservable: Observable<{}>;
  43307. /**
  43308. * Fired when a rotation sphere drag is ended
  43309. */
  43310. onRotationSphereDragEndObservable: Observable<{}>;
  43311. /**
  43312. * 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)
  43313. */
  43314. scalePivot: Nullable<Vector3>;
  43315. /**
  43316. * Mesh used as a pivot to rotate the attached mesh
  43317. */
  43318. private _anchorMesh;
  43319. private _existingMeshScale;
  43320. private _dragMesh;
  43321. private pointerDragBehavior;
  43322. private coloredMaterial;
  43323. private hoverColoredMaterial;
  43324. /**
  43325. * Sets the color of the bounding box gizmo
  43326. * @param color the color to set
  43327. */
  43328. setColor(color: Color3): void;
  43329. /**
  43330. * Creates an BoundingBoxGizmo
  43331. * @param gizmoLayer The utility layer the gizmo will be added to
  43332. * @param color The color of the gizmo
  43333. */
  43334. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43335. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43336. private _selectNode;
  43337. /**
  43338. * Updates the bounding box information for the Gizmo
  43339. */
  43340. updateBoundingBox(): void;
  43341. private _updateRotationSpheres;
  43342. private _updateScaleBoxes;
  43343. /**
  43344. * Enables rotation on the specified axis and disables rotation on the others
  43345. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43346. */
  43347. setEnabledRotationAxis(axis: string): void;
  43348. /**
  43349. * Enables/disables scaling
  43350. * @param enable if scaling should be enabled
  43351. */
  43352. setEnabledScaling(enable: boolean): void;
  43353. private _updateDummy;
  43354. /**
  43355. * Enables a pointer drag behavior on the bounding box of the gizmo
  43356. */
  43357. enableDragBehavior(): void;
  43358. /**
  43359. * Disposes of the gizmo
  43360. */
  43361. dispose(): void;
  43362. /**
  43363. * 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)
  43364. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43365. * @returns the bounding box mesh with the passed in mesh as a child
  43366. */
  43367. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43368. /**
  43369. * CustomMeshes are not supported by this gizmo
  43370. * @param mesh The mesh to replace the default mesh of the gizmo
  43371. */
  43372. setCustomMesh(mesh: Mesh): void;
  43373. }
  43374. }
  43375. declare module BABYLON {
  43376. /**
  43377. * Single plane rotation gizmo
  43378. */
  43379. export class PlaneRotationGizmo extends Gizmo {
  43380. /**
  43381. * Drag behavior responsible for the gizmos dragging interactions
  43382. */
  43383. dragBehavior: PointerDragBehavior;
  43384. private _pointerObserver;
  43385. /**
  43386. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43387. */
  43388. snapDistance: number;
  43389. /**
  43390. * Event that fires each time the gizmo snaps to a new location.
  43391. * * snapDistance is the the change in distance
  43392. */
  43393. onSnapObservable: Observable<{
  43394. snapDistance: number;
  43395. }>;
  43396. private _isEnabled;
  43397. private _parent;
  43398. /**
  43399. * Creates a PlaneRotationGizmo
  43400. * @param gizmoLayer The utility layer the gizmo will be added to
  43401. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43402. * @param color The color of the gizmo
  43403. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43404. */
  43405. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  43406. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43407. /**
  43408. * If the gizmo is enabled
  43409. */
  43410. isEnabled: boolean;
  43411. /**
  43412. * Disposes of the gizmo
  43413. */
  43414. dispose(): void;
  43415. }
  43416. }
  43417. declare module BABYLON {
  43418. /**
  43419. * Gizmo that enables rotating a mesh along 3 axis
  43420. */
  43421. export class RotationGizmo extends Gizmo {
  43422. /**
  43423. * Internal gizmo used for interactions on the x axis
  43424. */
  43425. xGizmo: PlaneRotationGizmo;
  43426. /**
  43427. * Internal gizmo used for interactions on the y axis
  43428. */
  43429. yGizmo: PlaneRotationGizmo;
  43430. /**
  43431. * Internal gizmo used for interactions on the z axis
  43432. */
  43433. zGizmo: PlaneRotationGizmo;
  43434. /** Fires an event when any of it's sub gizmos are dragged */
  43435. onDragStartObservable: Observable<unknown>;
  43436. /** Fires an event when any of it's sub gizmos are released from dragging */
  43437. onDragEndObservable: Observable<unknown>;
  43438. private _meshAttached;
  43439. attachedMesh: Nullable<AbstractMesh>;
  43440. /**
  43441. * Creates a RotationGizmo
  43442. * @param gizmoLayer The utility layer the gizmo will be added to
  43443. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43444. */
  43445. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43446. updateGizmoRotationToMatchAttachedMesh: boolean;
  43447. /**
  43448. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43449. */
  43450. snapDistance: number;
  43451. /**
  43452. * Ratio for the scale of the gizmo (Default: 1)
  43453. */
  43454. scaleRatio: number;
  43455. /**
  43456. * Disposes of the gizmo
  43457. */
  43458. dispose(): void;
  43459. /**
  43460. * CustomMeshes are not supported by this gizmo
  43461. * @param mesh The mesh to replace the default mesh of the gizmo
  43462. */
  43463. setCustomMesh(mesh: Mesh): void;
  43464. }
  43465. }
  43466. declare module BABYLON {
  43467. /**
  43468. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43469. */
  43470. export class GizmoManager implements IDisposable {
  43471. private scene;
  43472. /**
  43473. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43474. */
  43475. gizmos: {
  43476. positionGizmo: Nullable<PositionGizmo>;
  43477. rotationGizmo: Nullable<RotationGizmo>;
  43478. scaleGizmo: Nullable<ScaleGizmo>;
  43479. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43480. };
  43481. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43482. clearGizmoOnEmptyPointerEvent: boolean;
  43483. /** Fires an event when the manager is attached to a mesh */
  43484. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43485. private _gizmosEnabled;
  43486. private _pointerObserver;
  43487. private _attachedMesh;
  43488. private _boundingBoxColor;
  43489. private _defaultUtilityLayer;
  43490. private _defaultKeepDepthUtilityLayer;
  43491. /**
  43492. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43493. */
  43494. boundingBoxDragBehavior: SixDofDragBehavior;
  43495. /**
  43496. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43497. */
  43498. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43499. /**
  43500. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43501. */
  43502. usePointerToAttachGizmos: boolean;
  43503. /**
  43504. * Utility layer that the bounding box gizmo belongs to
  43505. */
  43506. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  43507. /**
  43508. * Utility layer that all gizmos besides bounding box belong to
  43509. */
  43510. readonly utilityLayer: UtilityLayerRenderer;
  43511. /**
  43512. * Instatiates a gizmo manager
  43513. * @param scene the scene to overlay the gizmos on top of
  43514. */
  43515. constructor(scene: Scene);
  43516. /**
  43517. * Attaches a set of gizmos to the specified mesh
  43518. * @param mesh The mesh the gizmo's should be attached to
  43519. */
  43520. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43521. /**
  43522. * If the position gizmo is enabled
  43523. */
  43524. positionGizmoEnabled: boolean;
  43525. /**
  43526. * If the rotation gizmo is enabled
  43527. */
  43528. rotationGizmoEnabled: boolean;
  43529. /**
  43530. * If the scale gizmo is enabled
  43531. */
  43532. scaleGizmoEnabled: boolean;
  43533. /**
  43534. * If the boundingBox gizmo is enabled
  43535. */
  43536. boundingBoxGizmoEnabled: boolean;
  43537. /**
  43538. * Disposes of the gizmo manager
  43539. */
  43540. dispose(): void;
  43541. }
  43542. }
  43543. declare module BABYLON {
  43544. /**
  43545. * A directional light is defined by a direction (what a surprise!).
  43546. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43547. * 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.
  43548. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43549. */
  43550. export class DirectionalLight extends ShadowLight {
  43551. private _shadowFrustumSize;
  43552. /**
  43553. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43554. */
  43555. /**
  43556. * Specifies a fix frustum size for the shadow generation.
  43557. */
  43558. shadowFrustumSize: number;
  43559. private _shadowOrthoScale;
  43560. /**
  43561. * Gets the shadow projection scale against the optimal computed one.
  43562. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43563. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43564. */
  43565. /**
  43566. * Sets the shadow projection scale against the optimal computed one.
  43567. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43568. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43569. */
  43570. shadowOrthoScale: number;
  43571. /**
  43572. * Automatically compute the projection matrix to best fit (including all the casters)
  43573. * on each frame.
  43574. */
  43575. autoUpdateExtends: boolean;
  43576. private _orthoLeft;
  43577. private _orthoRight;
  43578. private _orthoTop;
  43579. private _orthoBottom;
  43580. /**
  43581. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43582. * The directional light is emitted from everywhere in the given direction.
  43583. * It can cast shadows.
  43584. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43585. * @param name The friendly name of the light
  43586. * @param direction The direction of the light
  43587. * @param scene The scene the light belongs to
  43588. */
  43589. constructor(name: string, direction: Vector3, scene: Scene);
  43590. /**
  43591. * Returns the string "DirectionalLight".
  43592. * @return The class name
  43593. */
  43594. getClassName(): string;
  43595. /**
  43596. * Returns the integer 1.
  43597. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43598. */
  43599. getTypeID(): number;
  43600. /**
  43601. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43602. * Returns the DirectionalLight Shadow projection matrix.
  43603. */
  43604. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43605. /**
  43606. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43607. * Returns the DirectionalLight Shadow projection matrix.
  43608. */
  43609. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43610. /**
  43611. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43612. * Returns the DirectionalLight Shadow projection matrix.
  43613. */
  43614. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43615. protected _buildUniformLayout(): void;
  43616. /**
  43617. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43618. * @param effect The effect to update
  43619. * @param lightIndex The index of the light in the effect to update
  43620. * @returns The directional light
  43621. */
  43622. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43623. /**
  43624. * Gets the minZ used for shadow according to both the scene and the light.
  43625. *
  43626. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43627. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43628. * @param activeCamera The camera we are returning the min for
  43629. * @returns the depth min z
  43630. */
  43631. getDepthMinZ(activeCamera: Camera): number;
  43632. /**
  43633. * Gets the maxZ used for shadow according to both the scene and the light.
  43634. *
  43635. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43636. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43637. * @param activeCamera The camera we are returning the max for
  43638. * @returns the depth max z
  43639. */
  43640. getDepthMaxZ(activeCamera: Camera): number;
  43641. /**
  43642. * Prepares the list of defines specific to the light type.
  43643. * @param defines the list of defines
  43644. * @param lightIndex defines the index of the light for the effect
  43645. */
  43646. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43647. }
  43648. }
  43649. declare module BABYLON {
  43650. /**
  43651. * Class containing static functions to help procedurally build meshes
  43652. */
  43653. export class HemisphereBuilder {
  43654. /**
  43655. * Creates a hemisphere mesh
  43656. * @param name defines the name of the mesh
  43657. * @param options defines the options used to create the mesh
  43658. * @param scene defines the hosting scene
  43659. * @returns the hemisphere mesh
  43660. */
  43661. static CreateHemisphere(name: string, options: {
  43662. segments?: number;
  43663. diameter?: number;
  43664. sideOrientation?: number;
  43665. }, scene: any): Mesh;
  43666. }
  43667. }
  43668. declare module BABYLON {
  43669. /**
  43670. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43671. * These values define a cone of light starting from the position, emitting toward the direction.
  43672. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43673. * and the exponent defines the speed of the decay of the light with distance (reach).
  43674. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43675. */
  43676. export class SpotLight extends ShadowLight {
  43677. private _angle;
  43678. private _innerAngle;
  43679. private _cosHalfAngle;
  43680. private _lightAngleScale;
  43681. private _lightAngleOffset;
  43682. /**
  43683. * Gets the cone angle of the spot light in Radians.
  43684. */
  43685. /**
  43686. * Sets the cone angle of the spot light in Radians.
  43687. */
  43688. angle: number;
  43689. /**
  43690. * Only used in gltf falloff mode, this defines the angle where
  43691. * the directional falloff will start before cutting at angle which could be seen
  43692. * as outer angle.
  43693. */
  43694. /**
  43695. * Only used in gltf falloff mode, this defines the angle where
  43696. * the directional falloff will start before cutting at angle which could be seen
  43697. * as outer angle.
  43698. */
  43699. innerAngle: number;
  43700. private _shadowAngleScale;
  43701. /**
  43702. * Allows scaling the angle of the light for shadow generation only.
  43703. */
  43704. /**
  43705. * Allows scaling the angle of the light for shadow generation only.
  43706. */
  43707. shadowAngleScale: number;
  43708. /**
  43709. * The light decay speed with the distance from the emission spot.
  43710. */
  43711. exponent: number;
  43712. private _projectionTextureMatrix;
  43713. /**
  43714. * Allows reading the projecton texture
  43715. */
  43716. readonly projectionTextureMatrix: Matrix;
  43717. protected _projectionTextureLightNear: number;
  43718. /**
  43719. * Gets the near clip of the Spotlight for texture projection.
  43720. */
  43721. /**
  43722. * Sets the near clip of the Spotlight for texture projection.
  43723. */
  43724. projectionTextureLightNear: number;
  43725. protected _projectionTextureLightFar: number;
  43726. /**
  43727. * Gets the far clip of the Spotlight for texture projection.
  43728. */
  43729. /**
  43730. * Sets the far clip of the Spotlight for texture projection.
  43731. */
  43732. projectionTextureLightFar: number;
  43733. protected _projectionTextureUpDirection: Vector3;
  43734. /**
  43735. * Gets the Up vector of the Spotlight for texture projection.
  43736. */
  43737. /**
  43738. * Sets the Up vector of the Spotlight for texture projection.
  43739. */
  43740. projectionTextureUpDirection: Vector3;
  43741. private _projectionTexture;
  43742. /**
  43743. * Gets the projection texture of the light.
  43744. */
  43745. /**
  43746. * Sets the projection texture of the light.
  43747. */
  43748. projectionTexture: Nullable<BaseTexture>;
  43749. private _projectionTextureViewLightDirty;
  43750. private _projectionTextureProjectionLightDirty;
  43751. private _projectionTextureDirty;
  43752. private _projectionTextureViewTargetVector;
  43753. private _projectionTextureViewLightMatrix;
  43754. private _projectionTextureProjectionLightMatrix;
  43755. private _projectionTextureScalingMatrix;
  43756. /**
  43757. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43758. * It can cast shadows.
  43759. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43760. * @param name The light friendly name
  43761. * @param position The position of the spot light in the scene
  43762. * @param direction The direction of the light in the scene
  43763. * @param angle The cone angle of the light in Radians
  43764. * @param exponent The light decay speed with the distance from the emission spot
  43765. * @param scene The scene the lights belongs to
  43766. */
  43767. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43768. /**
  43769. * Returns the string "SpotLight".
  43770. * @returns the class name
  43771. */
  43772. getClassName(): string;
  43773. /**
  43774. * Returns the integer 2.
  43775. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43776. */
  43777. getTypeID(): number;
  43778. /**
  43779. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43780. */
  43781. protected _setDirection(value: Vector3): void;
  43782. /**
  43783. * Overrides the position setter to recompute the projection texture view light Matrix.
  43784. */
  43785. protected _setPosition(value: Vector3): void;
  43786. /**
  43787. * 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.
  43788. * Returns the SpotLight.
  43789. */
  43790. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43791. protected _computeProjectionTextureViewLightMatrix(): void;
  43792. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43793. /**
  43794. * Main function for light texture projection matrix computing.
  43795. */
  43796. protected _computeProjectionTextureMatrix(): void;
  43797. protected _buildUniformLayout(): void;
  43798. private _computeAngleValues;
  43799. /**
  43800. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43801. * @param effect The effect to update
  43802. * @param lightIndex The index of the light in the effect to update
  43803. * @returns The spot light
  43804. */
  43805. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43806. /**
  43807. * Disposes the light and the associated resources.
  43808. */
  43809. dispose(): void;
  43810. /**
  43811. * Prepares the list of defines specific to the light type.
  43812. * @param defines the list of defines
  43813. * @param lightIndex defines the index of the light for the effect
  43814. */
  43815. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43816. }
  43817. }
  43818. declare module BABYLON {
  43819. /**
  43820. * Gizmo that enables viewing a light
  43821. */
  43822. export class LightGizmo extends Gizmo {
  43823. private _lightMesh;
  43824. private _material;
  43825. private cachedPosition;
  43826. private cachedForward;
  43827. /**
  43828. * Creates a LightGizmo
  43829. * @param gizmoLayer The utility layer the gizmo will be added to
  43830. */
  43831. constructor(gizmoLayer?: UtilityLayerRenderer);
  43832. private _light;
  43833. /**
  43834. * The light that the gizmo is attached to
  43835. */
  43836. light: Nullable<Light>;
  43837. /**
  43838. * @hidden
  43839. * Updates the gizmo to match the attached mesh's position/rotation
  43840. */
  43841. protected _update(): void;
  43842. private static _Scale;
  43843. /**
  43844. * Creates the lines for a light mesh
  43845. */
  43846. private static _createLightLines;
  43847. /**
  43848. * Disposes of the light gizmo
  43849. */
  43850. dispose(): void;
  43851. private static _CreateHemisphericLightMesh;
  43852. private static _CreatePointLightMesh;
  43853. private static _CreateSpotLightMesh;
  43854. private static _CreateDirectionalLightMesh;
  43855. }
  43856. }
  43857. declare module BABYLON {
  43858. /** @hidden */
  43859. export var backgroundFragmentDeclaration: {
  43860. name: string;
  43861. shader: string;
  43862. };
  43863. }
  43864. declare module BABYLON {
  43865. /** @hidden */
  43866. export var backgroundUboDeclaration: {
  43867. name: string;
  43868. shader: string;
  43869. };
  43870. }
  43871. declare module BABYLON {
  43872. /** @hidden */
  43873. export var backgroundPixelShader: {
  43874. name: string;
  43875. shader: string;
  43876. };
  43877. }
  43878. declare module BABYLON {
  43879. /** @hidden */
  43880. export var backgroundVertexDeclaration: {
  43881. name: string;
  43882. shader: string;
  43883. };
  43884. }
  43885. declare module BABYLON {
  43886. /** @hidden */
  43887. export var backgroundVertexShader: {
  43888. name: string;
  43889. shader: string;
  43890. };
  43891. }
  43892. declare module BABYLON {
  43893. /**
  43894. * Background material used to create an efficient environement around your scene.
  43895. */
  43896. export class BackgroundMaterial extends PushMaterial {
  43897. /**
  43898. * Standard reflectance value at parallel view angle.
  43899. */
  43900. static StandardReflectance0: number;
  43901. /**
  43902. * Standard reflectance value at grazing angle.
  43903. */
  43904. static StandardReflectance90: number;
  43905. protected _primaryColor: Color3;
  43906. /**
  43907. * Key light Color (multiply against the environement texture)
  43908. */
  43909. primaryColor: Color3;
  43910. protected __perceptualColor: Nullable<Color3>;
  43911. /**
  43912. * Experimental Internal Use Only.
  43913. *
  43914. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43915. * This acts as a helper to set the primary color to a more "human friendly" value.
  43916. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43917. * output color as close as possible from the chosen value.
  43918. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43919. * part of lighting setup.)
  43920. */
  43921. _perceptualColor: Nullable<Color3>;
  43922. protected _primaryColorShadowLevel: float;
  43923. /**
  43924. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43925. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43926. */
  43927. primaryColorShadowLevel: float;
  43928. protected _primaryColorHighlightLevel: float;
  43929. /**
  43930. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43931. * The primary color is used at the level chosen to define what the white area would look.
  43932. */
  43933. primaryColorHighlightLevel: float;
  43934. protected _reflectionTexture: Nullable<BaseTexture>;
  43935. /**
  43936. * Reflection Texture used in the material.
  43937. * Should be author in a specific way for the best result (refer to the documentation).
  43938. */
  43939. reflectionTexture: Nullable<BaseTexture>;
  43940. protected _reflectionBlur: float;
  43941. /**
  43942. * Reflection Texture level of blur.
  43943. *
  43944. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43945. * texture twice.
  43946. */
  43947. reflectionBlur: float;
  43948. protected _diffuseTexture: Nullable<BaseTexture>;
  43949. /**
  43950. * Diffuse Texture used in the material.
  43951. * Should be author in a specific way for the best result (refer to the documentation).
  43952. */
  43953. diffuseTexture: Nullable<BaseTexture>;
  43954. protected _shadowLights: Nullable<IShadowLight[]>;
  43955. /**
  43956. * Specify the list of lights casting shadow on the material.
  43957. * All scene shadow lights will be included if null.
  43958. */
  43959. shadowLights: Nullable<IShadowLight[]>;
  43960. protected _shadowLevel: float;
  43961. /**
  43962. * Helps adjusting the shadow to a softer level if required.
  43963. * 0 means black shadows and 1 means no shadows.
  43964. */
  43965. shadowLevel: float;
  43966. protected _sceneCenter: Vector3;
  43967. /**
  43968. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43969. * It is usually zero but might be interesting to modify according to your setup.
  43970. */
  43971. sceneCenter: Vector3;
  43972. protected _opacityFresnel: boolean;
  43973. /**
  43974. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43975. * This helps ensuring a nice transition when the camera goes under the ground.
  43976. */
  43977. opacityFresnel: boolean;
  43978. protected _reflectionFresnel: boolean;
  43979. /**
  43980. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43981. * This helps adding a mirror texture on the ground.
  43982. */
  43983. reflectionFresnel: boolean;
  43984. protected _reflectionFalloffDistance: number;
  43985. /**
  43986. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43987. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43988. */
  43989. reflectionFalloffDistance: number;
  43990. protected _reflectionAmount: number;
  43991. /**
  43992. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43993. */
  43994. reflectionAmount: number;
  43995. protected _reflectionReflectance0: number;
  43996. /**
  43997. * This specifies the weight of the reflection at grazing angle.
  43998. */
  43999. reflectionReflectance0: number;
  44000. protected _reflectionReflectance90: number;
  44001. /**
  44002. * This specifies the weight of the reflection at a perpendicular point of view.
  44003. */
  44004. reflectionReflectance90: number;
  44005. /**
  44006. * Sets the reflection reflectance fresnel values according to the default standard
  44007. * empirically know to work well :-)
  44008. */
  44009. reflectionStandardFresnelWeight: number;
  44010. protected _useRGBColor: boolean;
  44011. /**
  44012. * Helps to directly use the maps channels instead of their level.
  44013. */
  44014. useRGBColor: boolean;
  44015. protected _enableNoise: boolean;
  44016. /**
  44017. * This helps reducing the banding effect that could occur on the background.
  44018. */
  44019. enableNoise: boolean;
  44020. /**
  44021. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44022. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44023. * Recommended to be keep at 1.0 except for special cases.
  44024. */
  44025. fovMultiplier: number;
  44026. private _fovMultiplier;
  44027. /**
  44028. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44029. */
  44030. useEquirectangularFOV: boolean;
  44031. private _maxSimultaneousLights;
  44032. /**
  44033. * Number of Simultaneous lights allowed on the material.
  44034. */
  44035. maxSimultaneousLights: int;
  44036. /**
  44037. * Default configuration related to image processing available in the Background Material.
  44038. */
  44039. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44040. /**
  44041. * Keep track of the image processing observer to allow dispose and replace.
  44042. */
  44043. private _imageProcessingObserver;
  44044. /**
  44045. * Attaches a new image processing configuration to the PBR Material.
  44046. * @param configuration (if null the scene configuration will be use)
  44047. */
  44048. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44049. /**
  44050. * Gets the image processing configuration used either in this material.
  44051. */
  44052. /**
  44053. * Sets the Default image processing configuration used either in the this material.
  44054. *
  44055. * If sets to null, the scene one is in use.
  44056. */
  44057. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44058. /**
  44059. * Gets wether the color curves effect is enabled.
  44060. */
  44061. /**
  44062. * Sets wether the color curves effect is enabled.
  44063. */
  44064. cameraColorCurvesEnabled: boolean;
  44065. /**
  44066. * Gets wether the color grading effect is enabled.
  44067. */
  44068. /**
  44069. * Gets wether the color grading effect is enabled.
  44070. */
  44071. cameraColorGradingEnabled: boolean;
  44072. /**
  44073. * Gets wether tonemapping is enabled or not.
  44074. */
  44075. /**
  44076. * Sets wether tonemapping is enabled or not
  44077. */
  44078. cameraToneMappingEnabled: boolean;
  44079. /**
  44080. * The camera exposure used on this material.
  44081. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44082. * This corresponds to a photographic exposure.
  44083. */
  44084. /**
  44085. * The camera exposure used on this material.
  44086. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44087. * This corresponds to a photographic exposure.
  44088. */
  44089. cameraExposure: float;
  44090. /**
  44091. * Gets The camera contrast used on this material.
  44092. */
  44093. /**
  44094. * Sets The camera contrast used on this material.
  44095. */
  44096. cameraContrast: float;
  44097. /**
  44098. * Gets the Color Grading 2D Lookup Texture.
  44099. */
  44100. /**
  44101. * Sets the Color Grading 2D Lookup Texture.
  44102. */
  44103. cameraColorGradingTexture: Nullable<BaseTexture>;
  44104. /**
  44105. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44106. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44107. * 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;
  44108. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44109. */
  44110. /**
  44111. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44112. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44113. * 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;
  44114. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44115. */
  44116. cameraColorCurves: Nullable<ColorCurves>;
  44117. /**
  44118. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44119. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44120. */
  44121. switchToBGR: boolean;
  44122. private _renderTargets;
  44123. private _reflectionControls;
  44124. private _white;
  44125. private _primaryShadowColor;
  44126. private _primaryHighlightColor;
  44127. /**
  44128. * Instantiates a Background Material in the given scene
  44129. * @param name The friendly name of the material
  44130. * @param scene The scene to add the material to
  44131. */
  44132. constructor(name: string, scene: Scene);
  44133. /**
  44134. * Gets a boolean indicating that current material needs to register RTT
  44135. */
  44136. readonly hasRenderTargetTextures: boolean;
  44137. /**
  44138. * The entire material has been created in order to prevent overdraw.
  44139. * @returns false
  44140. */
  44141. needAlphaTesting(): boolean;
  44142. /**
  44143. * The entire material has been created in order to prevent overdraw.
  44144. * @returns true if blending is enable
  44145. */
  44146. needAlphaBlending(): boolean;
  44147. /**
  44148. * Checks wether the material is ready to be rendered for a given mesh.
  44149. * @param mesh The mesh to render
  44150. * @param subMesh The submesh to check against
  44151. * @param useInstances Specify wether or not the material is used with instances
  44152. * @returns true if all the dependencies are ready (Textures, Effects...)
  44153. */
  44154. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44155. /**
  44156. * Compute the primary color according to the chosen perceptual color.
  44157. */
  44158. private _computePrimaryColorFromPerceptualColor;
  44159. /**
  44160. * Compute the highlights and shadow colors according to their chosen levels.
  44161. */
  44162. private _computePrimaryColors;
  44163. /**
  44164. * Build the uniform buffer used in the material.
  44165. */
  44166. buildUniformLayout(): void;
  44167. /**
  44168. * Unbind the material.
  44169. */
  44170. unbind(): void;
  44171. /**
  44172. * Bind only the world matrix to the material.
  44173. * @param world The world matrix to bind.
  44174. */
  44175. bindOnlyWorldMatrix(world: Matrix): void;
  44176. /**
  44177. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44178. * @param world The world matrix to bind.
  44179. * @param subMesh The submesh to bind for.
  44180. */
  44181. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44182. /**
  44183. * Dispose the material.
  44184. * @param forceDisposeEffect Force disposal of the associated effect.
  44185. * @param forceDisposeTextures Force disposal of the associated textures.
  44186. */
  44187. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44188. /**
  44189. * Clones the material.
  44190. * @param name The cloned name.
  44191. * @returns The cloned material.
  44192. */
  44193. clone(name: string): BackgroundMaterial;
  44194. /**
  44195. * Serializes the current material to its JSON representation.
  44196. * @returns The JSON representation.
  44197. */
  44198. serialize(): any;
  44199. /**
  44200. * Gets the class name of the material
  44201. * @returns "BackgroundMaterial"
  44202. */
  44203. getClassName(): string;
  44204. /**
  44205. * Parse a JSON input to create back a background material.
  44206. * @param source The JSON data to parse
  44207. * @param scene The scene to create the parsed material in
  44208. * @param rootUrl The root url of the assets the material depends upon
  44209. * @returns the instantiated BackgroundMaterial.
  44210. */
  44211. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44212. }
  44213. }
  44214. declare module BABYLON {
  44215. /**
  44216. * Represents the different options available during the creation of
  44217. * a Environment helper.
  44218. *
  44219. * This can control the default ground, skybox and image processing setup of your scene.
  44220. */
  44221. export interface IEnvironmentHelperOptions {
  44222. /**
  44223. * Specifies wether or not to create a ground.
  44224. * True by default.
  44225. */
  44226. createGround: boolean;
  44227. /**
  44228. * Specifies the ground size.
  44229. * 15 by default.
  44230. */
  44231. groundSize: number;
  44232. /**
  44233. * The texture used on the ground for the main color.
  44234. * Comes from the BabylonJS CDN by default.
  44235. *
  44236. * Remarks: Can be either a texture or a url.
  44237. */
  44238. groundTexture: string | BaseTexture;
  44239. /**
  44240. * The color mixed in the ground texture by default.
  44241. * BabylonJS clearColor by default.
  44242. */
  44243. groundColor: Color3;
  44244. /**
  44245. * Specifies the ground opacity.
  44246. * 1 by default.
  44247. */
  44248. groundOpacity: number;
  44249. /**
  44250. * Enables the ground to receive shadows.
  44251. * True by default.
  44252. */
  44253. enableGroundShadow: boolean;
  44254. /**
  44255. * Helps preventing the shadow to be fully black on the ground.
  44256. * 0.5 by default.
  44257. */
  44258. groundShadowLevel: number;
  44259. /**
  44260. * Creates a mirror texture attach to the ground.
  44261. * false by default.
  44262. */
  44263. enableGroundMirror: boolean;
  44264. /**
  44265. * Specifies the ground mirror size ratio.
  44266. * 0.3 by default as the default kernel is 64.
  44267. */
  44268. groundMirrorSizeRatio: number;
  44269. /**
  44270. * Specifies the ground mirror blur kernel size.
  44271. * 64 by default.
  44272. */
  44273. groundMirrorBlurKernel: number;
  44274. /**
  44275. * Specifies the ground mirror visibility amount.
  44276. * 1 by default
  44277. */
  44278. groundMirrorAmount: number;
  44279. /**
  44280. * Specifies the ground mirror reflectance weight.
  44281. * This uses the standard weight of the background material to setup the fresnel effect
  44282. * of the mirror.
  44283. * 1 by default.
  44284. */
  44285. groundMirrorFresnelWeight: number;
  44286. /**
  44287. * Specifies the ground mirror Falloff distance.
  44288. * This can helps reducing the size of the reflection.
  44289. * 0 by Default.
  44290. */
  44291. groundMirrorFallOffDistance: number;
  44292. /**
  44293. * Specifies the ground mirror texture type.
  44294. * Unsigned Int by Default.
  44295. */
  44296. groundMirrorTextureType: number;
  44297. /**
  44298. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44299. * the shown objects.
  44300. */
  44301. groundYBias: number;
  44302. /**
  44303. * Specifies wether or not to create a skybox.
  44304. * True by default.
  44305. */
  44306. createSkybox: boolean;
  44307. /**
  44308. * Specifies the skybox size.
  44309. * 20 by default.
  44310. */
  44311. skyboxSize: number;
  44312. /**
  44313. * The texture used on the skybox for the main color.
  44314. * Comes from the BabylonJS CDN by default.
  44315. *
  44316. * Remarks: Can be either a texture or a url.
  44317. */
  44318. skyboxTexture: string | BaseTexture;
  44319. /**
  44320. * The color mixed in the skybox texture by default.
  44321. * BabylonJS clearColor by default.
  44322. */
  44323. skyboxColor: Color3;
  44324. /**
  44325. * The background rotation around the Y axis of the scene.
  44326. * This helps aligning the key lights of your scene with the background.
  44327. * 0 by default.
  44328. */
  44329. backgroundYRotation: number;
  44330. /**
  44331. * Compute automatically the size of the elements to best fit with the scene.
  44332. */
  44333. sizeAuto: boolean;
  44334. /**
  44335. * Default position of the rootMesh if autoSize is not true.
  44336. */
  44337. rootPosition: Vector3;
  44338. /**
  44339. * Sets up the image processing in the scene.
  44340. * true by default.
  44341. */
  44342. setupImageProcessing: boolean;
  44343. /**
  44344. * The texture used as your environment texture in the scene.
  44345. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44346. *
  44347. * Remarks: Can be either a texture or a url.
  44348. */
  44349. environmentTexture: string | BaseTexture;
  44350. /**
  44351. * The value of the exposure to apply to the scene.
  44352. * 0.6 by default if setupImageProcessing is true.
  44353. */
  44354. cameraExposure: number;
  44355. /**
  44356. * The value of the contrast to apply to the scene.
  44357. * 1.6 by default if setupImageProcessing is true.
  44358. */
  44359. cameraContrast: number;
  44360. /**
  44361. * Specifies wether or not tonemapping should be enabled in the scene.
  44362. * true by default if setupImageProcessing is true.
  44363. */
  44364. toneMappingEnabled: boolean;
  44365. }
  44366. /**
  44367. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44368. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44369. * It also helps with the default setup of your imageProcessing configuration.
  44370. */
  44371. export class EnvironmentHelper {
  44372. /**
  44373. * Default ground texture URL.
  44374. */
  44375. private static _groundTextureCDNUrl;
  44376. /**
  44377. * Default skybox texture URL.
  44378. */
  44379. private static _skyboxTextureCDNUrl;
  44380. /**
  44381. * Default environment texture URL.
  44382. */
  44383. private static _environmentTextureCDNUrl;
  44384. /**
  44385. * Creates the default options for the helper.
  44386. */
  44387. private static _getDefaultOptions;
  44388. private _rootMesh;
  44389. /**
  44390. * Gets the root mesh created by the helper.
  44391. */
  44392. readonly rootMesh: Mesh;
  44393. private _skybox;
  44394. /**
  44395. * Gets the skybox created by the helper.
  44396. */
  44397. readonly skybox: Nullable<Mesh>;
  44398. private _skyboxTexture;
  44399. /**
  44400. * Gets the skybox texture created by the helper.
  44401. */
  44402. readonly skyboxTexture: Nullable<BaseTexture>;
  44403. private _skyboxMaterial;
  44404. /**
  44405. * Gets the skybox material created by the helper.
  44406. */
  44407. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44408. private _ground;
  44409. /**
  44410. * Gets the ground mesh created by the helper.
  44411. */
  44412. readonly ground: Nullable<Mesh>;
  44413. private _groundTexture;
  44414. /**
  44415. * Gets the ground texture created by the helper.
  44416. */
  44417. readonly groundTexture: Nullable<BaseTexture>;
  44418. private _groundMirror;
  44419. /**
  44420. * Gets the ground mirror created by the helper.
  44421. */
  44422. readonly groundMirror: Nullable<MirrorTexture>;
  44423. /**
  44424. * Gets the ground mirror render list to helps pushing the meshes
  44425. * you wish in the ground reflection.
  44426. */
  44427. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44428. private _groundMaterial;
  44429. /**
  44430. * Gets the ground material created by the helper.
  44431. */
  44432. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44433. /**
  44434. * Stores the creation options.
  44435. */
  44436. private readonly _scene;
  44437. private _options;
  44438. /**
  44439. * This observable will be notified with any error during the creation of the environment,
  44440. * mainly texture creation errors.
  44441. */
  44442. onErrorObservable: Observable<{
  44443. message?: string;
  44444. exception?: any;
  44445. }>;
  44446. /**
  44447. * constructor
  44448. * @param options Defines the options we want to customize the helper
  44449. * @param scene The scene to add the material to
  44450. */
  44451. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44452. /**
  44453. * Updates the background according to the new options
  44454. * @param options
  44455. */
  44456. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44457. /**
  44458. * Sets the primary color of all the available elements.
  44459. * @param color the main color to affect to the ground and the background
  44460. */
  44461. setMainColor(color: Color3): void;
  44462. /**
  44463. * Setup the image processing according to the specified options.
  44464. */
  44465. private _setupImageProcessing;
  44466. /**
  44467. * Setup the environment texture according to the specified options.
  44468. */
  44469. private _setupEnvironmentTexture;
  44470. /**
  44471. * Setup the background according to the specified options.
  44472. */
  44473. private _setupBackground;
  44474. /**
  44475. * Get the scene sizes according to the setup.
  44476. */
  44477. private _getSceneSize;
  44478. /**
  44479. * Setup the ground according to the specified options.
  44480. */
  44481. private _setupGround;
  44482. /**
  44483. * Setup the ground material according to the specified options.
  44484. */
  44485. private _setupGroundMaterial;
  44486. /**
  44487. * Setup the ground diffuse texture according to the specified options.
  44488. */
  44489. private _setupGroundDiffuseTexture;
  44490. /**
  44491. * Setup the ground mirror texture according to the specified options.
  44492. */
  44493. private _setupGroundMirrorTexture;
  44494. /**
  44495. * Setup the ground to receive the mirror texture.
  44496. */
  44497. private _setupMirrorInGroundMaterial;
  44498. /**
  44499. * Setup the skybox according to the specified options.
  44500. */
  44501. private _setupSkybox;
  44502. /**
  44503. * Setup the skybox material according to the specified options.
  44504. */
  44505. private _setupSkyboxMaterial;
  44506. /**
  44507. * Setup the skybox reflection texture according to the specified options.
  44508. */
  44509. private _setupSkyboxReflectionTexture;
  44510. private _errorHandler;
  44511. /**
  44512. * Dispose all the elements created by the Helper.
  44513. */
  44514. dispose(): void;
  44515. }
  44516. }
  44517. declare module BABYLON {
  44518. /**
  44519. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44520. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44521. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44522. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44523. */
  44524. export class PhotoDome extends TransformNode {
  44525. /**
  44526. * Define the image as a Monoscopic panoramic 360 image.
  44527. */
  44528. static readonly MODE_MONOSCOPIC: number;
  44529. /**
  44530. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44531. */
  44532. static readonly MODE_TOPBOTTOM: number;
  44533. /**
  44534. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44535. */
  44536. static readonly MODE_SIDEBYSIDE: number;
  44537. private _useDirectMapping;
  44538. /**
  44539. * The texture being displayed on the sphere
  44540. */
  44541. protected _photoTexture: Texture;
  44542. /**
  44543. * Gets or sets the texture being displayed on the sphere
  44544. */
  44545. photoTexture: Texture;
  44546. /**
  44547. * Observable raised when an error occured while loading the 360 image
  44548. */
  44549. onLoadErrorObservable: Observable<string>;
  44550. /**
  44551. * The skybox material
  44552. */
  44553. protected _material: BackgroundMaterial;
  44554. /**
  44555. * The surface used for the skybox
  44556. */
  44557. protected _mesh: Mesh;
  44558. /**
  44559. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44560. * Also see the options.resolution property.
  44561. */
  44562. fovMultiplier: number;
  44563. private _imageMode;
  44564. /**
  44565. * Gets or set the current video mode for the video. It can be:
  44566. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  44567. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44568. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44569. */
  44570. imageMode: number;
  44571. /**
  44572. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44573. * @param name Element's name, child elements will append suffixes for their own names.
  44574. * @param urlsOfPhoto defines the url of the photo to display
  44575. * @param options defines an object containing optional or exposed sub element properties
  44576. * @param onError defines a callback called when an error occured while loading the texture
  44577. */
  44578. constructor(name: string, urlOfPhoto: string, options: {
  44579. resolution?: number;
  44580. size?: number;
  44581. useDirectMapping?: boolean;
  44582. faceForward?: boolean;
  44583. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44584. private _onBeforeCameraRenderObserver;
  44585. private _changeImageMode;
  44586. /**
  44587. * Releases resources associated with this node.
  44588. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44589. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44590. */
  44591. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44592. }
  44593. }
  44594. declare module BABYLON {
  44595. /** @hidden */
  44596. export var rgbdDecodePixelShader: {
  44597. name: string;
  44598. shader: string;
  44599. };
  44600. }
  44601. declare module BABYLON {
  44602. /**
  44603. * Class used to host texture specific utilities
  44604. */
  44605. export class BRDFTextureTools {
  44606. /**
  44607. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44608. * @param texture the texture to expand.
  44609. */
  44610. private static _ExpandDefaultBRDFTexture;
  44611. /**
  44612. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44613. * @param scene defines the hosting scene
  44614. * @returns the environment BRDF texture
  44615. */
  44616. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44617. private static _environmentBRDFBase64Texture;
  44618. }
  44619. }
  44620. declare module BABYLON {
  44621. /**
  44622. * @hidden
  44623. */
  44624. export interface IMaterialClearCoatDefines {
  44625. CLEARCOAT: boolean;
  44626. CLEARCOAT_DEFAULTIOR: boolean;
  44627. CLEARCOAT_TEXTURE: boolean;
  44628. CLEARCOAT_TEXTUREDIRECTUV: number;
  44629. CLEARCOAT_BUMP: boolean;
  44630. CLEARCOAT_BUMPDIRECTUV: number;
  44631. CLEARCOAT_TINT: boolean;
  44632. CLEARCOAT_TINT_TEXTURE: boolean;
  44633. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44634. /** @hidden */
  44635. _areTexturesDirty: boolean;
  44636. }
  44637. /**
  44638. * Define the code related to the clear coat parameters of the pbr material.
  44639. */
  44640. export class PBRClearCoatConfiguration {
  44641. /**
  44642. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44643. * The default fits with a polyurethane material.
  44644. */
  44645. private static readonly _DefaultIndexOfRefraction;
  44646. private _isEnabled;
  44647. /**
  44648. * Defines if the clear coat is enabled in the material.
  44649. */
  44650. isEnabled: boolean;
  44651. /**
  44652. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44653. */
  44654. intensity: number;
  44655. /**
  44656. * Defines the clear coat layer roughness.
  44657. */
  44658. roughness: number;
  44659. private _indexOfRefraction;
  44660. /**
  44661. * Defines the index of refraction of the clear coat.
  44662. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44663. * The default fits with a polyurethane material.
  44664. * Changing the default value is more performance intensive.
  44665. */
  44666. indexOfRefraction: number;
  44667. private _texture;
  44668. /**
  44669. * Stores the clear coat values in a texture.
  44670. */
  44671. texture: Nullable<BaseTexture>;
  44672. private _bumpTexture;
  44673. /**
  44674. * Define the clear coat specific bump texture.
  44675. */
  44676. bumpTexture: Nullable<BaseTexture>;
  44677. private _isTintEnabled;
  44678. /**
  44679. * Defines if the clear coat tint is enabled in the material.
  44680. */
  44681. isTintEnabled: boolean;
  44682. /**
  44683. * Defines the clear coat tint of the material.
  44684. * This is only use if tint is enabled
  44685. */
  44686. tintColor: Color3;
  44687. /**
  44688. * Defines the distance at which the tint color should be found in the
  44689. * clear coat media.
  44690. * This is only use if tint is enabled
  44691. */
  44692. tintColorAtDistance: number;
  44693. /**
  44694. * Defines the clear coat layer thickness.
  44695. * This is only use if tint is enabled
  44696. */
  44697. tintThickness: number;
  44698. private _tintTexture;
  44699. /**
  44700. * Stores the clear tint values in a texture.
  44701. * rgb is tint
  44702. * a is a thickness factor
  44703. */
  44704. tintTexture: Nullable<BaseTexture>;
  44705. /** @hidden */
  44706. private _internalMarkAllSubMeshesAsTexturesDirty;
  44707. /** @hidden */
  44708. _markAllSubMeshesAsTexturesDirty(): void;
  44709. /**
  44710. * Instantiate a new istance of clear coat configuration.
  44711. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44712. */
  44713. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44714. /**
  44715. * Gets wehter the submesh is ready to be used or not.
  44716. * @param defines the list of "defines" to update.
  44717. * @param scene defines the scene the material belongs to.
  44718. * @param engine defines the engine the material belongs to.
  44719. * @param disableBumpMap defines wether the material disables bump or not.
  44720. * @returns - boolean indicating that the submesh is ready or not.
  44721. */
  44722. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44723. /**
  44724. * Checks to see if a texture is used in the material.
  44725. * @param defines the list of "defines" to update.
  44726. * @param scene defines the scene to the material belongs to.
  44727. */
  44728. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44729. /**
  44730. * Binds the material data.
  44731. * @param uniformBuffer defines the Uniform buffer to fill in.
  44732. * @param scene defines the scene the material belongs to.
  44733. * @param engine defines the engine the material belongs to.
  44734. * @param disableBumpMap defines wether the material disables bump or not.
  44735. * @param isFrozen defines wether the material is frozen or not.
  44736. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44737. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44738. */
  44739. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44740. /**
  44741. * Checks to see if a texture is used in the material.
  44742. * @param texture - Base texture to use.
  44743. * @returns - Boolean specifying if a texture is used in the material.
  44744. */
  44745. hasTexture(texture: BaseTexture): boolean;
  44746. /**
  44747. * Returns an array of the actively used textures.
  44748. * @param activeTextures Array of BaseTextures
  44749. */
  44750. getActiveTextures(activeTextures: BaseTexture[]): void;
  44751. /**
  44752. * Returns the animatable textures.
  44753. * @param animatables Array of animatable textures.
  44754. */
  44755. getAnimatables(animatables: IAnimatable[]): void;
  44756. /**
  44757. * Disposes the resources of the material.
  44758. * @param forceDisposeTextures - Forces the disposal of all textures.
  44759. */
  44760. dispose(forceDisposeTextures?: boolean): void;
  44761. /**
  44762. * Get the current class name of the texture useful for serialization or dynamic coding.
  44763. * @returns "PBRClearCoatConfiguration"
  44764. */
  44765. getClassName(): string;
  44766. /**
  44767. * Add fallbacks to the effect fallbacks list.
  44768. * @param defines defines the Base texture to use.
  44769. * @param fallbacks defines the current fallback list.
  44770. * @param currentRank defines the current fallback rank.
  44771. * @returns the new fallback rank.
  44772. */
  44773. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44774. /**
  44775. * Add the required uniforms to the current list.
  44776. * @param uniforms defines the current uniform list.
  44777. */
  44778. static AddUniforms(uniforms: string[]): void;
  44779. /**
  44780. * Add the required samplers to the current list.
  44781. * @param samplers defines the current sampler list.
  44782. */
  44783. static AddSamplers(samplers: string[]): void;
  44784. /**
  44785. * Add the required uniforms to the current buffer.
  44786. * @param uniformBuffer defines the current uniform buffer.
  44787. */
  44788. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44789. /**
  44790. * Makes a duplicate of the current configuration into another one.
  44791. * @param clearCoatConfiguration define the config where to copy the info
  44792. */
  44793. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44794. /**
  44795. * Serializes this clear coat configuration.
  44796. * @returns - An object with the serialized config.
  44797. */
  44798. serialize(): any;
  44799. /**
  44800. * Parses a anisotropy Configuration from a serialized object.
  44801. * @param source - Serialized object.
  44802. * @param scene Defines the scene we are parsing for
  44803. * @param rootUrl Defines the rootUrl to load from
  44804. */
  44805. parse(source: any, scene: Scene, rootUrl: string): void;
  44806. }
  44807. }
  44808. declare module BABYLON {
  44809. /**
  44810. * @hidden
  44811. */
  44812. export interface IMaterialAnisotropicDefines {
  44813. ANISOTROPIC: boolean;
  44814. ANISOTROPIC_TEXTURE: boolean;
  44815. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44816. MAINUV1: boolean;
  44817. _areTexturesDirty: boolean;
  44818. _needUVs: boolean;
  44819. }
  44820. /**
  44821. * Define the code related to the anisotropic parameters of the pbr material.
  44822. */
  44823. export class PBRAnisotropicConfiguration {
  44824. private _isEnabled;
  44825. /**
  44826. * Defines if the anisotropy is enabled in the material.
  44827. */
  44828. isEnabled: boolean;
  44829. /**
  44830. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44831. */
  44832. intensity: number;
  44833. /**
  44834. * Defines if the effect is along the tangents, bitangents or in between.
  44835. * By default, the effect is "strectching" the highlights along the tangents.
  44836. */
  44837. direction: Vector2;
  44838. private _texture;
  44839. /**
  44840. * Stores the anisotropy values in a texture.
  44841. * rg is direction (like normal from -1 to 1)
  44842. * b is a intensity
  44843. */
  44844. texture: Nullable<BaseTexture>;
  44845. /** @hidden */
  44846. private _internalMarkAllSubMeshesAsTexturesDirty;
  44847. /** @hidden */
  44848. _markAllSubMeshesAsTexturesDirty(): void;
  44849. /**
  44850. * Instantiate a new istance of anisotropy configuration.
  44851. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44852. */
  44853. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44854. /**
  44855. * Specifies that the submesh is ready to be used.
  44856. * @param defines the list of "defines" to update.
  44857. * @param scene defines the scene the material belongs to.
  44858. * @returns - boolean indicating that the submesh is ready or not.
  44859. */
  44860. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44861. /**
  44862. * Checks to see if a texture is used in the material.
  44863. * @param defines the list of "defines" to update.
  44864. * @param mesh the mesh we are preparing the defines for.
  44865. * @param scene defines the scene the material belongs to.
  44866. */
  44867. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44868. /**
  44869. * Binds the material data.
  44870. * @param uniformBuffer defines the Uniform buffer to fill in.
  44871. * @param scene defines the scene the material belongs to.
  44872. * @param isFrozen defines wether the material is frozen or not.
  44873. */
  44874. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44875. /**
  44876. * Checks to see if a texture is used in the material.
  44877. * @param texture - Base texture to use.
  44878. * @returns - Boolean specifying if a texture is used in the material.
  44879. */
  44880. hasTexture(texture: BaseTexture): boolean;
  44881. /**
  44882. * Returns an array of the actively used textures.
  44883. * @param activeTextures Array of BaseTextures
  44884. */
  44885. getActiveTextures(activeTextures: BaseTexture[]): void;
  44886. /**
  44887. * Returns the animatable textures.
  44888. * @param animatables Array of animatable textures.
  44889. */
  44890. getAnimatables(animatables: IAnimatable[]): void;
  44891. /**
  44892. * Disposes the resources of the material.
  44893. * @param forceDisposeTextures - Forces the disposal of all textures.
  44894. */
  44895. dispose(forceDisposeTextures?: boolean): void;
  44896. /**
  44897. * Get the current class name of the texture useful for serialization or dynamic coding.
  44898. * @returns "PBRAnisotropicConfiguration"
  44899. */
  44900. getClassName(): string;
  44901. /**
  44902. * Add fallbacks to the effect fallbacks list.
  44903. * @param defines defines the Base texture to use.
  44904. * @param fallbacks defines the current fallback list.
  44905. * @param currentRank defines the current fallback rank.
  44906. * @returns the new fallback rank.
  44907. */
  44908. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44909. /**
  44910. * Add the required uniforms to the current list.
  44911. * @param uniforms defines the current uniform list.
  44912. */
  44913. static AddUniforms(uniforms: string[]): void;
  44914. /**
  44915. * Add the required uniforms to the current buffer.
  44916. * @param uniformBuffer defines the current uniform buffer.
  44917. */
  44918. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44919. /**
  44920. * Add the required samplers to the current list.
  44921. * @param samplers defines the current sampler list.
  44922. */
  44923. static AddSamplers(samplers: string[]): void;
  44924. /**
  44925. * Makes a duplicate of the current configuration into another one.
  44926. * @param anisotropicConfiguration define the config where to copy the info
  44927. */
  44928. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44929. /**
  44930. * Serializes this anisotropy configuration.
  44931. * @returns - An object with the serialized config.
  44932. */
  44933. serialize(): any;
  44934. /**
  44935. * Parses a anisotropy Configuration from a serialized object.
  44936. * @param source - Serialized object.
  44937. * @param scene Defines the scene we are parsing for
  44938. * @param rootUrl Defines the rootUrl to load from
  44939. */
  44940. parse(source: any, scene: Scene, rootUrl: string): void;
  44941. }
  44942. }
  44943. declare module BABYLON {
  44944. /**
  44945. * @hidden
  44946. */
  44947. export interface IMaterialBRDFDefines {
  44948. BRDF_V_HEIGHT_CORRELATED: boolean;
  44949. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44950. SPHERICAL_HARMONICS: boolean;
  44951. /** @hidden */
  44952. _areMiscDirty: boolean;
  44953. }
  44954. /**
  44955. * Define the code related to the BRDF parameters of the pbr material.
  44956. */
  44957. export class PBRBRDFConfiguration {
  44958. /**
  44959. * Default value used for the energy conservation.
  44960. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44961. */
  44962. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44963. /**
  44964. * Default value used for the Smith Visibility Height Correlated mode.
  44965. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44966. */
  44967. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44968. /**
  44969. * Default value used for the IBL diffuse part.
  44970. * This can help switching back to the polynomials mode globally which is a tiny bit
  44971. * less GPU intensive at the drawback of a lower quality.
  44972. */
  44973. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44974. private _useEnergyConservation;
  44975. /**
  44976. * Defines if the material uses energy conservation.
  44977. */
  44978. useEnergyConservation: boolean;
  44979. private _useSmithVisibilityHeightCorrelated;
  44980. /**
  44981. * LEGACY Mode set to false
  44982. * Defines if the material uses height smith correlated visibility term.
  44983. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44984. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44985. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44986. * Not relying on height correlated will also disable energy conservation.
  44987. */
  44988. useSmithVisibilityHeightCorrelated: boolean;
  44989. private _useSphericalHarmonics;
  44990. /**
  44991. * LEGACY Mode set to false
  44992. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  44993. * diffuse part of the IBL.
  44994. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  44995. * to the ground truth.
  44996. */
  44997. useSphericalHarmonics: boolean;
  44998. /** @hidden */
  44999. private _internalMarkAllSubMeshesAsMiscDirty;
  45000. /** @hidden */
  45001. _markAllSubMeshesAsMiscDirty(): void;
  45002. /**
  45003. * Instantiate a new istance of clear coat configuration.
  45004. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45005. */
  45006. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45007. /**
  45008. * Checks to see if a texture is used in the material.
  45009. * @param defines the list of "defines" to update.
  45010. */
  45011. prepareDefines(defines: IMaterialBRDFDefines): void;
  45012. /**
  45013. * Get the current class name of the texture useful for serialization or dynamic coding.
  45014. * @returns "PBRClearCoatConfiguration"
  45015. */
  45016. getClassName(): string;
  45017. /**
  45018. * Makes a duplicate of the current configuration into another one.
  45019. * @param brdfConfiguration define the config where to copy the info
  45020. */
  45021. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45022. /**
  45023. * Serializes this BRDF configuration.
  45024. * @returns - An object with the serialized config.
  45025. */
  45026. serialize(): any;
  45027. /**
  45028. * Parses a anisotropy Configuration from a serialized object.
  45029. * @param source - Serialized object.
  45030. * @param scene Defines the scene we are parsing for
  45031. * @param rootUrl Defines the rootUrl to load from
  45032. */
  45033. parse(source: any, scene: Scene, rootUrl: string): void;
  45034. }
  45035. }
  45036. declare module BABYLON {
  45037. /**
  45038. * @hidden
  45039. */
  45040. export interface IMaterialSheenDefines {
  45041. SHEEN: boolean;
  45042. SHEEN_TEXTURE: boolean;
  45043. SHEEN_TEXTUREDIRECTUV: number;
  45044. SHEEN_LINKWITHALBEDO: boolean;
  45045. /** @hidden */
  45046. _areTexturesDirty: boolean;
  45047. }
  45048. /**
  45049. * Define the code related to the Sheen parameters of the pbr material.
  45050. */
  45051. export class PBRSheenConfiguration {
  45052. private _isEnabled;
  45053. /**
  45054. * Defines if the material uses sheen.
  45055. */
  45056. isEnabled: boolean;
  45057. private _linkSheenWithAlbedo;
  45058. /**
  45059. * Defines if the sheen is linked to the sheen color.
  45060. */
  45061. linkSheenWithAlbedo: boolean;
  45062. /**
  45063. * Defines the sheen intensity.
  45064. */
  45065. intensity: number;
  45066. /**
  45067. * Defines the sheen color.
  45068. */
  45069. color: Color3;
  45070. private _texture;
  45071. /**
  45072. * Stores the sheen tint values in a texture.
  45073. * rgb is tint
  45074. * a is a intensity
  45075. */
  45076. texture: Nullable<BaseTexture>;
  45077. /** @hidden */
  45078. private _internalMarkAllSubMeshesAsTexturesDirty;
  45079. /** @hidden */
  45080. _markAllSubMeshesAsTexturesDirty(): void;
  45081. /**
  45082. * Instantiate a new istance of clear coat configuration.
  45083. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45084. */
  45085. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45086. /**
  45087. * Specifies that the submesh is ready to be used.
  45088. * @param defines the list of "defines" to update.
  45089. * @param scene defines the scene the material belongs to.
  45090. * @returns - boolean indicating that the submesh is ready or not.
  45091. */
  45092. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45093. /**
  45094. * Checks to see if a texture is used in the material.
  45095. * @param defines the list of "defines" to update.
  45096. * @param scene defines the scene the material belongs to.
  45097. */
  45098. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45099. /**
  45100. * Binds the material data.
  45101. * @param uniformBuffer defines the Uniform buffer to fill in.
  45102. * @param scene defines the scene the material belongs to.
  45103. * @param isFrozen defines wether the material is frozen or not.
  45104. */
  45105. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45106. /**
  45107. * Checks to see if a texture is used in the material.
  45108. * @param texture - Base texture to use.
  45109. * @returns - Boolean specifying if a texture is used in the material.
  45110. */
  45111. hasTexture(texture: BaseTexture): boolean;
  45112. /**
  45113. * Returns an array of the actively used textures.
  45114. * @param activeTextures Array of BaseTextures
  45115. */
  45116. getActiveTextures(activeTextures: BaseTexture[]): void;
  45117. /**
  45118. * Returns the animatable textures.
  45119. * @param animatables Array of animatable textures.
  45120. */
  45121. getAnimatables(animatables: IAnimatable[]): void;
  45122. /**
  45123. * Disposes the resources of the material.
  45124. * @param forceDisposeTextures - Forces the disposal of all textures.
  45125. */
  45126. dispose(forceDisposeTextures?: boolean): void;
  45127. /**
  45128. * Get the current class name of the texture useful for serialization or dynamic coding.
  45129. * @returns "PBRSheenConfiguration"
  45130. */
  45131. getClassName(): string;
  45132. /**
  45133. * Add fallbacks to the effect fallbacks list.
  45134. * @param defines defines the Base texture to use.
  45135. * @param fallbacks defines the current fallback list.
  45136. * @param currentRank defines the current fallback rank.
  45137. * @returns the new fallback rank.
  45138. */
  45139. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45140. /**
  45141. * Add the required uniforms to the current list.
  45142. * @param uniforms defines the current uniform list.
  45143. */
  45144. static AddUniforms(uniforms: string[]): void;
  45145. /**
  45146. * Add the required uniforms to the current buffer.
  45147. * @param uniformBuffer defines the current uniform buffer.
  45148. */
  45149. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45150. /**
  45151. * Add the required samplers to the current list.
  45152. * @param samplers defines the current sampler list.
  45153. */
  45154. static AddSamplers(samplers: string[]): void;
  45155. /**
  45156. * Makes a duplicate of the current configuration into another one.
  45157. * @param sheenConfiguration define the config where to copy the info
  45158. */
  45159. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45160. /**
  45161. * Serializes this BRDF configuration.
  45162. * @returns - An object with the serialized config.
  45163. */
  45164. serialize(): any;
  45165. /**
  45166. * Parses a anisotropy Configuration from a serialized object.
  45167. * @param source - Serialized object.
  45168. * @param scene Defines the scene we are parsing for
  45169. * @param rootUrl Defines the rootUrl to load from
  45170. */
  45171. parse(source: any, scene: Scene, rootUrl: string): void;
  45172. }
  45173. }
  45174. declare module BABYLON {
  45175. /**
  45176. * @hidden
  45177. */
  45178. export interface IMaterialSubSurfaceDefines {
  45179. SUBSURFACE: boolean;
  45180. SS_REFRACTION: boolean;
  45181. SS_TRANSLUCENCY: boolean;
  45182. SS_SCATERRING: boolean;
  45183. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45184. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45185. SS_REFRACTIONMAP_3D: boolean;
  45186. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45187. SS_LODINREFRACTIONALPHA: boolean;
  45188. SS_GAMMAREFRACTION: boolean;
  45189. SS_RGBDREFRACTION: boolean;
  45190. SS_LINEARSPECULARREFRACTION: boolean;
  45191. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45192. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45193. /** @hidden */
  45194. _areTexturesDirty: boolean;
  45195. }
  45196. /**
  45197. * Define the code related to the sub surface parameters of the pbr material.
  45198. */
  45199. export class PBRSubSurfaceConfiguration {
  45200. private _isRefractionEnabled;
  45201. /**
  45202. * Defines if the refraction is enabled in the material.
  45203. */
  45204. isRefractionEnabled: boolean;
  45205. private _isTranslucencyEnabled;
  45206. /**
  45207. * Defines if the translucency is enabled in the material.
  45208. */
  45209. isTranslucencyEnabled: boolean;
  45210. private _isScatteringEnabled;
  45211. /**
  45212. * Defines the refraction intensity of the material.
  45213. * The refraction when enabled replaces the Diffuse part of the material.
  45214. * The intensity helps transitionning between diffuse and refraction.
  45215. */
  45216. refractionIntensity: number;
  45217. /**
  45218. * Defines the translucency intensity of the material.
  45219. * When translucency has been enabled, this defines how much of the "translucency"
  45220. * is addded to the diffuse part of the material.
  45221. */
  45222. translucencyIntensity: number;
  45223. /**
  45224. * Defines the scattering intensity of the material.
  45225. * When scattering has been enabled, this defines how much of the "scattered light"
  45226. * is addded to the diffuse part of the material.
  45227. */
  45228. scatteringIntensity: number;
  45229. private _thicknessTexture;
  45230. /**
  45231. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45232. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45233. * 0 would mean minimumThickness
  45234. * 1 would mean maximumThickness
  45235. * The other channels might be use as a mask to vary the different effects intensity.
  45236. */
  45237. thicknessTexture: Nullable<BaseTexture>;
  45238. private _refractionTexture;
  45239. /**
  45240. * Defines the texture to use for refraction.
  45241. */
  45242. refractionTexture: Nullable<BaseTexture>;
  45243. private _indexOfRefraction;
  45244. /**
  45245. * Defines the index of refraction used in the material.
  45246. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45247. */
  45248. indexOfRefraction: number;
  45249. private _invertRefractionY;
  45250. /**
  45251. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45252. */
  45253. invertRefractionY: boolean;
  45254. private _linkRefractionWithTransparency;
  45255. /**
  45256. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45257. * Materials half opaque for instance using refraction could benefit from this control.
  45258. */
  45259. linkRefractionWithTransparency: boolean;
  45260. /**
  45261. * Defines the minimum thickness stored in the thickness map.
  45262. * If no thickness map is defined, this value will be used to simulate thickness.
  45263. */
  45264. minimumThickness: number;
  45265. /**
  45266. * Defines the maximum thickness stored in the thickness map.
  45267. */
  45268. maximumThickness: number;
  45269. /**
  45270. * Defines the volume tint of the material.
  45271. * This is used for both translucency and scattering.
  45272. */
  45273. tintColor: Color3;
  45274. /**
  45275. * Defines the distance at which the tint color should be found in the media.
  45276. * This is used for refraction only.
  45277. */
  45278. tintColorAtDistance: number;
  45279. /**
  45280. * Defines how far each channel transmit through the media.
  45281. * It is defined as a color to simplify it selection.
  45282. */
  45283. diffusionDistance: Color3;
  45284. private _useMaskFromThicknessTexture;
  45285. /**
  45286. * Stores the intensity of the different subsurface effects in the thickness texture.
  45287. * * the green channel is the translucency intensity.
  45288. * * the blue channel is the scattering intensity.
  45289. * * the alpha channel is the refraction intensity.
  45290. */
  45291. useMaskFromThicknessTexture: boolean;
  45292. /** @hidden */
  45293. private _internalMarkAllSubMeshesAsTexturesDirty;
  45294. /** @hidden */
  45295. _markAllSubMeshesAsTexturesDirty(): void;
  45296. /**
  45297. * Instantiate a new istance of sub surface configuration.
  45298. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45299. */
  45300. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45301. /**
  45302. * Gets wehter the submesh is ready to be used or not.
  45303. * @param defines the list of "defines" to update.
  45304. * @param scene defines the scene the material belongs to.
  45305. * @returns - boolean indicating that the submesh is ready or not.
  45306. */
  45307. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45308. /**
  45309. * Checks to see if a texture is used in the material.
  45310. * @param defines the list of "defines" to update.
  45311. * @param scene defines the scene to the material belongs to.
  45312. */
  45313. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45314. /**
  45315. * Binds the material data.
  45316. * @param uniformBuffer defines the Uniform buffer to fill in.
  45317. * @param scene defines the scene the material belongs to.
  45318. * @param engine defines the engine the material belongs to.
  45319. * @param isFrozen defines wether the material is frozen or not.
  45320. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45321. */
  45322. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45323. /**
  45324. * Unbinds the material from the mesh.
  45325. * @param activeEffect defines the effect that should be unbound from.
  45326. * @returns true if unbound, otherwise false
  45327. */
  45328. unbind(activeEffect: Effect): boolean;
  45329. /**
  45330. * Returns the texture used for refraction or null if none is used.
  45331. * @param scene defines the scene the material belongs to.
  45332. * @returns - Refraction texture if present. If no refraction texture and refraction
  45333. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45334. */
  45335. private _getRefractionTexture;
  45336. /**
  45337. * Returns true if alpha blending should be disabled.
  45338. */
  45339. readonly disableAlphaBlending: boolean;
  45340. /**
  45341. * Fills the list of render target textures.
  45342. * @param renderTargets the list of render targets to update
  45343. */
  45344. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  45345. /**
  45346. * Checks to see if a texture is used in the material.
  45347. * @param texture - Base texture to use.
  45348. * @returns - Boolean specifying if a texture is used in the material.
  45349. */
  45350. hasTexture(texture: BaseTexture): boolean;
  45351. /**
  45352. * Gets a boolean indicating that current material needs to register RTT
  45353. * @returns true if this uses a render target otherwise false.
  45354. */
  45355. hasRenderTargetTextures(): boolean;
  45356. /**
  45357. * Returns an array of the actively used textures.
  45358. * @param activeTextures Array of BaseTextures
  45359. */
  45360. getActiveTextures(activeTextures: BaseTexture[]): void;
  45361. /**
  45362. * Returns the animatable textures.
  45363. * @param animatables Array of animatable textures.
  45364. */
  45365. getAnimatables(animatables: IAnimatable[]): void;
  45366. /**
  45367. * Disposes the resources of the material.
  45368. * @param forceDisposeTextures - Forces the disposal of all textures.
  45369. */
  45370. dispose(forceDisposeTextures?: boolean): void;
  45371. /**
  45372. * Get the current class name of the texture useful for serialization or dynamic coding.
  45373. * @returns "PBRSubSurfaceConfiguration"
  45374. */
  45375. getClassName(): string;
  45376. /**
  45377. * Add fallbacks to the effect fallbacks list.
  45378. * @param defines defines the Base texture to use.
  45379. * @param fallbacks defines the current fallback list.
  45380. * @param currentRank defines the current fallback rank.
  45381. * @returns the new fallback rank.
  45382. */
  45383. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45384. /**
  45385. * Add the required uniforms to the current list.
  45386. * @param uniforms defines the current uniform list.
  45387. */
  45388. static AddUniforms(uniforms: string[]): void;
  45389. /**
  45390. * Add the required samplers to the current list.
  45391. * @param samplers defines the current sampler list.
  45392. */
  45393. static AddSamplers(samplers: string[]): void;
  45394. /**
  45395. * Add the required uniforms to the current buffer.
  45396. * @param uniformBuffer defines the current uniform buffer.
  45397. */
  45398. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45399. /**
  45400. * Makes a duplicate of the current configuration into another one.
  45401. * @param configuration define the config where to copy the info
  45402. */
  45403. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  45404. /**
  45405. * Serializes this Sub Surface configuration.
  45406. * @returns - An object with the serialized config.
  45407. */
  45408. serialize(): any;
  45409. /**
  45410. * Parses a anisotropy Configuration from a serialized object.
  45411. * @param source - Serialized object.
  45412. * @param scene Defines the scene we are parsing for
  45413. * @param rootUrl Defines the rootUrl to load from
  45414. */
  45415. parse(source: any, scene: Scene, rootUrl: string): void;
  45416. }
  45417. }
  45418. declare module BABYLON {
  45419. /** @hidden */
  45420. export var pbrFragmentDeclaration: {
  45421. name: string;
  45422. shader: string;
  45423. };
  45424. }
  45425. declare module BABYLON {
  45426. /** @hidden */
  45427. export var pbrUboDeclaration: {
  45428. name: string;
  45429. shader: string;
  45430. };
  45431. }
  45432. declare module BABYLON {
  45433. /** @hidden */
  45434. export var pbrFragmentExtraDeclaration: {
  45435. name: string;
  45436. shader: string;
  45437. };
  45438. }
  45439. declare module BABYLON {
  45440. /** @hidden */
  45441. export var pbrFragmentSamplersDeclaration: {
  45442. name: string;
  45443. shader: string;
  45444. };
  45445. }
  45446. declare module BABYLON {
  45447. /** @hidden */
  45448. export var pbrHelperFunctions: {
  45449. name: string;
  45450. shader: string;
  45451. };
  45452. }
  45453. declare module BABYLON {
  45454. /** @hidden */
  45455. export var harmonicsFunctions: {
  45456. name: string;
  45457. shader: string;
  45458. };
  45459. }
  45460. declare module BABYLON {
  45461. /** @hidden */
  45462. export var pbrDirectLightingSetupFunctions: {
  45463. name: string;
  45464. shader: string;
  45465. };
  45466. }
  45467. declare module BABYLON {
  45468. /** @hidden */
  45469. export var pbrDirectLightingFalloffFunctions: {
  45470. name: string;
  45471. shader: string;
  45472. };
  45473. }
  45474. declare module BABYLON {
  45475. /** @hidden */
  45476. export var pbrBRDFFunctions: {
  45477. name: string;
  45478. shader: string;
  45479. };
  45480. }
  45481. declare module BABYLON {
  45482. /** @hidden */
  45483. export var pbrDirectLightingFunctions: {
  45484. name: string;
  45485. shader: string;
  45486. };
  45487. }
  45488. declare module BABYLON {
  45489. /** @hidden */
  45490. export var pbrIBLFunctions: {
  45491. name: string;
  45492. shader: string;
  45493. };
  45494. }
  45495. declare module BABYLON {
  45496. /** @hidden */
  45497. export var pbrDebug: {
  45498. name: string;
  45499. shader: string;
  45500. };
  45501. }
  45502. declare module BABYLON {
  45503. /** @hidden */
  45504. export var pbrPixelShader: {
  45505. name: string;
  45506. shader: string;
  45507. };
  45508. }
  45509. declare module BABYLON {
  45510. /** @hidden */
  45511. export var pbrVertexDeclaration: {
  45512. name: string;
  45513. shader: string;
  45514. };
  45515. }
  45516. declare module BABYLON {
  45517. /** @hidden */
  45518. export var pbrVertexShader: {
  45519. name: string;
  45520. shader: string;
  45521. };
  45522. }
  45523. declare module BABYLON {
  45524. /**
  45525. * Manages the defines for the PBR Material.
  45526. * @hidden
  45527. */
  45528. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  45529. PBR: boolean;
  45530. MAINUV1: boolean;
  45531. MAINUV2: boolean;
  45532. UV1: boolean;
  45533. UV2: boolean;
  45534. ALBEDO: boolean;
  45535. ALBEDODIRECTUV: number;
  45536. VERTEXCOLOR: boolean;
  45537. AMBIENT: boolean;
  45538. AMBIENTDIRECTUV: number;
  45539. AMBIENTINGRAYSCALE: boolean;
  45540. OPACITY: boolean;
  45541. VERTEXALPHA: boolean;
  45542. OPACITYDIRECTUV: number;
  45543. OPACITYRGB: boolean;
  45544. ALPHATEST: boolean;
  45545. DEPTHPREPASS: boolean;
  45546. ALPHABLEND: boolean;
  45547. ALPHAFROMALBEDO: boolean;
  45548. ALPHATESTVALUE: string;
  45549. SPECULAROVERALPHA: boolean;
  45550. RADIANCEOVERALPHA: boolean;
  45551. ALPHAFRESNEL: boolean;
  45552. LINEARALPHAFRESNEL: boolean;
  45553. PREMULTIPLYALPHA: boolean;
  45554. EMISSIVE: boolean;
  45555. EMISSIVEDIRECTUV: number;
  45556. REFLECTIVITY: boolean;
  45557. REFLECTIVITYDIRECTUV: number;
  45558. SPECULARTERM: boolean;
  45559. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  45560. MICROSURFACEAUTOMATIC: boolean;
  45561. LODBASEDMICROSFURACE: boolean;
  45562. MICROSURFACEMAP: boolean;
  45563. MICROSURFACEMAPDIRECTUV: number;
  45564. METALLICWORKFLOW: boolean;
  45565. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  45566. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  45567. METALLNESSSTOREINMETALMAPBLUE: boolean;
  45568. AOSTOREINMETALMAPRED: boolean;
  45569. ENVIRONMENTBRDF: boolean;
  45570. ENVIRONMENTBRDF_RGBD: boolean;
  45571. NORMAL: boolean;
  45572. TANGENT: boolean;
  45573. BUMP: boolean;
  45574. BUMPDIRECTUV: number;
  45575. OBJECTSPACE_NORMALMAP: boolean;
  45576. PARALLAX: boolean;
  45577. PARALLAXOCCLUSION: boolean;
  45578. NORMALXYSCALE: boolean;
  45579. LIGHTMAP: boolean;
  45580. LIGHTMAPDIRECTUV: number;
  45581. USELIGHTMAPASSHADOWMAP: boolean;
  45582. GAMMALIGHTMAP: boolean;
  45583. REFLECTION: boolean;
  45584. REFLECTIONMAP_3D: boolean;
  45585. REFLECTIONMAP_SPHERICAL: boolean;
  45586. REFLECTIONMAP_PLANAR: boolean;
  45587. REFLECTIONMAP_CUBIC: boolean;
  45588. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  45589. REFLECTIONMAP_PROJECTION: boolean;
  45590. REFLECTIONMAP_SKYBOX: boolean;
  45591. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  45592. REFLECTIONMAP_EXPLICIT: boolean;
  45593. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  45594. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  45595. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  45596. INVERTCUBICMAP: boolean;
  45597. USESPHERICALFROMREFLECTIONMAP: boolean;
  45598. USEIRRADIANCEMAP: boolean;
  45599. SPHERICAL_HARMONICS: boolean;
  45600. USESPHERICALINVERTEX: boolean;
  45601. REFLECTIONMAP_OPPOSITEZ: boolean;
  45602. LODINREFLECTIONALPHA: boolean;
  45603. GAMMAREFLECTION: boolean;
  45604. RGBDREFLECTION: boolean;
  45605. LINEARSPECULARREFLECTION: boolean;
  45606. RADIANCEOCCLUSION: boolean;
  45607. HORIZONOCCLUSION: boolean;
  45608. INSTANCES: boolean;
  45609. NUM_BONE_INFLUENCERS: number;
  45610. BonesPerMesh: number;
  45611. BONETEXTURE: boolean;
  45612. NONUNIFORMSCALING: boolean;
  45613. MORPHTARGETS: boolean;
  45614. MORPHTARGETS_NORMAL: boolean;
  45615. MORPHTARGETS_TANGENT: boolean;
  45616. MORPHTARGETS_UV: boolean;
  45617. NUM_MORPH_INFLUENCERS: number;
  45618. IMAGEPROCESSING: boolean;
  45619. VIGNETTE: boolean;
  45620. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45621. VIGNETTEBLENDMODEOPAQUE: boolean;
  45622. TONEMAPPING: boolean;
  45623. TONEMAPPING_ACES: boolean;
  45624. CONTRAST: boolean;
  45625. COLORCURVES: boolean;
  45626. COLORGRADING: boolean;
  45627. COLORGRADING3D: boolean;
  45628. SAMPLER3DGREENDEPTH: boolean;
  45629. SAMPLER3DBGRMAP: boolean;
  45630. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45631. EXPOSURE: boolean;
  45632. MULTIVIEW: boolean;
  45633. USEPHYSICALLIGHTFALLOFF: boolean;
  45634. USEGLTFLIGHTFALLOFF: boolean;
  45635. TWOSIDEDLIGHTING: boolean;
  45636. SHADOWFLOAT: boolean;
  45637. CLIPPLANE: boolean;
  45638. CLIPPLANE2: boolean;
  45639. CLIPPLANE3: boolean;
  45640. CLIPPLANE4: boolean;
  45641. POINTSIZE: boolean;
  45642. FOG: boolean;
  45643. LOGARITHMICDEPTH: boolean;
  45644. FORCENORMALFORWARD: boolean;
  45645. SPECULARAA: boolean;
  45646. CLEARCOAT: boolean;
  45647. CLEARCOAT_DEFAULTIOR: boolean;
  45648. CLEARCOAT_TEXTURE: boolean;
  45649. CLEARCOAT_TEXTUREDIRECTUV: number;
  45650. CLEARCOAT_BUMP: boolean;
  45651. CLEARCOAT_BUMPDIRECTUV: number;
  45652. CLEARCOAT_TINT: boolean;
  45653. CLEARCOAT_TINT_TEXTURE: boolean;
  45654. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45655. ANISOTROPIC: boolean;
  45656. ANISOTROPIC_TEXTURE: boolean;
  45657. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45658. BRDF_V_HEIGHT_CORRELATED: boolean;
  45659. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45660. SHEEN: boolean;
  45661. SHEEN_TEXTURE: boolean;
  45662. SHEEN_TEXTUREDIRECTUV: number;
  45663. SHEEN_LINKWITHALBEDO: boolean;
  45664. SUBSURFACE: boolean;
  45665. SS_REFRACTION: boolean;
  45666. SS_TRANSLUCENCY: boolean;
  45667. SS_SCATERRING: boolean;
  45668. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45669. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45670. SS_REFRACTIONMAP_3D: boolean;
  45671. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45672. SS_LODINREFRACTIONALPHA: boolean;
  45673. SS_GAMMAREFRACTION: boolean;
  45674. SS_RGBDREFRACTION: boolean;
  45675. SS_LINEARSPECULARREFRACTION: boolean;
  45676. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45677. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45678. UNLIT: boolean;
  45679. DEBUGMODE: number;
  45680. /**
  45681. * Initializes the PBR Material defines.
  45682. */
  45683. constructor();
  45684. /**
  45685. * Resets the PBR Material defines.
  45686. */
  45687. reset(): void;
  45688. }
  45689. /**
  45690. * The Physically based material base class of BJS.
  45691. *
  45692. * This offers the main features of a standard PBR material.
  45693. * For more information, please refer to the documentation :
  45694. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45695. */
  45696. export abstract class PBRBaseMaterial extends PushMaterial {
  45697. /**
  45698. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45699. */
  45700. static readonly PBRMATERIAL_OPAQUE: number;
  45701. /**
  45702. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45703. */
  45704. static readonly PBRMATERIAL_ALPHATEST: number;
  45705. /**
  45706. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45707. */
  45708. static readonly PBRMATERIAL_ALPHABLEND: number;
  45709. /**
  45710. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45711. * They are also discarded below the alpha cutoff threshold to improve performances.
  45712. */
  45713. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45714. /**
  45715. * Defines the default value of how much AO map is occluding the analytical lights
  45716. * (point spot...).
  45717. */
  45718. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45719. /**
  45720. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45721. */
  45722. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45723. /**
  45724. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45725. * to enhance interoperability with other engines.
  45726. */
  45727. static readonly LIGHTFALLOFF_GLTF: number;
  45728. /**
  45729. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45730. * to enhance interoperability with other materials.
  45731. */
  45732. static readonly LIGHTFALLOFF_STANDARD: number;
  45733. /**
  45734. * Intensity of the direct lights e.g. the four lights available in your scene.
  45735. * This impacts both the direct diffuse and specular highlights.
  45736. */
  45737. protected _directIntensity: number;
  45738. /**
  45739. * Intensity of the emissive part of the material.
  45740. * This helps controlling the emissive effect without modifying the emissive color.
  45741. */
  45742. protected _emissiveIntensity: number;
  45743. /**
  45744. * Intensity of the environment e.g. how much the environment will light the object
  45745. * either through harmonics for rough material or through the refelction for shiny ones.
  45746. */
  45747. protected _environmentIntensity: number;
  45748. /**
  45749. * This is a special control allowing the reduction of the specular highlights coming from the
  45750. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45751. */
  45752. protected _specularIntensity: number;
  45753. /**
  45754. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45755. */
  45756. private _lightingInfos;
  45757. /**
  45758. * Debug Control allowing disabling the bump map on this material.
  45759. */
  45760. protected _disableBumpMap: boolean;
  45761. /**
  45762. * AKA Diffuse Texture in standard nomenclature.
  45763. */
  45764. protected _albedoTexture: Nullable<BaseTexture>;
  45765. /**
  45766. * AKA Occlusion Texture in other nomenclature.
  45767. */
  45768. protected _ambientTexture: Nullable<BaseTexture>;
  45769. /**
  45770. * AKA Occlusion Texture Intensity in other nomenclature.
  45771. */
  45772. protected _ambientTextureStrength: number;
  45773. /**
  45774. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45775. * 1 means it completely occludes it
  45776. * 0 mean it has no impact
  45777. */
  45778. protected _ambientTextureImpactOnAnalyticalLights: number;
  45779. /**
  45780. * Stores the alpha values in a texture.
  45781. */
  45782. protected _opacityTexture: Nullable<BaseTexture>;
  45783. /**
  45784. * Stores the reflection values in a texture.
  45785. */
  45786. protected _reflectionTexture: Nullable<BaseTexture>;
  45787. /**
  45788. * Stores the emissive values in a texture.
  45789. */
  45790. protected _emissiveTexture: Nullable<BaseTexture>;
  45791. /**
  45792. * AKA Specular texture in other nomenclature.
  45793. */
  45794. protected _reflectivityTexture: Nullable<BaseTexture>;
  45795. /**
  45796. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45797. */
  45798. protected _metallicTexture: Nullable<BaseTexture>;
  45799. /**
  45800. * Specifies the metallic scalar of the metallic/roughness workflow.
  45801. * Can also be used to scale the metalness values of the metallic texture.
  45802. */
  45803. protected _metallic: Nullable<number>;
  45804. /**
  45805. * Specifies the roughness scalar of the metallic/roughness workflow.
  45806. * Can also be used to scale the roughness values of the metallic texture.
  45807. */
  45808. protected _roughness: Nullable<number>;
  45809. /**
  45810. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45811. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45812. */
  45813. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45814. /**
  45815. * Stores surface normal data used to displace a mesh in a texture.
  45816. */
  45817. protected _bumpTexture: Nullable<BaseTexture>;
  45818. /**
  45819. * Stores the pre-calculated light information of a mesh in a texture.
  45820. */
  45821. protected _lightmapTexture: Nullable<BaseTexture>;
  45822. /**
  45823. * The color of a material in ambient lighting.
  45824. */
  45825. protected _ambientColor: Color3;
  45826. /**
  45827. * AKA Diffuse Color in other nomenclature.
  45828. */
  45829. protected _albedoColor: Color3;
  45830. /**
  45831. * AKA Specular Color in other nomenclature.
  45832. */
  45833. protected _reflectivityColor: Color3;
  45834. /**
  45835. * The color applied when light is reflected from a material.
  45836. */
  45837. protected _reflectionColor: Color3;
  45838. /**
  45839. * The color applied when light is emitted from a material.
  45840. */
  45841. protected _emissiveColor: Color3;
  45842. /**
  45843. * AKA Glossiness in other nomenclature.
  45844. */
  45845. protected _microSurface: number;
  45846. /**
  45847. * Specifies that the material will use the light map as a show map.
  45848. */
  45849. protected _useLightmapAsShadowmap: boolean;
  45850. /**
  45851. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45852. * makes the reflect vector face the model (under horizon).
  45853. */
  45854. protected _useHorizonOcclusion: boolean;
  45855. /**
  45856. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45857. * too much the area relying on ambient texture to define their ambient occlusion.
  45858. */
  45859. protected _useRadianceOcclusion: boolean;
  45860. /**
  45861. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45862. */
  45863. protected _useAlphaFromAlbedoTexture: boolean;
  45864. /**
  45865. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45866. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45867. */
  45868. protected _useSpecularOverAlpha: boolean;
  45869. /**
  45870. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45871. */
  45872. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45873. /**
  45874. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45875. */
  45876. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45877. /**
  45878. * Specifies if the metallic texture contains the roughness information in its green channel.
  45879. */
  45880. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45881. /**
  45882. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45883. */
  45884. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45885. /**
  45886. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45887. */
  45888. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45889. /**
  45890. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45891. */
  45892. protected _useAmbientInGrayScale: boolean;
  45893. /**
  45894. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45895. * The material will try to infer what glossiness each pixel should be.
  45896. */
  45897. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45898. /**
  45899. * Defines the falloff type used in this material.
  45900. * It by default is Physical.
  45901. */
  45902. protected _lightFalloff: number;
  45903. /**
  45904. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45905. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45906. */
  45907. protected _useRadianceOverAlpha: boolean;
  45908. /**
  45909. * Allows using an object space normal map (instead of tangent space).
  45910. */
  45911. protected _useObjectSpaceNormalMap: boolean;
  45912. /**
  45913. * Allows using the bump map in parallax mode.
  45914. */
  45915. protected _useParallax: boolean;
  45916. /**
  45917. * Allows using the bump map in parallax occlusion mode.
  45918. */
  45919. protected _useParallaxOcclusion: boolean;
  45920. /**
  45921. * Controls the scale bias of the parallax mode.
  45922. */
  45923. protected _parallaxScaleBias: number;
  45924. /**
  45925. * If sets to true, disables all the lights affecting the material.
  45926. */
  45927. protected _disableLighting: boolean;
  45928. /**
  45929. * Number of Simultaneous lights allowed on the material.
  45930. */
  45931. protected _maxSimultaneousLights: number;
  45932. /**
  45933. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45934. */
  45935. protected _invertNormalMapX: boolean;
  45936. /**
  45937. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45938. */
  45939. protected _invertNormalMapY: boolean;
  45940. /**
  45941. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45942. */
  45943. protected _twoSidedLighting: boolean;
  45944. /**
  45945. * Defines the alpha limits in alpha test mode.
  45946. */
  45947. protected _alphaCutOff: number;
  45948. /**
  45949. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45950. */
  45951. protected _forceAlphaTest: boolean;
  45952. /**
  45953. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45954. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45955. */
  45956. protected _useAlphaFresnel: boolean;
  45957. /**
  45958. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45959. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45960. */
  45961. protected _useLinearAlphaFresnel: boolean;
  45962. /**
  45963. * The transparency mode of the material.
  45964. */
  45965. protected _transparencyMode: Nullable<number>;
  45966. /**
  45967. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45968. * from cos thetav and roughness:
  45969. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45970. */
  45971. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45972. /**
  45973. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45974. */
  45975. protected _forceIrradianceInFragment: boolean;
  45976. /**
  45977. * Force normal to face away from face.
  45978. */
  45979. protected _forceNormalForward: boolean;
  45980. /**
  45981. * Enables specular anti aliasing in the PBR shader.
  45982. * It will both interacts on the Geometry for analytical and IBL lighting.
  45983. * It also prefilter the roughness map based on the bump values.
  45984. */
  45985. protected _enableSpecularAntiAliasing: boolean;
  45986. /**
  45987. * Default configuration related to image processing available in the PBR Material.
  45988. */
  45989. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45990. /**
  45991. * Keep track of the image processing observer to allow dispose and replace.
  45992. */
  45993. private _imageProcessingObserver;
  45994. /**
  45995. * Attaches a new image processing configuration to the PBR Material.
  45996. * @param configuration
  45997. */
  45998. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45999. /**
  46000. * Stores the available render targets.
  46001. */
  46002. private _renderTargets;
  46003. /**
  46004. * Sets the global ambient color for the material used in lighting calculations.
  46005. */
  46006. private _globalAmbientColor;
  46007. /**
  46008. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46009. */
  46010. private _useLogarithmicDepth;
  46011. /**
  46012. * If set to true, no lighting calculations will be applied.
  46013. */
  46014. private _unlit;
  46015. private _debugMode;
  46016. /**
  46017. * @hidden
  46018. * This is reserved for the inspector.
  46019. * Defines the material debug mode.
  46020. * It helps seeing only some components of the material while troubleshooting.
  46021. */
  46022. debugMode: number;
  46023. /**
  46024. * @hidden
  46025. * This is reserved for the inspector.
  46026. * Specify from where on screen the debug mode should start.
  46027. * The value goes from -1 (full screen) to 1 (not visible)
  46028. * It helps with side by side comparison against the final render
  46029. * This defaults to -1
  46030. */
  46031. private debugLimit;
  46032. /**
  46033. * @hidden
  46034. * This is reserved for the inspector.
  46035. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46036. * You can use the factor to better multiply the final value.
  46037. */
  46038. private debugFactor;
  46039. /**
  46040. * Defines the clear coat layer parameters for the material.
  46041. */
  46042. readonly clearCoat: PBRClearCoatConfiguration;
  46043. /**
  46044. * Defines the anisotropic parameters for the material.
  46045. */
  46046. readonly anisotropy: PBRAnisotropicConfiguration;
  46047. /**
  46048. * Defines the BRDF parameters for the material.
  46049. */
  46050. readonly brdf: PBRBRDFConfiguration;
  46051. /**
  46052. * Defines the Sheen parameters for the material.
  46053. */
  46054. readonly sheen: PBRSheenConfiguration;
  46055. /**
  46056. * Defines the SubSurface parameters for the material.
  46057. */
  46058. readonly subSurface: PBRSubSurfaceConfiguration;
  46059. /**
  46060. * Custom callback helping to override the default shader used in the material.
  46061. */
  46062. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46063. /**
  46064. * Instantiates a new PBRMaterial instance.
  46065. *
  46066. * @param name The material name
  46067. * @param scene The scene the material will be use in.
  46068. */
  46069. constructor(name: string, scene: Scene);
  46070. /**
  46071. * Gets a boolean indicating that current material needs to register RTT
  46072. */
  46073. readonly hasRenderTargetTextures: boolean;
  46074. /**
  46075. * Gets the name of the material class.
  46076. */
  46077. getClassName(): string;
  46078. /**
  46079. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46080. */
  46081. /**
  46082. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46083. */
  46084. useLogarithmicDepth: boolean;
  46085. /**
  46086. * Gets the current transparency mode.
  46087. */
  46088. /**
  46089. * Sets the transparency mode of the material.
  46090. *
  46091. * | Value | Type | Description |
  46092. * | ----- | ----------------------------------- | ----------- |
  46093. * | 0 | OPAQUE | |
  46094. * | 1 | ALPHATEST | |
  46095. * | 2 | ALPHABLEND | |
  46096. * | 3 | ALPHATESTANDBLEND | |
  46097. *
  46098. */
  46099. transparencyMode: Nullable<number>;
  46100. /**
  46101. * Returns true if alpha blending should be disabled.
  46102. */
  46103. private readonly _disableAlphaBlending;
  46104. /**
  46105. * Specifies whether or not this material should be rendered in alpha blend mode.
  46106. */
  46107. needAlphaBlending(): boolean;
  46108. /**
  46109. * Specifies if the mesh will require alpha blending.
  46110. * @param mesh - BJS mesh.
  46111. */
  46112. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46113. /**
  46114. * Specifies whether or not this material should be rendered in alpha test mode.
  46115. */
  46116. needAlphaTesting(): boolean;
  46117. /**
  46118. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46119. */
  46120. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46121. /**
  46122. * Gets the texture used for the alpha test.
  46123. */
  46124. getAlphaTestTexture(): Nullable<BaseTexture>;
  46125. /**
  46126. * Specifies that the submesh is ready to be used.
  46127. * @param mesh - BJS mesh.
  46128. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46129. * @param useInstances - Specifies that instances should be used.
  46130. * @returns - boolean indicating that the submesh is ready or not.
  46131. */
  46132. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46133. /**
  46134. * Specifies if the material uses metallic roughness workflow.
  46135. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46136. */
  46137. isMetallicWorkflow(): boolean;
  46138. private _prepareEffect;
  46139. private _prepareDefines;
  46140. /**
  46141. * Force shader compilation
  46142. */
  46143. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46144. clipPlane: boolean;
  46145. }>): void;
  46146. /**
  46147. * Initializes the uniform buffer layout for the shader.
  46148. */
  46149. buildUniformLayout(): void;
  46150. /**
  46151. * Unbinds the material from the mesh
  46152. */
  46153. unbind(): void;
  46154. /**
  46155. * Binds the submesh data.
  46156. * @param world - The world matrix.
  46157. * @param mesh - The BJS mesh.
  46158. * @param subMesh - A submesh of the BJS mesh.
  46159. */
  46160. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46161. /**
  46162. * Returns the animatable textures.
  46163. * @returns - Array of animatable textures.
  46164. */
  46165. getAnimatables(): IAnimatable[];
  46166. /**
  46167. * Returns the texture used for reflections.
  46168. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46169. */
  46170. private _getReflectionTexture;
  46171. /**
  46172. * Returns an array of the actively used textures.
  46173. * @returns - Array of BaseTextures
  46174. */
  46175. getActiveTextures(): BaseTexture[];
  46176. /**
  46177. * Checks to see if a texture is used in the material.
  46178. * @param texture - Base texture to use.
  46179. * @returns - Boolean specifying if a texture is used in the material.
  46180. */
  46181. hasTexture(texture: BaseTexture): boolean;
  46182. /**
  46183. * Disposes the resources of the material.
  46184. * @param forceDisposeEffect - Forces the disposal of effects.
  46185. * @param forceDisposeTextures - Forces the disposal of all textures.
  46186. */
  46187. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46188. }
  46189. }
  46190. declare module BABYLON {
  46191. /**
  46192. * The Physically based material of BJS.
  46193. *
  46194. * This offers the main features of a standard PBR material.
  46195. * For more information, please refer to the documentation :
  46196. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46197. */
  46198. export class PBRMaterial extends PBRBaseMaterial {
  46199. /**
  46200. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46201. */
  46202. static readonly PBRMATERIAL_OPAQUE: number;
  46203. /**
  46204. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46205. */
  46206. static readonly PBRMATERIAL_ALPHATEST: number;
  46207. /**
  46208. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46209. */
  46210. static readonly PBRMATERIAL_ALPHABLEND: number;
  46211. /**
  46212. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46213. * They are also discarded below the alpha cutoff threshold to improve performances.
  46214. */
  46215. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46216. /**
  46217. * Defines the default value of how much AO map is occluding the analytical lights
  46218. * (point spot...).
  46219. */
  46220. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46221. /**
  46222. * Intensity of the direct lights e.g. the four lights available in your scene.
  46223. * This impacts both the direct diffuse and specular highlights.
  46224. */
  46225. directIntensity: number;
  46226. /**
  46227. * Intensity of the emissive part of the material.
  46228. * This helps controlling the emissive effect without modifying the emissive color.
  46229. */
  46230. emissiveIntensity: number;
  46231. /**
  46232. * Intensity of the environment e.g. how much the environment will light the object
  46233. * either through harmonics for rough material or through the refelction for shiny ones.
  46234. */
  46235. environmentIntensity: number;
  46236. /**
  46237. * This is a special control allowing the reduction of the specular highlights coming from the
  46238. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46239. */
  46240. specularIntensity: number;
  46241. /**
  46242. * Debug Control allowing disabling the bump map on this material.
  46243. */
  46244. disableBumpMap: boolean;
  46245. /**
  46246. * AKA Diffuse Texture in standard nomenclature.
  46247. */
  46248. albedoTexture: BaseTexture;
  46249. /**
  46250. * AKA Occlusion Texture in other nomenclature.
  46251. */
  46252. ambientTexture: BaseTexture;
  46253. /**
  46254. * AKA Occlusion Texture Intensity in other nomenclature.
  46255. */
  46256. ambientTextureStrength: number;
  46257. /**
  46258. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46259. * 1 means it completely occludes it
  46260. * 0 mean it has no impact
  46261. */
  46262. ambientTextureImpactOnAnalyticalLights: number;
  46263. /**
  46264. * Stores the alpha values in a texture.
  46265. */
  46266. opacityTexture: BaseTexture;
  46267. /**
  46268. * Stores the reflection values in a texture.
  46269. */
  46270. reflectionTexture: Nullable<BaseTexture>;
  46271. /**
  46272. * Stores the emissive values in a texture.
  46273. */
  46274. emissiveTexture: BaseTexture;
  46275. /**
  46276. * AKA Specular texture in other nomenclature.
  46277. */
  46278. reflectivityTexture: BaseTexture;
  46279. /**
  46280. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46281. */
  46282. metallicTexture: BaseTexture;
  46283. /**
  46284. * Specifies the metallic scalar of the metallic/roughness workflow.
  46285. * Can also be used to scale the metalness values of the metallic texture.
  46286. */
  46287. metallic: Nullable<number>;
  46288. /**
  46289. * Specifies the roughness scalar of the metallic/roughness workflow.
  46290. * Can also be used to scale the roughness values of the metallic texture.
  46291. */
  46292. roughness: Nullable<number>;
  46293. /**
  46294. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46295. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46296. */
  46297. microSurfaceTexture: BaseTexture;
  46298. /**
  46299. * Stores surface normal data used to displace a mesh in a texture.
  46300. */
  46301. bumpTexture: BaseTexture;
  46302. /**
  46303. * Stores the pre-calculated light information of a mesh in a texture.
  46304. */
  46305. lightmapTexture: BaseTexture;
  46306. /**
  46307. * Stores the refracted light information in a texture.
  46308. */
  46309. refractionTexture: Nullable<BaseTexture>;
  46310. /**
  46311. * The color of a material in ambient lighting.
  46312. */
  46313. ambientColor: Color3;
  46314. /**
  46315. * AKA Diffuse Color in other nomenclature.
  46316. */
  46317. albedoColor: Color3;
  46318. /**
  46319. * AKA Specular Color in other nomenclature.
  46320. */
  46321. reflectivityColor: Color3;
  46322. /**
  46323. * The color reflected from the material.
  46324. */
  46325. reflectionColor: Color3;
  46326. /**
  46327. * The color emitted from the material.
  46328. */
  46329. emissiveColor: Color3;
  46330. /**
  46331. * AKA Glossiness in other nomenclature.
  46332. */
  46333. microSurface: number;
  46334. /**
  46335. * source material index of refraction (IOR)' / 'destination material IOR.
  46336. */
  46337. indexOfRefraction: number;
  46338. /**
  46339. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46340. */
  46341. invertRefractionY: boolean;
  46342. /**
  46343. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46344. * Materials half opaque for instance using refraction could benefit from this control.
  46345. */
  46346. linkRefractionWithTransparency: boolean;
  46347. /**
  46348. * If true, the light map contains occlusion information instead of lighting info.
  46349. */
  46350. useLightmapAsShadowmap: boolean;
  46351. /**
  46352. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46353. */
  46354. useAlphaFromAlbedoTexture: boolean;
  46355. /**
  46356. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46357. */
  46358. forceAlphaTest: boolean;
  46359. /**
  46360. * Defines the alpha limits in alpha test mode.
  46361. */
  46362. alphaCutOff: number;
  46363. /**
  46364. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46365. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46366. */
  46367. useSpecularOverAlpha: boolean;
  46368. /**
  46369. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46370. */
  46371. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46372. /**
  46373. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46374. */
  46375. useRoughnessFromMetallicTextureAlpha: boolean;
  46376. /**
  46377. * Specifies if the metallic texture contains the roughness information in its green channel.
  46378. */
  46379. useRoughnessFromMetallicTextureGreen: boolean;
  46380. /**
  46381. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46382. */
  46383. useMetallnessFromMetallicTextureBlue: boolean;
  46384. /**
  46385. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46386. */
  46387. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46388. /**
  46389. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46390. */
  46391. useAmbientInGrayScale: boolean;
  46392. /**
  46393. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46394. * The material will try to infer what glossiness each pixel should be.
  46395. */
  46396. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46397. /**
  46398. * BJS is using an harcoded light falloff based on a manually sets up range.
  46399. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46400. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46401. */
  46402. /**
  46403. * BJS is using an harcoded light falloff based on a manually sets up range.
  46404. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46405. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46406. */
  46407. usePhysicalLightFalloff: boolean;
  46408. /**
  46409. * In order to support the falloff compatibility with gltf, a special mode has been added
  46410. * to reproduce the gltf light falloff.
  46411. */
  46412. /**
  46413. * In order to support the falloff compatibility with gltf, a special mode has been added
  46414. * to reproduce the gltf light falloff.
  46415. */
  46416. useGLTFLightFalloff: boolean;
  46417. /**
  46418. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46419. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46420. */
  46421. useRadianceOverAlpha: boolean;
  46422. /**
  46423. * Allows using an object space normal map (instead of tangent space).
  46424. */
  46425. useObjectSpaceNormalMap: boolean;
  46426. /**
  46427. * Allows using the bump map in parallax mode.
  46428. */
  46429. useParallax: boolean;
  46430. /**
  46431. * Allows using the bump map in parallax occlusion mode.
  46432. */
  46433. useParallaxOcclusion: boolean;
  46434. /**
  46435. * Controls the scale bias of the parallax mode.
  46436. */
  46437. parallaxScaleBias: number;
  46438. /**
  46439. * If sets to true, disables all the lights affecting the material.
  46440. */
  46441. disableLighting: boolean;
  46442. /**
  46443. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46444. */
  46445. forceIrradianceInFragment: boolean;
  46446. /**
  46447. * Number of Simultaneous lights allowed on the material.
  46448. */
  46449. maxSimultaneousLights: number;
  46450. /**
  46451. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46452. */
  46453. invertNormalMapX: boolean;
  46454. /**
  46455. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46456. */
  46457. invertNormalMapY: boolean;
  46458. /**
  46459. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46460. */
  46461. twoSidedLighting: boolean;
  46462. /**
  46463. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46464. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46465. */
  46466. useAlphaFresnel: boolean;
  46467. /**
  46468. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46469. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46470. */
  46471. useLinearAlphaFresnel: boolean;
  46472. /**
  46473. * Let user defines the brdf lookup texture used for IBL.
  46474. * A default 8bit version is embedded but you could point at :
  46475. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  46476. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46477. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46478. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46479. */
  46480. environmentBRDFTexture: Nullable<BaseTexture>;
  46481. /**
  46482. * Force normal to face away from face.
  46483. */
  46484. forceNormalForward: boolean;
  46485. /**
  46486. * Enables specular anti aliasing in the PBR shader.
  46487. * It will both interacts on the Geometry for analytical and IBL lighting.
  46488. * It also prefilter the roughness map based on the bump values.
  46489. */
  46490. enableSpecularAntiAliasing: boolean;
  46491. /**
  46492. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46493. * makes the reflect vector face the model (under horizon).
  46494. */
  46495. useHorizonOcclusion: boolean;
  46496. /**
  46497. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46498. * too much the area relying on ambient texture to define their ambient occlusion.
  46499. */
  46500. useRadianceOcclusion: boolean;
  46501. /**
  46502. * If set to true, no lighting calculations will be applied.
  46503. */
  46504. unlit: boolean;
  46505. /**
  46506. * Gets the image processing configuration used either in this material.
  46507. */
  46508. /**
  46509. * Sets the Default image processing configuration used either in the this material.
  46510. *
  46511. * If sets to null, the scene one is in use.
  46512. */
  46513. imageProcessingConfiguration: ImageProcessingConfiguration;
  46514. /**
  46515. * Gets wether the color curves effect is enabled.
  46516. */
  46517. /**
  46518. * Sets wether the color curves effect is enabled.
  46519. */
  46520. cameraColorCurvesEnabled: boolean;
  46521. /**
  46522. * Gets wether the color grading effect is enabled.
  46523. */
  46524. /**
  46525. * Gets wether the color grading effect is enabled.
  46526. */
  46527. cameraColorGradingEnabled: boolean;
  46528. /**
  46529. * Gets wether tonemapping is enabled or not.
  46530. */
  46531. /**
  46532. * Sets wether tonemapping is enabled or not
  46533. */
  46534. cameraToneMappingEnabled: boolean;
  46535. /**
  46536. * The camera exposure used on this material.
  46537. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46538. * This corresponds to a photographic exposure.
  46539. */
  46540. /**
  46541. * The camera exposure used on this material.
  46542. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46543. * This corresponds to a photographic exposure.
  46544. */
  46545. cameraExposure: number;
  46546. /**
  46547. * Gets The camera contrast used on this material.
  46548. */
  46549. /**
  46550. * Sets The camera contrast used on this material.
  46551. */
  46552. cameraContrast: number;
  46553. /**
  46554. * Gets the Color Grading 2D Lookup Texture.
  46555. */
  46556. /**
  46557. * Sets the Color Grading 2D Lookup Texture.
  46558. */
  46559. cameraColorGradingTexture: Nullable<BaseTexture>;
  46560. /**
  46561. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46562. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46563. * 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;
  46564. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46565. */
  46566. /**
  46567. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46568. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46569. * 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;
  46570. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46571. */
  46572. cameraColorCurves: Nullable<ColorCurves>;
  46573. /**
  46574. * Instantiates a new PBRMaterial instance.
  46575. *
  46576. * @param name The material name
  46577. * @param scene The scene the material will be use in.
  46578. */
  46579. constructor(name: string, scene: Scene);
  46580. /**
  46581. * Returns the name of this material class.
  46582. */
  46583. getClassName(): string;
  46584. /**
  46585. * Makes a duplicate of the current material.
  46586. * @param name - name to use for the new material.
  46587. */
  46588. clone(name: string): PBRMaterial;
  46589. /**
  46590. * Serializes this PBR Material.
  46591. * @returns - An object with the serialized material.
  46592. */
  46593. serialize(): any;
  46594. /**
  46595. * Parses a PBR Material from a serialized object.
  46596. * @param source - Serialized object.
  46597. * @param scene - BJS scene instance.
  46598. * @param rootUrl - url for the scene object
  46599. * @returns - PBRMaterial
  46600. */
  46601. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46602. }
  46603. }
  46604. declare module BABYLON {
  46605. /**
  46606. * Direct draw surface info
  46607. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46608. */
  46609. export interface DDSInfo {
  46610. /**
  46611. * Width of the texture
  46612. */
  46613. width: number;
  46614. /**
  46615. * Width of the texture
  46616. */
  46617. height: number;
  46618. /**
  46619. * Number of Mipmaps for the texture
  46620. * @see https://en.wikipedia.org/wiki/Mipmap
  46621. */
  46622. mipmapCount: number;
  46623. /**
  46624. * If the textures format is a known fourCC format
  46625. * @see https://www.fourcc.org/
  46626. */
  46627. isFourCC: boolean;
  46628. /**
  46629. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46630. */
  46631. isRGB: boolean;
  46632. /**
  46633. * If the texture is a lumincance format
  46634. */
  46635. isLuminance: boolean;
  46636. /**
  46637. * If this is a cube texture
  46638. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46639. */
  46640. isCube: boolean;
  46641. /**
  46642. * If the texture is a compressed format eg. FOURCC_DXT1
  46643. */
  46644. isCompressed: boolean;
  46645. /**
  46646. * The dxgiFormat of the texture
  46647. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46648. */
  46649. dxgiFormat: number;
  46650. /**
  46651. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46652. */
  46653. textureType: number;
  46654. /**
  46655. * Sphericle polynomial created for the dds texture
  46656. */
  46657. sphericalPolynomial?: SphericalPolynomial;
  46658. }
  46659. /**
  46660. * Class used to provide DDS decompression tools
  46661. */
  46662. export class DDSTools {
  46663. /**
  46664. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46665. */
  46666. static StoreLODInAlphaChannel: boolean;
  46667. /**
  46668. * Gets DDS information from an array buffer
  46669. * @param arrayBuffer defines the array buffer to read data from
  46670. * @returns the DDS information
  46671. */
  46672. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46673. private static _FloatView;
  46674. private static _Int32View;
  46675. private static _ToHalfFloat;
  46676. private static _FromHalfFloat;
  46677. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46678. private static _GetHalfFloatRGBAArrayBuffer;
  46679. private static _GetFloatRGBAArrayBuffer;
  46680. private static _GetFloatAsUIntRGBAArrayBuffer;
  46681. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46682. private static _GetRGBAArrayBuffer;
  46683. private static _ExtractLongWordOrder;
  46684. private static _GetRGBArrayBuffer;
  46685. private static _GetLuminanceArrayBuffer;
  46686. /**
  46687. * Uploads DDS Levels to a Babylon Texture
  46688. * @hidden
  46689. */
  46690. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46691. }
  46692. interface Engine {
  46693. /**
  46694. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46695. * @param rootUrl defines the url where the file to load is located
  46696. * @param scene defines the current scene
  46697. * @param lodScale defines scale to apply to the mip map selection
  46698. * @param lodOffset defines offset to apply to the mip map selection
  46699. * @param onLoad defines an optional callback raised when the texture is loaded
  46700. * @param onError defines an optional callback raised if there is an issue to load the texture
  46701. * @param format defines the format of the data
  46702. * @param forcedExtension defines the extension to use to pick the right loader
  46703. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46704. * @returns the cube texture as an InternalTexture
  46705. */
  46706. 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;
  46707. }
  46708. }
  46709. declare module BABYLON {
  46710. /**
  46711. * Implementation of the DDS Texture Loader.
  46712. * @hidden
  46713. */
  46714. export class _DDSTextureLoader implements IInternalTextureLoader {
  46715. /**
  46716. * Defines wether the loader supports cascade loading the different faces.
  46717. */
  46718. readonly supportCascades: boolean;
  46719. /**
  46720. * This returns if the loader support the current file information.
  46721. * @param extension defines the file extension of the file being loaded
  46722. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46723. * @param fallback defines the fallback internal texture if any
  46724. * @param isBase64 defines whether the texture is encoded as a base64
  46725. * @param isBuffer defines whether the texture data are stored as a buffer
  46726. * @returns true if the loader can load the specified file
  46727. */
  46728. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46729. /**
  46730. * Transform the url before loading if required.
  46731. * @param rootUrl the url of the texture
  46732. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46733. * @returns the transformed texture
  46734. */
  46735. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46736. /**
  46737. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46738. * @param rootUrl the url of the texture
  46739. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46740. * @returns the fallback texture
  46741. */
  46742. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46743. /**
  46744. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46745. * @param data contains the texture data
  46746. * @param texture defines the BabylonJS internal texture
  46747. * @param createPolynomials will be true if polynomials have been requested
  46748. * @param onLoad defines the callback to trigger once the texture is ready
  46749. * @param onError defines the callback to trigger in case of error
  46750. */
  46751. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46752. /**
  46753. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46754. * @param data contains the texture data
  46755. * @param texture defines the BabylonJS internal texture
  46756. * @param callback defines the method to call once ready to upload
  46757. */
  46758. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46759. }
  46760. }
  46761. declare module BABYLON {
  46762. /** @hidden */
  46763. export var rgbdEncodePixelShader: {
  46764. name: string;
  46765. shader: string;
  46766. };
  46767. }
  46768. declare module BABYLON {
  46769. /**
  46770. * Raw texture data and descriptor sufficient for WebGL texture upload
  46771. */
  46772. export interface EnvironmentTextureInfo {
  46773. /**
  46774. * Version of the environment map
  46775. */
  46776. version: number;
  46777. /**
  46778. * Width of image
  46779. */
  46780. width: number;
  46781. /**
  46782. * Irradiance information stored in the file.
  46783. */
  46784. irradiance: any;
  46785. /**
  46786. * Specular information stored in the file.
  46787. */
  46788. specular: any;
  46789. }
  46790. /**
  46791. * Sets of helpers addressing the serialization and deserialization of environment texture
  46792. * stored in a BabylonJS env file.
  46793. * Those files are usually stored as .env files.
  46794. */
  46795. export class EnvironmentTextureTools {
  46796. /**
  46797. * Magic number identifying the env file.
  46798. */
  46799. private static _MagicBytes;
  46800. /**
  46801. * Gets the environment info from an env file.
  46802. * @param data The array buffer containing the .env bytes.
  46803. * @returns the environment file info (the json header) if successfully parsed.
  46804. */
  46805. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46806. /**
  46807. * Creates an environment texture from a loaded cube texture.
  46808. * @param texture defines the cube texture to convert in env file
  46809. * @return a promise containing the environment data if succesfull.
  46810. */
  46811. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46812. /**
  46813. * Creates a JSON representation of the spherical data.
  46814. * @param texture defines the texture containing the polynomials
  46815. * @return the JSON representation of the spherical info
  46816. */
  46817. private static _CreateEnvTextureIrradiance;
  46818. /**
  46819. * Uploads the texture info contained in the env file to the GPU.
  46820. * @param texture defines the internal texture to upload to
  46821. * @param arrayBuffer defines the buffer cotaining the data to load
  46822. * @param info defines the texture info retrieved through the GetEnvInfo method
  46823. * @returns a promise
  46824. */
  46825. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46826. /**
  46827. * Uploads the levels of image data to the GPU.
  46828. * @param texture defines the internal texture to upload to
  46829. * @param imageData defines the array buffer views of image data [mipmap][face]
  46830. * @returns a promise
  46831. */
  46832. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46833. /**
  46834. * Uploads spherical polynomials information to the texture.
  46835. * @param texture defines the texture we are trying to upload the information to
  46836. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46837. */
  46838. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46839. /** @hidden */
  46840. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46841. }
  46842. }
  46843. declare module BABYLON {
  46844. /**
  46845. * Implementation of the ENV Texture Loader.
  46846. * @hidden
  46847. */
  46848. export class _ENVTextureLoader implements IInternalTextureLoader {
  46849. /**
  46850. * Defines wether the loader supports cascade loading the different faces.
  46851. */
  46852. readonly supportCascades: boolean;
  46853. /**
  46854. * This returns if the loader support the current file information.
  46855. * @param extension defines the file extension of the file being loaded
  46856. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46857. * @param fallback defines the fallback internal texture if any
  46858. * @param isBase64 defines whether the texture is encoded as a base64
  46859. * @param isBuffer defines whether the texture data are stored as a buffer
  46860. * @returns true if the loader can load the specified file
  46861. */
  46862. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46863. /**
  46864. * Transform the url before loading if required.
  46865. * @param rootUrl the url of the texture
  46866. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46867. * @returns the transformed texture
  46868. */
  46869. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46870. /**
  46871. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46872. * @param rootUrl the url of the texture
  46873. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46874. * @returns the fallback texture
  46875. */
  46876. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46877. /**
  46878. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46879. * @param data contains the texture data
  46880. * @param texture defines the BabylonJS internal texture
  46881. * @param createPolynomials will be true if polynomials have been requested
  46882. * @param onLoad defines the callback to trigger once the texture is ready
  46883. * @param onError defines the callback to trigger in case of error
  46884. */
  46885. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46886. /**
  46887. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46888. * @param data contains the texture data
  46889. * @param texture defines the BabylonJS internal texture
  46890. * @param callback defines the method to call once ready to upload
  46891. */
  46892. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46893. }
  46894. }
  46895. declare module BABYLON {
  46896. /**
  46897. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46898. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46899. */
  46900. export class KhronosTextureContainer {
  46901. /** contents of the KTX container file */
  46902. arrayBuffer: any;
  46903. private static HEADER_LEN;
  46904. private static COMPRESSED_2D;
  46905. private static COMPRESSED_3D;
  46906. private static TEX_2D;
  46907. private static TEX_3D;
  46908. /**
  46909. * Gets the openGL type
  46910. */
  46911. glType: number;
  46912. /**
  46913. * Gets the openGL type size
  46914. */
  46915. glTypeSize: number;
  46916. /**
  46917. * Gets the openGL format
  46918. */
  46919. glFormat: number;
  46920. /**
  46921. * Gets the openGL internal format
  46922. */
  46923. glInternalFormat: number;
  46924. /**
  46925. * Gets the base internal format
  46926. */
  46927. glBaseInternalFormat: number;
  46928. /**
  46929. * Gets image width in pixel
  46930. */
  46931. pixelWidth: number;
  46932. /**
  46933. * Gets image height in pixel
  46934. */
  46935. pixelHeight: number;
  46936. /**
  46937. * Gets image depth in pixels
  46938. */
  46939. pixelDepth: number;
  46940. /**
  46941. * Gets the number of array elements
  46942. */
  46943. numberOfArrayElements: number;
  46944. /**
  46945. * Gets the number of faces
  46946. */
  46947. numberOfFaces: number;
  46948. /**
  46949. * Gets the number of mipmap levels
  46950. */
  46951. numberOfMipmapLevels: number;
  46952. /**
  46953. * Gets the bytes of key value data
  46954. */
  46955. bytesOfKeyValueData: number;
  46956. /**
  46957. * Gets the load type
  46958. */
  46959. loadType: number;
  46960. /**
  46961. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46962. */
  46963. isInvalid: boolean;
  46964. /**
  46965. * Creates a new KhronosTextureContainer
  46966. * @param arrayBuffer contents of the KTX container file
  46967. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46968. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46969. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46970. */
  46971. constructor(
  46972. /** contents of the KTX container file */
  46973. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46974. /**
  46975. * Uploads KTX content to a Babylon Texture.
  46976. * It is assumed that the texture has already been created & is currently bound
  46977. * @hidden
  46978. */
  46979. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46980. private _upload2DCompressedLevels;
  46981. }
  46982. }
  46983. declare module BABYLON {
  46984. /**
  46985. * Implementation of the KTX Texture Loader.
  46986. * @hidden
  46987. */
  46988. export class _KTXTextureLoader implements IInternalTextureLoader {
  46989. /**
  46990. * Defines wether the loader supports cascade loading the different faces.
  46991. */
  46992. readonly supportCascades: boolean;
  46993. /**
  46994. * This returns if the loader support the current file information.
  46995. * @param extension defines the file extension of the file being loaded
  46996. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46997. * @param fallback defines the fallback internal texture if any
  46998. * @param isBase64 defines whether the texture is encoded as a base64
  46999. * @param isBuffer defines whether the texture data are stored as a buffer
  47000. * @returns true if the loader can load the specified file
  47001. */
  47002. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47003. /**
  47004. * Transform the url before loading if required.
  47005. * @param rootUrl the url of the texture
  47006. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47007. * @returns the transformed texture
  47008. */
  47009. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47010. /**
  47011. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47012. * @param rootUrl the url of the texture
  47013. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47014. * @returns the fallback texture
  47015. */
  47016. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47017. /**
  47018. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47019. * @param data contains the texture data
  47020. * @param texture defines the BabylonJS internal texture
  47021. * @param createPolynomials will be true if polynomials have been requested
  47022. * @param onLoad defines the callback to trigger once the texture is ready
  47023. * @param onError defines the callback to trigger in case of error
  47024. */
  47025. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47026. /**
  47027. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47028. * @param data contains the texture data
  47029. * @param texture defines the BabylonJS internal texture
  47030. * @param callback defines the method to call once ready to upload
  47031. */
  47032. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47033. }
  47034. }
  47035. declare module BABYLON {
  47036. /** @hidden */
  47037. export var _forceSceneHelpersToBundle: boolean;
  47038. interface Scene {
  47039. /**
  47040. * Creates a default light for the scene.
  47041. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47042. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47043. */
  47044. createDefaultLight(replace?: boolean): void;
  47045. /**
  47046. * Creates a default camera for the scene.
  47047. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47048. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47049. * @param replace has default false, when true replaces the active camera in the scene
  47050. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47051. */
  47052. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47053. /**
  47054. * Creates a default camera and a default light.
  47055. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47056. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47057. * @param replace has the default false, when true replaces the active camera/light in the scene
  47058. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47059. */
  47060. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47061. /**
  47062. * Creates a new sky box
  47063. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47064. * @param environmentTexture defines the texture to use as environment texture
  47065. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47066. * @param scale defines the overall scale of the skybox
  47067. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47068. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47069. * @returns a new mesh holding the sky box
  47070. */
  47071. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47072. /**
  47073. * Creates a new environment
  47074. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47075. * @param options defines the options you can use to configure the environment
  47076. * @returns the new EnvironmentHelper
  47077. */
  47078. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47079. /**
  47080. * Creates a new VREXperienceHelper
  47081. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47082. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47083. * @returns a new VREXperienceHelper
  47084. */
  47085. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47086. /**
  47087. * Creates a new XREXperienceHelper
  47088. * @see http://doc.babylonjs.com/how_to/webxr
  47089. * @returns a promise for a new XREXperienceHelper
  47090. */
  47091. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  47092. }
  47093. }
  47094. declare module BABYLON {
  47095. /**
  47096. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47097. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47098. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47099. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47100. */
  47101. export class VideoDome extends TransformNode {
  47102. /**
  47103. * Define the video source as a Monoscopic panoramic 360 video.
  47104. */
  47105. static readonly MODE_MONOSCOPIC: number;
  47106. /**
  47107. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47108. */
  47109. static readonly MODE_TOPBOTTOM: number;
  47110. /**
  47111. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47112. */
  47113. static readonly MODE_SIDEBYSIDE: number;
  47114. private _useDirectMapping;
  47115. /**
  47116. * The video texture being displayed on the sphere
  47117. */
  47118. protected _videoTexture: VideoTexture;
  47119. /**
  47120. * Gets the video texture being displayed on the sphere
  47121. */
  47122. readonly videoTexture: VideoTexture;
  47123. /**
  47124. * The skybox material
  47125. */
  47126. protected _material: BackgroundMaterial;
  47127. /**
  47128. * The surface used for the skybox
  47129. */
  47130. protected _mesh: Mesh;
  47131. /**
  47132. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47133. * Also see the options.resolution property.
  47134. */
  47135. fovMultiplier: number;
  47136. private _videoMode;
  47137. /**
  47138. * Gets or set the current video mode for the video. It can be:
  47139. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47140. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47141. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47142. */
  47143. videoMode: number;
  47144. /**
  47145. * Oberserver used in Stereoscopic VR Mode.
  47146. */
  47147. private _onBeforeCameraRenderObserver;
  47148. /**
  47149. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47150. * @param name Element's name, child elements will append suffixes for their own names.
  47151. * @param urlsOrVideo defines the url(s) or the video element to use
  47152. * @param options An object containing optional or exposed sub element properties
  47153. */
  47154. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47155. resolution?: number;
  47156. clickToPlay?: boolean;
  47157. autoPlay?: boolean;
  47158. loop?: boolean;
  47159. size?: number;
  47160. poster?: string;
  47161. faceForward?: boolean;
  47162. useDirectMapping?: boolean;
  47163. }, scene: Scene);
  47164. private _changeVideoMode;
  47165. /**
  47166. * Releases resources associated with this node.
  47167. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47168. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47169. */
  47170. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47171. }
  47172. }
  47173. declare module BABYLON {
  47174. /**
  47175. * This class can be used to get instrumentation data from a Babylon engine
  47176. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47177. */
  47178. export class EngineInstrumentation implements IDisposable {
  47179. /**
  47180. * Define the instrumented engine.
  47181. */
  47182. engine: Engine;
  47183. private _captureGPUFrameTime;
  47184. private _gpuFrameTimeToken;
  47185. private _gpuFrameTime;
  47186. private _captureShaderCompilationTime;
  47187. private _shaderCompilationTime;
  47188. private _onBeginFrameObserver;
  47189. private _onEndFrameObserver;
  47190. private _onBeforeShaderCompilationObserver;
  47191. private _onAfterShaderCompilationObserver;
  47192. /**
  47193. * Gets the perf counter used for GPU frame time
  47194. */
  47195. readonly gpuFrameTimeCounter: PerfCounter;
  47196. /**
  47197. * Gets the GPU frame time capture status
  47198. */
  47199. /**
  47200. * Enable or disable the GPU frame time capture
  47201. */
  47202. captureGPUFrameTime: boolean;
  47203. /**
  47204. * Gets the perf counter used for shader compilation time
  47205. */
  47206. readonly shaderCompilationTimeCounter: PerfCounter;
  47207. /**
  47208. * Gets the shader compilation time capture status
  47209. */
  47210. /**
  47211. * Enable or disable the shader compilation time capture
  47212. */
  47213. captureShaderCompilationTime: boolean;
  47214. /**
  47215. * Instantiates a new engine instrumentation.
  47216. * This class can be used to get instrumentation data from a Babylon engine
  47217. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47218. * @param engine Defines the engine to instrument
  47219. */
  47220. constructor(
  47221. /**
  47222. * Define the instrumented engine.
  47223. */
  47224. engine: Engine);
  47225. /**
  47226. * Dispose and release associated resources.
  47227. */
  47228. dispose(): void;
  47229. }
  47230. }
  47231. declare module BABYLON {
  47232. /**
  47233. * This class can be used to get instrumentation data from a Babylon engine
  47234. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47235. */
  47236. export class SceneInstrumentation implements IDisposable {
  47237. /**
  47238. * Defines the scene to instrument
  47239. */
  47240. scene: Scene;
  47241. private _captureActiveMeshesEvaluationTime;
  47242. private _activeMeshesEvaluationTime;
  47243. private _captureRenderTargetsRenderTime;
  47244. private _renderTargetsRenderTime;
  47245. private _captureFrameTime;
  47246. private _frameTime;
  47247. private _captureRenderTime;
  47248. private _renderTime;
  47249. private _captureInterFrameTime;
  47250. private _interFrameTime;
  47251. private _captureParticlesRenderTime;
  47252. private _particlesRenderTime;
  47253. private _captureSpritesRenderTime;
  47254. private _spritesRenderTime;
  47255. private _capturePhysicsTime;
  47256. private _physicsTime;
  47257. private _captureAnimationsTime;
  47258. private _animationsTime;
  47259. private _captureCameraRenderTime;
  47260. private _cameraRenderTime;
  47261. private _onBeforeActiveMeshesEvaluationObserver;
  47262. private _onAfterActiveMeshesEvaluationObserver;
  47263. private _onBeforeRenderTargetsRenderObserver;
  47264. private _onAfterRenderTargetsRenderObserver;
  47265. private _onAfterRenderObserver;
  47266. private _onBeforeDrawPhaseObserver;
  47267. private _onAfterDrawPhaseObserver;
  47268. private _onBeforeAnimationsObserver;
  47269. private _onBeforeParticlesRenderingObserver;
  47270. private _onAfterParticlesRenderingObserver;
  47271. private _onBeforeSpritesRenderingObserver;
  47272. private _onAfterSpritesRenderingObserver;
  47273. private _onBeforePhysicsObserver;
  47274. private _onAfterPhysicsObserver;
  47275. private _onAfterAnimationsObserver;
  47276. private _onBeforeCameraRenderObserver;
  47277. private _onAfterCameraRenderObserver;
  47278. /**
  47279. * Gets the perf counter used for active meshes evaluation time
  47280. */
  47281. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47282. /**
  47283. * Gets the active meshes evaluation time capture status
  47284. */
  47285. /**
  47286. * Enable or disable the active meshes evaluation time capture
  47287. */
  47288. captureActiveMeshesEvaluationTime: boolean;
  47289. /**
  47290. * Gets the perf counter used for render targets render time
  47291. */
  47292. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47293. /**
  47294. * Gets the render targets render time capture status
  47295. */
  47296. /**
  47297. * Enable or disable the render targets render time capture
  47298. */
  47299. captureRenderTargetsRenderTime: boolean;
  47300. /**
  47301. * Gets the perf counter used for particles render time
  47302. */
  47303. readonly particlesRenderTimeCounter: PerfCounter;
  47304. /**
  47305. * Gets the particles render time capture status
  47306. */
  47307. /**
  47308. * Enable or disable the particles render time capture
  47309. */
  47310. captureParticlesRenderTime: boolean;
  47311. /**
  47312. * Gets the perf counter used for sprites render time
  47313. */
  47314. readonly spritesRenderTimeCounter: PerfCounter;
  47315. /**
  47316. * Gets the sprites render time capture status
  47317. */
  47318. /**
  47319. * Enable or disable the sprites render time capture
  47320. */
  47321. captureSpritesRenderTime: boolean;
  47322. /**
  47323. * Gets the perf counter used for physics time
  47324. */
  47325. readonly physicsTimeCounter: PerfCounter;
  47326. /**
  47327. * Gets the physics time capture status
  47328. */
  47329. /**
  47330. * Enable or disable the physics time capture
  47331. */
  47332. capturePhysicsTime: boolean;
  47333. /**
  47334. * Gets the perf counter used for animations time
  47335. */
  47336. readonly animationsTimeCounter: PerfCounter;
  47337. /**
  47338. * Gets the animations time capture status
  47339. */
  47340. /**
  47341. * Enable or disable the animations time capture
  47342. */
  47343. captureAnimationsTime: boolean;
  47344. /**
  47345. * Gets the perf counter used for frame time capture
  47346. */
  47347. readonly frameTimeCounter: PerfCounter;
  47348. /**
  47349. * Gets the frame time capture status
  47350. */
  47351. /**
  47352. * Enable or disable the frame time capture
  47353. */
  47354. captureFrameTime: boolean;
  47355. /**
  47356. * Gets the perf counter used for inter-frames time capture
  47357. */
  47358. readonly interFrameTimeCounter: PerfCounter;
  47359. /**
  47360. * Gets the inter-frames time capture status
  47361. */
  47362. /**
  47363. * Enable or disable the inter-frames time capture
  47364. */
  47365. captureInterFrameTime: boolean;
  47366. /**
  47367. * Gets the perf counter used for render time capture
  47368. */
  47369. readonly renderTimeCounter: PerfCounter;
  47370. /**
  47371. * Gets the render time capture status
  47372. */
  47373. /**
  47374. * Enable or disable the render time capture
  47375. */
  47376. captureRenderTime: boolean;
  47377. /**
  47378. * Gets the perf counter used for camera render time capture
  47379. */
  47380. readonly cameraRenderTimeCounter: PerfCounter;
  47381. /**
  47382. * Gets the camera render time capture status
  47383. */
  47384. /**
  47385. * Enable or disable the camera render time capture
  47386. */
  47387. captureCameraRenderTime: boolean;
  47388. /**
  47389. * Gets the perf counter used for draw calls
  47390. */
  47391. readonly drawCallsCounter: PerfCounter;
  47392. /**
  47393. * Instantiates a new scene instrumentation.
  47394. * This class can be used to get instrumentation data from a Babylon engine
  47395. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47396. * @param scene Defines the scene to instrument
  47397. */
  47398. constructor(
  47399. /**
  47400. * Defines the scene to instrument
  47401. */
  47402. scene: Scene);
  47403. /**
  47404. * Dispose and release associated resources.
  47405. */
  47406. dispose(): void;
  47407. }
  47408. }
  47409. declare module BABYLON {
  47410. /** @hidden */
  47411. export var glowMapGenerationPixelShader: {
  47412. name: string;
  47413. shader: string;
  47414. };
  47415. }
  47416. declare module BABYLON {
  47417. /** @hidden */
  47418. export var glowMapGenerationVertexShader: {
  47419. name: string;
  47420. shader: string;
  47421. };
  47422. }
  47423. declare module BABYLON {
  47424. /**
  47425. * Effect layer options. This helps customizing the behaviour
  47426. * of the effect layer.
  47427. */
  47428. export interface IEffectLayerOptions {
  47429. /**
  47430. * Multiplication factor apply to the canvas size to compute the render target size
  47431. * used to generated the objects (the smaller the faster).
  47432. */
  47433. mainTextureRatio: number;
  47434. /**
  47435. * Enforces a fixed size texture to ensure effect stability across devices.
  47436. */
  47437. mainTextureFixedSize?: number;
  47438. /**
  47439. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47440. */
  47441. alphaBlendingMode: number;
  47442. /**
  47443. * The camera attached to the layer.
  47444. */
  47445. camera: Nullable<Camera>;
  47446. /**
  47447. * The rendering group to draw the layer in.
  47448. */
  47449. renderingGroupId: number;
  47450. }
  47451. /**
  47452. * The effect layer Helps adding post process effect blended with the main pass.
  47453. *
  47454. * This can be for instance use to generate glow or higlight effects on the scene.
  47455. *
  47456. * The effect layer class can not be used directly and is intented to inherited from to be
  47457. * customized per effects.
  47458. */
  47459. export abstract class EffectLayer {
  47460. private _vertexBuffers;
  47461. private _indexBuffer;
  47462. private _cachedDefines;
  47463. private _effectLayerMapGenerationEffect;
  47464. private _effectLayerOptions;
  47465. private _mergeEffect;
  47466. protected _scene: Scene;
  47467. protected _engine: Engine;
  47468. protected _maxSize: number;
  47469. protected _mainTextureDesiredSize: ISize;
  47470. protected _mainTexture: RenderTargetTexture;
  47471. protected _shouldRender: boolean;
  47472. protected _postProcesses: PostProcess[];
  47473. protected _textures: BaseTexture[];
  47474. protected _emissiveTextureAndColor: {
  47475. texture: Nullable<BaseTexture>;
  47476. color: Color4;
  47477. };
  47478. /**
  47479. * The name of the layer
  47480. */
  47481. name: string;
  47482. /**
  47483. * The clear color of the texture used to generate the glow map.
  47484. */
  47485. neutralColor: Color4;
  47486. /**
  47487. * Specifies wether the highlight layer is enabled or not.
  47488. */
  47489. isEnabled: boolean;
  47490. /**
  47491. * Gets the camera attached to the layer.
  47492. */
  47493. readonly camera: Nullable<Camera>;
  47494. /**
  47495. * Gets the rendering group id the layer should render in.
  47496. */
  47497. readonly renderingGroupId: number;
  47498. /**
  47499. * An event triggered when the effect layer has been disposed.
  47500. */
  47501. onDisposeObservable: Observable<EffectLayer>;
  47502. /**
  47503. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47504. */
  47505. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47506. /**
  47507. * An event triggered when the generated texture is being merged in the scene.
  47508. */
  47509. onBeforeComposeObservable: Observable<EffectLayer>;
  47510. /**
  47511. * An event triggered when the generated texture has been merged in the scene.
  47512. */
  47513. onAfterComposeObservable: Observable<EffectLayer>;
  47514. /**
  47515. * An event triggered when the efffect layer changes its size.
  47516. */
  47517. onSizeChangedObservable: Observable<EffectLayer>;
  47518. /** @hidden */
  47519. static _SceneComponentInitialization: (scene: Scene) => void;
  47520. /**
  47521. * Instantiates a new effect Layer and references it in the scene.
  47522. * @param name The name of the layer
  47523. * @param scene The scene to use the layer in
  47524. */
  47525. constructor(
  47526. /** The Friendly of the effect in the scene */
  47527. name: string, scene: Scene);
  47528. /**
  47529. * Get the effect name of the layer.
  47530. * @return The effect name
  47531. */
  47532. abstract getEffectName(): string;
  47533. /**
  47534. * Checks for the readiness of the element composing the layer.
  47535. * @param subMesh the mesh to check for
  47536. * @param useInstances specify wether or not to use instances to render the mesh
  47537. * @return true if ready otherwise, false
  47538. */
  47539. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47540. /**
  47541. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47542. * @returns true if the effect requires stencil during the main canvas render pass.
  47543. */
  47544. abstract needStencil(): boolean;
  47545. /**
  47546. * Create the merge effect. This is the shader use to blit the information back
  47547. * to the main canvas at the end of the scene rendering.
  47548. * @returns The effect containing the shader used to merge the effect on the main canvas
  47549. */
  47550. protected abstract _createMergeEffect(): Effect;
  47551. /**
  47552. * Creates the render target textures and post processes used in the effect layer.
  47553. */
  47554. protected abstract _createTextureAndPostProcesses(): void;
  47555. /**
  47556. * Implementation specific of rendering the generating effect on the main canvas.
  47557. * @param effect The effect used to render through
  47558. */
  47559. protected abstract _internalRender(effect: Effect): void;
  47560. /**
  47561. * Sets the required values for both the emissive texture and and the main color.
  47562. */
  47563. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47564. /**
  47565. * Free any resources and references associated to a mesh.
  47566. * Internal use
  47567. * @param mesh The mesh to free.
  47568. */
  47569. abstract _disposeMesh(mesh: Mesh): void;
  47570. /**
  47571. * Serializes this layer (Glow or Highlight for example)
  47572. * @returns a serialized layer object
  47573. */
  47574. abstract serialize?(): any;
  47575. /**
  47576. * Initializes the effect layer with the required options.
  47577. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47578. */
  47579. protected _init(options: Partial<IEffectLayerOptions>): void;
  47580. /**
  47581. * Generates the index buffer of the full screen quad blending to the main canvas.
  47582. */
  47583. private _generateIndexBuffer;
  47584. /**
  47585. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47586. */
  47587. private _generateVertexBuffer;
  47588. /**
  47589. * Sets the main texture desired size which is the closest power of two
  47590. * of the engine canvas size.
  47591. */
  47592. private _setMainTextureSize;
  47593. /**
  47594. * Creates the main texture for the effect layer.
  47595. */
  47596. protected _createMainTexture(): void;
  47597. /**
  47598. * Adds specific effects defines.
  47599. * @param defines The defines to add specifics to.
  47600. */
  47601. protected _addCustomEffectDefines(defines: string[]): void;
  47602. /**
  47603. * Checks for the readiness of the element composing the layer.
  47604. * @param subMesh the mesh to check for
  47605. * @param useInstances specify wether or not to use instances to render the mesh
  47606. * @param emissiveTexture the associated emissive texture used to generate the glow
  47607. * @return true if ready otherwise, false
  47608. */
  47609. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47610. /**
  47611. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47612. */
  47613. render(): void;
  47614. /**
  47615. * Determine if a given mesh will be used in the current effect.
  47616. * @param mesh mesh to test
  47617. * @returns true if the mesh will be used
  47618. */
  47619. hasMesh(mesh: AbstractMesh): boolean;
  47620. /**
  47621. * Returns true if the layer contains information to display, otherwise false.
  47622. * @returns true if the glow layer should be rendered
  47623. */
  47624. shouldRender(): boolean;
  47625. /**
  47626. * Returns true if the mesh should render, otherwise false.
  47627. * @param mesh The mesh to render
  47628. * @returns true if it should render otherwise false
  47629. */
  47630. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47631. /**
  47632. * Returns true if the mesh can be rendered, otherwise false.
  47633. * @param mesh The mesh to render
  47634. * @param material The material used on the mesh
  47635. * @returns true if it can be rendered otherwise false
  47636. */
  47637. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47638. /**
  47639. * Returns true if the mesh should render, otherwise false.
  47640. * @param mesh The mesh to render
  47641. * @returns true if it should render otherwise false
  47642. */
  47643. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47644. /**
  47645. * Renders the submesh passed in parameter to the generation map.
  47646. */
  47647. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47648. /**
  47649. * Rebuild the required buffers.
  47650. * @hidden Internal use only.
  47651. */
  47652. _rebuild(): void;
  47653. /**
  47654. * Dispose only the render target textures and post process.
  47655. */
  47656. private _disposeTextureAndPostProcesses;
  47657. /**
  47658. * Dispose the highlight layer and free resources.
  47659. */
  47660. dispose(): void;
  47661. /**
  47662. * Gets the class name of the effect layer
  47663. * @returns the string with the class name of the effect layer
  47664. */
  47665. getClassName(): string;
  47666. /**
  47667. * Creates an effect layer from parsed effect layer data
  47668. * @param parsedEffectLayer defines effect layer data
  47669. * @param scene defines the current scene
  47670. * @param rootUrl defines the root URL containing the effect layer information
  47671. * @returns a parsed effect Layer
  47672. */
  47673. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47674. }
  47675. }
  47676. declare module BABYLON {
  47677. interface AbstractScene {
  47678. /**
  47679. * The list of effect layers (highlights/glow) added to the scene
  47680. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47681. * @see http://doc.babylonjs.com/how_to/glow_layer
  47682. */
  47683. effectLayers: Array<EffectLayer>;
  47684. /**
  47685. * Removes the given effect layer from this scene.
  47686. * @param toRemove defines the effect layer to remove
  47687. * @returns the index of the removed effect layer
  47688. */
  47689. removeEffectLayer(toRemove: EffectLayer): number;
  47690. /**
  47691. * Adds the given effect layer to this scene
  47692. * @param newEffectLayer defines the effect layer to add
  47693. */
  47694. addEffectLayer(newEffectLayer: EffectLayer): void;
  47695. }
  47696. /**
  47697. * Defines the layer scene component responsible to manage any effect layers
  47698. * in a given scene.
  47699. */
  47700. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47701. /**
  47702. * The component name helpfull to identify the component in the list of scene components.
  47703. */
  47704. readonly name: string;
  47705. /**
  47706. * The scene the component belongs to.
  47707. */
  47708. scene: Scene;
  47709. private _engine;
  47710. private _renderEffects;
  47711. private _needStencil;
  47712. private _previousStencilState;
  47713. /**
  47714. * Creates a new instance of the component for the given scene
  47715. * @param scene Defines the scene to register the component in
  47716. */
  47717. constructor(scene: Scene);
  47718. /**
  47719. * Registers the component in a given scene
  47720. */
  47721. register(): void;
  47722. /**
  47723. * Rebuilds the elements related to this component in case of
  47724. * context lost for instance.
  47725. */
  47726. rebuild(): void;
  47727. /**
  47728. * Serializes the component data to the specified json object
  47729. * @param serializationObject The object to serialize to
  47730. */
  47731. serialize(serializationObject: any): void;
  47732. /**
  47733. * Adds all the elements from the container to the scene
  47734. * @param container the container holding the elements
  47735. */
  47736. addFromContainer(container: AbstractScene): void;
  47737. /**
  47738. * Removes all the elements in the container from the scene
  47739. * @param container contains the elements to remove
  47740. * @param dispose if the removed element should be disposed (default: false)
  47741. */
  47742. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47743. /**
  47744. * Disposes the component and the associated ressources.
  47745. */
  47746. dispose(): void;
  47747. private _isReadyForMesh;
  47748. private _renderMainTexture;
  47749. private _setStencil;
  47750. private _setStencilBack;
  47751. private _draw;
  47752. private _drawCamera;
  47753. private _drawRenderingGroup;
  47754. }
  47755. }
  47756. declare module BABYLON {
  47757. /** @hidden */
  47758. export var glowMapMergePixelShader: {
  47759. name: string;
  47760. shader: string;
  47761. };
  47762. }
  47763. declare module BABYLON {
  47764. /** @hidden */
  47765. export var glowMapMergeVertexShader: {
  47766. name: string;
  47767. shader: string;
  47768. };
  47769. }
  47770. declare module BABYLON {
  47771. interface AbstractScene {
  47772. /**
  47773. * Return a the first highlight layer of the scene with a given name.
  47774. * @param name The name of the highlight layer to look for.
  47775. * @return The highlight layer if found otherwise null.
  47776. */
  47777. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47778. }
  47779. /**
  47780. * Glow layer options. This helps customizing the behaviour
  47781. * of the glow layer.
  47782. */
  47783. export interface IGlowLayerOptions {
  47784. /**
  47785. * Multiplication factor apply to the canvas size to compute the render target size
  47786. * used to generated the glowing objects (the smaller the faster).
  47787. */
  47788. mainTextureRatio: number;
  47789. /**
  47790. * Enforces a fixed size texture to ensure resize independant blur.
  47791. */
  47792. mainTextureFixedSize?: number;
  47793. /**
  47794. * How big is the kernel of the blur texture.
  47795. */
  47796. blurKernelSize: number;
  47797. /**
  47798. * The camera attached to the layer.
  47799. */
  47800. camera: Nullable<Camera>;
  47801. /**
  47802. * Enable MSAA by chosing the number of samples.
  47803. */
  47804. mainTextureSamples?: number;
  47805. /**
  47806. * The rendering group to draw the layer in.
  47807. */
  47808. renderingGroupId: number;
  47809. }
  47810. /**
  47811. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47812. *
  47813. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47814. * glowy meshes to your scene.
  47815. *
  47816. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47817. */
  47818. export class GlowLayer extends EffectLayer {
  47819. /**
  47820. * Effect Name of the layer.
  47821. */
  47822. static readonly EffectName: string;
  47823. /**
  47824. * The default blur kernel size used for the glow.
  47825. */
  47826. static DefaultBlurKernelSize: number;
  47827. /**
  47828. * The default texture size ratio used for the glow.
  47829. */
  47830. static DefaultTextureRatio: number;
  47831. /**
  47832. * Sets the kernel size of the blur.
  47833. */
  47834. /**
  47835. * Gets the kernel size of the blur.
  47836. */
  47837. blurKernelSize: number;
  47838. /**
  47839. * Sets the glow intensity.
  47840. */
  47841. /**
  47842. * Gets the glow intensity.
  47843. */
  47844. intensity: number;
  47845. private _options;
  47846. private _intensity;
  47847. private _horizontalBlurPostprocess1;
  47848. private _verticalBlurPostprocess1;
  47849. private _horizontalBlurPostprocess2;
  47850. private _verticalBlurPostprocess2;
  47851. private _blurTexture1;
  47852. private _blurTexture2;
  47853. private _postProcesses1;
  47854. private _postProcesses2;
  47855. private _includedOnlyMeshes;
  47856. private _excludedMeshes;
  47857. /**
  47858. * Callback used to let the user override the color selection on a per mesh basis
  47859. */
  47860. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47861. /**
  47862. * Callback used to let the user override the texture selection on a per mesh basis
  47863. */
  47864. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47865. /**
  47866. * Instantiates a new glow Layer and references it to the scene.
  47867. * @param name The name of the layer
  47868. * @param scene The scene to use the layer in
  47869. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47870. */
  47871. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47872. /**
  47873. * Get the effect name of the layer.
  47874. * @return The effect name
  47875. */
  47876. getEffectName(): string;
  47877. /**
  47878. * Create the merge effect. This is the shader use to blit the information back
  47879. * to the main canvas at the end of the scene rendering.
  47880. */
  47881. protected _createMergeEffect(): Effect;
  47882. /**
  47883. * Creates the render target textures and post processes used in the glow layer.
  47884. */
  47885. protected _createTextureAndPostProcesses(): void;
  47886. /**
  47887. * Checks for the readiness of the element composing the layer.
  47888. * @param subMesh the mesh to check for
  47889. * @param useInstances specify wether or not to use instances to render the mesh
  47890. * @param emissiveTexture the associated emissive texture used to generate the glow
  47891. * @return true if ready otherwise, false
  47892. */
  47893. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47894. /**
  47895. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47896. */
  47897. needStencil(): boolean;
  47898. /**
  47899. * Returns true if the mesh can be rendered, otherwise false.
  47900. * @param mesh The mesh to render
  47901. * @param material The material used on the mesh
  47902. * @returns true if it can be rendered otherwise false
  47903. */
  47904. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47905. /**
  47906. * Implementation specific of rendering the generating effect on the main canvas.
  47907. * @param effect The effect used to render through
  47908. */
  47909. protected _internalRender(effect: Effect): void;
  47910. /**
  47911. * Sets the required values for both the emissive texture and and the main color.
  47912. */
  47913. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47914. /**
  47915. * Returns true if the mesh should render, otherwise false.
  47916. * @param mesh The mesh to render
  47917. * @returns true if it should render otherwise false
  47918. */
  47919. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47920. /**
  47921. * Adds specific effects defines.
  47922. * @param defines The defines to add specifics to.
  47923. */
  47924. protected _addCustomEffectDefines(defines: string[]): void;
  47925. /**
  47926. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47927. * @param mesh The mesh to exclude from the glow layer
  47928. */
  47929. addExcludedMesh(mesh: Mesh): void;
  47930. /**
  47931. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47932. * @param mesh The mesh to remove
  47933. */
  47934. removeExcludedMesh(mesh: Mesh): void;
  47935. /**
  47936. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47937. * @param mesh The mesh to include in the glow layer
  47938. */
  47939. addIncludedOnlyMesh(mesh: Mesh): void;
  47940. /**
  47941. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47942. * @param mesh The mesh to remove
  47943. */
  47944. removeIncludedOnlyMesh(mesh: Mesh): void;
  47945. /**
  47946. * Determine if a given mesh will be used in the glow layer
  47947. * @param mesh The mesh to test
  47948. * @returns true if the mesh will be highlighted by the current glow layer
  47949. */
  47950. hasMesh(mesh: AbstractMesh): boolean;
  47951. /**
  47952. * Free any resources and references associated to a mesh.
  47953. * Internal use
  47954. * @param mesh The mesh to free.
  47955. * @hidden
  47956. */
  47957. _disposeMesh(mesh: Mesh): void;
  47958. /**
  47959. * Gets the class name of the effect layer
  47960. * @returns the string with the class name of the effect layer
  47961. */
  47962. getClassName(): string;
  47963. /**
  47964. * Serializes this glow layer
  47965. * @returns a serialized glow layer object
  47966. */
  47967. serialize(): any;
  47968. /**
  47969. * Creates a Glow Layer from parsed glow layer data
  47970. * @param parsedGlowLayer defines glow layer data
  47971. * @param scene defines the current scene
  47972. * @param rootUrl defines the root URL containing the glow layer information
  47973. * @returns a parsed Glow Layer
  47974. */
  47975. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47976. }
  47977. }
  47978. declare module BABYLON {
  47979. /** @hidden */
  47980. export var glowBlurPostProcessPixelShader: {
  47981. name: string;
  47982. shader: string;
  47983. };
  47984. }
  47985. declare module BABYLON {
  47986. interface AbstractScene {
  47987. /**
  47988. * Return a the first highlight layer of the scene with a given name.
  47989. * @param name The name of the highlight layer to look for.
  47990. * @return The highlight layer if found otherwise null.
  47991. */
  47992. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47993. }
  47994. /**
  47995. * Highlight layer options. This helps customizing the behaviour
  47996. * of the highlight layer.
  47997. */
  47998. export interface IHighlightLayerOptions {
  47999. /**
  48000. * Multiplication factor apply to the canvas size to compute the render target size
  48001. * used to generated the glowing objects (the smaller the faster).
  48002. */
  48003. mainTextureRatio: number;
  48004. /**
  48005. * Enforces a fixed size texture to ensure resize independant blur.
  48006. */
  48007. mainTextureFixedSize?: number;
  48008. /**
  48009. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48010. * of the picture to blur (the smaller the faster).
  48011. */
  48012. blurTextureSizeRatio: number;
  48013. /**
  48014. * How big in texel of the blur texture is the vertical blur.
  48015. */
  48016. blurVerticalSize: number;
  48017. /**
  48018. * How big in texel of the blur texture is the horizontal blur.
  48019. */
  48020. blurHorizontalSize: number;
  48021. /**
  48022. * Alpha blending mode used to apply the blur. Default is combine.
  48023. */
  48024. alphaBlendingMode: number;
  48025. /**
  48026. * The camera attached to the layer.
  48027. */
  48028. camera: Nullable<Camera>;
  48029. /**
  48030. * Should we display highlight as a solid stroke?
  48031. */
  48032. isStroke?: boolean;
  48033. /**
  48034. * The rendering group to draw the layer in.
  48035. */
  48036. renderingGroupId: number;
  48037. }
  48038. /**
  48039. * The highlight layer Helps adding a glow effect around a mesh.
  48040. *
  48041. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48042. * glowy meshes to your scene.
  48043. *
  48044. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48045. */
  48046. export class HighlightLayer extends EffectLayer {
  48047. name: string;
  48048. /**
  48049. * Effect Name of the highlight layer.
  48050. */
  48051. static readonly EffectName: string;
  48052. /**
  48053. * The neutral color used during the preparation of the glow effect.
  48054. * This is black by default as the blend operation is a blend operation.
  48055. */
  48056. static NeutralColor: Color4;
  48057. /**
  48058. * Stencil value used for glowing meshes.
  48059. */
  48060. static GlowingMeshStencilReference: number;
  48061. /**
  48062. * Stencil value used for the other meshes in the scene.
  48063. */
  48064. static NormalMeshStencilReference: number;
  48065. /**
  48066. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48067. */
  48068. innerGlow: boolean;
  48069. /**
  48070. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48071. */
  48072. outerGlow: boolean;
  48073. /**
  48074. * Specifies the horizontal size of the blur.
  48075. */
  48076. /**
  48077. * Gets the horizontal size of the blur.
  48078. */
  48079. blurHorizontalSize: number;
  48080. /**
  48081. * Specifies the vertical size of the blur.
  48082. */
  48083. /**
  48084. * Gets the vertical size of the blur.
  48085. */
  48086. blurVerticalSize: number;
  48087. /**
  48088. * An event triggered when the highlight layer is being blurred.
  48089. */
  48090. onBeforeBlurObservable: Observable<HighlightLayer>;
  48091. /**
  48092. * An event triggered when the highlight layer has been blurred.
  48093. */
  48094. onAfterBlurObservable: Observable<HighlightLayer>;
  48095. private _instanceGlowingMeshStencilReference;
  48096. private _options;
  48097. private _downSamplePostprocess;
  48098. private _horizontalBlurPostprocess;
  48099. private _verticalBlurPostprocess;
  48100. private _blurTexture;
  48101. private _meshes;
  48102. private _excludedMeshes;
  48103. /**
  48104. * Instantiates a new highlight Layer and references it to the scene..
  48105. * @param name The name of the layer
  48106. * @param scene The scene to use the layer in
  48107. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48108. */
  48109. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48110. /**
  48111. * Get the effect name of the layer.
  48112. * @return The effect name
  48113. */
  48114. getEffectName(): string;
  48115. /**
  48116. * Create the merge effect. This is the shader use to blit the information back
  48117. * to the main canvas at the end of the scene rendering.
  48118. */
  48119. protected _createMergeEffect(): Effect;
  48120. /**
  48121. * Creates the render target textures and post processes used in the highlight layer.
  48122. */
  48123. protected _createTextureAndPostProcesses(): void;
  48124. /**
  48125. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48126. */
  48127. needStencil(): boolean;
  48128. /**
  48129. * Checks for the readiness of the element composing the layer.
  48130. * @param subMesh the mesh to check for
  48131. * @param useInstances specify wether or not to use instances to render the mesh
  48132. * @param emissiveTexture the associated emissive texture used to generate the glow
  48133. * @return true if ready otherwise, false
  48134. */
  48135. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48136. /**
  48137. * Implementation specific of rendering the generating effect on the main canvas.
  48138. * @param effect The effect used to render through
  48139. */
  48140. protected _internalRender(effect: Effect): void;
  48141. /**
  48142. * Returns true if the layer contains information to display, otherwise false.
  48143. */
  48144. shouldRender(): boolean;
  48145. /**
  48146. * Returns true if the mesh should render, otherwise false.
  48147. * @param mesh The mesh to render
  48148. * @returns true if it should render otherwise false
  48149. */
  48150. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48151. /**
  48152. * Sets the required values for both the emissive texture and and the main color.
  48153. */
  48154. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48155. /**
  48156. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48157. * @param mesh The mesh to exclude from the highlight layer
  48158. */
  48159. addExcludedMesh(mesh: Mesh): void;
  48160. /**
  48161. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48162. * @param mesh The mesh to highlight
  48163. */
  48164. removeExcludedMesh(mesh: Mesh): void;
  48165. /**
  48166. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48167. * @param mesh mesh to test
  48168. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48169. */
  48170. hasMesh(mesh: AbstractMesh): boolean;
  48171. /**
  48172. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48173. * @param mesh The mesh to highlight
  48174. * @param color The color of the highlight
  48175. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48176. */
  48177. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48178. /**
  48179. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48180. * @param mesh The mesh to highlight
  48181. */
  48182. removeMesh(mesh: Mesh): void;
  48183. /**
  48184. * Force the stencil to the normal expected value for none glowing parts
  48185. */
  48186. private _defaultStencilReference;
  48187. /**
  48188. * Free any resources and references associated to a mesh.
  48189. * Internal use
  48190. * @param mesh The mesh to free.
  48191. * @hidden
  48192. */
  48193. _disposeMesh(mesh: Mesh): void;
  48194. /**
  48195. * Dispose the highlight layer and free resources.
  48196. */
  48197. dispose(): void;
  48198. /**
  48199. * Gets the class name of the effect layer
  48200. * @returns the string with the class name of the effect layer
  48201. */
  48202. getClassName(): string;
  48203. /**
  48204. * Serializes this Highlight layer
  48205. * @returns a serialized Highlight layer object
  48206. */
  48207. serialize(): any;
  48208. /**
  48209. * Creates a Highlight layer from parsed Highlight layer data
  48210. * @param parsedHightlightLayer defines the Highlight layer data
  48211. * @param scene defines the current scene
  48212. * @param rootUrl defines the root URL containing the Highlight layer information
  48213. * @returns a parsed Highlight layer
  48214. */
  48215. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48216. }
  48217. }
  48218. declare module BABYLON {
  48219. interface AbstractScene {
  48220. /**
  48221. * The list of layers (background and foreground) of the scene
  48222. */
  48223. layers: Array<Layer>;
  48224. }
  48225. /**
  48226. * Defines the layer scene component responsible to manage any layers
  48227. * in a given scene.
  48228. */
  48229. export class LayerSceneComponent implements ISceneComponent {
  48230. /**
  48231. * The component name helpfull to identify the component in the list of scene components.
  48232. */
  48233. readonly name: string;
  48234. /**
  48235. * The scene the component belongs to.
  48236. */
  48237. scene: Scene;
  48238. private _engine;
  48239. /**
  48240. * Creates a new instance of the component for the given scene
  48241. * @param scene Defines the scene to register the component in
  48242. */
  48243. constructor(scene: Scene);
  48244. /**
  48245. * Registers the component in a given scene
  48246. */
  48247. register(): void;
  48248. /**
  48249. * Rebuilds the elements related to this component in case of
  48250. * context lost for instance.
  48251. */
  48252. rebuild(): void;
  48253. /**
  48254. * Disposes the component and the associated ressources.
  48255. */
  48256. dispose(): void;
  48257. private _draw;
  48258. private _drawCameraPredicate;
  48259. private _drawCameraBackground;
  48260. private _drawCameraForeground;
  48261. private _drawRenderTargetPredicate;
  48262. private _drawRenderTargetBackground;
  48263. private _drawRenderTargetForeground;
  48264. /**
  48265. * Adds all the elements from the container to the scene
  48266. * @param container the container holding the elements
  48267. */
  48268. addFromContainer(container: AbstractScene): void;
  48269. /**
  48270. * Removes all the elements in the container from the scene
  48271. * @param container contains the elements to remove
  48272. * @param dispose if the removed element should be disposed (default: false)
  48273. */
  48274. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48275. }
  48276. }
  48277. declare module BABYLON {
  48278. /** @hidden */
  48279. export var layerPixelShader: {
  48280. name: string;
  48281. shader: string;
  48282. };
  48283. }
  48284. declare module BABYLON {
  48285. /** @hidden */
  48286. export var layerVertexShader: {
  48287. name: string;
  48288. shader: string;
  48289. };
  48290. }
  48291. declare module BABYLON {
  48292. /**
  48293. * This represents a full screen 2d layer.
  48294. * This can be useful to display a picture in the background of your scene for instance.
  48295. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48296. */
  48297. export class Layer {
  48298. /**
  48299. * Define the name of the layer.
  48300. */
  48301. name: string;
  48302. /**
  48303. * Define the texture the layer should display.
  48304. */
  48305. texture: Nullable<Texture>;
  48306. /**
  48307. * Is the layer in background or foreground.
  48308. */
  48309. isBackground: boolean;
  48310. /**
  48311. * Define the color of the layer (instead of texture).
  48312. */
  48313. color: Color4;
  48314. /**
  48315. * Define the scale of the layer in order to zoom in out of the texture.
  48316. */
  48317. scale: Vector2;
  48318. /**
  48319. * Define an offset for the layer in order to shift the texture.
  48320. */
  48321. offset: Vector2;
  48322. /**
  48323. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48324. */
  48325. alphaBlendingMode: number;
  48326. /**
  48327. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48328. * Alpha test will not mix with the background color in case of transparency.
  48329. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48330. */
  48331. alphaTest: boolean;
  48332. /**
  48333. * Define a mask to restrict the layer to only some of the scene cameras.
  48334. */
  48335. layerMask: number;
  48336. /**
  48337. * Define the list of render target the layer is visible into.
  48338. */
  48339. renderTargetTextures: RenderTargetTexture[];
  48340. /**
  48341. * Define if the layer is only used in renderTarget or if it also
  48342. * renders in the main frame buffer of the canvas.
  48343. */
  48344. renderOnlyInRenderTargetTextures: boolean;
  48345. private _scene;
  48346. private _vertexBuffers;
  48347. private _indexBuffer;
  48348. private _effect;
  48349. private _alphaTestEffect;
  48350. /**
  48351. * An event triggered when the layer is disposed.
  48352. */
  48353. onDisposeObservable: Observable<Layer>;
  48354. private _onDisposeObserver;
  48355. /**
  48356. * Back compatibility with callback before the onDisposeObservable existed.
  48357. * The set callback will be triggered when the layer has been disposed.
  48358. */
  48359. onDispose: () => void;
  48360. /**
  48361. * An event triggered before rendering the scene
  48362. */
  48363. onBeforeRenderObservable: Observable<Layer>;
  48364. private _onBeforeRenderObserver;
  48365. /**
  48366. * Back compatibility with callback before the onBeforeRenderObservable existed.
  48367. * The set callback will be triggered just before rendering the layer.
  48368. */
  48369. onBeforeRender: () => void;
  48370. /**
  48371. * An event triggered after rendering the scene
  48372. */
  48373. onAfterRenderObservable: Observable<Layer>;
  48374. private _onAfterRenderObserver;
  48375. /**
  48376. * Back compatibility with callback before the onAfterRenderObservable existed.
  48377. * The set callback will be triggered just after rendering the layer.
  48378. */
  48379. onAfterRender: () => void;
  48380. /**
  48381. * Instantiates a new layer.
  48382. * This represents a full screen 2d layer.
  48383. * This can be useful to display a picture in the background of your scene for instance.
  48384. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48385. * @param name Define the name of the layer in the scene
  48386. * @param imgUrl Define the url of the texture to display in the layer
  48387. * @param scene Define the scene the layer belongs to
  48388. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  48389. * @param color Defines a color for the layer
  48390. */
  48391. constructor(
  48392. /**
  48393. * Define the name of the layer.
  48394. */
  48395. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  48396. private _createIndexBuffer;
  48397. /** @hidden */
  48398. _rebuild(): void;
  48399. /**
  48400. * Renders the layer in the scene.
  48401. */
  48402. render(): void;
  48403. /**
  48404. * Disposes and releases the associated ressources.
  48405. */
  48406. dispose(): void;
  48407. }
  48408. }
  48409. declare module BABYLON {
  48410. /** @hidden */
  48411. export var lensFlarePixelShader: {
  48412. name: string;
  48413. shader: string;
  48414. };
  48415. }
  48416. declare module BABYLON {
  48417. /** @hidden */
  48418. export var lensFlareVertexShader: {
  48419. name: string;
  48420. shader: string;
  48421. };
  48422. }
  48423. declare module BABYLON {
  48424. /**
  48425. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48426. * It is usually composed of several `lensFlare`.
  48427. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48428. */
  48429. export class LensFlareSystem {
  48430. /**
  48431. * Define the name of the lens flare system
  48432. */
  48433. name: string;
  48434. /**
  48435. * List of lens flares used in this system.
  48436. */
  48437. lensFlares: LensFlare[];
  48438. /**
  48439. * Define a limit from the border the lens flare can be visible.
  48440. */
  48441. borderLimit: number;
  48442. /**
  48443. * Define a viewport border we do not want to see the lens flare in.
  48444. */
  48445. viewportBorder: number;
  48446. /**
  48447. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48448. */
  48449. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48450. /**
  48451. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48452. */
  48453. layerMask: number;
  48454. /**
  48455. * Define the id of the lens flare system in the scene.
  48456. * (equal to name by default)
  48457. */
  48458. id: string;
  48459. private _scene;
  48460. private _emitter;
  48461. private _vertexBuffers;
  48462. private _indexBuffer;
  48463. private _effect;
  48464. private _positionX;
  48465. private _positionY;
  48466. private _isEnabled;
  48467. /** @hidden */
  48468. static _SceneComponentInitialization: (scene: Scene) => void;
  48469. /**
  48470. * Instantiates a lens flare system.
  48471. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48472. * It is usually composed of several `lensFlare`.
  48473. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48474. * @param name Define the name of the lens flare system in the scene
  48475. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48476. * @param scene Define the scene the lens flare system belongs to
  48477. */
  48478. constructor(
  48479. /**
  48480. * Define the name of the lens flare system
  48481. */
  48482. name: string, emitter: any, scene: Scene);
  48483. /**
  48484. * Define if the lens flare system is enabled.
  48485. */
  48486. isEnabled: boolean;
  48487. /**
  48488. * Get the scene the effects belongs to.
  48489. * @returns the scene holding the lens flare system
  48490. */
  48491. getScene(): Scene;
  48492. /**
  48493. * Get the emitter of the lens flare system.
  48494. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48495. * @returns the emitter of the lens flare system
  48496. */
  48497. getEmitter(): any;
  48498. /**
  48499. * Set the emitter of the lens flare system.
  48500. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48501. * @param newEmitter Define the new emitter of the system
  48502. */
  48503. setEmitter(newEmitter: any): void;
  48504. /**
  48505. * Get the lens flare system emitter position.
  48506. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48507. * @returns the position
  48508. */
  48509. getEmitterPosition(): Vector3;
  48510. /**
  48511. * @hidden
  48512. */
  48513. computeEffectivePosition(globalViewport: Viewport): boolean;
  48514. /** @hidden */
  48515. _isVisible(): boolean;
  48516. /**
  48517. * @hidden
  48518. */
  48519. render(): boolean;
  48520. /**
  48521. * Dispose and release the lens flare with its associated resources.
  48522. */
  48523. dispose(): void;
  48524. /**
  48525. * Parse a lens flare system from a JSON repressentation
  48526. * @param parsedLensFlareSystem Define the JSON to parse
  48527. * @param scene Define the scene the parsed system should be instantiated in
  48528. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48529. * @returns the parsed system
  48530. */
  48531. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48532. /**
  48533. * Serialize the current Lens Flare System into a JSON representation.
  48534. * @returns the serialized JSON
  48535. */
  48536. serialize(): any;
  48537. }
  48538. }
  48539. declare module BABYLON {
  48540. /**
  48541. * This represents one of the lens effect in a `lensFlareSystem`.
  48542. * It controls one of the indiviual texture used in the effect.
  48543. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48544. */
  48545. export class LensFlare {
  48546. /**
  48547. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48548. */
  48549. size: number;
  48550. /**
  48551. * 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.
  48552. */
  48553. position: number;
  48554. /**
  48555. * Define the lens color.
  48556. */
  48557. color: Color3;
  48558. /**
  48559. * Define the lens texture.
  48560. */
  48561. texture: Nullable<Texture>;
  48562. /**
  48563. * Define the alpha mode to render this particular lens.
  48564. */
  48565. alphaMode: number;
  48566. private _system;
  48567. /**
  48568. * Creates a new Lens Flare.
  48569. * This represents one of the lens effect in a `lensFlareSystem`.
  48570. * It controls one of the indiviual texture used in the effect.
  48571. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48572. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48573. * @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.
  48574. * @param color Define the lens color
  48575. * @param imgUrl Define the lens texture url
  48576. * @param system Define the `lensFlareSystem` this flare is part of
  48577. * @returns The newly created Lens Flare
  48578. */
  48579. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48580. /**
  48581. * Instantiates a new Lens Flare.
  48582. * This represents one of the lens effect in a `lensFlareSystem`.
  48583. * It controls one of the indiviual texture used in the effect.
  48584. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48585. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48586. * @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.
  48587. * @param color Define the lens color
  48588. * @param imgUrl Define the lens texture url
  48589. * @param system Define the `lensFlareSystem` this flare is part of
  48590. */
  48591. constructor(
  48592. /**
  48593. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48594. */
  48595. size: number,
  48596. /**
  48597. * 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.
  48598. */
  48599. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48600. /**
  48601. * Dispose and release the lens flare with its associated resources.
  48602. */
  48603. dispose(): void;
  48604. }
  48605. }
  48606. declare module BABYLON {
  48607. interface AbstractScene {
  48608. /**
  48609. * The list of lens flare system added to the scene
  48610. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48611. */
  48612. lensFlareSystems: Array<LensFlareSystem>;
  48613. /**
  48614. * Removes the given lens flare system from this scene.
  48615. * @param toRemove The lens flare system to remove
  48616. * @returns The index of the removed lens flare system
  48617. */
  48618. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48619. /**
  48620. * Adds the given lens flare system to this scene
  48621. * @param newLensFlareSystem The lens flare system to add
  48622. */
  48623. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48624. /**
  48625. * Gets a lens flare system using its name
  48626. * @param name defines the name to look for
  48627. * @returns the lens flare system or null if not found
  48628. */
  48629. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48630. /**
  48631. * Gets a lens flare system using its id
  48632. * @param id defines the id to look for
  48633. * @returns the lens flare system or null if not found
  48634. */
  48635. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48636. }
  48637. /**
  48638. * Defines the lens flare scene component responsible to manage any lens flares
  48639. * in a given scene.
  48640. */
  48641. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48642. /**
  48643. * The component name helpfull to identify the component in the list of scene components.
  48644. */
  48645. readonly name: string;
  48646. /**
  48647. * The scene the component belongs to.
  48648. */
  48649. scene: Scene;
  48650. /**
  48651. * Creates a new instance of the component for the given scene
  48652. * @param scene Defines the scene to register the component in
  48653. */
  48654. constructor(scene: Scene);
  48655. /**
  48656. * Registers the component in a given scene
  48657. */
  48658. register(): void;
  48659. /**
  48660. * Rebuilds the elements related to this component in case of
  48661. * context lost for instance.
  48662. */
  48663. rebuild(): void;
  48664. /**
  48665. * Adds all the elements from the container to the scene
  48666. * @param container the container holding the elements
  48667. */
  48668. addFromContainer(container: AbstractScene): void;
  48669. /**
  48670. * Removes all the elements in the container from the scene
  48671. * @param container contains the elements to remove
  48672. * @param dispose if the removed element should be disposed (default: false)
  48673. */
  48674. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48675. /**
  48676. * Serializes the component data to the specified json object
  48677. * @param serializationObject The object to serialize to
  48678. */
  48679. serialize(serializationObject: any): void;
  48680. /**
  48681. * Disposes the component and the associated ressources.
  48682. */
  48683. dispose(): void;
  48684. private _draw;
  48685. }
  48686. }
  48687. declare module BABYLON {
  48688. /**
  48689. * Defines the shadow generator component responsible to manage any shadow generators
  48690. * in a given scene.
  48691. */
  48692. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48693. /**
  48694. * The component name helpfull to identify the component in the list of scene components.
  48695. */
  48696. readonly name: string;
  48697. /**
  48698. * The scene the component belongs to.
  48699. */
  48700. scene: Scene;
  48701. /**
  48702. * Creates a new instance of the component for the given scene
  48703. * @param scene Defines the scene to register the component in
  48704. */
  48705. constructor(scene: Scene);
  48706. /**
  48707. * Registers the component in a given scene
  48708. */
  48709. register(): void;
  48710. /**
  48711. * Rebuilds the elements related to this component in case of
  48712. * context lost for instance.
  48713. */
  48714. rebuild(): void;
  48715. /**
  48716. * Serializes the component data to the specified json object
  48717. * @param serializationObject The object to serialize to
  48718. */
  48719. serialize(serializationObject: any): void;
  48720. /**
  48721. * Adds all the elements from the container to the scene
  48722. * @param container the container holding the elements
  48723. */
  48724. addFromContainer(container: AbstractScene): void;
  48725. /**
  48726. * Removes all the elements in the container from the scene
  48727. * @param container contains the elements to remove
  48728. * @param dispose if the removed element should be disposed (default: false)
  48729. */
  48730. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48731. /**
  48732. * Rebuilds the elements related to this component in case of
  48733. * context lost for instance.
  48734. */
  48735. dispose(): void;
  48736. private _gatherRenderTargets;
  48737. }
  48738. }
  48739. declare module BABYLON {
  48740. /**
  48741. * A point light is a light defined by an unique point in world space.
  48742. * The light is emitted in every direction from this point.
  48743. * A good example of a point light is a standard light bulb.
  48744. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48745. */
  48746. export class PointLight extends ShadowLight {
  48747. private _shadowAngle;
  48748. /**
  48749. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48750. * This specifies what angle the shadow will use to be created.
  48751. *
  48752. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48753. */
  48754. /**
  48755. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48756. * This specifies what angle the shadow will use to be created.
  48757. *
  48758. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48759. */
  48760. shadowAngle: number;
  48761. /**
  48762. * Gets the direction if it has been set.
  48763. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48764. */
  48765. /**
  48766. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48767. */
  48768. direction: Vector3;
  48769. /**
  48770. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48771. * A PointLight emits the light in every direction.
  48772. * It can cast shadows.
  48773. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48774. * ```javascript
  48775. * var pointLight = new PointLight("pl", camera.position, scene);
  48776. * ```
  48777. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48778. * @param name The light friendly name
  48779. * @param position The position of the point light in the scene
  48780. * @param scene The scene the lights belongs to
  48781. */
  48782. constructor(name: string, position: Vector3, scene: Scene);
  48783. /**
  48784. * Returns the string "PointLight"
  48785. * @returns the class name
  48786. */
  48787. getClassName(): string;
  48788. /**
  48789. * Returns the integer 0.
  48790. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48791. */
  48792. getTypeID(): number;
  48793. /**
  48794. * Specifies wether or not the shadowmap should be a cube texture.
  48795. * @returns true if the shadowmap needs to be a cube texture.
  48796. */
  48797. needCube(): boolean;
  48798. /**
  48799. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48800. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48801. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48802. */
  48803. getShadowDirection(faceIndex?: number): Vector3;
  48804. /**
  48805. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48806. * - fov = PI / 2
  48807. * - aspect ratio : 1.0
  48808. * - z-near and far equal to the active camera minZ and maxZ.
  48809. * Returns the PointLight.
  48810. */
  48811. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48812. protected _buildUniformLayout(): void;
  48813. /**
  48814. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48815. * @param effect The effect to update
  48816. * @param lightIndex The index of the light in the effect to update
  48817. * @returns The point light
  48818. */
  48819. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48820. /**
  48821. * Prepares the list of defines specific to the light type.
  48822. * @param defines the list of defines
  48823. * @param lightIndex defines the index of the light for the effect
  48824. */
  48825. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48826. }
  48827. }
  48828. declare module BABYLON {
  48829. /**
  48830. * Header information of HDR texture files.
  48831. */
  48832. export interface HDRInfo {
  48833. /**
  48834. * The height of the texture in pixels.
  48835. */
  48836. height: number;
  48837. /**
  48838. * The width of the texture in pixels.
  48839. */
  48840. width: number;
  48841. /**
  48842. * The index of the beginning of the data in the binary file.
  48843. */
  48844. dataPosition: number;
  48845. }
  48846. /**
  48847. * This groups tools to convert HDR texture to native colors array.
  48848. */
  48849. export class HDRTools {
  48850. private static Ldexp;
  48851. private static Rgbe2float;
  48852. private static readStringLine;
  48853. /**
  48854. * Reads header information from an RGBE texture stored in a native array.
  48855. * More information on this format are available here:
  48856. * https://en.wikipedia.org/wiki/RGBE_image_format
  48857. *
  48858. * @param uint8array The binary file stored in native array.
  48859. * @return The header information.
  48860. */
  48861. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48862. /**
  48863. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48864. * This RGBE texture needs to store the information as a panorama.
  48865. *
  48866. * More information on this format are available here:
  48867. * https://en.wikipedia.org/wiki/RGBE_image_format
  48868. *
  48869. * @param buffer The binary file stored in an array buffer.
  48870. * @param size The expected size of the extracted cubemap.
  48871. * @return The Cube Map information.
  48872. */
  48873. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48874. /**
  48875. * Returns the pixels data extracted from an RGBE texture.
  48876. * This pixels will be stored left to right up to down in the R G B order in one array.
  48877. *
  48878. * More information on this format are available here:
  48879. * https://en.wikipedia.org/wiki/RGBE_image_format
  48880. *
  48881. * @param uint8array The binary file stored in an array buffer.
  48882. * @param hdrInfo The header information of the file.
  48883. * @return The pixels data in RGB right to left up to down order.
  48884. */
  48885. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48886. private static RGBE_ReadPixels_RLE;
  48887. }
  48888. }
  48889. declare module BABYLON {
  48890. /**
  48891. * This represents a texture coming from an HDR input.
  48892. *
  48893. * The only supported format is currently panorama picture stored in RGBE format.
  48894. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48895. */
  48896. export class HDRCubeTexture extends BaseTexture {
  48897. private static _facesMapping;
  48898. private _generateHarmonics;
  48899. private _noMipmap;
  48900. private _textureMatrix;
  48901. private _size;
  48902. private _onLoad;
  48903. private _onError;
  48904. /**
  48905. * The texture URL.
  48906. */
  48907. url: string;
  48908. /**
  48909. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48910. */
  48911. coordinatesMode: number;
  48912. protected _isBlocking: boolean;
  48913. /**
  48914. * Sets wether or not the texture is blocking during loading.
  48915. */
  48916. /**
  48917. * Gets wether or not the texture is blocking during loading.
  48918. */
  48919. isBlocking: boolean;
  48920. protected _rotationY: number;
  48921. /**
  48922. * Sets texture matrix rotation angle around Y axis in radians.
  48923. */
  48924. /**
  48925. * Gets texture matrix rotation angle around Y axis radians.
  48926. */
  48927. rotationY: number;
  48928. /**
  48929. * Gets or sets the center of the bounding box associated with the cube texture
  48930. * It must define where the camera used to render the texture was set
  48931. */
  48932. boundingBoxPosition: Vector3;
  48933. private _boundingBoxSize;
  48934. /**
  48935. * Gets or sets the size of the bounding box associated with the cube texture
  48936. * When defined, the cubemap will switch to local mode
  48937. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48938. * @example https://www.babylonjs-playground.com/#RNASML
  48939. */
  48940. boundingBoxSize: Vector3;
  48941. /**
  48942. * Instantiates an HDRTexture from the following parameters.
  48943. *
  48944. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48945. * @param scene The scene the texture will be used in
  48946. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48947. * @param noMipmap Forces to not generate the mipmap if true
  48948. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48949. * @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)
  48950. * @param reserved Reserved flag for internal use.
  48951. */
  48952. 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>);
  48953. /**
  48954. * Get the current class name of the texture useful for serialization or dynamic coding.
  48955. * @returns "HDRCubeTexture"
  48956. */
  48957. getClassName(): string;
  48958. /**
  48959. * Occurs when the file is raw .hdr file.
  48960. */
  48961. private loadTexture;
  48962. clone(): HDRCubeTexture;
  48963. delayLoad(): void;
  48964. /**
  48965. * Get the texture reflection matrix used to rotate/transform the reflection.
  48966. * @returns the reflection matrix
  48967. */
  48968. getReflectionTextureMatrix(): Matrix;
  48969. /**
  48970. * Set the texture reflection matrix used to rotate/transform the reflection.
  48971. * @param value Define the reflection matrix to set
  48972. */
  48973. setReflectionTextureMatrix(value: Matrix): void;
  48974. /**
  48975. * Parses a JSON representation of an HDR Texture in order to create the texture
  48976. * @param parsedTexture Define the JSON representation
  48977. * @param scene Define the scene the texture should be created in
  48978. * @param rootUrl Define the root url in case we need to load relative dependencies
  48979. * @returns the newly created texture after parsing
  48980. */
  48981. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48982. serialize(): any;
  48983. }
  48984. }
  48985. declare module BABYLON {
  48986. /**
  48987. * Class used to control physics engine
  48988. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48989. */
  48990. export class PhysicsEngine implements IPhysicsEngine {
  48991. private _physicsPlugin;
  48992. /**
  48993. * Global value used to control the smallest number supported by the simulation
  48994. */
  48995. static Epsilon: number;
  48996. private _impostors;
  48997. private _joints;
  48998. /**
  48999. * Gets the gravity vector used by the simulation
  49000. */
  49001. gravity: Vector3;
  49002. /**
  49003. * Factory used to create the default physics plugin.
  49004. * @returns The default physics plugin
  49005. */
  49006. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49007. /**
  49008. * Creates a new Physics Engine
  49009. * @param gravity defines the gravity vector used by the simulation
  49010. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49011. */
  49012. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49013. /**
  49014. * Sets the gravity vector used by the simulation
  49015. * @param gravity defines the gravity vector to use
  49016. */
  49017. setGravity(gravity: Vector3): void;
  49018. /**
  49019. * Set the time step of the physics engine.
  49020. * Default is 1/60.
  49021. * To slow it down, enter 1/600 for example.
  49022. * To speed it up, 1/30
  49023. * @param newTimeStep defines the new timestep to apply to this world.
  49024. */
  49025. setTimeStep(newTimeStep?: number): void;
  49026. /**
  49027. * Get the time step of the physics engine.
  49028. * @returns the current time step
  49029. */
  49030. getTimeStep(): number;
  49031. /**
  49032. * Release all resources
  49033. */
  49034. dispose(): void;
  49035. /**
  49036. * Gets the name of the current physics plugin
  49037. * @returns the name of the plugin
  49038. */
  49039. getPhysicsPluginName(): string;
  49040. /**
  49041. * Adding a new impostor for the impostor tracking.
  49042. * This will be done by the impostor itself.
  49043. * @param impostor the impostor to add
  49044. */
  49045. addImpostor(impostor: PhysicsImpostor): void;
  49046. /**
  49047. * Remove an impostor from the engine.
  49048. * This impostor and its mesh will not longer be updated by the physics engine.
  49049. * @param impostor the impostor to remove
  49050. */
  49051. removeImpostor(impostor: PhysicsImpostor): void;
  49052. /**
  49053. * Add a joint to the physics engine
  49054. * @param mainImpostor defines the main impostor to which the joint is added.
  49055. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49056. * @param joint defines the joint that will connect both impostors.
  49057. */
  49058. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49059. /**
  49060. * Removes a joint from the simulation
  49061. * @param mainImpostor defines the impostor used with the joint
  49062. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49063. * @param joint defines the joint to remove
  49064. */
  49065. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49066. /**
  49067. * Called by the scene. No need to call it.
  49068. * @param delta defines the timespam between frames
  49069. */
  49070. _step(delta: number): void;
  49071. /**
  49072. * Gets the current plugin used to run the simulation
  49073. * @returns current plugin
  49074. */
  49075. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49076. /**
  49077. * Gets the list of physic impostors
  49078. * @returns an array of PhysicsImpostor
  49079. */
  49080. getImpostors(): Array<PhysicsImpostor>;
  49081. /**
  49082. * Gets the impostor for a physics enabled object
  49083. * @param object defines the object impersonated by the impostor
  49084. * @returns the PhysicsImpostor or null if not found
  49085. */
  49086. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49087. /**
  49088. * Gets the impostor for a physics body object
  49089. * @param body defines physics body used by the impostor
  49090. * @returns the PhysicsImpostor or null if not found
  49091. */
  49092. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49093. /**
  49094. * Does a raycast in the physics world
  49095. * @param from when should the ray start?
  49096. * @param to when should the ray end?
  49097. * @returns PhysicsRaycastResult
  49098. */
  49099. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49100. }
  49101. }
  49102. declare module BABYLON {
  49103. /** @hidden */
  49104. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49105. private _useDeltaForWorldStep;
  49106. world: any;
  49107. name: string;
  49108. private _physicsMaterials;
  49109. private _fixedTimeStep;
  49110. private _cannonRaycastResult;
  49111. private _raycastResult;
  49112. private _physicsBodysToRemoveAfterStep;
  49113. BJSCANNON: any;
  49114. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49115. setGravity(gravity: Vector3): void;
  49116. setTimeStep(timeStep: number): void;
  49117. getTimeStep(): number;
  49118. executeStep(delta: number): void;
  49119. private _removeMarkedPhysicsBodiesFromWorld;
  49120. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49121. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49122. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49123. private _processChildMeshes;
  49124. removePhysicsBody(impostor: PhysicsImpostor): void;
  49125. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49126. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49127. private _addMaterial;
  49128. private _checkWithEpsilon;
  49129. private _createShape;
  49130. private _createHeightmap;
  49131. private _minus90X;
  49132. private _plus90X;
  49133. private _tmpPosition;
  49134. private _tmpDeltaPosition;
  49135. private _tmpUnityRotation;
  49136. private _updatePhysicsBodyTransformation;
  49137. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49138. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49139. isSupported(): boolean;
  49140. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49141. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49142. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49143. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49144. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49145. getBodyMass(impostor: PhysicsImpostor): number;
  49146. getBodyFriction(impostor: PhysicsImpostor): number;
  49147. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49148. getBodyRestitution(impostor: PhysicsImpostor): number;
  49149. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49150. sleepBody(impostor: PhysicsImpostor): void;
  49151. wakeUpBody(impostor: PhysicsImpostor): void;
  49152. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49153. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49154. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49155. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49156. getRadius(impostor: PhysicsImpostor): number;
  49157. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49158. dispose(): void;
  49159. private _extendNamespace;
  49160. /**
  49161. * Does a raycast in the physics world
  49162. * @param from when should the ray start?
  49163. * @param to when should the ray end?
  49164. * @returns PhysicsRaycastResult
  49165. */
  49166. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49167. }
  49168. }
  49169. declare module BABYLON {
  49170. /** @hidden */
  49171. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49172. world: any;
  49173. name: string;
  49174. BJSOIMO: any;
  49175. private _raycastResult;
  49176. constructor(iterations?: number, oimoInjection?: any);
  49177. setGravity(gravity: Vector3): void;
  49178. setTimeStep(timeStep: number): void;
  49179. getTimeStep(): number;
  49180. private _tmpImpostorsArray;
  49181. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49182. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49183. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49184. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49185. private _tmpPositionVector;
  49186. removePhysicsBody(impostor: PhysicsImpostor): void;
  49187. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49188. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49189. isSupported(): boolean;
  49190. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49191. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49192. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49193. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49194. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49195. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49196. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49197. getBodyMass(impostor: PhysicsImpostor): number;
  49198. getBodyFriction(impostor: PhysicsImpostor): number;
  49199. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49200. getBodyRestitution(impostor: PhysicsImpostor): number;
  49201. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49202. sleepBody(impostor: PhysicsImpostor): void;
  49203. wakeUpBody(impostor: PhysicsImpostor): void;
  49204. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49205. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49206. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49207. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49208. getRadius(impostor: PhysicsImpostor): number;
  49209. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49210. dispose(): void;
  49211. /**
  49212. * Does a raycast in the physics world
  49213. * @param from when should the ray start?
  49214. * @param to when should the ray end?
  49215. * @returns PhysicsRaycastResult
  49216. */
  49217. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49218. }
  49219. }
  49220. declare module BABYLON {
  49221. /**
  49222. * Class containing static functions to help procedurally build meshes
  49223. */
  49224. export class RibbonBuilder {
  49225. /**
  49226. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49227. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49228. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49229. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49230. * * 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
  49231. * * 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
  49232. * * 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
  49233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49234. * * 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
  49235. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49236. * * 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
  49237. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49238. * * 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
  49239. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49241. * @param name defines the name of the mesh
  49242. * @param options defines the options used to create the mesh
  49243. * @param scene defines the hosting scene
  49244. * @returns the ribbon mesh
  49245. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49246. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49247. */
  49248. static CreateRibbon(name: string, options: {
  49249. pathArray: Vector3[][];
  49250. closeArray?: boolean;
  49251. closePath?: boolean;
  49252. offset?: number;
  49253. updatable?: boolean;
  49254. sideOrientation?: number;
  49255. frontUVs?: Vector4;
  49256. backUVs?: Vector4;
  49257. instance?: Mesh;
  49258. invertUV?: boolean;
  49259. uvs?: Vector2[];
  49260. colors?: Color4[];
  49261. }, scene?: Nullable<Scene>): Mesh;
  49262. }
  49263. }
  49264. declare module BABYLON {
  49265. /**
  49266. * Class containing static functions to help procedurally build meshes
  49267. */
  49268. export class ShapeBuilder {
  49269. /**
  49270. * 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.
  49271. * * 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.
  49272. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49273. * * 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.
  49274. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49275. * * 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
  49276. * * 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
  49277. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49279. * * 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
  49280. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49282. * @param name defines the name of the mesh
  49283. * @param options defines the options used to create the mesh
  49284. * @param scene defines the hosting scene
  49285. * @returns the extruded shape mesh
  49286. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49287. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49288. */
  49289. static ExtrudeShape(name: string, options: {
  49290. shape: Vector3[];
  49291. path: Vector3[];
  49292. scale?: number;
  49293. rotation?: number;
  49294. cap?: number;
  49295. updatable?: boolean;
  49296. sideOrientation?: number;
  49297. frontUVs?: Vector4;
  49298. backUVs?: Vector4;
  49299. instance?: Mesh;
  49300. invertUV?: boolean;
  49301. }, scene?: Nullable<Scene>): Mesh;
  49302. /**
  49303. * Creates an custom extruded shape mesh.
  49304. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49305. * * 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.
  49306. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49307. * * 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
  49308. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49309. * * 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
  49310. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49311. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49312. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49313. * * 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
  49314. * * 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
  49315. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49317. * * 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
  49318. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49320. * @param name defines the name of the mesh
  49321. * @param options defines the options used to create the mesh
  49322. * @param scene defines the hosting scene
  49323. * @returns the custom extruded shape mesh
  49324. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49325. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49326. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49327. */
  49328. static ExtrudeShapeCustom(name: string, options: {
  49329. shape: Vector3[];
  49330. path: Vector3[];
  49331. scaleFunction?: any;
  49332. rotationFunction?: any;
  49333. ribbonCloseArray?: boolean;
  49334. ribbonClosePath?: boolean;
  49335. cap?: number;
  49336. updatable?: boolean;
  49337. sideOrientation?: number;
  49338. frontUVs?: Vector4;
  49339. backUVs?: Vector4;
  49340. instance?: Mesh;
  49341. invertUV?: boolean;
  49342. }, scene?: Nullable<Scene>): Mesh;
  49343. private static _ExtrudeShapeGeneric;
  49344. }
  49345. }
  49346. declare module BABYLON {
  49347. /**
  49348. * AmmoJS Physics plugin
  49349. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49350. * @see https://github.com/kripken/ammo.js/
  49351. */
  49352. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49353. private _useDeltaForWorldStep;
  49354. /**
  49355. * Reference to the Ammo library
  49356. */
  49357. bjsAMMO: any;
  49358. /**
  49359. * Created ammoJS world which physics bodies are added to
  49360. */
  49361. world: any;
  49362. /**
  49363. * Name of the plugin
  49364. */
  49365. name: string;
  49366. private _timeStep;
  49367. private _fixedTimeStep;
  49368. private _maxSteps;
  49369. private _tmpQuaternion;
  49370. private _tmpAmmoTransform;
  49371. private _tmpAmmoQuaternion;
  49372. private _tmpAmmoConcreteContactResultCallback;
  49373. private _collisionConfiguration;
  49374. private _dispatcher;
  49375. private _overlappingPairCache;
  49376. private _solver;
  49377. private _softBodySolver;
  49378. private _tmpAmmoVectorA;
  49379. private _tmpAmmoVectorB;
  49380. private _tmpAmmoVectorC;
  49381. private _tmpAmmoVectorD;
  49382. private _tmpContactCallbackResult;
  49383. private _tmpAmmoVectorRCA;
  49384. private _tmpAmmoVectorRCB;
  49385. private _raycastResult;
  49386. private static readonly DISABLE_COLLISION_FLAG;
  49387. private static readonly KINEMATIC_FLAG;
  49388. private static readonly DISABLE_DEACTIVATION_FLAG;
  49389. /**
  49390. * Initializes the ammoJS plugin
  49391. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49392. * @param ammoInjection can be used to inject your own ammo reference
  49393. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  49394. */
  49395. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  49396. /**
  49397. * Sets the gravity of the physics world (m/(s^2))
  49398. * @param gravity Gravity to set
  49399. */
  49400. setGravity(gravity: Vector3): void;
  49401. /**
  49402. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49403. * @param timeStep timestep to use in seconds
  49404. */
  49405. setTimeStep(timeStep: number): void;
  49406. /**
  49407. * 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)
  49408. * @param fixedTimeStep fixedTimeStep to use in seconds
  49409. */
  49410. setFixedTimeStep(fixedTimeStep: number): void;
  49411. /**
  49412. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49413. * @param maxSteps the maximum number of steps by the physics engine per frame
  49414. */
  49415. setMaxSteps(maxSteps: number): void;
  49416. /**
  49417. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49418. * @returns the current timestep in seconds
  49419. */
  49420. getTimeStep(): number;
  49421. private _isImpostorInContact;
  49422. private _isImpostorPairInContact;
  49423. private _stepSimulation;
  49424. /**
  49425. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49426. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49427. * After the step the babylon meshes are set to the position of the physics imposters
  49428. * @param delta amount of time to step forward
  49429. * @param impostors array of imposters to update before/after the step
  49430. */
  49431. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49432. /**
  49433. * Update babylon mesh to match physics world object
  49434. * @param impostor imposter to match
  49435. */
  49436. private _afterSoftStep;
  49437. /**
  49438. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49439. * @param impostor imposter to match
  49440. */
  49441. private _ropeStep;
  49442. /**
  49443. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49444. * @param impostor imposter to match
  49445. */
  49446. private _softbodyOrClothStep;
  49447. private _tmpVector;
  49448. private _tmpMatrix;
  49449. /**
  49450. * Applies an impulse on the imposter
  49451. * @param impostor imposter to apply impulse to
  49452. * @param force amount of force to be applied to the imposter
  49453. * @param contactPoint the location to apply the impulse on the imposter
  49454. */
  49455. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49456. /**
  49457. * Applies a force on the imposter
  49458. * @param impostor imposter to apply force
  49459. * @param force amount of force to be applied to the imposter
  49460. * @param contactPoint the location to apply the force on the imposter
  49461. */
  49462. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49463. /**
  49464. * Creates a physics body using the plugin
  49465. * @param impostor the imposter to create the physics body on
  49466. */
  49467. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49468. /**
  49469. * Removes the physics body from the imposter and disposes of the body's memory
  49470. * @param impostor imposter to remove the physics body from
  49471. */
  49472. removePhysicsBody(impostor: PhysicsImpostor): void;
  49473. /**
  49474. * Generates a joint
  49475. * @param impostorJoint the imposter joint to create the joint with
  49476. */
  49477. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49478. /**
  49479. * Removes a joint
  49480. * @param impostorJoint the imposter joint to remove the joint from
  49481. */
  49482. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49483. private _addMeshVerts;
  49484. /**
  49485. * Initialise the soft body vertices to match its object's (mesh) vertices
  49486. * Softbody vertices (nodes) are in world space and to match this
  49487. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  49488. * @param impostor to create the softbody for
  49489. */
  49490. private _softVertexData;
  49491. /**
  49492. * Create an impostor's soft body
  49493. * @param impostor to create the softbody for
  49494. */
  49495. private _createSoftbody;
  49496. /**
  49497. * Create cloth for an impostor
  49498. * @param impostor to create the softbody for
  49499. */
  49500. private _createCloth;
  49501. /**
  49502. * Create rope for an impostor
  49503. * @param impostor to create the softbody for
  49504. */
  49505. private _createRope;
  49506. private _addHullVerts;
  49507. private _createShape;
  49508. /**
  49509. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49510. * @param impostor imposter containing the physics body and babylon object
  49511. */
  49512. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49513. /**
  49514. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49515. * @param impostor imposter containing the physics body and babylon object
  49516. * @param newPosition new position
  49517. * @param newRotation new rotation
  49518. */
  49519. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49520. /**
  49521. * If this plugin is supported
  49522. * @returns true if its supported
  49523. */
  49524. isSupported(): boolean;
  49525. /**
  49526. * Sets the linear velocity of the physics body
  49527. * @param impostor imposter to set the velocity on
  49528. * @param velocity velocity to set
  49529. */
  49530. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49531. /**
  49532. * Sets the angular velocity of the physics body
  49533. * @param impostor imposter to set the velocity on
  49534. * @param velocity velocity to set
  49535. */
  49536. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49537. /**
  49538. * gets the linear velocity
  49539. * @param impostor imposter to get linear velocity from
  49540. * @returns linear velocity
  49541. */
  49542. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49543. /**
  49544. * gets the angular velocity
  49545. * @param impostor imposter to get angular velocity from
  49546. * @returns angular velocity
  49547. */
  49548. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49549. /**
  49550. * Sets the mass of physics body
  49551. * @param impostor imposter to set the mass on
  49552. * @param mass mass to set
  49553. */
  49554. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49555. /**
  49556. * Gets the mass of the physics body
  49557. * @param impostor imposter to get the mass from
  49558. * @returns mass
  49559. */
  49560. getBodyMass(impostor: PhysicsImpostor): number;
  49561. /**
  49562. * Gets friction of the impostor
  49563. * @param impostor impostor to get friction from
  49564. * @returns friction value
  49565. */
  49566. getBodyFriction(impostor: PhysicsImpostor): number;
  49567. /**
  49568. * Sets friction of the impostor
  49569. * @param impostor impostor to set friction on
  49570. * @param friction friction value
  49571. */
  49572. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49573. /**
  49574. * Gets restitution of the impostor
  49575. * @param impostor impostor to get restitution from
  49576. * @returns restitution value
  49577. */
  49578. getBodyRestitution(impostor: PhysicsImpostor): number;
  49579. /**
  49580. * Sets resitution of the impostor
  49581. * @param impostor impostor to set resitution on
  49582. * @param restitution resitution value
  49583. */
  49584. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49585. /**
  49586. * Gets pressure inside the impostor
  49587. * @param impostor impostor to get pressure from
  49588. * @returns pressure value
  49589. */
  49590. getBodyPressure(impostor: PhysicsImpostor): number;
  49591. /**
  49592. * Sets pressure inside a soft body impostor
  49593. * Cloth and rope must remain 0 pressure
  49594. * @param impostor impostor to set pressure on
  49595. * @param pressure pressure value
  49596. */
  49597. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  49598. /**
  49599. * Gets stiffness of the impostor
  49600. * @param impostor impostor to get stiffness from
  49601. * @returns pressure value
  49602. */
  49603. getBodyStiffness(impostor: PhysicsImpostor): number;
  49604. /**
  49605. * Sets stiffness of the impostor
  49606. * @param impostor impostor to set stiffness on
  49607. * @param stiffness stiffness value from 0 to 1
  49608. */
  49609. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  49610. /**
  49611. * Gets velocityIterations of the impostor
  49612. * @param impostor impostor to get velocity iterations from
  49613. * @returns velocityIterations value
  49614. */
  49615. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  49616. /**
  49617. * Sets velocityIterations of the impostor
  49618. * @param impostor impostor to set velocity iterations on
  49619. * @param velocityIterations velocityIterations value
  49620. */
  49621. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  49622. /**
  49623. * Gets positionIterations of the impostor
  49624. * @param impostor impostor to get position iterations from
  49625. * @returns positionIterations value
  49626. */
  49627. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  49628. /**
  49629. * Sets positionIterations of the impostor
  49630. * @param impostor impostor to set position on
  49631. * @param positionIterations positionIterations value
  49632. */
  49633. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  49634. /**
  49635. * Append an anchor to a cloth object
  49636. * @param impostor is the cloth impostor to add anchor to
  49637. * @param otherImpostor is the rigid impostor to anchor to
  49638. * @param width ratio across width from 0 to 1
  49639. * @param height ratio up height from 0 to 1
  49640. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  49641. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49642. */
  49643. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49644. /**
  49645. * Append an hook to a rope object
  49646. * @param impostor is the rope impostor to add hook to
  49647. * @param otherImpostor is the rigid impostor to hook to
  49648. * @param length ratio along the rope from 0 to 1
  49649. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  49650. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49651. */
  49652. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49653. /**
  49654. * Sleeps the physics body and stops it from being active
  49655. * @param impostor impostor to sleep
  49656. */
  49657. sleepBody(impostor: PhysicsImpostor): void;
  49658. /**
  49659. * Activates the physics body
  49660. * @param impostor impostor to activate
  49661. */
  49662. wakeUpBody(impostor: PhysicsImpostor): void;
  49663. /**
  49664. * Updates the distance parameters of the joint
  49665. * @param joint joint to update
  49666. * @param maxDistance maximum distance of the joint
  49667. * @param minDistance minimum distance of the joint
  49668. */
  49669. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49670. /**
  49671. * Sets a motor on the joint
  49672. * @param joint joint to set motor on
  49673. * @param speed speed of the motor
  49674. * @param maxForce maximum force of the motor
  49675. * @param motorIndex index of the motor
  49676. */
  49677. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49678. /**
  49679. * Sets the motors limit
  49680. * @param joint joint to set limit on
  49681. * @param upperLimit upper limit
  49682. * @param lowerLimit lower limit
  49683. */
  49684. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49685. /**
  49686. * Syncs the position and rotation of a mesh with the impostor
  49687. * @param mesh mesh to sync
  49688. * @param impostor impostor to update the mesh with
  49689. */
  49690. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49691. /**
  49692. * Gets the radius of the impostor
  49693. * @param impostor impostor to get radius from
  49694. * @returns the radius
  49695. */
  49696. getRadius(impostor: PhysicsImpostor): number;
  49697. /**
  49698. * Gets the box size of the impostor
  49699. * @param impostor impostor to get box size from
  49700. * @param result the resulting box size
  49701. */
  49702. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49703. /**
  49704. * Disposes of the impostor
  49705. */
  49706. dispose(): void;
  49707. /**
  49708. * Does a raycast in the physics world
  49709. * @param from when should the ray start?
  49710. * @param to when should the ray end?
  49711. * @returns PhysicsRaycastResult
  49712. */
  49713. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49714. }
  49715. }
  49716. declare module BABYLON {
  49717. interface AbstractScene {
  49718. /**
  49719. * The list of reflection probes added to the scene
  49720. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49721. */
  49722. reflectionProbes: Array<ReflectionProbe>;
  49723. /**
  49724. * Removes the given reflection probe from this scene.
  49725. * @param toRemove The reflection probe to remove
  49726. * @returns The index of the removed reflection probe
  49727. */
  49728. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49729. /**
  49730. * Adds the given reflection probe to this scene.
  49731. * @param newReflectionProbe The reflection probe to add
  49732. */
  49733. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49734. }
  49735. /**
  49736. * Class used to generate realtime reflection / refraction cube textures
  49737. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49738. */
  49739. export class ReflectionProbe {
  49740. /** defines the name of the probe */
  49741. name: string;
  49742. private _scene;
  49743. private _renderTargetTexture;
  49744. private _projectionMatrix;
  49745. private _viewMatrix;
  49746. private _target;
  49747. private _add;
  49748. private _attachedMesh;
  49749. private _invertYAxis;
  49750. /** Gets or sets probe position (center of the cube map) */
  49751. position: Vector3;
  49752. /**
  49753. * Creates a new reflection probe
  49754. * @param name defines the name of the probe
  49755. * @param size defines the texture resolution (for each face)
  49756. * @param scene defines the hosting scene
  49757. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49758. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49759. */
  49760. constructor(
  49761. /** defines the name of the probe */
  49762. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49763. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49764. samples: number;
  49765. /** Gets or sets the refresh rate to use (on every frame by default) */
  49766. refreshRate: number;
  49767. /**
  49768. * Gets the hosting scene
  49769. * @returns a Scene
  49770. */
  49771. getScene(): Scene;
  49772. /** Gets the internal CubeTexture used to render to */
  49773. readonly cubeTexture: RenderTargetTexture;
  49774. /** Gets the list of meshes to render */
  49775. readonly renderList: Nullable<AbstractMesh[]>;
  49776. /**
  49777. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49778. * @param mesh defines the mesh to attach to
  49779. */
  49780. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49781. /**
  49782. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49783. * @param renderingGroupId The rendering group id corresponding to its index
  49784. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49785. */
  49786. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49787. /**
  49788. * Clean all associated resources
  49789. */
  49790. dispose(): void;
  49791. /**
  49792. * Converts the reflection probe information to a readable string for debug purpose.
  49793. * @param fullDetails Supports for multiple levels of logging within scene loading
  49794. * @returns the human readable reflection probe info
  49795. */
  49796. toString(fullDetails?: boolean): string;
  49797. /**
  49798. * Get the class name of the relfection probe.
  49799. * @returns "ReflectionProbe"
  49800. */
  49801. getClassName(): string;
  49802. /**
  49803. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49804. * @returns The JSON representation of the texture
  49805. */
  49806. serialize(): any;
  49807. /**
  49808. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49809. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49810. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49811. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49812. * @returns The parsed reflection probe if successful
  49813. */
  49814. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49815. }
  49816. }
  49817. declare module BABYLON {
  49818. /** @hidden */
  49819. export var _BabylonLoaderRegistered: boolean;
  49820. }
  49821. declare module BABYLON {
  49822. /**
  49823. * The Physically based simple base material of BJS.
  49824. *
  49825. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49826. * It is used as the base class for both the specGloss and metalRough conventions.
  49827. */
  49828. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49829. /**
  49830. * Number of Simultaneous lights allowed on the material.
  49831. */
  49832. maxSimultaneousLights: number;
  49833. /**
  49834. * If sets to true, disables all the lights affecting the material.
  49835. */
  49836. disableLighting: boolean;
  49837. /**
  49838. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49839. */
  49840. environmentTexture: BaseTexture;
  49841. /**
  49842. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49843. */
  49844. invertNormalMapX: boolean;
  49845. /**
  49846. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49847. */
  49848. invertNormalMapY: boolean;
  49849. /**
  49850. * Normal map used in the model.
  49851. */
  49852. normalTexture: BaseTexture;
  49853. /**
  49854. * Emissivie color used to self-illuminate the model.
  49855. */
  49856. emissiveColor: Color3;
  49857. /**
  49858. * Emissivie texture used to self-illuminate the model.
  49859. */
  49860. emissiveTexture: BaseTexture;
  49861. /**
  49862. * Occlusion Channel Strenght.
  49863. */
  49864. occlusionStrength: number;
  49865. /**
  49866. * Occlusion Texture of the material (adding extra occlusion effects).
  49867. */
  49868. occlusionTexture: BaseTexture;
  49869. /**
  49870. * Defines the alpha limits in alpha test mode.
  49871. */
  49872. alphaCutOff: number;
  49873. /**
  49874. * Gets the current double sided mode.
  49875. */
  49876. /**
  49877. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49878. */
  49879. doubleSided: boolean;
  49880. /**
  49881. * Stores the pre-calculated light information of a mesh in a texture.
  49882. */
  49883. lightmapTexture: BaseTexture;
  49884. /**
  49885. * If true, the light map contains occlusion information instead of lighting info.
  49886. */
  49887. useLightmapAsShadowmap: boolean;
  49888. /**
  49889. * Instantiates a new PBRMaterial instance.
  49890. *
  49891. * @param name The material name
  49892. * @param scene The scene the material will be use in.
  49893. */
  49894. constructor(name: string, scene: Scene);
  49895. getClassName(): string;
  49896. }
  49897. }
  49898. declare module BABYLON {
  49899. /**
  49900. * The PBR material of BJS following the metal roughness convention.
  49901. *
  49902. * This fits to the PBR convention in the GLTF definition:
  49903. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49904. */
  49905. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49906. /**
  49907. * The base color has two different interpretations depending on the value of metalness.
  49908. * When the material is a metal, the base color is the specific measured reflectance value
  49909. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49910. * of the material.
  49911. */
  49912. baseColor: Color3;
  49913. /**
  49914. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49915. * well as opacity information in the alpha channel.
  49916. */
  49917. baseTexture: BaseTexture;
  49918. /**
  49919. * Specifies the metallic scalar value of the material.
  49920. * Can also be used to scale the metalness values of the metallic texture.
  49921. */
  49922. metallic: number;
  49923. /**
  49924. * Specifies the roughness scalar value of the material.
  49925. * Can also be used to scale the roughness values of the metallic texture.
  49926. */
  49927. roughness: number;
  49928. /**
  49929. * Texture containing both the metallic value in the B channel and the
  49930. * roughness value in the G channel to keep better precision.
  49931. */
  49932. metallicRoughnessTexture: BaseTexture;
  49933. /**
  49934. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49935. *
  49936. * @param name The material name
  49937. * @param scene The scene the material will be use in.
  49938. */
  49939. constructor(name: string, scene: Scene);
  49940. /**
  49941. * Return the currrent class name of the material.
  49942. */
  49943. getClassName(): string;
  49944. /**
  49945. * Makes a duplicate of the current material.
  49946. * @param name - name to use for the new material.
  49947. */
  49948. clone(name: string): PBRMetallicRoughnessMaterial;
  49949. /**
  49950. * Serialize the material to a parsable JSON object.
  49951. */
  49952. serialize(): any;
  49953. /**
  49954. * Parses a JSON object correponding to the serialize function.
  49955. */
  49956. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49957. }
  49958. }
  49959. declare module BABYLON {
  49960. /**
  49961. * The PBR material of BJS following the specular glossiness convention.
  49962. *
  49963. * This fits to the PBR convention in the GLTF definition:
  49964. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49965. */
  49966. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49967. /**
  49968. * Specifies the diffuse color of the material.
  49969. */
  49970. diffuseColor: Color3;
  49971. /**
  49972. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49973. * channel.
  49974. */
  49975. diffuseTexture: BaseTexture;
  49976. /**
  49977. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49978. */
  49979. specularColor: Color3;
  49980. /**
  49981. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49982. */
  49983. glossiness: number;
  49984. /**
  49985. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49986. */
  49987. specularGlossinessTexture: BaseTexture;
  49988. /**
  49989. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49990. *
  49991. * @param name The material name
  49992. * @param scene The scene the material will be use in.
  49993. */
  49994. constructor(name: string, scene: Scene);
  49995. /**
  49996. * Return the currrent class name of the material.
  49997. */
  49998. getClassName(): string;
  49999. /**
  50000. * Makes a duplicate of the current material.
  50001. * @param name - name to use for the new material.
  50002. */
  50003. clone(name: string): PBRSpecularGlossinessMaterial;
  50004. /**
  50005. * Serialize the material to a parsable JSON object.
  50006. */
  50007. serialize(): any;
  50008. /**
  50009. * Parses a JSON object correponding to the serialize function.
  50010. */
  50011. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50012. }
  50013. }
  50014. declare module BABYLON {
  50015. /**
  50016. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50017. * It can help converting any input color in a desired output one. This can then be used to create effects
  50018. * from sepia, black and white to sixties or futuristic rendering...
  50019. *
  50020. * The only supported format is currently 3dl.
  50021. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50022. */
  50023. export class ColorGradingTexture extends BaseTexture {
  50024. /**
  50025. * The current texture matrix. (will always be identity in color grading texture)
  50026. */
  50027. private _textureMatrix;
  50028. /**
  50029. * The texture URL.
  50030. */
  50031. url: string;
  50032. /**
  50033. * Empty line regex stored for GC.
  50034. */
  50035. private static _noneEmptyLineRegex;
  50036. private _engine;
  50037. /**
  50038. * Instantiates a ColorGradingTexture from the following parameters.
  50039. *
  50040. * @param url The location of the color gradind data (currently only supporting 3dl)
  50041. * @param scene The scene the texture will be used in
  50042. */
  50043. constructor(url: string, scene: Scene);
  50044. /**
  50045. * Returns the texture matrix used in most of the material.
  50046. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50047. */
  50048. getTextureMatrix(): Matrix;
  50049. /**
  50050. * Occurs when the file being loaded is a .3dl LUT file.
  50051. */
  50052. private load3dlTexture;
  50053. /**
  50054. * Starts the loading process of the texture.
  50055. */
  50056. private loadTexture;
  50057. /**
  50058. * Clones the color gradind texture.
  50059. */
  50060. clone(): ColorGradingTexture;
  50061. /**
  50062. * Called during delayed load for textures.
  50063. */
  50064. delayLoad(): void;
  50065. /**
  50066. * Parses a color grading texture serialized by Babylon.
  50067. * @param parsedTexture The texture information being parsedTexture
  50068. * @param scene The scene to load the texture in
  50069. * @param rootUrl The root url of the data assets to load
  50070. * @return A color gradind texture
  50071. */
  50072. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50073. /**
  50074. * Serializes the LUT texture to json format.
  50075. */
  50076. serialize(): any;
  50077. }
  50078. }
  50079. declare module BABYLON {
  50080. /**
  50081. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50082. */
  50083. export class EquiRectangularCubeTexture extends BaseTexture {
  50084. /** The six faces of the cube. */
  50085. private static _FacesMapping;
  50086. private _noMipmap;
  50087. private _onLoad;
  50088. private _onError;
  50089. /** The size of the cubemap. */
  50090. private _size;
  50091. /** The buffer of the image. */
  50092. private _buffer;
  50093. /** The width of the input image. */
  50094. private _width;
  50095. /** The height of the input image. */
  50096. private _height;
  50097. /** The URL to the image. */
  50098. url: string;
  50099. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50100. coordinatesMode: number;
  50101. /**
  50102. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50103. * @param url The location of the image
  50104. * @param scene The scene the texture will be used in
  50105. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50106. * @param noMipmap Forces to not generate the mipmap if true
  50107. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50108. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50109. * @param onLoad — defines a callback called when texture is loaded
  50110. * @param onError — defines a callback called if there is an error
  50111. */
  50112. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50113. /**
  50114. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50115. */
  50116. private loadImage;
  50117. /**
  50118. * Convert the image buffer into a cubemap and create a CubeTexture.
  50119. */
  50120. private loadTexture;
  50121. /**
  50122. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50123. * @param buffer The ArrayBuffer that should be converted.
  50124. * @returns The buffer as Float32Array.
  50125. */
  50126. private getFloat32ArrayFromArrayBuffer;
  50127. /**
  50128. * Get the current class name of the texture useful for serialization or dynamic coding.
  50129. * @returns "EquiRectangularCubeTexture"
  50130. */
  50131. getClassName(): string;
  50132. /**
  50133. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50134. * @returns A clone of the current EquiRectangularCubeTexture.
  50135. */
  50136. clone(): EquiRectangularCubeTexture;
  50137. }
  50138. }
  50139. declare module BABYLON {
  50140. /**
  50141. * Based on jsTGALoader - Javascript loader for TGA file
  50142. * By Vincent Thibault
  50143. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50144. */
  50145. export class TGATools {
  50146. private static _TYPE_INDEXED;
  50147. private static _TYPE_RGB;
  50148. private static _TYPE_GREY;
  50149. private static _TYPE_RLE_INDEXED;
  50150. private static _TYPE_RLE_RGB;
  50151. private static _TYPE_RLE_GREY;
  50152. private static _ORIGIN_MASK;
  50153. private static _ORIGIN_SHIFT;
  50154. private static _ORIGIN_BL;
  50155. private static _ORIGIN_BR;
  50156. private static _ORIGIN_UL;
  50157. private static _ORIGIN_UR;
  50158. /**
  50159. * Gets the header of a TGA file
  50160. * @param data defines the TGA data
  50161. * @returns the header
  50162. */
  50163. static GetTGAHeader(data: Uint8Array): any;
  50164. /**
  50165. * Uploads TGA content to a Babylon Texture
  50166. * @hidden
  50167. */
  50168. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50169. /** @hidden */
  50170. 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;
  50171. /** @hidden */
  50172. 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;
  50173. /** @hidden */
  50174. 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;
  50175. /** @hidden */
  50176. 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;
  50177. /** @hidden */
  50178. 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;
  50179. /** @hidden */
  50180. 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;
  50181. }
  50182. }
  50183. declare module BABYLON {
  50184. /**
  50185. * Implementation of the TGA Texture Loader.
  50186. * @hidden
  50187. */
  50188. export class _TGATextureLoader implements IInternalTextureLoader {
  50189. /**
  50190. * Defines wether the loader supports cascade loading the different faces.
  50191. */
  50192. readonly supportCascades: boolean;
  50193. /**
  50194. * This returns if the loader support the current file information.
  50195. * @param extension defines the file extension of the file being loaded
  50196. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50197. * @param fallback defines the fallback internal texture if any
  50198. * @param isBase64 defines whether the texture is encoded as a base64
  50199. * @param isBuffer defines whether the texture data are stored as a buffer
  50200. * @returns true if the loader can load the specified file
  50201. */
  50202. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50203. /**
  50204. * Transform the url before loading if required.
  50205. * @param rootUrl the url of the texture
  50206. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50207. * @returns the transformed texture
  50208. */
  50209. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50210. /**
  50211. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50212. * @param rootUrl the url of the texture
  50213. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50214. * @returns the fallback texture
  50215. */
  50216. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50217. /**
  50218. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50219. * @param data contains the texture data
  50220. * @param texture defines the BabylonJS internal texture
  50221. * @param createPolynomials will be true if polynomials have been requested
  50222. * @param onLoad defines the callback to trigger once the texture is ready
  50223. * @param onError defines the callback to trigger in case of error
  50224. */
  50225. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50226. /**
  50227. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50228. * @param data contains the texture data
  50229. * @param texture defines the BabylonJS internal texture
  50230. * @param callback defines the method to call once ready to upload
  50231. */
  50232. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50233. }
  50234. }
  50235. declare module BABYLON {
  50236. /**
  50237. * Info about the .basis files
  50238. */
  50239. class BasisFileInfo {
  50240. /**
  50241. * If the file has alpha
  50242. */
  50243. hasAlpha: boolean;
  50244. /**
  50245. * Info about each image of the basis file
  50246. */
  50247. images: Array<{
  50248. levels: Array<{
  50249. width: number;
  50250. height: number;
  50251. transcodedPixels: ArrayBufferView;
  50252. }>;
  50253. }>;
  50254. }
  50255. /**
  50256. * Result of transcoding a basis file
  50257. */
  50258. class TranscodeResult {
  50259. /**
  50260. * Info about the .basis file
  50261. */
  50262. fileInfo: BasisFileInfo;
  50263. /**
  50264. * Format to use when loading the file
  50265. */
  50266. format: number;
  50267. }
  50268. /**
  50269. * Configuration options for the Basis transcoder
  50270. */
  50271. export class BasisTranscodeConfiguration {
  50272. /**
  50273. * Supported compression formats used to determine the supported output format of the transcoder
  50274. */
  50275. supportedCompressionFormats?: {
  50276. /**
  50277. * etc1 compression format
  50278. */
  50279. etc1?: boolean;
  50280. /**
  50281. * s3tc compression format
  50282. */
  50283. s3tc?: boolean;
  50284. /**
  50285. * pvrtc compression format
  50286. */
  50287. pvrtc?: boolean;
  50288. /**
  50289. * etc2 compression format
  50290. */
  50291. etc2?: boolean;
  50292. };
  50293. /**
  50294. * If mipmap levels should be loaded for transcoded images (Default: true)
  50295. */
  50296. loadMipmapLevels?: boolean;
  50297. /**
  50298. * Index of a single image to load (Default: all images)
  50299. */
  50300. loadSingleImage?: number;
  50301. }
  50302. /**
  50303. * Used to load .Basis files
  50304. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  50305. */
  50306. export class BasisTools {
  50307. private static _IgnoreSupportedFormats;
  50308. /**
  50309. * URL to use when loading the basis transcoder
  50310. */
  50311. static JSModuleURL: string;
  50312. /**
  50313. * URL to use when loading the wasm module for the transcoder
  50314. */
  50315. static WasmModuleURL: string;
  50316. /**
  50317. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  50318. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  50319. * @returns internal format corresponding to the Basis format
  50320. */
  50321. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  50322. private static _WorkerPromise;
  50323. private static _Worker;
  50324. private static _actionId;
  50325. private static _CreateWorkerAsync;
  50326. /**
  50327. * Transcodes a loaded image file to compressed pixel data
  50328. * @param imageData image data to transcode
  50329. * @param config configuration options for the transcoding
  50330. * @returns a promise resulting in the transcoded image
  50331. */
  50332. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  50333. /**
  50334. * Loads a texture from the transcode result
  50335. * @param texture texture load to
  50336. * @param transcodeResult the result of transcoding the basis file to load from
  50337. */
  50338. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  50339. }
  50340. }
  50341. declare module BABYLON {
  50342. /**
  50343. * Loader for .basis file format
  50344. */
  50345. export class _BasisTextureLoader implements IInternalTextureLoader {
  50346. /**
  50347. * Defines whether the loader supports cascade loading the different faces.
  50348. */
  50349. readonly supportCascades: boolean;
  50350. /**
  50351. * This returns if the loader support the current file information.
  50352. * @param extension defines the file extension of the file being loaded
  50353. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50354. * @param fallback defines the fallback internal texture if any
  50355. * @param isBase64 defines whether the texture is encoded as a base64
  50356. * @param isBuffer defines whether the texture data are stored as a buffer
  50357. * @returns true if the loader can load the specified file
  50358. */
  50359. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50360. /**
  50361. * Transform the url before loading if required.
  50362. * @param rootUrl the url of the texture
  50363. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50364. * @returns the transformed texture
  50365. */
  50366. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50367. /**
  50368. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50369. * @param rootUrl the url of the texture
  50370. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50371. * @returns the fallback texture
  50372. */
  50373. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50374. /**
  50375. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  50376. * @param data contains the texture data
  50377. * @param texture defines the BabylonJS internal texture
  50378. * @param createPolynomials will be true if polynomials have been requested
  50379. * @param onLoad defines the callback to trigger once the texture is ready
  50380. * @param onError defines the callback to trigger in case of error
  50381. */
  50382. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50383. /**
  50384. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50385. * @param data contains the texture data
  50386. * @param texture defines the BabylonJS internal texture
  50387. * @param callback defines the method to call once ready to upload
  50388. */
  50389. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50390. }
  50391. }
  50392. declare module BABYLON {
  50393. /**
  50394. * 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.
  50395. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50396. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50397. */
  50398. export class CustomProceduralTexture extends ProceduralTexture {
  50399. private _animate;
  50400. private _time;
  50401. private _config;
  50402. private _texturePath;
  50403. /**
  50404. * Instantiates a new Custom Procedural Texture.
  50405. * 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.
  50406. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50407. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50408. * @param name Define the name of the texture
  50409. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50410. * @param size Define the size of the texture to create
  50411. * @param scene Define the scene the texture belongs to
  50412. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50413. * @param generateMipMaps Define if the texture should creates mip maps or not
  50414. */
  50415. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50416. private _loadJson;
  50417. /**
  50418. * Is the texture ready to be used ? (rendered at least once)
  50419. * @returns true if ready, otherwise, false.
  50420. */
  50421. isReady(): boolean;
  50422. /**
  50423. * Render the texture to its associated render target.
  50424. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50425. */
  50426. render(useCameraPostProcess?: boolean): void;
  50427. /**
  50428. * Update the list of dependant textures samplers in the shader.
  50429. */
  50430. updateTextures(): void;
  50431. /**
  50432. * Update the uniform values of the procedural texture in the shader.
  50433. */
  50434. updateShaderUniforms(): void;
  50435. /**
  50436. * Define if the texture animates or not.
  50437. */
  50438. animate: boolean;
  50439. }
  50440. }
  50441. declare module BABYLON {
  50442. /** @hidden */
  50443. export var noisePixelShader: {
  50444. name: string;
  50445. shader: string;
  50446. };
  50447. }
  50448. declare module BABYLON {
  50449. /**
  50450. * Class used to generate noise procedural textures
  50451. */
  50452. export class NoiseProceduralTexture extends ProceduralTexture {
  50453. private _time;
  50454. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50455. brightness: number;
  50456. /** Defines the number of octaves to process */
  50457. octaves: number;
  50458. /** Defines the level of persistence (0.8 by default) */
  50459. persistence: number;
  50460. /** Gets or sets animation speed factor (default is 1) */
  50461. animationSpeedFactor: number;
  50462. /**
  50463. * Creates a new NoiseProceduralTexture
  50464. * @param name defines the name fo the texture
  50465. * @param size defines the size of the texture (default is 256)
  50466. * @param scene defines the hosting scene
  50467. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50468. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50469. */
  50470. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50471. private _updateShaderUniforms;
  50472. protected _getDefines(): string;
  50473. /** Generate the current state of the procedural texture */
  50474. render(useCameraPostProcess?: boolean): void;
  50475. /**
  50476. * Serializes this noise procedural texture
  50477. * @returns a serialized noise procedural texture object
  50478. */
  50479. serialize(): any;
  50480. /**
  50481. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50482. * @param parsedTexture defines parsed texture data
  50483. * @param scene defines the current scene
  50484. * @param rootUrl defines the root URL containing noise procedural texture information
  50485. * @returns a parsed NoiseProceduralTexture
  50486. */
  50487. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50488. }
  50489. }
  50490. declare module BABYLON {
  50491. /**
  50492. * Raw cube texture where the raw buffers are passed in
  50493. */
  50494. export class RawCubeTexture extends CubeTexture {
  50495. /**
  50496. * Creates a cube texture where the raw buffers are passed in.
  50497. * @param scene defines the scene the texture is attached to
  50498. * @param data defines the array of data to use to create each face
  50499. * @param size defines the size of the textures
  50500. * @param format defines the format of the data
  50501. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50502. * @param generateMipMaps defines if the engine should generate the mip levels
  50503. * @param invertY defines if data must be stored with Y axis inverted
  50504. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50505. * @param compression defines the compression used (null by default)
  50506. */
  50507. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50508. /**
  50509. * Updates the raw cube texture.
  50510. * @param data defines the data to store
  50511. * @param format defines the data format
  50512. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50513. * @param invertY defines if data must be stored with Y axis inverted
  50514. * @param compression defines the compression used (null by default)
  50515. * @param level defines which level of the texture to update
  50516. */
  50517. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50518. /**
  50519. * Updates a raw cube texture with RGBD encoded data.
  50520. * @param data defines the array of data [mipmap][face] to use to create each face
  50521. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50522. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50523. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50524. * @returns a promsie that resolves when the operation is complete
  50525. */
  50526. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50527. /**
  50528. * Clones the raw cube texture.
  50529. * @return a new cube texture
  50530. */
  50531. clone(): CubeTexture;
  50532. /** @hidden */
  50533. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50534. }
  50535. }
  50536. declare module BABYLON {
  50537. /**
  50538. * Class used to store 3D textures containing user data
  50539. */
  50540. export class RawTexture3D extends Texture {
  50541. /** Gets or sets the texture format to use */
  50542. format: number;
  50543. private _engine;
  50544. /**
  50545. * Create a new RawTexture3D
  50546. * @param data defines the data of the texture
  50547. * @param width defines the width of the texture
  50548. * @param height defines the height of the texture
  50549. * @param depth defines the depth of the texture
  50550. * @param format defines the texture format to use
  50551. * @param scene defines the hosting scene
  50552. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  50553. * @param invertY defines if texture must be stored with Y axis inverted
  50554. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  50555. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  50556. */
  50557. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  50558. /** Gets or sets the texture format to use */
  50559. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  50560. /**
  50561. * Update the texture with new data
  50562. * @param data defines the data to store in the texture
  50563. */
  50564. update(data: ArrayBufferView): void;
  50565. }
  50566. }
  50567. declare module BABYLON {
  50568. /**
  50569. * Creates a refraction texture used by refraction channel of the standard material.
  50570. * It is like a mirror but to see through a material.
  50571. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50572. */
  50573. export class RefractionTexture extends RenderTargetTexture {
  50574. /**
  50575. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  50576. * 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.
  50577. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50578. */
  50579. refractionPlane: Plane;
  50580. /**
  50581. * Define how deep under the surface we should see.
  50582. */
  50583. depth: number;
  50584. /**
  50585. * Creates a refraction texture used by refraction channel of the standard material.
  50586. * It is like a mirror but to see through a material.
  50587. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50588. * @param name Define the texture name
  50589. * @param size Define the size of the underlying texture
  50590. * @param scene Define the scene the refraction belongs to
  50591. * @param generateMipMaps Define if we need to generate mips level for the refraction
  50592. */
  50593. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  50594. /**
  50595. * Clone the refraction texture.
  50596. * @returns the cloned texture
  50597. */
  50598. clone(): RefractionTexture;
  50599. /**
  50600. * Serialize the texture to a JSON representation you could use in Parse later on
  50601. * @returns the serialized JSON representation
  50602. */
  50603. serialize(): any;
  50604. }
  50605. }
  50606. declare module BABYLON {
  50607. /**
  50608. * Defines the options related to the creation of an HtmlElementTexture
  50609. */
  50610. export interface IHtmlElementTextureOptions {
  50611. /**
  50612. * Defines wether mip maps should be created or not.
  50613. */
  50614. generateMipMaps?: boolean;
  50615. /**
  50616. * Defines the sampling mode of the texture.
  50617. */
  50618. samplingMode?: number;
  50619. /**
  50620. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  50621. */
  50622. engine: Nullable<Engine>;
  50623. /**
  50624. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  50625. */
  50626. scene: Nullable<Scene>;
  50627. }
  50628. /**
  50629. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  50630. * To be as efficient as possible depending on your constraints nothing aside the first upload
  50631. * is automatically managed.
  50632. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  50633. * in your application.
  50634. *
  50635. * As the update is not automatic, you need to call them manually.
  50636. */
  50637. export class HtmlElementTexture extends BaseTexture {
  50638. /**
  50639. * The texture URL.
  50640. */
  50641. element: HTMLVideoElement | HTMLCanvasElement;
  50642. private static readonly DefaultOptions;
  50643. private _textureMatrix;
  50644. private _engine;
  50645. private _isVideo;
  50646. private _generateMipMaps;
  50647. private _samplingMode;
  50648. /**
  50649. * Instantiates a HtmlElementTexture from the following parameters.
  50650. *
  50651. * @param name Defines the name of the texture
  50652. * @param element Defines the video or canvas the texture is filled with
  50653. * @param options Defines the other none mandatory texture creation options
  50654. */
  50655. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  50656. private _createInternalTexture;
  50657. /**
  50658. * Returns the texture matrix used in most of the material.
  50659. */
  50660. getTextureMatrix(): Matrix;
  50661. /**
  50662. * Updates the content of the texture.
  50663. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  50664. */
  50665. update(invertY?: Nullable<boolean>): void;
  50666. }
  50667. }
  50668. declare module BABYLON {
  50669. /**
  50670. * Enum used to define the target of a block
  50671. */
  50672. export enum NodeMaterialBlockTargets {
  50673. /** Vertex shader */
  50674. Vertex = 1,
  50675. /** Fragment shader */
  50676. Fragment = 2,
  50677. /** Vertex and Fragment */
  50678. VertexAndFragment = 3
  50679. }
  50680. }
  50681. declare module BABYLON {
  50682. /**
  50683. * Defines the kind of connection point for node based material
  50684. */
  50685. export enum NodeMaterialBlockConnectionPointTypes {
  50686. /** Float */
  50687. Float = 1,
  50688. /** Int */
  50689. Int = 2,
  50690. /** Vector2 */
  50691. Vector2 = 4,
  50692. /** Vector3 */
  50693. Vector3 = 8,
  50694. /** Vector4 */
  50695. Vector4 = 16,
  50696. /** Color3 */
  50697. Color3 = 32,
  50698. /** Color4 */
  50699. Color4 = 64,
  50700. /** Matrix */
  50701. Matrix = 128,
  50702. /** Texture */
  50703. Texture = 256,
  50704. /** Texture3D */
  50705. Texture3D = 512,
  50706. /** Vector3 or Color3 */
  50707. Vector3OrColor3 = 40,
  50708. /** Vector3 or Vector4 */
  50709. Vector3OrVector4 = 24,
  50710. /** Vector4 or Color4 */
  50711. Vector4OrColor4 = 80,
  50712. /** Color3 or Color4 */
  50713. Color3OrColor4 = 96,
  50714. /** Vector3 or Color3 */
  50715. Vector3OrColor3OrVector4OrColor4 = 120,
  50716. /** Detect type based on connection */
  50717. AutoDetect = 1024,
  50718. /** Output type that will be defined by input type */
  50719. BasedOnInput = 2048,
  50720. /** Light */
  50721. Light = 4096
  50722. }
  50723. }
  50724. declare module BABYLON {
  50725. /**
  50726. * Enum used to define well known values e.g. values automatically provided by the system
  50727. */
  50728. export enum NodeMaterialWellKnownValues {
  50729. /** World */
  50730. World = 1,
  50731. /** View */
  50732. View = 2,
  50733. /** Projection */
  50734. Projection = 3,
  50735. /** ViewProjection */
  50736. ViewProjection = 4,
  50737. /** WorldView */
  50738. WorldView = 5,
  50739. /** WorldViewProjection */
  50740. WorldViewProjection = 6,
  50741. /** CameraPosition */
  50742. CameraPosition = 7,
  50743. /** Will be filled by the block itself */
  50744. Automatic = 8
  50745. }
  50746. }
  50747. declare module BABYLON {
  50748. /**
  50749. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  50750. */
  50751. export enum NodeMaterialBlockConnectionPointMode {
  50752. /** Value is an uniform */
  50753. Uniform = 0,
  50754. /** Value is a mesh attribute */
  50755. Attribute = 1,
  50756. /** Value is a varying between vertex and fragment shaders */
  50757. Varying = 2,
  50758. /** Mode is undefined */
  50759. Undefined = 3
  50760. }
  50761. }
  50762. declare module BABYLON {
  50763. /**
  50764. * Class used to store shared data between 2 NodeMaterialBuildState
  50765. */
  50766. export class NodeMaterialBuildStateSharedData {
  50767. /**
  50768. * Gets the list of emitted varyings
  50769. */
  50770. varyings: string[];
  50771. /**
  50772. * Gets the varying declaration string
  50773. */
  50774. varyingDeclaration: string;
  50775. /**
  50776. * Uniform connection points
  50777. */
  50778. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  50779. /**
  50780. * Bindable blocks (Blocks that need to set data to the effect)
  50781. */
  50782. bindableBlocks: NodeMaterialBlock[];
  50783. /**
  50784. * List of blocks that can provide a compilation fallback
  50785. */
  50786. blocksWithFallbacks: NodeMaterialBlock[];
  50787. /**
  50788. * List of blocks that can provide a define update
  50789. */
  50790. blocksWithDefines: NodeMaterialBlock[];
  50791. /**
  50792. * List of blocks that can provide a repeatable content
  50793. */
  50794. repeatableContentBlocks: NodeMaterialBlock[];
  50795. /**
  50796. * List of blocks that can block the isReady function for the material
  50797. */
  50798. blockingBlocks: NodeMaterialBlock[];
  50799. /**
  50800. * Build Id used to avoid multiple recompilations
  50801. */
  50802. buildId: number;
  50803. /** List of emitted variables */
  50804. variableNames: {
  50805. [key: string]: number;
  50806. };
  50807. /** List of emitted defines */
  50808. defineNames: {
  50809. [key: string]: number;
  50810. };
  50811. /** Should emit comments? */
  50812. emitComments: boolean;
  50813. /** Emit build activity */
  50814. verbose: boolean;
  50815. /**
  50816. * Gets the compilation hints emitted at compilation time
  50817. */
  50818. hints: {
  50819. needWorldViewMatrix: boolean;
  50820. needWorldViewProjectionMatrix: boolean;
  50821. needAlphaBlending: boolean;
  50822. needAlphaTesting: boolean;
  50823. };
  50824. /**
  50825. * List of compilation checks
  50826. */
  50827. checks: {
  50828. emitVertex: boolean;
  50829. emitFragment: boolean;
  50830. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  50831. };
  50832. /** Creates a new shared data */
  50833. constructor();
  50834. /**
  50835. * Emits console errors and exceptions if there is a failing check
  50836. */
  50837. emitErrors(): void;
  50838. }
  50839. }
  50840. declare module BABYLON {
  50841. /**
  50842. * Class used to store node based material build state
  50843. */
  50844. export class NodeMaterialBuildState {
  50845. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  50846. supportUniformBuffers: boolean;
  50847. /**
  50848. * Gets the list of emitted attributes
  50849. */
  50850. attributes: string[];
  50851. /**
  50852. * Gets the list of emitted uniforms
  50853. */
  50854. uniforms: string[];
  50855. /**
  50856. * Gets the list of emitted uniform buffers
  50857. */
  50858. uniformBuffers: string[];
  50859. /**
  50860. * Gets the list of emitted samplers
  50861. */
  50862. samplers: string[];
  50863. /**
  50864. * Gets the list of emitted functions
  50865. */
  50866. functions: {
  50867. [key: string]: string;
  50868. };
  50869. /**
  50870. * Gets the target of the compilation state
  50871. */
  50872. target: NodeMaterialBlockTargets;
  50873. /**
  50874. * Gets the list of emitted counters
  50875. */
  50876. counters: {
  50877. [key: string]: number;
  50878. };
  50879. /**
  50880. * Shared data between multiple NodeMaterialBuildState instances
  50881. */
  50882. sharedData: NodeMaterialBuildStateSharedData;
  50883. /** @hidden */
  50884. _vertexState: NodeMaterialBuildState;
  50885. private _attributeDeclaration;
  50886. private _uniformDeclaration;
  50887. private _samplerDeclaration;
  50888. private _varyingTransfer;
  50889. private _repeatableContentAnchorIndex;
  50890. /** @hidden */
  50891. _builtCompilationString: string;
  50892. /**
  50893. * Gets the emitted compilation strings
  50894. */
  50895. compilationString: string;
  50896. /**
  50897. * Finalize the compilation strings
  50898. * @param state defines the current compilation state
  50899. */
  50900. finalize(state: NodeMaterialBuildState): void;
  50901. /** @hidden */
  50902. readonly _repeatableContentAnchor: string;
  50903. /** @hidden */
  50904. _getFreeVariableName(prefix: string): string;
  50905. /** @hidden */
  50906. _getFreeDefineName(prefix: string): string;
  50907. /** @hidden */
  50908. _excludeVariableName(name: string): void;
  50909. /** @hidden */
  50910. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  50911. /** @hidden */
  50912. _emitFunction(name: string, code: string, comments: string): void;
  50913. /** @hidden */
  50914. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  50915. replaceStrings?: {
  50916. search: RegExp;
  50917. replace: string;
  50918. }[];
  50919. }): string;
  50920. /** @hidden */
  50921. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  50922. repeatKey?: string;
  50923. removeAttributes?: boolean;
  50924. removeUniforms?: boolean;
  50925. removeVaryings?: boolean;
  50926. removeIfDef?: boolean;
  50927. replaceStrings?: {
  50928. search: RegExp;
  50929. replace: string;
  50930. }[];
  50931. }, storeKey?: string): void;
  50932. /** @hidden */
  50933. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  50934. private _emitDefine;
  50935. /** @hidden */
  50936. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  50937. }
  50938. }
  50939. declare module BABYLON {
  50940. /**
  50941. * Root class for all node material optimizers
  50942. */
  50943. export class NodeMaterialOptimizer {
  50944. /**
  50945. * Function used to optimize a NodeMaterial graph
  50946. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  50947. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  50948. */
  50949. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  50950. }
  50951. }
  50952. declare module BABYLON {
  50953. /**
  50954. * Block used to transform a vector4 with a matrix
  50955. */
  50956. export class Vector4TransformBlock extends NodeMaterialBlock {
  50957. /**
  50958. * Defines the value to use to complement Vector3 to transform it to a Vector4
  50959. */
  50960. complementW: number;
  50961. /**
  50962. * Creates a new Vector4TransformBlock
  50963. * @param name defines the block name
  50964. */
  50965. constructor(name: string);
  50966. /**
  50967. * Gets the current class name
  50968. * @returns the class name
  50969. */
  50970. getClassName(): string;
  50971. /**
  50972. * Gets the vector input
  50973. */
  50974. readonly vector: NodeMaterialConnectionPoint;
  50975. /**
  50976. * Gets the output component
  50977. */
  50978. readonly output: NodeMaterialConnectionPoint;
  50979. /**
  50980. * Gets the matrix transform input
  50981. */
  50982. readonly transform: NodeMaterialConnectionPoint;
  50983. protected _buildBlock(state: NodeMaterialBuildState): this;
  50984. }
  50985. }
  50986. declare module BABYLON {
  50987. /**
  50988. * Block used to output the vertex position
  50989. */
  50990. export class VertexOutputBlock extends NodeMaterialBlock {
  50991. /**
  50992. * Creates a new VertexOutputBlock
  50993. * @param name defines the block name
  50994. */
  50995. constructor(name: string);
  50996. /**
  50997. * Gets the current class name
  50998. * @returns the class name
  50999. */
  51000. getClassName(): string;
  51001. /**
  51002. * Gets the vector input component
  51003. */
  51004. readonly vector: NodeMaterialConnectionPoint;
  51005. protected _buildBlock(state: NodeMaterialBuildState): this;
  51006. }
  51007. }
  51008. declare module BABYLON {
  51009. /**
  51010. * Block used to output the final color
  51011. */
  51012. export class FragmentOutputBlock extends NodeMaterialBlock {
  51013. /**
  51014. * Gets or sets a boolean indicating if this block will output an alpha value
  51015. */
  51016. alphaBlendingEnabled: boolean;
  51017. /**
  51018. * Create a new FragmentOutputBlock
  51019. * @param name defines the block name
  51020. */
  51021. constructor(name: string);
  51022. /**
  51023. * Gets the current class name
  51024. * @returns the class name
  51025. */
  51026. getClassName(): string;
  51027. /**
  51028. * Gets the color input component
  51029. */
  51030. readonly color: NodeMaterialConnectionPoint;
  51031. protected _buildBlock(state: NodeMaterialBuildState): this;
  51032. }
  51033. }
  51034. declare module BABYLON {
  51035. /**
  51036. * Interface used to configure the node material editor
  51037. */
  51038. export interface INodeMaterialEditorOptions {
  51039. /** Define the URl to load node editor script */
  51040. editorURL?: string;
  51041. }
  51042. /** @hidden */
  51043. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51044. /** BONES */
  51045. NUM_BONE_INFLUENCERS: number;
  51046. BonesPerMesh: number;
  51047. BONETEXTURE: boolean;
  51048. /** MORPH TARGETS */
  51049. MORPHTARGETS: boolean;
  51050. MORPHTARGETS_NORMAL: boolean;
  51051. MORPHTARGETS_TANGENT: boolean;
  51052. MORPHTARGETS_UV: boolean;
  51053. NUM_MORPH_INFLUENCERS: number;
  51054. /** IMAGE PROCESSING */
  51055. IMAGEPROCESSING: boolean;
  51056. VIGNETTE: boolean;
  51057. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51058. VIGNETTEBLENDMODEOPAQUE: boolean;
  51059. TONEMAPPING: boolean;
  51060. TONEMAPPING_ACES: boolean;
  51061. CONTRAST: boolean;
  51062. EXPOSURE: boolean;
  51063. COLORCURVES: boolean;
  51064. COLORGRADING: boolean;
  51065. COLORGRADING3D: boolean;
  51066. SAMPLER3DGREENDEPTH: boolean;
  51067. SAMPLER3DBGRMAP: boolean;
  51068. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51069. constructor();
  51070. setValue(name: string, value: boolean): void;
  51071. }
  51072. /**
  51073. * Class used to configure NodeMaterial
  51074. */
  51075. export interface INodeMaterialOptions {
  51076. /**
  51077. * Defines if blocks should emit comments
  51078. */
  51079. emitComments: boolean;
  51080. }
  51081. /**
  51082. * Class used to create a node based material built by assembling shader blocks
  51083. */
  51084. export class NodeMaterial extends PushMaterial {
  51085. private _options;
  51086. private _vertexCompilationState;
  51087. private _fragmentCompilationState;
  51088. private _sharedData;
  51089. private _buildId;
  51090. private _buildWasSuccessful;
  51091. private _cachedWorldViewMatrix;
  51092. private _cachedWorldViewProjectionMatrix;
  51093. private _textureConnectionPoints;
  51094. private _optimizers;
  51095. /** Define the URl to load node editor script */
  51096. static EditorURL: string;
  51097. private BJSNODEMATERIALEDITOR;
  51098. /** Get the inspector from bundle or global */
  51099. private _getGlobalNodeMaterialEditor;
  51100. /**
  51101. * Defines the maximum number of lights that can be used in the material
  51102. */
  51103. maxSimultaneousLights: number;
  51104. /**
  51105. * Observable raised when the material is built
  51106. */
  51107. onBuildObservable: Observable<NodeMaterial>;
  51108. /**
  51109. * Gets or sets the root nodes of the material vertex shader
  51110. */
  51111. _vertexOutputNodes: NodeMaterialBlock[];
  51112. /**
  51113. * Gets or sets the root nodes of the material fragment (pixel) shader
  51114. */
  51115. _fragmentOutputNodes: NodeMaterialBlock[];
  51116. /** Gets or sets options to control the node material overall behavior */
  51117. options: INodeMaterialOptions;
  51118. /**
  51119. * Default configuration related to image processing available in the standard Material.
  51120. */
  51121. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51122. /**
  51123. * Gets the image processing configuration used either in this material.
  51124. */
  51125. /**
  51126. * Sets the Default image processing configuration used either in the this material.
  51127. *
  51128. * If sets to null, the scene one is in use.
  51129. */
  51130. imageProcessingConfiguration: ImageProcessingConfiguration;
  51131. /**
  51132. * Create a new node based material
  51133. * @param name defines the material name
  51134. * @param scene defines the hosting scene
  51135. * @param options defines creation option
  51136. */
  51137. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51138. /**
  51139. * Gets the current class name of the material e.g. "NodeMaterial"
  51140. * @returns the class name
  51141. */
  51142. getClassName(): string;
  51143. /**
  51144. * Keep track of the image processing observer to allow dispose and replace.
  51145. */
  51146. private _imageProcessingObserver;
  51147. /**
  51148. * Attaches a new image processing configuration to the Standard Material.
  51149. * @param configuration
  51150. */
  51151. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51152. /**
  51153. * Adds a new optimizer to the list of optimizers
  51154. * @param optimizer defines the optimizers to add
  51155. * @returns the current material
  51156. */
  51157. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51158. /**
  51159. * Remove an optimizer from the list of optimizers
  51160. * @param optimizer defines the optimizers to remove
  51161. * @returns the current material
  51162. */
  51163. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51164. /**
  51165. * Add a new block to the list of output nodes
  51166. * @param node defines the node to add
  51167. * @returns the current material
  51168. */
  51169. addOutputNode(node: NodeMaterialBlock): this;
  51170. /**
  51171. * Remove a block from the list of root nodes
  51172. * @param node defines the node to remove
  51173. * @returns the current material
  51174. */
  51175. removeOutputNode(node: NodeMaterialBlock): this;
  51176. private _addVertexOutputNode;
  51177. private _removeVertexOutputNode;
  51178. private _addFragmentOutputNode;
  51179. private _removeFragmentOutputNode;
  51180. /**
  51181. * Specifies if the material will require alpha blending
  51182. * @returns a boolean specifying if alpha blending is needed
  51183. */
  51184. needAlphaBlending(): boolean;
  51185. /**
  51186. * Specifies if this material should be rendered in alpha test mode
  51187. * @returns a boolean specifying if an alpha test is needed.
  51188. */
  51189. needAlphaTesting(): boolean;
  51190. private _initializeBlock;
  51191. private _resetDualBlocks;
  51192. /**
  51193. * Build the material and generates the inner effect
  51194. * @param verbose defines if the build should log activity
  51195. */
  51196. build(verbose?: boolean): void;
  51197. /**
  51198. * Runs an otpimization phase to try to improve the shader code
  51199. */
  51200. optimize(): void;
  51201. private _prepareDefinesForAttributes;
  51202. /**
  51203. * Get if the submesh is ready to be used and all its information available.
  51204. * Child classes can use it to update shaders
  51205. * @param mesh defines the mesh to check
  51206. * @param subMesh defines which submesh to check
  51207. * @param useInstances specifies that instances should be used
  51208. * @returns a boolean indicating that the submesh is ready or not
  51209. */
  51210. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51211. /**
  51212. * Binds the world matrix to the material
  51213. * @param world defines the world transformation matrix
  51214. */
  51215. bindOnlyWorldMatrix(world: Matrix): void;
  51216. /**
  51217. * Binds the submesh to this material by preparing the effect and shader to draw
  51218. * @param world defines the world transformation matrix
  51219. * @param mesh defines the mesh containing the submesh
  51220. * @param subMesh defines the submesh to bind the material to
  51221. */
  51222. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51223. /**
  51224. * Gets the active textures from the material
  51225. * @returns an array of textures
  51226. */
  51227. getActiveTextures(): BaseTexture[];
  51228. /**
  51229. * Specifies if the material uses a texture
  51230. * @param texture defines the texture to check against the material
  51231. * @returns a boolean specifying if the material uses the texture
  51232. */
  51233. hasTexture(texture: BaseTexture): boolean;
  51234. /**
  51235. * Disposes the material
  51236. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51237. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51238. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51239. */
  51240. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51241. /** Creates the node editor window. */
  51242. private _createNodeEditor;
  51243. /**
  51244. * Launch the node material editor
  51245. * @param config Define the configuration of the editor
  51246. * @return a promise fulfilled when the node editor is visible
  51247. */
  51248. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51249. /**
  51250. * Clear the current material
  51251. */
  51252. clear(): void;
  51253. /**
  51254. * Clear the current material and set it to a default state
  51255. */
  51256. setToDefault(): void;
  51257. }
  51258. }
  51259. declare module BABYLON {
  51260. /**
  51261. * Defines a block that can be used inside a node based material
  51262. */
  51263. export class NodeMaterialBlock {
  51264. private _buildId;
  51265. private _target;
  51266. private _isFinalMerger;
  51267. /** @hidden */
  51268. _inputs: NodeMaterialConnectionPoint[];
  51269. /** @hidden */
  51270. _outputs: NodeMaterialConnectionPoint[];
  51271. /**
  51272. * Gets or sets the name of the block
  51273. */
  51274. name: string;
  51275. /**
  51276. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  51277. */
  51278. readonly isFinalMerger: boolean;
  51279. /**
  51280. * Gets or sets the build Id
  51281. */
  51282. buildId: number;
  51283. /**
  51284. * Gets or sets the target of the block
  51285. */
  51286. target: NodeMaterialBlockTargets;
  51287. /**
  51288. * Gets the list of input points
  51289. */
  51290. readonly inputs: NodeMaterialConnectionPoint[];
  51291. /** Gets the list of output points */
  51292. readonly outputs: NodeMaterialConnectionPoint[];
  51293. /**
  51294. * Find an input by its name
  51295. * @param name defines the name of the input to look for
  51296. * @returns the input or null if not found
  51297. */
  51298. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51299. /**
  51300. * Find an output by its name
  51301. * @param name defines the name of the outputto look for
  51302. * @returns the output or null if not found
  51303. */
  51304. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51305. /**
  51306. * Creates a new NodeMaterialBlock
  51307. * @param name defines the block name
  51308. * @param target defines the target of that block (Vertex by default)
  51309. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  51310. */
  51311. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  51312. /**
  51313. * Initialize the block and prepare the context for build
  51314. * @param state defines the state that will be used for the build
  51315. */
  51316. initialize(state: NodeMaterialBuildState): void;
  51317. /**
  51318. * Bind data to effect. Will only be called for blocks with isBindable === true
  51319. * @param effect defines the effect to bind data to
  51320. * @param nodeMaterial defines the hosting NodeMaterial
  51321. * @param mesh defines the mesh that will be rendered
  51322. */
  51323. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51324. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  51325. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  51326. protected _writeFloat(value: number): string;
  51327. /**
  51328. * Gets the current class name e.g. "NodeMaterialBlock"
  51329. * @returns the class name
  51330. */
  51331. getClassName(): string;
  51332. /**
  51333. * Register a new input. Must be called inside a block constructor
  51334. * @param name defines the connection point name
  51335. * @param type defines the connection point type
  51336. * @param isOptional defines a boolean indicating that this input can be omitted
  51337. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51338. * @returns the current block
  51339. */
  51340. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  51341. /**
  51342. * Register a new output. Must be called inside a block constructor
  51343. * @param name defines the connection point name
  51344. * @param type defines the connection point type
  51345. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51346. * @returns the current block
  51347. */
  51348. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  51349. /**
  51350. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  51351. * @param forOutput defines an optional connection point to check compatibility with
  51352. * @returns the first available input or null
  51353. */
  51354. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  51355. /**
  51356. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  51357. * @param forBlock defines an optional block to check compatibility with
  51358. * @returns the first available input or null
  51359. */
  51360. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  51361. /**
  51362. * Connect current block with another block
  51363. * @param other defines the block to connect with
  51364. * @param options define the various options to help pick the right connections
  51365. * @returns the current block
  51366. */
  51367. connectTo(other: NodeMaterialBlock, options?: {
  51368. input?: string;
  51369. output?: string;
  51370. outputSwizzle?: string;
  51371. }): this | undefined;
  51372. protected _buildBlock(state: NodeMaterialBuildState): void;
  51373. /**
  51374. * Add potential fallbacks if shader compilation fails
  51375. * @param mesh defines the mesh to be rendered
  51376. * @param fallbacks defines the current prioritized list of fallbacks
  51377. */
  51378. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51379. /**
  51380. * Update defines for shader compilation
  51381. * @param mesh defines the mesh to be rendered
  51382. * @param nodeMaterial defines the node material requesting the update
  51383. * @param defines defines the material defines to update
  51384. * @param useInstances specifies that instances should be used
  51385. */
  51386. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51387. /**
  51388. * Lets the block try to connect some inputs automatically
  51389. */
  51390. autoConfigure(): void;
  51391. /**
  51392. * Function called when a block is declared as repeatable content generator
  51393. * @param vertexShaderState defines the current compilation state for the vertex shader
  51394. * @param fragmentShaderState defines the current compilation state for the fragment shader
  51395. * @param mesh defines the mesh to be rendered
  51396. * @param defines defines the material defines to update
  51397. */
  51398. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51399. /**
  51400. * Checks if the block is ready
  51401. * @param mesh defines the mesh to be rendered
  51402. * @param nodeMaterial defines the node material requesting the update
  51403. * @param defines defines the material defines to update
  51404. * @param useInstances specifies that instances should be used
  51405. * @returns true if the block is ready
  51406. */
  51407. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  51408. /**
  51409. * Compile the current node and generate the shader code
  51410. * @param state defines the current compilation state (uniforms, samplers, current string)
  51411. * @returns the current block
  51412. */
  51413. build(state: NodeMaterialBuildState): this | undefined;
  51414. }
  51415. }
  51416. declare module BABYLON {
  51417. /**
  51418. * Defines a connection point for a block
  51419. */
  51420. export class NodeMaterialConnectionPoint {
  51421. /** @hidden */
  51422. _ownerBlock: NodeMaterialBlock;
  51423. /** @hidden */
  51424. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51425. private _associatedVariableName;
  51426. private _endpoints;
  51427. private _storedValue;
  51428. private _valueCallback;
  51429. private _mode;
  51430. /** @hidden */
  51431. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51432. /** @hidden */
  51433. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  51434. /** @hidden */
  51435. _needToEmitVarying: boolean;
  51436. /** @hidden */
  51437. _forceUniformInVertexShaderOnly: boolean;
  51438. private _type;
  51439. /**
  51440. * Gets or sets the connection point type (default is float)
  51441. */
  51442. type: NodeMaterialBlockConnectionPointTypes;
  51443. /**
  51444. * Gets or sets the connection point name
  51445. */
  51446. name: string;
  51447. /**
  51448. * Gets or sets the swizzle to apply to this connection point when reading or writing
  51449. */
  51450. swizzle: string;
  51451. /**
  51452. * Gets or sets a boolean indicating that this connection point can be omitted
  51453. */
  51454. isOptional: boolean;
  51455. /**
  51456. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  51457. */
  51458. define: string;
  51459. /** Gets or sets the target of that connection point */
  51460. target: NodeMaterialBlockTargets;
  51461. /**
  51462. * Gets or sets the value of that point.
  51463. * Please note that this value will be ignored if valueCallback is defined
  51464. */
  51465. value: any;
  51466. /**
  51467. * Gets or sets a callback used to get the value of that point.
  51468. * Please note that setting this value will force the connection point to ignore the value property
  51469. */
  51470. valueCallback: () => any;
  51471. /**
  51472. * Gets or sets the associated variable name in the shader
  51473. */
  51474. associatedVariableName: string;
  51475. /**
  51476. * Gets a boolean indicating that this connection point not defined yet
  51477. */
  51478. readonly isUndefined: boolean;
  51479. /**
  51480. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  51481. * In this case the connection point name must be the name of the uniform to use.
  51482. * Can only be set on inputs
  51483. */
  51484. isUniform: boolean;
  51485. /**
  51486. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  51487. * In this case the connection point name must be the name of the attribute to use
  51488. * Can only be set on inputs
  51489. */
  51490. isAttribute: boolean;
  51491. /**
  51492. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  51493. * Can only be set on exit points
  51494. */
  51495. isVarying: boolean;
  51496. /** Get the other side of the connection (if any) */
  51497. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51498. /** Get the block that owns this connection point */
  51499. readonly ownerBlock: NodeMaterialBlock;
  51500. /** Get the block connected on the other side of this connection (if any) */
  51501. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  51502. /** Get the block connected on the endpoints of this connection (if any) */
  51503. readonly connectedBlocks: Array<NodeMaterialBlock>;
  51504. /**
  51505. * Creates a new connection point
  51506. * @param name defines the connection point name
  51507. * @param ownerBlock defines the block hosting this connection point
  51508. */
  51509. constructor(name: string, ownerBlock: NodeMaterialBlock);
  51510. /**
  51511. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  51512. * @returns the class name
  51513. */
  51514. getClassName(): string;
  51515. /**
  51516. * Set the source of this connection point to a vertex attribute
  51517. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  51518. * @returns the current connection point
  51519. */
  51520. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  51521. /**
  51522. * Set the source of this connection point to a well known value
  51523. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  51524. * @returns the current connection point
  51525. */
  51526. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  51527. /**
  51528. * Gets a boolean indicating that the current connection point is a well known value
  51529. */
  51530. readonly isWellKnownValue: boolean;
  51531. /**
  51532. * Gets or sets the current well known value or null if not defined as well know value
  51533. */
  51534. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51535. private _getTypeLength;
  51536. /**
  51537. * Connect this point to another connection point
  51538. * @param connectionPoint defines the other connection point
  51539. * @returns the current connection point
  51540. */
  51541. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51542. /**
  51543. * Disconnect this point from one of his endpoint
  51544. * @param endpoint defines the other connection point
  51545. * @returns the current connection point
  51546. */
  51547. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51548. /**
  51549. * When connection point is an uniform, this function will send its value to the effect
  51550. * @param effect defines the effect to transmit value to
  51551. * @param world defines the world matrix
  51552. * @param worldView defines the worldxview matrix
  51553. * @param worldViewProjection defines the worldxviewxprojection matrix
  51554. */
  51555. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  51556. /**
  51557. * When connection point is an uniform, this function will send its value to the effect
  51558. * @param effect defines the effect to transmit value to
  51559. * @param scene defines the hosting scene
  51560. */
  51561. transmit(effect: Effect, scene: Scene): void;
  51562. }
  51563. }
  51564. declare module BABYLON {
  51565. /**
  51566. * Block used to add support for vertex skinning (bones)
  51567. */
  51568. export class BonesBlock extends NodeMaterialBlock {
  51569. /**
  51570. * Creates a new BonesBlock
  51571. * @param name defines the block name
  51572. */
  51573. constructor(name: string);
  51574. /**
  51575. * Initialize the block and prepare the context for build
  51576. * @param state defines the state that will be used for the build
  51577. */
  51578. initialize(state: NodeMaterialBuildState): void;
  51579. /**
  51580. * Gets the current class name
  51581. * @returns the class name
  51582. */
  51583. getClassName(): string;
  51584. /**
  51585. * Gets the matrix indices input component
  51586. */
  51587. readonly matricesIndices: NodeMaterialConnectionPoint;
  51588. /**
  51589. * Gets the matrix weights input component
  51590. */
  51591. readonly matricesWeights: NodeMaterialConnectionPoint;
  51592. /**
  51593. * Gets the extra matrix indices input component
  51594. */
  51595. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  51596. /**
  51597. * Gets the extra matrix weights input component
  51598. */
  51599. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  51600. /**
  51601. * Gets the world input component
  51602. */
  51603. readonly world: NodeMaterialConnectionPoint;
  51604. /**
  51605. * Gets the output component
  51606. */
  51607. readonly output: NodeMaterialConnectionPoint;
  51608. autoConfigure(): void;
  51609. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51610. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51611. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51612. protected _buildBlock(state: NodeMaterialBuildState): this;
  51613. }
  51614. }
  51615. declare module BABYLON {
  51616. /**
  51617. * Block used to add support for instances
  51618. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  51619. */
  51620. export class InstancesBlock extends NodeMaterialBlock {
  51621. /**
  51622. * Creates a new InstancesBlock
  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 first world row input component
  51633. */
  51634. readonly world0: NodeMaterialConnectionPoint;
  51635. /**
  51636. * Gets the second world row input component
  51637. */
  51638. readonly world1: NodeMaterialConnectionPoint;
  51639. /**
  51640. * Gets the third world row input component
  51641. */
  51642. readonly world2: NodeMaterialConnectionPoint;
  51643. /**
  51644. * Gets the forth world row input component
  51645. */
  51646. readonly world3: NodeMaterialConnectionPoint;
  51647. /**
  51648. * Gets the world input component
  51649. */
  51650. readonly world: NodeMaterialConnectionPoint;
  51651. /**
  51652. * Gets the output component
  51653. */
  51654. readonly output: NodeMaterialConnectionPoint;
  51655. autoConfigure(): void;
  51656. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51657. protected _buildBlock(state: NodeMaterialBuildState): this;
  51658. }
  51659. }
  51660. declare module BABYLON {
  51661. /**
  51662. * Block used to add morph targets support to vertex shader
  51663. */
  51664. export class MorphTargetsBlock extends NodeMaterialBlock {
  51665. private _repeatableContentAnchor;
  51666. private _repeatebleContentGenerated;
  51667. /**
  51668. * Create a new MorphTargetsBlock
  51669. * @param name defines the block name
  51670. */
  51671. constructor(name: string);
  51672. /**
  51673. * Gets the current class name
  51674. * @returns the class name
  51675. */
  51676. getClassName(): string;
  51677. /**
  51678. * Gets the position input component
  51679. */
  51680. readonly position: NodeMaterialConnectionPoint;
  51681. /**
  51682. * Gets the normal input component
  51683. */
  51684. readonly normal: NodeMaterialConnectionPoint;
  51685. /**
  51686. * Gets the tangent input component
  51687. */
  51688. readonly tangent: NodeMaterialConnectionPoint;
  51689. /**
  51690. * Gets the tangent input component
  51691. */
  51692. readonly uv: NodeMaterialConnectionPoint;
  51693. /**
  51694. * Gets the position output component
  51695. */
  51696. readonly positionOutput: NodeMaterialConnectionPoint;
  51697. /**
  51698. * Gets the normal output component
  51699. */
  51700. readonly normalOutput: NodeMaterialConnectionPoint;
  51701. /**
  51702. * Gets the tangent output component
  51703. */
  51704. readonly tangentOutput: NodeMaterialConnectionPoint;
  51705. /**
  51706. * Gets the tangent output component
  51707. */
  51708. readonly uvOutput: NodeMaterialConnectionPoint;
  51709. initialize(state: NodeMaterialBuildState): void;
  51710. autoConfigure(): void;
  51711. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51712. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51713. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51714. protected _buildBlock(state: NodeMaterialBuildState): this;
  51715. }
  51716. }
  51717. declare module BABYLON {
  51718. /**
  51719. * Block used to add an alpha test in the fragment shader
  51720. */
  51721. export class AlphaTestBlock extends NodeMaterialBlock {
  51722. /**
  51723. * Gets or sets the alpha value where alpha testing happens
  51724. */
  51725. alphaCutOff: number;
  51726. /**
  51727. * Create a new AlphaTestBlock
  51728. * @param name defines the block name
  51729. */
  51730. constructor(name: string);
  51731. /**
  51732. * Gets the current class name
  51733. * @returns the class name
  51734. */
  51735. getClassName(): string;
  51736. /**
  51737. * Gets the color input component
  51738. */
  51739. readonly color: NodeMaterialConnectionPoint;
  51740. protected _buildBlock(state: NodeMaterialBuildState): this;
  51741. }
  51742. }
  51743. declare module BABYLON {
  51744. /**
  51745. * Block used to create a Color4 out of 4 inputs (one for each component)
  51746. */
  51747. export class RGBAMergerBlock extends NodeMaterialBlock {
  51748. /**
  51749. * Create a new RGBAMergerBlock
  51750. * @param name defines the block name
  51751. */
  51752. constructor(name: string);
  51753. /**
  51754. * Gets the current class name
  51755. * @returns the class name
  51756. */
  51757. getClassName(): string;
  51758. /**
  51759. * Gets the R input component
  51760. */
  51761. readonly r: NodeMaterialConnectionPoint;
  51762. /**
  51763. * Gets the G input component
  51764. */
  51765. readonly g: NodeMaterialConnectionPoint;
  51766. /**
  51767. * Gets the B input component
  51768. */
  51769. readonly b: NodeMaterialConnectionPoint;
  51770. /**
  51771. * Gets the RGB input component
  51772. */
  51773. readonly rgb: NodeMaterialConnectionPoint;
  51774. /**
  51775. * Gets the R input component
  51776. */
  51777. readonly a: NodeMaterialConnectionPoint;
  51778. /**
  51779. * Gets the output component
  51780. */
  51781. readonly output: NodeMaterialConnectionPoint;
  51782. protected _buildBlock(state: NodeMaterialBuildState): this;
  51783. }
  51784. }
  51785. declare module BABYLON {
  51786. /**
  51787. * Block used to create a Color3 out of 3 inputs (one for each component)
  51788. */
  51789. export class RGBMergerBlock extends NodeMaterialBlock {
  51790. /**
  51791. * Create a new RGBMergerBlock
  51792. * @param name defines the block name
  51793. */
  51794. constructor(name: string);
  51795. /**
  51796. * Gets the current class name
  51797. * @returns the class name
  51798. */
  51799. getClassName(): string;
  51800. /**
  51801. * Gets the R component input
  51802. */
  51803. readonly r: NodeMaterialConnectionPoint;
  51804. /**
  51805. * Gets the G component input
  51806. */
  51807. readonly g: NodeMaterialConnectionPoint;
  51808. /**
  51809. * Gets the B component input
  51810. */
  51811. readonly b: NodeMaterialConnectionPoint;
  51812. /**
  51813. * Gets the output component
  51814. */
  51815. readonly output: NodeMaterialConnectionPoint;
  51816. protected _buildBlock(state: NodeMaterialBuildState): this;
  51817. }
  51818. }
  51819. declare module BABYLON {
  51820. /**
  51821. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  51822. */
  51823. export class RGBASplitterBlock extends NodeMaterialBlock {
  51824. /**
  51825. * Create a new RGBASplitterBlock
  51826. * @param name defines the block name
  51827. */
  51828. constructor(name: string);
  51829. /**
  51830. * Gets the current class name
  51831. * @returns the class name
  51832. */
  51833. getClassName(): string;
  51834. /**
  51835. * Gets the input component
  51836. */
  51837. readonly input: NodeMaterialConnectionPoint;
  51838. protected _buildBlock(state: NodeMaterialBuildState): this;
  51839. }
  51840. }
  51841. declare module BABYLON {
  51842. /**
  51843. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  51844. */
  51845. export class RGBSplitterBlock extends NodeMaterialBlock {
  51846. /**
  51847. * Create a new RGBSplitterBlock
  51848. * @param name defines the block name
  51849. */
  51850. constructor(name: string);
  51851. /**
  51852. * Gets the current class name
  51853. * @returns the class name
  51854. */
  51855. getClassName(): string;
  51856. /**
  51857. * Gets the input component
  51858. */
  51859. readonly input: NodeMaterialConnectionPoint;
  51860. protected _buildBlock(state: NodeMaterialBuildState): this;
  51861. }
  51862. }
  51863. declare module BABYLON {
  51864. /**
  51865. * Block used to read a texture from a sampler
  51866. */
  51867. export class TextureBlock extends NodeMaterialBlock {
  51868. private _defineName;
  51869. /**
  51870. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  51871. */
  51872. autoConnectTextureMatrix: boolean;
  51873. /**
  51874. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  51875. */
  51876. autoSelectUV: boolean;
  51877. /**
  51878. * Create a new TextureBlock
  51879. * @param name defines the block name
  51880. */
  51881. constructor(name: string);
  51882. /**
  51883. * Gets the current class name
  51884. * @returns the class name
  51885. */
  51886. getClassName(): string;
  51887. /**
  51888. * Gets the uv input component
  51889. */
  51890. readonly uv: NodeMaterialConnectionPoint;
  51891. /**
  51892. * Gets the texture information input component
  51893. */
  51894. readonly textureInfo: NodeMaterialConnectionPoint;
  51895. /**
  51896. * Gets the transformed uv input component
  51897. */
  51898. readonly transformedUV: NodeMaterialConnectionPoint;
  51899. /**
  51900. * Gets the texture input component
  51901. */
  51902. readonly texture: NodeMaterialConnectionPoint;
  51903. /**
  51904. * Gets the texture transform input component
  51905. */
  51906. readonly textureTransform: NodeMaterialConnectionPoint;
  51907. /**
  51908. * Gets the output component
  51909. */
  51910. readonly output: NodeMaterialConnectionPoint;
  51911. autoConfigure(): void;
  51912. initialize(state: NodeMaterialBuildState): void;
  51913. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51914. isReady(): boolean;
  51915. private _injectVertexCode;
  51916. protected _buildBlock(state: NodeMaterialBuildState): this;
  51917. }
  51918. }
  51919. declare module BABYLON {
  51920. /**
  51921. * Block used to add image processing support to fragment shader
  51922. */
  51923. export class ImageProcessingBlock extends NodeMaterialBlock {
  51924. /**
  51925. * Create a new ImageProcessingBlock
  51926. * @param name defines the block name
  51927. */
  51928. constructor(name: string);
  51929. /**
  51930. * Gets the current class name
  51931. * @returns the class name
  51932. */
  51933. getClassName(): string;
  51934. /**
  51935. * Gets the color input component
  51936. */
  51937. readonly color: NodeMaterialConnectionPoint;
  51938. /**
  51939. * Gets the output component
  51940. */
  51941. readonly output: NodeMaterialConnectionPoint;
  51942. /**
  51943. * Initialize the block and prepare the context for build
  51944. * @param state defines the state that will be used for the build
  51945. */
  51946. initialize(state: NodeMaterialBuildState): void;
  51947. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  51948. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51949. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51950. protected _buildBlock(state: NodeMaterialBuildState): this;
  51951. }
  51952. }
  51953. declare module BABYLON {
  51954. /**
  51955. * Block used to add support for scene fog
  51956. */
  51957. export class FogBlock extends NodeMaterialBlock {
  51958. /**
  51959. * Create a new FogBlock
  51960. * @param name defines the block name
  51961. */
  51962. constructor(name: string);
  51963. /**
  51964. * Gets the current class name
  51965. * @returns the class name
  51966. */
  51967. getClassName(): string;
  51968. /**
  51969. * Gets the world position input component
  51970. */
  51971. readonly worldPosition: NodeMaterialConnectionPoint;
  51972. /**
  51973. * Gets the view input component
  51974. */
  51975. readonly view: NodeMaterialConnectionPoint;
  51976. /**
  51977. * Gets the color input component
  51978. */
  51979. readonly color: NodeMaterialConnectionPoint;
  51980. /**
  51981. * Gets the fog color input component
  51982. */
  51983. readonly fogColor: NodeMaterialConnectionPoint;
  51984. /**
  51985. * Gets the for parameter input component
  51986. */
  51987. readonly fogParameters: NodeMaterialConnectionPoint;
  51988. /**
  51989. * Gets the output component
  51990. */
  51991. readonly output: NodeMaterialConnectionPoint;
  51992. autoConfigure(): void;
  51993. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51994. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51995. protected _buildBlock(state: NodeMaterialBuildState): this;
  51996. }
  51997. }
  51998. declare module BABYLON {
  51999. /**
  52000. * Block used to add light in the fragment shader
  52001. */
  52002. export class LightBlock extends NodeMaterialBlock {
  52003. private _lightId;
  52004. /**
  52005. * Create a new LightBlock
  52006. * @param name defines the block name
  52007. */
  52008. constructor(name: string);
  52009. /**
  52010. * Gets the current class name
  52011. * @returns the class name
  52012. */
  52013. getClassName(): string;
  52014. /**
  52015. * Gets the world position input component
  52016. */
  52017. readonly worldPosition: NodeMaterialConnectionPoint;
  52018. /**
  52019. * Gets the world normal input component
  52020. */
  52021. readonly worldNormal: NodeMaterialConnectionPoint;
  52022. /**
  52023. * Gets the light input component
  52024. */
  52025. readonly light: NodeMaterialConnectionPoint;
  52026. /**
  52027. * Gets the camera (or eye) position component
  52028. */
  52029. readonly cameraPosition: NodeMaterialConnectionPoint;
  52030. /**
  52031. * Gets the diffuse output component
  52032. */
  52033. readonly diffuseOutput: NodeMaterialConnectionPoint;
  52034. /**
  52035. * Gets the specular output component
  52036. */
  52037. readonly specularOutput: NodeMaterialConnectionPoint;
  52038. autoConfigure(): void;
  52039. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52040. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52041. private _injectVertexCode;
  52042. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52043. }
  52044. }
  52045. declare module BABYLON {
  52046. /**
  52047. * Block used to multiply 2 vector4
  52048. */
  52049. export class MultiplyBlock extends NodeMaterialBlock {
  52050. /**
  52051. * Creates a new MultiplyBlock
  52052. * @param name defines the block name
  52053. */
  52054. constructor(name: string);
  52055. /**
  52056. * Gets the current class name
  52057. * @returns the class name
  52058. */
  52059. getClassName(): string;
  52060. /**
  52061. * Gets the left operand input component
  52062. */
  52063. readonly left: NodeMaterialConnectionPoint;
  52064. /**
  52065. * Gets the right operand input component
  52066. */
  52067. readonly right: NodeMaterialConnectionPoint;
  52068. /**
  52069. * Gets the output component
  52070. */
  52071. readonly output: NodeMaterialConnectionPoint;
  52072. protected _buildBlock(state: NodeMaterialBuildState): this;
  52073. }
  52074. }
  52075. declare module BABYLON {
  52076. /**
  52077. * Block used to add 2 vector4
  52078. */
  52079. export class AddBlock extends NodeMaterialBlock {
  52080. /**
  52081. * Creates a new AddBlock
  52082. * @param name defines the block name
  52083. */
  52084. constructor(name: string);
  52085. /**
  52086. * Gets the current class name
  52087. * @returns the class name
  52088. */
  52089. getClassName(): string;
  52090. /**
  52091. * Gets the left operand input component
  52092. */
  52093. readonly left: NodeMaterialConnectionPoint;
  52094. /**
  52095. * Gets the right operand input component
  52096. */
  52097. readonly right: NodeMaterialConnectionPoint;
  52098. /**
  52099. * Gets the output component
  52100. */
  52101. readonly output: NodeMaterialConnectionPoint;
  52102. protected _buildBlock(state: NodeMaterialBuildState): this;
  52103. }
  52104. }
  52105. declare module BABYLON {
  52106. /**
  52107. * Block used to clamp a float
  52108. */
  52109. export class ClampBlock extends NodeMaterialBlock {
  52110. /** Gets or sets the minimum range */
  52111. minimum: number;
  52112. /** Gets or sets the maximum range */
  52113. maximum: number;
  52114. /**
  52115. * Creates a new ClampBlock
  52116. * @param name defines the block name
  52117. */
  52118. constructor(name: string);
  52119. /**
  52120. * Gets the current class name
  52121. * @returns the class name
  52122. */
  52123. getClassName(): string;
  52124. /**
  52125. * Gets the value input component
  52126. */
  52127. readonly value: NodeMaterialConnectionPoint;
  52128. /**
  52129. * Gets the output component
  52130. */
  52131. readonly output: NodeMaterialConnectionPoint;
  52132. protected _buildBlock(state: NodeMaterialBuildState): this;
  52133. }
  52134. }
  52135. declare module BABYLON {
  52136. /**
  52137. * Block used to scale a value
  52138. */
  52139. export class ScaleBlock extends NodeMaterialBlock {
  52140. /**
  52141. * Creates a new ScaleBlock
  52142. * @param name defines the block name
  52143. */
  52144. constructor(name: string);
  52145. /**
  52146. * Gets the current class name
  52147. * @returns the class name
  52148. */
  52149. getClassName(): string;
  52150. /**
  52151. * Gets the value operand input component
  52152. */
  52153. readonly value: NodeMaterialConnectionPoint;
  52154. /**
  52155. * Gets the scale operand input component
  52156. */
  52157. readonly scale: NodeMaterialConnectionPoint;
  52158. /**
  52159. * Gets the output component
  52160. */
  52161. readonly output: NodeMaterialConnectionPoint;
  52162. protected _buildBlock(state: NodeMaterialBuildState): this;
  52163. }
  52164. }
  52165. declare module BABYLON {
  52166. /**
  52167. * Block used to transform a vector2 with a matrix
  52168. */
  52169. export class Vector2TransformBlock extends NodeMaterialBlock {
  52170. /**
  52171. * Defines the value to use to complement Vector2 to transform it to a Vector4
  52172. */
  52173. complementZ: number;
  52174. /**
  52175. * Defines the value to use to complement Vector2 to transform it to a Vector4
  52176. */
  52177. complementW: number;
  52178. /**
  52179. * Creates a new Vector2TransformBlock
  52180. * @param name defines the block name
  52181. */
  52182. constructor(name: string);
  52183. /**
  52184. * Gets the vector input
  52185. */
  52186. readonly vector: NodeMaterialConnectionPoint;
  52187. /**
  52188. * Gets the matrix transform input
  52189. */
  52190. readonly transform: NodeMaterialConnectionPoint;
  52191. /**
  52192. * Gets the output component
  52193. */
  52194. readonly output: NodeMaterialConnectionPoint;
  52195. /**
  52196. * Gets the current class name
  52197. * @returns the class name
  52198. */
  52199. getClassName(): string;
  52200. protected _buildBlock(state: NodeMaterialBuildState): this;
  52201. }
  52202. }
  52203. declare module BABYLON {
  52204. /**
  52205. * Block used to transform a vector3 with a matrix
  52206. */
  52207. export class Vector3TransformBlock extends NodeMaterialBlock {
  52208. /**
  52209. * Defines the value to use to complement Vector3 to transform it to a Vector4
  52210. */
  52211. complement: number;
  52212. /**
  52213. * Creates a new Vector3TransformBlock
  52214. * @param name defines the block name
  52215. */
  52216. constructor(name: string);
  52217. /**
  52218. * Gets the vector input
  52219. */
  52220. readonly vector: NodeMaterialConnectionPoint;
  52221. /**
  52222. * Gets the matrix transform input
  52223. */
  52224. readonly transform: NodeMaterialConnectionPoint;
  52225. /**
  52226. * Gets the output component
  52227. */
  52228. readonly output: NodeMaterialConnectionPoint;
  52229. /**
  52230. * Gets the current class name
  52231. * @returns the class name
  52232. */
  52233. getClassName(): string;
  52234. protected _buildBlock(state: NodeMaterialBuildState): this;
  52235. }
  52236. }
  52237. declare module BABYLON {
  52238. /**
  52239. * Block used to multiply two matrices
  52240. */
  52241. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  52242. /**
  52243. * Creates a new MatrixMultiplicationBlock
  52244. * @param name defines the block name
  52245. */
  52246. constructor(name: string);
  52247. /**
  52248. * Gets the left operand
  52249. */
  52250. readonly left: NodeMaterialConnectionPoint;
  52251. /**
  52252. * Gets the right operand
  52253. */
  52254. readonly right: NodeMaterialConnectionPoint;
  52255. /**
  52256. * Gets the output component
  52257. */
  52258. readonly output: NodeMaterialConnectionPoint;
  52259. /**
  52260. * Gets the current class name
  52261. * @returns the class name
  52262. */
  52263. getClassName(): string;
  52264. protected _buildBlock(state: NodeMaterialBuildState): this;
  52265. }
  52266. }
  52267. declare module BABYLON {
  52268. /**
  52269. * Helper class to push actions to a pool of workers.
  52270. */
  52271. export class WorkerPool implements IDisposable {
  52272. private _workerInfos;
  52273. private _pendingActions;
  52274. /**
  52275. * Constructor
  52276. * @param workers Array of workers to use for actions
  52277. */
  52278. constructor(workers: Array<Worker>);
  52279. /**
  52280. * Terminates all workers and clears any pending actions.
  52281. */
  52282. dispose(): void;
  52283. /**
  52284. * Pushes an action to the worker pool. If all the workers are active, the action will be
  52285. * pended until a worker has completed its action.
  52286. * @param action The action to perform. Call onComplete when the action is complete.
  52287. */
  52288. push(action: (worker: Worker, onComplete: () => void) => void): void;
  52289. private _execute;
  52290. }
  52291. }
  52292. declare module BABYLON {
  52293. /**
  52294. * Configuration for Draco compression
  52295. */
  52296. export interface IDracoCompressionConfiguration {
  52297. /**
  52298. * Configuration for the decoder.
  52299. */
  52300. decoder: {
  52301. /**
  52302. * The url to the WebAssembly module.
  52303. */
  52304. wasmUrl?: string;
  52305. /**
  52306. * The url to the WebAssembly binary.
  52307. */
  52308. wasmBinaryUrl?: string;
  52309. /**
  52310. * The url to the fallback JavaScript module.
  52311. */
  52312. fallbackUrl?: string;
  52313. };
  52314. }
  52315. /**
  52316. * Draco compression (https://google.github.io/draco/)
  52317. *
  52318. * This class wraps the Draco module.
  52319. *
  52320. * **Encoder**
  52321. *
  52322. * The encoder is not currently implemented.
  52323. *
  52324. * **Decoder**
  52325. *
  52326. * 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.
  52327. *
  52328. * To update the configuration, use the following code:
  52329. * ```javascript
  52330. * DracoCompression.Configuration = {
  52331. * decoder: {
  52332. * wasmUrl: "<url to the WebAssembly library>",
  52333. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  52334. * fallbackUrl: "<url to the fallback JavaScript library>",
  52335. * }
  52336. * };
  52337. * ```
  52338. *
  52339. * 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.
  52340. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  52341. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  52342. *
  52343. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  52344. * ```javascript
  52345. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  52346. * ```
  52347. *
  52348. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52349. */
  52350. export class DracoCompression implements IDisposable {
  52351. private _workerPoolPromise?;
  52352. private _decoderModulePromise?;
  52353. /**
  52354. * The configuration. Defaults to the following urls:
  52355. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  52356. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  52357. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  52358. */
  52359. static Configuration: IDracoCompressionConfiguration;
  52360. /**
  52361. * Returns true if the decoder configuration is available.
  52362. */
  52363. static readonly DecoderAvailable: boolean;
  52364. /**
  52365. * Default number of workers to create when creating the draco compression object.
  52366. */
  52367. static DefaultNumWorkers: number;
  52368. private static GetDefaultNumWorkers;
  52369. private static _Default;
  52370. /**
  52371. * Default instance for the draco compression object.
  52372. */
  52373. static readonly Default: DracoCompression;
  52374. /**
  52375. * Constructor
  52376. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  52377. */
  52378. constructor(numWorkers?: number);
  52379. /**
  52380. * Stop all async operations and release resources.
  52381. */
  52382. dispose(): void;
  52383. /**
  52384. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52385. * @returns a promise that resolves when ready
  52386. */
  52387. whenReadyAsync(): Promise<void>;
  52388. /**
  52389. * Decode Draco compressed mesh data to vertex data.
  52390. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52391. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52392. * @returns A promise that resolves with the decoded vertex data
  52393. */
  52394. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52395. [kind: string]: number;
  52396. }): Promise<VertexData>;
  52397. }
  52398. }
  52399. declare module BABYLON {
  52400. /**
  52401. * Class for building Constructive Solid Geometry
  52402. */
  52403. export class CSG {
  52404. private polygons;
  52405. /**
  52406. * The world matrix
  52407. */
  52408. matrix: Matrix;
  52409. /**
  52410. * Stores the position
  52411. */
  52412. position: Vector3;
  52413. /**
  52414. * Stores the rotation
  52415. */
  52416. rotation: Vector3;
  52417. /**
  52418. * Stores the rotation quaternion
  52419. */
  52420. rotationQuaternion: Nullable<Quaternion>;
  52421. /**
  52422. * Stores the scaling vector
  52423. */
  52424. scaling: Vector3;
  52425. /**
  52426. * Convert the Mesh to CSG
  52427. * @param mesh The Mesh to convert to CSG
  52428. * @returns A new CSG from the Mesh
  52429. */
  52430. static FromMesh(mesh: Mesh): CSG;
  52431. /**
  52432. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52433. * @param polygons Polygons used to construct a CSG solid
  52434. */
  52435. private static FromPolygons;
  52436. /**
  52437. * Clones, or makes a deep copy, of the CSG
  52438. * @returns A new CSG
  52439. */
  52440. clone(): CSG;
  52441. /**
  52442. * Unions this CSG with another CSG
  52443. * @param csg The CSG to union against this CSG
  52444. * @returns The unioned CSG
  52445. */
  52446. union(csg: CSG): CSG;
  52447. /**
  52448. * Unions this CSG with another CSG in place
  52449. * @param csg The CSG to union against this CSG
  52450. */
  52451. unionInPlace(csg: CSG): void;
  52452. /**
  52453. * Subtracts this CSG with another CSG
  52454. * @param csg The CSG to subtract against this CSG
  52455. * @returns A new CSG
  52456. */
  52457. subtract(csg: CSG): CSG;
  52458. /**
  52459. * Subtracts this CSG with another CSG in place
  52460. * @param csg The CSG to subtact against this CSG
  52461. */
  52462. subtractInPlace(csg: CSG): void;
  52463. /**
  52464. * Intersect this CSG with another CSG
  52465. * @param csg The CSG to intersect against this CSG
  52466. * @returns A new CSG
  52467. */
  52468. intersect(csg: CSG): CSG;
  52469. /**
  52470. * Intersects this CSG with another CSG in place
  52471. * @param csg The CSG to intersect against this CSG
  52472. */
  52473. intersectInPlace(csg: CSG): void;
  52474. /**
  52475. * Return a new CSG solid with solid and empty space switched. This solid is
  52476. * not modified.
  52477. * @returns A new CSG solid with solid and empty space switched
  52478. */
  52479. inverse(): CSG;
  52480. /**
  52481. * Inverses the CSG in place
  52482. */
  52483. inverseInPlace(): void;
  52484. /**
  52485. * This is used to keep meshes transformations so they can be restored
  52486. * when we build back a Babylon Mesh
  52487. * NB : All CSG operations are performed in world coordinates
  52488. * @param csg The CSG to copy the transform attributes from
  52489. * @returns This CSG
  52490. */
  52491. copyTransformAttributes(csg: CSG): CSG;
  52492. /**
  52493. * Build Raw mesh from CSG
  52494. * Coordinates here are in world space
  52495. * @param name The name of the mesh geometry
  52496. * @param scene The Scene
  52497. * @param keepSubMeshes Specifies if the submeshes should be kept
  52498. * @returns A new Mesh
  52499. */
  52500. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52501. /**
  52502. * Build Mesh from CSG taking material and transforms into account
  52503. * @param name The name of the Mesh
  52504. * @param material The material of the Mesh
  52505. * @param scene The Scene
  52506. * @param keepSubMeshes Specifies if submeshes should be kept
  52507. * @returns The new Mesh
  52508. */
  52509. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52510. }
  52511. }
  52512. declare module BABYLON {
  52513. /**
  52514. * Class used to create a trail following a mesh
  52515. */
  52516. export class TrailMesh extends Mesh {
  52517. private _generator;
  52518. private _autoStart;
  52519. private _running;
  52520. private _diameter;
  52521. private _length;
  52522. private _sectionPolygonPointsCount;
  52523. private _sectionVectors;
  52524. private _sectionNormalVectors;
  52525. private _beforeRenderObserver;
  52526. /**
  52527. * @constructor
  52528. * @param name The value used by scene.getMeshByName() to do a lookup.
  52529. * @param generator The mesh to generate a trail.
  52530. * @param scene The scene to add this mesh to.
  52531. * @param diameter Diameter of trailing mesh. Default is 1.
  52532. * @param length Length of trailing mesh. Default is 60.
  52533. * @param autoStart Automatically start trailing mesh. Default true.
  52534. */
  52535. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52536. /**
  52537. * "TrailMesh"
  52538. * @returns "TrailMesh"
  52539. */
  52540. getClassName(): string;
  52541. private _createMesh;
  52542. /**
  52543. * Start trailing mesh.
  52544. */
  52545. start(): void;
  52546. /**
  52547. * Stop trailing mesh.
  52548. */
  52549. stop(): void;
  52550. /**
  52551. * Update trailing mesh geometry.
  52552. */
  52553. update(): void;
  52554. /**
  52555. * Returns a new TrailMesh object.
  52556. * @param name is a string, the name given to the new mesh
  52557. * @param newGenerator use new generator object for cloned trail mesh
  52558. * @returns a new mesh
  52559. */
  52560. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52561. /**
  52562. * Serializes this trail mesh
  52563. * @param serializationObject object to write serialization to
  52564. */
  52565. serialize(serializationObject: any): void;
  52566. /**
  52567. * Parses a serialized trail mesh
  52568. * @param parsedMesh the serialized mesh
  52569. * @param scene the scene to create the trail mesh in
  52570. * @returns the created trail mesh
  52571. */
  52572. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52573. }
  52574. }
  52575. declare module BABYLON {
  52576. /**
  52577. * Class containing static functions to help procedurally build meshes
  52578. */
  52579. export class TiledBoxBuilder {
  52580. /**
  52581. * Creates a box mesh
  52582. * 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)
  52583. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52585. * * 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
  52586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52587. * @param name defines the name of the mesh
  52588. * @param options defines the options used to create the mesh
  52589. * @param scene defines the hosting scene
  52590. * @returns the box mesh
  52591. */
  52592. static CreateTiledBox(name: string, options: {
  52593. pattern?: number;
  52594. width?: number;
  52595. height?: number;
  52596. depth?: number;
  52597. tileSize?: number;
  52598. tileWidth?: number;
  52599. tileHeight?: number;
  52600. alignHorizontal?: number;
  52601. alignVertical?: number;
  52602. faceUV?: Vector4[];
  52603. faceColors?: Color4[];
  52604. sideOrientation?: number;
  52605. updatable?: boolean;
  52606. }, scene?: Nullable<Scene>): Mesh;
  52607. }
  52608. }
  52609. declare module BABYLON {
  52610. /**
  52611. * Class containing static functions to help procedurally build meshes
  52612. */
  52613. export class TorusKnotBuilder {
  52614. /**
  52615. * Creates a torus knot mesh
  52616. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52617. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52618. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52619. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52621. * * 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
  52622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52623. * @param name defines the name of the mesh
  52624. * @param options defines the options used to create the mesh
  52625. * @param scene defines the hosting scene
  52626. * @returns the torus knot mesh
  52627. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52628. */
  52629. static CreateTorusKnot(name: string, options: {
  52630. radius?: number;
  52631. tube?: number;
  52632. radialSegments?: number;
  52633. tubularSegments?: number;
  52634. p?: number;
  52635. q?: number;
  52636. updatable?: boolean;
  52637. sideOrientation?: number;
  52638. frontUVs?: Vector4;
  52639. backUVs?: Vector4;
  52640. }, scene: any): Mesh;
  52641. }
  52642. }
  52643. declare module BABYLON {
  52644. /**
  52645. * Polygon
  52646. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52647. */
  52648. export class Polygon {
  52649. /**
  52650. * Creates a rectangle
  52651. * @param xmin bottom X coord
  52652. * @param ymin bottom Y coord
  52653. * @param xmax top X coord
  52654. * @param ymax top Y coord
  52655. * @returns points that make the resulting rectation
  52656. */
  52657. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52658. /**
  52659. * Creates a circle
  52660. * @param radius radius of circle
  52661. * @param cx scale in x
  52662. * @param cy scale in y
  52663. * @param numberOfSides number of sides that make up the circle
  52664. * @returns points that make the resulting circle
  52665. */
  52666. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52667. /**
  52668. * Creates a polygon from input string
  52669. * @param input Input polygon data
  52670. * @returns the parsed points
  52671. */
  52672. static Parse(input: string): Vector2[];
  52673. /**
  52674. * Starts building a polygon from x and y coordinates
  52675. * @param x x coordinate
  52676. * @param y y coordinate
  52677. * @returns the started path2
  52678. */
  52679. static StartingAt(x: number, y: number): Path2;
  52680. }
  52681. /**
  52682. * Builds a polygon
  52683. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52684. */
  52685. export class PolygonMeshBuilder {
  52686. private _points;
  52687. private _outlinepoints;
  52688. private _holes;
  52689. private _name;
  52690. private _scene;
  52691. private _epoints;
  52692. private _eholes;
  52693. private _addToepoint;
  52694. /**
  52695. * Babylon reference to the earcut plugin.
  52696. */
  52697. bjsEarcut: any;
  52698. /**
  52699. * Creates a PolygonMeshBuilder
  52700. * @param name name of the builder
  52701. * @param contours Path of the polygon
  52702. * @param scene scene to add to when creating the mesh
  52703. * @param earcutInjection can be used to inject your own earcut reference
  52704. */
  52705. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52706. /**
  52707. * Adds a whole within the polygon
  52708. * @param hole Array of points defining the hole
  52709. * @returns this
  52710. */
  52711. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52712. /**
  52713. * Creates the polygon
  52714. * @param updatable If the mesh should be updatable
  52715. * @param depth The depth of the mesh created
  52716. * @returns the created mesh
  52717. */
  52718. build(updatable?: boolean, depth?: number): Mesh;
  52719. /**
  52720. * Creates the polygon
  52721. * @param depth The depth of the mesh created
  52722. * @returns the created VertexData
  52723. */
  52724. buildVertexData(depth?: number): VertexData;
  52725. /**
  52726. * Adds a side to the polygon
  52727. * @param positions points that make the polygon
  52728. * @param normals normals of the polygon
  52729. * @param uvs uvs of the polygon
  52730. * @param indices indices of the polygon
  52731. * @param bounds bounds of the polygon
  52732. * @param points points of the polygon
  52733. * @param depth depth of the polygon
  52734. * @param flip flip of the polygon
  52735. */
  52736. private addSide;
  52737. }
  52738. }
  52739. declare module BABYLON {
  52740. /**
  52741. * Class containing static functions to help procedurally build meshes
  52742. */
  52743. export class PolygonBuilder {
  52744. /**
  52745. * Creates a polygon mesh
  52746. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52747. * * 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
  52748. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52750. * * 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)
  52751. * * Remember you can only change the shape positions, not their number when updating a polygon
  52752. * @param name defines the name of the mesh
  52753. * @param options defines the options used to create the mesh
  52754. * @param scene defines the hosting scene
  52755. * @param earcutInjection can be used to inject your own earcut reference
  52756. * @returns the polygon mesh
  52757. */
  52758. static CreatePolygon(name: string, options: {
  52759. shape: Vector3[];
  52760. holes?: Vector3[][];
  52761. depth?: number;
  52762. faceUV?: Vector4[];
  52763. faceColors?: Color4[];
  52764. updatable?: boolean;
  52765. sideOrientation?: number;
  52766. frontUVs?: Vector4;
  52767. backUVs?: Vector4;
  52768. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52769. /**
  52770. * Creates an extruded polygon mesh, with depth in the Y direction.
  52771. * * 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)
  52772. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52773. * @param name defines the name of the mesh
  52774. * @param options defines the options used to create the mesh
  52775. * @param scene defines the hosting scene
  52776. * @param earcutInjection can be used to inject your own earcut reference
  52777. * @returns the polygon mesh
  52778. */
  52779. static ExtrudePolygon(name: string, options: {
  52780. shape: Vector3[];
  52781. holes?: Vector3[][];
  52782. depth?: number;
  52783. faceUV?: Vector4[];
  52784. faceColors?: Color4[];
  52785. updatable?: boolean;
  52786. sideOrientation?: number;
  52787. frontUVs?: Vector4;
  52788. backUVs?: Vector4;
  52789. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52790. }
  52791. }
  52792. declare module BABYLON {
  52793. /**
  52794. * Class containing static functions to help procedurally build meshes
  52795. */
  52796. export class LatheBuilder {
  52797. /**
  52798. * Creates lathe mesh.
  52799. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52800. * * 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
  52801. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52802. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52803. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52804. * * 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
  52805. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52806. * * 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
  52807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52808. * * 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
  52809. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52811. * @param name defines the name of the mesh
  52812. * @param options defines the options used to create the mesh
  52813. * @param scene defines the hosting scene
  52814. * @returns the lathe mesh
  52815. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52816. */
  52817. static CreateLathe(name: string, options: {
  52818. shape: Vector3[];
  52819. radius?: number;
  52820. tessellation?: number;
  52821. clip?: number;
  52822. arc?: number;
  52823. closed?: boolean;
  52824. updatable?: boolean;
  52825. sideOrientation?: number;
  52826. frontUVs?: Vector4;
  52827. backUVs?: Vector4;
  52828. cap?: number;
  52829. invertUV?: boolean;
  52830. }, scene?: Nullable<Scene>): Mesh;
  52831. }
  52832. }
  52833. declare module BABYLON {
  52834. /**
  52835. * Class containing static functions to help procedurally build meshes
  52836. */
  52837. export class TiledPlaneBuilder {
  52838. /**
  52839. * Creates a tiled plane mesh
  52840. * * The parameter `pattern` will, depending on value, do nothing or
  52841. * * * flip (reflect about central vertical) alternate tiles across and up
  52842. * * * flip every tile on alternate rows
  52843. * * * rotate (180 degs) alternate tiles across and up
  52844. * * * rotate every tile on alternate rows
  52845. * * * flip and rotate alternate tiles across and up
  52846. * * * flip and rotate every tile on alternate rows
  52847. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  52848. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  52849. * * 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
  52850. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52851. * * 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)
  52852. * * 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)
  52853. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52854. * @param name defines the name of the mesh
  52855. * @param options defines the options used to create the mesh
  52856. * @param scene defines the hosting scene
  52857. * @returns the box mesh
  52858. */
  52859. static CreateTiledPlane(name: string, options: {
  52860. pattern?: number;
  52861. tileSize?: number;
  52862. tileWidth?: number;
  52863. tileHeight?: number;
  52864. size?: number;
  52865. width?: number;
  52866. height?: number;
  52867. alignHorizontal?: number;
  52868. alignVertical?: number;
  52869. sideOrientation?: number;
  52870. frontUVs?: Vector4;
  52871. backUVs?: Vector4;
  52872. updatable?: boolean;
  52873. }, scene?: Nullable<Scene>): Mesh;
  52874. }
  52875. }
  52876. declare module BABYLON {
  52877. /**
  52878. * Class containing static functions to help procedurally build meshes
  52879. */
  52880. export class TubeBuilder {
  52881. /**
  52882. * Creates a tube mesh.
  52883. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52884. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52885. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52886. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52887. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52888. * * 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)
  52889. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52890. * * 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
  52891. * * 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
  52892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52893. * * 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
  52894. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52896. * @param name defines the name of the mesh
  52897. * @param options defines the options used to create the mesh
  52898. * @param scene defines the hosting scene
  52899. * @returns the tube mesh
  52900. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52901. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52902. */
  52903. static CreateTube(name: string, options: {
  52904. path: Vector3[];
  52905. radius?: number;
  52906. tessellation?: number;
  52907. radiusFunction?: {
  52908. (i: number, distance: number): number;
  52909. };
  52910. cap?: number;
  52911. arc?: number;
  52912. updatable?: boolean;
  52913. sideOrientation?: number;
  52914. frontUVs?: Vector4;
  52915. backUVs?: Vector4;
  52916. instance?: Mesh;
  52917. invertUV?: boolean;
  52918. }, scene?: Nullable<Scene>): Mesh;
  52919. }
  52920. }
  52921. declare module BABYLON {
  52922. /**
  52923. * Class containing static functions to help procedurally build meshes
  52924. */
  52925. export class IcoSphereBuilder {
  52926. /**
  52927. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52928. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52929. * * 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`)
  52930. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52931. * * 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
  52932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52933. * * 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
  52934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52935. * @param name defines the name of the mesh
  52936. * @param options defines the options used to create the mesh
  52937. * @param scene defines the hosting scene
  52938. * @returns the icosahedron mesh
  52939. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52940. */
  52941. static CreateIcoSphere(name: string, options: {
  52942. radius?: number;
  52943. radiusX?: number;
  52944. radiusY?: number;
  52945. radiusZ?: number;
  52946. flat?: boolean;
  52947. subdivisions?: number;
  52948. sideOrientation?: number;
  52949. frontUVs?: Vector4;
  52950. backUVs?: Vector4;
  52951. updatable?: boolean;
  52952. }, scene?: Nullable<Scene>): Mesh;
  52953. }
  52954. }
  52955. declare module BABYLON {
  52956. /**
  52957. * Class containing static functions to help procedurally build meshes
  52958. */
  52959. export class DecalBuilder {
  52960. /**
  52961. * Creates a decal mesh.
  52962. * 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
  52963. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52964. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52965. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52966. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52967. * @param name defines the name of the mesh
  52968. * @param sourceMesh defines the mesh where the decal must be applied
  52969. * @param options defines the options used to create the mesh
  52970. * @param scene defines the hosting scene
  52971. * @returns the decal mesh
  52972. * @see https://doc.babylonjs.com/how_to/decals
  52973. */
  52974. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52975. position?: Vector3;
  52976. normal?: Vector3;
  52977. size?: Vector3;
  52978. angle?: number;
  52979. }): Mesh;
  52980. }
  52981. }
  52982. declare module BABYLON {
  52983. /**
  52984. * Class containing static functions to help procedurally build meshes
  52985. */
  52986. export class MeshBuilder {
  52987. /**
  52988. * Creates a box mesh
  52989. * * The parameter `size` sets the size (float) of each box side (default 1)
  52990. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52991. * * 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)
  52992. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52994. * * 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
  52995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52996. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52997. * @param name defines the name of the mesh
  52998. * @param options defines the options used to create the mesh
  52999. * @param scene defines the hosting scene
  53000. * @returns the box mesh
  53001. */
  53002. static CreateBox(name: string, options: {
  53003. size?: number;
  53004. width?: number;
  53005. height?: number;
  53006. depth?: number;
  53007. faceUV?: Vector4[];
  53008. faceColors?: Color4[];
  53009. sideOrientation?: number;
  53010. frontUVs?: Vector4;
  53011. backUVs?: Vector4;
  53012. updatable?: boolean;
  53013. }, scene?: Nullable<Scene>): Mesh;
  53014. /**
  53015. * Creates a tiled box mesh
  53016. * * faceTiles sets the pattern, tile size and number of tiles for a face
  53017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53018. * @param name defines the name of the mesh
  53019. * @param options defines the options used to create the mesh
  53020. * @param scene defines the hosting scene
  53021. * @returns the tiled box mesh
  53022. */
  53023. static CreateTiledBox(name: string, options: {
  53024. pattern?: number;
  53025. size?: number;
  53026. width?: number;
  53027. height?: number;
  53028. depth: number;
  53029. tileSize?: number;
  53030. tileWidth?: number;
  53031. tileHeight?: number;
  53032. faceUV?: Vector4[];
  53033. faceColors?: Color4[];
  53034. alignHorizontal?: number;
  53035. alignVertical?: number;
  53036. sideOrientation?: number;
  53037. updatable?: boolean;
  53038. }, scene?: Nullable<Scene>): Mesh;
  53039. /**
  53040. * Creates a sphere mesh
  53041. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53042. * * 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`)
  53043. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53044. * * 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
  53045. * * 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)
  53046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53047. * * 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
  53048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53049. * @param name defines the name of the mesh
  53050. * @param options defines the options used to create the mesh
  53051. * @param scene defines the hosting scene
  53052. * @returns the sphere mesh
  53053. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53054. */
  53055. static CreateSphere(name: string, options: {
  53056. segments?: number;
  53057. diameter?: number;
  53058. diameterX?: number;
  53059. diameterY?: number;
  53060. diameterZ?: number;
  53061. arc?: number;
  53062. slice?: number;
  53063. sideOrientation?: number;
  53064. frontUVs?: Vector4;
  53065. backUVs?: Vector4;
  53066. updatable?: boolean;
  53067. }, scene?: Nullable<Scene>): Mesh;
  53068. /**
  53069. * Creates a plane polygonal mesh. By default, this is a disc
  53070. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  53071. * * 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
  53072. * * 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
  53073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53074. * * 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
  53075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53076. * @param name defines the name of the mesh
  53077. * @param options defines the options used to create the mesh
  53078. * @param scene defines the hosting scene
  53079. * @returns the plane polygonal mesh
  53080. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  53081. */
  53082. static CreateDisc(name: string, options: {
  53083. radius?: number;
  53084. tessellation?: number;
  53085. arc?: number;
  53086. updatable?: boolean;
  53087. sideOrientation?: number;
  53088. frontUVs?: Vector4;
  53089. backUVs?: Vector4;
  53090. }, scene?: Nullable<Scene>): Mesh;
  53091. /**
  53092. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53093. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53094. * * 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`)
  53095. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53096. * * 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
  53097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53098. * * 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
  53099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53100. * @param name defines the name of the mesh
  53101. * @param options defines the options used to create the mesh
  53102. * @param scene defines the hosting scene
  53103. * @returns the icosahedron mesh
  53104. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53105. */
  53106. static CreateIcoSphere(name: string, options: {
  53107. radius?: number;
  53108. radiusX?: number;
  53109. radiusY?: number;
  53110. radiusZ?: number;
  53111. flat?: boolean;
  53112. subdivisions?: number;
  53113. sideOrientation?: number;
  53114. frontUVs?: Vector4;
  53115. backUVs?: Vector4;
  53116. updatable?: boolean;
  53117. }, scene?: Nullable<Scene>): Mesh;
  53118. /**
  53119. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53120. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53121. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53122. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53123. * * 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
  53124. * * 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
  53125. * * 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
  53126. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53127. * * 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
  53128. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53129. * * 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
  53130. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53131. * * 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
  53132. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53134. * @param name defines the name of the mesh
  53135. * @param options defines the options used to create the mesh
  53136. * @param scene defines the hosting scene
  53137. * @returns the ribbon mesh
  53138. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53139. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53140. */
  53141. static CreateRibbon(name: string, options: {
  53142. pathArray: Vector3[][];
  53143. closeArray?: boolean;
  53144. closePath?: boolean;
  53145. offset?: number;
  53146. updatable?: boolean;
  53147. sideOrientation?: number;
  53148. frontUVs?: Vector4;
  53149. backUVs?: Vector4;
  53150. instance?: Mesh;
  53151. invertUV?: boolean;
  53152. uvs?: Vector2[];
  53153. colors?: Color4[];
  53154. }, scene?: Nullable<Scene>): Mesh;
  53155. /**
  53156. * Creates a cylinder or a cone mesh
  53157. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53158. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53159. * * 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.
  53160. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53161. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53162. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53163. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53164. * * 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).
  53165. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53166. * * 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).
  53167. * * 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
  53168. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53169. * * 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
  53170. * * 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.
  53171. * * If `enclose` is false, a ring surface is one element.
  53172. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53173. * * 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
  53174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53175. * * 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
  53176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53177. * @param name defines the name of the mesh
  53178. * @param options defines the options used to create the mesh
  53179. * @param scene defines the hosting scene
  53180. * @returns the cylinder mesh
  53181. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53182. */
  53183. static CreateCylinder(name: string, options: {
  53184. height?: number;
  53185. diameterTop?: number;
  53186. diameterBottom?: number;
  53187. diameter?: number;
  53188. tessellation?: number;
  53189. subdivisions?: number;
  53190. arc?: number;
  53191. faceColors?: Color4[];
  53192. faceUV?: Vector4[];
  53193. updatable?: boolean;
  53194. hasRings?: boolean;
  53195. enclose?: boolean;
  53196. cap?: number;
  53197. sideOrientation?: number;
  53198. frontUVs?: Vector4;
  53199. backUVs?: Vector4;
  53200. }, scene?: Nullable<Scene>): Mesh;
  53201. /**
  53202. * Creates a torus mesh
  53203. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53204. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53205. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53207. * * 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
  53208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53209. * @param name defines the name of the mesh
  53210. * @param options defines the options used to create the mesh
  53211. * @param scene defines the hosting scene
  53212. * @returns the torus mesh
  53213. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53214. */
  53215. static CreateTorus(name: string, options: {
  53216. diameter?: number;
  53217. thickness?: number;
  53218. tessellation?: number;
  53219. updatable?: boolean;
  53220. sideOrientation?: number;
  53221. frontUVs?: Vector4;
  53222. backUVs?: Vector4;
  53223. }, scene?: Nullable<Scene>): Mesh;
  53224. /**
  53225. * Creates a torus knot mesh
  53226. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53227. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53228. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53229. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53231. * * 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
  53232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53233. * @param name defines the name of the mesh
  53234. * @param options defines the options used to create the mesh
  53235. * @param scene defines the hosting scene
  53236. * @returns the torus knot mesh
  53237. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  53238. */
  53239. static CreateTorusKnot(name: string, options: {
  53240. radius?: number;
  53241. tube?: number;
  53242. radialSegments?: number;
  53243. tubularSegments?: number;
  53244. p?: number;
  53245. q?: number;
  53246. updatable?: boolean;
  53247. sideOrientation?: number;
  53248. frontUVs?: Vector4;
  53249. backUVs?: Vector4;
  53250. }, scene?: Nullable<Scene>): Mesh;
  53251. /**
  53252. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  53253. * * 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
  53254. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  53255. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  53256. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  53257. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  53258. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  53259. * * 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
  53260. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  53261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53262. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  53263. * @param name defines the name of the new line system
  53264. * @param options defines the options used to create the line system
  53265. * @param scene defines the hosting scene
  53266. * @returns a new line system mesh
  53267. */
  53268. static CreateLineSystem(name: string, options: {
  53269. lines: Vector3[][];
  53270. updatable?: boolean;
  53271. instance?: Nullable<LinesMesh>;
  53272. colors?: Nullable<Color4[][]>;
  53273. useVertexAlpha?: boolean;
  53274. }, scene: Nullable<Scene>): LinesMesh;
  53275. /**
  53276. * Creates a line mesh
  53277. * 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
  53278. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53279. * * The parameter `points` is an array successive Vector3
  53280. * * 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
  53281. * * The optional parameter `colors` is an array of successive Color4, one per line point
  53282. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  53283. * * When updating an instance, remember that only point positions can change, not the number of points
  53284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53285. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  53286. * @param name defines the name of the new line system
  53287. * @param options defines the options used to create the line system
  53288. * @param scene defines the hosting scene
  53289. * @returns a new line mesh
  53290. */
  53291. static CreateLines(name: string, options: {
  53292. points: Vector3[];
  53293. updatable?: boolean;
  53294. instance?: Nullable<LinesMesh>;
  53295. colors?: Color4[];
  53296. useVertexAlpha?: boolean;
  53297. }, scene?: Nullable<Scene>): LinesMesh;
  53298. /**
  53299. * Creates a dashed line mesh
  53300. * * 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
  53301. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53302. * * The parameter `points` is an array successive Vector3
  53303. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  53304. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  53305. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  53306. * * 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
  53307. * * When updating an instance, remember that only point positions can change, not the number of points
  53308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53309. * @param name defines the name of the mesh
  53310. * @param options defines the options used to create the mesh
  53311. * @param scene defines the hosting scene
  53312. * @returns the dashed line mesh
  53313. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  53314. */
  53315. static CreateDashedLines(name: string, options: {
  53316. points: Vector3[];
  53317. dashSize?: number;
  53318. gapSize?: number;
  53319. dashNb?: number;
  53320. updatable?: boolean;
  53321. instance?: LinesMesh;
  53322. }, scene?: Nullable<Scene>): LinesMesh;
  53323. /**
  53324. * 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.
  53325. * * 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.
  53326. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53327. * * 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.
  53328. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53329. * * 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
  53330. * * 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
  53331. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53333. * * 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
  53334. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53336. * @param name defines the name of the mesh
  53337. * @param options defines the options used to create the mesh
  53338. * @param scene defines the hosting scene
  53339. * @returns the extruded shape mesh
  53340. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53342. */
  53343. static ExtrudeShape(name: string, options: {
  53344. shape: Vector3[];
  53345. path: Vector3[];
  53346. scale?: number;
  53347. rotation?: number;
  53348. cap?: number;
  53349. updatable?: boolean;
  53350. sideOrientation?: number;
  53351. frontUVs?: Vector4;
  53352. backUVs?: Vector4;
  53353. instance?: Mesh;
  53354. invertUV?: boolean;
  53355. }, scene?: Nullable<Scene>): Mesh;
  53356. /**
  53357. * Creates an custom extruded shape mesh.
  53358. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53359. * * 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.
  53360. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53361. * * 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
  53362. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53363. * * 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
  53364. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53365. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53366. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53367. * * 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
  53368. * * 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
  53369. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53371. * * 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
  53372. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53374. * @param name defines the name of the mesh
  53375. * @param options defines the options used to create the mesh
  53376. * @param scene defines the hosting scene
  53377. * @returns the custom extruded shape mesh
  53378. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53379. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53380. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53381. */
  53382. static ExtrudeShapeCustom(name: string, options: {
  53383. shape: Vector3[];
  53384. path: Vector3[];
  53385. scaleFunction?: any;
  53386. rotationFunction?: any;
  53387. ribbonCloseArray?: boolean;
  53388. ribbonClosePath?: boolean;
  53389. cap?: number;
  53390. updatable?: boolean;
  53391. sideOrientation?: number;
  53392. frontUVs?: Vector4;
  53393. backUVs?: Vector4;
  53394. instance?: Mesh;
  53395. invertUV?: boolean;
  53396. }, scene?: Nullable<Scene>): Mesh;
  53397. /**
  53398. * Creates lathe mesh.
  53399. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53400. * * 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
  53401. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53402. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53403. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53404. * * 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
  53405. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53406. * * 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
  53407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53408. * * 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
  53409. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53411. * @param name defines the name of the mesh
  53412. * @param options defines the options used to create the mesh
  53413. * @param scene defines the hosting scene
  53414. * @returns the lathe mesh
  53415. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53416. */
  53417. static CreateLathe(name: string, options: {
  53418. shape: Vector3[];
  53419. radius?: number;
  53420. tessellation?: number;
  53421. clip?: number;
  53422. arc?: number;
  53423. closed?: boolean;
  53424. updatable?: boolean;
  53425. sideOrientation?: number;
  53426. frontUVs?: Vector4;
  53427. backUVs?: Vector4;
  53428. cap?: number;
  53429. invertUV?: boolean;
  53430. }, scene?: Nullable<Scene>): Mesh;
  53431. /**
  53432. * Creates a tiled plane mesh
  53433. * * You can set a limited pattern arrangement with the tiles
  53434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53435. * * 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
  53436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53437. * @param name defines the name of the mesh
  53438. * @param options defines the options used to create the mesh
  53439. * @param scene defines the hosting scene
  53440. * @returns the plane mesh
  53441. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53442. */
  53443. static CreateTiledPlane(name: string, options: {
  53444. pattern?: number;
  53445. tileSize?: number;
  53446. tileWidth?: number;
  53447. tileHeight?: number;
  53448. size?: number;
  53449. width?: number;
  53450. height?: number;
  53451. alignHorizontal?: number;
  53452. alignVertical?: number;
  53453. sideOrientation?: number;
  53454. frontUVs?: Vector4;
  53455. backUVs?: Vector4;
  53456. updatable?: boolean;
  53457. }, scene?: Nullable<Scene>): Mesh;
  53458. /**
  53459. * Creates a plane mesh
  53460. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53461. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53462. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53464. * * 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
  53465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53466. * @param name defines the name of the mesh
  53467. * @param options defines the options used to create the mesh
  53468. * @param scene defines the hosting scene
  53469. * @returns the plane mesh
  53470. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53471. */
  53472. static CreatePlane(name: string, options: {
  53473. size?: number;
  53474. width?: number;
  53475. height?: number;
  53476. sideOrientation?: number;
  53477. frontUVs?: Vector4;
  53478. backUVs?: Vector4;
  53479. updatable?: boolean;
  53480. sourcePlane?: Plane;
  53481. }, scene?: Nullable<Scene>): Mesh;
  53482. /**
  53483. * Creates a ground mesh
  53484. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53485. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53487. * @param name defines the name of the mesh
  53488. * @param options defines the options used to create the mesh
  53489. * @param scene defines the hosting scene
  53490. * @returns the ground mesh
  53491. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53492. */
  53493. static CreateGround(name: string, options: {
  53494. width?: number;
  53495. height?: number;
  53496. subdivisions?: number;
  53497. subdivisionsX?: number;
  53498. subdivisionsY?: number;
  53499. updatable?: boolean;
  53500. }, scene?: Nullable<Scene>): Mesh;
  53501. /**
  53502. * Creates a tiled ground mesh
  53503. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53504. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53505. * * 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
  53506. * * 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
  53507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53508. * @param name defines the name of the mesh
  53509. * @param options defines the options used to create the mesh
  53510. * @param scene defines the hosting scene
  53511. * @returns the tiled ground mesh
  53512. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53513. */
  53514. static CreateTiledGround(name: string, options: {
  53515. xmin: number;
  53516. zmin: number;
  53517. xmax: number;
  53518. zmax: number;
  53519. subdivisions?: {
  53520. w: number;
  53521. h: number;
  53522. };
  53523. precision?: {
  53524. w: number;
  53525. h: number;
  53526. };
  53527. updatable?: boolean;
  53528. }, scene?: Nullable<Scene>): Mesh;
  53529. /**
  53530. * Creates a ground mesh from a height map
  53531. * * The parameter `url` sets the URL of the height map image resource.
  53532. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53533. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53534. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53535. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53536. * * 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.
  53537. * * 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).
  53538. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53540. * @param name defines the name of the mesh
  53541. * @param url defines the url to the height map
  53542. * @param options defines the options used to create the mesh
  53543. * @param scene defines the hosting scene
  53544. * @returns the ground mesh
  53545. * @see https://doc.babylonjs.com/babylon101/height_map
  53546. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53547. */
  53548. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53549. width?: number;
  53550. height?: number;
  53551. subdivisions?: number;
  53552. minHeight?: number;
  53553. maxHeight?: number;
  53554. colorFilter?: Color3;
  53555. alphaFilter?: number;
  53556. updatable?: boolean;
  53557. onReady?: (mesh: GroundMesh) => void;
  53558. }, scene?: Nullable<Scene>): GroundMesh;
  53559. /**
  53560. * Creates a polygon mesh
  53561. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53562. * * 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
  53563. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53565. * * 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)
  53566. * * Remember you can only change the shape positions, not their number when updating a polygon
  53567. * @param name defines the name of the mesh
  53568. * @param options defines the options used to create the mesh
  53569. * @param scene defines the hosting scene
  53570. * @param earcutInjection can be used to inject your own earcut reference
  53571. * @returns the polygon mesh
  53572. */
  53573. static CreatePolygon(name: string, options: {
  53574. shape: Vector3[];
  53575. holes?: Vector3[][];
  53576. depth?: number;
  53577. faceUV?: Vector4[];
  53578. faceColors?: Color4[];
  53579. updatable?: boolean;
  53580. sideOrientation?: number;
  53581. frontUVs?: Vector4;
  53582. backUVs?: Vector4;
  53583. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53584. /**
  53585. * Creates an extruded polygon mesh, with depth in the Y direction.
  53586. * * 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)
  53587. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53588. * @param name defines the name of the mesh
  53589. * @param options defines the options used to create the mesh
  53590. * @param scene defines the hosting scene
  53591. * @param earcutInjection can be used to inject your own earcut reference
  53592. * @returns the polygon mesh
  53593. */
  53594. static ExtrudePolygon(name: string, options: {
  53595. shape: Vector3[];
  53596. holes?: Vector3[][];
  53597. depth?: number;
  53598. faceUV?: Vector4[];
  53599. faceColors?: Color4[];
  53600. updatable?: boolean;
  53601. sideOrientation?: number;
  53602. frontUVs?: Vector4;
  53603. backUVs?: Vector4;
  53604. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53605. /**
  53606. * Creates a tube mesh.
  53607. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53608. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53609. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53610. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53611. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53612. * * 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)
  53613. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53614. * * 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
  53615. * * 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
  53616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53617. * * 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
  53618. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53620. * @param name defines the name of the mesh
  53621. * @param options defines the options used to create the mesh
  53622. * @param scene defines the hosting scene
  53623. * @returns the tube mesh
  53624. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53625. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53626. */
  53627. static CreateTube(name: string, options: {
  53628. path: Vector3[];
  53629. radius?: number;
  53630. tessellation?: number;
  53631. radiusFunction?: {
  53632. (i: number, distance: number): number;
  53633. };
  53634. cap?: number;
  53635. arc?: number;
  53636. updatable?: boolean;
  53637. sideOrientation?: number;
  53638. frontUVs?: Vector4;
  53639. backUVs?: Vector4;
  53640. instance?: Mesh;
  53641. invertUV?: boolean;
  53642. }, scene?: Nullable<Scene>): Mesh;
  53643. /**
  53644. * Creates a polyhedron mesh
  53645. * * 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
  53646. * * The parameter `size` (positive float, default 1) sets the polygon size
  53647. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53648. * * 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`
  53649. * * 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
  53650. * * 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)`)
  53651. * * 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
  53652. * * 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
  53653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53654. * * 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
  53655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53656. * @param name defines the name of the mesh
  53657. * @param options defines the options used to create the mesh
  53658. * @param scene defines the hosting scene
  53659. * @returns the polyhedron mesh
  53660. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53661. */
  53662. static CreatePolyhedron(name: string, options: {
  53663. type?: number;
  53664. size?: number;
  53665. sizeX?: number;
  53666. sizeY?: number;
  53667. sizeZ?: number;
  53668. custom?: any;
  53669. faceUV?: Vector4[];
  53670. faceColors?: Color4[];
  53671. flat?: boolean;
  53672. updatable?: boolean;
  53673. sideOrientation?: number;
  53674. frontUVs?: Vector4;
  53675. backUVs?: Vector4;
  53676. }, scene?: Nullable<Scene>): Mesh;
  53677. /**
  53678. * Creates a decal mesh.
  53679. * 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
  53680. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53681. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53682. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53683. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53684. * @param name defines the name of the mesh
  53685. * @param sourceMesh defines the mesh where the decal must be applied
  53686. * @param options defines the options used to create the mesh
  53687. * @param scene defines the hosting scene
  53688. * @returns the decal mesh
  53689. * @see https://doc.babylonjs.com/how_to/decals
  53690. */
  53691. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53692. position?: Vector3;
  53693. normal?: Vector3;
  53694. size?: Vector3;
  53695. angle?: number;
  53696. }): Mesh;
  53697. }
  53698. }
  53699. declare module BABYLON {
  53700. /**
  53701. * A simplifier interface for future simplification implementations
  53702. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53703. */
  53704. export interface ISimplifier {
  53705. /**
  53706. * Simplification of a given mesh according to the given settings.
  53707. * Since this requires computation, it is assumed that the function runs async.
  53708. * @param settings The settings of the simplification, including quality and distance
  53709. * @param successCallback A callback that will be called after the mesh was simplified.
  53710. * @param errorCallback in case of an error, this callback will be called. optional.
  53711. */
  53712. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53713. }
  53714. /**
  53715. * Expected simplification settings.
  53716. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53717. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53718. */
  53719. export interface ISimplificationSettings {
  53720. /**
  53721. * Gets or sets the expected quality
  53722. */
  53723. quality: number;
  53724. /**
  53725. * Gets or sets the distance when this optimized version should be used
  53726. */
  53727. distance: number;
  53728. /**
  53729. * Gets an already optimized mesh
  53730. */
  53731. optimizeMesh?: boolean;
  53732. }
  53733. /**
  53734. * Class used to specify simplification options
  53735. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53736. */
  53737. export class SimplificationSettings implements ISimplificationSettings {
  53738. /** expected quality */
  53739. quality: number;
  53740. /** distance when this optimized version should be used */
  53741. distance: number;
  53742. /** already optimized mesh */
  53743. optimizeMesh?: boolean | undefined;
  53744. /**
  53745. * Creates a SimplificationSettings
  53746. * @param quality expected quality
  53747. * @param distance distance when this optimized version should be used
  53748. * @param optimizeMesh already optimized mesh
  53749. */
  53750. constructor(
  53751. /** expected quality */
  53752. quality: number,
  53753. /** distance when this optimized version should be used */
  53754. distance: number,
  53755. /** already optimized mesh */
  53756. optimizeMesh?: boolean | undefined);
  53757. }
  53758. /**
  53759. * Interface used to define a simplification task
  53760. */
  53761. export interface ISimplificationTask {
  53762. /**
  53763. * Array of settings
  53764. */
  53765. settings: Array<ISimplificationSettings>;
  53766. /**
  53767. * Simplification type
  53768. */
  53769. simplificationType: SimplificationType;
  53770. /**
  53771. * Mesh to simplify
  53772. */
  53773. mesh: Mesh;
  53774. /**
  53775. * Callback called on success
  53776. */
  53777. successCallback?: () => void;
  53778. /**
  53779. * Defines if parallel processing can be used
  53780. */
  53781. parallelProcessing: boolean;
  53782. }
  53783. /**
  53784. * Queue used to order the simplification tasks
  53785. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53786. */
  53787. export class SimplificationQueue {
  53788. private _simplificationArray;
  53789. /**
  53790. * Gets a boolean indicating that the process is still running
  53791. */
  53792. running: boolean;
  53793. /**
  53794. * Creates a new queue
  53795. */
  53796. constructor();
  53797. /**
  53798. * Adds a new simplification task
  53799. * @param task defines a task to add
  53800. */
  53801. addTask(task: ISimplificationTask): void;
  53802. /**
  53803. * Execute next task
  53804. */
  53805. executeNext(): void;
  53806. /**
  53807. * Execute a simplification task
  53808. * @param task defines the task to run
  53809. */
  53810. runSimplification(task: ISimplificationTask): void;
  53811. private getSimplifier;
  53812. }
  53813. /**
  53814. * The implemented types of simplification
  53815. * At the moment only Quadratic Error Decimation is implemented
  53816. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53817. */
  53818. export enum SimplificationType {
  53819. /** Quadratic error decimation */
  53820. QUADRATIC = 0
  53821. }
  53822. }
  53823. declare module BABYLON {
  53824. interface Scene {
  53825. /** @hidden (Backing field) */
  53826. _simplificationQueue: SimplificationQueue;
  53827. /**
  53828. * Gets or sets the simplification queue attached to the scene
  53829. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53830. */
  53831. simplificationQueue: SimplificationQueue;
  53832. }
  53833. interface Mesh {
  53834. /**
  53835. * Simplify the mesh according to the given array of settings.
  53836. * Function will return immediately and will simplify async
  53837. * @param settings a collection of simplification settings
  53838. * @param parallelProcessing should all levels calculate parallel or one after the other
  53839. * @param simplificationType the type of simplification to run
  53840. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53841. * @returns the current mesh
  53842. */
  53843. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53844. }
  53845. /**
  53846. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53847. * created in a scene
  53848. */
  53849. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53850. /**
  53851. * The component name helpfull to identify the component in the list of scene components.
  53852. */
  53853. readonly name: string;
  53854. /**
  53855. * The scene the component belongs to.
  53856. */
  53857. scene: Scene;
  53858. /**
  53859. * Creates a new instance of the component for the given scene
  53860. * @param scene Defines the scene to register the component in
  53861. */
  53862. constructor(scene: Scene);
  53863. /**
  53864. * Registers the component in a given scene
  53865. */
  53866. register(): void;
  53867. /**
  53868. * Rebuilds the elements related to this component in case of
  53869. * context lost for instance.
  53870. */
  53871. rebuild(): void;
  53872. /**
  53873. * Disposes the component and the associated ressources
  53874. */
  53875. dispose(): void;
  53876. private _beforeCameraUpdate;
  53877. }
  53878. }
  53879. declare module BABYLON {
  53880. /**
  53881. * Class used to enable access to IndexedDB
  53882. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53883. */
  53884. export class Database implements IOfflineProvider {
  53885. private _callbackManifestChecked;
  53886. private _currentSceneUrl;
  53887. private _db;
  53888. private _enableSceneOffline;
  53889. private _enableTexturesOffline;
  53890. private _manifestVersionFound;
  53891. private _mustUpdateRessources;
  53892. private _hasReachedQuota;
  53893. private _isSupported;
  53894. private _idbFactory;
  53895. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53896. private static IsUASupportingBlobStorage;
  53897. /**
  53898. * Gets a boolean indicating if Database storate is enabled (off by default)
  53899. */
  53900. static IDBStorageEnabled: boolean;
  53901. /**
  53902. * Gets a boolean indicating if scene must be saved in the database
  53903. */
  53904. readonly enableSceneOffline: boolean;
  53905. /**
  53906. * Gets a boolean indicating if textures must be saved in the database
  53907. */
  53908. readonly enableTexturesOffline: boolean;
  53909. /**
  53910. * Creates a new Database
  53911. * @param urlToScene defines the url to load the scene
  53912. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53913. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53914. */
  53915. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53916. private static _ParseURL;
  53917. private static _ReturnFullUrlLocation;
  53918. private _checkManifestFile;
  53919. /**
  53920. * Open the database and make it available
  53921. * @param successCallback defines the callback to call on success
  53922. * @param errorCallback defines the callback to call on error
  53923. */
  53924. open(successCallback: () => void, errorCallback: () => void): void;
  53925. /**
  53926. * Loads an image from the database
  53927. * @param url defines the url to load from
  53928. * @param image defines the target DOM image
  53929. */
  53930. loadImage(url: string, image: HTMLImageElement): void;
  53931. private _loadImageFromDBAsync;
  53932. private _saveImageIntoDBAsync;
  53933. private _checkVersionFromDB;
  53934. private _loadVersionFromDBAsync;
  53935. private _saveVersionIntoDBAsync;
  53936. /**
  53937. * Loads a file from database
  53938. * @param url defines the URL to load from
  53939. * @param sceneLoaded defines a callback to call on success
  53940. * @param progressCallBack defines a callback to call when progress changed
  53941. * @param errorCallback defines a callback to call on error
  53942. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53943. */
  53944. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53945. private _loadFileAsync;
  53946. private _saveFileAsync;
  53947. /**
  53948. * Validates if xhr data is correct
  53949. * @param xhr defines the request to validate
  53950. * @param dataType defines the expected data type
  53951. * @returns true if data is correct
  53952. */
  53953. private static _ValidateXHRData;
  53954. }
  53955. }
  53956. declare module BABYLON {
  53957. /** @hidden */
  53958. export var gpuUpdateParticlesPixelShader: {
  53959. name: string;
  53960. shader: string;
  53961. };
  53962. }
  53963. declare module BABYLON {
  53964. /** @hidden */
  53965. export var gpuUpdateParticlesVertexShader: {
  53966. name: string;
  53967. shader: string;
  53968. };
  53969. }
  53970. declare module BABYLON {
  53971. /** @hidden */
  53972. export var clipPlaneFragmentDeclaration2: {
  53973. name: string;
  53974. shader: string;
  53975. };
  53976. }
  53977. declare module BABYLON {
  53978. /** @hidden */
  53979. export var gpuRenderParticlesPixelShader: {
  53980. name: string;
  53981. shader: string;
  53982. };
  53983. }
  53984. declare module BABYLON {
  53985. /** @hidden */
  53986. export var clipPlaneVertexDeclaration2: {
  53987. name: string;
  53988. shader: string;
  53989. };
  53990. }
  53991. declare module BABYLON {
  53992. /** @hidden */
  53993. export var gpuRenderParticlesVertexShader: {
  53994. name: string;
  53995. shader: string;
  53996. };
  53997. }
  53998. declare module BABYLON {
  53999. /**
  54000. * This represents a GPU particle system in Babylon
  54001. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  54002. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  54003. */
  54004. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  54005. /**
  54006. * The layer mask we are rendering the particles through.
  54007. */
  54008. layerMask: number;
  54009. private _capacity;
  54010. private _activeCount;
  54011. private _currentActiveCount;
  54012. private _accumulatedCount;
  54013. private _renderEffect;
  54014. private _updateEffect;
  54015. private _buffer0;
  54016. private _buffer1;
  54017. private _spriteBuffer;
  54018. private _updateVAO;
  54019. private _renderVAO;
  54020. private _targetIndex;
  54021. private _sourceBuffer;
  54022. private _targetBuffer;
  54023. private _engine;
  54024. private _currentRenderId;
  54025. private _started;
  54026. private _stopped;
  54027. private _timeDelta;
  54028. private _randomTexture;
  54029. private _randomTexture2;
  54030. private _attributesStrideSize;
  54031. private _updateEffectOptions;
  54032. private _randomTextureSize;
  54033. private _actualFrame;
  54034. private readonly _rawTextureWidth;
  54035. /**
  54036. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  54037. */
  54038. static readonly IsSupported: boolean;
  54039. /**
  54040. * An event triggered when the system is disposed.
  54041. */
  54042. onDisposeObservable: Observable<GPUParticleSystem>;
  54043. /**
  54044. * Gets the maximum number of particles active at the same time.
  54045. * @returns The max number of active particles.
  54046. */
  54047. getCapacity(): number;
  54048. /**
  54049. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  54050. * to override the particles.
  54051. */
  54052. forceDepthWrite: boolean;
  54053. /**
  54054. * Gets or set the number of active particles
  54055. */
  54056. activeParticleCount: number;
  54057. private _preWarmDone;
  54058. /**
  54059. * Is this system ready to be used/rendered
  54060. * @return true if the system is ready
  54061. */
  54062. isReady(): boolean;
  54063. /**
  54064. * Gets if the system has been started. (Note: this will still be true after stop is called)
  54065. * @returns True if it has been started, otherwise false.
  54066. */
  54067. isStarted(): boolean;
  54068. /**
  54069. * Starts the particle system and begins to emit
  54070. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  54071. */
  54072. start(delay?: number): void;
  54073. /**
  54074. * Stops the particle system.
  54075. */
  54076. stop(): void;
  54077. /**
  54078. * Remove all active particles
  54079. */
  54080. reset(): void;
  54081. /**
  54082. * Returns the string "GPUParticleSystem"
  54083. * @returns a string containing the class name
  54084. */
  54085. getClassName(): string;
  54086. private _colorGradientsTexture;
  54087. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  54088. /**
  54089. * Adds a new color gradient
  54090. * @param gradient defines the gradient to use (between 0 and 1)
  54091. * @param color1 defines the color to affect to the specified gradient
  54092. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  54093. * @returns the current particle system
  54094. */
  54095. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  54096. /**
  54097. * Remove a specific color gradient
  54098. * @param gradient defines the gradient to remove
  54099. * @returns the current particle system
  54100. */
  54101. removeColorGradient(gradient: number): GPUParticleSystem;
  54102. private _angularSpeedGradientsTexture;
  54103. private _sizeGradientsTexture;
  54104. private _velocityGradientsTexture;
  54105. private _limitVelocityGradientsTexture;
  54106. private _dragGradientsTexture;
  54107. private _addFactorGradient;
  54108. /**
  54109. * Adds a new size gradient
  54110. * @param gradient defines the gradient to use (between 0 and 1)
  54111. * @param factor defines the size factor to affect to the specified gradient
  54112. * @returns the current particle system
  54113. */
  54114. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  54115. /**
  54116. * Remove a specific size gradient
  54117. * @param gradient defines the gradient to remove
  54118. * @returns the current particle system
  54119. */
  54120. removeSizeGradient(gradient: number): GPUParticleSystem;
  54121. /**
  54122. * Adds a new angular speed gradient
  54123. * @param gradient defines the gradient to use (between 0 and 1)
  54124. * @param factor defines the angular speed to affect to the specified gradient
  54125. * @returns the current particle system
  54126. */
  54127. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  54128. /**
  54129. * Remove a specific angular speed gradient
  54130. * @param gradient defines the gradient to remove
  54131. * @returns the current particle system
  54132. */
  54133. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  54134. /**
  54135. * Adds a new velocity gradient
  54136. * @param gradient defines the gradient to use (between 0 and 1)
  54137. * @param factor defines the velocity to affect to the specified gradient
  54138. * @returns the current particle system
  54139. */
  54140. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  54141. /**
  54142. * Remove a specific velocity gradient
  54143. * @param gradient defines the gradient to remove
  54144. * @returns the current particle system
  54145. */
  54146. removeVelocityGradient(gradient: number): GPUParticleSystem;
  54147. /**
  54148. * Adds a new limit velocity gradient
  54149. * @param gradient defines the gradient to use (between 0 and 1)
  54150. * @param factor defines the limit velocity value to affect to the specified gradient
  54151. * @returns the current particle system
  54152. */
  54153. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  54154. /**
  54155. * Remove a specific limit velocity gradient
  54156. * @param gradient defines the gradient to remove
  54157. * @returns the current particle system
  54158. */
  54159. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  54160. /**
  54161. * Adds a new drag gradient
  54162. * @param gradient defines the gradient to use (between 0 and 1)
  54163. * @param factor defines the drag value to affect to the specified gradient
  54164. * @returns the current particle system
  54165. */
  54166. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  54167. /**
  54168. * Remove a specific drag gradient
  54169. * @param gradient defines the gradient to remove
  54170. * @returns the current particle system
  54171. */
  54172. removeDragGradient(gradient: number): GPUParticleSystem;
  54173. /**
  54174. * Not supported by GPUParticleSystem
  54175. * @param gradient defines the gradient to use (between 0 and 1)
  54176. * @param factor defines the emit rate value to affect to the specified gradient
  54177. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54178. * @returns the current particle system
  54179. */
  54180. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54181. /**
  54182. * Not supported by GPUParticleSystem
  54183. * @param gradient defines the gradient to remove
  54184. * @returns the current particle system
  54185. */
  54186. removeEmitRateGradient(gradient: number): IParticleSystem;
  54187. /**
  54188. * Not supported by GPUParticleSystem
  54189. * @param gradient defines the gradient to use (between 0 and 1)
  54190. * @param factor defines the start size value to affect to the specified gradient
  54191. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54192. * @returns the current particle system
  54193. */
  54194. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54195. /**
  54196. * Not supported by GPUParticleSystem
  54197. * @param gradient defines the gradient to remove
  54198. * @returns the current particle system
  54199. */
  54200. removeStartSizeGradient(gradient: number): IParticleSystem;
  54201. /**
  54202. * Not supported by GPUParticleSystem
  54203. * @param gradient defines the gradient to use (between 0 and 1)
  54204. * @param min defines the color remap minimal range
  54205. * @param max defines the color remap maximal range
  54206. * @returns the current particle system
  54207. */
  54208. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  54209. /**
  54210. * Not supported by GPUParticleSystem
  54211. * @param gradient defines the gradient to remove
  54212. * @returns the current particle system
  54213. */
  54214. removeColorRemapGradient(): IParticleSystem;
  54215. /**
  54216. * Not supported by GPUParticleSystem
  54217. * @param gradient defines the gradient to use (between 0 and 1)
  54218. * @param min defines the alpha remap minimal range
  54219. * @param max defines the alpha remap maximal range
  54220. * @returns the current particle system
  54221. */
  54222. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  54223. /**
  54224. * Not supported by GPUParticleSystem
  54225. * @param gradient defines the gradient to remove
  54226. * @returns the current particle system
  54227. */
  54228. removeAlphaRemapGradient(): IParticleSystem;
  54229. /**
  54230. * Not supported by GPUParticleSystem
  54231. * @param gradient defines the gradient to use (between 0 and 1)
  54232. * @param color defines the color to affect to the specified gradient
  54233. * @returns the current particle system
  54234. */
  54235. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  54236. /**
  54237. * Not supported by GPUParticleSystem
  54238. * @param gradient defines the gradient to remove
  54239. * @returns the current particle system
  54240. */
  54241. removeRampGradient(): IParticleSystem;
  54242. /**
  54243. * Not supported by GPUParticleSystem
  54244. * @returns the list of ramp gradients
  54245. */
  54246. getRampGradients(): Nullable<Array<Color3Gradient>>;
  54247. /**
  54248. * Not supported by GPUParticleSystem
  54249. * Gets or sets a boolean indicating that ramp gradients must be used
  54250. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  54251. */
  54252. useRampGradients: boolean;
  54253. /**
  54254. * Not supported by GPUParticleSystem
  54255. * @param gradient defines the gradient to use (between 0 and 1)
  54256. * @param factor defines the life time factor to affect to the specified gradient
  54257. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54258. * @returns the current particle system
  54259. */
  54260. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54261. /**
  54262. * Not supported by GPUParticleSystem
  54263. * @param gradient defines the gradient to remove
  54264. * @returns the current particle system
  54265. */
  54266. removeLifeTimeGradient(gradient: number): IParticleSystem;
  54267. /**
  54268. * Instantiates a GPU particle system.
  54269. * 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.
  54270. * @param name The name of the particle system
  54271. * @param options The options used to create the system
  54272. * @param scene The scene the particle system belongs to
  54273. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  54274. */
  54275. constructor(name: string, options: Partial<{
  54276. capacity: number;
  54277. randomTextureSize: number;
  54278. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  54279. protected _reset(): void;
  54280. private _createUpdateVAO;
  54281. private _createRenderVAO;
  54282. private _initialize;
  54283. /** @hidden */
  54284. _recreateUpdateEffect(): void;
  54285. /** @hidden */
  54286. _recreateRenderEffect(): void;
  54287. /**
  54288. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  54289. * @param preWarm defines if we are in the pre-warmimg phase
  54290. */
  54291. animate(preWarm?: boolean): void;
  54292. private _createFactorGradientTexture;
  54293. private _createSizeGradientTexture;
  54294. private _createAngularSpeedGradientTexture;
  54295. private _createVelocityGradientTexture;
  54296. private _createLimitVelocityGradientTexture;
  54297. private _createDragGradientTexture;
  54298. private _createColorGradientTexture;
  54299. /**
  54300. * Renders the particle system in its current state
  54301. * @param preWarm defines if the system should only update the particles but not render them
  54302. * @returns the current number of particles
  54303. */
  54304. render(preWarm?: boolean): number;
  54305. /**
  54306. * Rebuilds the particle system
  54307. */
  54308. rebuild(): void;
  54309. private _releaseBuffers;
  54310. private _releaseVAOs;
  54311. /**
  54312. * Disposes the particle system and free the associated resources
  54313. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  54314. */
  54315. dispose(disposeTexture?: boolean): void;
  54316. /**
  54317. * Clones the particle system.
  54318. * @param name The name of the cloned object
  54319. * @param newEmitter The new emitter to use
  54320. * @returns the cloned particle system
  54321. */
  54322. clone(name: string, newEmitter: any): GPUParticleSystem;
  54323. /**
  54324. * Serializes the particle system to a JSON object.
  54325. * @returns the JSON object
  54326. */
  54327. serialize(): any;
  54328. /**
  54329. * Parses a JSON object to create a GPU particle system.
  54330. * @param parsedParticleSystem The JSON object to parse
  54331. * @param scene The scene to create the particle system in
  54332. * @param rootUrl The root url to use to load external dependencies like texture
  54333. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  54334. * @returns the parsed GPU particle system
  54335. */
  54336. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  54337. }
  54338. }
  54339. declare module BABYLON {
  54340. /**
  54341. * Represents a set of particle systems working together to create a specific effect
  54342. */
  54343. export class ParticleSystemSet implements IDisposable {
  54344. private _emitterCreationOptions;
  54345. private _emitterNode;
  54346. /**
  54347. * Gets the particle system list
  54348. */
  54349. systems: IParticleSystem[];
  54350. /**
  54351. * Gets the emitter node used with this set
  54352. */
  54353. readonly emitterNode: Nullable<TransformNode>;
  54354. /**
  54355. * Creates a new emitter mesh as a sphere
  54356. * @param options defines the options used to create the sphere
  54357. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  54358. * @param scene defines the hosting scene
  54359. */
  54360. setEmitterAsSphere(options: {
  54361. diameter: number;
  54362. segments: number;
  54363. color: Color3;
  54364. }, renderingGroupId: number, scene: Scene): void;
  54365. /**
  54366. * Starts all particle systems of the set
  54367. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54368. */
  54369. start(emitter?: AbstractMesh): void;
  54370. /**
  54371. * Release all associated resources
  54372. */
  54373. dispose(): void;
  54374. /**
  54375. * Serialize the set into a JSON compatible object
  54376. * @returns a JSON compatible representation of the set
  54377. */
  54378. serialize(): any;
  54379. /**
  54380. * Parse a new ParticleSystemSet from a serialized source
  54381. * @param data defines a JSON compatible representation of the set
  54382. * @param scene defines the hosting scene
  54383. * @param gpu defines if we want GPU particles or CPU particles
  54384. * @returns a new ParticleSystemSet
  54385. */
  54386. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54387. }
  54388. }
  54389. declare module BABYLON {
  54390. /**
  54391. * This class is made for on one-liner static method to help creating particle system set.
  54392. */
  54393. export class ParticleHelper {
  54394. /**
  54395. * Gets or sets base Assets URL
  54396. */
  54397. static BaseAssetsUrl: string;
  54398. /**
  54399. * Create a default particle system that you can tweak
  54400. * @param emitter defines the emitter to use
  54401. * @param capacity defines the system capacity (default is 500 particles)
  54402. * @param scene defines the hosting scene
  54403. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54404. * @returns the new Particle system
  54405. */
  54406. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54407. /**
  54408. * This is the main static method (one-liner) of this helper to create different particle systems
  54409. * @param type This string represents the type to the particle system to create
  54410. * @param scene The scene where the particle system should live
  54411. * @param gpu If the system will use gpu
  54412. * @returns the ParticleSystemSet created
  54413. */
  54414. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54415. /**
  54416. * Static function used to export a particle system to a ParticleSystemSet variable.
  54417. * Please note that the emitter shape is not exported
  54418. * @param systems defines the particle systems to export
  54419. * @returns the created particle system set
  54420. */
  54421. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54422. }
  54423. }
  54424. declare module BABYLON {
  54425. interface Engine {
  54426. /**
  54427. * Create an effect to use with particle systems.
  54428. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54429. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54430. * @param uniformsNames defines a list of attribute names
  54431. * @param samplers defines an array of string used to represent textures
  54432. * @param defines defines the string containing the defines to use to compile the shaders
  54433. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54434. * @param onCompiled defines a function to call when the effect creation is successful
  54435. * @param onError defines a function to call when the effect creation has failed
  54436. * @returns the new Effect
  54437. */
  54438. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54439. }
  54440. interface Mesh {
  54441. /**
  54442. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54443. * @returns an array of IParticleSystem
  54444. */
  54445. getEmittedParticleSystems(): IParticleSystem[];
  54446. /**
  54447. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54448. * @returns an array of IParticleSystem
  54449. */
  54450. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54451. }
  54452. /**
  54453. * @hidden
  54454. */
  54455. export var _IDoNeedToBeInTheBuild: number;
  54456. }
  54457. declare module BABYLON {
  54458. interface Scene {
  54459. /** @hidden (Backing field) */
  54460. _physicsEngine: Nullable<IPhysicsEngine>;
  54461. /**
  54462. * Gets the current physics engine
  54463. * @returns a IPhysicsEngine or null if none attached
  54464. */
  54465. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54466. /**
  54467. * Enables physics to the current scene
  54468. * @param gravity defines the scene's gravity for the physics engine
  54469. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54470. * @return a boolean indicating if the physics engine was initialized
  54471. */
  54472. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54473. /**
  54474. * Disables and disposes the physics engine associated with the scene
  54475. */
  54476. disablePhysicsEngine(): void;
  54477. /**
  54478. * Gets a boolean indicating if there is an active physics engine
  54479. * @returns a boolean indicating if there is an active physics engine
  54480. */
  54481. isPhysicsEnabled(): boolean;
  54482. /**
  54483. * Deletes a physics compound impostor
  54484. * @param compound defines the compound to delete
  54485. */
  54486. deleteCompoundImpostor(compound: any): void;
  54487. /**
  54488. * An event triggered when physic simulation is about to be run
  54489. */
  54490. onBeforePhysicsObservable: Observable<Scene>;
  54491. /**
  54492. * An event triggered when physic simulation has been done
  54493. */
  54494. onAfterPhysicsObservable: Observable<Scene>;
  54495. }
  54496. interface AbstractMesh {
  54497. /** @hidden */
  54498. _physicsImpostor: Nullable<PhysicsImpostor>;
  54499. /**
  54500. * Gets or sets impostor used for physic simulation
  54501. * @see http://doc.babylonjs.com/features/physics_engine
  54502. */
  54503. physicsImpostor: Nullable<PhysicsImpostor>;
  54504. /**
  54505. * Gets the current physics impostor
  54506. * @see http://doc.babylonjs.com/features/physics_engine
  54507. * @returns a physics impostor or null
  54508. */
  54509. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54510. /** Apply a physic impulse to the mesh
  54511. * @param force defines the force to apply
  54512. * @param contactPoint defines where to apply the force
  54513. * @returns the current mesh
  54514. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54515. */
  54516. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54517. /**
  54518. * Creates a physic joint between two meshes
  54519. * @param otherMesh defines the other mesh to use
  54520. * @param pivot1 defines the pivot to use on this mesh
  54521. * @param pivot2 defines the pivot to use on the other mesh
  54522. * @param options defines additional options (can be plugin dependent)
  54523. * @returns the current mesh
  54524. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54525. */
  54526. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54527. /** @hidden */
  54528. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54529. }
  54530. /**
  54531. * Defines the physics engine scene component responsible to manage a physics engine
  54532. */
  54533. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54534. /**
  54535. * The component name helpful to identify the component in the list of scene components.
  54536. */
  54537. readonly name: string;
  54538. /**
  54539. * The scene the component belongs to.
  54540. */
  54541. scene: Scene;
  54542. /**
  54543. * Creates a new instance of the component for the given scene
  54544. * @param scene Defines the scene to register the component in
  54545. */
  54546. constructor(scene: Scene);
  54547. /**
  54548. * Registers the component in a given scene
  54549. */
  54550. register(): void;
  54551. /**
  54552. * Rebuilds the elements related to this component in case of
  54553. * context lost for instance.
  54554. */
  54555. rebuild(): void;
  54556. /**
  54557. * Disposes the component and the associated ressources
  54558. */
  54559. dispose(): void;
  54560. }
  54561. }
  54562. declare module BABYLON {
  54563. /**
  54564. * A helper for physics simulations
  54565. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54566. */
  54567. export class PhysicsHelper {
  54568. private _scene;
  54569. private _physicsEngine;
  54570. /**
  54571. * Initializes the Physics helper
  54572. * @param scene Babylon.js scene
  54573. */
  54574. constructor(scene: Scene);
  54575. /**
  54576. * Applies a radial explosion impulse
  54577. * @param origin the origin of the explosion
  54578. * @param radiusOrEventOptions the radius or the options of radial explosion
  54579. * @param strength the explosion strength
  54580. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54581. * @returns A physics radial explosion event, or null
  54582. */
  54583. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54584. /**
  54585. * Applies a radial explosion force
  54586. * @param origin the origin of the explosion
  54587. * @param radiusOrEventOptions the radius or the options of radial explosion
  54588. * @param strength the explosion strength
  54589. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54590. * @returns A physics radial explosion event, or null
  54591. */
  54592. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54593. /**
  54594. * Creates a gravitational field
  54595. * @param origin the origin of the explosion
  54596. * @param radiusOrEventOptions the radius or the options of radial explosion
  54597. * @param strength the explosion strength
  54598. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54599. * @returns A physics gravitational field event, or null
  54600. */
  54601. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54602. /**
  54603. * Creates a physics updraft event
  54604. * @param origin the origin of the updraft
  54605. * @param radiusOrEventOptions the radius or the options of the updraft
  54606. * @param strength the strength of the updraft
  54607. * @param height the height of the updraft
  54608. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54609. * @returns A physics updraft event, or null
  54610. */
  54611. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54612. /**
  54613. * Creates a physics vortex event
  54614. * @param origin the of the vortex
  54615. * @param radiusOrEventOptions the radius or the options of the vortex
  54616. * @param strength the strength of the vortex
  54617. * @param height the height of the vortex
  54618. * @returns a Physics vortex event, or null
  54619. * A physics vortex event or null
  54620. */
  54621. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54622. }
  54623. /**
  54624. * Represents a physics radial explosion event
  54625. */
  54626. class PhysicsRadialExplosionEvent {
  54627. private _scene;
  54628. private _options;
  54629. private _sphere;
  54630. private _dataFetched;
  54631. /**
  54632. * Initializes a radial explosioin event
  54633. * @param _scene BabylonJS scene
  54634. * @param _options The options for the vortex event
  54635. */
  54636. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54637. /**
  54638. * Returns the data related to the radial explosion event (sphere).
  54639. * @returns The radial explosion event data
  54640. */
  54641. getData(): PhysicsRadialExplosionEventData;
  54642. /**
  54643. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54644. * @param impostor A physics imposter
  54645. * @param origin the origin of the explosion
  54646. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54647. */
  54648. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54649. /**
  54650. * Triggers affecterd impostors callbacks
  54651. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54652. */
  54653. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54654. /**
  54655. * Disposes the sphere.
  54656. * @param force Specifies if the sphere should be disposed by force
  54657. */
  54658. dispose(force?: boolean): void;
  54659. /*** Helpers ***/
  54660. private _prepareSphere;
  54661. private _intersectsWithSphere;
  54662. }
  54663. /**
  54664. * Represents a gravitational field event
  54665. */
  54666. class PhysicsGravitationalFieldEvent {
  54667. private _physicsHelper;
  54668. private _scene;
  54669. private _origin;
  54670. private _options;
  54671. private _tickCallback;
  54672. private _sphere;
  54673. private _dataFetched;
  54674. /**
  54675. * Initializes the physics gravitational field event
  54676. * @param _physicsHelper A physics helper
  54677. * @param _scene BabylonJS scene
  54678. * @param _origin The origin position of the gravitational field event
  54679. * @param _options The options for the vortex event
  54680. */
  54681. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54682. /**
  54683. * Returns the data related to the gravitational field event (sphere).
  54684. * @returns A gravitational field event
  54685. */
  54686. getData(): PhysicsGravitationalFieldEventData;
  54687. /**
  54688. * Enables the gravitational field.
  54689. */
  54690. enable(): void;
  54691. /**
  54692. * Disables the gravitational field.
  54693. */
  54694. disable(): void;
  54695. /**
  54696. * Disposes the sphere.
  54697. * @param force The force to dispose from the gravitational field event
  54698. */
  54699. dispose(force?: boolean): void;
  54700. private _tick;
  54701. }
  54702. /**
  54703. * Represents a physics updraft event
  54704. */
  54705. class PhysicsUpdraftEvent {
  54706. private _scene;
  54707. private _origin;
  54708. private _options;
  54709. private _physicsEngine;
  54710. private _originTop;
  54711. private _originDirection;
  54712. private _tickCallback;
  54713. private _cylinder;
  54714. private _cylinderPosition;
  54715. private _dataFetched;
  54716. /**
  54717. * Initializes the physics updraft event
  54718. * @param _scene BabylonJS scene
  54719. * @param _origin The origin position of the updraft
  54720. * @param _options The options for the updraft event
  54721. */
  54722. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54723. /**
  54724. * Returns the data related to the updraft event (cylinder).
  54725. * @returns A physics updraft event
  54726. */
  54727. getData(): PhysicsUpdraftEventData;
  54728. /**
  54729. * Enables the updraft.
  54730. */
  54731. enable(): void;
  54732. /**
  54733. * Disables the updraft.
  54734. */
  54735. disable(): void;
  54736. /**
  54737. * Disposes the cylinder.
  54738. * @param force Specifies if the updraft should be disposed by force
  54739. */
  54740. dispose(force?: boolean): void;
  54741. private getImpostorHitData;
  54742. private _tick;
  54743. /*** Helpers ***/
  54744. private _prepareCylinder;
  54745. private _intersectsWithCylinder;
  54746. }
  54747. /**
  54748. * Represents a physics vortex event
  54749. */
  54750. class PhysicsVortexEvent {
  54751. private _scene;
  54752. private _origin;
  54753. private _options;
  54754. private _physicsEngine;
  54755. private _originTop;
  54756. private _tickCallback;
  54757. private _cylinder;
  54758. private _cylinderPosition;
  54759. private _dataFetched;
  54760. /**
  54761. * Initializes the physics vortex event
  54762. * @param _scene The BabylonJS scene
  54763. * @param _origin The origin position of the vortex
  54764. * @param _options The options for the vortex event
  54765. */
  54766. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54767. /**
  54768. * Returns the data related to the vortex event (cylinder).
  54769. * @returns The physics vortex event data
  54770. */
  54771. getData(): PhysicsVortexEventData;
  54772. /**
  54773. * Enables the vortex.
  54774. */
  54775. enable(): void;
  54776. /**
  54777. * Disables the cortex.
  54778. */
  54779. disable(): void;
  54780. /**
  54781. * Disposes the sphere.
  54782. * @param force
  54783. */
  54784. dispose(force?: boolean): void;
  54785. private getImpostorHitData;
  54786. private _tick;
  54787. /*** Helpers ***/
  54788. private _prepareCylinder;
  54789. private _intersectsWithCylinder;
  54790. }
  54791. /**
  54792. * Options fot the radial explosion event
  54793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54794. */
  54795. export class PhysicsRadialExplosionEventOptions {
  54796. /**
  54797. * The radius of the sphere for the radial explosion.
  54798. */
  54799. radius: number;
  54800. /**
  54801. * The strenth of the explosion.
  54802. */
  54803. strength: number;
  54804. /**
  54805. * The strenght of the force in correspondence to the distance of the affected object
  54806. */
  54807. falloff: PhysicsRadialImpulseFalloff;
  54808. /**
  54809. * Sphere options for the radial explosion.
  54810. */
  54811. sphere: {
  54812. segments: number;
  54813. diameter: number;
  54814. };
  54815. /**
  54816. * Sphere options for the radial explosion.
  54817. */
  54818. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54819. }
  54820. /**
  54821. * Options fot the updraft event
  54822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54823. */
  54824. export class PhysicsUpdraftEventOptions {
  54825. /**
  54826. * The radius of the cylinder for the vortex
  54827. */
  54828. radius: number;
  54829. /**
  54830. * The strenth of the updraft.
  54831. */
  54832. strength: number;
  54833. /**
  54834. * The height of the cylinder for the updraft.
  54835. */
  54836. height: number;
  54837. /**
  54838. * The mode for the the updraft.
  54839. */
  54840. updraftMode: PhysicsUpdraftMode;
  54841. }
  54842. /**
  54843. * Options fot the vortex event
  54844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54845. */
  54846. export class PhysicsVortexEventOptions {
  54847. /**
  54848. * The radius of the cylinder for the vortex
  54849. */
  54850. radius: number;
  54851. /**
  54852. * The strenth of the vortex.
  54853. */
  54854. strength: number;
  54855. /**
  54856. * The height of the cylinder for the vortex.
  54857. */
  54858. height: number;
  54859. /**
  54860. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54861. */
  54862. centripetalForceThreshold: number;
  54863. /**
  54864. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54865. */
  54866. centripetalForceMultiplier: number;
  54867. /**
  54868. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54869. */
  54870. centrifugalForceMultiplier: number;
  54871. /**
  54872. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54873. */
  54874. updraftForceMultiplier: number;
  54875. }
  54876. /**
  54877. * The strenght of the force in correspondence to the distance of the affected object
  54878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54879. */
  54880. export enum PhysicsRadialImpulseFalloff {
  54881. /** Defines that impulse is constant in strength across it's whole radius */
  54882. Constant = 0,
  54883. /** Defines that impulse gets weaker if it's further from the origin */
  54884. Linear = 1
  54885. }
  54886. /**
  54887. * The strength of the force in correspondence to the distance of the affected object
  54888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54889. */
  54890. export enum PhysicsUpdraftMode {
  54891. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54892. Center = 0,
  54893. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54894. Perpendicular = 1
  54895. }
  54896. /**
  54897. * Interface for a physics hit data
  54898. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54899. */
  54900. export interface PhysicsHitData {
  54901. /**
  54902. * The force applied at the contact point
  54903. */
  54904. force: Vector3;
  54905. /**
  54906. * The contact point
  54907. */
  54908. contactPoint: Vector3;
  54909. /**
  54910. * The distance from the origin to the contact point
  54911. */
  54912. distanceFromOrigin: number;
  54913. }
  54914. /**
  54915. * Interface for radial explosion event data
  54916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54917. */
  54918. export interface PhysicsRadialExplosionEventData {
  54919. /**
  54920. * A sphere used for the radial explosion event
  54921. */
  54922. sphere: Mesh;
  54923. }
  54924. /**
  54925. * Interface for gravitational field event data
  54926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54927. */
  54928. export interface PhysicsGravitationalFieldEventData {
  54929. /**
  54930. * A sphere mesh used for the gravitational field event
  54931. */
  54932. sphere: Mesh;
  54933. }
  54934. /**
  54935. * Interface for updraft event data
  54936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54937. */
  54938. export interface PhysicsUpdraftEventData {
  54939. /**
  54940. * A cylinder used for the updraft event
  54941. */
  54942. cylinder: Mesh;
  54943. }
  54944. /**
  54945. * Interface for vortex event data
  54946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54947. */
  54948. export interface PhysicsVortexEventData {
  54949. /**
  54950. * A cylinder used for the vortex event
  54951. */
  54952. cylinder: Mesh;
  54953. }
  54954. /**
  54955. * Interface for an affected physics impostor
  54956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54957. */
  54958. export interface PhysicsAffectedImpostorWithData {
  54959. /**
  54960. * The impostor affected by the effect
  54961. */
  54962. impostor: PhysicsImpostor;
  54963. /**
  54964. * The data about the hit/horce from the explosion
  54965. */
  54966. hitData: PhysicsHitData;
  54967. }
  54968. }
  54969. declare module BABYLON {
  54970. /** @hidden */
  54971. export var blackAndWhitePixelShader: {
  54972. name: string;
  54973. shader: string;
  54974. };
  54975. }
  54976. declare module BABYLON {
  54977. /**
  54978. * Post process used to render in black and white
  54979. */
  54980. export class BlackAndWhitePostProcess extends PostProcess {
  54981. /**
  54982. * Linear about to convert he result to black and white (default: 1)
  54983. */
  54984. degree: number;
  54985. /**
  54986. * Creates a black and white post process
  54987. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54988. * @param name The name of the effect.
  54989. * @param options The required width/height ratio to downsize to before computing the render pass.
  54990. * @param camera The camera to apply the render pass to.
  54991. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54992. * @param engine The engine which the post process will be applied. (default: current engine)
  54993. * @param reusable If the post process can be reused on the same frame. (default: false)
  54994. */
  54995. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54996. }
  54997. }
  54998. declare module BABYLON {
  54999. /**
  55000. * This represents a set of one or more post processes in Babylon.
  55001. * A post process can be used to apply a shader to a texture after it is rendered.
  55002. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55003. */
  55004. export class PostProcessRenderEffect {
  55005. private _postProcesses;
  55006. private _getPostProcesses;
  55007. private _singleInstance;
  55008. private _cameras;
  55009. private _indicesForCamera;
  55010. /**
  55011. * Name of the effect
  55012. * @hidden
  55013. */
  55014. _name: string;
  55015. /**
  55016. * Instantiates a post process render effect.
  55017. * A post process can be used to apply a shader to a texture after it is rendered.
  55018. * @param engine The engine the effect is tied to
  55019. * @param name The name of the effect
  55020. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  55021. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  55022. */
  55023. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  55024. /**
  55025. * Checks if all the post processes in the effect are supported.
  55026. */
  55027. readonly isSupported: boolean;
  55028. /**
  55029. * Updates the current state of the effect
  55030. * @hidden
  55031. */
  55032. _update(): void;
  55033. /**
  55034. * Attaches the effect on cameras
  55035. * @param cameras The camera to attach to.
  55036. * @hidden
  55037. */
  55038. _attachCameras(cameras: Camera): void;
  55039. /**
  55040. * Attaches the effect on cameras
  55041. * @param cameras The camera to attach to.
  55042. * @hidden
  55043. */
  55044. _attachCameras(cameras: Camera[]): void;
  55045. /**
  55046. * Detaches the effect on cameras
  55047. * @param cameras The camera to detatch from.
  55048. * @hidden
  55049. */
  55050. _detachCameras(cameras: Camera): void;
  55051. /**
  55052. * Detatches the effect on cameras
  55053. * @param cameras The camera to detatch from.
  55054. * @hidden
  55055. */
  55056. _detachCameras(cameras: Camera[]): void;
  55057. /**
  55058. * Enables the effect on given cameras
  55059. * @param cameras The camera to enable.
  55060. * @hidden
  55061. */
  55062. _enable(cameras: Camera): void;
  55063. /**
  55064. * Enables the effect on given cameras
  55065. * @param cameras The camera to enable.
  55066. * @hidden
  55067. */
  55068. _enable(cameras: Nullable<Camera[]>): void;
  55069. /**
  55070. * Disables the effect on the given cameras
  55071. * @param cameras The camera to disable.
  55072. * @hidden
  55073. */
  55074. _disable(cameras: Camera): void;
  55075. /**
  55076. * Disables the effect on the given cameras
  55077. * @param cameras The camera to disable.
  55078. * @hidden
  55079. */
  55080. _disable(cameras: Nullable<Camera[]>): void;
  55081. /**
  55082. * Gets a list of the post processes contained in the effect.
  55083. * @param camera The camera to get the post processes on.
  55084. * @returns The list of the post processes in the effect.
  55085. */
  55086. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  55087. }
  55088. }
  55089. declare module BABYLON {
  55090. /** @hidden */
  55091. export var extractHighlightsPixelShader: {
  55092. name: string;
  55093. shader: string;
  55094. };
  55095. }
  55096. declare module BABYLON {
  55097. /**
  55098. * 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.
  55099. */
  55100. export class ExtractHighlightsPostProcess extends PostProcess {
  55101. /**
  55102. * The luminance threshold, pixels below this value will be set to black.
  55103. */
  55104. threshold: number;
  55105. /** @hidden */
  55106. _exposure: number;
  55107. /**
  55108. * Post process which has the input texture to be used when performing highlight extraction
  55109. * @hidden
  55110. */
  55111. _inputPostProcess: Nullable<PostProcess>;
  55112. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55113. }
  55114. }
  55115. declare module BABYLON {
  55116. /** @hidden */
  55117. export var bloomMergePixelShader: {
  55118. name: string;
  55119. shader: string;
  55120. };
  55121. }
  55122. declare module BABYLON {
  55123. /**
  55124. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55125. */
  55126. export class BloomMergePostProcess extends PostProcess {
  55127. /** Weight of the bloom to be added to the original input. */
  55128. weight: number;
  55129. /**
  55130. * Creates a new instance of @see BloomMergePostProcess
  55131. * @param name The name of the effect.
  55132. * @param originalFromInput Post process which's input will be used for the merge.
  55133. * @param blurred Blurred highlights post process which's output will be used.
  55134. * @param weight Weight of the bloom to be added to the original input.
  55135. * @param options The required width/height ratio to downsize to before computing the render pass.
  55136. * @param camera The camera to apply the render pass to.
  55137. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55138. * @param engine The engine which the post process will be applied. (default: current engine)
  55139. * @param reusable If the post process can be reused on the same frame. (default: false)
  55140. * @param textureType Type of textures used when performing the post process. (default: 0)
  55141. * @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)
  55142. */
  55143. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  55144. /** Weight of the bloom to be added to the original input. */
  55145. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55146. }
  55147. }
  55148. declare module BABYLON {
  55149. /**
  55150. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  55151. */
  55152. export class BloomEffect extends PostProcessRenderEffect {
  55153. private bloomScale;
  55154. /**
  55155. * @hidden Internal
  55156. */
  55157. _effects: Array<PostProcess>;
  55158. /**
  55159. * @hidden Internal
  55160. */
  55161. _downscale: ExtractHighlightsPostProcess;
  55162. private _blurX;
  55163. private _blurY;
  55164. private _merge;
  55165. /**
  55166. * The luminance threshold to find bright areas of the image to bloom.
  55167. */
  55168. threshold: number;
  55169. /**
  55170. * The strength of the bloom.
  55171. */
  55172. weight: number;
  55173. /**
  55174. * Specifies the size of the bloom blur kernel, relative to the final output size
  55175. */
  55176. kernel: number;
  55177. /**
  55178. * Creates a new instance of @see BloomEffect
  55179. * @param scene The scene the effect belongs to.
  55180. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  55181. * @param bloomKernel The size of the kernel to be used when applying the blur.
  55182. * @param bloomWeight The the strength of bloom.
  55183. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55184. * @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)
  55185. */
  55186. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  55187. /**
  55188. * Disposes each of the internal effects for a given camera.
  55189. * @param camera The camera to dispose the effect on.
  55190. */
  55191. disposeEffects(camera: Camera): void;
  55192. /**
  55193. * @hidden Internal
  55194. */
  55195. _updateEffects(): void;
  55196. /**
  55197. * Internal
  55198. * @returns if all the contained post processes are ready.
  55199. * @hidden
  55200. */
  55201. _isReady(): boolean;
  55202. }
  55203. }
  55204. declare module BABYLON {
  55205. /** @hidden */
  55206. export var chromaticAberrationPixelShader: {
  55207. name: string;
  55208. shader: string;
  55209. };
  55210. }
  55211. declare module BABYLON {
  55212. /**
  55213. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  55214. */
  55215. export class ChromaticAberrationPostProcess extends PostProcess {
  55216. /**
  55217. * The amount of seperation of rgb channels (default: 30)
  55218. */
  55219. aberrationAmount: number;
  55220. /**
  55221. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  55222. */
  55223. radialIntensity: number;
  55224. /**
  55225. * 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))
  55226. */
  55227. direction: Vector2;
  55228. /**
  55229. * 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))
  55230. */
  55231. centerPosition: Vector2;
  55232. /**
  55233. * Creates a new instance ChromaticAberrationPostProcess
  55234. * @param name The name of the effect.
  55235. * @param screenWidth The width of the screen to apply the effect on.
  55236. * @param screenHeight The height of the screen to apply the effect on.
  55237. * @param options The required width/height ratio to downsize to before computing the render pass.
  55238. * @param camera The camera to apply the render pass to.
  55239. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55240. * @param engine The engine which the post process will be applied. (default: current engine)
  55241. * @param reusable If the post process can be reused on the same frame. (default: false)
  55242. * @param textureType Type of textures used when performing the post process. (default: 0)
  55243. * @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)
  55244. */
  55245. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55246. }
  55247. }
  55248. declare module BABYLON {
  55249. /** @hidden */
  55250. export var circleOfConfusionPixelShader: {
  55251. name: string;
  55252. shader: string;
  55253. };
  55254. }
  55255. declare module BABYLON {
  55256. /**
  55257. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  55258. */
  55259. export class CircleOfConfusionPostProcess extends PostProcess {
  55260. /**
  55261. * 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.
  55262. */
  55263. lensSize: number;
  55264. /**
  55265. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55266. */
  55267. fStop: number;
  55268. /**
  55269. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55270. */
  55271. focusDistance: number;
  55272. /**
  55273. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  55274. */
  55275. focalLength: number;
  55276. private _depthTexture;
  55277. /**
  55278. * Creates a new instance CircleOfConfusionPostProcess
  55279. * @param name The name of the effect.
  55280. * @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.
  55281. * @param options The required width/height ratio to downsize to before computing the render pass.
  55282. * @param camera The camera to apply the render pass to.
  55283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55284. * @param engine The engine which the post process will be applied. (default: current engine)
  55285. * @param reusable If the post process can be reused on the same frame. (default: false)
  55286. * @param textureType Type of textures used when performing the post process. (default: 0)
  55287. * @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)
  55288. */
  55289. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55290. /**
  55291. * 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.
  55292. */
  55293. depthTexture: RenderTargetTexture;
  55294. }
  55295. }
  55296. declare module BABYLON {
  55297. /** @hidden */
  55298. export var colorCorrectionPixelShader: {
  55299. name: string;
  55300. shader: string;
  55301. };
  55302. }
  55303. declare module BABYLON {
  55304. /**
  55305. *
  55306. * This post-process allows the modification of rendered colors by using
  55307. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55308. *
  55309. * The object needs to be provided an url to a texture containing the color
  55310. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55311. * Use an image editing software to tweak the LUT to match your needs.
  55312. *
  55313. * For an example of a color LUT, see here:
  55314. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55315. * For explanations on color grading, see here:
  55316. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55317. *
  55318. */
  55319. export class ColorCorrectionPostProcess extends PostProcess {
  55320. private _colorTableTexture;
  55321. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55322. }
  55323. }
  55324. declare module BABYLON {
  55325. /** @hidden */
  55326. export var convolutionPixelShader: {
  55327. name: string;
  55328. shader: string;
  55329. };
  55330. }
  55331. declare module BABYLON {
  55332. /**
  55333. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55334. * input texture to perform effects such as edge detection or sharpening
  55335. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55336. */
  55337. export class ConvolutionPostProcess extends PostProcess {
  55338. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  55339. kernel: number[];
  55340. /**
  55341. * Creates a new instance ConvolutionPostProcess
  55342. * @param name The name of the effect.
  55343. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  55344. * @param options The required width/height ratio to downsize to before computing the render pass.
  55345. * @param camera The camera to apply the render pass to.
  55346. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55347. * @param engine The engine which the post process will be applied. (default: current engine)
  55348. * @param reusable If the post process can be reused on the same frame. (default: false)
  55349. * @param textureType Type of textures used when performing the post process. (default: 0)
  55350. */
  55351. constructor(name: string,
  55352. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  55353. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55354. /**
  55355. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55356. */
  55357. static EdgeDetect0Kernel: number[];
  55358. /**
  55359. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55360. */
  55361. static EdgeDetect1Kernel: number[];
  55362. /**
  55363. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55364. */
  55365. static EdgeDetect2Kernel: number[];
  55366. /**
  55367. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55368. */
  55369. static SharpenKernel: number[];
  55370. /**
  55371. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55372. */
  55373. static EmbossKernel: number[];
  55374. /**
  55375. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55376. */
  55377. static GaussianKernel: number[];
  55378. }
  55379. }
  55380. declare module BABYLON {
  55381. /**
  55382. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55383. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55384. * based on samples that have a large difference in distance than the center pixel.
  55385. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55386. */
  55387. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55388. direction: Vector2;
  55389. /**
  55390. * Creates a new instance CircleOfConfusionPostProcess
  55391. * @param name The name of the effect.
  55392. * @param scene The scene the effect belongs to.
  55393. * @param direction The direction the blur should be applied.
  55394. * @param kernel The size of the kernel used to blur.
  55395. * @param options The required width/height ratio to downsize to before computing the render pass.
  55396. * @param camera The camera to apply the render pass to.
  55397. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55398. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55399. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55400. * @param engine The engine which the post process will be applied. (default: current engine)
  55401. * @param reusable If the post process can be reused on the same frame. (default: false)
  55402. * @param textureType Type of textures used when performing the post process. (default: 0)
  55403. * @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)
  55404. */
  55405. 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);
  55406. }
  55407. }
  55408. declare module BABYLON {
  55409. /** @hidden */
  55410. export var depthOfFieldMergePixelShader: {
  55411. name: string;
  55412. shader: string;
  55413. };
  55414. }
  55415. declare module BABYLON {
  55416. /**
  55417. * Options to be set when merging outputs from the default pipeline.
  55418. */
  55419. export class DepthOfFieldMergePostProcessOptions {
  55420. /**
  55421. * The original image to merge on top of
  55422. */
  55423. originalFromInput: PostProcess;
  55424. /**
  55425. * Parameters to perform the merge of the depth of field effect
  55426. */
  55427. depthOfField?: {
  55428. circleOfConfusion: PostProcess;
  55429. blurSteps: Array<PostProcess>;
  55430. };
  55431. /**
  55432. * Parameters to perform the merge of bloom effect
  55433. */
  55434. bloom?: {
  55435. blurred: PostProcess;
  55436. weight: number;
  55437. };
  55438. }
  55439. /**
  55440. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55441. */
  55442. export class DepthOfFieldMergePostProcess extends PostProcess {
  55443. private blurSteps;
  55444. /**
  55445. * Creates a new instance of DepthOfFieldMergePostProcess
  55446. * @param name The name of the effect.
  55447. * @param originalFromInput Post process which's input will be used for the merge.
  55448. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55449. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55450. * @param options The required width/height ratio to downsize to before computing the render pass.
  55451. * @param camera The camera to apply the render pass to.
  55452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55453. * @param engine The engine which the post process will be applied. (default: current engine)
  55454. * @param reusable If the post process can be reused on the same frame. (default: false)
  55455. * @param textureType Type of textures used when performing the post process. (default: 0)
  55456. * @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)
  55457. */
  55458. 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);
  55459. /**
  55460. * Updates the effect with the current post process compile time values and recompiles the shader.
  55461. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55462. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55463. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55464. * @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
  55465. * @param onCompiled Called when the shader has been compiled.
  55466. * @param onError Called if there is an error when compiling a shader.
  55467. */
  55468. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55469. }
  55470. }
  55471. declare module BABYLON {
  55472. /**
  55473. * Specifies the level of max blur that should be applied when using the depth of field effect
  55474. */
  55475. export enum DepthOfFieldEffectBlurLevel {
  55476. /**
  55477. * Subtle blur
  55478. */
  55479. Low = 0,
  55480. /**
  55481. * Medium blur
  55482. */
  55483. Medium = 1,
  55484. /**
  55485. * Large blur
  55486. */
  55487. High = 2
  55488. }
  55489. /**
  55490. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55491. */
  55492. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55493. private _circleOfConfusion;
  55494. /**
  55495. * @hidden Internal, blurs from high to low
  55496. */
  55497. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55498. private _depthOfFieldBlurY;
  55499. private _dofMerge;
  55500. /**
  55501. * @hidden Internal post processes in depth of field effect
  55502. */
  55503. _effects: Array<PostProcess>;
  55504. /**
  55505. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55506. */
  55507. focalLength: number;
  55508. /**
  55509. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55510. */
  55511. fStop: number;
  55512. /**
  55513. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55514. */
  55515. focusDistance: number;
  55516. /**
  55517. * 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.
  55518. */
  55519. lensSize: number;
  55520. /**
  55521. * Creates a new instance DepthOfFieldEffect
  55522. * @param scene The scene the effect belongs to.
  55523. * @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.
  55524. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55525. * @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)
  55526. */
  55527. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55528. /**
  55529. * Get the current class name of the current effet
  55530. * @returns "DepthOfFieldEffect"
  55531. */
  55532. getClassName(): string;
  55533. /**
  55534. * 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.
  55535. */
  55536. depthTexture: RenderTargetTexture;
  55537. /**
  55538. * Disposes each of the internal effects for a given camera.
  55539. * @param camera The camera to dispose the effect on.
  55540. */
  55541. disposeEffects(camera: Camera): void;
  55542. /**
  55543. * @hidden Internal
  55544. */
  55545. _updateEffects(): void;
  55546. /**
  55547. * Internal
  55548. * @returns if all the contained post processes are ready.
  55549. * @hidden
  55550. */
  55551. _isReady(): boolean;
  55552. }
  55553. }
  55554. declare module BABYLON {
  55555. /** @hidden */
  55556. export var displayPassPixelShader: {
  55557. name: string;
  55558. shader: string;
  55559. };
  55560. }
  55561. declare module BABYLON {
  55562. /**
  55563. * DisplayPassPostProcess which produces an output the same as it's input
  55564. */
  55565. export class DisplayPassPostProcess extends PostProcess {
  55566. /**
  55567. * Creates the DisplayPassPostProcess
  55568. * @param name The name of the effect.
  55569. * @param options The required width/height ratio to downsize to before computing the render pass.
  55570. * @param camera The camera to apply the render pass to.
  55571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55572. * @param engine The engine which the post process will be applied. (default: current engine)
  55573. * @param reusable If the post process can be reused on the same frame. (default: false)
  55574. */
  55575. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55576. }
  55577. }
  55578. declare module BABYLON {
  55579. /** @hidden */
  55580. export var filterPixelShader: {
  55581. name: string;
  55582. shader: string;
  55583. };
  55584. }
  55585. declare module BABYLON {
  55586. /**
  55587. * Applies a kernel filter to the image
  55588. */
  55589. export class FilterPostProcess extends PostProcess {
  55590. /** The matrix to be applied to the image */
  55591. kernelMatrix: Matrix;
  55592. /**
  55593. *
  55594. * @param name The name of the effect.
  55595. * @param kernelMatrix The matrix to be applied to the image
  55596. * @param options The required width/height ratio to downsize to before computing the render pass.
  55597. * @param camera The camera to apply the render pass to.
  55598. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55599. * @param engine The engine which the post process will be applied. (default: current engine)
  55600. * @param reusable If the post process can be reused on the same frame. (default: false)
  55601. */
  55602. constructor(name: string,
  55603. /** The matrix to be applied to the image */
  55604. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55605. }
  55606. }
  55607. declare module BABYLON {
  55608. /** @hidden */
  55609. export var fxaaPixelShader: {
  55610. name: string;
  55611. shader: string;
  55612. };
  55613. }
  55614. declare module BABYLON {
  55615. /** @hidden */
  55616. export var fxaaVertexShader: {
  55617. name: string;
  55618. shader: string;
  55619. };
  55620. }
  55621. declare module BABYLON {
  55622. /**
  55623. * Fxaa post process
  55624. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55625. */
  55626. export class FxaaPostProcess extends PostProcess {
  55627. /** @hidden */
  55628. texelWidth: number;
  55629. /** @hidden */
  55630. texelHeight: number;
  55631. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55632. private _getDefines;
  55633. }
  55634. }
  55635. declare module BABYLON {
  55636. /** @hidden */
  55637. export var grainPixelShader: {
  55638. name: string;
  55639. shader: string;
  55640. };
  55641. }
  55642. declare module BABYLON {
  55643. /**
  55644. * The GrainPostProcess adds noise to the image at mid luminance levels
  55645. */
  55646. export class GrainPostProcess extends PostProcess {
  55647. /**
  55648. * The intensity of the grain added (default: 30)
  55649. */
  55650. intensity: number;
  55651. /**
  55652. * If the grain should be randomized on every frame
  55653. */
  55654. animated: boolean;
  55655. /**
  55656. * Creates a new instance of @see GrainPostProcess
  55657. * @param name The name of the effect.
  55658. * @param options The required width/height ratio to downsize to before computing the render pass.
  55659. * @param camera The camera to apply the render pass to.
  55660. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55661. * @param engine The engine which the post process will be applied. (default: current engine)
  55662. * @param reusable If the post process can be reused on the same frame. (default: false)
  55663. * @param textureType Type of textures used when performing the post process. (default: 0)
  55664. * @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)
  55665. */
  55666. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55667. }
  55668. }
  55669. declare module BABYLON {
  55670. /** @hidden */
  55671. export var highlightsPixelShader: {
  55672. name: string;
  55673. shader: string;
  55674. };
  55675. }
  55676. declare module BABYLON {
  55677. /**
  55678. * Extracts highlights from the image
  55679. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55680. */
  55681. export class HighlightsPostProcess extends PostProcess {
  55682. /**
  55683. * Extracts highlights from the image
  55684. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55685. * @param name The name of the effect.
  55686. * @param options The required width/height ratio to downsize to before computing the render pass.
  55687. * @param camera The camera to apply the render pass to.
  55688. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55689. * @param engine The engine which the post process will be applied. (default: current engine)
  55690. * @param reusable If the post process can be reused on the same frame. (default: false)
  55691. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55692. */
  55693. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55694. }
  55695. }
  55696. declare module BABYLON {
  55697. /** @hidden */
  55698. export var mrtFragmentDeclaration: {
  55699. name: string;
  55700. shader: string;
  55701. };
  55702. }
  55703. declare module BABYLON {
  55704. /** @hidden */
  55705. export var geometryPixelShader: {
  55706. name: string;
  55707. shader: string;
  55708. };
  55709. }
  55710. declare module BABYLON {
  55711. /** @hidden */
  55712. export var geometryVertexShader: {
  55713. name: string;
  55714. shader: string;
  55715. };
  55716. }
  55717. declare module BABYLON {
  55718. /** @hidden */
  55719. interface ISavedTransformationMatrix {
  55720. world: Matrix;
  55721. viewProjection: Matrix;
  55722. }
  55723. /**
  55724. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55725. */
  55726. export class GeometryBufferRenderer {
  55727. /**
  55728. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55729. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55730. */
  55731. static readonly POSITION_TEXTURE_TYPE: number;
  55732. /**
  55733. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55734. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55735. */
  55736. static readonly VELOCITY_TEXTURE_TYPE: number;
  55737. /**
  55738. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55739. * in order to compute objects velocities when enableVelocity is set to "true"
  55740. * @hidden
  55741. */
  55742. _previousTransformationMatrices: {
  55743. [index: number]: ISavedTransformationMatrix;
  55744. };
  55745. /**
  55746. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  55747. * in order to compute objects velocities when enableVelocity is set to "true"
  55748. * @hidden
  55749. */
  55750. _previousBonesTransformationMatrices: {
  55751. [index: number]: Float32Array;
  55752. };
  55753. /**
  55754. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  55755. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  55756. */
  55757. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  55758. private _scene;
  55759. private _multiRenderTarget;
  55760. private _ratio;
  55761. private _enablePosition;
  55762. private _enableVelocity;
  55763. private _positionIndex;
  55764. private _velocityIndex;
  55765. protected _effect: Effect;
  55766. protected _cachedDefines: string;
  55767. /**
  55768. * Set the render list (meshes to be rendered) used in the G buffer.
  55769. */
  55770. renderList: Mesh[];
  55771. /**
  55772. * Gets wether or not G buffer are supported by the running hardware.
  55773. * This requires draw buffer supports
  55774. */
  55775. readonly isSupported: boolean;
  55776. /**
  55777. * Returns the index of the given texture type in the G-Buffer textures array
  55778. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55779. * @returns the index of the given texture type in the G-Buffer textures array
  55780. */
  55781. getTextureIndex(textureType: number): number;
  55782. /**
  55783. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55784. */
  55785. /**
  55786. * Sets whether or not objects positions are enabled for the G buffer.
  55787. */
  55788. enablePosition: boolean;
  55789. /**
  55790. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55791. */
  55792. /**
  55793. * Sets wether or not objects velocities are enabled for the G buffer.
  55794. */
  55795. enableVelocity: boolean;
  55796. /**
  55797. * Gets the scene associated with the buffer.
  55798. */
  55799. readonly scene: Scene;
  55800. /**
  55801. * Gets the ratio used by the buffer during its creation.
  55802. * How big is the buffer related to the main canvas.
  55803. */
  55804. readonly ratio: number;
  55805. /** @hidden */
  55806. static _SceneComponentInitialization: (scene: Scene) => void;
  55807. /**
  55808. * Creates a new G Buffer for the scene
  55809. * @param scene The scene the buffer belongs to
  55810. * @param ratio How big is the buffer related to the main canvas.
  55811. */
  55812. constructor(scene: Scene, ratio?: number);
  55813. /**
  55814. * Checks wether everything is ready to render a submesh to the G buffer.
  55815. * @param subMesh the submesh to check readiness for
  55816. * @param useInstances is the mesh drawn using instance or not
  55817. * @returns true if ready otherwise false
  55818. */
  55819. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55820. /**
  55821. * Gets the current underlying G Buffer.
  55822. * @returns the buffer
  55823. */
  55824. getGBuffer(): MultiRenderTarget;
  55825. /**
  55826. * Gets the number of samples used to render the buffer (anti aliasing).
  55827. */
  55828. /**
  55829. * Sets the number of samples used to render the buffer (anti aliasing).
  55830. */
  55831. samples: number;
  55832. /**
  55833. * Disposes the renderer and frees up associated resources.
  55834. */
  55835. dispose(): void;
  55836. protected _createRenderTargets(): void;
  55837. private _copyBonesTransformationMatrices;
  55838. }
  55839. }
  55840. declare module BABYLON {
  55841. interface Scene {
  55842. /** @hidden (Backing field) */
  55843. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55844. /**
  55845. * Gets or Sets the current geometry buffer associated to the scene.
  55846. */
  55847. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55848. /**
  55849. * Enables a GeometryBufferRender and associates it with the scene
  55850. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55851. * @returns the GeometryBufferRenderer
  55852. */
  55853. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55854. /**
  55855. * Disables the GeometryBufferRender associated with the scene
  55856. */
  55857. disableGeometryBufferRenderer(): void;
  55858. }
  55859. /**
  55860. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55861. * in several rendering techniques.
  55862. */
  55863. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55864. /**
  55865. * The component name helpful to identify the component in the list of scene components.
  55866. */
  55867. readonly name: string;
  55868. /**
  55869. * The scene the component belongs to.
  55870. */
  55871. scene: Scene;
  55872. /**
  55873. * Creates a new instance of the component for the given scene
  55874. * @param scene Defines the scene to register the component in
  55875. */
  55876. constructor(scene: Scene);
  55877. /**
  55878. * Registers the component in a given scene
  55879. */
  55880. register(): void;
  55881. /**
  55882. * Rebuilds the elements related to this component in case of
  55883. * context lost for instance.
  55884. */
  55885. rebuild(): void;
  55886. /**
  55887. * Disposes the component and the associated ressources
  55888. */
  55889. dispose(): void;
  55890. private _gatherRenderTargets;
  55891. }
  55892. }
  55893. declare module BABYLON {
  55894. /** @hidden */
  55895. export var motionBlurPixelShader: {
  55896. name: string;
  55897. shader: string;
  55898. };
  55899. }
  55900. declare module BABYLON {
  55901. /**
  55902. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55903. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55904. * As an example, all you have to do is to create the post-process:
  55905. * var mb = new BABYLON.MotionBlurPostProcess(
  55906. * 'mb', // The name of the effect.
  55907. * scene, // The scene containing the objects to blur according to their velocity.
  55908. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55909. * camera // The camera to apply the render pass to.
  55910. * );
  55911. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55912. */
  55913. export class MotionBlurPostProcess extends PostProcess {
  55914. /**
  55915. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55916. */
  55917. motionStrength: number;
  55918. /**
  55919. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55920. */
  55921. /**
  55922. * Sets the number of iterations to be used for motion blur quality
  55923. */
  55924. motionBlurSamples: number;
  55925. private _motionBlurSamples;
  55926. private _geometryBufferRenderer;
  55927. /**
  55928. * Creates a new instance MotionBlurPostProcess
  55929. * @param name The name of the effect.
  55930. * @param scene The scene containing the objects to blur according to their velocity.
  55931. * @param options The required width/height ratio to downsize to before computing the render pass.
  55932. * @param camera The camera to apply the render pass to.
  55933. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55934. * @param engine The engine which the post process will be applied. (default: current engine)
  55935. * @param reusable If the post process can be reused on the same frame. (default: false)
  55936. * @param textureType Type of textures used when performing the post process. (default: 0)
  55937. * @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)
  55938. */
  55939. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55940. /**
  55941. * Excludes the given skinned mesh from computing bones velocities.
  55942. * 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.
  55943. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  55944. */
  55945. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55946. /**
  55947. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  55948. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  55949. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  55950. */
  55951. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55952. /**
  55953. * Disposes the post process.
  55954. * @param camera The camera to dispose the post process on.
  55955. */
  55956. dispose(camera?: Camera): void;
  55957. }
  55958. }
  55959. declare module BABYLON {
  55960. /** @hidden */
  55961. export var refractionPixelShader: {
  55962. name: string;
  55963. shader: string;
  55964. };
  55965. }
  55966. declare module BABYLON {
  55967. /**
  55968. * Post process which applies a refractin texture
  55969. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55970. */
  55971. export class RefractionPostProcess extends PostProcess {
  55972. /** the base color of the refraction (used to taint the rendering) */
  55973. color: Color3;
  55974. /** simulated refraction depth */
  55975. depth: number;
  55976. /** the coefficient of the base color (0 to remove base color tainting) */
  55977. colorLevel: number;
  55978. private _refTexture;
  55979. private _ownRefractionTexture;
  55980. /**
  55981. * Gets or sets the refraction texture
  55982. * Please note that you are responsible for disposing the texture if you set it manually
  55983. */
  55984. refractionTexture: Texture;
  55985. /**
  55986. * Initializes the RefractionPostProcess
  55987. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55988. * @param name The name of the effect.
  55989. * @param refractionTextureUrl Url of the refraction texture to use
  55990. * @param color the base color of the refraction (used to taint the rendering)
  55991. * @param depth simulated refraction depth
  55992. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55993. * @param camera The camera to apply the render pass to.
  55994. * @param options The required width/height ratio to downsize to before computing the render pass.
  55995. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55996. * @param engine The engine which the post process will be applied. (default: current engine)
  55997. * @param reusable If the post process can be reused on the same frame. (default: false)
  55998. */
  55999. constructor(name: string, refractionTextureUrl: string,
  56000. /** the base color of the refraction (used to taint the rendering) */
  56001. color: Color3,
  56002. /** simulated refraction depth */
  56003. depth: number,
  56004. /** the coefficient of the base color (0 to remove base color tainting) */
  56005. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56006. /**
  56007. * Disposes of the post process
  56008. * @param camera Camera to dispose post process on
  56009. */
  56010. dispose(camera: Camera): void;
  56011. }
  56012. }
  56013. declare module BABYLON {
  56014. /** @hidden */
  56015. export var sharpenPixelShader: {
  56016. name: string;
  56017. shader: string;
  56018. };
  56019. }
  56020. declare module BABYLON {
  56021. /**
  56022. * The SharpenPostProcess applies a sharpen kernel to every pixel
  56023. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  56024. */
  56025. export class SharpenPostProcess extends PostProcess {
  56026. /**
  56027. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  56028. */
  56029. colorAmount: number;
  56030. /**
  56031. * How much sharpness should be applied (default: 0.3)
  56032. */
  56033. edgeAmount: number;
  56034. /**
  56035. * Creates a new instance ConvolutionPostProcess
  56036. * @param name The name of the effect.
  56037. * @param options The required width/height ratio to downsize to before computing the render pass.
  56038. * @param camera The camera to apply the render pass to.
  56039. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56040. * @param engine The engine which the post process will be applied. (default: current engine)
  56041. * @param reusable If the post process can be reused on the same frame. (default: false)
  56042. * @param textureType Type of textures used when performing the post process. (default: 0)
  56043. * @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)
  56044. */
  56045. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56046. }
  56047. }
  56048. declare module BABYLON {
  56049. /**
  56050. * PostProcessRenderPipeline
  56051. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56052. */
  56053. export class PostProcessRenderPipeline {
  56054. private engine;
  56055. private _renderEffects;
  56056. private _renderEffectsForIsolatedPass;
  56057. /**
  56058. * List of inspectable custom properties (used by the Inspector)
  56059. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  56060. */
  56061. inspectableCustomProperties: IInspectable[];
  56062. /**
  56063. * @hidden
  56064. */
  56065. protected _cameras: Camera[];
  56066. /** @hidden */
  56067. _name: string;
  56068. /**
  56069. * Gets pipeline name
  56070. */
  56071. readonly name: string;
  56072. /**
  56073. * Initializes a PostProcessRenderPipeline
  56074. * @param engine engine to add the pipeline to
  56075. * @param name name of the pipeline
  56076. */
  56077. constructor(engine: Engine, name: string);
  56078. /**
  56079. * Gets the class name
  56080. * @returns "PostProcessRenderPipeline"
  56081. */
  56082. getClassName(): string;
  56083. /**
  56084. * If all the render effects in the pipeline are supported
  56085. */
  56086. readonly isSupported: boolean;
  56087. /**
  56088. * Adds an effect to the pipeline
  56089. * @param renderEffect the effect to add
  56090. */
  56091. addEffect(renderEffect: PostProcessRenderEffect): void;
  56092. /** @hidden */
  56093. _rebuild(): void;
  56094. /** @hidden */
  56095. _enableEffect(renderEffectName: string, cameras: Camera): void;
  56096. /** @hidden */
  56097. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  56098. /** @hidden */
  56099. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56100. /** @hidden */
  56101. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56102. /** @hidden */
  56103. _attachCameras(cameras: Camera, unique: boolean): void;
  56104. /** @hidden */
  56105. _attachCameras(cameras: Camera[], unique: boolean): void;
  56106. /** @hidden */
  56107. _detachCameras(cameras: Camera): void;
  56108. /** @hidden */
  56109. _detachCameras(cameras: Nullable<Camera[]>): void;
  56110. /** @hidden */
  56111. _update(): void;
  56112. /** @hidden */
  56113. _reset(): void;
  56114. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  56115. /**
  56116. * Disposes of the pipeline
  56117. */
  56118. dispose(): void;
  56119. }
  56120. }
  56121. declare module BABYLON {
  56122. /**
  56123. * PostProcessRenderPipelineManager class
  56124. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56125. */
  56126. export class PostProcessRenderPipelineManager {
  56127. private _renderPipelines;
  56128. /**
  56129. * Initializes a PostProcessRenderPipelineManager
  56130. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56131. */
  56132. constructor();
  56133. /**
  56134. * Gets the list of supported render pipelines
  56135. */
  56136. readonly supportedPipelines: PostProcessRenderPipeline[];
  56137. /**
  56138. * Adds a pipeline to the manager
  56139. * @param renderPipeline The pipeline to add
  56140. */
  56141. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  56142. /**
  56143. * Attaches a camera to the pipeline
  56144. * @param renderPipelineName The name of the pipeline to attach to
  56145. * @param cameras the camera to attach
  56146. * @param unique if the camera can be attached multiple times to the pipeline
  56147. */
  56148. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  56149. /**
  56150. * Detaches a camera from the pipeline
  56151. * @param renderPipelineName The name of the pipeline to detach from
  56152. * @param cameras the camera to detach
  56153. */
  56154. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  56155. /**
  56156. * Enables an effect by name on a pipeline
  56157. * @param renderPipelineName the name of the pipeline to enable the effect in
  56158. * @param renderEffectName the name of the effect to enable
  56159. * @param cameras the cameras that the effect should be enabled on
  56160. */
  56161. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56162. /**
  56163. * Disables an effect by name on a pipeline
  56164. * @param renderPipelineName the name of the pipeline to disable the effect in
  56165. * @param renderEffectName the name of the effect to disable
  56166. * @param cameras the cameras that the effect should be disabled on
  56167. */
  56168. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56169. /**
  56170. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  56171. */
  56172. update(): void;
  56173. /** @hidden */
  56174. _rebuild(): void;
  56175. /**
  56176. * Disposes of the manager and pipelines
  56177. */
  56178. dispose(): void;
  56179. }
  56180. }
  56181. declare module BABYLON {
  56182. interface Scene {
  56183. /** @hidden (Backing field) */
  56184. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56185. /**
  56186. * Gets the postprocess render pipeline manager
  56187. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56188. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56189. */
  56190. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56191. }
  56192. /**
  56193. * Defines the Render Pipeline scene component responsible to rendering pipelines
  56194. */
  56195. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  56196. /**
  56197. * The component name helpfull to identify the component in the list of scene components.
  56198. */
  56199. readonly name: string;
  56200. /**
  56201. * The scene the component belongs to.
  56202. */
  56203. scene: Scene;
  56204. /**
  56205. * Creates a new instance of the component for the given scene
  56206. * @param scene Defines the scene to register the component in
  56207. */
  56208. constructor(scene: Scene);
  56209. /**
  56210. * Registers the component in a given scene
  56211. */
  56212. register(): void;
  56213. /**
  56214. * Rebuilds the elements related to this component in case of
  56215. * context lost for instance.
  56216. */
  56217. rebuild(): void;
  56218. /**
  56219. * Disposes the component and the associated ressources
  56220. */
  56221. dispose(): void;
  56222. private _gatherRenderTargets;
  56223. }
  56224. }
  56225. declare module BABYLON {
  56226. /**
  56227. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56228. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56229. */
  56230. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56231. private _scene;
  56232. private _camerasToBeAttached;
  56233. /**
  56234. * ID of the sharpen post process,
  56235. */
  56236. private readonly SharpenPostProcessId;
  56237. /**
  56238. * @ignore
  56239. * ID of the image processing post process;
  56240. */
  56241. readonly ImageProcessingPostProcessId: string;
  56242. /**
  56243. * @ignore
  56244. * ID of the Fast Approximate Anti-Aliasing post process;
  56245. */
  56246. readonly FxaaPostProcessId: string;
  56247. /**
  56248. * ID of the chromatic aberration post process,
  56249. */
  56250. private readonly ChromaticAberrationPostProcessId;
  56251. /**
  56252. * ID of the grain post process
  56253. */
  56254. private readonly GrainPostProcessId;
  56255. /**
  56256. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56257. */
  56258. sharpen: SharpenPostProcess;
  56259. private _sharpenEffect;
  56260. private bloom;
  56261. /**
  56262. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56263. */
  56264. depthOfField: DepthOfFieldEffect;
  56265. /**
  56266. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56267. */
  56268. fxaa: FxaaPostProcess;
  56269. /**
  56270. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56271. */
  56272. imageProcessing: ImageProcessingPostProcess;
  56273. /**
  56274. * Chromatic aberration post process which will shift rgb colors in the image
  56275. */
  56276. chromaticAberration: ChromaticAberrationPostProcess;
  56277. private _chromaticAberrationEffect;
  56278. /**
  56279. * Grain post process which add noise to the image
  56280. */
  56281. grain: GrainPostProcess;
  56282. private _grainEffect;
  56283. /**
  56284. * Glow post process which adds a glow to emissive areas of the image
  56285. */
  56286. private _glowLayer;
  56287. /**
  56288. * Animations which can be used to tweak settings over a period of time
  56289. */
  56290. animations: Animation[];
  56291. private _imageProcessingConfigurationObserver;
  56292. private _sharpenEnabled;
  56293. private _bloomEnabled;
  56294. private _depthOfFieldEnabled;
  56295. private _depthOfFieldBlurLevel;
  56296. private _fxaaEnabled;
  56297. private _imageProcessingEnabled;
  56298. private _defaultPipelineTextureType;
  56299. private _bloomScale;
  56300. private _chromaticAberrationEnabled;
  56301. private _grainEnabled;
  56302. private _buildAllowed;
  56303. /**
  56304. * Gets active scene
  56305. */
  56306. readonly scene: Scene;
  56307. /**
  56308. * Enable or disable the sharpen process from the pipeline
  56309. */
  56310. sharpenEnabled: boolean;
  56311. private _resizeObserver;
  56312. private _hardwareScaleLevel;
  56313. private _bloomKernel;
  56314. /**
  56315. * Specifies the size of the bloom blur kernel, relative to the final output size
  56316. */
  56317. bloomKernel: number;
  56318. /**
  56319. * Specifies the weight of the bloom in the final rendering
  56320. */
  56321. private _bloomWeight;
  56322. /**
  56323. * Specifies the luma threshold for the area that will be blurred by the bloom
  56324. */
  56325. private _bloomThreshold;
  56326. private _hdr;
  56327. /**
  56328. * The strength of the bloom.
  56329. */
  56330. bloomWeight: number;
  56331. /**
  56332. * The strength of the bloom.
  56333. */
  56334. bloomThreshold: number;
  56335. /**
  56336. * The scale of the bloom, lower value will provide better performance.
  56337. */
  56338. bloomScale: number;
  56339. /**
  56340. * Enable or disable the bloom from the pipeline
  56341. */
  56342. bloomEnabled: boolean;
  56343. private _rebuildBloom;
  56344. /**
  56345. * If the depth of field is enabled.
  56346. */
  56347. depthOfFieldEnabled: boolean;
  56348. /**
  56349. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56350. */
  56351. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56352. /**
  56353. * If the anti aliasing is enabled.
  56354. */
  56355. fxaaEnabled: boolean;
  56356. private _samples;
  56357. /**
  56358. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56359. */
  56360. samples: number;
  56361. /**
  56362. * If image processing is enabled.
  56363. */
  56364. imageProcessingEnabled: boolean;
  56365. /**
  56366. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56367. */
  56368. glowLayerEnabled: boolean;
  56369. /**
  56370. * Gets the glow layer (or null if not defined)
  56371. */
  56372. readonly glowLayer: Nullable<GlowLayer>;
  56373. /**
  56374. * Enable or disable the chromaticAberration process from the pipeline
  56375. */
  56376. chromaticAberrationEnabled: boolean;
  56377. /**
  56378. * Enable or disable the grain process from the pipeline
  56379. */
  56380. grainEnabled: boolean;
  56381. /**
  56382. * @constructor
  56383. * @param name - The rendering pipeline name (default: "")
  56384. * @param hdr - If high dynamic range textures should be used (default: true)
  56385. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56386. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56387. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56388. */
  56389. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56390. /**
  56391. * Get the class name
  56392. * @returns "DefaultRenderingPipeline"
  56393. */
  56394. getClassName(): string;
  56395. /**
  56396. * Force the compilation of the entire pipeline.
  56397. */
  56398. prepare(): void;
  56399. private _hasCleared;
  56400. private _prevPostProcess;
  56401. private _prevPrevPostProcess;
  56402. private _setAutoClearAndTextureSharing;
  56403. private _depthOfFieldSceneObserver;
  56404. private _buildPipeline;
  56405. private _disposePostProcesses;
  56406. /**
  56407. * Adds a camera to the pipeline
  56408. * @param camera the camera to be added
  56409. */
  56410. addCamera(camera: Camera): void;
  56411. /**
  56412. * Removes a camera from the pipeline
  56413. * @param camera the camera to remove
  56414. */
  56415. removeCamera(camera: Camera): void;
  56416. /**
  56417. * Dispose of the pipeline and stop all post processes
  56418. */
  56419. dispose(): void;
  56420. /**
  56421. * Serialize the rendering pipeline (Used when exporting)
  56422. * @returns the serialized object
  56423. */
  56424. serialize(): any;
  56425. /**
  56426. * Parse the serialized pipeline
  56427. * @param source Source pipeline.
  56428. * @param scene The scene to load the pipeline to.
  56429. * @param rootUrl The URL of the serialized pipeline.
  56430. * @returns An instantiated pipeline from the serialized object.
  56431. */
  56432. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56433. }
  56434. }
  56435. declare module BABYLON {
  56436. /** @hidden */
  56437. export var lensHighlightsPixelShader: {
  56438. name: string;
  56439. shader: string;
  56440. };
  56441. }
  56442. declare module BABYLON {
  56443. /** @hidden */
  56444. export var depthOfFieldPixelShader: {
  56445. name: string;
  56446. shader: string;
  56447. };
  56448. }
  56449. declare module BABYLON {
  56450. /**
  56451. * BABYLON.JS Chromatic Aberration GLSL Shader
  56452. * Author: Olivier Guyot
  56453. * Separates very slightly R, G and B colors on the edges of the screen
  56454. * Inspired by Francois Tarlier & Martins Upitis
  56455. */
  56456. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56457. /**
  56458. * @ignore
  56459. * The chromatic aberration PostProcess id in the pipeline
  56460. */
  56461. LensChromaticAberrationEffect: string;
  56462. /**
  56463. * @ignore
  56464. * The highlights enhancing PostProcess id in the pipeline
  56465. */
  56466. HighlightsEnhancingEffect: string;
  56467. /**
  56468. * @ignore
  56469. * The depth-of-field PostProcess id in the pipeline
  56470. */
  56471. LensDepthOfFieldEffect: string;
  56472. private _scene;
  56473. private _depthTexture;
  56474. private _grainTexture;
  56475. private _chromaticAberrationPostProcess;
  56476. private _highlightsPostProcess;
  56477. private _depthOfFieldPostProcess;
  56478. private _edgeBlur;
  56479. private _grainAmount;
  56480. private _chromaticAberration;
  56481. private _distortion;
  56482. private _highlightsGain;
  56483. private _highlightsThreshold;
  56484. private _dofDistance;
  56485. private _dofAperture;
  56486. private _dofDarken;
  56487. private _dofPentagon;
  56488. private _blurNoise;
  56489. /**
  56490. * @constructor
  56491. *
  56492. * Effect parameters are as follow:
  56493. * {
  56494. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56495. * edge_blur: number; // from 0 to x (1 for realism)
  56496. * distortion: number; // from 0 to x (1 for realism)
  56497. * grain_amount: number; // from 0 to 1
  56498. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56499. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56500. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56501. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56502. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56503. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56504. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56505. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56506. * }
  56507. * Note: if an effect parameter is unset, effect is disabled
  56508. *
  56509. * @param name The rendering pipeline name
  56510. * @param parameters - An object containing all parameters (see above)
  56511. * @param scene The scene linked to this pipeline
  56512. * @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)
  56513. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56514. */
  56515. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56516. /**
  56517. * Get the class name
  56518. * @returns "LensRenderingPipeline"
  56519. */
  56520. getClassName(): string;
  56521. /**
  56522. * Gets associated scene
  56523. */
  56524. readonly scene: Scene;
  56525. /**
  56526. * Gets or sets the edge blur
  56527. */
  56528. edgeBlur: number;
  56529. /**
  56530. * Gets or sets the grain amount
  56531. */
  56532. grainAmount: number;
  56533. /**
  56534. * Gets or sets the chromatic aberration amount
  56535. */
  56536. chromaticAberration: number;
  56537. /**
  56538. * Gets or sets the depth of field aperture
  56539. */
  56540. dofAperture: number;
  56541. /**
  56542. * Gets or sets the edge distortion
  56543. */
  56544. edgeDistortion: number;
  56545. /**
  56546. * Gets or sets the depth of field distortion
  56547. */
  56548. dofDistortion: number;
  56549. /**
  56550. * Gets or sets the darken out of focus amount
  56551. */
  56552. darkenOutOfFocus: number;
  56553. /**
  56554. * Gets or sets a boolean indicating if blur noise is enabled
  56555. */
  56556. blurNoise: boolean;
  56557. /**
  56558. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56559. */
  56560. pentagonBokeh: boolean;
  56561. /**
  56562. * Gets or sets the highlight grain amount
  56563. */
  56564. highlightsGain: number;
  56565. /**
  56566. * Gets or sets the highlight threshold
  56567. */
  56568. highlightsThreshold: number;
  56569. /**
  56570. * Sets the amount of blur at the edges
  56571. * @param amount blur amount
  56572. */
  56573. setEdgeBlur(amount: number): void;
  56574. /**
  56575. * Sets edge blur to 0
  56576. */
  56577. disableEdgeBlur(): void;
  56578. /**
  56579. * Sets the amout of grain
  56580. * @param amount Amount of grain
  56581. */
  56582. setGrainAmount(amount: number): void;
  56583. /**
  56584. * Set grain amount to 0
  56585. */
  56586. disableGrain(): void;
  56587. /**
  56588. * Sets the chromatic aberration amount
  56589. * @param amount amount of chromatic aberration
  56590. */
  56591. setChromaticAberration(amount: number): void;
  56592. /**
  56593. * Sets chromatic aberration amount to 0
  56594. */
  56595. disableChromaticAberration(): void;
  56596. /**
  56597. * Sets the EdgeDistortion amount
  56598. * @param amount amount of EdgeDistortion
  56599. */
  56600. setEdgeDistortion(amount: number): void;
  56601. /**
  56602. * Sets edge distortion to 0
  56603. */
  56604. disableEdgeDistortion(): void;
  56605. /**
  56606. * Sets the FocusDistance amount
  56607. * @param amount amount of FocusDistance
  56608. */
  56609. setFocusDistance(amount: number): void;
  56610. /**
  56611. * Disables depth of field
  56612. */
  56613. disableDepthOfField(): void;
  56614. /**
  56615. * Sets the Aperture amount
  56616. * @param amount amount of Aperture
  56617. */
  56618. setAperture(amount: number): void;
  56619. /**
  56620. * Sets the DarkenOutOfFocus amount
  56621. * @param amount amount of DarkenOutOfFocus
  56622. */
  56623. setDarkenOutOfFocus(amount: number): void;
  56624. private _pentagonBokehIsEnabled;
  56625. /**
  56626. * Creates a pentagon bokeh effect
  56627. */
  56628. enablePentagonBokeh(): void;
  56629. /**
  56630. * Disables the pentagon bokeh effect
  56631. */
  56632. disablePentagonBokeh(): void;
  56633. /**
  56634. * Enables noise blur
  56635. */
  56636. enableNoiseBlur(): void;
  56637. /**
  56638. * Disables noise blur
  56639. */
  56640. disableNoiseBlur(): void;
  56641. /**
  56642. * Sets the HighlightsGain amount
  56643. * @param amount amount of HighlightsGain
  56644. */
  56645. setHighlightsGain(amount: number): void;
  56646. /**
  56647. * Sets the HighlightsThreshold amount
  56648. * @param amount amount of HighlightsThreshold
  56649. */
  56650. setHighlightsThreshold(amount: number): void;
  56651. /**
  56652. * Disables highlights
  56653. */
  56654. disableHighlights(): void;
  56655. /**
  56656. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56657. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56658. */
  56659. dispose(disableDepthRender?: boolean): void;
  56660. private _createChromaticAberrationPostProcess;
  56661. private _createHighlightsPostProcess;
  56662. private _createDepthOfFieldPostProcess;
  56663. private _createGrainTexture;
  56664. }
  56665. }
  56666. declare module BABYLON {
  56667. /** @hidden */
  56668. export var ssao2PixelShader: {
  56669. name: string;
  56670. shader: string;
  56671. };
  56672. }
  56673. declare module BABYLON {
  56674. /** @hidden */
  56675. export var ssaoCombinePixelShader: {
  56676. name: string;
  56677. shader: string;
  56678. };
  56679. }
  56680. declare module BABYLON {
  56681. /**
  56682. * Render pipeline to produce ssao effect
  56683. */
  56684. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56685. /**
  56686. * @ignore
  56687. * The PassPostProcess id in the pipeline that contains the original scene color
  56688. */
  56689. SSAOOriginalSceneColorEffect: string;
  56690. /**
  56691. * @ignore
  56692. * The SSAO PostProcess id in the pipeline
  56693. */
  56694. SSAORenderEffect: string;
  56695. /**
  56696. * @ignore
  56697. * The horizontal blur PostProcess id in the pipeline
  56698. */
  56699. SSAOBlurHRenderEffect: string;
  56700. /**
  56701. * @ignore
  56702. * The vertical blur PostProcess id in the pipeline
  56703. */
  56704. SSAOBlurVRenderEffect: string;
  56705. /**
  56706. * @ignore
  56707. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56708. */
  56709. SSAOCombineRenderEffect: string;
  56710. /**
  56711. * The output strength of the SSAO post-process. Default value is 1.0.
  56712. */
  56713. totalStrength: number;
  56714. /**
  56715. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56716. */
  56717. maxZ: number;
  56718. /**
  56719. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56720. */
  56721. minZAspect: number;
  56722. private _samples;
  56723. /**
  56724. * Number of samples used for the SSAO calculations. Default value is 8
  56725. */
  56726. samples: number;
  56727. private _textureSamples;
  56728. /**
  56729. * Number of samples to use for antialiasing
  56730. */
  56731. textureSamples: number;
  56732. /**
  56733. * Ratio object used for SSAO ratio and blur ratio
  56734. */
  56735. private _ratio;
  56736. /**
  56737. * Dynamically generated sphere sampler.
  56738. */
  56739. private _sampleSphere;
  56740. /**
  56741. * Blur filter offsets
  56742. */
  56743. private _samplerOffsets;
  56744. private _expensiveBlur;
  56745. /**
  56746. * If bilateral blur should be used
  56747. */
  56748. expensiveBlur: boolean;
  56749. /**
  56750. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56751. */
  56752. radius: number;
  56753. /**
  56754. * The base color of the SSAO post-process
  56755. * The final result is "base + ssao" between [0, 1]
  56756. */
  56757. base: number;
  56758. /**
  56759. * Support test.
  56760. */
  56761. static readonly IsSupported: boolean;
  56762. private _scene;
  56763. private _depthTexture;
  56764. private _normalTexture;
  56765. private _randomTexture;
  56766. private _originalColorPostProcess;
  56767. private _ssaoPostProcess;
  56768. private _blurHPostProcess;
  56769. private _blurVPostProcess;
  56770. private _ssaoCombinePostProcess;
  56771. private _firstUpdate;
  56772. /**
  56773. * Gets active scene
  56774. */
  56775. readonly scene: Scene;
  56776. /**
  56777. * @constructor
  56778. * @param name The rendering pipeline name
  56779. * @param scene The scene linked to this pipeline
  56780. * @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 }
  56781. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56782. */
  56783. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56784. /**
  56785. * Get the class name
  56786. * @returns "SSAO2RenderingPipeline"
  56787. */
  56788. getClassName(): string;
  56789. /**
  56790. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56791. */
  56792. dispose(disableGeometryBufferRenderer?: boolean): void;
  56793. private _createBlurPostProcess;
  56794. /** @hidden */
  56795. _rebuild(): void;
  56796. private _bits;
  56797. private _radicalInverse_VdC;
  56798. private _hammersley;
  56799. private _hemisphereSample_uniform;
  56800. private _generateHemisphere;
  56801. private _createSSAOPostProcess;
  56802. private _createSSAOCombinePostProcess;
  56803. private _createRandomTexture;
  56804. /**
  56805. * Serialize the rendering pipeline (Used when exporting)
  56806. * @returns the serialized object
  56807. */
  56808. serialize(): any;
  56809. /**
  56810. * Parse the serialized pipeline
  56811. * @param source Source pipeline.
  56812. * @param scene The scene to load the pipeline to.
  56813. * @param rootUrl The URL of the serialized pipeline.
  56814. * @returns An instantiated pipeline from the serialized object.
  56815. */
  56816. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56817. }
  56818. }
  56819. declare module BABYLON {
  56820. /** @hidden */
  56821. export var ssaoPixelShader: {
  56822. name: string;
  56823. shader: string;
  56824. };
  56825. }
  56826. declare module BABYLON {
  56827. /**
  56828. * Render pipeline to produce ssao effect
  56829. */
  56830. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56831. /**
  56832. * @ignore
  56833. * The PassPostProcess id in the pipeline that contains the original scene color
  56834. */
  56835. SSAOOriginalSceneColorEffect: string;
  56836. /**
  56837. * @ignore
  56838. * The SSAO PostProcess id in the pipeline
  56839. */
  56840. SSAORenderEffect: string;
  56841. /**
  56842. * @ignore
  56843. * The horizontal blur PostProcess id in the pipeline
  56844. */
  56845. SSAOBlurHRenderEffect: string;
  56846. /**
  56847. * @ignore
  56848. * The vertical blur PostProcess id in the pipeline
  56849. */
  56850. SSAOBlurVRenderEffect: string;
  56851. /**
  56852. * @ignore
  56853. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56854. */
  56855. SSAOCombineRenderEffect: string;
  56856. /**
  56857. * The output strength of the SSAO post-process. Default value is 1.0.
  56858. */
  56859. totalStrength: number;
  56860. /**
  56861. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56862. */
  56863. radius: number;
  56864. /**
  56865. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56866. * Must not be equal to fallOff and superior to fallOff.
  56867. * Default value is 0.0075
  56868. */
  56869. area: number;
  56870. /**
  56871. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56872. * Must not be equal to area and inferior to area.
  56873. * Default value is 0.000001
  56874. */
  56875. fallOff: number;
  56876. /**
  56877. * The base color of the SSAO post-process
  56878. * The final result is "base + ssao" between [0, 1]
  56879. */
  56880. base: number;
  56881. private _scene;
  56882. private _depthTexture;
  56883. private _randomTexture;
  56884. private _originalColorPostProcess;
  56885. private _ssaoPostProcess;
  56886. private _blurHPostProcess;
  56887. private _blurVPostProcess;
  56888. private _ssaoCombinePostProcess;
  56889. private _firstUpdate;
  56890. /**
  56891. * Gets active scene
  56892. */
  56893. readonly scene: Scene;
  56894. /**
  56895. * @constructor
  56896. * @param name - The rendering pipeline name
  56897. * @param scene - The scene linked to this pipeline
  56898. * @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 }
  56899. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56900. */
  56901. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56902. /**
  56903. * Get the class name
  56904. * @returns "SSAORenderingPipeline"
  56905. */
  56906. getClassName(): string;
  56907. /**
  56908. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56909. */
  56910. dispose(disableDepthRender?: boolean): void;
  56911. private _createBlurPostProcess;
  56912. /** @hidden */
  56913. _rebuild(): void;
  56914. private _createSSAOPostProcess;
  56915. private _createSSAOCombinePostProcess;
  56916. private _createRandomTexture;
  56917. }
  56918. }
  56919. declare module BABYLON {
  56920. /** @hidden */
  56921. export var standardPixelShader: {
  56922. name: string;
  56923. shader: string;
  56924. };
  56925. }
  56926. declare module BABYLON {
  56927. /**
  56928. * Standard rendering pipeline
  56929. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56930. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56931. */
  56932. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56933. /**
  56934. * Public members
  56935. */
  56936. /**
  56937. * Post-process which contains the original scene color before the pipeline applies all the effects
  56938. */
  56939. originalPostProcess: Nullable<PostProcess>;
  56940. /**
  56941. * Post-process used to down scale an image x4
  56942. */
  56943. downSampleX4PostProcess: Nullable<PostProcess>;
  56944. /**
  56945. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56946. */
  56947. brightPassPostProcess: Nullable<PostProcess>;
  56948. /**
  56949. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56950. */
  56951. blurHPostProcesses: PostProcess[];
  56952. /**
  56953. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56954. */
  56955. blurVPostProcesses: PostProcess[];
  56956. /**
  56957. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56958. */
  56959. textureAdderPostProcess: Nullable<PostProcess>;
  56960. /**
  56961. * Post-process used to create volumetric lighting effect
  56962. */
  56963. volumetricLightPostProcess: Nullable<PostProcess>;
  56964. /**
  56965. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56966. */
  56967. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56968. /**
  56969. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56970. */
  56971. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56972. /**
  56973. * Post-process used to merge the volumetric light effect and the real scene color
  56974. */
  56975. volumetricLightMergePostProces: Nullable<PostProcess>;
  56976. /**
  56977. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56978. */
  56979. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56980. /**
  56981. * Base post-process used to calculate the average luminance of the final image for HDR
  56982. */
  56983. luminancePostProcess: Nullable<PostProcess>;
  56984. /**
  56985. * Post-processes used to create down sample post-processes in order to get
  56986. * the average luminance of the final image for HDR
  56987. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56988. */
  56989. luminanceDownSamplePostProcesses: PostProcess[];
  56990. /**
  56991. * Post-process used to create a HDR effect (light adaptation)
  56992. */
  56993. hdrPostProcess: Nullable<PostProcess>;
  56994. /**
  56995. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56996. */
  56997. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56998. /**
  56999. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  57000. */
  57001. lensFlareFinalPostProcess: Nullable<PostProcess>;
  57002. /**
  57003. * Post-process used to merge the final HDR post-process and the real scene color
  57004. */
  57005. hdrFinalPostProcess: Nullable<PostProcess>;
  57006. /**
  57007. * Post-process used to create a lens flare effect
  57008. */
  57009. lensFlarePostProcess: Nullable<PostProcess>;
  57010. /**
  57011. * Post-process that merges the result of the lens flare post-process and the real scene color
  57012. */
  57013. lensFlareComposePostProcess: Nullable<PostProcess>;
  57014. /**
  57015. * Post-process used to create a motion blur effect
  57016. */
  57017. motionBlurPostProcess: Nullable<PostProcess>;
  57018. /**
  57019. * Post-process used to create a depth of field effect
  57020. */
  57021. depthOfFieldPostProcess: Nullable<PostProcess>;
  57022. /**
  57023. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  57024. */
  57025. fxaaPostProcess: Nullable<FxaaPostProcess>;
  57026. /**
  57027. * Represents the brightness threshold in order to configure the illuminated surfaces
  57028. */
  57029. brightThreshold: number;
  57030. /**
  57031. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  57032. */
  57033. blurWidth: number;
  57034. /**
  57035. * Sets if the blur for highlighted surfaces must be only horizontal
  57036. */
  57037. horizontalBlur: boolean;
  57038. /**
  57039. * Gets the overall exposure used by the pipeline
  57040. */
  57041. /**
  57042. * Sets the overall exposure used by the pipeline
  57043. */
  57044. exposure: number;
  57045. /**
  57046. * Texture used typically to simulate "dirty" on camera lens
  57047. */
  57048. lensTexture: Nullable<Texture>;
  57049. /**
  57050. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  57051. */
  57052. volumetricLightCoefficient: number;
  57053. /**
  57054. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  57055. */
  57056. volumetricLightPower: number;
  57057. /**
  57058. * Used the set the blur intensity to smooth the volumetric lights
  57059. */
  57060. volumetricLightBlurScale: number;
  57061. /**
  57062. * Light (spot or directional) used to generate the volumetric lights rays
  57063. * The source light must have a shadow generate so the pipeline can get its
  57064. * depth map
  57065. */
  57066. sourceLight: Nullable<SpotLight | DirectionalLight>;
  57067. /**
  57068. * For eye adaptation, represents the minimum luminance the eye can see
  57069. */
  57070. hdrMinimumLuminance: number;
  57071. /**
  57072. * For eye adaptation, represents the decrease luminance speed
  57073. */
  57074. hdrDecreaseRate: number;
  57075. /**
  57076. * For eye adaptation, represents the increase luminance speed
  57077. */
  57078. hdrIncreaseRate: number;
  57079. /**
  57080. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57081. */
  57082. /**
  57083. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57084. */
  57085. hdrAutoExposure: boolean;
  57086. /**
  57087. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  57088. */
  57089. lensColorTexture: Nullable<Texture>;
  57090. /**
  57091. * The overall strengh for the lens flare effect
  57092. */
  57093. lensFlareStrength: number;
  57094. /**
  57095. * Dispersion coefficient for lens flare ghosts
  57096. */
  57097. lensFlareGhostDispersal: number;
  57098. /**
  57099. * Main lens flare halo width
  57100. */
  57101. lensFlareHaloWidth: number;
  57102. /**
  57103. * Based on the lens distortion effect, defines how much the lens flare result
  57104. * is distorted
  57105. */
  57106. lensFlareDistortionStrength: number;
  57107. /**
  57108. * Lens star texture must be used to simulate rays on the flares and is available
  57109. * in the documentation
  57110. */
  57111. lensStarTexture: Nullable<Texture>;
  57112. /**
  57113. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  57114. * flare effect by taking account of the dirt texture
  57115. */
  57116. lensFlareDirtTexture: Nullable<Texture>;
  57117. /**
  57118. * Represents the focal length for the depth of field effect
  57119. */
  57120. depthOfFieldDistance: number;
  57121. /**
  57122. * Represents the blur intensity for the blurred part of the depth of field effect
  57123. */
  57124. depthOfFieldBlurWidth: number;
  57125. /**
  57126. * Gets how much the image is blurred by the movement while using the motion blur post-process
  57127. */
  57128. /**
  57129. * Sets how much the image is blurred by the movement while using the motion blur post-process
  57130. */
  57131. motionStrength: number;
  57132. /**
  57133. * Gets wether or not the motion blur post-process is object based or screen based.
  57134. */
  57135. /**
  57136. * Sets wether or not the motion blur post-process should be object based or screen based
  57137. */
  57138. objectBasedMotionBlur: boolean;
  57139. /**
  57140. * List of animations for the pipeline (IAnimatable implementation)
  57141. */
  57142. animations: Animation[];
  57143. /**
  57144. * Private members
  57145. */
  57146. private _scene;
  57147. private _currentDepthOfFieldSource;
  57148. private _basePostProcess;
  57149. private _fixedExposure;
  57150. private _currentExposure;
  57151. private _hdrAutoExposure;
  57152. private _hdrCurrentLuminance;
  57153. private _motionStrength;
  57154. private _isObjectBasedMotionBlur;
  57155. private _floatTextureType;
  57156. private _ratio;
  57157. private _bloomEnabled;
  57158. private _depthOfFieldEnabled;
  57159. private _vlsEnabled;
  57160. private _lensFlareEnabled;
  57161. private _hdrEnabled;
  57162. private _motionBlurEnabled;
  57163. private _fxaaEnabled;
  57164. private _motionBlurSamples;
  57165. private _volumetricLightStepsCount;
  57166. private _samples;
  57167. /**
  57168. * @ignore
  57169. * Specifies if the bloom pipeline is enabled
  57170. */
  57171. BloomEnabled: boolean;
  57172. /**
  57173. * @ignore
  57174. * Specifies if the depth of field pipeline is enabed
  57175. */
  57176. DepthOfFieldEnabled: boolean;
  57177. /**
  57178. * @ignore
  57179. * Specifies if the lens flare pipeline is enabed
  57180. */
  57181. LensFlareEnabled: boolean;
  57182. /**
  57183. * @ignore
  57184. * Specifies if the HDR pipeline is enabled
  57185. */
  57186. HDREnabled: boolean;
  57187. /**
  57188. * @ignore
  57189. * Specifies if the volumetric lights scattering effect is enabled
  57190. */
  57191. VLSEnabled: boolean;
  57192. /**
  57193. * @ignore
  57194. * Specifies if the motion blur effect is enabled
  57195. */
  57196. MotionBlurEnabled: boolean;
  57197. /**
  57198. * Specifies if anti-aliasing is enabled
  57199. */
  57200. fxaaEnabled: boolean;
  57201. /**
  57202. * Specifies the number of steps used to calculate the volumetric lights
  57203. * Typically in interval [50, 200]
  57204. */
  57205. volumetricLightStepsCount: number;
  57206. /**
  57207. * Specifies the number of samples used for the motion blur effect
  57208. * Typically in interval [16, 64]
  57209. */
  57210. motionBlurSamples: number;
  57211. /**
  57212. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57213. */
  57214. samples: number;
  57215. /**
  57216. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57217. * @constructor
  57218. * @param name The rendering pipeline name
  57219. * @param scene The scene linked to this pipeline
  57220. * @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)
  57221. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57222. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57223. */
  57224. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57225. private _buildPipeline;
  57226. private _createDownSampleX4PostProcess;
  57227. private _createBrightPassPostProcess;
  57228. private _createBlurPostProcesses;
  57229. private _createTextureAdderPostProcess;
  57230. private _createVolumetricLightPostProcess;
  57231. private _createLuminancePostProcesses;
  57232. private _createHdrPostProcess;
  57233. private _createLensFlarePostProcess;
  57234. private _createDepthOfFieldPostProcess;
  57235. private _createMotionBlurPostProcess;
  57236. private _getDepthTexture;
  57237. private _disposePostProcesses;
  57238. /**
  57239. * Dispose of the pipeline and stop all post processes
  57240. */
  57241. dispose(): void;
  57242. /**
  57243. * Serialize the rendering pipeline (Used when exporting)
  57244. * @returns the serialized object
  57245. */
  57246. serialize(): any;
  57247. /**
  57248. * Parse the serialized pipeline
  57249. * @param source Source pipeline.
  57250. * @param scene The scene to load the pipeline to.
  57251. * @param rootUrl The URL of the serialized pipeline.
  57252. * @returns An instantiated pipeline from the serialized object.
  57253. */
  57254. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57255. /**
  57256. * Luminance steps
  57257. */
  57258. static LuminanceSteps: number;
  57259. }
  57260. }
  57261. declare module BABYLON {
  57262. /** @hidden */
  57263. export var tonemapPixelShader: {
  57264. name: string;
  57265. shader: string;
  57266. };
  57267. }
  57268. declare module BABYLON {
  57269. /** Defines operator used for tonemapping */
  57270. export enum TonemappingOperator {
  57271. /** Hable */
  57272. Hable = 0,
  57273. /** Reinhard */
  57274. Reinhard = 1,
  57275. /** HejiDawson */
  57276. HejiDawson = 2,
  57277. /** Photographic */
  57278. Photographic = 3
  57279. }
  57280. /**
  57281. * Defines a post process to apply tone mapping
  57282. */
  57283. export class TonemapPostProcess extends PostProcess {
  57284. private _operator;
  57285. /** Defines the required exposure adjustement */
  57286. exposureAdjustment: number;
  57287. /**
  57288. * Creates a new TonemapPostProcess
  57289. * @param name defines the name of the postprocess
  57290. * @param _operator defines the operator to use
  57291. * @param exposureAdjustment defines the required exposure adjustement
  57292. * @param camera defines the camera to use (can be null)
  57293. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57294. * @param engine defines the hosting engine (can be ignore if camera is set)
  57295. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57296. */
  57297. constructor(name: string, _operator: TonemappingOperator,
  57298. /** Defines the required exposure adjustement */
  57299. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57300. }
  57301. }
  57302. declare module BABYLON {
  57303. /** @hidden */
  57304. export var depthVertexShader: {
  57305. name: string;
  57306. shader: string;
  57307. };
  57308. }
  57309. declare module BABYLON {
  57310. /** @hidden */
  57311. export var volumetricLightScatteringPixelShader: {
  57312. name: string;
  57313. shader: string;
  57314. };
  57315. }
  57316. declare module BABYLON {
  57317. /** @hidden */
  57318. export var volumetricLightScatteringPassPixelShader: {
  57319. name: string;
  57320. shader: string;
  57321. };
  57322. }
  57323. declare module BABYLON {
  57324. /**
  57325. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57326. */
  57327. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57328. private _volumetricLightScatteringPass;
  57329. private _volumetricLightScatteringRTT;
  57330. private _viewPort;
  57331. private _screenCoordinates;
  57332. private _cachedDefines;
  57333. /**
  57334. * If not undefined, the mesh position is computed from the attached node position
  57335. */
  57336. attachedNode: {
  57337. position: Vector3;
  57338. };
  57339. /**
  57340. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57341. */
  57342. customMeshPosition: Vector3;
  57343. /**
  57344. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57345. */
  57346. useCustomMeshPosition: boolean;
  57347. /**
  57348. * If the post-process should inverse the light scattering direction
  57349. */
  57350. invert: boolean;
  57351. /**
  57352. * The internal mesh used by the post-process
  57353. */
  57354. mesh: Mesh;
  57355. /**
  57356. * @hidden
  57357. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57358. */
  57359. useDiffuseColor: boolean;
  57360. /**
  57361. * Array containing the excluded meshes not rendered in the internal pass
  57362. */
  57363. excludedMeshes: AbstractMesh[];
  57364. /**
  57365. * Controls the overall intensity of the post-process
  57366. */
  57367. exposure: number;
  57368. /**
  57369. * Dissipates each sample's contribution in range [0, 1]
  57370. */
  57371. decay: number;
  57372. /**
  57373. * Controls the overall intensity of each sample
  57374. */
  57375. weight: number;
  57376. /**
  57377. * Controls the density of each sample
  57378. */
  57379. density: number;
  57380. /**
  57381. * @constructor
  57382. * @param name The post-process name
  57383. * @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)
  57384. * @param camera The camera that the post-process will be attached to
  57385. * @param mesh The mesh used to create the light scattering
  57386. * @param samples The post-process quality, default 100
  57387. * @param samplingModeThe post-process filtering mode
  57388. * @param engine The babylon engine
  57389. * @param reusable If the post-process is reusable
  57390. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57391. */
  57392. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57393. /**
  57394. * Returns the string "VolumetricLightScatteringPostProcess"
  57395. * @returns "VolumetricLightScatteringPostProcess"
  57396. */
  57397. getClassName(): string;
  57398. private _isReady;
  57399. /**
  57400. * Sets the new light position for light scattering effect
  57401. * @param position The new custom light position
  57402. */
  57403. setCustomMeshPosition(position: Vector3): void;
  57404. /**
  57405. * Returns the light position for light scattering effect
  57406. * @return Vector3 The custom light position
  57407. */
  57408. getCustomMeshPosition(): Vector3;
  57409. /**
  57410. * Disposes the internal assets and detaches the post-process from the camera
  57411. */
  57412. dispose(camera: Camera): void;
  57413. /**
  57414. * Returns the render target texture used by the post-process
  57415. * @return the render target texture used by the post-process
  57416. */
  57417. getPass(): RenderTargetTexture;
  57418. private _meshExcluded;
  57419. private _createPass;
  57420. private _updateMeshScreenCoordinates;
  57421. /**
  57422. * Creates a default mesh for the Volumeric Light Scattering post-process
  57423. * @param name The mesh name
  57424. * @param scene The scene where to create the mesh
  57425. * @return the default mesh
  57426. */
  57427. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57428. }
  57429. }
  57430. declare module BABYLON {
  57431. interface Scene {
  57432. /** @hidden (Backing field) */
  57433. _boundingBoxRenderer: BoundingBoxRenderer;
  57434. /** @hidden (Backing field) */
  57435. _forceShowBoundingBoxes: boolean;
  57436. /**
  57437. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57438. */
  57439. forceShowBoundingBoxes: boolean;
  57440. /**
  57441. * Gets the bounding box renderer associated with the scene
  57442. * @returns a BoundingBoxRenderer
  57443. */
  57444. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57445. }
  57446. interface AbstractMesh {
  57447. /** @hidden (Backing field) */
  57448. _showBoundingBox: boolean;
  57449. /**
  57450. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57451. */
  57452. showBoundingBox: boolean;
  57453. }
  57454. /**
  57455. * Component responsible of rendering the bounding box of the meshes in a scene.
  57456. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57457. */
  57458. export class BoundingBoxRenderer implements ISceneComponent {
  57459. /**
  57460. * The component name helpfull to identify the component in the list of scene components.
  57461. */
  57462. readonly name: string;
  57463. /**
  57464. * The scene the component belongs to.
  57465. */
  57466. scene: Scene;
  57467. /**
  57468. * Color of the bounding box lines placed in front of an object
  57469. */
  57470. frontColor: Color3;
  57471. /**
  57472. * Color of the bounding box lines placed behind an object
  57473. */
  57474. backColor: Color3;
  57475. /**
  57476. * Defines if the renderer should show the back lines or not
  57477. */
  57478. showBackLines: boolean;
  57479. /**
  57480. * @hidden
  57481. */
  57482. renderList: SmartArray<BoundingBox>;
  57483. private _colorShader;
  57484. private _vertexBuffers;
  57485. private _indexBuffer;
  57486. private _fillIndexBuffer;
  57487. private _fillIndexData;
  57488. /**
  57489. * Instantiates a new bounding box renderer in a scene.
  57490. * @param scene the scene the renderer renders in
  57491. */
  57492. constructor(scene: Scene);
  57493. /**
  57494. * Registers the component in a given scene
  57495. */
  57496. register(): void;
  57497. private _evaluateSubMesh;
  57498. private _activeMesh;
  57499. private _prepareRessources;
  57500. private _createIndexBuffer;
  57501. /**
  57502. * Rebuilds the elements related to this component in case of
  57503. * context lost for instance.
  57504. */
  57505. rebuild(): void;
  57506. /**
  57507. * @hidden
  57508. */
  57509. reset(): void;
  57510. /**
  57511. * Render the bounding boxes of a specific rendering group
  57512. * @param renderingGroupId defines the rendering group to render
  57513. */
  57514. render(renderingGroupId: number): void;
  57515. /**
  57516. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57517. * @param mesh Define the mesh to render the occlusion bounding box for
  57518. */
  57519. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57520. /**
  57521. * Dispose and release the resources attached to this renderer.
  57522. */
  57523. dispose(): void;
  57524. }
  57525. }
  57526. declare module BABYLON {
  57527. /** @hidden */
  57528. export var depthPixelShader: {
  57529. name: string;
  57530. shader: string;
  57531. };
  57532. }
  57533. declare module BABYLON {
  57534. /**
  57535. * This represents a depth renderer in Babylon.
  57536. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57537. */
  57538. export class DepthRenderer {
  57539. private _scene;
  57540. private _depthMap;
  57541. private _effect;
  57542. private _cachedDefines;
  57543. private _camera;
  57544. /**
  57545. * Specifiess that the depth renderer will only be used within
  57546. * the camera it is created for.
  57547. * This can help forcing its rendering during the camera processing.
  57548. */
  57549. useOnlyInActiveCamera: boolean;
  57550. /** @hidden */
  57551. static _SceneComponentInitialization: (scene: Scene) => void;
  57552. /**
  57553. * Instantiates a depth renderer
  57554. * @param scene The scene the renderer belongs to
  57555. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57556. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57557. */
  57558. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57559. /**
  57560. * Creates the depth rendering effect and checks if the effect is ready.
  57561. * @param subMesh The submesh to be used to render the depth map of
  57562. * @param useInstances If multiple world instances should be used
  57563. * @returns if the depth renderer is ready to render the depth map
  57564. */
  57565. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57566. /**
  57567. * Gets the texture which the depth map will be written to.
  57568. * @returns The depth map texture
  57569. */
  57570. getDepthMap(): RenderTargetTexture;
  57571. /**
  57572. * Disposes of the depth renderer.
  57573. */
  57574. dispose(): void;
  57575. }
  57576. }
  57577. declare module BABYLON {
  57578. interface Scene {
  57579. /** @hidden (Backing field) */
  57580. _depthRenderer: {
  57581. [id: string]: DepthRenderer;
  57582. };
  57583. /**
  57584. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57585. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57586. * @returns the created depth renderer
  57587. */
  57588. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57589. /**
  57590. * Disables a depth renderer for a given camera
  57591. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57592. */
  57593. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57594. }
  57595. /**
  57596. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57597. * in several rendering techniques.
  57598. */
  57599. export class DepthRendererSceneComponent implements ISceneComponent {
  57600. /**
  57601. * The component name helpfull to identify the component in the list of scene components.
  57602. */
  57603. readonly name: string;
  57604. /**
  57605. * The scene the component belongs to.
  57606. */
  57607. scene: Scene;
  57608. /**
  57609. * Creates a new instance of the component for the given scene
  57610. * @param scene Defines the scene to register the component in
  57611. */
  57612. constructor(scene: Scene);
  57613. /**
  57614. * Registers the component in a given scene
  57615. */
  57616. register(): void;
  57617. /**
  57618. * Rebuilds the elements related to this component in case of
  57619. * context lost for instance.
  57620. */
  57621. rebuild(): void;
  57622. /**
  57623. * Disposes the component and the associated ressources
  57624. */
  57625. dispose(): void;
  57626. private _gatherRenderTargets;
  57627. private _gatherActiveCameraRenderTargets;
  57628. }
  57629. }
  57630. declare module BABYLON {
  57631. /** @hidden */
  57632. export var outlinePixelShader: {
  57633. name: string;
  57634. shader: string;
  57635. };
  57636. }
  57637. declare module BABYLON {
  57638. /** @hidden */
  57639. export var outlineVertexShader: {
  57640. name: string;
  57641. shader: string;
  57642. };
  57643. }
  57644. declare module BABYLON {
  57645. interface Scene {
  57646. /** @hidden */
  57647. _outlineRenderer: OutlineRenderer;
  57648. /**
  57649. * Gets the outline renderer associated with the scene
  57650. * @returns a OutlineRenderer
  57651. */
  57652. getOutlineRenderer(): OutlineRenderer;
  57653. }
  57654. interface AbstractMesh {
  57655. /** @hidden (Backing field) */
  57656. _renderOutline: boolean;
  57657. /**
  57658. * Gets or sets a boolean indicating if the outline must be rendered as well
  57659. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57660. */
  57661. renderOutline: boolean;
  57662. /** @hidden (Backing field) */
  57663. _renderOverlay: boolean;
  57664. /**
  57665. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57666. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57667. */
  57668. renderOverlay: boolean;
  57669. }
  57670. /**
  57671. * This class is responsible to draw bothe outline/overlay of meshes.
  57672. * It should not be used directly but through the available method on mesh.
  57673. */
  57674. export class OutlineRenderer implements ISceneComponent {
  57675. /**
  57676. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57677. */
  57678. private static _StencilReference;
  57679. /**
  57680. * The name of the component. Each component must have a unique name.
  57681. */
  57682. name: string;
  57683. /**
  57684. * The scene the component belongs to.
  57685. */
  57686. scene: Scene;
  57687. /**
  57688. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57689. */
  57690. zOffset: number;
  57691. private _engine;
  57692. private _effect;
  57693. private _cachedDefines;
  57694. private _savedDepthWrite;
  57695. /**
  57696. * Instantiates a new outline renderer. (There could be only one per scene).
  57697. * @param scene Defines the scene it belongs to
  57698. */
  57699. constructor(scene: Scene);
  57700. /**
  57701. * Register the component to one instance of a scene.
  57702. */
  57703. register(): void;
  57704. /**
  57705. * Rebuilds the elements related to this component in case of
  57706. * context lost for instance.
  57707. */
  57708. rebuild(): void;
  57709. /**
  57710. * Disposes the component and the associated ressources.
  57711. */
  57712. dispose(): void;
  57713. /**
  57714. * Renders the outline in the canvas.
  57715. * @param subMesh Defines the sumesh to render
  57716. * @param batch Defines the batch of meshes in case of instances
  57717. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57718. */
  57719. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57720. /**
  57721. * Returns whether or not the outline renderer is ready for a given submesh.
  57722. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57723. * @param subMesh Defines the submesh to check readyness for
  57724. * @param useInstances Defines wheter wee are trying to render instances or not
  57725. * @returns true if ready otherwise false
  57726. */
  57727. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57728. private _beforeRenderingMesh;
  57729. private _afterRenderingMesh;
  57730. }
  57731. }
  57732. declare module BABYLON {
  57733. /**
  57734. * Defines the list of states available for a task inside a AssetsManager
  57735. */
  57736. export enum AssetTaskState {
  57737. /**
  57738. * Initialization
  57739. */
  57740. INIT = 0,
  57741. /**
  57742. * Running
  57743. */
  57744. RUNNING = 1,
  57745. /**
  57746. * Done
  57747. */
  57748. DONE = 2,
  57749. /**
  57750. * Error
  57751. */
  57752. ERROR = 3
  57753. }
  57754. /**
  57755. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57756. */
  57757. export abstract class AbstractAssetTask {
  57758. /**
  57759. * Task name
  57760. */ name: string;
  57761. /**
  57762. * Callback called when the task is successful
  57763. */
  57764. onSuccess: (task: any) => void;
  57765. /**
  57766. * Callback called when the task is not successful
  57767. */
  57768. onError: (task: any, message?: string, exception?: any) => void;
  57769. /**
  57770. * Creates a new AssetsManager
  57771. * @param name defines the name of the task
  57772. */
  57773. constructor(
  57774. /**
  57775. * Task name
  57776. */ name: string);
  57777. private _isCompleted;
  57778. private _taskState;
  57779. private _errorObject;
  57780. /**
  57781. * Get if the task is completed
  57782. */
  57783. readonly isCompleted: boolean;
  57784. /**
  57785. * Gets the current state of the task
  57786. */
  57787. readonly taskState: AssetTaskState;
  57788. /**
  57789. * Gets the current error object (if task is in error)
  57790. */
  57791. readonly errorObject: {
  57792. message?: string;
  57793. exception?: any;
  57794. };
  57795. /**
  57796. * Internal only
  57797. * @hidden
  57798. */
  57799. _setErrorObject(message?: string, exception?: any): void;
  57800. /**
  57801. * Execute the current task
  57802. * @param scene defines the scene where you want your assets to be loaded
  57803. * @param onSuccess is a callback called when the task is successfully executed
  57804. * @param onError is a callback called if an error occurs
  57805. */
  57806. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57807. /**
  57808. * Execute the current task
  57809. * @param scene defines the scene where you want your assets to be loaded
  57810. * @param onSuccess is a callback called when the task is successfully executed
  57811. * @param onError is a callback called if an error occurs
  57812. */
  57813. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57814. /**
  57815. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57816. * This can be used with failed tasks that have the reason for failure fixed.
  57817. */
  57818. reset(): void;
  57819. private onErrorCallback;
  57820. private onDoneCallback;
  57821. }
  57822. /**
  57823. * Define the interface used by progress events raised during assets loading
  57824. */
  57825. export interface IAssetsProgressEvent {
  57826. /**
  57827. * Defines the number of remaining tasks to process
  57828. */
  57829. remainingCount: number;
  57830. /**
  57831. * Defines the total number of tasks
  57832. */
  57833. totalCount: number;
  57834. /**
  57835. * Defines the task that was just processed
  57836. */
  57837. task: AbstractAssetTask;
  57838. }
  57839. /**
  57840. * Class used to share progress information about assets loading
  57841. */
  57842. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57843. /**
  57844. * Defines the number of remaining tasks to process
  57845. */
  57846. remainingCount: number;
  57847. /**
  57848. * Defines the total number of tasks
  57849. */
  57850. totalCount: number;
  57851. /**
  57852. * Defines the task that was just processed
  57853. */
  57854. task: AbstractAssetTask;
  57855. /**
  57856. * Creates a AssetsProgressEvent
  57857. * @param remainingCount defines the number of remaining tasks to process
  57858. * @param totalCount defines the total number of tasks
  57859. * @param task defines the task that was just processed
  57860. */
  57861. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57862. }
  57863. /**
  57864. * Define a task used by AssetsManager to load meshes
  57865. */
  57866. export class MeshAssetTask extends AbstractAssetTask {
  57867. /**
  57868. * Defines the name of the task
  57869. */
  57870. name: string;
  57871. /**
  57872. * Defines the list of mesh's names you want to load
  57873. */
  57874. meshesNames: any;
  57875. /**
  57876. * Defines the root url to use as a base to load your meshes and associated resources
  57877. */
  57878. rootUrl: string;
  57879. /**
  57880. * Defines the filename of the scene to load from
  57881. */
  57882. sceneFilename: string;
  57883. /**
  57884. * Gets the list of loaded meshes
  57885. */
  57886. loadedMeshes: Array<AbstractMesh>;
  57887. /**
  57888. * Gets the list of loaded particle systems
  57889. */
  57890. loadedParticleSystems: Array<IParticleSystem>;
  57891. /**
  57892. * Gets the list of loaded skeletons
  57893. */
  57894. loadedSkeletons: Array<Skeleton>;
  57895. /**
  57896. * Gets the list of loaded animation groups
  57897. */
  57898. loadedAnimationGroups: Array<AnimationGroup>;
  57899. /**
  57900. * Callback called when the task is successful
  57901. */
  57902. onSuccess: (task: MeshAssetTask) => void;
  57903. /**
  57904. * Callback called when the task is successful
  57905. */
  57906. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57907. /**
  57908. * Creates a new MeshAssetTask
  57909. * @param name defines the name of the task
  57910. * @param meshesNames defines the list of mesh's names you want to load
  57911. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57912. * @param sceneFilename defines the filename of the scene to load from
  57913. */
  57914. constructor(
  57915. /**
  57916. * Defines the name of the task
  57917. */
  57918. name: string,
  57919. /**
  57920. * Defines the list of mesh's names you want to load
  57921. */
  57922. meshesNames: any,
  57923. /**
  57924. * Defines the root url to use as a base to load your meshes and associated resources
  57925. */
  57926. rootUrl: string,
  57927. /**
  57928. * Defines the filename of the scene to load from
  57929. */
  57930. sceneFilename: string);
  57931. /**
  57932. * Execute the current task
  57933. * @param scene defines the scene where you want your assets to be loaded
  57934. * @param onSuccess is a callback called when the task is successfully executed
  57935. * @param onError is a callback called if an error occurs
  57936. */
  57937. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57938. }
  57939. /**
  57940. * Define a task used by AssetsManager to load text content
  57941. */
  57942. export class TextFileAssetTask extends AbstractAssetTask {
  57943. /**
  57944. * Defines the name of the task
  57945. */
  57946. name: string;
  57947. /**
  57948. * Defines the location of the file to load
  57949. */
  57950. url: string;
  57951. /**
  57952. * Gets the loaded text string
  57953. */
  57954. text: string;
  57955. /**
  57956. * Callback called when the task is successful
  57957. */
  57958. onSuccess: (task: TextFileAssetTask) => void;
  57959. /**
  57960. * Callback called when the task is successful
  57961. */
  57962. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57963. /**
  57964. * Creates a new TextFileAssetTask object
  57965. * @param name defines the name of the task
  57966. * @param url defines the location of the file to load
  57967. */
  57968. constructor(
  57969. /**
  57970. * Defines the name of the task
  57971. */
  57972. name: string,
  57973. /**
  57974. * Defines the location of the file to load
  57975. */
  57976. url: string);
  57977. /**
  57978. * Execute the current task
  57979. * @param scene defines the scene where you want your assets to be loaded
  57980. * @param onSuccess is a callback called when the task is successfully executed
  57981. * @param onError is a callback called if an error occurs
  57982. */
  57983. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57984. }
  57985. /**
  57986. * Define a task used by AssetsManager to load binary data
  57987. */
  57988. export class BinaryFileAssetTask extends AbstractAssetTask {
  57989. /**
  57990. * Defines the name of the task
  57991. */
  57992. name: string;
  57993. /**
  57994. * Defines the location of the file to load
  57995. */
  57996. url: string;
  57997. /**
  57998. * Gets the lodaded data (as an array buffer)
  57999. */
  58000. data: ArrayBuffer;
  58001. /**
  58002. * Callback called when the task is successful
  58003. */
  58004. onSuccess: (task: BinaryFileAssetTask) => void;
  58005. /**
  58006. * Callback called when the task is successful
  58007. */
  58008. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  58009. /**
  58010. * Creates a new BinaryFileAssetTask object
  58011. * @param name defines the name of the new task
  58012. * @param url defines the location of the file to load
  58013. */
  58014. constructor(
  58015. /**
  58016. * Defines the name of the task
  58017. */
  58018. name: string,
  58019. /**
  58020. * Defines the location of the file to load
  58021. */
  58022. url: string);
  58023. /**
  58024. * Execute the current task
  58025. * @param scene defines the scene where you want your assets to be loaded
  58026. * @param onSuccess is a callback called when the task is successfully executed
  58027. * @param onError is a callback called if an error occurs
  58028. */
  58029. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58030. }
  58031. /**
  58032. * Define a task used by AssetsManager to load images
  58033. */
  58034. export class ImageAssetTask extends AbstractAssetTask {
  58035. /**
  58036. * Defines the name of the task
  58037. */
  58038. name: string;
  58039. /**
  58040. * Defines the location of the image to load
  58041. */
  58042. url: string;
  58043. /**
  58044. * Gets the loaded images
  58045. */
  58046. image: HTMLImageElement;
  58047. /**
  58048. * Callback called when the task is successful
  58049. */
  58050. onSuccess: (task: ImageAssetTask) => void;
  58051. /**
  58052. * Callback called when the task is successful
  58053. */
  58054. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  58055. /**
  58056. * Creates a new ImageAssetTask
  58057. * @param name defines the name of the task
  58058. * @param url defines the location of the image to load
  58059. */
  58060. constructor(
  58061. /**
  58062. * Defines the name of the task
  58063. */
  58064. name: string,
  58065. /**
  58066. * Defines the location of the image to load
  58067. */
  58068. url: string);
  58069. /**
  58070. * Execute the current task
  58071. * @param scene defines the scene where you want your assets to be loaded
  58072. * @param onSuccess is a callback called when the task is successfully executed
  58073. * @param onError is a callback called if an error occurs
  58074. */
  58075. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58076. }
  58077. /**
  58078. * Defines the interface used by texture loading tasks
  58079. */
  58080. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58081. /**
  58082. * Gets the loaded texture
  58083. */
  58084. texture: TEX;
  58085. }
  58086. /**
  58087. * Define a task used by AssetsManager to load 2D textures
  58088. */
  58089. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58090. /**
  58091. * Defines the name of the task
  58092. */
  58093. name: string;
  58094. /**
  58095. * Defines the location of the file to load
  58096. */
  58097. url: string;
  58098. /**
  58099. * Defines if mipmap should not be generated (default is false)
  58100. */
  58101. noMipmap?: boolean | undefined;
  58102. /**
  58103. * Defines if texture must be inverted on Y axis (default is false)
  58104. */
  58105. invertY?: boolean | undefined;
  58106. /**
  58107. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58108. */
  58109. samplingMode: number;
  58110. /**
  58111. * Gets the loaded texture
  58112. */
  58113. texture: Texture;
  58114. /**
  58115. * Callback called when the task is successful
  58116. */
  58117. onSuccess: (task: TextureAssetTask) => void;
  58118. /**
  58119. * Callback called when the task is successful
  58120. */
  58121. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58122. /**
  58123. * Creates a new TextureAssetTask object
  58124. * @param name defines the name of the task
  58125. * @param url defines the location of the file to load
  58126. * @param noMipmap defines if mipmap should not be generated (default is false)
  58127. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58128. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58129. */
  58130. constructor(
  58131. /**
  58132. * Defines the name of the task
  58133. */
  58134. name: string,
  58135. /**
  58136. * Defines the location of the file to load
  58137. */
  58138. url: string,
  58139. /**
  58140. * Defines if mipmap should not be generated (default is false)
  58141. */
  58142. noMipmap?: boolean | undefined,
  58143. /**
  58144. * Defines if texture must be inverted on Y axis (default is false)
  58145. */
  58146. invertY?: boolean | undefined,
  58147. /**
  58148. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58149. */
  58150. samplingMode?: number);
  58151. /**
  58152. * Execute the current task
  58153. * @param scene defines the scene where you want your assets to be loaded
  58154. * @param onSuccess is a callback called when the task is successfully executed
  58155. * @param onError is a callback called if an error occurs
  58156. */
  58157. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58158. }
  58159. /**
  58160. * Define a task used by AssetsManager to load cube textures
  58161. */
  58162. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58163. /**
  58164. * Defines the name of the task
  58165. */
  58166. name: string;
  58167. /**
  58168. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58169. */
  58170. url: string;
  58171. /**
  58172. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58173. */
  58174. extensions?: string[] | undefined;
  58175. /**
  58176. * Defines if mipmaps should not be generated (default is false)
  58177. */
  58178. noMipmap?: boolean | undefined;
  58179. /**
  58180. * Defines the explicit list of files (undefined by default)
  58181. */
  58182. files?: string[] | undefined;
  58183. /**
  58184. * Gets the loaded texture
  58185. */
  58186. texture: CubeTexture;
  58187. /**
  58188. * Callback called when the task is successful
  58189. */
  58190. onSuccess: (task: CubeTextureAssetTask) => void;
  58191. /**
  58192. * Callback called when the task is successful
  58193. */
  58194. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58195. /**
  58196. * Creates a new CubeTextureAssetTask
  58197. * @param name defines the name of the task
  58198. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58199. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58200. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58201. * @param files defines the explicit list of files (undefined by default)
  58202. */
  58203. constructor(
  58204. /**
  58205. * Defines the name of the task
  58206. */
  58207. name: string,
  58208. /**
  58209. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58210. */
  58211. url: string,
  58212. /**
  58213. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58214. */
  58215. extensions?: string[] | undefined,
  58216. /**
  58217. * Defines if mipmaps should not be generated (default is false)
  58218. */
  58219. noMipmap?: boolean | undefined,
  58220. /**
  58221. * Defines the explicit list of files (undefined by default)
  58222. */
  58223. files?: string[] | undefined);
  58224. /**
  58225. * Execute the current task
  58226. * @param scene defines the scene where you want your assets to be loaded
  58227. * @param onSuccess is a callback called when the task is successfully executed
  58228. * @param onError is a callback called if an error occurs
  58229. */
  58230. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58231. }
  58232. /**
  58233. * Define a task used by AssetsManager to load HDR cube textures
  58234. */
  58235. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58236. /**
  58237. * Defines the name of the task
  58238. */
  58239. name: string;
  58240. /**
  58241. * Defines the location of the file to load
  58242. */
  58243. url: string;
  58244. /**
  58245. * Defines the desired size (the more it increases the longer the generation will be)
  58246. */
  58247. size: number;
  58248. /**
  58249. * Defines if mipmaps should not be generated (default is false)
  58250. */
  58251. noMipmap: boolean;
  58252. /**
  58253. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58254. */
  58255. generateHarmonics: boolean;
  58256. /**
  58257. * 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)
  58258. */
  58259. gammaSpace: boolean;
  58260. /**
  58261. * Internal Use Only
  58262. */
  58263. reserved: boolean;
  58264. /**
  58265. * Gets the loaded texture
  58266. */
  58267. texture: HDRCubeTexture;
  58268. /**
  58269. * Callback called when the task is successful
  58270. */
  58271. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58272. /**
  58273. * Callback called when the task is successful
  58274. */
  58275. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58276. /**
  58277. * Creates a new HDRCubeTextureAssetTask object
  58278. * @param name defines the name of the task
  58279. * @param url defines the location of the file to load
  58280. * @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.
  58281. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58282. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58283. * @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)
  58284. * @param reserved Internal use only
  58285. */
  58286. constructor(
  58287. /**
  58288. * Defines the name of the task
  58289. */
  58290. name: string,
  58291. /**
  58292. * Defines the location of the file to load
  58293. */
  58294. url: string,
  58295. /**
  58296. * Defines the desired size (the more it increases the longer the generation will be)
  58297. */
  58298. size: number,
  58299. /**
  58300. * Defines if mipmaps should not be generated (default is false)
  58301. */
  58302. noMipmap?: boolean,
  58303. /**
  58304. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58305. */
  58306. generateHarmonics?: boolean,
  58307. /**
  58308. * 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)
  58309. */
  58310. gammaSpace?: boolean,
  58311. /**
  58312. * Internal Use Only
  58313. */
  58314. reserved?: boolean);
  58315. /**
  58316. * Execute the current task
  58317. * @param scene defines the scene where you want your assets to be loaded
  58318. * @param onSuccess is a callback called when the task is successfully executed
  58319. * @param onError is a callback called if an error occurs
  58320. */
  58321. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58322. }
  58323. /**
  58324. * Define a task used by AssetsManager to load Equirectangular cube textures
  58325. */
  58326. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58327. /**
  58328. * Defines the name of the task
  58329. */
  58330. name: string;
  58331. /**
  58332. * Defines the location of the file to load
  58333. */
  58334. url: string;
  58335. /**
  58336. * Defines the desired size (the more it increases the longer the generation will be)
  58337. */
  58338. size: number;
  58339. /**
  58340. * Defines if mipmaps should not be generated (default is false)
  58341. */
  58342. noMipmap: boolean;
  58343. /**
  58344. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58345. * but the standard material would require them in Gamma space) (default is true)
  58346. */
  58347. gammaSpace: boolean;
  58348. /**
  58349. * Gets the loaded texture
  58350. */
  58351. texture: EquiRectangularCubeTexture;
  58352. /**
  58353. * Callback called when the task is successful
  58354. */
  58355. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58356. /**
  58357. * Callback called when the task is successful
  58358. */
  58359. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58360. /**
  58361. * Creates a new EquiRectangularCubeTextureAssetTask object
  58362. * @param name defines the name of the task
  58363. * @param url defines the location of the file to load
  58364. * @param size defines the desired size (the more it increases the longer the generation will be)
  58365. * If the size is omitted this implies you are using a preprocessed cubemap.
  58366. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58367. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58368. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58369. * (default is true)
  58370. */
  58371. constructor(
  58372. /**
  58373. * Defines the name of the task
  58374. */
  58375. name: string,
  58376. /**
  58377. * Defines the location of the file to load
  58378. */
  58379. url: string,
  58380. /**
  58381. * Defines the desired size (the more it increases the longer the generation will be)
  58382. */
  58383. size: number,
  58384. /**
  58385. * Defines if mipmaps should not be generated (default is false)
  58386. */
  58387. noMipmap?: boolean,
  58388. /**
  58389. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58390. * but the standard material would require them in Gamma space) (default is true)
  58391. */
  58392. gammaSpace?: boolean);
  58393. /**
  58394. * Execute the current task
  58395. * @param scene defines the scene where you want your assets to be loaded
  58396. * @param onSuccess is a callback called when the task is successfully executed
  58397. * @param onError is a callback called if an error occurs
  58398. */
  58399. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58400. }
  58401. /**
  58402. * This class can be used to easily import assets into a scene
  58403. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58404. */
  58405. export class AssetsManager {
  58406. private _scene;
  58407. private _isLoading;
  58408. protected _tasks: AbstractAssetTask[];
  58409. protected _waitingTasksCount: number;
  58410. protected _totalTasksCount: number;
  58411. /**
  58412. * Callback called when all tasks are processed
  58413. */
  58414. onFinish: (tasks: AbstractAssetTask[]) => void;
  58415. /**
  58416. * Callback called when a task is successful
  58417. */
  58418. onTaskSuccess: (task: AbstractAssetTask) => void;
  58419. /**
  58420. * Callback called when a task had an error
  58421. */
  58422. onTaskError: (task: AbstractAssetTask) => void;
  58423. /**
  58424. * Callback called when a task is done (whatever the result is)
  58425. */
  58426. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58427. /**
  58428. * Observable called when all tasks are processed
  58429. */
  58430. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58431. /**
  58432. * Observable called when a task had an error
  58433. */
  58434. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58435. /**
  58436. * Observable called when all tasks were executed
  58437. */
  58438. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58439. /**
  58440. * Observable called when a task is done (whatever the result is)
  58441. */
  58442. onProgressObservable: Observable<IAssetsProgressEvent>;
  58443. /**
  58444. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58445. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58446. */
  58447. useDefaultLoadingScreen: boolean;
  58448. /**
  58449. * Creates a new AssetsManager
  58450. * @param scene defines the scene to work on
  58451. */
  58452. constructor(scene: Scene);
  58453. /**
  58454. * Add a MeshAssetTask to the list of active tasks
  58455. * @param taskName defines the name of the new task
  58456. * @param meshesNames defines the name of meshes to load
  58457. * @param rootUrl defines the root url to use to locate files
  58458. * @param sceneFilename defines the filename of the scene file
  58459. * @returns a new MeshAssetTask object
  58460. */
  58461. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58462. /**
  58463. * Add a TextFileAssetTask to the list of active tasks
  58464. * @param taskName defines the name of the new task
  58465. * @param url defines the url of the file to load
  58466. * @returns a new TextFileAssetTask object
  58467. */
  58468. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58469. /**
  58470. * Add a BinaryFileAssetTask to the list of active tasks
  58471. * @param taskName defines the name of the new task
  58472. * @param url defines the url of the file to load
  58473. * @returns a new BinaryFileAssetTask object
  58474. */
  58475. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58476. /**
  58477. * Add a ImageAssetTask to the list of active tasks
  58478. * @param taskName defines the name of the new task
  58479. * @param url defines the url of the file to load
  58480. * @returns a new ImageAssetTask object
  58481. */
  58482. addImageTask(taskName: string, url: string): ImageAssetTask;
  58483. /**
  58484. * Add a TextureAssetTask to the list of active tasks
  58485. * @param taskName defines the name of the new task
  58486. * @param url defines the url of the file to load
  58487. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58488. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58489. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58490. * @returns a new TextureAssetTask object
  58491. */
  58492. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58493. /**
  58494. * Add a CubeTextureAssetTask to the list of active tasks
  58495. * @param taskName defines the name of the new task
  58496. * @param url defines the url of the file to load
  58497. * @param extensions defines the extension to use to load the cube map (can be null)
  58498. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58499. * @param files defines the list of files to load (can be null)
  58500. * @returns a new CubeTextureAssetTask object
  58501. */
  58502. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58503. /**
  58504. *
  58505. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58506. * @param taskName defines the name of the new task
  58507. * @param url defines the url of the file to load
  58508. * @param size defines the size you want for the cubemap (can be null)
  58509. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58510. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58511. * @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)
  58512. * @param reserved Internal use only
  58513. * @returns a new HDRCubeTextureAssetTask object
  58514. */
  58515. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58516. /**
  58517. *
  58518. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58519. * @param taskName defines the name of the new task
  58520. * @param url defines the url of the file to load
  58521. * @param size defines the size you want for the cubemap (can be null)
  58522. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58523. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58524. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58525. * @returns a new EquiRectangularCubeTextureAssetTask object
  58526. */
  58527. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58528. /**
  58529. * Remove a task from the assets manager.
  58530. * @param task the task to remove
  58531. */
  58532. removeTask(task: AbstractAssetTask): void;
  58533. private _decreaseWaitingTasksCount;
  58534. private _runTask;
  58535. /**
  58536. * Reset the AssetsManager and remove all tasks
  58537. * @return the current instance of the AssetsManager
  58538. */
  58539. reset(): AssetsManager;
  58540. /**
  58541. * Start the loading process
  58542. * @return the current instance of the AssetsManager
  58543. */
  58544. load(): AssetsManager;
  58545. /**
  58546. * Start the loading process as an async operation
  58547. * @return a promise returning the list of failed tasks
  58548. */
  58549. loadAsync(): Promise<void>;
  58550. }
  58551. }
  58552. declare module BABYLON {
  58553. /**
  58554. * Wrapper class for promise with external resolve and reject.
  58555. */
  58556. export class Deferred<T> {
  58557. /**
  58558. * The promise associated with this deferred object.
  58559. */
  58560. readonly promise: Promise<T>;
  58561. private _resolve;
  58562. private _reject;
  58563. /**
  58564. * The resolve method of the promise associated with this deferred object.
  58565. */
  58566. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58567. /**
  58568. * The reject method of the promise associated with this deferred object.
  58569. */
  58570. readonly reject: (reason?: any) => void;
  58571. /**
  58572. * Constructor for this deferred object.
  58573. */
  58574. constructor();
  58575. }
  58576. }
  58577. declare module BABYLON {
  58578. /**
  58579. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58580. */
  58581. export class MeshExploder {
  58582. private _centerMesh;
  58583. private _meshes;
  58584. private _meshesOrigins;
  58585. private _toCenterVectors;
  58586. private _scaledDirection;
  58587. private _newPosition;
  58588. private _centerPosition;
  58589. /**
  58590. * Explodes meshes from a center mesh.
  58591. * @param meshes The meshes to explode.
  58592. * @param centerMesh The mesh to be center of explosion.
  58593. */
  58594. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58595. private _setCenterMesh;
  58596. /**
  58597. * Get class name
  58598. * @returns "MeshExploder"
  58599. */
  58600. getClassName(): string;
  58601. /**
  58602. * "Exploded meshes"
  58603. * @returns Array of meshes with the centerMesh at index 0.
  58604. */
  58605. getMeshes(): Array<Mesh>;
  58606. /**
  58607. * Explodes meshes giving a specific direction
  58608. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58609. */
  58610. explode(direction?: number): void;
  58611. }
  58612. }
  58613. declare module BABYLON {
  58614. /**
  58615. * Class used to help managing file picking and drag'n'drop
  58616. */
  58617. export class FilesInput {
  58618. /**
  58619. * List of files ready to be loaded
  58620. */
  58621. static readonly FilesToLoad: {
  58622. [key: string]: File;
  58623. };
  58624. /**
  58625. * Callback called when a file is processed
  58626. */
  58627. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58628. private _engine;
  58629. private _currentScene;
  58630. private _sceneLoadedCallback;
  58631. private _progressCallback;
  58632. private _additionalRenderLoopLogicCallback;
  58633. private _textureLoadingCallback;
  58634. private _startingProcessingFilesCallback;
  58635. private _onReloadCallback;
  58636. private _errorCallback;
  58637. private _elementToMonitor;
  58638. private _sceneFileToLoad;
  58639. private _filesToLoad;
  58640. /**
  58641. * Creates a new FilesInput
  58642. * @param engine defines the rendering engine
  58643. * @param scene defines the hosting scene
  58644. * @param sceneLoadedCallback callback called when scene is loaded
  58645. * @param progressCallback callback called to track progress
  58646. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58647. * @param textureLoadingCallback callback called when a texture is loading
  58648. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58649. * @param onReloadCallback callback called when a reload is requested
  58650. * @param errorCallback callback call if an error occurs
  58651. */
  58652. 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);
  58653. private _dragEnterHandler;
  58654. private _dragOverHandler;
  58655. private _dropHandler;
  58656. /**
  58657. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58658. * @param elementToMonitor defines the DOM element to track
  58659. */
  58660. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58661. /**
  58662. * Release all associated resources
  58663. */
  58664. dispose(): void;
  58665. private renderFunction;
  58666. private drag;
  58667. private drop;
  58668. private _traverseFolder;
  58669. private _processFiles;
  58670. /**
  58671. * Load files from a drop event
  58672. * @param event defines the drop event to use as source
  58673. */
  58674. loadFiles(event: any): void;
  58675. private _processReload;
  58676. /**
  58677. * Reload the current scene from the loaded files
  58678. */
  58679. reload(): void;
  58680. }
  58681. }
  58682. declare module BABYLON {
  58683. /**
  58684. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58685. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58686. */
  58687. export class SceneOptimization {
  58688. /**
  58689. * Defines the priority of this optimization (0 by default which means first in the list)
  58690. */
  58691. priority: number;
  58692. /**
  58693. * Gets a string describing the action executed by the current optimization
  58694. * @returns description string
  58695. */
  58696. getDescription(): string;
  58697. /**
  58698. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58699. * @param scene defines the current scene where to apply this optimization
  58700. * @param optimizer defines the current optimizer
  58701. * @returns true if everything that can be done was applied
  58702. */
  58703. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58704. /**
  58705. * Creates the SceneOptimization object
  58706. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58707. * @param desc defines the description associated with the optimization
  58708. */
  58709. constructor(
  58710. /**
  58711. * Defines the priority of this optimization (0 by default which means first in the list)
  58712. */
  58713. priority?: number);
  58714. }
  58715. /**
  58716. * Defines an optimization used to reduce the size of render target textures
  58717. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58718. */
  58719. export class TextureOptimization extends SceneOptimization {
  58720. /**
  58721. * Defines the priority of this optimization (0 by default which means first in the list)
  58722. */
  58723. priority: number;
  58724. /**
  58725. * 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
  58726. */
  58727. maximumSize: number;
  58728. /**
  58729. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58730. */
  58731. step: number;
  58732. /**
  58733. * Gets a string describing the action executed by the current optimization
  58734. * @returns description string
  58735. */
  58736. getDescription(): string;
  58737. /**
  58738. * Creates the TextureOptimization object
  58739. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58740. * @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
  58741. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58742. */
  58743. constructor(
  58744. /**
  58745. * Defines the priority of this optimization (0 by default which means first in the list)
  58746. */
  58747. priority?: number,
  58748. /**
  58749. * 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
  58750. */
  58751. maximumSize?: number,
  58752. /**
  58753. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58754. */
  58755. step?: number);
  58756. /**
  58757. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58758. * @param scene defines the current scene where to apply this optimization
  58759. * @param optimizer defines the current optimizer
  58760. * @returns true if everything that can be done was applied
  58761. */
  58762. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58763. }
  58764. /**
  58765. * Defines an optimization used to increase or decrease the rendering resolution
  58766. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58767. */
  58768. export class HardwareScalingOptimization extends SceneOptimization {
  58769. /**
  58770. * Defines the priority of this optimization (0 by default which means first in the list)
  58771. */
  58772. priority: number;
  58773. /**
  58774. * Defines the maximum scale to use (2 by default)
  58775. */
  58776. maximumScale: number;
  58777. /**
  58778. * Defines the step to use between two passes (0.5 by default)
  58779. */
  58780. step: number;
  58781. private _currentScale;
  58782. private _directionOffset;
  58783. /**
  58784. * Gets a string describing the action executed by the current optimization
  58785. * @return description string
  58786. */
  58787. getDescription(): string;
  58788. /**
  58789. * Creates the HardwareScalingOptimization object
  58790. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58791. * @param maximumScale defines the maximum scale to use (2 by default)
  58792. * @param step defines the step to use between two passes (0.5 by default)
  58793. */
  58794. constructor(
  58795. /**
  58796. * Defines the priority of this optimization (0 by default which means first in the list)
  58797. */
  58798. priority?: number,
  58799. /**
  58800. * Defines the maximum scale to use (2 by default)
  58801. */
  58802. maximumScale?: number,
  58803. /**
  58804. * Defines the step to use between two passes (0.5 by default)
  58805. */
  58806. step?: number);
  58807. /**
  58808. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58809. * @param scene defines the current scene where to apply this optimization
  58810. * @param optimizer defines the current optimizer
  58811. * @returns true if everything that can be done was applied
  58812. */
  58813. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58814. }
  58815. /**
  58816. * Defines an optimization used to remove shadows
  58817. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58818. */
  58819. export class ShadowsOptimization extends SceneOptimization {
  58820. /**
  58821. * Gets a string describing the action executed by the current optimization
  58822. * @return description string
  58823. */
  58824. getDescription(): string;
  58825. /**
  58826. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58827. * @param scene defines the current scene where to apply this optimization
  58828. * @param optimizer defines the current optimizer
  58829. * @returns true if everything that can be done was applied
  58830. */
  58831. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58832. }
  58833. /**
  58834. * Defines an optimization used to turn post-processes off
  58835. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58836. */
  58837. export class PostProcessesOptimization extends SceneOptimization {
  58838. /**
  58839. * Gets a string describing the action executed by the current optimization
  58840. * @return description string
  58841. */
  58842. getDescription(): string;
  58843. /**
  58844. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58845. * @param scene defines the current scene where to apply this optimization
  58846. * @param optimizer defines the current optimizer
  58847. * @returns true if everything that can be done was applied
  58848. */
  58849. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58850. }
  58851. /**
  58852. * Defines an optimization used to turn lens flares off
  58853. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58854. */
  58855. export class LensFlaresOptimization extends SceneOptimization {
  58856. /**
  58857. * Gets a string describing the action executed by the current optimization
  58858. * @return description string
  58859. */
  58860. getDescription(): string;
  58861. /**
  58862. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58863. * @param scene defines the current scene where to apply this optimization
  58864. * @param optimizer defines the current optimizer
  58865. * @returns true if everything that can be done was applied
  58866. */
  58867. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58868. }
  58869. /**
  58870. * Defines an optimization based on user defined callback.
  58871. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58872. */
  58873. export class CustomOptimization extends SceneOptimization {
  58874. /**
  58875. * Callback called to apply the custom optimization.
  58876. */
  58877. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58878. /**
  58879. * Callback called to get custom description
  58880. */
  58881. onGetDescription: () => string;
  58882. /**
  58883. * Gets a string describing the action executed by the current optimization
  58884. * @returns description string
  58885. */
  58886. getDescription(): string;
  58887. /**
  58888. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58889. * @param scene defines the current scene where to apply this optimization
  58890. * @param optimizer defines the current optimizer
  58891. * @returns true if everything that can be done was applied
  58892. */
  58893. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58894. }
  58895. /**
  58896. * Defines an optimization used to turn particles off
  58897. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58898. */
  58899. export class ParticlesOptimization extends SceneOptimization {
  58900. /**
  58901. * Gets a string describing the action executed by the current optimization
  58902. * @return description string
  58903. */
  58904. getDescription(): string;
  58905. /**
  58906. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58907. * @param scene defines the current scene where to apply this optimization
  58908. * @param optimizer defines the current optimizer
  58909. * @returns true if everything that can be done was applied
  58910. */
  58911. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58912. }
  58913. /**
  58914. * Defines an optimization used to turn render targets off
  58915. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58916. */
  58917. export class RenderTargetsOptimization extends SceneOptimization {
  58918. /**
  58919. * Gets a string describing the action executed by the current optimization
  58920. * @return description string
  58921. */
  58922. getDescription(): string;
  58923. /**
  58924. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58925. * @param scene defines the current scene where to apply this optimization
  58926. * @param optimizer defines the current optimizer
  58927. * @returns true if everything that can be done was applied
  58928. */
  58929. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58930. }
  58931. /**
  58932. * Defines an optimization used to merge meshes with compatible materials
  58933. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58934. */
  58935. export class MergeMeshesOptimization extends SceneOptimization {
  58936. private static _UpdateSelectionTree;
  58937. /**
  58938. * Gets or sets a boolean which defines if optimization octree has to be updated
  58939. */
  58940. /**
  58941. * Gets or sets a boolean which defines if optimization octree has to be updated
  58942. */
  58943. static UpdateSelectionTree: boolean;
  58944. /**
  58945. * Gets a string describing the action executed by the current optimization
  58946. * @return description string
  58947. */
  58948. getDescription(): string;
  58949. private _canBeMerged;
  58950. /**
  58951. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58952. * @param scene defines the current scene where to apply this optimization
  58953. * @param optimizer defines the current optimizer
  58954. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58955. * @returns true if everything that can be done was applied
  58956. */
  58957. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58958. }
  58959. /**
  58960. * Defines a list of options used by SceneOptimizer
  58961. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58962. */
  58963. export class SceneOptimizerOptions {
  58964. /**
  58965. * Defines the target frame rate to reach (60 by default)
  58966. */
  58967. targetFrameRate: number;
  58968. /**
  58969. * Defines the interval between two checkes (2000ms by default)
  58970. */
  58971. trackerDuration: number;
  58972. /**
  58973. * Gets the list of optimizations to apply
  58974. */
  58975. optimizations: SceneOptimization[];
  58976. /**
  58977. * Creates a new list of options used by SceneOptimizer
  58978. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58979. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58980. */
  58981. constructor(
  58982. /**
  58983. * Defines the target frame rate to reach (60 by default)
  58984. */
  58985. targetFrameRate?: number,
  58986. /**
  58987. * Defines the interval between two checkes (2000ms by default)
  58988. */
  58989. trackerDuration?: number);
  58990. /**
  58991. * Add a new optimization
  58992. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58993. * @returns the current SceneOptimizerOptions
  58994. */
  58995. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58996. /**
  58997. * Add a new custom optimization
  58998. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58999. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  59000. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59001. * @returns the current SceneOptimizerOptions
  59002. */
  59003. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  59004. /**
  59005. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  59006. * @param targetFrameRate defines the target frame rate (60 by default)
  59007. * @returns a SceneOptimizerOptions object
  59008. */
  59009. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59010. /**
  59011. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59012. * @param targetFrameRate defines the target frame rate (60 by default)
  59013. * @returns a SceneOptimizerOptions object
  59014. */
  59015. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59016. /**
  59017. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59018. * @param targetFrameRate defines the target frame rate (60 by default)
  59019. * @returns a SceneOptimizerOptions object
  59020. */
  59021. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59022. }
  59023. /**
  59024. * Class used to run optimizations in order to reach a target frame rate
  59025. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59026. */
  59027. export class SceneOptimizer implements IDisposable {
  59028. private _isRunning;
  59029. private _options;
  59030. private _scene;
  59031. private _currentPriorityLevel;
  59032. private _targetFrameRate;
  59033. private _trackerDuration;
  59034. private _currentFrameRate;
  59035. private _sceneDisposeObserver;
  59036. private _improvementMode;
  59037. /**
  59038. * Defines an observable called when the optimizer reaches the target frame rate
  59039. */
  59040. onSuccessObservable: Observable<SceneOptimizer>;
  59041. /**
  59042. * Defines an observable called when the optimizer enables an optimization
  59043. */
  59044. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59045. /**
  59046. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59047. */
  59048. onFailureObservable: Observable<SceneOptimizer>;
  59049. /**
  59050. * Gets a boolean indicating if the optimizer is in improvement mode
  59051. */
  59052. readonly isInImprovementMode: boolean;
  59053. /**
  59054. * Gets the current priority level (0 at start)
  59055. */
  59056. readonly currentPriorityLevel: number;
  59057. /**
  59058. * Gets the current frame rate checked by the SceneOptimizer
  59059. */
  59060. readonly currentFrameRate: number;
  59061. /**
  59062. * Gets or sets the current target frame rate (60 by default)
  59063. */
  59064. /**
  59065. * Gets or sets the current target frame rate (60 by default)
  59066. */
  59067. targetFrameRate: number;
  59068. /**
  59069. * Gets or sets the current interval between two checks (every 2000ms by default)
  59070. */
  59071. /**
  59072. * Gets or sets the current interval between two checks (every 2000ms by default)
  59073. */
  59074. trackerDuration: number;
  59075. /**
  59076. * Gets the list of active optimizations
  59077. */
  59078. readonly optimizations: SceneOptimization[];
  59079. /**
  59080. * Creates a new SceneOptimizer
  59081. * @param scene defines the scene to work on
  59082. * @param options defines the options to use with the SceneOptimizer
  59083. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59084. * @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)
  59085. */
  59086. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59087. /**
  59088. * Stops the current optimizer
  59089. */
  59090. stop(): void;
  59091. /**
  59092. * Reset the optimizer to initial step (current priority level = 0)
  59093. */
  59094. reset(): void;
  59095. /**
  59096. * Start the optimizer. By default it will try to reach a specific framerate
  59097. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59098. */
  59099. start(): void;
  59100. private _checkCurrentState;
  59101. /**
  59102. * Release all resources
  59103. */
  59104. dispose(): void;
  59105. /**
  59106. * Helper function to create a SceneOptimizer with one single line of code
  59107. * @param scene defines the scene to work on
  59108. * @param options defines the options to use with the SceneOptimizer
  59109. * @param onSuccess defines a callback to call on success
  59110. * @param onFailure defines a callback to call on failure
  59111. * @returns the new SceneOptimizer object
  59112. */
  59113. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59114. }
  59115. }
  59116. declare module BABYLON {
  59117. /**
  59118. * Class used to serialize a scene into a string
  59119. */
  59120. export class SceneSerializer {
  59121. /**
  59122. * Clear cache used by a previous serialization
  59123. */
  59124. static ClearCache(): void;
  59125. /**
  59126. * Serialize a scene into a JSON compatible object
  59127. * @param scene defines the scene to serialize
  59128. * @returns a JSON compatible object
  59129. */
  59130. static Serialize(scene: Scene): any;
  59131. /**
  59132. * Serialize a mesh into a JSON compatible object
  59133. * @param toSerialize defines the mesh to serialize
  59134. * @param withParents defines if parents must be serialized as well
  59135. * @param withChildren defines if children must be serialized as well
  59136. * @returns a JSON compatible object
  59137. */
  59138. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59139. }
  59140. }
  59141. declare module BABYLON {
  59142. /**
  59143. * Class used to host texture specific utilities
  59144. */
  59145. export class TextureTools {
  59146. /**
  59147. * Uses the GPU to create a copy texture rescaled at a given size
  59148. * @param texture Texture to copy from
  59149. * @param width defines the desired width
  59150. * @param height defines the desired height
  59151. * @param useBilinearMode defines if bilinear mode has to be used
  59152. * @return the generated texture
  59153. */
  59154. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59155. }
  59156. }
  59157. declare module BABYLON {
  59158. /**
  59159. * This represents the different options available for the video capture.
  59160. */
  59161. export interface VideoRecorderOptions {
  59162. /** Defines the mime type of the video. */
  59163. mimeType: string;
  59164. /** Defines the FPS the video should be recorded at. */
  59165. fps: number;
  59166. /** Defines the chunk size for the recording data. */
  59167. recordChunckSize: number;
  59168. /** The audio tracks to attach to the recording. */
  59169. audioTracks?: MediaStreamTrack[];
  59170. }
  59171. /**
  59172. * This can help with recording videos from BabylonJS.
  59173. * This is based on the available WebRTC functionalities of the browser.
  59174. *
  59175. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59176. */
  59177. export class VideoRecorder {
  59178. private static readonly _defaultOptions;
  59179. /**
  59180. * Returns whether or not the VideoRecorder is available in your browser.
  59181. * @param engine Defines the Babylon Engine.
  59182. * @returns true if supported otherwise false.
  59183. */
  59184. static IsSupported(engine: Engine): boolean;
  59185. private readonly _options;
  59186. private _canvas;
  59187. private _mediaRecorder;
  59188. private _recordedChunks;
  59189. private _fileName;
  59190. private _resolve;
  59191. private _reject;
  59192. /**
  59193. * True when a recording is already in progress.
  59194. */
  59195. readonly isRecording: boolean;
  59196. /**
  59197. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  59198. * @param engine Defines the BabylonJS Engine you wish to record.
  59199. * @param options Defines options that can be used to customize the capture.
  59200. */
  59201. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59202. /**
  59203. * Stops the current recording before the default capture timeout passed in the startRecording function.
  59204. */
  59205. stopRecording(): void;
  59206. /**
  59207. * Starts recording the canvas for a max duration specified in parameters.
  59208. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  59209. * If null no automatic download will start and you can rely on the promise to get the data back.
  59210. * @param maxDuration Defines the maximum recording time in seconds.
  59211. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59212. * @return A promise callback at the end of the recording with the video data in Blob.
  59213. */
  59214. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59215. /**
  59216. * Releases internal resources used during the recording.
  59217. */
  59218. dispose(): void;
  59219. private _handleDataAvailable;
  59220. private _handleError;
  59221. private _handleStop;
  59222. }
  59223. }
  59224. declare module BABYLON {
  59225. /**
  59226. * Class containing a set of static utilities functions for screenshots
  59227. */
  59228. export class ScreenshotTools {
  59229. /**
  59230. * Captures a screenshot of the current rendering
  59231. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59232. * @param engine defines the rendering engine
  59233. * @param camera defines the source camera
  59234. * @param size This parameter can be set to a single number or to an object with the
  59235. * following (optional) properties: precision, width, height. If a single number is passed,
  59236. * it will be used for both width and height. If an object is passed, the screenshot size
  59237. * will be derived from the parameters. The precision property is a multiplier allowing
  59238. * rendering at a higher or lower resolution
  59239. * @param successCallback defines the callback receives a single parameter which contains the
  59240. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59241. * src parameter of an <img> to display it
  59242. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59243. * Check your browser for supported MIME types
  59244. */
  59245. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59246. /**
  59247. * Generates an image screenshot from the specified camera.
  59248. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59249. * @param engine The engine to use for rendering
  59250. * @param camera The camera to use for rendering
  59251. * @param size This parameter can be set to a single number or to an object with the
  59252. * following (optional) properties: precision, width, height. If a single number is passed,
  59253. * it will be used for both width and height. If an object is passed, the screenshot size
  59254. * will be derived from the parameters. The precision property is a multiplier allowing
  59255. * rendering at a higher or lower resolution
  59256. * @param successCallback The callback receives a single parameter which contains the
  59257. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59258. * src parameter of an <img> to display it
  59259. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59260. * Check your browser for supported MIME types
  59261. * @param samples Texture samples (default: 1)
  59262. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59263. * @param fileName A name for for the downloaded file.
  59264. */
  59265. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59266. }
  59267. }
  59268. declare module BABYLON {
  59269. /**
  59270. * A cursor which tracks a point on a path
  59271. */
  59272. export class PathCursor {
  59273. private path;
  59274. /**
  59275. * Stores path cursor callbacks for when an onchange event is triggered
  59276. */
  59277. private _onchange;
  59278. /**
  59279. * The value of the path cursor
  59280. */
  59281. value: number;
  59282. /**
  59283. * The animation array of the path cursor
  59284. */
  59285. animations: Animation[];
  59286. /**
  59287. * Initializes the path cursor
  59288. * @param path The path to track
  59289. */
  59290. constructor(path: Path2);
  59291. /**
  59292. * Gets the cursor point on the path
  59293. * @returns A point on the path cursor at the cursor location
  59294. */
  59295. getPoint(): Vector3;
  59296. /**
  59297. * Moves the cursor ahead by the step amount
  59298. * @param step The amount to move the cursor forward
  59299. * @returns This path cursor
  59300. */
  59301. moveAhead(step?: number): PathCursor;
  59302. /**
  59303. * Moves the cursor behind by the step amount
  59304. * @param step The amount to move the cursor back
  59305. * @returns This path cursor
  59306. */
  59307. moveBack(step?: number): PathCursor;
  59308. /**
  59309. * Moves the cursor by the step amount
  59310. * If the step amount is greater than one, an exception is thrown
  59311. * @param step The amount to move the cursor
  59312. * @returns This path cursor
  59313. */
  59314. move(step: number): PathCursor;
  59315. /**
  59316. * Ensures that the value is limited between zero and one
  59317. * @returns This path cursor
  59318. */
  59319. private ensureLimits;
  59320. /**
  59321. * Runs onchange callbacks on change (used by the animation engine)
  59322. * @returns This path cursor
  59323. */
  59324. private raiseOnChange;
  59325. /**
  59326. * Executes a function on change
  59327. * @param f A path cursor onchange callback
  59328. * @returns This path cursor
  59329. */
  59330. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59331. }
  59332. }
  59333. declare module BABYLON {
  59334. /** @hidden */
  59335. export var blurPixelShader: {
  59336. name: string;
  59337. shader: string;
  59338. };
  59339. }
  59340. declare module BABYLON {
  59341. /** @hidden */
  59342. export var pointCloudVertexDeclaration: {
  59343. name: string;
  59344. shader: string;
  59345. };
  59346. }
  59347. // Mixins
  59348. interface Window {
  59349. mozIndexedDB: IDBFactory;
  59350. webkitIndexedDB: IDBFactory;
  59351. msIndexedDB: IDBFactory;
  59352. webkitURL: typeof URL;
  59353. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59354. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59355. WebGLRenderingContext: WebGLRenderingContext;
  59356. MSGesture: MSGesture;
  59357. CANNON: any;
  59358. AudioContext: AudioContext;
  59359. webkitAudioContext: AudioContext;
  59360. PointerEvent: any;
  59361. Math: Math;
  59362. Uint8Array: Uint8ArrayConstructor;
  59363. Float32Array: Float32ArrayConstructor;
  59364. mozURL: typeof URL;
  59365. msURL: typeof URL;
  59366. VRFrameData: any; // WebVR, from specs 1.1
  59367. DracoDecoderModule: any;
  59368. setImmediate(handler: (...args: any[]) => void): number;
  59369. }
  59370. interface HTMLCanvasElement {
  59371. requestPointerLock(): void;
  59372. msRequestPointerLock?(): void;
  59373. mozRequestPointerLock?(): void;
  59374. webkitRequestPointerLock?(): void;
  59375. /** Track wether a record is in progress */
  59376. isRecording: boolean;
  59377. /** Capture Stream method defined by some browsers */
  59378. captureStream(fps?: number): MediaStream;
  59379. }
  59380. interface CanvasRenderingContext2D {
  59381. msImageSmoothingEnabled: boolean;
  59382. }
  59383. interface MouseEvent {
  59384. mozMovementX: number;
  59385. mozMovementY: number;
  59386. webkitMovementX: number;
  59387. webkitMovementY: number;
  59388. msMovementX: number;
  59389. msMovementY: number;
  59390. }
  59391. interface Navigator {
  59392. mozGetVRDevices: (any: any) => any;
  59393. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59394. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59395. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59396. webkitGetGamepads(): Gamepad[];
  59397. msGetGamepads(): Gamepad[];
  59398. webkitGamepads(): Gamepad[];
  59399. }
  59400. interface HTMLVideoElement {
  59401. mozSrcObject: any;
  59402. }
  59403. interface Math {
  59404. fround(x: number): number;
  59405. imul(a: number, b: number): number;
  59406. }
  59407. interface WebGLRenderingContext {
  59408. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59409. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59410. vertexAttribDivisor(index: number, divisor: number): void;
  59411. createVertexArray(): any;
  59412. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59413. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59414. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59415. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59416. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59417. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59418. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59419. // Queries
  59420. createQuery(): WebGLQuery;
  59421. deleteQuery(query: WebGLQuery): void;
  59422. beginQuery(target: number, query: WebGLQuery): void;
  59423. endQuery(target: number): void;
  59424. getQueryParameter(query: WebGLQuery, pname: number): any;
  59425. getQuery(target: number, pname: number): any;
  59426. MAX_SAMPLES: number;
  59427. RGBA8: number;
  59428. READ_FRAMEBUFFER: number;
  59429. DRAW_FRAMEBUFFER: number;
  59430. UNIFORM_BUFFER: number;
  59431. HALF_FLOAT_OES: number;
  59432. RGBA16F: number;
  59433. RGBA32F: number;
  59434. R32F: number;
  59435. RG32F: number;
  59436. RGB32F: number;
  59437. R16F: number;
  59438. RG16F: number;
  59439. RGB16F: number;
  59440. RED: number;
  59441. RG: number;
  59442. R8: number;
  59443. RG8: number;
  59444. UNSIGNED_INT_24_8: number;
  59445. DEPTH24_STENCIL8: number;
  59446. /* Multiple Render Targets */
  59447. drawBuffers(buffers: number[]): void;
  59448. readBuffer(src: number): void;
  59449. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59450. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59451. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59452. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59453. // Occlusion Query
  59454. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59455. ANY_SAMPLES_PASSED: number;
  59456. QUERY_RESULT_AVAILABLE: number;
  59457. QUERY_RESULT: number;
  59458. }
  59459. interface WebGLProgram {
  59460. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59461. }
  59462. interface EXT_disjoint_timer_query {
  59463. QUERY_COUNTER_BITS_EXT: number;
  59464. TIME_ELAPSED_EXT: number;
  59465. TIMESTAMP_EXT: number;
  59466. GPU_DISJOINT_EXT: number;
  59467. QUERY_RESULT_EXT: number;
  59468. QUERY_RESULT_AVAILABLE_EXT: number;
  59469. queryCounterEXT(query: WebGLQuery, target: number): void;
  59470. createQueryEXT(): WebGLQuery;
  59471. beginQueryEXT(target: number, query: WebGLQuery): void;
  59472. endQueryEXT(target: number): void;
  59473. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59474. deleteQueryEXT(query: WebGLQuery): void;
  59475. }
  59476. interface WebGLUniformLocation {
  59477. _currentState: any;
  59478. }
  59479. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59480. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59481. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59482. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59483. interface WebGLRenderingContext {
  59484. readonly RASTERIZER_DISCARD: number;
  59485. readonly DEPTH_COMPONENT24: number;
  59486. readonly TEXTURE_3D: number;
  59487. readonly TEXTURE_2D_ARRAY: number;
  59488. readonly TEXTURE_COMPARE_FUNC: number;
  59489. readonly TEXTURE_COMPARE_MODE: number;
  59490. readonly COMPARE_REF_TO_TEXTURE: number;
  59491. readonly TEXTURE_WRAP_R: number;
  59492. readonly HALF_FLOAT: number;
  59493. readonly RGB8: number;
  59494. readonly RED_INTEGER: number;
  59495. readonly RG_INTEGER: number;
  59496. readonly RGB_INTEGER: number;
  59497. readonly RGBA_INTEGER: number;
  59498. readonly R8_SNORM: number;
  59499. readonly RG8_SNORM: number;
  59500. readonly RGB8_SNORM: number;
  59501. readonly RGBA8_SNORM: number;
  59502. readonly R8I: number;
  59503. readonly RG8I: number;
  59504. readonly RGB8I: number;
  59505. readonly RGBA8I: number;
  59506. readonly R8UI: number;
  59507. readonly RG8UI: number;
  59508. readonly RGB8UI: number;
  59509. readonly RGBA8UI: number;
  59510. readonly R16I: number;
  59511. readonly RG16I: number;
  59512. readonly RGB16I: number;
  59513. readonly RGBA16I: number;
  59514. readonly R16UI: number;
  59515. readonly RG16UI: number;
  59516. readonly RGB16UI: number;
  59517. readonly RGBA16UI: number;
  59518. readonly R32I: number;
  59519. readonly RG32I: number;
  59520. readonly RGB32I: number;
  59521. readonly RGBA32I: number;
  59522. readonly R32UI: number;
  59523. readonly RG32UI: number;
  59524. readonly RGB32UI: number;
  59525. readonly RGBA32UI: number;
  59526. readonly RGB10_A2UI: number;
  59527. readonly R11F_G11F_B10F: number;
  59528. readonly RGB9_E5: number;
  59529. readonly RGB10_A2: number;
  59530. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59531. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59532. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59533. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59534. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59535. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59536. 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;
  59537. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59538. readonly TRANSFORM_FEEDBACK: number;
  59539. readonly INTERLEAVED_ATTRIBS: number;
  59540. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59541. createTransformFeedback(): WebGLTransformFeedback;
  59542. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59543. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59544. beginTransformFeedback(primitiveMode: number): void;
  59545. endTransformFeedback(): void;
  59546. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59547. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59548. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59549. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59550. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59551. }
  59552. interface ImageBitmap {
  59553. readonly width: number;
  59554. readonly height: number;
  59555. close(): void;
  59556. }
  59557. interface WebGLQuery extends WebGLObject {
  59558. }
  59559. declare var WebGLQuery: {
  59560. prototype: WebGLQuery;
  59561. new(): WebGLQuery;
  59562. };
  59563. interface WebGLSampler extends WebGLObject {
  59564. }
  59565. declare var WebGLSampler: {
  59566. prototype: WebGLSampler;
  59567. new(): WebGLSampler;
  59568. };
  59569. interface WebGLSync extends WebGLObject {
  59570. }
  59571. declare var WebGLSync: {
  59572. prototype: WebGLSync;
  59573. new(): WebGLSync;
  59574. };
  59575. interface WebGLTransformFeedback extends WebGLObject {
  59576. }
  59577. declare var WebGLTransformFeedback: {
  59578. prototype: WebGLTransformFeedback;
  59579. new(): WebGLTransformFeedback;
  59580. };
  59581. interface WebGLVertexArrayObject extends WebGLObject {
  59582. }
  59583. declare var WebGLVertexArrayObject: {
  59584. prototype: WebGLVertexArrayObject;
  59585. new(): WebGLVertexArrayObject;
  59586. };
  59587. // Type definitions for WebVR API
  59588. // Project: https://w3c.github.io/webvr/
  59589. // Definitions by: six a <https://github.com/lostfictions>
  59590. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59591. interface VRDisplay extends EventTarget {
  59592. /**
  59593. * Dictionary of capabilities describing the VRDisplay.
  59594. */
  59595. readonly capabilities: VRDisplayCapabilities;
  59596. /**
  59597. * z-depth defining the far plane of the eye view frustum
  59598. * enables mapping of values in the render target depth
  59599. * attachment to scene coordinates. Initially set to 10000.0.
  59600. */
  59601. depthFar: number;
  59602. /**
  59603. * z-depth defining the near plane of the eye view frustum
  59604. * enables mapping of values in the render target depth
  59605. * attachment to scene coordinates. Initially set to 0.01.
  59606. */
  59607. depthNear: number;
  59608. /**
  59609. * An identifier for this distinct VRDisplay. Used as an
  59610. * association point in the Gamepad API.
  59611. */
  59612. readonly displayId: number;
  59613. /**
  59614. * A display name, a user-readable name identifying it.
  59615. */
  59616. readonly displayName: string;
  59617. readonly isConnected: boolean;
  59618. readonly isPresenting: boolean;
  59619. /**
  59620. * If this VRDisplay supports room-scale experiences, the optional
  59621. * stage attribute contains details on the room-scale parameters.
  59622. */
  59623. readonly stageParameters: VRStageParameters | null;
  59624. /**
  59625. * Passing the value returned by `requestAnimationFrame` to
  59626. * `cancelAnimationFrame` will unregister the callback.
  59627. * @param handle Define the hanle of the request to cancel
  59628. */
  59629. cancelAnimationFrame(handle: number): void;
  59630. /**
  59631. * Stops presenting to the VRDisplay.
  59632. * @returns a promise to know when it stopped
  59633. */
  59634. exitPresent(): Promise<void>;
  59635. /**
  59636. * Return the current VREyeParameters for the given eye.
  59637. * @param whichEye Define the eye we want the parameter for
  59638. * @returns the eye parameters
  59639. */
  59640. getEyeParameters(whichEye: string): VREyeParameters;
  59641. /**
  59642. * Populates the passed VRFrameData with the information required to render
  59643. * the current frame.
  59644. * @param frameData Define the data structure to populate
  59645. * @returns true if ok otherwise false
  59646. */
  59647. getFrameData(frameData: VRFrameData): boolean;
  59648. /**
  59649. * Get the layers currently being presented.
  59650. * @returns the list of VR layers
  59651. */
  59652. getLayers(): VRLayer[];
  59653. /**
  59654. * Return a VRPose containing the future predicted pose of the VRDisplay
  59655. * when the current frame will be presented. The value returned will not
  59656. * change until JavaScript has returned control to the browser.
  59657. *
  59658. * The VRPose will contain the position, orientation, velocity,
  59659. * and acceleration of each of these properties.
  59660. * @returns the pose object
  59661. */
  59662. getPose(): VRPose;
  59663. /**
  59664. * Return the current instantaneous pose of the VRDisplay, with no
  59665. * prediction applied.
  59666. * @returns the current instantaneous pose
  59667. */
  59668. getImmediatePose(): VRPose;
  59669. /**
  59670. * The callback passed to `requestAnimationFrame` will be called
  59671. * any time a new frame should be rendered. When the VRDisplay is
  59672. * presenting the callback will be called at the native refresh
  59673. * rate of the HMD. When not presenting this function acts
  59674. * identically to how window.requestAnimationFrame acts. Content should
  59675. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59676. * asynchronously from other displays and at differing refresh rates.
  59677. * @param callback Define the eaction to run next frame
  59678. * @returns the request handle it
  59679. */
  59680. requestAnimationFrame(callback: FrameRequestCallback): number;
  59681. /**
  59682. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59683. * Repeat calls while already presenting will update the VRLayers being displayed.
  59684. * @param layers Define the list of layer to present
  59685. * @returns a promise to know when the request has been fulfilled
  59686. */
  59687. requestPresent(layers: VRLayer[]): Promise<void>;
  59688. /**
  59689. * Reset the pose for this display, treating its current position and
  59690. * orientation as the "origin/zero" values. VRPose.position,
  59691. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59692. * updated when calling resetPose(). This should be called in only
  59693. * sitting-space experiences.
  59694. */
  59695. resetPose(): void;
  59696. /**
  59697. * The VRLayer provided to the VRDisplay will be captured and presented
  59698. * in the HMD. Calling this function has the same effect on the source
  59699. * canvas as any other operation that uses its source image, and canvases
  59700. * created without preserveDrawingBuffer set to true will be cleared.
  59701. * @param pose Define the pose to submit
  59702. */
  59703. submitFrame(pose?: VRPose): void;
  59704. }
  59705. declare var VRDisplay: {
  59706. prototype: VRDisplay;
  59707. new(): VRDisplay;
  59708. };
  59709. interface VRLayer {
  59710. leftBounds?: number[] | Float32Array | null;
  59711. rightBounds?: number[] | Float32Array | null;
  59712. source?: HTMLCanvasElement | null;
  59713. }
  59714. interface VRDisplayCapabilities {
  59715. readonly canPresent: boolean;
  59716. readonly hasExternalDisplay: boolean;
  59717. readonly hasOrientation: boolean;
  59718. readonly hasPosition: boolean;
  59719. readonly maxLayers: number;
  59720. }
  59721. interface VREyeParameters {
  59722. /** @deprecated */
  59723. readonly fieldOfView: VRFieldOfView;
  59724. readonly offset: Float32Array;
  59725. readonly renderHeight: number;
  59726. readonly renderWidth: number;
  59727. }
  59728. interface VRFieldOfView {
  59729. readonly downDegrees: number;
  59730. readonly leftDegrees: number;
  59731. readonly rightDegrees: number;
  59732. readonly upDegrees: number;
  59733. }
  59734. interface VRFrameData {
  59735. readonly leftProjectionMatrix: Float32Array;
  59736. readonly leftViewMatrix: Float32Array;
  59737. readonly pose: VRPose;
  59738. readonly rightProjectionMatrix: Float32Array;
  59739. readonly rightViewMatrix: Float32Array;
  59740. readonly timestamp: number;
  59741. }
  59742. interface VRPose {
  59743. readonly angularAcceleration: Float32Array | null;
  59744. readonly angularVelocity: Float32Array | null;
  59745. readonly linearAcceleration: Float32Array | null;
  59746. readonly linearVelocity: Float32Array | null;
  59747. readonly orientation: Float32Array | null;
  59748. readonly position: Float32Array | null;
  59749. readonly timestamp: number;
  59750. }
  59751. interface VRStageParameters {
  59752. sittingToStandingTransform?: Float32Array;
  59753. sizeX?: number;
  59754. sizeY?: number;
  59755. }
  59756. interface Navigator {
  59757. getVRDisplays(): Promise<VRDisplay[]>;
  59758. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59759. }
  59760. interface Window {
  59761. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59762. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59763. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59764. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59765. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59766. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59767. }
  59768. interface Gamepad {
  59769. readonly displayId: number;
  59770. }
  59771. interface XRDevice {
  59772. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59773. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59774. }
  59775. interface XRSession {
  59776. getInputSources(): Array<any>;
  59777. baseLayer: XRWebGLLayer;
  59778. requestFrameOfReference(type: string): Promise<void>;
  59779. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59780. end(): Promise<void>;
  59781. requestAnimationFrame: Function;
  59782. addEventListener: Function;
  59783. }
  59784. interface XRSessionCreationOptions {
  59785. outputContext?: WebGLRenderingContext | null;
  59786. immersive?: boolean;
  59787. environmentIntegration?: boolean;
  59788. }
  59789. interface XRLayer {
  59790. getViewport: Function;
  59791. framebufferWidth: number;
  59792. framebufferHeight: number;
  59793. }
  59794. interface XRView {
  59795. projectionMatrix: Float32Array;
  59796. }
  59797. interface XRFrame {
  59798. getDevicePose: Function;
  59799. getInputPose: Function;
  59800. views: Array<XRView>;
  59801. baseLayer: XRLayer;
  59802. }
  59803. interface XRFrameOfReference {
  59804. }
  59805. interface XRWebGLLayer extends XRLayer {
  59806. framebuffer: WebGLFramebuffer;
  59807. }
  59808. declare var XRWebGLLayer: {
  59809. prototype: XRWebGLLayer;
  59810. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59811. };
  59812. declare module BABYLON.GUI {
  59813. /**
  59814. * Class used to specific a value and its associated unit
  59815. */
  59816. export class ValueAndUnit {
  59817. /** defines the unit to store */
  59818. unit: number;
  59819. /** defines a boolean indicating if the value can be negative */
  59820. negativeValueAllowed: boolean;
  59821. private _value;
  59822. private _originalUnit;
  59823. /**
  59824. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  59825. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59826. */
  59827. ignoreAdaptiveScaling: boolean;
  59828. /**
  59829. * Creates a new ValueAndUnit
  59830. * @param value defines the value to store
  59831. * @param unit defines the unit to store
  59832. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  59833. */
  59834. constructor(value: number,
  59835. /** defines the unit to store */
  59836. unit?: number,
  59837. /** defines a boolean indicating if the value can be negative */
  59838. negativeValueAllowed?: boolean);
  59839. /** Gets a boolean indicating if the value is a percentage */
  59840. readonly isPercentage: boolean;
  59841. /** Gets a boolean indicating if the value is store as pixel */
  59842. readonly isPixel: boolean;
  59843. /** Gets direct internal value */
  59844. readonly internalValue: number;
  59845. /**
  59846. * Gets value as pixel
  59847. * @param host defines the root host
  59848. * @param refValue defines the reference value for percentages
  59849. * @returns the value as pixel
  59850. */
  59851. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  59852. /**
  59853. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  59854. * @param value defines the value to store
  59855. * @param unit defines the unit to store
  59856. * @returns the current ValueAndUnit
  59857. */
  59858. updateInPlace(value: number, unit?: number): ValueAndUnit;
  59859. /**
  59860. * Gets the value accordingly to its unit
  59861. * @param host defines the root host
  59862. * @returns the value
  59863. */
  59864. getValue(host: AdvancedDynamicTexture): number;
  59865. /**
  59866. * Gets a string representation of the value
  59867. * @param host defines the root host
  59868. * @param decimals defines an optional number of decimals to display
  59869. * @returns a string
  59870. */
  59871. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  59872. /**
  59873. * Store a value parsed from a string
  59874. * @param source defines the source string
  59875. * @returns true if the value was successfully parsed
  59876. */
  59877. fromString(source: string | number): boolean;
  59878. private static _Regex;
  59879. private static _UNITMODE_PERCENTAGE;
  59880. private static _UNITMODE_PIXEL;
  59881. /** UNITMODE_PERCENTAGE */
  59882. static readonly UNITMODE_PERCENTAGE: number;
  59883. /** UNITMODE_PIXEL */
  59884. static readonly UNITMODE_PIXEL: number;
  59885. }
  59886. }
  59887. declare module BABYLON.GUI {
  59888. /**
  59889. * Define a style used by control to automatically setup properties based on a template.
  59890. * Only support font related properties so far
  59891. */
  59892. export class Style implements BABYLON.IDisposable {
  59893. private _fontFamily;
  59894. private _fontStyle;
  59895. private _fontWeight;
  59896. /** @hidden */
  59897. _host: AdvancedDynamicTexture;
  59898. /** @hidden */
  59899. _fontSize: ValueAndUnit;
  59900. /**
  59901. * BABYLON.Observable raised when the style values are changed
  59902. */
  59903. onChangedObservable: BABYLON.Observable<Style>;
  59904. /**
  59905. * Creates a new style object
  59906. * @param host defines the AdvancedDynamicTexture which hosts this style
  59907. */
  59908. constructor(host: AdvancedDynamicTexture);
  59909. /**
  59910. * Gets or sets the font size
  59911. */
  59912. fontSize: string | number;
  59913. /**
  59914. * Gets or sets the font family
  59915. */
  59916. fontFamily: string;
  59917. /**
  59918. * Gets or sets the font style
  59919. */
  59920. fontStyle: string;
  59921. /** Gets or sets font weight */
  59922. fontWeight: string;
  59923. /** Dispose all associated resources */
  59924. dispose(): void;
  59925. }
  59926. }
  59927. declare module BABYLON.GUI {
  59928. /**
  59929. * Class used to transport BABYLON.Vector2 information for pointer events
  59930. */
  59931. export class Vector2WithInfo extends BABYLON.Vector2 {
  59932. /** defines the current mouse button index */
  59933. buttonIndex: number;
  59934. /**
  59935. * Creates a new Vector2WithInfo
  59936. * @param source defines the vector2 data to transport
  59937. * @param buttonIndex defines the current mouse button index
  59938. */
  59939. constructor(source: BABYLON.Vector2,
  59940. /** defines the current mouse button index */
  59941. buttonIndex?: number);
  59942. }
  59943. /** Class used to provide 2D matrix features */
  59944. export class Matrix2D {
  59945. /** Gets the internal array of 6 floats used to store matrix data */
  59946. m: Float32Array;
  59947. /**
  59948. * Creates a new matrix
  59949. * @param m00 defines value for (0, 0)
  59950. * @param m01 defines value for (0, 1)
  59951. * @param m10 defines value for (1, 0)
  59952. * @param m11 defines value for (1, 1)
  59953. * @param m20 defines value for (2, 0)
  59954. * @param m21 defines value for (2, 1)
  59955. */
  59956. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  59957. /**
  59958. * Fills the matrix from direct values
  59959. * @param m00 defines value for (0, 0)
  59960. * @param m01 defines value for (0, 1)
  59961. * @param m10 defines value for (1, 0)
  59962. * @param m11 defines value for (1, 1)
  59963. * @param m20 defines value for (2, 0)
  59964. * @param m21 defines value for (2, 1)
  59965. * @returns the current modified matrix
  59966. */
  59967. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  59968. /**
  59969. * Gets matrix determinant
  59970. * @returns the determinant
  59971. */
  59972. determinant(): number;
  59973. /**
  59974. * Inverses the matrix and stores it in a target matrix
  59975. * @param result defines the target matrix
  59976. * @returns the current matrix
  59977. */
  59978. invertToRef(result: Matrix2D): Matrix2D;
  59979. /**
  59980. * Multiplies the current matrix with another one
  59981. * @param other defines the second operand
  59982. * @param result defines the target matrix
  59983. * @returns the current matrix
  59984. */
  59985. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  59986. /**
  59987. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  59988. * @param x defines the x coordinate to transform
  59989. * @param y defines the x coordinate to transform
  59990. * @param result defines the target vector2
  59991. * @returns the current matrix
  59992. */
  59993. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  59994. /**
  59995. * Creates an identity matrix
  59996. * @returns a new matrix
  59997. */
  59998. static Identity(): Matrix2D;
  59999. /**
  60000. * Creates a translation matrix and stores it in a target matrix
  60001. * @param x defines the x coordinate of the translation
  60002. * @param y defines the y coordinate of the translation
  60003. * @param result defines the target matrix
  60004. */
  60005. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  60006. /**
  60007. * Creates a scaling matrix and stores it in a target matrix
  60008. * @param x defines the x coordinate of the scaling
  60009. * @param y defines the y coordinate of the scaling
  60010. * @param result defines the target matrix
  60011. */
  60012. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  60013. /**
  60014. * Creates a rotation matrix and stores it in a target matrix
  60015. * @param angle defines the rotation angle
  60016. * @param result defines the target matrix
  60017. */
  60018. static RotationToRef(angle: number, result: Matrix2D): void;
  60019. private static _TempPreTranslationMatrix;
  60020. private static _TempPostTranslationMatrix;
  60021. private static _TempRotationMatrix;
  60022. private static _TempScalingMatrix;
  60023. private static _TempCompose0;
  60024. private static _TempCompose1;
  60025. private static _TempCompose2;
  60026. /**
  60027. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  60028. * @param tx defines the x coordinate of the translation
  60029. * @param ty defines the y coordinate of the translation
  60030. * @param angle defines the rotation angle
  60031. * @param scaleX defines the x coordinate of the scaling
  60032. * @param scaleY defines the y coordinate of the scaling
  60033. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  60034. * @param result defines the target matrix
  60035. */
  60036. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  60037. }
  60038. }
  60039. declare module BABYLON.GUI {
  60040. /**
  60041. * Class used to store 2D control sizes
  60042. */
  60043. export class Measure {
  60044. /** defines left coordinate */
  60045. left: number;
  60046. /** defines top coordinate */
  60047. top: number;
  60048. /** defines width dimension */
  60049. width: number;
  60050. /** defines height dimension */
  60051. height: number;
  60052. /**
  60053. * Creates a new measure
  60054. * @param left defines left coordinate
  60055. * @param top defines top coordinate
  60056. * @param width defines width dimension
  60057. * @param height defines height dimension
  60058. */
  60059. constructor(
  60060. /** defines left coordinate */
  60061. left: number,
  60062. /** defines top coordinate */
  60063. top: number,
  60064. /** defines width dimension */
  60065. width: number,
  60066. /** defines height dimension */
  60067. height: number);
  60068. /**
  60069. * Copy from another measure
  60070. * @param other defines the other measure to copy from
  60071. */
  60072. copyFrom(other: Measure): void;
  60073. /**
  60074. * Copy from a group of 4 floats
  60075. * @param left defines left coordinate
  60076. * @param top defines top coordinate
  60077. * @param width defines width dimension
  60078. * @param height defines height dimension
  60079. */
  60080. copyFromFloats(left: number, top: number, width: number, height: number): void;
  60081. /**
  60082. * Computes the axis aligned bounding box measure for two given measures
  60083. * @param a Input measure
  60084. * @param b Input measure
  60085. * @param result the resulting bounding measure
  60086. */
  60087. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  60088. /**
  60089. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  60090. * @param transform the matrix to transform the measure before computing the AABB
  60091. * @param result the resulting AABB
  60092. */
  60093. transformToRef(transform: Matrix2D, result: Measure): void;
  60094. /**
  60095. * Check equality between this measure and another one
  60096. * @param other defines the other measures
  60097. * @returns true if both measures are equals
  60098. */
  60099. isEqualsTo(other: Measure): boolean;
  60100. /**
  60101. * Creates an empty measure
  60102. * @returns a new measure
  60103. */
  60104. static Empty(): Measure;
  60105. }
  60106. }
  60107. declare module BABYLON.GUI {
  60108. /**
  60109. * Interface used to define a control that can receive focus
  60110. */
  60111. export interface IFocusableControl {
  60112. /**
  60113. * Function called when the control receives the focus
  60114. */
  60115. onFocus(): void;
  60116. /**
  60117. * Function called when the control loses the focus
  60118. */
  60119. onBlur(): void;
  60120. /**
  60121. * Function called to let the control handle keyboard events
  60122. * @param evt defines the current keyboard event
  60123. */
  60124. processKeyboard(evt: KeyboardEvent): void;
  60125. /**
  60126. * Function called to get the list of controls that should not steal the focus from this control
  60127. * @returns an array of controls
  60128. */
  60129. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  60130. }
  60131. /**
  60132. * Class used to create texture to support 2D GUI elements
  60133. * @see http://doc.babylonjs.com/how_to/gui
  60134. */
  60135. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  60136. private _isDirty;
  60137. private _renderObserver;
  60138. private _resizeObserver;
  60139. private _preKeyboardObserver;
  60140. private _pointerMoveObserver;
  60141. private _pointerObserver;
  60142. private _canvasPointerOutObserver;
  60143. private _background;
  60144. /** @hidden */
  60145. _rootContainer: Container;
  60146. /** @hidden */
  60147. _lastPickedControl: Control;
  60148. /** @hidden */
  60149. _lastControlOver: {
  60150. [pointerId: number]: Control;
  60151. };
  60152. /** @hidden */
  60153. _lastControlDown: {
  60154. [pointerId: number]: Control;
  60155. };
  60156. /** @hidden */
  60157. _capturingControl: {
  60158. [pointerId: number]: Control;
  60159. };
  60160. /** @hidden */
  60161. _shouldBlockPointer: boolean;
  60162. /** @hidden */
  60163. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  60164. /** @hidden */
  60165. _linkedControls: Control[];
  60166. private _isFullscreen;
  60167. private _fullscreenViewport;
  60168. private _idealWidth;
  60169. private _idealHeight;
  60170. private _useSmallestIdeal;
  60171. private _renderAtIdealSize;
  60172. private _focusedControl;
  60173. private _blockNextFocusCheck;
  60174. private _renderScale;
  60175. private _rootCanvas;
  60176. private _cursorChanged;
  60177. /**
  60178. * Define type to string to ensure compatibility across browsers
  60179. * Safari doesn't support DataTransfer constructor
  60180. */
  60181. private _clipboardData;
  60182. /**
  60183. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  60184. */
  60185. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  60186. /**
  60187. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  60188. */
  60189. onControlPickedObservable: BABYLON.Observable<Control>;
  60190. /**
  60191. * BABYLON.Observable event triggered before layout is evaluated
  60192. */
  60193. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60194. /**
  60195. * BABYLON.Observable event triggered after the layout was evaluated
  60196. */
  60197. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60198. /**
  60199. * BABYLON.Observable event triggered before the texture is rendered
  60200. */
  60201. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60202. /**
  60203. * BABYLON.Observable event triggered after the texture was rendered
  60204. */
  60205. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60206. /**
  60207. * Gets or sets a boolean defining if alpha is stored as premultiplied
  60208. */
  60209. premulAlpha: boolean;
  60210. /**
  60211. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  60212. * Useful when you want more antialiasing
  60213. */
  60214. renderScale: number;
  60215. /** Gets or sets the background color */
  60216. background: string;
  60217. /**
  60218. * Gets or sets the ideal width used to design controls.
  60219. * The GUI will then rescale everything accordingly
  60220. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60221. */
  60222. idealWidth: number;
  60223. /**
  60224. * Gets or sets the ideal height used to design controls.
  60225. * The GUI will then rescale everything accordingly
  60226. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60227. */
  60228. idealHeight: number;
  60229. /**
  60230. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  60231. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60232. */
  60233. useSmallestIdeal: boolean;
  60234. /**
  60235. * Gets or sets a boolean indicating if adaptive scaling must be used
  60236. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60237. */
  60238. renderAtIdealSize: boolean;
  60239. /**
  60240. * Gets the underlying layer used to render the texture when in fullscreen mode
  60241. */
  60242. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  60243. /**
  60244. * Gets the root container control
  60245. */
  60246. readonly rootContainer: Container;
  60247. /**
  60248. * Returns an array containing the root container.
  60249. * This is mostly used to let the Inspector introspects the ADT
  60250. * @returns an array containing the rootContainer
  60251. */
  60252. getChildren(): Array<Container>;
  60253. /**
  60254. * Will return all controls that are inside this texture
  60255. * @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
  60256. * @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
  60257. * @return all child controls
  60258. */
  60259. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  60260. /**
  60261. * Gets or sets the current focused control
  60262. */
  60263. focusedControl: BABYLON.Nullable<IFocusableControl>;
  60264. /**
  60265. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  60266. */
  60267. isForeground: boolean;
  60268. /**
  60269. * Gets or set information about clipboardData
  60270. */
  60271. clipboardData: string;
  60272. /**
  60273. * Creates a new AdvancedDynamicTexture
  60274. * @param name defines the name of the texture
  60275. * @param width defines the width of the texture
  60276. * @param height defines the height of the texture
  60277. * @param scene defines the hosting scene
  60278. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  60279. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  60280. */
  60281. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  60282. /**
  60283. * Get the current class name of the texture useful for serialization or dynamic coding.
  60284. * @returns "AdvancedDynamicTexture"
  60285. */
  60286. getClassName(): string;
  60287. /**
  60288. * Function used to execute a function on all controls
  60289. * @param func defines the function to execute
  60290. * @param container defines the container where controls belong. If null the root container will be used
  60291. */
  60292. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  60293. private _useInvalidateRectOptimization;
  60294. /**
  60295. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  60296. */
  60297. useInvalidateRectOptimization: boolean;
  60298. private _invalidatedRectangle;
  60299. /**
  60300. * Invalidates a rectangle area on the gui texture
  60301. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  60302. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  60303. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  60304. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  60305. */
  60306. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  60307. /**
  60308. * Marks the texture as dirty forcing a complete update
  60309. */
  60310. markAsDirty(): void;
  60311. /**
  60312. * Helper function used to create a new style
  60313. * @returns a new style
  60314. * @see http://doc.babylonjs.com/how_to/gui#styles
  60315. */
  60316. createStyle(): Style;
  60317. /**
  60318. * Adds a new control to the root container
  60319. * @param control defines the control to add
  60320. * @returns the current texture
  60321. */
  60322. addControl(control: Control): AdvancedDynamicTexture;
  60323. /**
  60324. * Removes a control from the root container
  60325. * @param control defines the control to remove
  60326. * @returns the current texture
  60327. */
  60328. removeControl(control: Control): AdvancedDynamicTexture;
  60329. /**
  60330. * Release all resources
  60331. */
  60332. dispose(): void;
  60333. private _onResize;
  60334. /** @hidden */
  60335. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  60336. /**
  60337. * Get screen coordinates for a vector3
  60338. * @param position defines the position to project
  60339. * @param worldMatrix defines the world matrix to use
  60340. * @returns the projected position
  60341. */
  60342. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  60343. private _checkUpdate;
  60344. private _clearMeasure;
  60345. private _render;
  60346. /** @hidden */
  60347. _changeCursor(cursor: string): void;
  60348. /** @hidden */
  60349. _registerLastControlDown(control: Control, pointerId: number): void;
  60350. private _doPicking;
  60351. /** @hidden */
  60352. _cleanControlAfterRemovalFromList(list: {
  60353. [pointerId: number]: Control;
  60354. }, control: Control): void;
  60355. /** @hidden */
  60356. _cleanControlAfterRemoval(control: Control): void;
  60357. /** Attach to all scene events required to support pointer events */
  60358. attach(): void;
  60359. /** @hidden */
  60360. private onClipboardCopy;
  60361. /** @hidden */
  60362. private onClipboardCut;
  60363. /** @hidden */
  60364. private onClipboardPaste;
  60365. /**
  60366. * Register the clipboard Events onto the canvas
  60367. */
  60368. registerClipboardEvents(): void;
  60369. /**
  60370. * Unregister the clipboard Events from the canvas
  60371. */
  60372. unRegisterClipboardEvents(): void;
  60373. /**
  60374. * Connect the texture to a hosting mesh to enable interactions
  60375. * @param mesh defines the mesh to attach to
  60376. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  60377. */
  60378. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  60379. /**
  60380. * Move the focus to a specific control
  60381. * @param control defines the control which will receive the focus
  60382. */
  60383. moveFocusToControl(control: IFocusableControl): void;
  60384. private _manageFocus;
  60385. private _attachToOnPointerOut;
  60386. /**
  60387. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  60388. * @param mesh defines the mesh which will receive the texture
  60389. * @param width defines the texture width (1024 by default)
  60390. * @param height defines the texture height (1024 by default)
  60391. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  60392. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  60393. * @returns a new AdvancedDynamicTexture
  60394. */
  60395. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  60396. /**
  60397. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  60398. * In this mode the texture will rely on a layer for its rendering.
  60399. * This allows it to be treated like any other layer.
  60400. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  60401. * LayerMask is set through advancedTexture.layer.layerMask
  60402. * @param name defines name for the texture
  60403. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  60404. * @param scene defines the hsoting scene
  60405. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  60406. * @returns a new AdvancedDynamicTexture
  60407. */
  60408. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  60409. }
  60410. }
  60411. declare module BABYLON.GUI {
  60412. /**
  60413. * Root class used for all 2D controls
  60414. * @see http://doc.babylonjs.com/how_to/gui#controls
  60415. */
  60416. export class Control {
  60417. /** defines the name of the control */
  60418. name?: string | undefined;
  60419. /**
  60420. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  60421. */
  60422. static AllowAlphaInheritance: boolean;
  60423. private _alpha;
  60424. private _alphaSet;
  60425. private _zIndex;
  60426. /** @hidden */
  60427. _host: AdvancedDynamicTexture;
  60428. /** Gets or sets the control parent */
  60429. parent: BABYLON.Nullable<Container>;
  60430. /** @hidden */
  60431. _currentMeasure: Measure;
  60432. private _fontFamily;
  60433. private _fontStyle;
  60434. private _fontWeight;
  60435. private _fontSize;
  60436. private _font;
  60437. /** @hidden */
  60438. _width: ValueAndUnit;
  60439. /** @hidden */
  60440. _height: ValueAndUnit;
  60441. /** @hidden */
  60442. protected _fontOffset: {
  60443. ascent: number;
  60444. height: number;
  60445. descent: number;
  60446. };
  60447. private _color;
  60448. private _style;
  60449. private _styleObserver;
  60450. /** @hidden */
  60451. protected _horizontalAlignment: number;
  60452. /** @hidden */
  60453. protected _verticalAlignment: number;
  60454. /** @hidden */
  60455. protected _isDirty: boolean;
  60456. /** @hidden */
  60457. protected _wasDirty: boolean;
  60458. /** @hidden */
  60459. _tempParentMeasure: Measure;
  60460. /** @hidden */
  60461. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  60462. /** @hidden */
  60463. protected _cachedParentMeasure: Measure;
  60464. private _paddingLeft;
  60465. private _paddingRight;
  60466. private _paddingTop;
  60467. private _paddingBottom;
  60468. /** @hidden */
  60469. _left: ValueAndUnit;
  60470. /** @hidden */
  60471. _top: ValueAndUnit;
  60472. private _scaleX;
  60473. private _scaleY;
  60474. private _rotation;
  60475. private _transformCenterX;
  60476. private _transformCenterY;
  60477. /** @hidden */
  60478. _transformMatrix: Matrix2D;
  60479. /** @hidden */
  60480. protected _invertTransformMatrix: Matrix2D;
  60481. /** @hidden */
  60482. protected _transformedPosition: BABYLON.Vector2;
  60483. private _isMatrixDirty;
  60484. private _cachedOffsetX;
  60485. private _cachedOffsetY;
  60486. private _isVisible;
  60487. private _isHighlighted;
  60488. /** @hidden */
  60489. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  60490. private _fontSet;
  60491. private _dummyVector2;
  60492. private _downCount;
  60493. private _enterCount;
  60494. private _doNotRender;
  60495. private _downPointerIds;
  60496. protected _isEnabled: boolean;
  60497. protected _disabledColor: string;
  60498. /** @hidden */
  60499. protected _rebuildLayout: boolean;
  60500. /** @hidden */
  60501. _isClipped: boolean;
  60502. /** @hidden */
  60503. _tag: any;
  60504. /**
  60505. * 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
  60506. */
  60507. uniqueId: number;
  60508. /**
  60509. * Gets or sets an object used to store user defined information for the node
  60510. */
  60511. metadata: any;
  60512. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  60513. isHitTestVisible: boolean;
  60514. /** Gets or sets a boolean indicating if the control can block pointer events */
  60515. isPointerBlocker: boolean;
  60516. /** Gets or sets a boolean indicating if the control can be focusable */
  60517. isFocusInvisible: boolean;
  60518. /**
  60519. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  60520. * 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
  60521. */
  60522. clipChildren: boolean;
  60523. /**
  60524. * Gets or sets a boolean indicating that control content must be clipped
  60525. * 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
  60526. */
  60527. clipContent: boolean;
  60528. /**
  60529. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  60530. */
  60531. useBitmapCache: boolean;
  60532. private _cacheData;
  60533. private _shadowOffsetX;
  60534. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  60535. shadowOffsetX: number;
  60536. private _shadowOffsetY;
  60537. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  60538. shadowOffsetY: number;
  60539. private _shadowBlur;
  60540. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  60541. shadowBlur: number;
  60542. private _shadowColor;
  60543. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  60544. shadowColor: string;
  60545. /** Gets or sets the cursor to use when the control is hovered */
  60546. hoverCursor: string;
  60547. /** @hidden */
  60548. protected _linkOffsetX: ValueAndUnit;
  60549. /** @hidden */
  60550. protected _linkOffsetY: ValueAndUnit;
  60551. /** Gets the control type name */
  60552. readonly typeName: string;
  60553. /**
  60554. * Get the current class name of the control.
  60555. * @returns current class name
  60556. */
  60557. getClassName(): string;
  60558. /**
  60559. * An event triggered when the pointer move over the control.
  60560. */
  60561. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  60562. /**
  60563. * An event triggered when the pointer move out of the control.
  60564. */
  60565. onPointerOutObservable: BABYLON.Observable<Control>;
  60566. /**
  60567. * An event triggered when the pointer taps the control
  60568. */
  60569. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  60570. /**
  60571. * An event triggered when pointer up
  60572. */
  60573. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  60574. /**
  60575. * An event triggered when a control is clicked on
  60576. */
  60577. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  60578. /**
  60579. * An event triggered when pointer enters the control
  60580. */
  60581. onPointerEnterObservable: BABYLON.Observable<Control>;
  60582. /**
  60583. * An event triggered when the control is marked as dirty
  60584. */
  60585. onDirtyObservable: BABYLON.Observable<Control>;
  60586. /**
  60587. * An event triggered before drawing the control
  60588. */
  60589. onBeforeDrawObservable: BABYLON.Observable<Control>;
  60590. /**
  60591. * An event triggered after the control was drawn
  60592. */
  60593. onAfterDrawObservable: BABYLON.Observable<Control>;
  60594. /**
  60595. * Get the hosting AdvancedDynamicTexture
  60596. */
  60597. readonly host: AdvancedDynamicTexture;
  60598. /** Gets or set information about font offsets (used to render and align text) */
  60599. fontOffset: {
  60600. ascent: number;
  60601. height: number;
  60602. descent: number;
  60603. };
  60604. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  60605. alpha: number;
  60606. /**
  60607. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  60608. */
  60609. isHighlighted: boolean;
  60610. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  60611. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60612. */
  60613. scaleX: number;
  60614. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  60615. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60616. */
  60617. scaleY: number;
  60618. /** Gets or sets the rotation angle (0 by default)
  60619. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60620. */
  60621. rotation: number;
  60622. /** Gets or sets the transformation center on Y axis (0 by default)
  60623. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60624. */
  60625. transformCenterY: number;
  60626. /** Gets or sets the transformation center on X axis (0 by default)
  60627. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60628. */
  60629. transformCenterX: number;
  60630. /**
  60631. * Gets or sets the horizontal alignment
  60632. * @see http://doc.babylonjs.com/how_to/gui#alignments
  60633. */
  60634. horizontalAlignment: number;
  60635. /**
  60636. * Gets or sets the vertical alignment
  60637. * @see http://doc.babylonjs.com/how_to/gui#alignments
  60638. */
  60639. verticalAlignment: number;
  60640. /**
  60641. * Gets or sets control width
  60642. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60643. */
  60644. width: string | number;
  60645. /**
  60646. * Gets or sets the control width in pixel
  60647. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60648. */
  60649. widthInPixels: number;
  60650. /**
  60651. * Gets or sets control height
  60652. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60653. */
  60654. height: string | number;
  60655. /**
  60656. * Gets or sets control height in pixel
  60657. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60658. */
  60659. heightInPixels: number;
  60660. /** Gets or set font family */
  60661. fontFamily: string;
  60662. /** Gets or sets font style */
  60663. fontStyle: string;
  60664. /** Gets or sets font weight */
  60665. fontWeight: string;
  60666. /**
  60667. * Gets or sets style
  60668. * @see http://doc.babylonjs.com/how_to/gui#styles
  60669. */
  60670. style: BABYLON.Nullable<Style>;
  60671. /** @hidden */
  60672. readonly _isFontSizeInPercentage: boolean;
  60673. /** Gets or sets font size in pixels */
  60674. fontSizeInPixels: number;
  60675. /** Gets or sets font size */
  60676. fontSize: string | number;
  60677. /** Gets or sets foreground color */
  60678. color: string;
  60679. /** Gets or sets z index which is used to reorder controls on the z axis */
  60680. zIndex: number;
  60681. /** Gets or sets a boolean indicating if the control can be rendered */
  60682. notRenderable: boolean;
  60683. /** Gets or sets a boolean indicating if the control is visible */
  60684. isVisible: boolean;
  60685. /** Gets a boolean indicating that the control needs to update its rendering */
  60686. readonly isDirty: boolean;
  60687. /**
  60688. * Gets the current linked mesh (or null if none)
  60689. */
  60690. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  60691. /**
  60692. * Gets or sets a value indicating the padding to use on the left of the control
  60693. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60694. */
  60695. paddingLeft: string | number;
  60696. /**
  60697. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  60698. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60699. */
  60700. paddingLeftInPixels: number;
  60701. /**
  60702. * Gets or sets a value indicating the padding to use on the right of the control
  60703. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60704. */
  60705. paddingRight: string | number;
  60706. /**
  60707. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  60708. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60709. */
  60710. paddingRightInPixels: number;
  60711. /**
  60712. * Gets or sets a value indicating the padding to use on the top of the control
  60713. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60714. */
  60715. paddingTop: string | number;
  60716. /**
  60717. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  60718. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60719. */
  60720. paddingTopInPixels: number;
  60721. /**
  60722. * Gets or sets a value indicating the padding to use on the bottom of the control
  60723. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60724. */
  60725. paddingBottom: string | number;
  60726. /**
  60727. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  60728. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60729. */
  60730. paddingBottomInPixels: number;
  60731. /**
  60732. * Gets or sets a value indicating the left coordinate of the control
  60733. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60734. */
  60735. left: string | number;
  60736. /**
  60737. * Gets or sets a value indicating the left coordinate in pixels of the control
  60738. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60739. */
  60740. leftInPixels: number;
  60741. /**
  60742. * Gets or sets a value indicating the top coordinate of the control
  60743. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60744. */
  60745. top: string | number;
  60746. /**
  60747. * Gets or sets a value indicating the top coordinate in pixels of the control
  60748. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60749. */
  60750. topInPixels: number;
  60751. /**
  60752. * Gets or sets a value indicating the offset on X axis to the linked mesh
  60753. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60754. */
  60755. linkOffsetX: string | number;
  60756. /**
  60757. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  60758. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60759. */
  60760. linkOffsetXInPixels: number;
  60761. /**
  60762. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  60763. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60764. */
  60765. linkOffsetY: string | number;
  60766. /**
  60767. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  60768. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60769. */
  60770. linkOffsetYInPixels: number;
  60771. /** Gets the center coordinate on X axis */
  60772. readonly centerX: number;
  60773. /** Gets the center coordinate on Y axis */
  60774. readonly centerY: number;
  60775. /** Gets or sets if control is Enabled*/
  60776. isEnabled: boolean;
  60777. /** Gets or sets background color of control if it's disabled*/
  60778. disabledColor: string;
  60779. /**
  60780. * Creates a new control
  60781. * @param name defines the name of the control
  60782. */
  60783. constructor(
  60784. /** defines the name of the control */
  60785. name?: string | undefined);
  60786. /** @hidden */
  60787. protected _getTypeName(): string;
  60788. /**
  60789. * Gets the first ascendant in the hierarchy of the given type
  60790. * @param className defines the required type
  60791. * @returns the ascendant or null if not found
  60792. */
  60793. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  60794. /** @hidden */
  60795. _resetFontCache(): void;
  60796. /**
  60797. * Determines if a container is an ascendant of the current control
  60798. * @param container defines the container to look for
  60799. * @returns true if the container is one of the ascendant of the control
  60800. */
  60801. isAscendant(container: Control): boolean;
  60802. /**
  60803. * Gets coordinates in local control space
  60804. * @param globalCoordinates defines the coordinates to transform
  60805. * @returns the new coordinates in local space
  60806. */
  60807. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  60808. /**
  60809. * Gets coordinates in local control space
  60810. * @param globalCoordinates defines the coordinates to transform
  60811. * @param result defines the target vector2 where to store the result
  60812. * @returns the current control
  60813. */
  60814. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  60815. /**
  60816. * Gets coordinates in parent local control space
  60817. * @param globalCoordinates defines the coordinates to transform
  60818. * @returns the new coordinates in parent local space
  60819. */
  60820. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  60821. /**
  60822. * Move the current control to a vector3 position projected onto the screen.
  60823. * @param position defines the target position
  60824. * @param scene defines the hosting scene
  60825. */
  60826. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  60827. /** @hidden */
  60828. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  60829. /**
  60830. * Will return all controls that have this control as ascendant
  60831. * @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
  60832. * @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
  60833. * @return all child controls
  60834. */
  60835. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  60836. /**
  60837. * Link current control with a target mesh
  60838. * @param mesh defines the mesh to link with
  60839. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60840. */
  60841. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  60842. /** @hidden */
  60843. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  60844. /** @hidden */
  60845. _offsetLeft(offset: number): void;
  60846. /** @hidden */
  60847. _offsetTop(offset: number): void;
  60848. /** @hidden */
  60849. _markMatrixAsDirty(): void;
  60850. /** @hidden */
  60851. _flagDescendantsAsMatrixDirty(): void;
  60852. /** @hidden */
  60853. _intersectsRect(rect: Measure): boolean;
  60854. /** @hidden */
  60855. protected invalidateRect(): void;
  60856. /** @hidden */
  60857. _markAsDirty(force?: boolean): void;
  60858. /** @hidden */
  60859. _markAllAsDirty(): void;
  60860. /** @hidden */
  60861. _link(host: AdvancedDynamicTexture): void;
  60862. /** @hidden */
  60863. protected _transform(context?: CanvasRenderingContext2D): void;
  60864. /** @hidden */
  60865. _renderHighlight(context: CanvasRenderingContext2D): void;
  60866. /** @hidden */
  60867. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  60868. /** @hidden */
  60869. protected _applyStates(context: CanvasRenderingContext2D): void;
  60870. /** @hidden */
  60871. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  60872. /** @hidden */
  60873. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60874. protected _evaluateClippingState(parentMeasure: Measure): void;
  60875. /** @hidden */
  60876. _measure(): void;
  60877. /** @hidden */
  60878. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60879. /** @hidden */
  60880. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60881. /** @hidden */
  60882. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60883. /** @hidden */
  60884. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60885. private static _ClipMeasure;
  60886. private _tmpMeasureA;
  60887. private _clip;
  60888. /** @hidden */
  60889. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  60890. /** @hidden */
  60891. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  60892. /**
  60893. * Tests if a given coordinates belong to the current control
  60894. * @param x defines x coordinate to test
  60895. * @param y defines y coordinate to test
  60896. * @returns true if the coordinates are inside the control
  60897. */
  60898. contains(x: number, y: number): boolean;
  60899. /** @hidden */
  60900. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60901. /** @hidden */
  60902. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  60903. /** @hidden */
  60904. _onPointerEnter(target: Control): boolean;
  60905. /** @hidden */
  60906. _onPointerOut(target: Control, force?: boolean): void;
  60907. /** @hidden */
  60908. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60909. /** @hidden */
  60910. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60911. /** @hidden */
  60912. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  60913. /** @hidden */
  60914. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  60915. private _prepareFont;
  60916. /** Releases associated resources */
  60917. dispose(): void;
  60918. private static _HORIZONTAL_ALIGNMENT_LEFT;
  60919. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  60920. private static _HORIZONTAL_ALIGNMENT_CENTER;
  60921. private static _VERTICAL_ALIGNMENT_TOP;
  60922. private static _VERTICAL_ALIGNMENT_BOTTOM;
  60923. private static _VERTICAL_ALIGNMENT_CENTER;
  60924. /** HORIZONTAL_ALIGNMENT_LEFT */
  60925. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  60926. /** HORIZONTAL_ALIGNMENT_RIGHT */
  60927. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  60928. /** HORIZONTAL_ALIGNMENT_CENTER */
  60929. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  60930. /** VERTICAL_ALIGNMENT_TOP */
  60931. static readonly VERTICAL_ALIGNMENT_TOP: number;
  60932. /** VERTICAL_ALIGNMENT_BOTTOM */
  60933. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  60934. /** VERTICAL_ALIGNMENT_CENTER */
  60935. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  60936. private static _FontHeightSizes;
  60937. /** @hidden */
  60938. static _GetFontOffset(font: string): {
  60939. ascent: number;
  60940. height: number;
  60941. descent: number;
  60942. };
  60943. /**
  60944. * Creates a stack panel that can be used to render headers
  60945. * @param control defines the control to associate with the header
  60946. * @param text defines the text of the header
  60947. * @param size defines the size of the header
  60948. * @param options defines options used to configure the header
  60949. * @returns a new StackPanel
  60950. * @ignore
  60951. * @hidden
  60952. */
  60953. static AddHeader: (control: Control, text: string, size: string | number, options: {
  60954. isHorizontal: boolean;
  60955. controlFirst: boolean;
  60956. }) => any;
  60957. /** @hidden */
  60958. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  60959. }
  60960. }
  60961. declare module BABYLON.GUI {
  60962. /**
  60963. * Root class for 2D containers
  60964. * @see http://doc.babylonjs.com/how_to/gui#containers
  60965. */
  60966. export class Container extends Control {
  60967. name?: string | undefined;
  60968. /** @hidden */
  60969. protected _children: Control[];
  60970. /** @hidden */
  60971. protected _measureForChildren: Measure;
  60972. /** @hidden */
  60973. protected _background: string;
  60974. /** @hidden */
  60975. protected _adaptWidthToChildren: boolean;
  60976. /** @hidden */
  60977. protected _adaptHeightToChildren: boolean;
  60978. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  60979. adaptHeightToChildren: boolean;
  60980. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  60981. adaptWidthToChildren: boolean;
  60982. /** Gets or sets background color */
  60983. background: string;
  60984. /** Gets the list of children */
  60985. readonly children: Control[];
  60986. /**
  60987. * Creates a new Container
  60988. * @param name defines the name of the container
  60989. */
  60990. constructor(name?: string | undefined);
  60991. protected _getTypeName(): string;
  60992. _flagDescendantsAsMatrixDirty(): void;
  60993. /**
  60994. * Gets a child using its name
  60995. * @param name defines the child name to look for
  60996. * @returns the child control if found
  60997. */
  60998. getChildByName(name: string): BABYLON.Nullable<Control>;
  60999. /**
  61000. * Gets a child using its type and its name
  61001. * @param name defines the child name to look for
  61002. * @param type defines the child type to look for
  61003. * @returns the child control if found
  61004. */
  61005. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  61006. /**
  61007. * Search for a specific control in children
  61008. * @param control defines the control to look for
  61009. * @returns true if the control is in child list
  61010. */
  61011. containsControl(control: Control): boolean;
  61012. /**
  61013. * Adds a new control to the current container
  61014. * @param control defines the control to add
  61015. * @returns the current container
  61016. */
  61017. addControl(control: BABYLON.Nullable<Control>): Container;
  61018. /**
  61019. * Removes all controls from the current container
  61020. * @returns the current container
  61021. */
  61022. clearControls(): Container;
  61023. /**
  61024. * Removes a control from the current container
  61025. * @param control defines the control to remove
  61026. * @returns the current container
  61027. */
  61028. removeControl(control: Control): Container;
  61029. /** @hidden */
  61030. _reOrderControl(control: Control): void;
  61031. /** @hidden */
  61032. _offsetLeft(offset: number): void;
  61033. /** @hidden */
  61034. _offsetTop(offset: number): void;
  61035. /** @hidden */
  61036. _markAllAsDirty(): void;
  61037. /** @hidden */
  61038. protected _localDraw(context: CanvasRenderingContext2D): void;
  61039. /** @hidden */
  61040. _link(host: AdvancedDynamicTexture): void;
  61041. /** @hidden */
  61042. protected _beforeLayout(): void;
  61043. /** @hidden */
  61044. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61045. /** @hidden */
  61046. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  61047. protected _postMeasure(): void;
  61048. /** @hidden */
  61049. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  61050. /** @hidden */
  61051. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  61052. /** @hidden */
  61053. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61054. /** @hidden */
  61055. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61056. /** Releases associated resources */
  61057. dispose(): void;
  61058. }
  61059. }
  61060. declare module BABYLON.GUI {
  61061. /** Class used to create rectangle container */
  61062. export class Rectangle extends Container {
  61063. name?: string | undefined;
  61064. private _thickness;
  61065. private _cornerRadius;
  61066. /** Gets or sets border thickness */
  61067. thickness: number;
  61068. /** Gets or sets the corner radius angle */
  61069. cornerRadius: number;
  61070. /**
  61071. * Creates a new Rectangle
  61072. * @param name defines the control name
  61073. */
  61074. constructor(name?: string | undefined);
  61075. protected _getTypeName(): string;
  61076. protected _localDraw(context: CanvasRenderingContext2D): void;
  61077. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61078. private _drawRoundedRect;
  61079. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61080. }
  61081. }
  61082. declare module BABYLON.GUI {
  61083. /**
  61084. * Enum that determines the text-wrapping mode to use.
  61085. */
  61086. export enum TextWrapping {
  61087. /**
  61088. * Clip the text when it's larger than Control.width; this is the default mode.
  61089. */
  61090. Clip = 0,
  61091. /**
  61092. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  61093. */
  61094. WordWrap = 1,
  61095. /**
  61096. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  61097. */
  61098. Ellipsis = 2
  61099. }
  61100. /**
  61101. * Class used to create text block control
  61102. */
  61103. export class TextBlock extends Control {
  61104. /**
  61105. * Defines the name of the control
  61106. */
  61107. name?: string | undefined;
  61108. private _text;
  61109. private _textWrapping;
  61110. private _textHorizontalAlignment;
  61111. private _textVerticalAlignment;
  61112. private _lines;
  61113. private _resizeToFit;
  61114. private _lineSpacing;
  61115. private _outlineWidth;
  61116. private _outlineColor;
  61117. /**
  61118. * An event triggered after the text is changed
  61119. */
  61120. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  61121. /**
  61122. * An event triggered after the text was broken up into lines
  61123. */
  61124. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  61125. /**
  61126. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  61127. */
  61128. readonly lines: any[];
  61129. /**
  61130. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  61131. */
  61132. /**
  61133. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  61134. */
  61135. resizeToFit: boolean;
  61136. /**
  61137. * Gets or sets a boolean indicating if text must be wrapped
  61138. */
  61139. /**
  61140. * Gets or sets a boolean indicating if text must be wrapped
  61141. */
  61142. textWrapping: TextWrapping | boolean;
  61143. /**
  61144. * Gets or sets text to display
  61145. */
  61146. /**
  61147. * Gets or sets text to display
  61148. */
  61149. text: string;
  61150. /**
  61151. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  61152. */
  61153. /**
  61154. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  61155. */
  61156. textHorizontalAlignment: number;
  61157. /**
  61158. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  61159. */
  61160. /**
  61161. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  61162. */
  61163. textVerticalAlignment: number;
  61164. /**
  61165. * Gets or sets line spacing value
  61166. */
  61167. /**
  61168. * Gets or sets line spacing value
  61169. */
  61170. lineSpacing: string | number;
  61171. /**
  61172. * Gets or sets outlineWidth of the text to display
  61173. */
  61174. /**
  61175. * Gets or sets outlineWidth of the text to display
  61176. */
  61177. outlineWidth: number;
  61178. /**
  61179. * Gets or sets outlineColor of the text to display
  61180. */
  61181. /**
  61182. * Gets or sets outlineColor of the text to display
  61183. */
  61184. outlineColor: string;
  61185. /**
  61186. * Creates a new TextBlock object
  61187. * @param name defines the name of the control
  61188. * @param text defines the text to display (emptry string by default)
  61189. */
  61190. constructor(
  61191. /**
  61192. * Defines the name of the control
  61193. */
  61194. name?: string | undefined, text?: string);
  61195. protected _getTypeName(): string;
  61196. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61197. private _drawText;
  61198. /** @hidden */
  61199. _draw(context: CanvasRenderingContext2D): void;
  61200. protected _applyStates(context: CanvasRenderingContext2D): void;
  61201. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  61202. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  61203. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  61204. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  61205. protected _renderLines(context: CanvasRenderingContext2D): void;
  61206. /**
  61207. * Given a width constraint applied on the text block, find the expected height
  61208. * @returns expected height
  61209. */
  61210. computeExpectedHeight(): number;
  61211. dispose(): void;
  61212. }
  61213. }
  61214. declare module BABYLON.GUI {
  61215. /**
  61216. * Class used to create 2D images
  61217. */
  61218. export class Image extends Control {
  61219. name?: string | undefined;
  61220. private static _WorkingCanvas;
  61221. private _domImage;
  61222. private _imageWidth;
  61223. private _imageHeight;
  61224. private _loaded;
  61225. private _stretch;
  61226. private _source;
  61227. private _autoScale;
  61228. private _sourceLeft;
  61229. private _sourceTop;
  61230. private _sourceWidth;
  61231. private _sourceHeight;
  61232. private _cellWidth;
  61233. private _cellHeight;
  61234. private _cellId;
  61235. private _populateNinePatchSlicesFromImage;
  61236. private _sliceLeft;
  61237. private _sliceRight;
  61238. private _sliceTop;
  61239. private _sliceBottom;
  61240. private _detectPointerOnOpaqueOnly;
  61241. /**
  61242. * BABYLON.Observable notified when the content is loaded
  61243. */
  61244. onImageLoadedObservable: BABYLON.Observable<Image>;
  61245. /**
  61246. * Gets a boolean indicating that the content is loaded
  61247. */
  61248. readonly isLoaded: boolean;
  61249. /**
  61250. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  61251. */
  61252. populateNinePatchSlicesFromImage: boolean;
  61253. /**
  61254. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  61255. * Beware using this as this will comsume more memory as the image has to be stored twice
  61256. */
  61257. detectPointerOnOpaqueOnly: boolean;
  61258. /**
  61259. * Gets or sets the left value for slicing (9-patch)
  61260. */
  61261. sliceLeft: number;
  61262. /**
  61263. * Gets or sets the right value for slicing (9-patch)
  61264. */
  61265. sliceRight: number;
  61266. /**
  61267. * Gets or sets the top value for slicing (9-patch)
  61268. */
  61269. sliceTop: number;
  61270. /**
  61271. * Gets or sets the bottom value for slicing (9-patch)
  61272. */
  61273. sliceBottom: number;
  61274. /**
  61275. * Gets or sets the left coordinate in the source image
  61276. */
  61277. sourceLeft: number;
  61278. /**
  61279. * Gets or sets the top coordinate in the source image
  61280. */
  61281. sourceTop: number;
  61282. /**
  61283. * Gets or sets the width to capture in the source image
  61284. */
  61285. sourceWidth: number;
  61286. /**
  61287. * Gets or sets the height to capture in the source image
  61288. */
  61289. sourceHeight: number;
  61290. /**
  61291. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  61292. * @see http://doc.babylonjs.com/how_to/gui#image
  61293. */
  61294. autoScale: boolean;
  61295. /** Gets or sets the streching mode used by the image */
  61296. stretch: number;
  61297. /**
  61298. * Gets or sets the internal DOM image used to render the control
  61299. */
  61300. domImage: HTMLImageElement;
  61301. private _onImageLoaded;
  61302. private _extractNinePatchSliceDataFromImage;
  61303. /**
  61304. * Gets or sets image source url
  61305. */
  61306. source: BABYLON.Nullable<string>;
  61307. /**
  61308. * Gets or sets the cell width to use when animation sheet is enabled
  61309. * @see http://doc.babylonjs.com/how_to/gui#image
  61310. */
  61311. cellWidth: number;
  61312. /**
  61313. * Gets or sets the cell height to use when animation sheet is enabled
  61314. * @see http://doc.babylonjs.com/how_to/gui#image
  61315. */
  61316. cellHeight: number;
  61317. /**
  61318. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  61319. * @see http://doc.babylonjs.com/how_to/gui#image
  61320. */
  61321. cellId: number;
  61322. /**
  61323. * Creates a new Image
  61324. * @param name defines the control name
  61325. * @param url defines the image url
  61326. */
  61327. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  61328. /**
  61329. * Tests if a given coordinates belong to the current control
  61330. * @param x defines x coordinate to test
  61331. * @param y defines y coordinate to test
  61332. * @returns true if the coordinates are inside the control
  61333. */
  61334. contains(x: number, y: number): boolean;
  61335. protected _getTypeName(): string;
  61336. /** Force the control to synchronize with its content */
  61337. synchronizeSizeWithContent(): void;
  61338. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61339. private _prepareWorkingCanvasForOpaqueDetection;
  61340. private _drawImage;
  61341. _draw(context: CanvasRenderingContext2D): void;
  61342. private _renderCornerPatch;
  61343. private _renderNinePatch;
  61344. dispose(): void;
  61345. /** STRETCH_NONE */
  61346. static readonly STRETCH_NONE: number;
  61347. /** STRETCH_FILL */
  61348. static readonly STRETCH_FILL: number;
  61349. /** STRETCH_UNIFORM */
  61350. static readonly STRETCH_UNIFORM: number;
  61351. /** STRETCH_EXTEND */
  61352. static readonly STRETCH_EXTEND: number;
  61353. /** NINE_PATCH */
  61354. static readonly STRETCH_NINE_PATCH: number;
  61355. }
  61356. }
  61357. declare module BABYLON.GUI {
  61358. /**
  61359. * Class used to create 2D buttons
  61360. */
  61361. export class Button extends Rectangle {
  61362. name?: string | undefined;
  61363. /**
  61364. * Function called to generate a pointer enter animation
  61365. */
  61366. pointerEnterAnimation: () => void;
  61367. /**
  61368. * Function called to generate a pointer out animation
  61369. */
  61370. pointerOutAnimation: () => void;
  61371. /**
  61372. * Function called to generate a pointer down animation
  61373. */
  61374. pointerDownAnimation: () => void;
  61375. /**
  61376. * Function called to generate a pointer up animation
  61377. */
  61378. pointerUpAnimation: () => void;
  61379. private _image;
  61380. /**
  61381. * Returns the image part of the button (if any)
  61382. */
  61383. readonly image: BABYLON.Nullable<Image>;
  61384. private _textBlock;
  61385. /**
  61386. * Returns the image part of the button (if any)
  61387. */
  61388. readonly textBlock: BABYLON.Nullable<TextBlock>;
  61389. /**
  61390. * Creates a new Button
  61391. * @param name defines the name of the button
  61392. */
  61393. constructor(name?: string | undefined);
  61394. protected _getTypeName(): string;
  61395. /** @hidden */
  61396. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61397. /** @hidden */
  61398. _onPointerEnter(target: Control): boolean;
  61399. /** @hidden */
  61400. _onPointerOut(target: Control, force?: boolean): void;
  61401. /** @hidden */
  61402. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61403. /** @hidden */
  61404. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61405. /**
  61406. * Creates a new button made with an image and a text
  61407. * @param name defines the name of the button
  61408. * @param text defines the text of the button
  61409. * @param imageUrl defines the url of the image
  61410. * @returns a new Button
  61411. */
  61412. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  61413. /**
  61414. * Creates a new button made with an image
  61415. * @param name defines the name of the button
  61416. * @param imageUrl defines the url of the image
  61417. * @returns a new Button
  61418. */
  61419. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  61420. /**
  61421. * Creates a new button made with a text
  61422. * @param name defines the name of the button
  61423. * @param text defines the text of the button
  61424. * @returns a new Button
  61425. */
  61426. static CreateSimpleButton(name: string, text: string): Button;
  61427. /**
  61428. * Creates a new button made with an image and a centered text
  61429. * @param name defines the name of the button
  61430. * @param text defines the text of the button
  61431. * @param imageUrl defines the url of the image
  61432. * @returns a new Button
  61433. */
  61434. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  61435. }
  61436. }
  61437. declare module BABYLON.GUI {
  61438. /**
  61439. * Class used to create a 2D stack panel container
  61440. */
  61441. export class StackPanel extends Container {
  61442. name?: string | undefined;
  61443. private _isVertical;
  61444. private _manualWidth;
  61445. private _manualHeight;
  61446. private _doNotTrackManualChanges;
  61447. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  61448. isVertical: boolean;
  61449. /**
  61450. * Gets or sets panel width.
  61451. * This value should not be set when in horizontal mode as it will be computed automatically
  61452. */
  61453. width: string | number;
  61454. /**
  61455. * Gets or sets panel height.
  61456. * This value should not be set when in vertical mode as it will be computed automatically
  61457. */
  61458. height: string | number;
  61459. /**
  61460. * Creates a new StackPanel
  61461. * @param name defines control name
  61462. */
  61463. constructor(name?: string | undefined);
  61464. protected _getTypeName(): string;
  61465. /** @hidden */
  61466. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61467. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61468. protected _postMeasure(): void;
  61469. }
  61470. }
  61471. declare module BABYLON.GUI {
  61472. /**
  61473. * Class used to represent a 2D checkbox
  61474. */
  61475. export class Checkbox extends Control {
  61476. name?: string | undefined;
  61477. private _isChecked;
  61478. private _background;
  61479. private _checkSizeRatio;
  61480. private _thickness;
  61481. /** Gets or sets border thickness */
  61482. thickness: number;
  61483. /**
  61484. * BABYLON.Observable raised when isChecked property changes
  61485. */
  61486. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  61487. /** Gets or sets a value indicating the ratio between overall size and check size */
  61488. checkSizeRatio: number;
  61489. /** Gets or sets background color */
  61490. background: string;
  61491. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  61492. isChecked: boolean;
  61493. /**
  61494. * Creates a new CheckBox
  61495. * @param name defines the control name
  61496. */
  61497. constructor(name?: string | undefined);
  61498. protected _getTypeName(): string;
  61499. /** @hidden */
  61500. _draw(context: CanvasRenderingContext2D): void;
  61501. /** @hidden */
  61502. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61503. /**
  61504. * Utility function to easily create a checkbox with a header
  61505. * @param title defines the label to use for the header
  61506. * @param onValueChanged defines the callback to call when value changes
  61507. * @returns a StackPanel containing the checkbox and a textBlock
  61508. */
  61509. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  61510. }
  61511. }
  61512. declare module BABYLON.GUI {
  61513. /**
  61514. * Class used to store key control properties
  61515. */
  61516. export class KeyPropertySet {
  61517. /** Width */
  61518. width?: string;
  61519. /** Height */
  61520. height?: string;
  61521. /** Left padding */
  61522. paddingLeft?: string;
  61523. /** Right padding */
  61524. paddingRight?: string;
  61525. /** Top padding */
  61526. paddingTop?: string;
  61527. /** Bottom padding */
  61528. paddingBottom?: string;
  61529. /** Foreground color */
  61530. color?: string;
  61531. /** Background color */
  61532. background?: string;
  61533. }
  61534. /**
  61535. * Class used to create virtual keyboard
  61536. */
  61537. export class VirtualKeyboard extends StackPanel {
  61538. /** BABYLON.Observable raised when a key is pressed */
  61539. onKeyPressObservable: BABYLON.Observable<string>;
  61540. /** Gets or sets default key button width */
  61541. defaultButtonWidth: string;
  61542. /** Gets or sets default key button height */
  61543. defaultButtonHeight: string;
  61544. /** Gets or sets default key button left padding */
  61545. defaultButtonPaddingLeft: string;
  61546. /** Gets or sets default key button right padding */
  61547. defaultButtonPaddingRight: string;
  61548. /** Gets or sets default key button top padding */
  61549. defaultButtonPaddingTop: string;
  61550. /** Gets or sets default key button bottom padding */
  61551. defaultButtonPaddingBottom: string;
  61552. /** Gets or sets default key button foreground color */
  61553. defaultButtonColor: string;
  61554. /** Gets or sets default key button background color */
  61555. defaultButtonBackground: string;
  61556. /** Gets or sets shift button foreground color */
  61557. shiftButtonColor: string;
  61558. /** Gets or sets shift button thickness*/
  61559. selectedShiftThickness: number;
  61560. /** Gets shift key state */
  61561. shiftState: number;
  61562. protected _getTypeName(): string;
  61563. private _createKey;
  61564. /**
  61565. * Adds a new row of keys
  61566. * @param keys defines the list of keys to add
  61567. * @param propertySets defines the associated property sets
  61568. */
  61569. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  61570. /**
  61571. * Set the shift key to a specific state
  61572. * @param shiftState defines the new shift state
  61573. */
  61574. applyShiftState(shiftState: number): void;
  61575. private _currentlyConnectedInputText;
  61576. private _connectedInputTexts;
  61577. private _onKeyPressObserver;
  61578. /** Gets the input text control currently attached to the keyboard */
  61579. readonly connectedInputText: BABYLON.Nullable<InputText>;
  61580. /**
  61581. * Connects the keyboard with an input text control
  61582. *
  61583. * @param input defines the target control
  61584. */
  61585. connect(input: InputText): void;
  61586. /**
  61587. * Disconnects the keyboard from connected InputText controls
  61588. *
  61589. * @param input optionally defines a target control, otherwise all are disconnected
  61590. */
  61591. disconnect(input?: InputText): void;
  61592. private _removeConnectedInputObservables;
  61593. /**
  61594. * Release all resources
  61595. */
  61596. dispose(): void;
  61597. /**
  61598. * Creates a new keyboard using a default layout
  61599. *
  61600. * @param name defines control name
  61601. * @returns a new VirtualKeyboard
  61602. */
  61603. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  61604. }
  61605. }
  61606. declare module BABYLON.GUI {
  61607. /**
  61608. * Class used to create input text control
  61609. */
  61610. export class InputText extends Control implements IFocusableControl {
  61611. name?: string | undefined;
  61612. private _text;
  61613. private _placeholderText;
  61614. private _background;
  61615. private _focusedBackground;
  61616. private _focusedColor;
  61617. private _placeholderColor;
  61618. private _thickness;
  61619. private _margin;
  61620. private _autoStretchWidth;
  61621. private _maxWidth;
  61622. private _isFocused;
  61623. private _blinkTimeout;
  61624. private _blinkIsEven;
  61625. private _cursorOffset;
  61626. private _scrollLeft;
  61627. private _textWidth;
  61628. private _clickedCoordinate;
  61629. private _deadKey;
  61630. private _addKey;
  61631. private _currentKey;
  61632. private _isTextHighlightOn;
  61633. private _textHighlightColor;
  61634. private _highligherOpacity;
  61635. private _highlightedText;
  61636. private _startHighlightIndex;
  61637. private _endHighlightIndex;
  61638. private _cursorIndex;
  61639. private _onFocusSelectAll;
  61640. private _isPointerDown;
  61641. private _onClipboardObserver;
  61642. private _onPointerDblTapObserver;
  61643. /** @hidden */
  61644. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  61645. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  61646. promptMessage: string;
  61647. /** BABYLON.Observable raised when the text changes */
  61648. onTextChangedObservable: BABYLON.Observable<InputText>;
  61649. /** BABYLON.Observable raised just before an entered character is to be added */
  61650. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  61651. /** BABYLON.Observable raised when the control gets the focus */
  61652. onFocusObservable: BABYLON.Observable<InputText>;
  61653. /** BABYLON.Observable raised when the control loses the focus */
  61654. onBlurObservable: BABYLON.Observable<InputText>;
  61655. /**Observable raised when the text is highlighted */
  61656. onTextHighlightObservable: BABYLON.Observable<InputText>;
  61657. /**Observable raised when copy event is triggered */
  61658. onTextCopyObservable: BABYLON.Observable<InputText>;
  61659. /** BABYLON.Observable raised when cut event is triggered */
  61660. onTextCutObservable: BABYLON.Observable<InputText>;
  61661. /** BABYLON.Observable raised when paste event is triggered */
  61662. onTextPasteObservable: BABYLON.Observable<InputText>;
  61663. /** BABYLON.Observable raised when a key event was processed */
  61664. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  61665. /** Gets or sets the maximum width allowed by the control */
  61666. maxWidth: string | number;
  61667. /** Gets the maximum width allowed by the control in pixels */
  61668. readonly maxWidthInPixels: number;
  61669. /** Gets or sets the text highlighter transparency; default: 0.4 */
  61670. highligherOpacity: number;
  61671. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  61672. onFocusSelectAll: boolean;
  61673. /** Gets or sets the text hightlight color */
  61674. textHighlightColor: string;
  61675. /** Gets or sets control margin */
  61676. margin: string;
  61677. /** Gets control margin in pixels */
  61678. readonly marginInPixels: number;
  61679. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  61680. autoStretchWidth: boolean;
  61681. /** Gets or sets border thickness */
  61682. thickness: number;
  61683. /** Gets or sets the background color when focused */
  61684. focusedBackground: string;
  61685. /** Gets or sets the background color when focused */
  61686. focusedColor: string;
  61687. /** Gets or sets the background color */
  61688. background: string;
  61689. /** Gets or sets the placeholder color */
  61690. placeholderColor: string;
  61691. /** Gets or sets the text displayed when the control is empty */
  61692. placeholderText: string;
  61693. /** Gets or sets the dead key flag */
  61694. deadKey: boolean;
  61695. /** Gets or sets the highlight text */
  61696. highlightedText: string;
  61697. /** Gets or sets if the current key should be added */
  61698. addKey: boolean;
  61699. /** Gets or sets the value of the current key being entered */
  61700. currentKey: string;
  61701. /** Gets or sets the text displayed in the control */
  61702. text: string;
  61703. /** Gets or sets control width */
  61704. width: string | number;
  61705. /**
  61706. * Creates a new InputText
  61707. * @param name defines the control name
  61708. * @param text defines the text of the control
  61709. */
  61710. constructor(name?: string | undefined, text?: string);
  61711. /** @hidden */
  61712. onBlur(): void;
  61713. /** @hidden */
  61714. onFocus(): void;
  61715. protected _getTypeName(): string;
  61716. /**
  61717. * Function called to get the list of controls that should not steal the focus from this control
  61718. * @returns an array of controls
  61719. */
  61720. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  61721. /** @hidden */
  61722. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  61723. /** @hidden */
  61724. private _updateValueFromCursorIndex;
  61725. /** @hidden */
  61726. private _processDblClick;
  61727. /** @hidden */
  61728. private _selectAllText;
  61729. /**
  61730. * Handles the keyboard event
  61731. * @param evt Defines the KeyboardEvent
  61732. */
  61733. processKeyboard(evt: KeyboardEvent): void;
  61734. /** @hidden */
  61735. private _onCopyText;
  61736. /** @hidden */
  61737. private _onCutText;
  61738. /** @hidden */
  61739. private _onPasteText;
  61740. _draw(context: CanvasRenderingContext2D): void;
  61741. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61742. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61743. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61744. protected _beforeRenderText(text: string): string;
  61745. dispose(): void;
  61746. }
  61747. }
  61748. declare module BABYLON.GUI {
  61749. /**
  61750. * Class used to create a 2D grid container
  61751. */
  61752. export class Grid extends Container {
  61753. name?: string | undefined;
  61754. private _rowDefinitions;
  61755. private _columnDefinitions;
  61756. private _cells;
  61757. private _childControls;
  61758. /**
  61759. * Gets the number of columns
  61760. */
  61761. readonly columnCount: number;
  61762. /**
  61763. * Gets the number of rows
  61764. */
  61765. readonly rowCount: number;
  61766. /** Gets the list of children */
  61767. readonly children: Control[];
  61768. /** Gets the list of cells (e.g. the containers) */
  61769. readonly cells: {
  61770. [key: string]: Container;
  61771. };
  61772. /**
  61773. * Gets the definition of a specific row
  61774. * @param index defines the index of the row
  61775. * @returns the row definition
  61776. */
  61777. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  61778. /**
  61779. * Gets the definition of a specific column
  61780. * @param index defines the index of the column
  61781. * @returns the column definition
  61782. */
  61783. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  61784. /**
  61785. * Adds a new row to the grid
  61786. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  61787. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  61788. * @returns the current grid
  61789. */
  61790. addRowDefinition(height: number, isPixel?: boolean): Grid;
  61791. /**
  61792. * Adds a new column to the grid
  61793. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  61794. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  61795. * @returns the current grid
  61796. */
  61797. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  61798. /**
  61799. * Update a row definition
  61800. * @param index defines the index of the row to update
  61801. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  61802. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  61803. * @returns the current grid
  61804. */
  61805. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  61806. /**
  61807. * Update a column definition
  61808. * @param index defines the index of the column to update
  61809. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  61810. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  61811. * @returns the current grid
  61812. */
  61813. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  61814. /**
  61815. * Gets the list of children stored in a specific cell
  61816. * @param row defines the row to check
  61817. * @param column defines the column to check
  61818. * @returns the list of controls
  61819. */
  61820. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  61821. /**
  61822. * Gets a string representing the child cell info (row x column)
  61823. * @param child defines the control to get info from
  61824. * @returns a string containing the child cell info (row x column)
  61825. */
  61826. getChildCellInfo(child: Control): string;
  61827. private _removeCell;
  61828. private _offsetCell;
  61829. /**
  61830. * Remove a column definition at specified index
  61831. * @param index defines the index of the column to remove
  61832. * @returns the current grid
  61833. */
  61834. removeColumnDefinition(index: number): Grid;
  61835. /**
  61836. * Remove a row definition at specified index
  61837. * @param index defines the index of the row to remove
  61838. * @returns the current grid
  61839. */
  61840. removeRowDefinition(index: number): Grid;
  61841. /**
  61842. * Adds a new control to the current grid
  61843. * @param control defines the control to add
  61844. * @param row defines the row where to add the control (0 by default)
  61845. * @param column defines the column where to add the control (0 by default)
  61846. * @returns the current grid
  61847. */
  61848. addControl(control: Control, row?: number, column?: number): Grid;
  61849. /**
  61850. * Removes a control from the current container
  61851. * @param control defines the control to remove
  61852. * @returns the current container
  61853. */
  61854. removeControl(control: Control): Container;
  61855. /**
  61856. * Creates a new Grid
  61857. * @param name defines control name
  61858. */
  61859. constructor(name?: string | undefined);
  61860. protected _getTypeName(): string;
  61861. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  61862. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61863. _flagDescendantsAsMatrixDirty(): void;
  61864. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61865. /** Releases associated resources */
  61866. dispose(): void;
  61867. }
  61868. }
  61869. declare module BABYLON.GUI {
  61870. /** Class used to create color pickers */
  61871. export class ColorPicker extends Control {
  61872. name?: string | undefined;
  61873. private static _Epsilon;
  61874. private _colorWheelCanvas;
  61875. private _value;
  61876. private _tmpColor;
  61877. private _pointerStartedOnSquare;
  61878. private _pointerStartedOnWheel;
  61879. private _squareLeft;
  61880. private _squareTop;
  61881. private _squareSize;
  61882. private _h;
  61883. private _s;
  61884. private _v;
  61885. private _lastPointerDownID;
  61886. /**
  61887. * BABYLON.Observable raised when the value changes
  61888. */
  61889. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  61890. /** Gets or sets the color of the color picker */
  61891. value: BABYLON.Color3;
  61892. /**
  61893. * Gets or sets control width
  61894. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61895. */
  61896. width: string | number;
  61897. /**
  61898. * Gets or sets control height
  61899. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61900. */
  61901. /** Gets or sets control height */
  61902. height: string | number;
  61903. /** Gets or sets control size */
  61904. size: string | number;
  61905. /**
  61906. * Creates a new ColorPicker
  61907. * @param name defines the control name
  61908. */
  61909. constructor(name?: string | undefined);
  61910. protected _getTypeName(): string;
  61911. /** @hidden */
  61912. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61913. private _updateSquareProps;
  61914. private _drawGradientSquare;
  61915. private _drawCircle;
  61916. private _createColorWheelCanvas;
  61917. /** @hidden */
  61918. _draw(context: CanvasRenderingContext2D): void;
  61919. private _pointerIsDown;
  61920. private _updateValueFromPointer;
  61921. private _isPointOnSquare;
  61922. private _isPointOnWheel;
  61923. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61924. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61925. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61926. /**
  61927. * This function expands the color picker by creating a color picker dialog with manual
  61928. * color value input and the ability to save colors into an array to be used later in
  61929. * subsequent launches of the dialogue.
  61930. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  61931. * @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.
  61932. * @returns picked color as a hex string and the saved colors array as hex strings.
  61933. */
  61934. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  61935. pickerWidth?: string;
  61936. pickerHeight?: string;
  61937. headerHeight?: string;
  61938. lastColor?: string;
  61939. swatchLimit?: number;
  61940. numSwatchesPerLine?: number;
  61941. savedColors?: Array<string>;
  61942. }): Promise<{
  61943. savedColors?: string[];
  61944. pickedColor: string;
  61945. }>;
  61946. }
  61947. }
  61948. declare module BABYLON.GUI {
  61949. /** Class used to create 2D ellipse containers */
  61950. export class Ellipse extends Container {
  61951. name?: string | undefined;
  61952. private _thickness;
  61953. /** Gets or sets border thickness */
  61954. thickness: number;
  61955. /**
  61956. * Creates a new Ellipse
  61957. * @param name defines the control name
  61958. */
  61959. constructor(name?: string | undefined);
  61960. protected _getTypeName(): string;
  61961. protected _localDraw(context: CanvasRenderingContext2D): void;
  61962. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61963. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61964. }
  61965. }
  61966. declare module BABYLON.GUI {
  61967. /**
  61968. * Class used to create a password control
  61969. */
  61970. export class InputPassword extends InputText {
  61971. protected _beforeRenderText(text: string): string;
  61972. }
  61973. }
  61974. declare module BABYLON.GUI {
  61975. /** Class used to render 2D lines */
  61976. export class Line extends Control {
  61977. name?: string | undefined;
  61978. private _lineWidth;
  61979. private _x1;
  61980. private _y1;
  61981. private _x2;
  61982. private _y2;
  61983. private _dash;
  61984. private _connectedControl;
  61985. private _connectedControlDirtyObserver;
  61986. /** Gets or sets the dash pattern */
  61987. dash: Array<number>;
  61988. /** Gets or sets the control connected with the line end */
  61989. connectedControl: Control;
  61990. /** Gets or sets start coordinates on X axis */
  61991. x1: string | number;
  61992. /** Gets or sets start coordinates on Y axis */
  61993. y1: string | number;
  61994. /** Gets or sets end coordinates on X axis */
  61995. x2: string | number;
  61996. /** Gets or sets end coordinates on Y axis */
  61997. y2: string | number;
  61998. /** Gets or sets line width */
  61999. lineWidth: number;
  62000. /** Gets or sets horizontal alignment */
  62001. horizontalAlignment: number;
  62002. /** Gets or sets vertical alignment */
  62003. verticalAlignment: number;
  62004. private readonly _effectiveX2;
  62005. private readonly _effectiveY2;
  62006. /**
  62007. * Creates a new Line
  62008. * @param name defines the control name
  62009. */
  62010. constructor(name?: string | undefined);
  62011. protected _getTypeName(): string;
  62012. _draw(context: CanvasRenderingContext2D): void;
  62013. _measure(): void;
  62014. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62015. /**
  62016. * Move one end of the line given 3D cartesian coordinates.
  62017. * @param position Targeted world position
  62018. * @param scene BABYLON.Scene
  62019. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  62020. */
  62021. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  62022. /**
  62023. * Move one end of the line to a position in screen absolute space.
  62024. * @param projectedPosition Position in screen absolute space (X, Y)
  62025. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  62026. */
  62027. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  62028. }
  62029. }
  62030. declare module BABYLON.GUI {
  62031. /**
  62032. * Class used to store a point for a MultiLine object.
  62033. * The point can be pure 2D coordinates, a mesh or a control
  62034. */
  62035. export class MultiLinePoint {
  62036. private _multiLine;
  62037. private _x;
  62038. private _y;
  62039. private _control;
  62040. private _mesh;
  62041. private _controlObserver;
  62042. private _meshObserver;
  62043. /** @hidden */
  62044. _point: BABYLON.Vector2;
  62045. /**
  62046. * Creates a new MultiLinePoint
  62047. * @param multiLine defines the source MultiLine object
  62048. */
  62049. constructor(multiLine: MultiLine);
  62050. /** Gets or sets x coordinate */
  62051. x: string | number;
  62052. /** Gets or sets y coordinate */
  62053. y: string | number;
  62054. /** Gets or sets the control associated with this point */
  62055. control: BABYLON.Nullable<Control>;
  62056. /** Gets or sets the mesh associated with this point */
  62057. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62058. /** Resets links */
  62059. resetLinks(): void;
  62060. /**
  62061. * Gets a translation vector
  62062. * @returns the translation vector
  62063. */
  62064. translate(): BABYLON.Vector2;
  62065. private _translatePoint;
  62066. /** Release associated resources */
  62067. dispose(): void;
  62068. }
  62069. }
  62070. declare module BABYLON.GUI {
  62071. /**
  62072. * Class used to create multi line control
  62073. */
  62074. export class MultiLine extends Control {
  62075. name?: string | undefined;
  62076. private _lineWidth;
  62077. private _dash;
  62078. private _points;
  62079. private _minX;
  62080. private _minY;
  62081. private _maxX;
  62082. private _maxY;
  62083. /**
  62084. * Creates a new MultiLine
  62085. * @param name defines the control name
  62086. */
  62087. constructor(name?: string | undefined);
  62088. /** Gets or sets dash pattern */
  62089. dash: Array<number>;
  62090. /**
  62091. * Gets point stored at specified index
  62092. * @param index defines the index to look for
  62093. * @returns the requested point if found
  62094. */
  62095. getAt(index: number): MultiLinePoint;
  62096. /** Function called when a point is updated */
  62097. onPointUpdate: () => void;
  62098. /**
  62099. * Adds new points to the point collection
  62100. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  62101. * @returns the list of created MultiLinePoint
  62102. */
  62103. add(...items: (AbstractMesh | Control | {
  62104. x: string | number;
  62105. y: string | number;
  62106. })[]): MultiLinePoint[];
  62107. /**
  62108. * Adds a new point to the point collection
  62109. * @param item defines the item (mesh, control or 2d coordiantes) to add
  62110. * @returns the created MultiLinePoint
  62111. */
  62112. push(item?: (AbstractMesh | Control | {
  62113. x: string | number;
  62114. y: string | number;
  62115. })): MultiLinePoint;
  62116. /**
  62117. * Remove a specific value or point from the active point collection
  62118. * @param value defines the value or point to remove
  62119. */
  62120. remove(value: number | MultiLinePoint): void;
  62121. /**
  62122. * Resets this object to initial state (no point)
  62123. */
  62124. reset(): void;
  62125. /**
  62126. * Resets all links
  62127. */
  62128. resetLinks(): void;
  62129. /** Gets or sets line width */
  62130. lineWidth: number;
  62131. horizontalAlignment: number;
  62132. verticalAlignment: number;
  62133. protected _getTypeName(): string;
  62134. _draw(context: CanvasRenderingContext2D): void;
  62135. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62136. _measure(): void;
  62137. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62138. dispose(): void;
  62139. }
  62140. }
  62141. declare module BABYLON.GUI {
  62142. /**
  62143. * Class used to create radio button controls
  62144. */
  62145. export class RadioButton extends Control {
  62146. name?: string | undefined;
  62147. private _isChecked;
  62148. private _background;
  62149. private _checkSizeRatio;
  62150. private _thickness;
  62151. /** Gets or sets border thickness */
  62152. thickness: number;
  62153. /** Gets or sets group name */
  62154. group: string;
  62155. /** BABYLON.Observable raised when isChecked is changed */
  62156. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  62157. /** Gets or sets a value indicating the ratio between overall size and check size */
  62158. checkSizeRatio: number;
  62159. /** Gets or sets background color */
  62160. background: string;
  62161. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  62162. isChecked: boolean;
  62163. /**
  62164. * Creates a new RadioButton
  62165. * @param name defines the control name
  62166. */
  62167. constructor(name?: string | undefined);
  62168. protected _getTypeName(): string;
  62169. _draw(context: CanvasRenderingContext2D): void;
  62170. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62171. /**
  62172. * Utility function to easily create a radio button with a header
  62173. * @param title defines the label to use for the header
  62174. * @param group defines the group to use for the radio button
  62175. * @param isChecked defines the initial state of the radio button
  62176. * @param onValueChanged defines the callback to call when value changes
  62177. * @returns a StackPanel containing the radio button and a textBlock
  62178. */
  62179. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  62180. }
  62181. }
  62182. declare module BABYLON.GUI {
  62183. /**
  62184. * Class used to create slider controls
  62185. */
  62186. export class BaseSlider extends Control {
  62187. name?: string | undefined;
  62188. protected _thumbWidth: ValueAndUnit;
  62189. private _minimum;
  62190. private _maximum;
  62191. private _value;
  62192. private _isVertical;
  62193. protected _barOffset: ValueAndUnit;
  62194. private _isThumbClamped;
  62195. protected _displayThumb: boolean;
  62196. private _step;
  62197. private _lastPointerDownID;
  62198. protected _effectiveBarOffset: number;
  62199. protected _renderLeft: number;
  62200. protected _renderTop: number;
  62201. protected _renderWidth: number;
  62202. protected _renderHeight: number;
  62203. protected _backgroundBoxLength: number;
  62204. protected _backgroundBoxThickness: number;
  62205. protected _effectiveThumbThickness: number;
  62206. /** BABYLON.Observable raised when the sldier value changes */
  62207. onValueChangedObservable: BABYLON.Observable<number>;
  62208. /** Gets or sets a boolean indicating if the thumb must be rendered */
  62209. displayThumb: boolean;
  62210. /** Gets or sets a step to apply to values (0 by default) */
  62211. step: number;
  62212. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  62213. barOffset: string | number;
  62214. /** Gets main bar offset in pixels*/
  62215. readonly barOffsetInPixels: number;
  62216. /** Gets or sets thumb width */
  62217. thumbWidth: string | number;
  62218. /** Gets thumb width in pixels */
  62219. readonly thumbWidthInPixels: number;
  62220. /** Gets or sets minimum value */
  62221. minimum: number;
  62222. /** Gets or sets maximum value */
  62223. maximum: number;
  62224. /** Gets or sets current value */
  62225. value: number;
  62226. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  62227. isVertical: boolean;
  62228. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  62229. isThumbClamped: boolean;
  62230. /**
  62231. * Creates a new BaseSlider
  62232. * @param name defines the control name
  62233. */
  62234. constructor(name?: string | undefined);
  62235. protected _getTypeName(): string;
  62236. protected _getThumbPosition(): number;
  62237. protected _getThumbThickness(type: string): number;
  62238. protected _prepareRenderingData(type: string): void;
  62239. private _pointerIsDown;
  62240. /** @hidden */
  62241. protected _updateValueFromPointer(x: number, y: number): void;
  62242. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62243. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62244. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62245. }
  62246. }
  62247. declare module BABYLON.GUI {
  62248. /**
  62249. * Class used to create slider controls
  62250. */
  62251. export class Slider extends BaseSlider {
  62252. name?: string | undefined;
  62253. private _background;
  62254. private _borderColor;
  62255. private _isThumbCircle;
  62256. protected _displayValueBar: boolean;
  62257. /** Gets or sets a boolean indicating if the value bar must be rendered */
  62258. displayValueBar: boolean;
  62259. /** Gets or sets border color */
  62260. borderColor: string;
  62261. /** Gets or sets background color */
  62262. background: string;
  62263. /** Gets or sets a boolean indicating if the thumb should be round or square */
  62264. isThumbCircle: boolean;
  62265. /**
  62266. * Creates a new Slider
  62267. * @param name defines the control name
  62268. */
  62269. constructor(name?: string | undefined);
  62270. protected _getTypeName(): string;
  62271. _draw(context: CanvasRenderingContext2D): void;
  62272. }
  62273. }
  62274. declare module BABYLON.GUI {
  62275. /** Class used to create a RadioGroup
  62276. * which contains groups of radio buttons
  62277. */
  62278. export class SelectorGroup {
  62279. /** name of SelectorGroup */
  62280. name: string;
  62281. private _groupPanel;
  62282. private _selectors;
  62283. private _groupHeader;
  62284. /**
  62285. * Creates a new SelectorGroup
  62286. * @param name of group, used as a group heading
  62287. */
  62288. constructor(
  62289. /** name of SelectorGroup */
  62290. name: string);
  62291. /** Gets the groupPanel of the SelectorGroup */
  62292. readonly groupPanel: StackPanel;
  62293. /** Gets the selectors array */
  62294. readonly selectors: StackPanel[];
  62295. /** Gets and sets the group header */
  62296. header: string;
  62297. /** @hidden */
  62298. private _addGroupHeader;
  62299. /** @hidden*/
  62300. _getSelector(selectorNb: number): StackPanel | undefined;
  62301. /** Removes the selector at the given position
  62302. * @param selectorNb the position of the selector within the group
  62303. */
  62304. removeSelector(selectorNb: number): void;
  62305. }
  62306. /** Class used to create a CheckboxGroup
  62307. * which contains groups of checkbox buttons
  62308. */
  62309. export class CheckboxGroup extends SelectorGroup {
  62310. /** Adds a checkbox as a control
  62311. * @param text is the label for the selector
  62312. * @param func is the function called when the Selector is checked
  62313. * @param checked is true when Selector is checked
  62314. */
  62315. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  62316. /** @hidden */
  62317. _setSelectorLabel(selectorNb: number, label: string): void;
  62318. /** @hidden */
  62319. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62320. /** @hidden */
  62321. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62322. /** @hidden */
  62323. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62324. }
  62325. /** Class used to create a RadioGroup
  62326. * which contains groups of radio buttons
  62327. */
  62328. export class RadioGroup extends SelectorGroup {
  62329. private _selectNb;
  62330. /** Adds a radio button as a control
  62331. * @param label is the label for the selector
  62332. * @param func is the function called when the Selector is checked
  62333. * @param checked is true when Selector is checked
  62334. */
  62335. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  62336. /** @hidden */
  62337. _setSelectorLabel(selectorNb: number, label: string): void;
  62338. /** @hidden */
  62339. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62340. /** @hidden */
  62341. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62342. /** @hidden */
  62343. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62344. }
  62345. /** Class used to create a SliderGroup
  62346. * which contains groups of slider buttons
  62347. */
  62348. export class SliderGroup extends SelectorGroup {
  62349. /**
  62350. * Adds a slider to the SelectorGroup
  62351. * @param label is the label for the SliderBar
  62352. * @param func is the function called when the Slider moves
  62353. * @param unit is a string describing the units used, eg degrees or metres
  62354. * @param min is the minimum value for the Slider
  62355. * @param max is the maximum value for the Slider
  62356. * @param value is the start value for the Slider between min and max
  62357. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  62358. */
  62359. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  62360. /** @hidden */
  62361. _setSelectorLabel(selectorNb: number, label: string): void;
  62362. /** @hidden */
  62363. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62364. /** @hidden */
  62365. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62366. /** @hidden */
  62367. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62368. }
  62369. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  62370. * @see http://doc.babylonjs.com/how_to/selector
  62371. */
  62372. export class SelectionPanel extends Rectangle {
  62373. /** name of SelectionPanel */
  62374. name: string;
  62375. /** an array of SelectionGroups */
  62376. groups: SelectorGroup[];
  62377. private _panel;
  62378. private _buttonColor;
  62379. private _buttonBackground;
  62380. private _headerColor;
  62381. private _barColor;
  62382. private _barHeight;
  62383. private _spacerHeight;
  62384. private _labelColor;
  62385. private _groups;
  62386. private _bars;
  62387. /**
  62388. * Creates a new SelectionPanel
  62389. * @param name of SelectionPanel
  62390. * @param groups is an array of SelectionGroups
  62391. */
  62392. constructor(
  62393. /** name of SelectionPanel */
  62394. name: string,
  62395. /** an array of SelectionGroups */
  62396. groups?: SelectorGroup[]);
  62397. protected _getTypeName(): string;
  62398. /** Gets or sets the headerColor */
  62399. headerColor: string;
  62400. private _setHeaderColor;
  62401. /** Gets or sets the button color */
  62402. buttonColor: string;
  62403. private _setbuttonColor;
  62404. /** Gets or sets the label color */
  62405. labelColor: string;
  62406. private _setLabelColor;
  62407. /** Gets or sets the button background */
  62408. buttonBackground: string;
  62409. private _setButtonBackground;
  62410. /** Gets or sets the color of separator bar */
  62411. barColor: string;
  62412. private _setBarColor;
  62413. /** Gets or sets the height of separator bar */
  62414. barHeight: string;
  62415. private _setBarHeight;
  62416. /** Gets or sets the height of spacers*/
  62417. spacerHeight: string;
  62418. private _setSpacerHeight;
  62419. /** Adds a bar between groups */
  62420. private _addSpacer;
  62421. /** Add a group to the selection panel
  62422. * @param group is the selector group to add
  62423. */
  62424. addGroup(group: SelectorGroup): void;
  62425. /** Remove the group from the given position
  62426. * @param groupNb is the position of the group in the list
  62427. */
  62428. removeGroup(groupNb: number): void;
  62429. /** Change a group header label
  62430. * @param label is the new group header label
  62431. * @param groupNb is the number of the group to relabel
  62432. * */
  62433. setHeaderName(label: string, groupNb: number): void;
  62434. /** Change selector label to the one given
  62435. * @param label is the new selector label
  62436. * @param groupNb is the number of the groupcontaining the selector
  62437. * @param selectorNb is the number of the selector within a group to relabel
  62438. * */
  62439. relabel(label: string, groupNb: number, selectorNb: number): void;
  62440. /** For a given group position remove the selector at the given position
  62441. * @param groupNb is the number of the group to remove the selector from
  62442. * @param selectorNb is the number of the selector within the group
  62443. */
  62444. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  62445. /** For a given group position of correct type add a checkbox button
  62446. * @param groupNb is the number of the group to remove the selector from
  62447. * @param label is the label for the selector
  62448. * @param func is the function called when the Selector is checked
  62449. * @param checked is true when Selector is checked
  62450. */
  62451. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  62452. /** For a given group position of correct type add a radio button
  62453. * @param groupNb is the number of the group to remove the selector from
  62454. * @param label is the label for the selector
  62455. * @param func is the function called when the Selector is checked
  62456. * @param checked is true when Selector is checked
  62457. */
  62458. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  62459. /**
  62460. * For a given slider group add a slider
  62461. * @param groupNb is the number of the group to add the slider to
  62462. * @param label is the label for the Slider
  62463. * @param func is the function called when the Slider moves
  62464. * @param unit is a string describing the units used, eg degrees or metres
  62465. * @param min is the minimum value for the Slider
  62466. * @param max is the maximum value for the Slider
  62467. * @param value is the start value for the Slider between min and max
  62468. * @param onVal is the function used to format the value displayed, eg radians to degrees
  62469. */
  62470. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  62471. }
  62472. }
  62473. declare module BABYLON.GUI {
  62474. /**
  62475. * Class used to hold a the container for ScrollViewer
  62476. * @hidden
  62477. */
  62478. export class _ScrollViewerWindow extends Container {
  62479. parentClientWidth: number;
  62480. parentClientHeight: number;
  62481. /**
  62482. * Creates a new ScrollViewerWindow
  62483. * @param name of ScrollViewerWindow
  62484. */
  62485. constructor(name?: string);
  62486. protected _getTypeName(): string;
  62487. /** @hidden */
  62488. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62489. protected _postMeasure(): void;
  62490. }
  62491. }
  62492. declare module BABYLON.GUI {
  62493. /**
  62494. * Class used to create slider controls
  62495. */
  62496. export class ScrollBar extends BaseSlider {
  62497. name?: string | undefined;
  62498. private _background;
  62499. private _borderColor;
  62500. private _thumbMeasure;
  62501. /** Gets or sets border color */
  62502. borderColor: string;
  62503. /** Gets or sets background color */
  62504. background: string;
  62505. /**
  62506. * Creates a new Slider
  62507. * @param name defines the control name
  62508. */
  62509. constructor(name?: string | undefined);
  62510. protected _getTypeName(): string;
  62511. protected _getThumbThickness(): number;
  62512. _draw(context: CanvasRenderingContext2D): void;
  62513. private _first;
  62514. private _originX;
  62515. private _originY;
  62516. /** @hidden */
  62517. protected _updateValueFromPointer(x: number, y: number): void;
  62518. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62519. }
  62520. }
  62521. declare module BABYLON.GUI {
  62522. /**
  62523. * Class used to hold a viewer window and sliders in a grid
  62524. */
  62525. export class ScrollViewer extends Rectangle {
  62526. private _grid;
  62527. private _horizontalBarSpace;
  62528. private _verticalBarSpace;
  62529. private _dragSpace;
  62530. private _horizontalBar;
  62531. private _verticalBar;
  62532. private _barColor;
  62533. private _barBackground;
  62534. private _barSize;
  62535. private _endLeft;
  62536. private _endTop;
  62537. private _window;
  62538. private _pointerIsOver;
  62539. private _wheelPrecision;
  62540. private _onPointerObserver;
  62541. private _clientWidth;
  62542. private _clientHeight;
  62543. /**
  62544. * Gets the horizontal scrollbar
  62545. */
  62546. readonly horizontalBar: ScrollBar;
  62547. /**
  62548. * Gets the vertical scrollbar
  62549. */
  62550. readonly verticalBar: ScrollBar;
  62551. /**
  62552. * Adds a new control to the current container
  62553. * @param control defines the control to add
  62554. * @returns the current container
  62555. */
  62556. addControl(control: BABYLON.Nullable<Control>): Container;
  62557. /**
  62558. * Removes a control from the current container
  62559. * @param control defines the control to remove
  62560. * @returns the current container
  62561. */
  62562. removeControl(control: Control): Container;
  62563. /** Gets the list of children */
  62564. readonly children: Control[];
  62565. _flagDescendantsAsMatrixDirty(): void;
  62566. /**
  62567. * Creates a new ScrollViewer
  62568. * @param name of ScrollViewer
  62569. */
  62570. constructor(name?: string);
  62571. /** Reset the scroll viewer window to initial size */
  62572. resetWindow(): void;
  62573. protected _getTypeName(): string;
  62574. private _buildClientSizes;
  62575. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62576. protected _postMeasure(): void;
  62577. /**
  62578. * Gets or sets the mouse wheel precision
  62579. * from 0 to 1 with a default value of 0.05
  62580. * */
  62581. wheelPrecision: number;
  62582. /** Gets or sets the bar color */
  62583. barColor: string;
  62584. /** Gets or sets the size of the bar */
  62585. barSize: number;
  62586. /** Gets or sets the bar background */
  62587. barBackground: string;
  62588. /** @hidden */
  62589. private _updateScroller;
  62590. _link(host: AdvancedDynamicTexture): void;
  62591. /** @hidden */
  62592. private _attachWheel;
  62593. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62594. /** Releases associated resources */
  62595. dispose(): void;
  62596. }
  62597. }
  62598. declare module BABYLON.GUI {
  62599. /** Class used to render a grid */
  62600. export class DisplayGrid extends Control {
  62601. name?: string | undefined;
  62602. private _cellWidth;
  62603. private _cellHeight;
  62604. private _minorLineTickness;
  62605. private _minorLineColor;
  62606. private _majorLineTickness;
  62607. private _majorLineColor;
  62608. private _majorLineFrequency;
  62609. private _background;
  62610. private _displayMajorLines;
  62611. private _displayMinorLines;
  62612. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  62613. displayMinorLines: boolean;
  62614. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  62615. displayMajorLines: boolean;
  62616. /** Gets or sets background color (Black by default) */
  62617. background: string;
  62618. /** Gets or sets the width of each cell (20 by default) */
  62619. cellWidth: number;
  62620. /** Gets or sets the height of each cell (20 by default) */
  62621. cellHeight: number;
  62622. /** Gets or sets the tickness of minor lines (1 by default) */
  62623. minorLineTickness: number;
  62624. /** Gets or sets the color of minor lines (DarkGray by default) */
  62625. minorLineColor: string;
  62626. /** Gets or sets the tickness of major lines (2 by default) */
  62627. majorLineTickness: number;
  62628. /** Gets or sets the color of major lines (White by default) */
  62629. majorLineColor: string;
  62630. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  62631. majorLineFrequency: number;
  62632. /**
  62633. * Creates a new GridDisplayRectangle
  62634. * @param name defines the control name
  62635. */
  62636. constructor(name?: string | undefined);
  62637. _draw(context: CanvasRenderingContext2D): void;
  62638. protected _getTypeName(): string;
  62639. }
  62640. }
  62641. declare module BABYLON.GUI {
  62642. /**
  62643. * Class used to create slider controls based on images
  62644. */
  62645. export class ImageBasedSlider extends BaseSlider {
  62646. name?: string | undefined;
  62647. private _backgroundImage;
  62648. private _thumbImage;
  62649. private _valueBarImage;
  62650. private _tempMeasure;
  62651. displayThumb: boolean;
  62652. /**
  62653. * Gets or sets the image used to render the background
  62654. */
  62655. backgroundImage: Image;
  62656. /**
  62657. * Gets or sets the image used to render the value bar
  62658. */
  62659. valueBarImage: Image;
  62660. /**
  62661. * Gets or sets the image used to render the thumb
  62662. */
  62663. thumbImage: Image;
  62664. /**
  62665. * Creates a new ImageBasedSlider
  62666. * @param name defines the control name
  62667. */
  62668. constructor(name?: string | undefined);
  62669. protected _getTypeName(): string;
  62670. _draw(context: CanvasRenderingContext2D): void;
  62671. }
  62672. }
  62673. declare module BABYLON.GUI {
  62674. /**
  62675. * Forcing an export so that this code will execute
  62676. * @hidden
  62677. */
  62678. const name = "Statics";
  62679. }
  62680. declare module BABYLON.GUI {
  62681. /**
  62682. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  62683. */
  62684. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  62685. /**
  62686. * Define the instrumented AdvancedDynamicTexture.
  62687. */
  62688. texture: AdvancedDynamicTexture;
  62689. private _captureRenderTime;
  62690. private _renderTime;
  62691. private _captureLayoutTime;
  62692. private _layoutTime;
  62693. private _onBeginRenderObserver;
  62694. private _onEndRenderObserver;
  62695. private _onBeginLayoutObserver;
  62696. private _onEndLayoutObserver;
  62697. /**
  62698. * Gets the perf counter used to capture render time
  62699. */
  62700. readonly renderTimeCounter: BABYLON.PerfCounter;
  62701. /**
  62702. * Gets the perf counter used to capture layout time
  62703. */
  62704. readonly layoutTimeCounter: BABYLON.PerfCounter;
  62705. /**
  62706. * Enable or disable the render time capture
  62707. */
  62708. captureRenderTime: boolean;
  62709. /**
  62710. * Enable or disable the layout time capture
  62711. */
  62712. captureLayoutTime: boolean;
  62713. /**
  62714. * Instantiates a new advanced dynamic texture instrumentation.
  62715. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  62716. * @param texture Defines the AdvancedDynamicTexture to instrument
  62717. */
  62718. constructor(
  62719. /**
  62720. * Define the instrumented AdvancedDynamicTexture.
  62721. */
  62722. texture: AdvancedDynamicTexture);
  62723. /**
  62724. * Dispose and release associated resources.
  62725. */
  62726. dispose(): void;
  62727. }
  62728. }
  62729. declare module BABYLON.GUI {
  62730. /**
  62731. * Class used to create containers for controls
  62732. */
  62733. export class Container3D extends Control3D {
  62734. private _blockLayout;
  62735. /**
  62736. * Gets the list of child controls
  62737. */
  62738. protected _children: Control3D[];
  62739. /**
  62740. * Gets the list of child controls
  62741. */
  62742. readonly children: Array<Control3D>;
  62743. /**
  62744. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  62745. * This is helpful to optimize layout operation when adding multiple children in a row
  62746. */
  62747. blockLayout: boolean;
  62748. /**
  62749. * Creates a new container
  62750. * @param name defines the container name
  62751. */
  62752. constructor(name?: string);
  62753. /**
  62754. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  62755. * @returns the current container
  62756. */
  62757. updateLayout(): Container3D;
  62758. /**
  62759. * Gets a boolean indicating if the given control is in the children of this control
  62760. * @param control defines the control to check
  62761. * @returns true if the control is in the child list
  62762. */
  62763. containsControl(control: Control3D): boolean;
  62764. /**
  62765. * Adds a control to the children of this control
  62766. * @param control defines the control to add
  62767. * @returns the current container
  62768. */
  62769. addControl(control: Control3D): Container3D;
  62770. /**
  62771. * This function will be called everytime a new control is added
  62772. */
  62773. protected _arrangeChildren(): void;
  62774. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  62775. /**
  62776. * Removes a control from the children of this control
  62777. * @param control defines the control to remove
  62778. * @returns the current container
  62779. */
  62780. removeControl(control: Control3D): Container3D;
  62781. protected _getTypeName(): string;
  62782. /**
  62783. * Releases all associated resources
  62784. */
  62785. dispose(): void;
  62786. /** Control rotation will remain unchanged */
  62787. static readonly UNSET_ORIENTATION: number;
  62788. /** Control will rotate to make it look at sphere central axis */
  62789. static readonly FACEORIGIN_ORIENTATION: number;
  62790. /** Control will rotate to make it look back at sphere central axis */
  62791. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  62792. /** Control will rotate to look at z axis (0, 0, 1) */
  62793. static readonly FACEFORWARD_ORIENTATION: number;
  62794. /** Control will rotate to look at negative z axis (0, 0, -1) */
  62795. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  62796. }
  62797. }
  62798. declare module BABYLON.GUI {
  62799. /**
  62800. * Class used to manage 3D user interface
  62801. * @see http://doc.babylonjs.com/how_to/gui3d
  62802. */
  62803. export class GUI3DManager implements BABYLON.IDisposable {
  62804. private _scene;
  62805. private _sceneDisposeObserver;
  62806. private _utilityLayer;
  62807. private _rootContainer;
  62808. private _pointerObserver;
  62809. private _pointerOutObserver;
  62810. /** @hidden */
  62811. _lastPickedControl: Control3D;
  62812. /** @hidden */
  62813. _lastControlOver: {
  62814. [pointerId: number]: Control3D;
  62815. };
  62816. /** @hidden */
  62817. _lastControlDown: {
  62818. [pointerId: number]: Control3D;
  62819. };
  62820. /**
  62821. * BABYLON.Observable raised when the point picked by the pointer events changed
  62822. */
  62823. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  62824. /** @hidden */
  62825. _sharedMaterials: {
  62826. [key: string]: BABYLON.Material;
  62827. };
  62828. /** Gets the hosting scene */
  62829. readonly scene: BABYLON.Scene;
  62830. /** Gets associated utility layer */
  62831. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  62832. /**
  62833. * Creates a new GUI3DManager
  62834. * @param scene
  62835. */
  62836. constructor(scene?: BABYLON.Scene);
  62837. private _handlePointerOut;
  62838. private _doPicking;
  62839. /**
  62840. * Gets the root container
  62841. */
  62842. readonly rootContainer: Container3D;
  62843. /**
  62844. * Gets a boolean indicating if the given control is in the root child list
  62845. * @param control defines the control to check
  62846. * @returns true if the control is in the root child list
  62847. */
  62848. containsControl(control: Control3D): boolean;
  62849. /**
  62850. * Adds a control to the root child list
  62851. * @param control defines the control to add
  62852. * @returns the current manager
  62853. */
  62854. addControl(control: Control3D): GUI3DManager;
  62855. /**
  62856. * Removes a control from the root child list
  62857. * @param control defines the control to remove
  62858. * @returns the current container
  62859. */
  62860. removeControl(control: Control3D): GUI3DManager;
  62861. /**
  62862. * Releases all associated resources
  62863. */
  62864. dispose(): void;
  62865. }
  62866. }
  62867. declare module BABYLON.GUI {
  62868. /**
  62869. * Class used to transport BABYLON.Vector3 information for pointer events
  62870. */
  62871. export class Vector3WithInfo extends BABYLON.Vector3 {
  62872. /** defines the current mouse button index */
  62873. buttonIndex: number;
  62874. /**
  62875. * Creates a new Vector3WithInfo
  62876. * @param source defines the vector3 data to transport
  62877. * @param buttonIndex defines the current mouse button index
  62878. */
  62879. constructor(source: BABYLON.Vector3,
  62880. /** defines the current mouse button index */
  62881. buttonIndex?: number);
  62882. }
  62883. }
  62884. declare module BABYLON.GUI {
  62885. /**
  62886. * Class used as base class for controls
  62887. */
  62888. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  62889. /** Defines the control name */
  62890. name?: string | undefined;
  62891. /** @hidden */
  62892. _host: GUI3DManager;
  62893. private _node;
  62894. private _downCount;
  62895. private _enterCount;
  62896. private _downPointerIds;
  62897. private _isVisible;
  62898. /** Gets or sets the control position in world space */
  62899. position: BABYLON.Vector3;
  62900. /** Gets or sets the control scaling in world space */
  62901. scaling: BABYLON.Vector3;
  62902. /** Callback used to start pointer enter animation */
  62903. pointerEnterAnimation: () => void;
  62904. /** Callback used to start pointer out animation */
  62905. pointerOutAnimation: () => void;
  62906. /** Callback used to start pointer down animation */
  62907. pointerDownAnimation: () => void;
  62908. /** Callback used to start pointer up animation */
  62909. pointerUpAnimation: () => void;
  62910. /**
  62911. * An event triggered when the pointer move over the control
  62912. */
  62913. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  62914. /**
  62915. * An event triggered when the pointer move out of the control
  62916. */
  62917. onPointerOutObservable: BABYLON.Observable<Control3D>;
  62918. /**
  62919. * An event triggered when the pointer taps the control
  62920. */
  62921. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  62922. /**
  62923. * An event triggered when pointer is up
  62924. */
  62925. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  62926. /**
  62927. * An event triggered when a control is clicked on (with a mouse)
  62928. */
  62929. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  62930. /**
  62931. * An event triggered when pointer enters the control
  62932. */
  62933. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  62934. /**
  62935. * Gets or sets the parent container
  62936. */
  62937. parent: BABYLON.Nullable<Container3D>;
  62938. private _behaviors;
  62939. /**
  62940. * Gets the list of attached behaviors
  62941. * @see http://doc.babylonjs.com/features/behaviour
  62942. */
  62943. readonly behaviors: BABYLON.Behavior<Control3D>[];
  62944. /**
  62945. * Attach a behavior to the control
  62946. * @see http://doc.babylonjs.com/features/behaviour
  62947. * @param behavior defines the behavior to attach
  62948. * @returns the current control
  62949. */
  62950. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62951. /**
  62952. * Remove an attached behavior
  62953. * @see http://doc.babylonjs.com/features/behaviour
  62954. * @param behavior defines the behavior to attach
  62955. * @returns the current control
  62956. */
  62957. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62958. /**
  62959. * Gets an attached behavior by name
  62960. * @param name defines the name of the behavior to look for
  62961. * @see http://doc.babylonjs.com/features/behaviour
  62962. * @returns null if behavior was not found else the requested behavior
  62963. */
  62964. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  62965. /** Gets or sets a boolean indicating if the control is visible */
  62966. isVisible: boolean;
  62967. /**
  62968. * Creates a new control
  62969. * @param name defines the control name
  62970. */
  62971. constructor(
  62972. /** Defines the control name */
  62973. name?: string | undefined);
  62974. /**
  62975. * Gets a string representing the class name
  62976. */
  62977. readonly typeName: string;
  62978. /**
  62979. * Get the current class name of the control.
  62980. * @returns current class name
  62981. */
  62982. getClassName(): string;
  62983. protected _getTypeName(): string;
  62984. /**
  62985. * Gets the transform node used by this control
  62986. */
  62987. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  62988. /**
  62989. * Gets the mesh used to render this control
  62990. */
  62991. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62992. /**
  62993. * Link the control as child of the given node
  62994. * @param node defines the node to link to. Use null to unlink the control
  62995. * @returns the current control
  62996. */
  62997. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  62998. /** @hidden **/
  62999. _prepareNode(scene: BABYLON.Scene): void;
  63000. /**
  63001. * Node creation.
  63002. * Can be overriden by children
  63003. * @param scene defines the scene where the node must be attached
  63004. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  63005. */
  63006. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  63007. /**
  63008. * Affect a material to the given mesh
  63009. * @param mesh defines the mesh which will represent the control
  63010. */
  63011. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63012. /** @hidden */
  63013. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  63014. /** @hidden */
  63015. _onPointerEnter(target: Control3D): boolean;
  63016. /** @hidden */
  63017. _onPointerOut(target: Control3D): void;
  63018. /** @hidden */
  63019. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  63020. /** @hidden */
  63021. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63022. /** @hidden */
  63023. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63024. /** @hidden */
  63025. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  63026. /** @hidden */
  63027. _disposeNode(): void;
  63028. /**
  63029. * Releases all associated resources
  63030. */
  63031. dispose(): void;
  63032. }
  63033. }
  63034. declare module BABYLON.GUI {
  63035. /**
  63036. * Class used as a root to all buttons
  63037. */
  63038. export class AbstractButton3D extends Control3D {
  63039. /**
  63040. * Creates a new button
  63041. * @param name defines the control name
  63042. */
  63043. constructor(name?: string);
  63044. protected _getTypeName(): string;
  63045. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63046. }
  63047. }
  63048. declare module BABYLON.GUI {
  63049. /**
  63050. * Class used to create a button in 3D
  63051. */
  63052. export class Button3D extends AbstractButton3D {
  63053. /** @hidden */
  63054. protected _currentMaterial: BABYLON.Material;
  63055. private _facadeTexture;
  63056. private _content;
  63057. private _contentResolution;
  63058. private _contentScaleRatio;
  63059. /**
  63060. * Gets or sets the texture resolution used to render content (512 by default)
  63061. */
  63062. contentResolution: BABYLON.int;
  63063. /**
  63064. * Gets or sets the texture scale ratio used to render content (2 by default)
  63065. */
  63066. contentScaleRatio: number;
  63067. protected _disposeFacadeTexture(): void;
  63068. protected _resetContent(): void;
  63069. /**
  63070. * Creates a new button
  63071. * @param name defines the control name
  63072. */
  63073. constructor(name?: string);
  63074. /**
  63075. * Gets or sets the GUI 2D content used to display the button's facade
  63076. */
  63077. content: Control;
  63078. /**
  63079. * Apply the facade texture (created from the content property).
  63080. * This function can be overloaded by child classes
  63081. * @param facadeTexture defines the AdvancedDynamicTexture to use
  63082. */
  63083. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  63084. protected _getTypeName(): string;
  63085. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63086. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63087. /**
  63088. * Releases all associated resources
  63089. */
  63090. dispose(): void;
  63091. }
  63092. }
  63093. declare module BABYLON.GUI {
  63094. /**
  63095. * Abstract class used to create a container panel deployed on the surface of a volume
  63096. */
  63097. export abstract class VolumeBasedPanel extends Container3D {
  63098. private _columns;
  63099. private _rows;
  63100. private _rowThenColum;
  63101. private _orientation;
  63102. protected _cellWidth: number;
  63103. protected _cellHeight: number;
  63104. /**
  63105. * Gets or sets the distance between elements
  63106. */
  63107. margin: number;
  63108. /**
  63109. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  63110. * | Value | Type | Description |
  63111. * | ----- | ----------------------------------- | ----------- |
  63112. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  63113. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  63114. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  63115. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  63116. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  63117. */
  63118. orientation: number;
  63119. /**
  63120. * Gets or sets the number of columns requested (10 by default).
  63121. * The panel will automatically compute the number of rows based on number of child controls.
  63122. */
  63123. columns: BABYLON.int;
  63124. /**
  63125. * Gets or sets a the number of rows requested.
  63126. * The panel will automatically compute the number of columns based on number of child controls.
  63127. */
  63128. rows: BABYLON.int;
  63129. /**
  63130. * Creates new VolumeBasedPanel
  63131. */
  63132. constructor();
  63133. protected _arrangeChildren(): void;
  63134. /** Child classes must implement this function to provide correct control positioning */
  63135. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63136. /** Child classes can implement this function to provide additional processing */
  63137. protected _finalProcessing(): void;
  63138. }
  63139. }
  63140. declare module BABYLON.GUI {
  63141. /**
  63142. * Class used to create a container panel deployed on the surface of a cylinder
  63143. */
  63144. export class CylinderPanel extends VolumeBasedPanel {
  63145. private _radius;
  63146. /**
  63147. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  63148. */
  63149. radius: BABYLON.float;
  63150. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63151. private _cylindricalMapping;
  63152. }
  63153. }
  63154. declare module BABYLON.GUI {
  63155. /** @hidden */
  63156. export var fluentVertexShader: {
  63157. name: string;
  63158. shader: string;
  63159. };
  63160. }
  63161. declare module BABYLON.GUI {
  63162. /** @hidden */
  63163. export var fluentPixelShader: {
  63164. name: string;
  63165. shader: string;
  63166. };
  63167. }
  63168. declare module BABYLON.GUI {
  63169. /** @hidden */
  63170. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  63171. INNERGLOW: boolean;
  63172. BORDER: boolean;
  63173. HOVERLIGHT: boolean;
  63174. TEXTURE: boolean;
  63175. constructor();
  63176. }
  63177. /**
  63178. * Class used to render controls with fluent desgin
  63179. */
  63180. export class FluentMaterial extends BABYLON.PushMaterial {
  63181. /**
  63182. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  63183. */
  63184. innerGlowColorIntensity: number;
  63185. /**
  63186. * Gets or sets the inner glow color (white by default)
  63187. */
  63188. innerGlowColor: BABYLON.Color3;
  63189. /**
  63190. * Gets or sets alpha value (default is 1.0)
  63191. */
  63192. alpha: number;
  63193. /**
  63194. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  63195. */
  63196. albedoColor: BABYLON.Color3;
  63197. /**
  63198. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  63199. */
  63200. renderBorders: boolean;
  63201. /**
  63202. * Gets or sets border width (default is 0.5)
  63203. */
  63204. borderWidth: number;
  63205. /**
  63206. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  63207. */
  63208. edgeSmoothingValue: number;
  63209. /**
  63210. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  63211. */
  63212. borderMinValue: number;
  63213. /**
  63214. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  63215. */
  63216. renderHoverLight: boolean;
  63217. /**
  63218. * Gets or sets the radius used to render the hover light (default is 1.0)
  63219. */
  63220. hoverRadius: number;
  63221. /**
  63222. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  63223. */
  63224. hoverColor: BABYLON.Color4;
  63225. /**
  63226. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  63227. */
  63228. hoverPosition: BABYLON.Vector3;
  63229. private _albedoTexture;
  63230. /** Gets or sets the texture to use for albedo color */
  63231. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63232. /**
  63233. * Creates a new Fluent material
  63234. * @param name defines the name of the material
  63235. * @param scene defines the hosting scene
  63236. */
  63237. constructor(name: string, scene: BABYLON.Scene);
  63238. needAlphaBlending(): boolean;
  63239. needAlphaTesting(): boolean;
  63240. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63241. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63242. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63243. getActiveTextures(): BABYLON.BaseTexture[];
  63244. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63245. dispose(forceDisposeEffect?: boolean): void;
  63246. clone(name: string): FluentMaterial;
  63247. serialize(): any;
  63248. getClassName(): string;
  63249. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  63250. }
  63251. }
  63252. declare module BABYLON.GUI {
  63253. /**
  63254. * Class used to create a holographic button in 3D
  63255. */
  63256. export class HolographicButton extends Button3D {
  63257. private _backPlate;
  63258. private _textPlate;
  63259. private _frontPlate;
  63260. private _text;
  63261. private _imageUrl;
  63262. private _shareMaterials;
  63263. private _frontMaterial;
  63264. private _backMaterial;
  63265. private _plateMaterial;
  63266. private _pickedPointObserver;
  63267. private _tooltipFade;
  63268. private _tooltipTextBlock;
  63269. private _tooltipTexture;
  63270. private _tooltipMesh;
  63271. private _tooltipHoverObserver;
  63272. private _tooltipOutObserver;
  63273. private _disposeTooltip;
  63274. /**
  63275. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  63276. */
  63277. tooltipText: BABYLON.Nullable<string>;
  63278. /**
  63279. * Gets or sets text for the button
  63280. */
  63281. text: string;
  63282. /**
  63283. * Gets or sets the image url for the button
  63284. */
  63285. imageUrl: string;
  63286. /**
  63287. * Gets the back material used by this button
  63288. */
  63289. readonly backMaterial: FluentMaterial;
  63290. /**
  63291. * Gets the front material used by this button
  63292. */
  63293. readonly frontMaterial: FluentMaterial;
  63294. /**
  63295. * Gets the plate material used by this button
  63296. */
  63297. readonly plateMaterial: BABYLON.StandardMaterial;
  63298. /**
  63299. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  63300. */
  63301. readonly shareMaterials: boolean;
  63302. /**
  63303. * Creates a new button
  63304. * @param name defines the control name
  63305. */
  63306. constructor(name?: string, shareMaterials?: boolean);
  63307. protected _getTypeName(): string;
  63308. private _rebuildContent;
  63309. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63310. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  63311. private _createBackMaterial;
  63312. private _createFrontMaterial;
  63313. private _createPlateMaterial;
  63314. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  63315. /**
  63316. * Releases all associated resources
  63317. */
  63318. dispose(): void;
  63319. }
  63320. }
  63321. declare module BABYLON.GUI {
  63322. /**
  63323. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  63324. */
  63325. export class MeshButton3D extends Button3D {
  63326. /** @hidden */
  63327. protected _currentMesh: BABYLON.Mesh;
  63328. /**
  63329. * Creates a new 3D button based on a mesh
  63330. * @param mesh mesh to become a 3D button
  63331. * @param name defines the control name
  63332. */
  63333. constructor(mesh: BABYLON.Mesh, name?: string);
  63334. protected _getTypeName(): string;
  63335. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63336. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63337. }
  63338. }
  63339. declare module BABYLON.GUI {
  63340. /**
  63341. * Class used to create a container panel deployed on the surface of a plane
  63342. */
  63343. export class PlanePanel extends VolumeBasedPanel {
  63344. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63345. }
  63346. }
  63347. declare module BABYLON.GUI {
  63348. /**
  63349. * Class used to create a container panel where items get randomized planar mapping
  63350. */
  63351. export class ScatterPanel extends VolumeBasedPanel {
  63352. private _iteration;
  63353. /**
  63354. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  63355. */
  63356. iteration: BABYLON.float;
  63357. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63358. private _scatterMapping;
  63359. protected _finalProcessing(): void;
  63360. }
  63361. }
  63362. declare module BABYLON.GUI {
  63363. /**
  63364. * Class used to create a container panel deployed on the surface of a sphere
  63365. */
  63366. export class SpherePanel extends VolumeBasedPanel {
  63367. private _radius;
  63368. /**
  63369. * Gets or sets the radius of the sphere where to project controls (5 by default)
  63370. */
  63371. radius: BABYLON.float;
  63372. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63373. private _sphericalMapping;
  63374. }
  63375. }
  63376. declare module BABYLON.GUI {
  63377. /**
  63378. * Class used to create a stack panel in 3D on XY plane
  63379. */
  63380. export class StackPanel3D extends Container3D {
  63381. private _isVertical;
  63382. /**
  63383. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  63384. */
  63385. isVertical: boolean;
  63386. /**
  63387. * Gets or sets the distance between elements
  63388. */
  63389. margin: number;
  63390. /**
  63391. * Creates new StackPanel
  63392. * @param isVertical
  63393. */
  63394. constructor(isVertical?: boolean);
  63395. protected _arrangeChildren(): void;
  63396. }
  63397. }
  63398. declare module BABYLON {
  63399. /**
  63400. * Mode that determines the coordinate system to use.
  63401. */
  63402. export enum GLTFLoaderCoordinateSystemMode {
  63403. /**
  63404. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  63405. */
  63406. AUTO = 0,
  63407. /**
  63408. * Sets the useRightHandedSystem flag on the scene.
  63409. */
  63410. FORCE_RIGHT_HANDED = 1
  63411. }
  63412. /**
  63413. * Mode that determines what animations will start.
  63414. */
  63415. export enum GLTFLoaderAnimationStartMode {
  63416. /**
  63417. * No animation will start.
  63418. */
  63419. NONE = 0,
  63420. /**
  63421. * The first animation will start.
  63422. */
  63423. FIRST = 1,
  63424. /**
  63425. * All animations will start.
  63426. */
  63427. ALL = 2
  63428. }
  63429. /**
  63430. * Interface that contains the data for the glTF asset.
  63431. */
  63432. export interface IGLTFLoaderData {
  63433. /**
  63434. * Object that represents the glTF JSON.
  63435. */
  63436. json: Object;
  63437. /**
  63438. * The BIN chunk of a binary glTF.
  63439. */
  63440. bin: Nullable<ArrayBufferView>;
  63441. }
  63442. /**
  63443. * Interface for extending the loader.
  63444. */
  63445. export interface IGLTFLoaderExtension {
  63446. /**
  63447. * The name of this extension.
  63448. */
  63449. readonly name: string;
  63450. /**
  63451. * Defines whether this extension is enabled.
  63452. */
  63453. enabled: boolean;
  63454. }
  63455. /**
  63456. * Loader state.
  63457. */
  63458. export enum GLTFLoaderState {
  63459. /**
  63460. * The asset is loading.
  63461. */
  63462. LOADING = 0,
  63463. /**
  63464. * The asset is ready for rendering.
  63465. */
  63466. READY = 1,
  63467. /**
  63468. * The asset is completely loaded.
  63469. */
  63470. COMPLETE = 2
  63471. }
  63472. /** @hidden */
  63473. export interface IGLTFLoader extends IDisposable {
  63474. readonly state: Nullable<GLTFLoaderState>;
  63475. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  63476. meshes: AbstractMesh[];
  63477. particleSystems: IParticleSystem[];
  63478. skeletons: Skeleton[];
  63479. animationGroups: AnimationGroup[];
  63480. }>;
  63481. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  63482. }
  63483. /**
  63484. * File loader for loading glTF files into a scene.
  63485. */
  63486. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  63487. /** @hidden */
  63488. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  63489. /** @hidden */
  63490. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  63491. /**
  63492. * Raised when the asset has been parsed
  63493. */
  63494. onParsedObservable: Observable<IGLTFLoaderData>;
  63495. private _onParsedObserver;
  63496. /**
  63497. * Raised when the asset has been parsed
  63498. */
  63499. onParsed: (loaderData: IGLTFLoaderData) => void;
  63500. /**
  63501. * 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.
  63502. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  63503. * Defaults to true.
  63504. * @hidden
  63505. */
  63506. static IncrementalLoading: boolean;
  63507. /**
  63508. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  63509. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  63510. * @hidden
  63511. */
  63512. static HomogeneousCoordinates: boolean;
  63513. /**
  63514. * The coordinate system mode. Defaults to AUTO.
  63515. */
  63516. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  63517. /**
  63518. * The animation start mode. Defaults to FIRST.
  63519. */
  63520. animationStartMode: GLTFLoaderAnimationStartMode;
  63521. /**
  63522. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  63523. */
  63524. compileMaterials: boolean;
  63525. /**
  63526. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  63527. */
  63528. useClipPlane: boolean;
  63529. /**
  63530. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  63531. */
  63532. compileShadowGenerators: boolean;
  63533. /**
  63534. * Defines if the Alpha blended materials are only applied as coverage.
  63535. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  63536. * If true, no extra effects are applied to transparent pixels.
  63537. */
  63538. transparencyAsCoverage: boolean;
  63539. /**
  63540. * Function called before loading a url referenced by the asset.
  63541. */
  63542. preprocessUrlAsync: (url: string) => Promise<string>;
  63543. /**
  63544. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  63545. */
  63546. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  63547. private _onMeshLoadedObserver;
  63548. /**
  63549. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  63550. */
  63551. onMeshLoaded: (mesh: AbstractMesh) => void;
  63552. /**
  63553. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  63554. */
  63555. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  63556. private _onTextureLoadedObserver;
  63557. /**
  63558. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  63559. */
  63560. onTextureLoaded: (texture: BaseTexture) => void;
  63561. /**
  63562. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  63563. */
  63564. readonly onMaterialLoadedObservable: Observable<Material>;
  63565. private _onMaterialLoadedObserver;
  63566. /**
  63567. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  63568. */
  63569. onMaterialLoaded: (material: Material) => void;
  63570. /**
  63571. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  63572. */
  63573. readonly onCameraLoadedObservable: Observable<Camera>;
  63574. private _onCameraLoadedObserver;
  63575. /**
  63576. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  63577. */
  63578. onCameraLoaded: (camera: Camera) => void;
  63579. /**
  63580. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  63581. * For assets with LODs, raised when all of the LODs are complete.
  63582. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63583. */
  63584. readonly onCompleteObservable: Observable<void>;
  63585. private _onCompleteObserver;
  63586. /**
  63587. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  63588. * For assets with LODs, raised when all of the LODs are complete.
  63589. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63590. */
  63591. onComplete: () => void;
  63592. /**
  63593. * Observable raised when an error occurs.
  63594. */
  63595. readonly onErrorObservable: Observable<any>;
  63596. private _onErrorObserver;
  63597. /**
  63598. * Callback raised when an error occurs.
  63599. */
  63600. onError: (reason: any) => void;
  63601. /**
  63602. * Observable raised after the loader is disposed.
  63603. */
  63604. readonly onDisposeObservable: Observable<void>;
  63605. private _onDisposeObserver;
  63606. /**
  63607. * Callback raised after the loader is disposed.
  63608. */
  63609. onDispose: () => void;
  63610. /**
  63611. * Observable raised after a loader extension is created.
  63612. * Set additional options for a loader extension in this event.
  63613. */
  63614. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  63615. private _onExtensionLoadedObserver;
  63616. /**
  63617. * Callback raised after a loader extension is created.
  63618. */
  63619. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  63620. /**
  63621. * Defines if the loader logging is enabled.
  63622. */
  63623. loggingEnabled: boolean;
  63624. /**
  63625. * Defines if the loader should capture performance counters.
  63626. */
  63627. capturePerformanceCounters: boolean;
  63628. /**
  63629. * Defines if the loader should validate the asset.
  63630. */
  63631. validate: boolean;
  63632. /**
  63633. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  63634. */
  63635. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  63636. private _onValidatedObserver;
  63637. /**
  63638. * Callback raised after a loader extension is created.
  63639. */
  63640. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  63641. private _loader;
  63642. /**
  63643. * Name of the loader ("gltf")
  63644. */
  63645. name: string;
  63646. /**
  63647. * Supported file extensions of the loader (.gltf, .glb)
  63648. */
  63649. extensions: ISceneLoaderPluginExtensions;
  63650. /**
  63651. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  63652. */
  63653. dispose(): void;
  63654. /** @hidden */
  63655. _clear(): void;
  63656. /**
  63657. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  63658. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  63659. * @param scene the scene the meshes should be added to
  63660. * @param data the glTF data to load
  63661. * @param rootUrl root url to load from
  63662. * @param onProgress event that fires when loading progress has occured
  63663. * @param fileName Defines the name of the file to load
  63664. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  63665. */
  63666. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  63667. meshes: AbstractMesh[];
  63668. particleSystems: IParticleSystem[];
  63669. skeletons: Skeleton[];
  63670. animationGroups: AnimationGroup[];
  63671. }>;
  63672. /**
  63673. * Imports all objects from the loaded glTF data and adds them to the scene
  63674. * @param scene the scene the objects should be added to
  63675. * @param data the glTF data to load
  63676. * @param rootUrl root url to load from
  63677. * @param onProgress event that fires when loading progress has occured
  63678. * @param fileName Defines the name of the file to load
  63679. * @returns a promise which completes when objects have been loaded to the scene
  63680. */
  63681. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  63682. /**
  63683. * Load into an asset container.
  63684. * @param scene The scene to load into
  63685. * @param data The data to import
  63686. * @param rootUrl The root url for scene and resources
  63687. * @param onProgress The callback when the load progresses
  63688. * @param fileName Defines the name of the file to load
  63689. * @returns The loaded asset container
  63690. */
  63691. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  63692. /**
  63693. * If the data string can be loaded directly.
  63694. * @param data string contianing the file data
  63695. * @returns if the data can be loaded directly
  63696. */
  63697. canDirectLoad(data: string): boolean;
  63698. /**
  63699. * Rewrites a url by combining a root url and response url.
  63700. */
  63701. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  63702. /**
  63703. * Instantiates a glTF file loader plugin.
  63704. * @returns the created plugin
  63705. */
  63706. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  63707. /**
  63708. * The loader state or null if the loader is not active.
  63709. */
  63710. readonly loaderState: Nullable<GLTFLoaderState>;
  63711. /**
  63712. * Returns a promise that resolves when the asset is completely loaded.
  63713. * @returns a promise that resolves when the asset is completely loaded.
  63714. */
  63715. whenCompleteAsync(): Promise<void>;
  63716. private _parseAsync;
  63717. private _validateAsync;
  63718. private _getLoader;
  63719. private _unpackBinary;
  63720. private _unpackBinaryV1;
  63721. private _unpackBinaryV2;
  63722. private static _parseVersion;
  63723. private static _compareVersion;
  63724. private static _decodeBufferToText;
  63725. private static readonly _logSpaces;
  63726. private _logIndentLevel;
  63727. private _loggingEnabled;
  63728. /** @hidden */
  63729. _log: (message: string) => void;
  63730. /** @hidden */
  63731. _logOpen(message: string): void;
  63732. /** @hidden */
  63733. _logClose(): void;
  63734. private _logEnabled;
  63735. private _logDisabled;
  63736. private _capturePerformanceCounters;
  63737. /** @hidden */
  63738. _startPerformanceCounter: (counterName: string) => void;
  63739. /** @hidden */
  63740. _endPerformanceCounter: (counterName: string) => void;
  63741. private _startPerformanceCounterEnabled;
  63742. private _startPerformanceCounterDisabled;
  63743. private _endPerformanceCounterEnabled;
  63744. private _endPerformanceCounterDisabled;
  63745. }
  63746. }
  63747. declare module BABYLON.GLTF1 {
  63748. /**
  63749. * Enums
  63750. * @hidden
  63751. */
  63752. export enum EComponentType {
  63753. BYTE = 5120,
  63754. UNSIGNED_BYTE = 5121,
  63755. SHORT = 5122,
  63756. UNSIGNED_SHORT = 5123,
  63757. FLOAT = 5126
  63758. }
  63759. /** @hidden */
  63760. export enum EShaderType {
  63761. FRAGMENT = 35632,
  63762. VERTEX = 35633
  63763. }
  63764. /** @hidden */
  63765. export enum EParameterType {
  63766. BYTE = 5120,
  63767. UNSIGNED_BYTE = 5121,
  63768. SHORT = 5122,
  63769. UNSIGNED_SHORT = 5123,
  63770. INT = 5124,
  63771. UNSIGNED_INT = 5125,
  63772. FLOAT = 5126,
  63773. FLOAT_VEC2 = 35664,
  63774. FLOAT_VEC3 = 35665,
  63775. FLOAT_VEC4 = 35666,
  63776. INT_VEC2 = 35667,
  63777. INT_VEC3 = 35668,
  63778. INT_VEC4 = 35669,
  63779. BOOL = 35670,
  63780. BOOL_VEC2 = 35671,
  63781. BOOL_VEC3 = 35672,
  63782. BOOL_VEC4 = 35673,
  63783. FLOAT_MAT2 = 35674,
  63784. FLOAT_MAT3 = 35675,
  63785. FLOAT_MAT4 = 35676,
  63786. SAMPLER_2D = 35678
  63787. }
  63788. /** @hidden */
  63789. export enum ETextureWrapMode {
  63790. CLAMP_TO_EDGE = 33071,
  63791. MIRRORED_REPEAT = 33648,
  63792. REPEAT = 10497
  63793. }
  63794. /** @hidden */
  63795. export enum ETextureFilterType {
  63796. NEAREST = 9728,
  63797. LINEAR = 9728,
  63798. NEAREST_MIPMAP_NEAREST = 9984,
  63799. LINEAR_MIPMAP_NEAREST = 9985,
  63800. NEAREST_MIPMAP_LINEAR = 9986,
  63801. LINEAR_MIPMAP_LINEAR = 9987
  63802. }
  63803. /** @hidden */
  63804. export enum ETextureFormat {
  63805. ALPHA = 6406,
  63806. RGB = 6407,
  63807. RGBA = 6408,
  63808. LUMINANCE = 6409,
  63809. LUMINANCE_ALPHA = 6410
  63810. }
  63811. /** @hidden */
  63812. export enum ECullingType {
  63813. FRONT = 1028,
  63814. BACK = 1029,
  63815. FRONT_AND_BACK = 1032
  63816. }
  63817. /** @hidden */
  63818. export enum EBlendingFunction {
  63819. ZERO = 0,
  63820. ONE = 1,
  63821. SRC_COLOR = 768,
  63822. ONE_MINUS_SRC_COLOR = 769,
  63823. DST_COLOR = 774,
  63824. ONE_MINUS_DST_COLOR = 775,
  63825. SRC_ALPHA = 770,
  63826. ONE_MINUS_SRC_ALPHA = 771,
  63827. DST_ALPHA = 772,
  63828. ONE_MINUS_DST_ALPHA = 773,
  63829. CONSTANT_COLOR = 32769,
  63830. ONE_MINUS_CONSTANT_COLOR = 32770,
  63831. CONSTANT_ALPHA = 32771,
  63832. ONE_MINUS_CONSTANT_ALPHA = 32772,
  63833. SRC_ALPHA_SATURATE = 776
  63834. }
  63835. /** @hidden */
  63836. export interface IGLTFProperty {
  63837. extensions?: {
  63838. [key: string]: any;
  63839. };
  63840. extras?: Object;
  63841. }
  63842. /** @hidden */
  63843. export interface IGLTFChildRootProperty extends IGLTFProperty {
  63844. name?: string;
  63845. }
  63846. /** @hidden */
  63847. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  63848. bufferView: string;
  63849. byteOffset: number;
  63850. byteStride: number;
  63851. count: number;
  63852. type: string;
  63853. componentType: EComponentType;
  63854. max?: number[];
  63855. min?: number[];
  63856. name?: string;
  63857. }
  63858. /** @hidden */
  63859. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  63860. buffer: string;
  63861. byteOffset: number;
  63862. byteLength: number;
  63863. byteStride: number;
  63864. target?: number;
  63865. }
  63866. /** @hidden */
  63867. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  63868. uri: string;
  63869. byteLength?: number;
  63870. type?: string;
  63871. }
  63872. /** @hidden */
  63873. export interface IGLTFShader extends IGLTFChildRootProperty {
  63874. uri: string;
  63875. type: EShaderType;
  63876. }
  63877. /** @hidden */
  63878. export interface IGLTFProgram extends IGLTFChildRootProperty {
  63879. attributes: string[];
  63880. fragmentShader: string;
  63881. vertexShader: string;
  63882. }
  63883. /** @hidden */
  63884. export interface IGLTFTechniqueParameter {
  63885. type: number;
  63886. count?: number;
  63887. semantic?: string;
  63888. node?: string;
  63889. value?: number | boolean | string | Array<any>;
  63890. source?: string;
  63891. babylonValue?: any;
  63892. }
  63893. /** @hidden */
  63894. export interface IGLTFTechniqueCommonProfile {
  63895. lightingModel: string;
  63896. texcoordBindings: Object;
  63897. parameters?: Array<any>;
  63898. }
  63899. /** @hidden */
  63900. export interface IGLTFTechniqueStatesFunctions {
  63901. blendColor?: number[];
  63902. blendEquationSeparate?: number[];
  63903. blendFuncSeparate?: number[];
  63904. colorMask: boolean[];
  63905. cullFace: number[];
  63906. }
  63907. /** @hidden */
  63908. export interface IGLTFTechniqueStates {
  63909. enable: number[];
  63910. functions: IGLTFTechniqueStatesFunctions;
  63911. }
  63912. /** @hidden */
  63913. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  63914. parameters: {
  63915. [key: string]: IGLTFTechniqueParameter;
  63916. };
  63917. program: string;
  63918. attributes: {
  63919. [key: string]: string;
  63920. };
  63921. uniforms: {
  63922. [key: string]: string;
  63923. };
  63924. states: IGLTFTechniqueStates;
  63925. }
  63926. /** @hidden */
  63927. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  63928. technique?: string;
  63929. values: string[];
  63930. }
  63931. /** @hidden */
  63932. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  63933. attributes: {
  63934. [key: string]: string;
  63935. };
  63936. indices: string;
  63937. material: string;
  63938. mode?: number;
  63939. }
  63940. /** @hidden */
  63941. export interface IGLTFMesh extends IGLTFChildRootProperty {
  63942. primitives: IGLTFMeshPrimitive[];
  63943. }
  63944. /** @hidden */
  63945. export interface IGLTFImage extends IGLTFChildRootProperty {
  63946. uri: string;
  63947. }
  63948. /** @hidden */
  63949. export interface IGLTFSampler extends IGLTFChildRootProperty {
  63950. magFilter?: number;
  63951. minFilter?: number;
  63952. wrapS?: number;
  63953. wrapT?: number;
  63954. }
  63955. /** @hidden */
  63956. export interface IGLTFTexture extends IGLTFChildRootProperty {
  63957. sampler: string;
  63958. source: string;
  63959. format?: ETextureFormat;
  63960. internalFormat?: ETextureFormat;
  63961. target?: number;
  63962. type?: number;
  63963. babylonTexture?: Texture;
  63964. }
  63965. /** @hidden */
  63966. export interface IGLTFAmbienLight {
  63967. color?: number[];
  63968. }
  63969. /** @hidden */
  63970. export interface IGLTFDirectionalLight {
  63971. color?: number[];
  63972. }
  63973. /** @hidden */
  63974. export interface IGLTFPointLight {
  63975. color?: number[];
  63976. constantAttenuation?: number;
  63977. linearAttenuation?: number;
  63978. quadraticAttenuation?: number;
  63979. }
  63980. /** @hidden */
  63981. export interface IGLTFSpotLight {
  63982. color?: number[];
  63983. constantAttenuation?: number;
  63984. fallOfAngle?: number;
  63985. fallOffExponent?: number;
  63986. linearAttenuation?: number;
  63987. quadraticAttenuation?: number;
  63988. }
  63989. /** @hidden */
  63990. export interface IGLTFLight extends IGLTFChildRootProperty {
  63991. type: string;
  63992. }
  63993. /** @hidden */
  63994. export interface IGLTFCameraOrthographic {
  63995. xmag: number;
  63996. ymag: number;
  63997. zfar: number;
  63998. znear: number;
  63999. }
  64000. /** @hidden */
  64001. export interface IGLTFCameraPerspective {
  64002. aspectRatio: number;
  64003. yfov: number;
  64004. zfar: number;
  64005. znear: number;
  64006. }
  64007. /** @hidden */
  64008. export interface IGLTFCamera extends IGLTFChildRootProperty {
  64009. type: string;
  64010. }
  64011. /** @hidden */
  64012. export interface IGLTFAnimationChannelTarget {
  64013. id: string;
  64014. path: string;
  64015. }
  64016. /** @hidden */
  64017. export interface IGLTFAnimationChannel {
  64018. sampler: string;
  64019. target: IGLTFAnimationChannelTarget;
  64020. }
  64021. /** @hidden */
  64022. export interface IGLTFAnimationSampler {
  64023. input: string;
  64024. output: string;
  64025. interpolation?: string;
  64026. }
  64027. /** @hidden */
  64028. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  64029. channels?: IGLTFAnimationChannel[];
  64030. parameters?: {
  64031. [key: string]: string;
  64032. };
  64033. samplers?: {
  64034. [key: string]: IGLTFAnimationSampler;
  64035. };
  64036. }
  64037. /** @hidden */
  64038. export interface IGLTFNodeInstanceSkin {
  64039. skeletons: string[];
  64040. skin: string;
  64041. meshes: string[];
  64042. }
  64043. /** @hidden */
  64044. export interface IGLTFSkins extends IGLTFChildRootProperty {
  64045. bindShapeMatrix: number[];
  64046. inverseBindMatrices: string;
  64047. jointNames: string[];
  64048. babylonSkeleton?: Skeleton;
  64049. }
  64050. /** @hidden */
  64051. export interface IGLTFNode extends IGLTFChildRootProperty {
  64052. camera?: string;
  64053. children: string[];
  64054. skin?: string;
  64055. jointName?: string;
  64056. light?: string;
  64057. matrix: number[];
  64058. mesh?: string;
  64059. meshes?: string[];
  64060. rotation?: number[];
  64061. scale?: number[];
  64062. translation?: number[];
  64063. babylonNode?: Node;
  64064. }
  64065. /** @hidden */
  64066. export interface IGLTFScene extends IGLTFChildRootProperty {
  64067. nodes: string[];
  64068. }
  64069. /** @hidden */
  64070. export interface IGLTFRuntime {
  64071. extensions: {
  64072. [key: string]: any;
  64073. };
  64074. accessors: {
  64075. [key: string]: IGLTFAccessor;
  64076. };
  64077. buffers: {
  64078. [key: string]: IGLTFBuffer;
  64079. };
  64080. bufferViews: {
  64081. [key: string]: IGLTFBufferView;
  64082. };
  64083. meshes: {
  64084. [key: string]: IGLTFMesh;
  64085. };
  64086. lights: {
  64087. [key: string]: IGLTFLight;
  64088. };
  64089. cameras: {
  64090. [key: string]: IGLTFCamera;
  64091. };
  64092. nodes: {
  64093. [key: string]: IGLTFNode;
  64094. };
  64095. images: {
  64096. [key: string]: IGLTFImage;
  64097. };
  64098. textures: {
  64099. [key: string]: IGLTFTexture;
  64100. };
  64101. shaders: {
  64102. [key: string]: IGLTFShader;
  64103. };
  64104. programs: {
  64105. [key: string]: IGLTFProgram;
  64106. };
  64107. samplers: {
  64108. [key: string]: IGLTFSampler;
  64109. };
  64110. techniques: {
  64111. [key: string]: IGLTFTechnique;
  64112. };
  64113. materials: {
  64114. [key: string]: IGLTFMaterial;
  64115. };
  64116. animations: {
  64117. [key: string]: IGLTFAnimation;
  64118. };
  64119. skins: {
  64120. [key: string]: IGLTFSkins;
  64121. };
  64122. currentScene?: Object;
  64123. scenes: {
  64124. [key: string]: IGLTFScene;
  64125. };
  64126. extensionsUsed: string[];
  64127. extensionsRequired?: string[];
  64128. buffersCount: number;
  64129. shaderscount: number;
  64130. scene: Scene;
  64131. rootUrl: string;
  64132. loadedBufferCount: number;
  64133. loadedBufferViews: {
  64134. [name: string]: ArrayBufferView;
  64135. };
  64136. loadedShaderCount: number;
  64137. importOnlyMeshes: boolean;
  64138. importMeshesNames?: string[];
  64139. dummyNodes: Node[];
  64140. }
  64141. /** @hidden */
  64142. export interface INodeToRoot {
  64143. bone: Bone;
  64144. node: IGLTFNode;
  64145. id: string;
  64146. }
  64147. /** @hidden */
  64148. export interface IJointNode {
  64149. node: IGLTFNode;
  64150. id: string;
  64151. }
  64152. }
  64153. declare module BABYLON.GLTF1 {
  64154. /**
  64155. * Utils functions for GLTF
  64156. * @hidden
  64157. */
  64158. export class GLTFUtils {
  64159. /**
  64160. * Sets the given "parameter" matrix
  64161. * @param scene: the Scene object
  64162. * @param source: the source node where to pick the matrix
  64163. * @param parameter: the GLTF technique parameter
  64164. * @param uniformName: the name of the shader's uniform
  64165. * @param shaderMaterial: the shader material
  64166. */
  64167. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  64168. /**
  64169. * Sets the given "parameter" matrix
  64170. * @param shaderMaterial: the shader material
  64171. * @param uniform: the name of the shader's uniform
  64172. * @param value: the value of the uniform
  64173. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  64174. */
  64175. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  64176. /**
  64177. * Returns the wrap mode of the texture
  64178. * @param mode: the mode value
  64179. */
  64180. static GetWrapMode(mode: number): number;
  64181. /**
  64182. * Returns the byte stride giving an accessor
  64183. * @param accessor: the GLTF accessor objet
  64184. */
  64185. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  64186. /**
  64187. * Returns the texture filter mode giving a mode value
  64188. * @param mode: the filter mode value
  64189. */
  64190. static GetTextureFilterMode(mode: number): ETextureFilterType;
  64191. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  64192. /**
  64193. * Returns a buffer from its accessor
  64194. * @param gltfRuntime: the GLTF runtime
  64195. * @param accessor: the GLTF accessor
  64196. */
  64197. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  64198. /**
  64199. * Decodes a buffer view into a string
  64200. * @param view: the buffer view
  64201. */
  64202. static DecodeBufferToText(view: ArrayBufferView): string;
  64203. /**
  64204. * Returns the default material of gltf. Related to
  64205. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  64206. * @param scene: the Babylon.js scene
  64207. */
  64208. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  64209. private static _DefaultMaterial;
  64210. }
  64211. }
  64212. declare module BABYLON.GLTF1 {
  64213. /**
  64214. * Implementation of the base glTF spec
  64215. * @hidden
  64216. */
  64217. export class GLTFLoaderBase {
  64218. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  64219. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  64220. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  64221. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  64222. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  64223. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  64224. }
  64225. /**
  64226. * glTF V1 Loader
  64227. * @hidden
  64228. */
  64229. export class GLTFLoader implements IGLTFLoader {
  64230. static Extensions: {
  64231. [name: string]: GLTFLoaderExtension;
  64232. };
  64233. static RegisterExtension(extension: GLTFLoaderExtension): void;
  64234. state: Nullable<GLTFLoaderState>;
  64235. dispose(): void;
  64236. private _importMeshAsync;
  64237. /**
  64238. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  64239. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64240. * @param scene the scene the meshes should be added to
  64241. * @param data gltf data containing information of the meshes in a loaded file
  64242. * @param rootUrl root url to load from
  64243. * @param onProgress event that fires when loading progress has occured
  64244. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64245. */
  64246. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  64247. meshes: AbstractMesh[];
  64248. particleSystems: IParticleSystem[];
  64249. skeletons: Skeleton[];
  64250. animationGroups: AnimationGroup[];
  64251. }>;
  64252. private _loadAsync;
  64253. /**
  64254. * Imports all objects from a loaded gltf file and adds them to the scene
  64255. * @param scene the scene the objects should be added to
  64256. * @param data gltf data containing information of the meshes in a loaded file
  64257. * @param rootUrl root url to load from
  64258. * @param onProgress event that fires when loading progress has occured
  64259. * @returns a promise which completes when objects have been loaded to the scene
  64260. */
  64261. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  64262. private _loadShadersAsync;
  64263. private _loadBuffersAsync;
  64264. private _createNodes;
  64265. }
  64266. /** @hidden */
  64267. export abstract class GLTFLoaderExtension {
  64268. private _name;
  64269. constructor(name: string);
  64270. readonly name: string;
  64271. /**
  64272. * Defines an override for loading the runtime
  64273. * Return true to stop further extensions from loading the runtime
  64274. */
  64275. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  64276. /**
  64277. * Defines an onverride for creating gltf runtime
  64278. * Return true to stop further extensions from creating the runtime
  64279. */
  64280. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  64281. /**
  64282. * Defines an override for loading buffers
  64283. * Return true to stop further extensions from loading this buffer
  64284. */
  64285. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  64286. /**
  64287. * Defines an override for loading texture buffers
  64288. * Return true to stop further extensions from loading this texture data
  64289. */
  64290. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64291. /**
  64292. * Defines an override for creating textures
  64293. * Return true to stop further extensions from loading this texture
  64294. */
  64295. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  64296. /**
  64297. * Defines an override for loading shader strings
  64298. * Return true to stop further extensions from loading this shader data
  64299. */
  64300. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  64301. /**
  64302. * Defines an override for loading materials
  64303. * Return true to stop further extensions from loading this material
  64304. */
  64305. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  64306. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  64307. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  64308. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  64309. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  64310. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  64311. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  64312. private static LoadTextureBufferAsync;
  64313. private static CreateTextureAsync;
  64314. private static ApplyExtensions;
  64315. }
  64316. }
  64317. declare module BABYLON.GLTF1 {
  64318. /** @hidden */
  64319. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  64320. private _bin;
  64321. constructor();
  64322. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  64323. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64324. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64325. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  64326. }
  64327. }
  64328. declare module BABYLON.GLTF1 {
  64329. /** @hidden */
  64330. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  64331. constructor();
  64332. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  64333. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  64334. private _loadTexture;
  64335. }
  64336. }
  64337. declare module BABYLON.GLTF2.Loader {
  64338. /**
  64339. * Loader interface with an index field.
  64340. */
  64341. export interface IArrayItem {
  64342. /**
  64343. * The index of this item in the array.
  64344. */
  64345. index: number;
  64346. }
  64347. /**
  64348. * Loader interface with additional members.
  64349. */
  64350. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  64351. /** @hidden */
  64352. _data?: Promise<ArrayBufferView>;
  64353. /** @hidden */
  64354. _babylonVertexBuffer?: Promise<VertexBuffer>;
  64355. }
  64356. /**
  64357. * Loader interface with additional members.
  64358. */
  64359. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  64360. }
  64361. /** @hidden */
  64362. export interface _IAnimationSamplerData {
  64363. input: Float32Array;
  64364. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  64365. output: Float32Array;
  64366. }
  64367. /**
  64368. * Loader interface with additional members.
  64369. */
  64370. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  64371. /** @hidden */
  64372. _data?: Promise<_IAnimationSamplerData>;
  64373. }
  64374. /**
  64375. * Loader interface with additional members.
  64376. */
  64377. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  64378. channels: IAnimationChannel[];
  64379. samplers: IAnimationSampler[];
  64380. /** @hidden */
  64381. _babylonAnimationGroup?: AnimationGroup;
  64382. }
  64383. /**
  64384. * Loader interface with additional members.
  64385. */
  64386. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  64387. /** @hidden */
  64388. _data?: Promise<ArrayBufferView>;
  64389. }
  64390. /**
  64391. * Loader interface with additional members.
  64392. */
  64393. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  64394. /** @hidden */
  64395. _data?: Promise<ArrayBufferView>;
  64396. /** @hidden */
  64397. _babylonBuffer?: Promise<Buffer>;
  64398. }
  64399. /**
  64400. * Loader interface with additional members.
  64401. */
  64402. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  64403. }
  64404. /**
  64405. * Loader interface with additional members.
  64406. */
  64407. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  64408. /** @hidden */
  64409. _data?: Promise<ArrayBufferView>;
  64410. }
  64411. /**
  64412. * Loader interface with additional members.
  64413. */
  64414. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  64415. }
  64416. /**
  64417. * Loader interface with additional members.
  64418. */
  64419. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  64420. }
  64421. /**
  64422. * Loader interface with additional members.
  64423. */
  64424. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  64425. baseColorTexture?: ITextureInfo;
  64426. metallicRoughnessTexture?: ITextureInfo;
  64427. }
  64428. /**
  64429. * Loader interface with additional members.
  64430. */
  64431. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  64432. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  64433. normalTexture?: IMaterialNormalTextureInfo;
  64434. occlusionTexture?: IMaterialOcclusionTextureInfo;
  64435. emissiveTexture?: ITextureInfo;
  64436. /** @hidden */
  64437. _data?: {
  64438. [babylonDrawMode: number]: {
  64439. babylonMaterial: Material;
  64440. babylonMeshes: AbstractMesh[];
  64441. promise: Promise<void>;
  64442. };
  64443. };
  64444. }
  64445. /**
  64446. * Loader interface with additional members.
  64447. */
  64448. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  64449. primitives: IMeshPrimitive[];
  64450. }
  64451. /**
  64452. * Loader interface with additional members.
  64453. */
  64454. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  64455. /** @hidden */
  64456. _instanceData?: {
  64457. babylonSourceMesh: Mesh;
  64458. promise: Promise<any>;
  64459. };
  64460. }
  64461. /**
  64462. * Loader interface with additional members.
  64463. */
  64464. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  64465. /**
  64466. * The parent glTF node.
  64467. */
  64468. parent?: INode;
  64469. /** @hidden */
  64470. _babylonTransformNode?: TransformNode;
  64471. /** @hidden */
  64472. _primitiveBabylonMeshes?: AbstractMesh[];
  64473. /** @hidden */
  64474. _babylonBones?: Bone[];
  64475. /** @hidden */
  64476. _numMorphTargets?: number;
  64477. }
  64478. /** @hidden */
  64479. export interface _ISamplerData {
  64480. noMipMaps: boolean;
  64481. samplingMode: number;
  64482. wrapU: number;
  64483. wrapV: number;
  64484. }
  64485. /**
  64486. * Loader interface with additional members.
  64487. */
  64488. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  64489. /** @hidden */
  64490. _data?: _ISamplerData;
  64491. }
  64492. /**
  64493. * Loader interface with additional members.
  64494. */
  64495. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  64496. }
  64497. /**
  64498. * Loader interface with additional members.
  64499. */
  64500. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  64501. /** @hidden */
  64502. _data?: {
  64503. babylonSkeleton: Skeleton;
  64504. promise: Promise<void>;
  64505. };
  64506. }
  64507. /**
  64508. * Loader interface with additional members.
  64509. */
  64510. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  64511. }
  64512. /**
  64513. * Loader interface with additional members.
  64514. */
  64515. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  64516. }
  64517. /**
  64518. * Loader interface with additional members.
  64519. */
  64520. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  64521. accessors?: IAccessor[];
  64522. animations?: IAnimation[];
  64523. buffers?: IBuffer[];
  64524. bufferViews?: IBufferView[];
  64525. cameras?: ICamera[];
  64526. images?: IImage[];
  64527. materials?: IMaterial[];
  64528. meshes?: IMesh[];
  64529. nodes?: INode[];
  64530. samplers?: ISampler[];
  64531. scenes?: IScene[];
  64532. skins?: ISkin[];
  64533. textures?: ITexture[];
  64534. }
  64535. }
  64536. declare module BABYLON.GLTF2 {
  64537. /**
  64538. * Interface for a glTF loader extension.
  64539. */
  64540. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  64541. /**
  64542. * Called after the loader state changes to LOADING.
  64543. */
  64544. onLoading?(): void;
  64545. /**
  64546. * Called after the loader state changes to READY.
  64547. */
  64548. onReady?(): void;
  64549. /**
  64550. * Define this method to modify the default behavior when loading scenes.
  64551. * @param context The context when loading the asset
  64552. * @param scene The glTF scene property
  64553. * @returns A promise that resolves when the load is complete or null if not handled
  64554. */
  64555. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  64556. /**
  64557. * Define this method to modify the default behavior when loading nodes.
  64558. * @param context The context when loading the asset
  64559. * @param node The glTF node property
  64560. * @param assign A function called synchronously after parsing the glTF properties
  64561. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  64562. */
  64563. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64564. /**
  64565. * Define this method to modify the default behavior when loading cameras.
  64566. * @param context The context when loading the asset
  64567. * @param camera The glTF camera property
  64568. * @param assign A function called synchronously after parsing the glTF properties
  64569. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  64570. */
  64571. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  64572. /**
  64573. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  64574. * @param context The context when loading the asset
  64575. * @param primitive The glTF mesh primitive property
  64576. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  64577. */
  64578. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  64579. /**
  64580. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  64581. * @param context The context when loading the asset
  64582. * @param name The mesh name when loading the asset
  64583. * @param node The glTF node when loading the asset
  64584. * @param mesh The glTF mesh when loading the asset
  64585. * @param primitive The glTF mesh primitive property
  64586. * @param assign A function called synchronously after parsing the glTF properties
  64587. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  64588. */
  64589. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  64590. /**
  64591. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  64592. * @param context The context when loading the asset
  64593. * @param material The glTF material property
  64594. * @param assign A function called synchronously after parsing the glTF properties
  64595. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  64596. */
  64597. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  64598. /**
  64599. * Define this method to modify the default behavior when creating materials.
  64600. * @param context The context when loading the asset
  64601. * @param material The glTF material property
  64602. * @param babylonDrawMode The draw mode for the Babylon material
  64603. * @returns The Babylon material or null if not handled
  64604. */
  64605. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  64606. /**
  64607. * Define this method to modify the default behavior when loading material properties.
  64608. * @param context The context when loading the asset
  64609. * @param material The glTF material property
  64610. * @param babylonMaterial The Babylon material
  64611. * @returns A promise that resolves when the load is complete or null if not handled
  64612. */
  64613. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64614. /**
  64615. * Define this method to modify the default behavior when loading texture infos.
  64616. * @param context The context when loading the asset
  64617. * @param textureInfo The glTF texture info property
  64618. * @param assign A function called synchronously after parsing the glTF properties
  64619. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  64620. */
  64621. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  64622. /**
  64623. * Define this method to modify the default behavior when loading animations.
  64624. * @param context The context when loading the asset
  64625. * @param animation The glTF animation property
  64626. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  64627. */
  64628. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  64629. /**
  64630. * @hidden Define this method to modify the default behavior when loading skins.
  64631. * @param context The context when loading the asset
  64632. * @param node The glTF node property
  64633. * @param skin The glTF skin property
  64634. * @returns A promise that resolves when the load is complete or null if not handled
  64635. */
  64636. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  64637. /**
  64638. * @hidden Define this method to modify the default behavior when loading uris.
  64639. * @param context The context when loading the asset
  64640. * @param property The glTF property associated with the uri
  64641. * @param uri The uri to load
  64642. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  64643. */
  64644. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  64645. }
  64646. }
  64647. declare module BABYLON.GLTF2 {
  64648. /**
  64649. * Helper class for working with arrays when loading the glTF asset
  64650. */
  64651. export class ArrayItem {
  64652. /**
  64653. * Gets an item from the given array.
  64654. * @param context The context when loading the asset
  64655. * @param array The array to get the item from
  64656. * @param index The index to the array
  64657. * @returns The array item
  64658. */
  64659. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  64660. /**
  64661. * Assign an `index` field to each item of the given array.
  64662. * @param array The array of items
  64663. */
  64664. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  64665. }
  64666. /**
  64667. * The glTF 2.0 loader
  64668. */
  64669. export class GLTFLoader implements IGLTFLoader {
  64670. /** @hidden */
  64671. _completePromises: Promise<any>[];
  64672. private _disposed;
  64673. private _parent;
  64674. private _state;
  64675. private _extensions;
  64676. private _rootUrl;
  64677. private _fileName;
  64678. private _uniqueRootUrl;
  64679. private _gltf;
  64680. private _babylonScene;
  64681. private _rootBabylonMesh;
  64682. private _defaultBabylonMaterialData;
  64683. private _progressCallback?;
  64684. private _requests;
  64685. private static readonly _DefaultSampler;
  64686. private static _ExtensionNames;
  64687. private static _ExtensionFactories;
  64688. /**
  64689. * Registers a loader extension.
  64690. * @param name The name of the loader extension.
  64691. * @param factory The factory function that creates the loader extension.
  64692. */
  64693. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  64694. /**
  64695. * Unregisters a loader extension.
  64696. * @param name The name of the loader extenion.
  64697. * @returns A boolean indicating whether the extension has been unregistered
  64698. */
  64699. static UnregisterExtension(name: string): boolean;
  64700. /**
  64701. * Gets the loader state.
  64702. */
  64703. readonly state: Nullable<GLTFLoaderState>;
  64704. /**
  64705. * The glTF object parsed from the JSON.
  64706. */
  64707. readonly gltf: IGLTF;
  64708. /**
  64709. * The Babylon scene when loading the asset.
  64710. */
  64711. readonly babylonScene: Scene;
  64712. /**
  64713. * The root Babylon mesh when loading the asset.
  64714. */
  64715. readonly rootBabylonMesh: Mesh;
  64716. /** @hidden */
  64717. constructor(parent: GLTFFileLoader);
  64718. /** @hidden */
  64719. dispose(): void;
  64720. /** @hidden */
  64721. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64722. meshes: AbstractMesh[];
  64723. particleSystems: IParticleSystem[];
  64724. skeletons: Skeleton[];
  64725. animationGroups: AnimationGroup[];
  64726. }>;
  64727. /** @hidden */
  64728. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64729. private _loadAsync;
  64730. private _loadData;
  64731. private _setupData;
  64732. private _loadExtensions;
  64733. private _checkExtensions;
  64734. private _setState;
  64735. private _createRootNode;
  64736. /**
  64737. * Loads a glTF scene.
  64738. * @param context The context when loading the asset
  64739. * @param scene The glTF scene property
  64740. * @returns A promise that resolves when the load is complete
  64741. */
  64742. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  64743. private _forEachPrimitive;
  64744. private _getMeshes;
  64745. private _getSkeletons;
  64746. private _getAnimationGroups;
  64747. private _startAnimations;
  64748. /**
  64749. * Loads a glTF node.
  64750. * @param context The context when loading the asset
  64751. * @param node The glTF node property
  64752. * @param assign A function called synchronously after parsing the glTF properties
  64753. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  64754. */
  64755. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  64756. private _loadMeshAsync;
  64757. /**
  64758. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  64759. * @param context The context when loading the asset
  64760. * @param name The mesh name when loading the asset
  64761. * @param node The glTF node when loading the asset
  64762. * @param mesh The glTF mesh when loading the asset
  64763. * @param primitive The glTF mesh primitive property
  64764. * @param assign A function called synchronously after parsing the glTF properties
  64765. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  64766. */
  64767. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  64768. private _loadVertexDataAsync;
  64769. private _createMorphTargets;
  64770. private _loadMorphTargetsAsync;
  64771. private _loadMorphTargetVertexDataAsync;
  64772. private static _LoadTransform;
  64773. private _loadSkinAsync;
  64774. private _loadBones;
  64775. private _loadBone;
  64776. private _loadSkinInverseBindMatricesDataAsync;
  64777. private _updateBoneMatrices;
  64778. private _getNodeMatrix;
  64779. /**
  64780. * Loads a glTF camera.
  64781. * @param context The context when loading the asset
  64782. * @param camera The glTF camera property
  64783. * @param assign A function called synchronously after parsing the glTF properties
  64784. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  64785. */
  64786. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  64787. private _loadAnimationsAsync;
  64788. /**
  64789. * Loads a glTF animation.
  64790. * @param context The context when loading the asset
  64791. * @param animation The glTF animation property
  64792. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  64793. */
  64794. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  64795. /**
  64796. * @hidden Loads a glTF animation channel.
  64797. * @param context The context when loading the asset
  64798. * @param animationContext The context of the animation when loading the asset
  64799. * @param animation The glTF animation property
  64800. * @param channel The glTF animation channel property
  64801. * @param babylonAnimationGroup The babylon animation group property
  64802. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  64803. * @returns A void promise when the channel load is complete
  64804. */
  64805. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  64806. private _loadAnimationSamplerAsync;
  64807. private _loadBufferAsync;
  64808. /**
  64809. * Loads a glTF buffer view.
  64810. * @param context The context when loading the asset
  64811. * @param bufferView The glTF buffer view property
  64812. * @returns A promise that resolves with the loaded data when the load is complete
  64813. */
  64814. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  64815. private _loadIndicesAccessorAsync;
  64816. private _loadFloatAccessorAsync;
  64817. private _loadVertexBufferViewAsync;
  64818. private _loadVertexAccessorAsync;
  64819. private _loadMaterialMetallicRoughnessPropertiesAsync;
  64820. /** @hidden */
  64821. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  64822. private _createDefaultMaterial;
  64823. /**
  64824. * Creates a Babylon material from a glTF material.
  64825. * @param context The context when loading the asset
  64826. * @param material The glTF material property
  64827. * @param babylonDrawMode The draw mode for the Babylon material
  64828. * @returns The Babylon material
  64829. */
  64830. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  64831. /**
  64832. * Loads properties from a glTF material into a Babylon material.
  64833. * @param context The context when loading the asset
  64834. * @param material The glTF material property
  64835. * @param babylonMaterial The Babylon material
  64836. * @returns A promise that resolves when the load is complete
  64837. */
  64838. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  64839. /**
  64840. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  64841. * @param context The context when loading the asset
  64842. * @param material The glTF material property
  64843. * @param babylonMaterial The Babylon material
  64844. * @returns A promise that resolves when the load is complete
  64845. */
  64846. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  64847. /**
  64848. * Loads the alpha properties from a glTF material into a Babylon material.
  64849. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  64850. * @param context The context when loading the asset
  64851. * @param material The glTF material property
  64852. * @param babylonMaterial The Babylon material
  64853. */
  64854. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  64855. /**
  64856. * Loads a glTF texture info.
  64857. * @param context The context when loading the asset
  64858. * @param textureInfo The glTF texture info property
  64859. * @param assign A function called synchronously after parsing the glTF properties
  64860. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  64861. */
  64862. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  64863. private _loadTextureAsync;
  64864. private _loadSampler;
  64865. /**
  64866. * Loads a glTF image.
  64867. * @param context The context when loading the asset
  64868. * @param image The glTF image property
  64869. * @returns A promise that resolves with the loaded data when the load is complete
  64870. */
  64871. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  64872. /**
  64873. * Loads a glTF uri.
  64874. * @param context The context when loading the asset
  64875. * @param property The glTF property associated with the uri
  64876. * @param uri The base64 or relative uri
  64877. * @returns A promise that resolves with the loaded data when the load is complete
  64878. */
  64879. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  64880. private _onProgress;
  64881. /**
  64882. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  64883. * @param babylonObject the Babylon object with metadata
  64884. * @param pointer the JSON pointer
  64885. */
  64886. static AddPointerMetadata(babylonObject: {
  64887. metadata: any;
  64888. }, pointer: string): void;
  64889. private static _GetTextureWrapMode;
  64890. private static _GetTextureSamplingMode;
  64891. private static _GetTypedArray;
  64892. private static _GetNumComponents;
  64893. private static _ValidateUri;
  64894. private static _GetDrawMode;
  64895. private _compileMaterialsAsync;
  64896. private _compileShadowGeneratorsAsync;
  64897. private _forEachExtensions;
  64898. private _applyExtensions;
  64899. private _extensionsOnLoading;
  64900. private _extensionsOnReady;
  64901. private _extensionsLoadSceneAsync;
  64902. private _extensionsLoadNodeAsync;
  64903. private _extensionsLoadCameraAsync;
  64904. private _extensionsLoadVertexDataAsync;
  64905. private _extensionsLoadMeshPrimitiveAsync;
  64906. private _extensionsLoadMaterialAsync;
  64907. private _extensionsCreateMaterial;
  64908. private _extensionsLoadMaterialPropertiesAsync;
  64909. private _extensionsLoadTextureInfoAsync;
  64910. private _extensionsLoadAnimationAsync;
  64911. private _extensionsLoadSkinAsync;
  64912. private _extensionsLoadUriAsync;
  64913. /**
  64914. * Helper method called by a loader extension to load an glTF extension.
  64915. * @param context The context when loading the asset
  64916. * @param property The glTF property to load the extension from
  64917. * @param extensionName The name of the extension to load
  64918. * @param actionAsync The action to run
  64919. * @returns The promise returned by actionAsync or null if the extension does not exist
  64920. */
  64921. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  64922. /**
  64923. * Helper method called by a loader extension to load a glTF extra.
  64924. * @param context The context when loading the asset
  64925. * @param property The glTF property to load the extra from
  64926. * @param extensionName The name of the extension to load
  64927. * @param actionAsync The action to run
  64928. * @returns The promise returned by actionAsync or null if the extra does not exist
  64929. */
  64930. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  64931. /**
  64932. * Increments the indentation level and logs a message.
  64933. * @param message The message to log
  64934. */
  64935. logOpen(message: string): void;
  64936. /**
  64937. * Decrements the indentation level.
  64938. */
  64939. logClose(): void;
  64940. /**
  64941. * Logs a message
  64942. * @param message The message to log
  64943. */
  64944. log(message: string): void;
  64945. /**
  64946. * Starts a performance counter.
  64947. * @param counterName The name of the performance counter
  64948. */
  64949. startPerformanceCounter(counterName: string): void;
  64950. /**
  64951. * Ends a performance counter.
  64952. * @param counterName The name of the performance counter
  64953. */
  64954. endPerformanceCounter(counterName: string): void;
  64955. }
  64956. }
  64957. declare module BABYLON.GLTF2.Loader.Extensions {
  64958. /**
  64959. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  64960. */
  64961. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  64962. /** The name of this extension. */
  64963. readonly name: string;
  64964. /** Defines whether this extension is enabled. */
  64965. enabled: boolean;
  64966. private _loader;
  64967. private _lights?;
  64968. /** @hidden */
  64969. constructor(loader: GLTFLoader);
  64970. /** @hidden */
  64971. dispose(): void;
  64972. /** @hidden */
  64973. onLoading(): void;
  64974. /** @hidden */
  64975. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  64976. private _loadLightAsync;
  64977. }
  64978. }
  64979. declare module BABYLON.GLTF2.Loader.Extensions {
  64980. /**
  64981. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  64982. */
  64983. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  64984. /** The name of this extension. */
  64985. readonly name: string;
  64986. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  64987. dracoCompression?: DracoCompression;
  64988. /** Defines whether this extension is enabled. */
  64989. enabled: boolean;
  64990. private _loader;
  64991. /** @hidden */
  64992. constructor(loader: GLTFLoader);
  64993. /** @hidden */
  64994. dispose(): void;
  64995. /** @hidden */
  64996. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  64997. }
  64998. }
  64999. declare module BABYLON.GLTF2.Loader.Extensions {
  65000. /**
  65001. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  65002. */
  65003. export class KHR_lights implements IGLTFLoaderExtension {
  65004. /** The name of this extension. */
  65005. readonly name: string;
  65006. /** Defines whether this extension is enabled. */
  65007. enabled: boolean;
  65008. private _loader;
  65009. private _lights?;
  65010. /** @hidden */
  65011. constructor(loader: GLTFLoader);
  65012. /** @hidden */
  65013. dispose(): void;
  65014. /** @hidden */
  65015. onLoading(): void;
  65016. /** @hidden */
  65017. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65018. }
  65019. }
  65020. declare module BABYLON.GLTF2.Loader.Extensions {
  65021. /**
  65022. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  65023. */
  65024. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  65025. /** The name of this extension. */
  65026. readonly name: string;
  65027. /** Defines whether this extension is enabled. */
  65028. enabled: boolean;
  65029. private _loader;
  65030. /** @hidden */
  65031. constructor(loader: GLTFLoader);
  65032. /** @hidden */
  65033. dispose(): void;
  65034. /** @hidden */
  65035. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65036. private _loadSpecularGlossinessPropertiesAsync;
  65037. }
  65038. }
  65039. declare module BABYLON.GLTF2.Loader.Extensions {
  65040. /**
  65041. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  65042. */
  65043. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  65044. /** The name of this extension. */
  65045. readonly name: string;
  65046. /** Defines whether this extension is enabled. */
  65047. enabled: boolean;
  65048. private _loader;
  65049. /** @hidden */
  65050. constructor(loader: GLTFLoader);
  65051. /** @hidden */
  65052. dispose(): void;
  65053. /** @hidden */
  65054. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65055. private _loadUnlitPropertiesAsync;
  65056. }
  65057. }
  65058. declare module BABYLON.GLTF2.Loader.Extensions {
  65059. /**
  65060. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  65061. */
  65062. export class KHR_texture_transform implements IGLTFLoaderExtension {
  65063. /** The name of this extension. */
  65064. readonly name: string;
  65065. /** Defines whether this extension is enabled. */
  65066. enabled: boolean;
  65067. private _loader;
  65068. /** @hidden */
  65069. constructor(loader: GLTFLoader);
  65070. /** @hidden */
  65071. dispose(): void;
  65072. /** @hidden */
  65073. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  65074. }
  65075. }
  65076. declare module BABYLON.GLTF2.Loader.Extensions {
  65077. /**
  65078. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  65079. */
  65080. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  65081. /** The name of this extension. */
  65082. readonly name: string;
  65083. /** Defines whether this extension is enabled. */
  65084. enabled: boolean;
  65085. private _loader;
  65086. private _clips;
  65087. private _emitters;
  65088. /** @hidden */
  65089. constructor(loader: GLTFLoader);
  65090. /** @hidden */
  65091. dispose(): void;
  65092. /** @hidden */
  65093. onLoading(): void;
  65094. /** @hidden */
  65095. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  65096. /** @hidden */
  65097. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65098. /** @hidden */
  65099. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  65100. private _loadClipAsync;
  65101. private _loadEmitterAsync;
  65102. private _getEventAction;
  65103. private _loadAnimationEventAsync;
  65104. }
  65105. }
  65106. declare module BABYLON.GLTF2.Loader.Extensions {
  65107. /**
  65108. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  65109. */
  65110. export class MSFT_lod implements IGLTFLoaderExtension {
  65111. /** The name of this extension. */
  65112. readonly name: string;
  65113. /** Defines whether this extension is enabled. */
  65114. enabled: boolean;
  65115. /**
  65116. * Maximum number of LODs to load, starting from the lowest LOD.
  65117. */
  65118. maxLODsToLoad: number;
  65119. /**
  65120. * Observable raised when all node LODs of one level are loaded.
  65121. * The event data is the index of the loaded LOD starting from zero.
  65122. * Dispose the loader to cancel the loading of the next level of LODs.
  65123. */
  65124. onNodeLODsLoadedObservable: Observable<number>;
  65125. /**
  65126. * Observable raised when all material LODs of one level are loaded.
  65127. * The event data is the index of the loaded LOD starting from zero.
  65128. * Dispose the loader to cancel the loading of the next level of LODs.
  65129. */
  65130. onMaterialLODsLoadedObservable: Observable<number>;
  65131. private _loader;
  65132. private _nodeIndexLOD;
  65133. private _nodeSignalLODs;
  65134. private _nodePromiseLODs;
  65135. private _materialIndexLOD;
  65136. private _materialSignalLODs;
  65137. private _materialPromiseLODs;
  65138. /** @hidden */
  65139. constructor(loader: GLTFLoader);
  65140. /** @hidden */
  65141. dispose(): void;
  65142. /** @hidden */
  65143. onReady(): void;
  65144. /** @hidden */
  65145. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65146. /** @hidden */
  65147. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  65148. /** @hidden */
  65149. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  65150. /**
  65151. * Gets an array of LOD properties from lowest to highest.
  65152. */
  65153. private _getLODs;
  65154. private _disposeUnusedMaterials;
  65155. }
  65156. }
  65157. declare module BABYLON.GLTF2.Loader.Extensions {
  65158. /** @hidden */
  65159. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  65160. readonly name: string;
  65161. enabled: boolean;
  65162. private _loader;
  65163. constructor(loader: GLTFLoader);
  65164. dispose(): void;
  65165. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65166. }
  65167. }
  65168. declare module BABYLON.GLTF2.Loader.Extensions {
  65169. /** @hidden */
  65170. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  65171. readonly name: string;
  65172. enabled: boolean;
  65173. private _loader;
  65174. constructor(loader: GLTFLoader);
  65175. dispose(): void;
  65176. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65177. }
  65178. }
  65179. declare module BABYLON {
  65180. /**
  65181. * Class reading and parsing the MTL file bundled with the obj file.
  65182. */
  65183. export class MTLFileLoader {
  65184. /**
  65185. * All material loaded from the mtl will be set here
  65186. */
  65187. materials: StandardMaterial[];
  65188. /**
  65189. * This function will read the mtl file and create each material described inside
  65190. * This function could be improve by adding :
  65191. * -some component missing (Ni, Tf...)
  65192. * -including the specific options available
  65193. *
  65194. * @param scene defines the scene the material will be created in
  65195. * @param data defines the mtl data to parse
  65196. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  65197. */
  65198. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  65199. /**
  65200. * Gets the texture for the material.
  65201. *
  65202. * If the material is imported from input file,
  65203. * We sanitize the url to ensure it takes the textre from aside the material.
  65204. *
  65205. * @param rootUrl The root url to load from
  65206. * @param value The value stored in the mtl
  65207. * @return The Texture
  65208. */
  65209. private static _getTexture;
  65210. }
  65211. /**
  65212. * Options for loading OBJ/MTL files
  65213. */
  65214. type MeshLoadOptions = {
  65215. /**
  65216. * Defines if UVs are optimized by default during load.
  65217. */
  65218. OptimizeWithUV: boolean;
  65219. /**
  65220. * Defines custom scaling of UV coordinates of loaded meshes.
  65221. */
  65222. UVScaling: Vector2;
  65223. /**
  65224. * Invert model on y-axis (does a model scaling inversion)
  65225. */
  65226. InvertY: boolean;
  65227. /**
  65228. * Invert Y-Axis of referenced textures on load
  65229. */
  65230. InvertTextureY: boolean;
  65231. /**
  65232. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  65233. */
  65234. ImportVertexColors: boolean;
  65235. /**
  65236. * Compute the normals for the model, even if normals are present in the file.
  65237. */
  65238. ComputeNormals: boolean;
  65239. /**
  65240. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  65241. */
  65242. SkipMaterials: boolean;
  65243. /**
  65244. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  65245. */
  65246. MaterialLoadingFailsSilently: boolean;
  65247. };
  65248. /**
  65249. * OBJ file type loader.
  65250. * This is a babylon scene loader plugin.
  65251. */
  65252. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  65253. /**
  65254. * Defines if UVs are optimized by default during load.
  65255. */
  65256. static OPTIMIZE_WITH_UV: boolean;
  65257. /**
  65258. * Invert model on y-axis (does a model scaling inversion)
  65259. */
  65260. static INVERT_Y: boolean;
  65261. /**
  65262. * Invert Y-Axis of referenced textures on load
  65263. */
  65264. static INVERT_TEXTURE_Y: boolean;
  65265. /**
  65266. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  65267. */
  65268. static IMPORT_VERTEX_COLORS: boolean;
  65269. /**
  65270. * Compute the normals for the model, even if normals are present in the file.
  65271. */
  65272. static COMPUTE_NORMALS: boolean;
  65273. /**
  65274. * Defines custom scaling of UV coordinates of loaded meshes.
  65275. */
  65276. static UV_SCALING: Vector2;
  65277. /**
  65278. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  65279. */
  65280. static SKIP_MATERIALS: boolean;
  65281. /**
  65282. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  65283. *
  65284. * Defaults to true for backwards compatibility.
  65285. */
  65286. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  65287. /**
  65288. * Defines the name of the plugin.
  65289. */
  65290. name: string;
  65291. /**
  65292. * Defines the extension the plugin is able to load.
  65293. */
  65294. extensions: string;
  65295. /** @hidden */
  65296. obj: RegExp;
  65297. /** @hidden */
  65298. group: RegExp;
  65299. /** @hidden */
  65300. mtllib: RegExp;
  65301. /** @hidden */
  65302. usemtl: RegExp;
  65303. /** @hidden */
  65304. smooth: RegExp;
  65305. /** @hidden */
  65306. vertexPattern: RegExp;
  65307. /** @hidden */
  65308. normalPattern: RegExp;
  65309. /** @hidden */
  65310. uvPattern: RegExp;
  65311. /** @hidden */
  65312. facePattern1: RegExp;
  65313. /** @hidden */
  65314. facePattern2: RegExp;
  65315. /** @hidden */
  65316. facePattern3: RegExp;
  65317. /** @hidden */
  65318. facePattern4: RegExp;
  65319. /** @hidden */
  65320. facePattern5: RegExp;
  65321. private _meshLoadOptions;
  65322. /**
  65323. * Creates loader for .OBJ files
  65324. *
  65325. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  65326. */
  65327. constructor(meshLoadOptions?: MeshLoadOptions);
  65328. private static readonly currentMeshLoadOptions;
  65329. /**
  65330. * Calls synchronously the MTL file attached to this obj.
  65331. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  65332. * Without this function materials are not displayed in the first frame (but displayed after).
  65333. * In consequence it is impossible to get material information in your HTML file
  65334. *
  65335. * @param url The URL of the MTL file
  65336. * @param rootUrl
  65337. * @param onSuccess Callback function to be called when the MTL file is loaded
  65338. * @private
  65339. */
  65340. private _loadMTL;
  65341. /**
  65342. * Instantiates a OBJ file loader plugin.
  65343. * @returns the created plugin
  65344. */
  65345. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  65346. /**
  65347. * If the data string can be loaded directly.
  65348. *
  65349. * @param data string containing the file data
  65350. * @returns if the data can be loaded directly
  65351. */
  65352. canDirectLoad(data: string): boolean;
  65353. /**
  65354. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  65355. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65356. * @param scene the scene the meshes should be added to
  65357. * @param data the OBJ data to load
  65358. * @param rootUrl root url to load from
  65359. * @param onProgress event that fires when loading progress has occured
  65360. * @param fileName Defines the name of the file to load
  65361. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65362. */
  65363. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65364. meshes: AbstractMesh[];
  65365. particleSystems: IParticleSystem[];
  65366. skeletons: Skeleton[];
  65367. animationGroups: AnimationGroup[];
  65368. }>;
  65369. /**
  65370. * Imports all objects from the loaded OBJ data and adds them to the scene
  65371. * @param scene the scene the objects should be added to
  65372. * @param data the OBJ data to load
  65373. * @param rootUrl root url to load from
  65374. * @param onProgress event that fires when loading progress has occured
  65375. * @param fileName Defines the name of the file to load
  65376. * @returns a promise which completes when objects have been loaded to the scene
  65377. */
  65378. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65379. /**
  65380. * Load into an asset container.
  65381. * @param scene The scene to load into
  65382. * @param data The data to import
  65383. * @param rootUrl The root url for scene and resources
  65384. * @param onProgress The callback when the load progresses
  65385. * @param fileName Defines the name of the file to load
  65386. * @returns The loaded asset container
  65387. */
  65388. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  65389. /**
  65390. * Read the OBJ file and create an Array of meshes.
  65391. * Each mesh contains all information given by the OBJ and the MTL file.
  65392. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  65393. *
  65394. * @param meshesNames
  65395. * @param scene Scene The scene where are displayed the data
  65396. * @param data String The content of the obj file
  65397. * @param rootUrl String The path to the folder
  65398. * @returns Array<AbstractMesh>
  65399. * @private
  65400. */
  65401. private _parseSolid;
  65402. }
  65403. }
  65404. declare module BABYLON {
  65405. /**
  65406. * STL file type loader.
  65407. * This is a babylon scene loader plugin.
  65408. */
  65409. export class STLFileLoader implements ISceneLoaderPlugin {
  65410. /** @hidden */
  65411. solidPattern: RegExp;
  65412. /** @hidden */
  65413. facetsPattern: RegExp;
  65414. /** @hidden */
  65415. normalPattern: RegExp;
  65416. /** @hidden */
  65417. vertexPattern: RegExp;
  65418. /**
  65419. * Defines the name of the plugin.
  65420. */
  65421. name: string;
  65422. /**
  65423. * Defines the extensions the stl loader is able to load.
  65424. * force data to come in as an ArrayBuffer
  65425. * we'll convert to string if it looks like it's an ASCII .stl
  65426. */
  65427. extensions: ISceneLoaderPluginExtensions;
  65428. /**
  65429. * Import meshes into a scene.
  65430. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  65431. * @param scene The scene to import into
  65432. * @param data The data to import
  65433. * @param rootUrl The root url for scene and resources
  65434. * @param meshes The meshes array to import into
  65435. * @param particleSystems The particle systems array to import into
  65436. * @param skeletons The skeletons array to import into
  65437. * @param onError The callback when import fails
  65438. * @returns True if successful or false otherwise
  65439. */
  65440. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  65441. /**
  65442. * Load into a scene.
  65443. * @param scene The scene to load into
  65444. * @param data The data to import
  65445. * @param rootUrl The root url for scene and resources
  65446. * @param onError The callback when import fails
  65447. * @returns true if successful or false otherwise
  65448. */
  65449. load(scene: Scene, data: any, rootUrl: string): boolean;
  65450. /**
  65451. * Load into an asset container.
  65452. * @param scene The scene to load into
  65453. * @param data The data to import
  65454. * @param rootUrl The root url for scene and resources
  65455. * @param onError The callback when import fails
  65456. * @returns The loaded asset container
  65457. */
  65458. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  65459. private _isBinary;
  65460. private _parseBinary;
  65461. private _parseASCII;
  65462. }
  65463. }
  65464. declare module BABYLON {
  65465. /**
  65466. * Class for generating OBJ data from a Babylon scene.
  65467. */
  65468. export class OBJExport {
  65469. /**
  65470. * Exports the geometry of a Mesh array in .OBJ file format (text)
  65471. * @param mesh defines the list of meshes to serialize
  65472. * @param materials defines if materials should be exported
  65473. * @param matlibname defines the name of the associated mtl file
  65474. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  65475. * @returns the OBJ content
  65476. */
  65477. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  65478. /**
  65479. * Exports the material(s) of a mesh in .MTL file format (text)
  65480. * @param mesh defines the mesh to extract the material from
  65481. * @returns the mtl content
  65482. */
  65483. static MTL(mesh: Mesh): string;
  65484. }
  65485. }
  65486. declare module BABYLON {
  65487. /** @hidden */
  65488. export var __IGLTFExporterExtension: number;
  65489. /**
  65490. * Interface for extending the exporter
  65491. * @hidden
  65492. */
  65493. export interface IGLTFExporterExtension {
  65494. /**
  65495. * The name of this extension
  65496. */
  65497. readonly name: string;
  65498. /**
  65499. * Defines whether this extension is enabled
  65500. */
  65501. enabled: boolean;
  65502. /**
  65503. * Defines whether this extension is required
  65504. */
  65505. required: boolean;
  65506. }
  65507. }
  65508. declare module BABYLON.GLTF2.Exporter {
  65509. /** @hidden */
  65510. export var __IGLTFExporterExtensionV2: number;
  65511. /**
  65512. * Interface for a glTF exporter extension
  65513. * @hidden
  65514. */
  65515. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  65516. /**
  65517. * Define this method to modify the default behavior before exporting a texture
  65518. * @param context The context when loading the asset
  65519. * @param babylonTexture The glTF texture info property
  65520. * @param mimeType The mime-type of the generated image
  65521. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  65522. */
  65523. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  65524. /**
  65525. * Define this method to modify the default behavior when exporting texture info
  65526. * @param context The context when loading the asset
  65527. * @param meshPrimitive glTF mesh primitive
  65528. * @param babylonSubMesh Babylon submesh
  65529. * @param binaryWriter glTF serializer binary writer instance
  65530. * @returns nullable IMeshPrimitive promise
  65531. */
  65532. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  65533. /**
  65534. * Define this method to modify the default behavior when exporting a node
  65535. * @param context The context when exporting the node
  65536. * @param node glTF node
  65537. * @param babylonNode BabylonJS node
  65538. * @returns nullable INode promise
  65539. */
  65540. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65541. /**
  65542. * Called after the exporter state changes to EXPORTING
  65543. */
  65544. onExporting?(): void;
  65545. }
  65546. }
  65547. declare module BABYLON.GLTF2.Exporter {
  65548. /**
  65549. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  65550. * @hidden
  65551. */
  65552. export class _GLTFMaterialExporter {
  65553. /**
  65554. * Represents the dielectric specular values for R, G and B
  65555. */
  65556. private static readonly _DielectricSpecular;
  65557. /**
  65558. * Allows the maximum specular power to be defined for material calculations
  65559. */
  65560. private static readonly _MaxSpecularPower;
  65561. /**
  65562. * Mapping to store textures
  65563. */
  65564. private _textureMap;
  65565. /**
  65566. * Numeric tolerance value
  65567. */
  65568. private static readonly _Epsilon;
  65569. /**
  65570. * Reference to the glTF Exporter
  65571. */
  65572. private _exporter;
  65573. constructor(exporter: _Exporter);
  65574. /**
  65575. * Specifies if two colors are approximately equal in value
  65576. * @param color1 first color to compare to
  65577. * @param color2 second color to compare to
  65578. * @param epsilon threshold value
  65579. */
  65580. private static FuzzyEquals;
  65581. /**
  65582. * Gets the materials from a Babylon scene and converts them to glTF materials
  65583. * @param scene babylonjs scene
  65584. * @param mimeType texture mime type
  65585. * @param images array of images
  65586. * @param textures array of textures
  65587. * @param materials array of materials
  65588. * @param imageData mapping of texture names to base64 textures
  65589. * @param hasTextureCoords specifies if texture coordinates are present on the material
  65590. */
  65591. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65592. /**
  65593. * Makes a copy of the glTF material without the texture parameters
  65594. * @param originalMaterial original glTF material
  65595. * @returns glTF material without texture parameters
  65596. */
  65597. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  65598. /**
  65599. * Specifies if the material has any texture parameters present
  65600. * @param material glTF Material
  65601. * @returns boolean specifying if texture parameters are present
  65602. */
  65603. _hasTexturesPresent(material: IMaterial): boolean;
  65604. /**
  65605. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  65606. * @param babylonStandardMaterial
  65607. * @returns glTF Metallic Roughness Material representation
  65608. */
  65609. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  65610. /**
  65611. * Computes the metallic factor
  65612. * @param diffuse diffused value
  65613. * @param specular specular value
  65614. * @param oneMinusSpecularStrength one minus the specular strength
  65615. * @returns metallic value
  65616. */
  65617. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  65618. /**
  65619. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  65620. * @param glTFMaterial glTF material
  65621. * @param babylonMaterial Babylon material
  65622. */
  65623. private static _SetAlphaMode;
  65624. /**
  65625. * Converts a Babylon Standard Material to a glTF Material
  65626. * @param babylonStandardMaterial BJS Standard Material
  65627. * @param mimeType mime type to use for the textures
  65628. * @param images array of glTF image interfaces
  65629. * @param textures array of glTF texture interfaces
  65630. * @param materials array of glTF material interfaces
  65631. * @param imageData map of image file name to data
  65632. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65633. */
  65634. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65635. /**
  65636. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  65637. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  65638. * @param mimeType mime type to use for the textures
  65639. * @param images array of glTF image interfaces
  65640. * @param textures array of glTF texture interfaces
  65641. * @param materials array of glTF material interfaces
  65642. * @param imageData map of image file name to data
  65643. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65644. */
  65645. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65646. /**
  65647. * Converts an image typed array buffer to a base64 image
  65648. * @param buffer typed array buffer
  65649. * @param width width of the image
  65650. * @param height height of the image
  65651. * @param mimeType mimetype of the image
  65652. * @returns base64 image string
  65653. */
  65654. private _createBase64FromCanvasAsync;
  65655. /**
  65656. * Generates a white texture based on the specified width and height
  65657. * @param width width of the texture in pixels
  65658. * @param height height of the texture in pixels
  65659. * @param scene babylonjs scene
  65660. * @returns white texture
  65661. */
  65662. private _createWhiteTexture;
  65663. /**
  65664. * 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
  65665. * @param texture1 first texture to resize
  65666. * @param texture2 second texture to resize
  65667. * @param scene babylonjs scene
  65668. * @returns resized textures or null
  65669. */
  65670. private _resizeTexturesToSameDimensions;
  65671. /**
  65672. * Converts an array of pixels to a Float32Array
  65673. * Throws an error if the pixel format is not supported
  65674. * @param pixels - array buffer containing pixel values
  65675. * @returns Float32 of pixels
  65676. */
  65677. private _convertPixelArrayToFloat32;
  65678. /**
  65679. * Convert Specular Glossiness Textures to Metallic Roughness
  65680. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  65681. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  65682. * @param diffuseTexture texture used to store diffuse information
  65683. * @param specularGlossinessTexture texture used to store specular and glossiness information
  65684. * @param factors specular glossiness material factors
  65685. * @param mimeType the mime type to use for the texture
  65686. * @returns pbr metallic roughness interface or null
  65687. */
  65688. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  65689. /**
  65690. * Converts specular glossiness material properties to metallic roughness
  65691. * @param specularGlossiness interface with specular glossiness material properties
  65692. * @returns interface with metallic roughness material properties
  65693. */
  65694. private _convertSpecularGlossinessToMetallicRoughness;
  65695. /**
  65696. * Calculates the surface reflectance, independent of lighting conditions
  65697. * @param color Color source to calculate brightness from
  65698. * @returns number representing the perceived brightness, or zero if color is undefined
  65699. */
  65700. private _getPerceivedBrightness;
  65701. /**
  65702. * Returns the maximum color component value
  65703. * @param color
  65704. * @returns maximum color component value, or zero if color is null or undefined
  65705. */
  65706. private _getMaxComponent;
  65707. /**
  65708. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  65709. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65710. * @param mimeType mime type to use for the textures
  65711. * @param images array of glTF image interfaces
  65712. * @param textures array of glTF texture interfaces
  65713. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  65714. * @param imageData map of image file name to data
  65715. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65716. * @returns glTF PBR Metallic Roughness factors
  65717. */
  65718. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  65719. private _getGLTFTextureSampler;
  65720. private _getGLTFTextureWrapMode;
  65721. private _getGLTFTextureWrapModesSampler;
  65722. /**
  65723. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  65724. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65725. * @param mimeType mime type to use for the textures
  65726. * @param images array of glTF image interfaces
  65727. * @param textures array of glTF texture interfaces
  65728. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  65729. * @param imageData map of image file name to data
  65730. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65731. * @returns glTF PBR Metallic Roughness factors
  65732. */
  65733. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  65734. /**
  65735. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  65736. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65737. * @param mimeType mime type to use for the textures
  65738. * @param images array of glTF image interfaces
  65739. * @param textures array of glTF texture interfaces
  65740. * @param materials array of glTF material interfaces
  65741. * @param imageData map of image file name to data
  65742. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65743. */
  65744. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65745. private setMetallicRoughnessPbrMaterial;
  65746. private getPixelsFromTexture;
  65747. /**
  65748. * Extracts a texture from a Babylon texture into file data and glTF data
  65749. * @param babylonTexture Babylon texture to extract
  65750. * @param mimeType Mime Type of the babylonTexture
  65751. * @return glTF texture info, or null if the texture format is not supported
  65752. */
  65753. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  65754. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  65755. /**
  65756. * Builds a texture from base64 string
  65757. * @param base64Texture base64 texture string
  65758. * @param baseTextureName Name to use for the texture
  65759. * @param mimeType image mime type for the texture
  65760. * @param images array of images
  65761. * @param textures array of textures
  65762. * @param imageData map of image data
  65763. * @returns glTF texture info, or null if the texture format is not supported
  65764. */
  65765. private _getTextureInfoFromBase64;
  65766. }
  65767. }
  65768. declare module BABYLON {
  65769. /**
  65770. * Class for holding and downloading glTF file data
  65771. */
  65772. export class GLTFData {
  65773. /**
  65774. * Object which contains the file name as the key and its data as the value
  65775. */
  65776. glTFFiles: {
  65777. [fileName: string]: string | Blob;
  65778. };
  65779. /**
  65780. * Initializes the glTF file object
  65781. */
  65782. constructor();
  65783. /**
  65784. * Downloads the glTF data as files based on their names and data
  65785. */
  65786. downloadFiles(): void;
  65787. }
  65788. }
  65789. declare module BABYLON {
  65790. /**
  65791. * Holds a collection of exporter options and parameters
  65792. */
  65793. export interface IExportOptions {
  65794. /**
  65795. * Function which indicates whether a babylon node should be exported or not
  65796. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  65797. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  65798. */
  65799. shouldExportNode?(node: Node): boolean;
  65800. /**
  65801. * The sample rate to bake animation curves
  65802. */
  65803. animationSampleRate?: number;
  65804. /**
  65805. * Begin serialization without waiting for the scene to be ready
  65806. */
  65807. exportWithoutWaitingForScene?: boolean;
  65808. }
  65809. /**
  65810. * Class for generating glTF data from a Babylon scene.
  65811. */
  65812. export class GLTF2Export {
  65813. /**
  65814. * Exports the geometry of the scene to .gltf file format asynchronously
  65815. * @param scene Babylon scene with scene hierarchy information
  65816. * @param filePrefix File prefix to use when generating the glTF file
  65817. * @param options Exporter options
  65818. * @returns Returns an object with a .gltf file and associates texture names
  65819. * as keys and their data and paths as values
  65820. */
  65821. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  65822. private static _PreExportAsync;
  65823. private static _PostExportAsync;
  65824. /**
  65825. * Exports the geometry of the scene to .glb file format asychronously
  65826. * @param scene Babylon scene with scene hierarchy information
  65827. * @param filePrefix File prefix to use when generating glb file
  65828. * @param options Exporter options
  65829. * @returns Returns an object with a .glb filename as key and data as value
  65830. */
  65831. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  65832. }
  65833. }
  65834. declare module BABYLON.GLTF2.Exporter {
  65835. /**
  65836. * @hidden
  65837. */
  65838. export class _GLTFUtilities {
  65839. /**
  65840. * Creates a buffer view based on the supplied arguments
  65841. * @param bufferIndex index value of the specified buffer
  65842. * @param byteOffset byte offset value
  65843. * @param byteLength byte length of the bufferView
  65844. * @param byteStride byte distance between conequential elements
  65845. * @param name name of the buffer view
  65846. * @returns bufferView for glTF
  65847. */
  65848. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  65849. /**
  65850. * Creates an accessor based on the supplied arguments
  65851. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  65852. * @param name The name of the accessor
  65853. * @param type The type of the accessor
  65854. * @param componentType The datatype of components in the attribute
  65855. * @param count The number of attributes referenced by this accessor
  65856. * @param byteOffset The offset relative to the start of the bufferView in bytes
  65857. * @param min Minimum value of each component in this attribute
  65858. * @param max Maximum value of each component in this attribute
  65859. * @returns accessor for glTF
  65860. */
  65861. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  65862. /**
  65863. * Calculates the minimum and maximum values of an array of position floats
  65864. * @param positions Positions array of a mesh
  65865. * @param vertexStart Starting vertex offset to calculate min and max values
  65866. * @param vertexCount Number of vertices to check for min and max values
  65867. * @returns min number array and max number array
  65868. */
  65869. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  65870. min: number[];
  65871. max: number[];
  65872. };
  65873. /**
  65874. * Converts a new right-handed Vector3
  65875. * @param vector vector3 array
  65876. * @returns right-handed Vector3
  65877. */
  65878. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  65879. /**
  65880. * Converts a Vector3 to right-handed
  65881. * @param vector Vector3 to convert to right-handed
  65882. */
  65883. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  65884. /**
  65885. * Converts a three element number array to right-handed
  65886. * @param vector number array to convert to right-handed
  65887. */
  65888. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  65889. /**
  65890. * Converts a new right-handed Vector3
  65891. * @param vector vector3 array
  65892. * @returns right-handed Vector3
  65893. */
  65894. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  65895. /**
  65896. * Converts a Vector3 to right-handed
  65897. * @param vector Vector3 to convert to right-handed
  65898. */
  65899. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  65900. /**
  65901. * Converts a three element number array to right-handed
  65902. * @param vector number array to convert to right-handed
  65903. */
  65904. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  65905. /**
  65906. * Converts a Vector4 to right-handed
  65907. * @param vector Vector4 to convert to right-handed
  65908. */
  65909. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  65910. /**
  65911. * Converts a Vector4 to right-handed
  65912. * @param vector Vector4 to convert to right-handed
  65913. */
  65914. static _GetRightHandedArray4FromRef(vector: number[]): void;
  65915. /**
  65916. * Converts a Quaternion to right-handed
  65917. * @param quaternion Source quaternion to convert to right-handed
  65918. */
  65919. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  65920. /**
  65921. * Converts a Quaternion to right-handed
  65922. * @param quaternion Source quaternion to convert to right-handed
  65923. */
  65924. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  65925. static _NormalizeTangentFromRef(tangent: Vector4): void;
  65926. }
  65927. }
  65928. declare module BABYLON.GLTF2.Exporter {
  65929. /**
  65930. * Converts Babylon Scene into glTF 2.0.
  65931. * @hidden
  65932. */
  65933. export class _Exporter {
  65934. /**
  65935. * Stores the glTF to export
  65936. */
  65937. _glTF: IGLTF;
  65938. /**
  65939. * Stores all generated buffer views, which represents views into the main glTF buffer data
  65940. */
  65941. _bufferViews: IBufferView[];
  65942. /**
  65943. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  65944. */
  65945. _accessors: IAccessor[];
  65946. /**
  65947. * Stores all the generated nodes, which contains transform and/or mesh information per node
  65948. */
  65949. private _nodes;
  65950. /**
  65951. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  65952. */
  65953. private _scenes;
  65954. /**
  65955. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  65956. */
  65957. private _meshes;
  65958. /**
  65959. * Stores all the generated material information, which represents the appearance of each primitive
  65960. */
  65961. _materials: IMaterial[];
  65962. _materialMap: {
  65963. [materialID: number]: number;
  65964. };
  65965. /**
  65966. * Stores all the generated texture information, which is referenced by glTF materials
  65967. */
  65968. _textures: ITexture[];
  65969. /**
  65970. * Stores all the generated image information, which is referenced by glTF textures
  65971. */
  65972. _images: IImage[];
  65973. /**
  65974. * Stores all the texture samplers
  65975. */
  65976. _samplers: ISampler[];
  65977. /**
  65978. * Stores all the generated animation samplers, which is referenced by glTF animations
  65979. */
  65980. /**
  65981. * Stores the animations for glTF models
  65982. */
  65983. private _animations;
  65984. /**
  65985. * Stores the total amount of bytes stored in the glTF buffer
  65986. */
  65987. private _totalByteLength;
  65988. /**
  65989. * Stores a reference to the Babylon scene containing the source geometry and material information
  65990. */
  65991. _babylonScene: Scene;
  65992. /**
  65993. * Stores a map of the image data, where the key is the file name and the value
  65994. * is the image data
  65995. */
  65996. _imageData: {
  65997. [fileName: string]: {
  65998. data: Uint8Array;
  65999. mimeType: ImageMimeType;
  66000. };
  66001. };
  66002. /**
  66003. * Stores a map of the unique id of a node to its index in the node array
  66004. */
  66005. private _nodeMap;
  66006. /**
  66007. * Specifies if the Babylon scene should be converted to right-handed on export
  66008. */
  66009. _convertToRightHandedSystem: boolean;
  66010. /**
  66011. * Baked animation sample rate
  66012. */
  66013. private _animationSampleRate;
  66014. /**
  66015. * Callback which specifies if a node should be exported or not
  66016. */
  66017. private _shouldExportNode;
  66018. private _localEngine;
  66019. _glTFMaterialExporter: _GLTFMaterialExporter;
  66020. private _extensions;
  66021. private static _ExtensionNames;
  66022. private static _ExtensionFactories;
  66023. private _applyExtensions;
  66024. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  66025. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  66026. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66027. private _forEachExtensions;
  66028. private _extensionsOnExporting;
  66029. /**
  66030. * Load glTF serializer extensions
  66031. */
  66032. private _loadExtensions;
  66033. /**
  66034. * Creates a glTF Exporter instance, which can accept optional exporter options
  66035. * @param babylonScene Babylon scene object
  66036. * @param options Options to modify the behavior of the exporter
  66037. */
  66038. constructor(babylonScene: Scene, options?: IExportOptions);
  66039. /**
  66040. * Registers a glTF exporter extension
  66041. * @param name Name of the extension to export
  66042. * @param factory The factory function that creates the exporter extension
  66043. */
  66044. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  66045. /**
  66046. * Un-registers an exporter extension
  66047. * @param name The name fo the exporter extension
  66048. * @returns A boolean indicating whether the extension has been un-registered
  66049. */
  66050. static UnregisterExtension(name: string): boolean;
  66051. /**
  66052. * Lazy load a local engine with premultiplied alpha set to false
  66053. */
  66054. _getLocalEngine(): Engine;
  66055. private reorderIndicesBasedOnPrimitiveMode;
  66056. /**
  66057. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  66058. * clock-wise during export to glTF
  66059. * @param submesh BabylonJS submesh
  66060. * @param primitiveMode Primitive mode of the mesh
  66061. * @param sideOrientation the winding order of the submesh
  66062. * @param vertexBufferKind The type of vertex attribute
  66063. * @param meshAttributeArray The vertex attribute data
  66064. * @param byteOffset The offset to the binary data
  66065. * @param binaryWriter The binary data for the glTF file
  66066. */
  66067. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  66068. /**
  66069. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  66070. * clock-wise during export to glTF
  66071. * @param submesh BabylonJS submesh
  66072. * @param primitiveMode Primitive mode of the mesh
  66073. * @param sideOrientation the winding order of the submesh
  66074. * @param vertexBufferKind The type of vertex attribute
  66075. * @param meshAttributeArray The vertex attribute data
  66076. * @param byteOffset The offset to the binary data
  66077. * @param binaryWriter The binary data for the glTF file
  66078. */
  66079. private reorderTriangleFillMode;
  66080. /**
  66081. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  66082. * clock-wise during export to glTF
  66083. * @param submesh BabylonJS submesh
  66084. * @param primitiveMode Primitive mode of the mesh
  66085. * @param sideOrientation the winding order of the submesh
  66086. * @param vertexBufferKind The type of vertex attribute
  66087. * @param meshAttributeArray The vertex attribute data
  66088. * @param byteOffset The offset to the binary data
  66089. * @param binaryWriter The binary data for the glTF file
  66090. */
  66091. private reorderTriangleStripDrawMode;
  66092. /**
  66093. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  66094. * clock-wise during export to glTF
  66095. * @param submesh BabylonJS submesh
  66096. * @param primitiveMode Primitive mode of the mesh
  66097. * @param sideOrientation the winding order of the submesh
  66098. * @param vertexBufferKind The type of vertex attribute
  66099. * @param meshAttributeArray The vertex attribute data
  66100. * @param byteOffset The offset to the binary data
  66101. * @param binaryWriter The binary data for the glTF file
  66102. */
  66103. private reorderTriangleFanMode;
  66104. /**
  66105. * Writes the vertex attribute data to binary
  66106. * @param vertices The vertices to write to the binary writer
  66107. * @param byteOffset The offset into the binary writer to overwrite binary data
  66108. * @param vertexAttributeKind The vertex attribute type
  66109. * @param meshAttributeArray The vertex attribute data
  66110. * @param binaryWriter The writer containing the binary data
  66111. */
  66112. private writeVertexAttributeData;
  66113. /**
  66114. * Writes mesh attribute data to a data buffer
  66115. * Returns the bytelength of the data
  66116. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  66117. * @param meshAttributeArray Array containing the attribute data
  66118. * @param binaryWriter The buffer to write the binary data to
  66119. * @param indices Used to specify the order of the vertex data
  66120. */
  66121. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  66122. /**
  66123. * Generates glTF json data
  66124. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  66125. * @param glTFPrefix Text to use when prefixing a glTF file
  66126. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  66127. * @returns json data as string
  66128. */
  66129. private generateJSON;
  66130. /**
  66131. * Generates data for .gltf and .bin files based on the glTF prefix string
  66132. * @param glTFPrefix Text to use when prefixing a glTF file
  66133. * @returns GLTFData with glTF file data
  66134. */
  66135. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  66136. /**
  66137. * Creates a binary buffer for glTF
  66138. * @returns array buffer for binary data
  66139. */
  66140. private _generateBinaryAsync;
  66141. /**
  66142. * Pads the number to a multiple of 4
  66143. * @param num number to pad
  66144. * @returns padded number
  66145. */
  66146. private _getPadding;
  66147. /**
  66148. * Generates a glb file from the json and binary data
  66149. * Returns an object with the glb file name as the key and data as the value
  66150. * @param glTFPrefix
  66151. * @returns object with glb filename as key and data as value
  66152. */
  66153. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  66154. /**
  66155. * Sets the TRS for each node
  66156. * @param node glTF Node for storing the transformation data
  66157. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  66158. */
  66159. private setNodeTransformation;
  66160. private getVertexBufferFromMesh;
  66161. /**
  66162. * Creates a bufferview based on the vertices type for the Babylon mesh
  66163. * @param kind Indicates the type of vertices data
  66164. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  66165. * @param binaryWriter The buffer to write the bufferview data to
  66166. */
  66167. private createBufferViewKind;
  66168. /**
  66169. * The primitive mode of the Babylon mesh
  66170. * @param babylonMesh The BabylonJS mesh
  66171. */
  66172. private getMeshPrimitiveMode;
  66173. /**
  66174. * Sets the primitive mode of the glTF mesh primitive
  66175. * @param meshPrimitive glTF mesh primitive
  66176. * @param primitiveMode The primitive mode
  66177. */
  66178. private setPrimitiveMode;
  66179. /**
  66180. * Sets the vertex attribute accessor based of the glTF mesh primitive
  66181. * @param meshPrimitive glTF mesh primitive
  66182. * @param attributeKind vertex attribute
  66183. * @returns boolean specifying if uv coordinates are present
  66184. */
  66185. private setAttributeKind;
  66186. /**
  66187. * Sets data for the primitive attributes of each submesh
  66188. * @param mesh glTF Mesh object to store the primitive attribute information
  66189. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  66190. * @param binaryWriter Buffer to write the attribute data to
  66191. */
  66192. private setPrimitiveAttributesAsync;
  66193. /**
  66194. * Creates a glTF scene based on the array of meshes
  66195. * Returns the the total byte offset
  66196. * @param babylonScene Babylon scene to get the mesh data from
  66197. * @param binaryWriter Buffer to write binary data to
  66198. */
  66199. private createSceneAsync;
  66200. /**
  66201. * Creates a mapping of Node unique id to node index and handles animations
  66202. * @param babylonScene Babylon Scene
  66203. * @param nodes Babylon transform nodes
  66204. * @param shouldExportNode Callback specifying if a transform node should be exported
  66205. * @param binaryWriter Buffer to write binary data to
  66206. * @returns Node mapping of unique id to index
  66207. */
  66208. private createNodeMapAndAnimationsAsync;
  66209. /**
  66210. * Creates a glTF node from a Babylon mesh
  66211. * @param babylonMesh Source Babylon mesh
  66212. * @param binaryWriter Buffer for storing geometry data
  66213. * @returns glTF node
  66214. */
  66215. private createNodeAsync;
  66216. }
  66217. /**
  66218. * @hidden
  66219. *
  66220. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  66221. */
  66222. export class _BinaryWriter {
  66223. /**
  66224. * Array buffer which stores all binary data
  66225. */
  66226. private _arrayBuffer;
  66227. /**
  66228. * View of the array buffer
  66229. */
  66230. private _dataView;
  66231. /**
  66232. * byte offset of data in array buffer
  66233. */
  66234. private _byteOffset;
  66235. /**
  66236. * Initialize binary writer with an initial byte length
  66237. * @param byteLength Initial byte length of the array buffer
  66238. */
  66239. constructor(byteLength: number);
  66240. /**
  66241. * Resize the array buffer to the specified byte length
  66242. * @param byteLength
  66243. */
  66244. private resizeBuffer;
  66245. /**
  66246. * Get an array buffer with the length of the byte offset
  66247. * @returns ArrayBuffer resized to the byte offset
  66248. */
  66249. getArrayBuffer(): ArrayBuffer;
  66250. /**
  66251. * Get the byte offset of the array buffer
  66252. * @returns byte offset
  66253. */
  66254. getByteOffset(): number;
  66255. /**
  66256. * Stores an UInt8 in the array buffer
  66257. * @param entry
  66258. * @param byteOffset If defined, specifies where to set the value as an offset.
  66259. */
  66260. setUInt8(entry: number, byteOffset?: number): void;
  66261. /**
  66262. * Gets an UInt32 in the array buffer
  66263. * @param entry
  66264. * @param byteOffset If defined, specifies where to set the value as an offset.
  66265. */
  66266. getUInt32(byteOffset: number): number;
  66267. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  66268. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  66269. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  66270. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  66271. /**
  66272. * Stores a Float32 in the array buffer
  66273. * @param entry
  66274. */
  66275. setFloat32(entry: number, byteOffset?: number): void;
  66276. /**
  66277. * Stores an UInt32 in the array buffer
  66278. * @param entry
  66279. * @param byteOffset If defined, specifies where to set the value as an offset.
  66280. */
  66281. setUInt32(entry: number, byteOffset?: number): void;
  66282. }
  66283. }
  66284. declare module BABYLON.GLTF2.Exporter {
  66285. /**
  66286. * @hidden
  66287. * Interface to store animation data.
  66288. */
  66289. export interface _IAnimationData {
  66290. /**
  66291. * Keyframe data.
  66292. */
  66293. inputs: number[];
  66294. /**
  66295. * Value data.
  66296. */
  66297. outputs: number[][];
  66298. /**
  66299. * Animation interpolation data.
  66300. */
  66301. samplerInterpolation: AnimationSamplerInterpolation;
  66302. /**
  66303. * Minimum keyframe value.
  66304. */
  66305. inputsMin: number;
  66306. /**
  66307. * Maximum keyframe value.
  66308. */
  66309. inputsMax: number;
  66310. }
  66311. /**
  66312. * @hidden
  66313. */
  66314. export interface _IAnimationInfo {
  66315. /**
  66316. * The target channel for the animation
  66317. */
  66318. animationChannelTargetPath: AnimationChannelTargetPath;
  66319. /**
  66320. * The glTF accessor type for the data.
  66321. */
  66322. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  66323. /**
  66324. * Specifies if quaternions should be used.
  66325. */
  66326. useQuaternion: boolean;
  66327. }
  66328. /**
  66329. * @hidden
  66330. * Utility class for generating glTF animation data from BabylonJS.
  66331. */
  66332. export class _GLTFAnimation {
  66333. /**
  66334. * @ignore
  66335. *
  66336. * Creates glTF channel animation from BabylonJS animation.
  66337. * @param babylonTransformNode - BabylonJS mesh.
  66338. * @param animation - animation.
  66339. * @param animationChannelTargetPath - The target animation channel.
  66340. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  66341. * @param useQuaternion - Specifies if quaternions are used.
  66342. * @returns nullable IAnimationData
  66343. */
  66344. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  66345. private static _DeduceAnimationInfo;
  66346. /**
  66347. * @ignore
  66348. * Create node animations from the transform node animations
  66349. * @param babylonNode
  66350. * @param runtimeGLTFAnimation
  66351. * @param idleGLTFAnimations
  66352. * @param nodeMap
  66353. * @param nodes
  66354. * @param binaryWriter
  66355. * @param bufferViews
  66356. * @param accessors
  66357. * @param convertToRightHandedSystem
  66358. */
  66359. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  66360. [key: number]: number;
  66361. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  66362. /**
  66363. * @ignore
  66364. * Create node animations from the animation groups
  66365. * @param babylonScene
  66366. * @param glTFAnimations
  66367. * @param nodeMap
  66368. * @param nodes
  66369. * @param binaryWriter
  66370. * @param bufferViews
  66371. * @param accessors
  66372. * @param convertToRightHandedSystem
  66373. */
  66374. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  66375. [key: number]: number;
  66376. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  66377. private static AddAnimation;
  66378. /**
  66379. * Create a baked animation
  66380. * @param babylonTransformNode BabylonJS mesh
  66381. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  66382. * @param animationChannelTargetPath animation target channel
  66383. * @param minFrame minimum animation frame
  66384. * @param maxFrame maximum animation frame
  66385. * @param fps frames per second of the animation
  66386. * @param inputs input key frames of the animation
  66387. * @param outputs output key frame data of the animation
  66388. * @param convertToRightHandedSystem converts the values to right-handed
  66389. * @param useQuaternion specifies if quaternions should be used
  66390. */
  66391. private static _CreateBakedAnimation;
  66392. private static _ConvertFactorToVector3OrQuaternion;
  66393. private static _SetInterpolatedValue;
  66394. /**
  66395. * Creates linear animation from the animation key frames
  66396. * @param babylonTransformNode BabylonJS mesh
  66397. * @param animation BabylonJS animation
  66398. * @param animationChannelTargetPath The target animation channel
  66399. * @param frameDelta The difference between the last and first frame of the animation
  66400. * @param inputs Array to store the key frame times
  66401. * @param outputs Array to store the key frame data
  66402. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  66403. * @param useQuaternion Specifies if quaternions are used in the animation
  66404. */
  66405. private static _CreateLinearOrStepAnimation;
  66406. /**
  66407. * Creates cubic spline animation from the animation key frames
  66408. * @param babylonTransformNode BabylonJS mesh
  66409. * @param animation BabylonJS animation
  66410. * @param animationChannelTargetPath The target animation channel
  66411. * @param frameDelta The difference between the last and first frame of the animation
  66412. * @param inputs Array to store the key frame times
  66413. * @param outputs Array to store the key frame data
  66414. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  66415. * @param useQuaternion Specifies if quaternions are used in the animation
  66416. */
  66417. private static _CreateCubicSplineAnimation;
  66418. private static _GetBasePositionRotationOrScale;
  66419. /**
  66420. * Adds a key frame value
  66421. * @param keyFrame
  66422. * @param animation
  66423. * @param outputs
  66424. * @param animationChannelTargetPath
  66425. * @param basePositionRotationOrScale
  66426. * @param convertToRightHandedSystem
  66427. * @param useQuaternion
  66428. */
  66429. private static _AddKeyframeValue;
  66430. /**
  66431. * Determine the interpolation based on the key frames
  66432. * @param keyFrames
  66433. * @param animationChannelTargetPath
  66434. * @param useQuaternion
  66435. */
  66436. private static _DeduceInterpolation;
  66437. /**
  66438. * Adds an input tangent or output tangent to the output data
  66439. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  66440. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  66441. * @param outputs The animation data by keyframe
  66442. * @param animationChannelTargetPath The target animation channel
  66443. * @param interpolation The interpolation type
  66444. * @param keyFrame The key frame with the animation data
  66445. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  66446. * @param useQuaternion Specifies if quaternions are used
  66447. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  66448. */
  66449. private static AddSplineTangent;
  66450. /**
  66451. * Get the minimum and maximum key frames' frame values
  66452. * @param keyFrames animation key frames
  66453. * @returns the minimum and maximum key frame value
  66454. */
  66455. private static calculateMinMaxKeyFrames;
  66456. }
  66457. }
  66458. declare module BABYLON.GLTF2.Exporter {
  66459. /** @hidden */
  66460. export var textureTransformPixelShader: {
  66461. name: string;
  66462. shader: string;
  66463. };
  66464. }
  66465. declare module BABYLON.GLTF2.Exporter.Extensions {
  66466. /**
  66467. * @hidden
  66468. */
  66469. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  66470. /** Name of this extension */
  66471. readonly name: string;
  66472. /** Defines whether this extension is enabled */
  66473. enabled: boolean;
  66474. /** Defines whether this extension is required */
  66475. required: boolean;
  66476. /** Reference to the glTF exporter */
  66477. private _exporter;
  66478. constructor(exporter: _Exporter);
  66479. dispose(): void;
  66480. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  66481. /**
  66482. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  66483. * @param babylonTexture
  66484. * @param offset
  66485. * @param rotation
  66486. * @param scale
  66487. * @param scene
  66488. */
  66489. private _textureTransformTextureAsync;
  66490. }
  66491. }
  66492. declare module BABYLON.GLTF2.Exporter.Extensions {
  66493. /**
  66494. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  66495. */
  66496. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  66497. /** The name of this extension. */
  66498. readonly name: string;
  66499. /** Defines whether this extension is enabled. */
  66500. enabled: boolean;
  66501. /** Defines whether this extension is required */
  66502. required: boolean;
  66503. /** Reference to the glTF exporter */
  66504. private _exporter;
  66505. private _lights;
  66506. /** @hidden */
  66507. constructor(exporter: _Exporter);
  66508. /** @hidden */
  66509. dispose(): void;
  66510. /** @hidden */
  66511. onExporting(): void;
  66512. /**
  66513. * Define this method to modify the default behavior when exporting a node
  66514. * @param context The context when exporting the node
  66515. * @param node glTF node
  66516. * @param babylonNode BabylonJS node
  66517. * @returns nullable INode promise
  66518. */
  66519. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66520. }
  66521. }
  66522. declare module BABYLON {
  66523. /**
  66524. * Class for generating STL data from a Babylon scene.
  66525. */
  66526. export class STLExport {
  66527. /**
  66528. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  66529. * @param meshes list defines the mesh to serialize
  66530. * @param download triggers the automatic download of the file.
  66531. * @param fileName changes the downloads fileName.
  66532. * @param binary changes the STL to a binary type.
  66533. * @param isLittleEndian toggle for binary type exporter.
  66534. * @returns the STL as UTF8 string
  66535. */
  66536. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  66537. }
  66538. }
  66539. /**
  66540. * @ignoreChildren
  66541. * @ignore
  66542. */
  66543. declare module "babylonjs-gltf2interface" {
  66544. export = BABYLON.GLTF2;
  66545. }
  66546. /**
  66547. * Module for glTF 2.0 Interface
  66548. * @ignoreChildren
  66549. * @ignore
  66550. */
  66551. declare module BABYLON.GLTF2 {
  66552. /**
  66553. * The datatype of the components in the attribute
  66554. */
  66555. const enum AccessorComponentType {
  66556. /**
  66557. * Byte
  66558. */
  66559. BYTE = 5120,
  66560. /**
  66561. * Unsigned Byte
  66562. */
  66563. UNSIGNED_BYTE = 5121,
  66564. /**
  66565. * Short
  66566. */
  66567. SHORT = 5122,
  66568. /**
  66569. * Unsigned Short
  66570. */
  66571. UNSIGNED_SHORT = 5123,
  66572. /**
  66573. * Unsigned Int
  66574. */
  66575. UNSIGNED_INT = 5125,
  66576. /**
  66577. * Float
  66578. */
  66579. FLOAT = 5126,
  66580. }
  66581. /**
  66582. * Specifies if the attirbute is a scalar, vector, or matrix
  66583. */
  66584. const enum AccessorType {
  66585. /**
  66586. * Scalar
  66587. */
  66588. SCALAR = "SCALAR",
  66589. /**
  66590. * Vector2
  66591. */
  66592. VEC2 = "VEC2",
  66593. /**
  66594. * Vector3
  66595. */
  66596. VEC3 = "VEC3",
  66597. /**
  66598. * Vector4
  66599. */
  66600. VEC4 = "VEC4",
  66601. /**
  66602. * Matrix2x2
  66603. */
  66604. MAT2 = "MAT2",
  66605. /**
  66606. * Matrix3x3
  66607. */
  66608. MAT3 = "MAT3",
  66609. /**
  66610. * Matrix4x4
  66611. */
  66612. MAT4 = "MAT4",
  66613. }
  66614. /**
  66615. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  66616. */
  66617. const enum AnimationChannelTargetPath {
  66618. /**
  66619. * Translation
  66620. */
  66621. TRANSLATION = "translation",
  66622. /**
  66623. * Rotation
  66624. */
  66625. ROTATION = "rotation",
  66626. /**
  66627. * Scale
  66628. */
  66629. SCALE = "scale",
  66630. /**
  66631. * Weights
  66632. */
  66633. WEIGHTS = "weights",
  66634. }
  66635. /**
  66636. * Interpolation algorithm
  66637. */
  66638. const enum AnimationSamplerInterpolation {
  66639. /**
  66640. * The animated values are linearly interpolated between keyframes
  66641. */
  66642. LINEAR = "LINEAR",
  66643. /**
  66644. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  66645. */
  66646. STEP = "STEP",
  66647. /**
  66648. * The animation's interpolation is computed using a cubic spline with specified tangents
  66649. */
  66650. CUBICSPLINE = "CUBICSPLINE",
  66651. }
  66652. /**
  66653. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  66654. */
  66655. const enum CameraType {
  66656. /**
  66657. * A perspective camera containing properties to create a perspective projection matrix
  66658. */
  66659. PERSPECTIVE = "perspective",
  66660. /**
  66661. * An orthographic camera containing properties to create an orthographic projection matrix
  66662. */
  66663. ORTHOGRAPHIC = "orthographic",
  66664. }
  66665. /**
  66666. * The mime-type of the image
  66667. */
  66668. const enum ImageMimeType {
  66669. /**
  66670. * JPEG Mime-type
  66671. */
  66672. JPEG = "image/jpeg",
  66673. /**
  66674. * PNG Mime-type
  66675. */
  66676. PNG = "image/png",
  66677. }
  66678. /**
  66679. * The alpha rendering mode of the material
  66680. */
  66681. const enum MaterialAlphaMode {
  66682. /**
  66683. * The alpha value is ignored and the rendered output is fully opaque
  66684. */
  66685. OPAQUE = "OPAQUE",
  66686. /**
  66687. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  66688. */
  66689. MASK = "MASK",
  66690. /**
  66691. * 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)
  66692. */
  66693. BLEND = "BLEND",
  66694. }
  66695. /**
  66696. * The type of the primitives to render
  66697. */
  66698. const enum MeshPrimitiveMode {
  66699. /**
  66700. * Points
  66701. */
  66702. POINTS = 0,
  66703. /**
  66704. * Lines
  66705. */
  66706. LINES = 1,
  66707. /**
  66708. * Line Loop
  66709. */
  66710. LINE_LOOP = 2,
  66711. /**
  66712. * Line Strip
  66713. */
  66714. LINE_STRIP = 3,
  66715. /**
  66716. * Triangles
  66717. */
  66718. TRIANGLES = 4,
  66719. /**
  66720. * Triangle Strip
  66721. */
  66722. TRIANGLE_STRIP = 5,
  66723. /**
  66724. * Triangle Fan
  66725. */
  66726. TRIANGLE_FAN = 6,
  66727. }
  66728. /**
  66729. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  66730. */
  66731. const enum TextureMagFilter {
  66732. /**
  66733. * Nearest
  66734. */
  66735. NEAREST = 9728,
  66736. /**
  66737. * Linear
  66738. */
  66739. LINEAR = 9729,
  66740. }
  66741. /**
  66742. * Minification filter. All valid values correspond to WebGL enums
  66743. */
  66744. const enum TextureMinFilter {
  66745. /**
  66746. * Nearest
  66747. */
  66748. NEAREST = 9728,
  66749. /**
  66750. * Linear
  66751. */
  66752. LINEAR = 9729,
  66753. /**
  66754. * Nearest Mip-Map Nearest
  66755. */
  66756. NEAREST_MIPMAP_NEAREST = 9984,
  66757. /**
  66758. * Linear Mipmap Nearest
  66759. */
  66760. LINEAR_MIPMAP_NEAREST = 9985,
  66761. /**
  66762. * Nearest Mipmap Linear
  66763. */
  66764. NEAREST_MIPMAP_LINEAR = 9986,
  66765. /**
  66766. * Linear Mipmap Linear
  66767. */
  66768. LINEAR_MIPMAP_LINEAR = 9987,
  66769. }
  66770. /**
  66771. * S (U) wrapping mode. All valid values correspond to WebGL enums
  66772. */
  66773. const enum TextureWrapMode {
  66774. /**
  66775. * Clamp to Edge
  66776. */
  66777. CLAMP_TO_EDGE = 33071,
  66778. /**
  66779. * Mirrored Repeat
  66780. */
  66781. MIRRORED_REPEAT = 33648,
  66782. /**
  66783. * Repeat
  66784. */
  66785. REPEAT = 10497,
  66786. }
  66787. /**
  66788. * glTF Property
  66789. */
  66790. interface IProperty {
  66791. /**
  66792. * Dictionary object with extension-specific objects
  66793. */
  66794. extensions?: {
  66795. [key: string]: any;
  66796. };
  66797. /**
  66798. * Application-Specific data
  66799. */
  66800. extras?: any;
  66801. }
  66802. /**
  66803. * glTF Child of Root Property
  66804. */
  66805. interface IChildRootProperty extends IProperty {
  66806. /**
  66807. * The user-defined name of this object
  66808. */
  66809. name?: string;
  66810. }
  66811. /**
  66812. * Indices of those attributes that deviate from their initialization value
  66813. */
  66814. interface IAccessorSparseIndices extends IProperty {
  66815. /**
  66816. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  66817. */
  66818. bufferView: number;
  66819. /**
  66820. * The offset relative to the start of the bufferView in bytes. Must be aligned
  66821. */
  66822. byteOffset?: number;
  66823. /**
  66824. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  66825. */
  66826. componentType: AccessorComponentType;
  66827. }
  66828. /**
  66829. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  66830. */
  66831. interface IAccessorSparseValues extends IProperty {
  66832. /**
  66833. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  66834. */
  66835. bufferView: number;
  66836. /**
  66837. * The offset relative to the start of the bufferView in bytes. Must be aligned
  66838. */
  66839. byteOffset?: number;
  66840. }
  66841. /**
  66842. * Sparse storage of attributes that deviate from their initialization value
  66843. */
  66844. interface IAccessorSparse extends IProperty {
  66845. /**
  66846. * The number of attributes encoded in this sparse accessor
  66847. */
  66848. count: number;
  66849. /**
  66850. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  66851. */
  66852. indices: IAccessorSparseIndices;
  66853. /**
  66854. * 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
  66855. */
  66856. values: IAccessorSparseValues;
  66857. }
  66858. /**
  66859. * 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
  66860. */
  66861. interface IAccessor extends IChildRootProperty {
  66862. /**
  66863. * The index of the bufferview
  66864. */
  66865. bufferView?: number;
  66866. /**
  66867. * The offset relative to the start of the bufferView in bytes
  66868. */
  66869. byteOffset?: number;
  66870. /**
  66871. * The datatype of components in the attribute
  66872. */
  66873. componentType: AccessorComponentType;
  66874. /**
  66875. * Specifies whether integer data values should be normalized
  66876. */
  66877. normalized?: boolean;
  66878. /**
  66879. * The number of attributes referenced by this accessor
  66880. */
  66881. count: number;
  66882. /**
  66883. * Specifies if the attribute is a scalar, vector, or matrix
  66884. */
  66885. type: AccessorType;
  66886. /**
  66887. * Maximum value of each component in this attribute
  66888. */
  66889. max?: number[];
  66890. /**
  66891. * Minimum value of each component in this attribute
  66892. */
  66893. min?: number[];
  66894. /**
  66895. * Sparse storage of attributes that deviate from their initialization value
  66896. */
  66897. sparse?: IAccessorSparse;
  66898. }
  66899. /**
  66900. * Targets an animation's sampler at a node's property
  66901. */
  66902. interface IAnimationChannel extends IProperty {
  66903. /**
  66904. * The index of a sampler in this animation used to compute the value for the target
  66905. */
  66906. sampler: number;
  66907. /**
  66908. * The index of the node and TRS property to target
  66909. */
  66910. target: IAnimationChannelTarget;
  66911. }
  66912. /**
  66913. * The index of the node and TRS property that an animation channel targets
  66914. */
  66915. interface IAnimationChannelTarget extends IProperty {
  66916. /**
  66917. * The index of the node to target
  66918. */
  66919. node: number;
  66920. /**
  66921. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  66922. */
  66923. path: AnimationChannelTargetPath;
  66924. }
  66925. /**
  66926. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  66927. */
  66928. interface IAnimationSampler extends IProperty {
  66929. /**
  66930. * The index of an accessor containing keyframe input values, e.g., time
  66931. */
  66932. input: number;
  66933. /**
  66934. * Interpolation algorithm
  66935. */
  66936. interpolation?: AnimationSamplerInterpolation;
  66937. /**
  66938. * The index of an accessor, containing keyframe output values
  66939. */
  66940. output: number;
  66941. }
  66942. /**
  66943. * A keyframe animation
  66944. */
  66945. interface IAnimation extends IChildRootProperty {
  66946. /**
  66947. * An array of channels, each of which targets an animation's sampler at a node's property
  66948. */
  66949. channels: IAnimationChannel[];
  66950. /**
  66951. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  66952. */
  66953. samplers: IAnimationSampler[];
  66954. }
  66955. /**
  66956. * Metadata about the glTF asset
  66957. */
  66958. interface IAsset extends IChildRootProperty {
  66959. /**
  66960. * A copyright message suitable for display to credit the content creator
  66961. */
  66962. copyright?: string;
  66963. /**
  66964. * Tool that generated this glTF model. Useful for debugging
  66965. */
  66966. generator?: string;
  66967. /**
  66968. * The glTF version that this asset targets
  66969. */
  66970. version: string;
  66971. /**
  66972. * The minimum glTF version that this asset targets
  66973. */
  66974. minVersion?: string;
  66975. }
  66976. /**
  66977. * A buffer points to binary geometry, animation, or skins
  66978. */
  66979. interface IBuffer extends IChildRootProperty {
  66980. /**
  66981. * 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
  66982. */
  66983. uri?: string;
  66984. /**
  66985. * The length of the buffer in bytes
  66986. */
  66987. byteLength: number;
  66988. }
  66989. /**
  66990. * A view into a buffer generally representing a subset of the buffer
  66991. */
  66992. interface IBufferView extends IChildRootProperty {
  66993. /**
  66994. * The index of the buffer
  66995. */
  66996. buffer: number;
  66997. /**
  66998. * The offset into the buffer in bytes
  66999. */
  67000. byteOffset?: number;
  67001. /**
  67002. * The lenth of the bufferView in bytes
  67003. */
  67004. byteLength: number;
  67005. /**
  67006. * The stride, in bytes
  67007. */
  67008. byteStride?: number;
  67009. }
  67010. /**
  67011. * An orthographic camera containing properties to create an orthographic projection matrix
  67012. */
  67013. interface ICameraOrthographic extends IProperty {
  67014. /**
  67015. * The floating-point horizontal magnification of the view. Must not be zero
  67016. */
  67017. xmag: number;
  67018. /**
  67019. * The floating-point vertical magnification of the view. Must not be zero
  67020. */
  67021. ymag: number;
  67022. /**
  67023. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  67024. */
  67025. zfar: number;
  67026. /**
  67027. * The floating-point distance to the near clipping plane
  67028. */
  67029. znear: number;
  67030. }
  67031. /**
  67032. * A perspective camera containing properties to create a perspective projection matrix
  67033. */
  67034. interface ICameraPerspective extends IProperty {
  67035. /**
  67036. * The floating-point aspect ratio of the field of view
  67037. */
  67038. aspectRatio?: number;
  67039. /**
  67040. * The floating-point vertical field of view in radians
  67041. */
  67042. yfov: number;
  67043. /**
  67044. * The floating-point distance to the far clipping plane
  67045. */
  67046. zfar?: number;
  67047. /**
  67048. * The floating-point distance to the near clipping plane
  67049. */
  67050. znear: number;
  67051. }
  67052. /**
  67053. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  67054. */
  67055. interface ICamera extends IChildRootProperty {
  67056. /**
  67057. * An orthographic camera containing properties to create an orthographic projection matrix
  67058. */
  67059. orthographic?: ICameraOrthographic;
  67060. /**
  67061. * A perspective camera containing properties to create a perspective projection matrix
  67062. */
  67063. perspective?: ICameraPerspective;
  67064. /**
  67065. * Specifies if the camera uses a perspective or orthographic projection
  67066. */
  67067. type: CameraType;
  67068. }
  67069. /**
  67070. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  67071. */
  67072. interface IImage extends IChildRootProperty {
  67073. /**
  67074. * 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
  67075. */
  67076. uri?: string;
  67077. /**
  67078. * The image's MIME type
  67079. */
  67080. mimeType?: ImageMimeType;
  67081. /**
  67082. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  67083. */
  67084. bufferView?: number;
  67085. }
  67086. /**
  67087. * Material Normal Texture Info
  67088. */
  67089. interface IMaterialNormalTextureInfo extends ITextureInfo {
  67090. /**
  67091. * The scalar multiplier applied to each normal vector of the normal texture
  67092. */
  67093. scale?: number;
  67094. }
  67095. /**
  67096. * Material Occlusion Texture Info
  67097. */
  67098. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  67099. /**
  67100. * A scalar multiplier controlling the amount of occlusion applied
  67101. */
  67102. strength?: number;
  67103. }
  67104. /**
  67105. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  67106. */
  67107. interface IMaterialPbrMetallicRoughness {
  67108. /**
  67109. * The material's base color factor
  67110. */
  67111. baseColorFactor?: number[];
  67112. /**
  67113. * The base color texture
  67114. */
  67115. baseColorTexture?: ITextureInfo;
  67116. /**
  67117. * The metalness of the material
  67118. */
  67119. metallicFactor?: number;
  67120. /**
  67121. * The roughness of the material
  67122. */
  67123. roughnessFactor?: number;
  67124. /**
  67125. * The metallic-roughness texture
  67126. */
  67127. metallicRoughnessTexture?: ITextureInfo;
  67128. }
  67129. /**
  67130. * The material appearance of a primitive
  67131. */
  67132. interface IMaterial extends IChildRootProperty {
  67133. /**
  67134. * 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
  67135. */
  67136. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  67137. /**
  67138. * The normal map texture
  67139. */
  67140. normalTexture?: IMaterialNormalTextureInfo;
  67141. /**
  67142. * The occlusion map texture
  67143. */
  67144. occlusionTexture?: IMaterialOcclusionTextureInfo;
  67145. /**
  67146. * The emissive map texture
  67147. */
  67148. emissiveTexture?: ITextureInfo;
  67149. /**
  67150. * 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
  67151. */
  67152. emissiveFactor?: number[];
  67153. /**
  67154. * The alpha rendering mode of the material
  67155. */
  67156. alphaMode?: MaterialAlphaMode;
  67157. /**
  67158. * The alpha cutoff value of the material
  67159. */
  67160. alphaCutoff?: number;
  67161. /**
  67162. * Specifies whether the material is double sided
  67163. */
  67164. doubleSided?: boolean;
  67165. }
  67166. /**
  67167. * Geometry to be rendered with the given material
  67168. */
  67169. interface IMeshPrimitive extends IProperty {
  67170. /**
  67171. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  67172. */
  67173. attributes: {
  67174. [name: string]: number;
  67175. };
  67176. /**
  67177. * The index of the accessor that contains the indices
  67178. */
  67179. indices?: number;
  67180. /**
  67181. * The index of the material to apply to this primitive when rendering
  67182. */
  67183. material?: number;
  67184. /**
  67185. * The type of primitives to render. All valid values correspond to WebGL enums
  67186. */
  67187. mode?: MeshPrimitiveMode;
  67188. /**
  67189. * 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
  67190. */
  67191. targets?: {
  67192. [name: string]: number;
  67193. }[];
  67194. }
  67195. /**
  67196. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  67197. */
  67198. interface IMesh extends IChildRootProperty {
  67199. /**
  67200. * An array of primitives, each defining geometry to be rendered with a material
  67201. */
  67202. primitives: IMeshPrimitive[];
  67203. /**
  67204. * Array of weights to be applied to the Morph Targets
  67205. */
  67206. weights?: number[];
  67207. }
  67208. /**
  67209. * A node in the node hierarchy
  67210. */
  67211. interface INode extends IChildRootProperty {
  67212. /**
  67213. * The index of the camera referenced by this node
  67214. */
  67215. camera?: number;
  67216. /**
  67217. * The indices of this node's children
  67218. */
  67219. children?: number[];
  67220. /**
  67221. * The index of the skin referenced by this node
  67222. */
  67223. skin?: number;
  67224. /**
  67225. * A floating-point 4x4 transformation matrix stored in column-major order
  67226. */
  67227. matrix?: number[];
  67228. /**
  67229. * The index of the mesh in this node
  67230. */
  67231. mesh?: number;
  67232. /**
  67233. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  67234. */
  67235. rotation?: number[];
  67236. /**
  67237. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  67238. */
  67239. scale?: number[];
  67240. /**
  67241. * The node's translation along the x, y, and z axes
  67242. */
  67243. translation?: number[];
  67244. /**
  67245. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  67246. */
  67247. weights?: number[];
  67248. }
  67249. /**
  67250. * Texture sampler properties for filtering and wrapping modes
  67251. */
  67252. interface ISampler extends IChildRootProperty {
  67253. /**
  67254. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  67255. */
  67256. magFilter?: TextureMagFilter;
  67257. /**
  67258. * Minification filter. All valid values correspond to WebGL enums
  67259. */
  67260. minFilter?: TextureMinFilter;
  67261. /**
  67262. * S (U) wrapping mode. All valid values correspond to WebGL enums
  67263. */
  67264. wrapS?: TextureWrapMode;
  67265. /**
  67266. * T (V) wrapping mode. All valid values correspond to WebGL enums
  67267. */
  67268. wrapT?: TextureWrapMode;
  67269. }
  67270. /**
  67271. * The root nodes of a scene
  67272. */
  67273. interface IScene extends IChildRootProperty {
  67274. /**
  67275. * The indices of each root node
  67276. */
  67277. nodes: number[];
  67278. }
  67279. /**
  67280. * Joints and matrices defining a skin
  67281. */
  67282. interface ISkin extends IChildRootProperty {
  67283. /**
  67284. * 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
  67285. */
  67286. inverseBindMatrices?: number;
  67287. /**
  67288. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  67289. */
  67290. skeleton?: number;
  67291. /**
  67292. * 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)
  67293. */
  67294. joints: number[];
  67295. }
  67296. /**
  67297. * A texture and its sampler
  67298. */
  67299. interface ITexture extends IChildRootProperty {
  67300. /**
  67301. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  67302. */
  67303. sampler?: number;
  67304. /**
  67305. * The index of the image used by this texture
  67306. */
  67307. source: number;
  67308. }
  67309. /**
  67310. * Reference to a texture
  67311. */
  67312. interface ITextureInfo extends IProperty {
  67313. /**
  67314. * The index of the texture
  67315. */
  67316. index: number;
  67317. /**
  67318. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  67319. */
  67320. texCoord?: number;
  67321. }
  67322. /**
  67323. * The root object for a glTF asset
  67324. */
  67325. interface IGLTF extends IProperty {
  67326. /**
  67327. * An array of accessors. An accessor is a typed view into a bufferView
  67328. */
  67329. accessors?: IAccessor[];
  67330. /**
  67331. * An array of keyframe animations
  67332. */
  67333. animations?: IAnimation[];
  67334. /**
  67335. * Metadata about the glTF asset
  67336. */
  67337. asset: IAsset;
  67338. /**
  67339. * An array of buffers. A buffer points to binary geometry, animation, or skins
  67340. */
  67341. buffers?: IBuffer[];
  67342. /**
  67343. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  67344. */
  67345. bufferViews?: IBufferView[];
  67346. /**
  67347. * An array of cameras
  67348. */
  67349. cameras?: ICamera[];
  67350. /**
  67351. * Names of glTF extensions used somewhere in this asset
  67352. */
  67353. extensionsUsed?: string[];
  67354. /**
  67355. * Names of glTF extensions required to properly load this asset
  67356. */
  67357. extensionsRequired?: string[];
  67358. /**
  67359. * An array of images. An image defines data used to create a texture
  67360. */
  67361. images?: IImage[];
  67362. /**
  67363. * An array of materials. A material defines the appearance of a primitive
  67364. */
  67365. materials?: IMaterial[];
  67366. /**
  67367. * An array of meshes. A mesh is a set of primitives to be rendered
  67368. */
  67369. meshes?: IMesh[];
  67370. /**
  67371. * An array of nodes
  67372. */
  67373. nodes?: INode[];
  67374. /**
  67375. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  67376. */
  67377. samplers?: ISampler[];
  67378. /**
  67379. * The index of the default scene
  67380. */
  67381. scene?: number;
  67382. /**
  67383. * An array of scenes
  67384. */
  67385. scenes?: IScene[];
  67386. /**
  67387. * An array of skins. A skin is defined by joints and matrices
  67388. */
  67389. skins?: ISkin[];
  67390. /**
  67391. * An array of textures
  67392. */
  67393. textures?: ITexture[];
  67394. }
  67395. /**
  67396. * The glTF validation results
  67397. */
  67398. interface IGLTFValidationResults {
  67399. info: {
  67400. generator: string;
  67401. hasAnimations: boolean;
  67402. hasDefaultScene: boolean;
  67403. hasMaterials: boolean;
  67404. hasMorphTargets: boolean;
  67405. hasSkins: boolean;
  67406. hasTextures: boolean;
  67407. maxAttributesUsed: number;
  67408. primitivesCount: number
  67409. };
  67410. issues: {
  67411. messages: Array<string>;
  67412. numErrors: number;
  67413. numHints: number;
  67414. numInfos: number;
  67415. numWarnings: number;
  67416. truncated: boolean
  67417. };
  67418. mimeType: string;
  67419. uri: string;
  67420. validatedAt: string;
  67421. validatorVersion: string;
  67422. }
  67423. /**
  67424. * The glTF validation options
  67425. */
  67426. interface IGLTFValidationOptions {
  67427. uri?: string;
  67428. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  67429. validateAccessorData?: boolean;
  67430. maxIssues?: number;
  67431. ignoredIssues?: Array<string>;
  67432. severityOverrides?: Object;
  67433. }
  67434. /**
  67435. * The glTF validator object
  67436. */
  67437. interface IGLTFValidator {
  67438. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  67439. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  67440. }
  67441. }
  67442. declare module BABYLON {
  67443. /** @hidden */
  67444. export var cellPixelShader: {
  67445. name: string;
  67446. shader: string;
  67447. };
  67448. }
  67449. declare module BABYLON {
  67450. /** @hidden */
  67451. export var cellVertexShader: {
  67452. name: string;
  67453. shader: string;
  67454. };
  67455. }
  67456. declare module BABYLON {
  67457. export class CellMaterial extends BABYLON.PushMaterial {
  67458. private _diffuseTexture;
  67459. diffuseTexture: BABYLON.BaseTexture;
  67460. diffuseColor: BABYLON.Color3;
  67461. _computeHighLevel: boolean;
  67462. computeHighLevel: boolean;
  67463. private _disableLighting;
  67464. disableLighting: boolean;
  67465. private _maxSimultaneousLights;
  67466. maxSimultaneousLights: number;
  67467. private _renderId;
  67468. constructor(name: string, scene: BABYLON.Scene);
  67469. needAlphaBlending(): boolean;
  67470. needAlphaTesting(): boolean;
  67471. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67472. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67473. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67474. getAnimatables(): BABYLON.IAnimatable[];
  67475. getActiveTextures(): BABYLON.BaseTexture[];
  67476. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67477. dispose(forceDisposeEffect?: boolean): void;
  67478. getClassName(): string;
  67479. clone(name: string): CellMaterial;
  67480. serialize(): any;
  67481. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  67482. }
  67483. }
  67484. declare module BABYLON {
  67485. export class CustomShaderStructure {
  67486. FragmentStore: string;
  67487. VertexStore: string;
  67488. constructor();
  67489. }
  67490. export class ShaderSpecialParts {
  67491. constructor();
  67492. Fragment_Begin: string;
  67493. Fragment_Definitions: string;
  67494. Fragment_MainBegin: string;
  67495. Fragment_Custom_Diffuse: string;
  67496. Fragment_Before_Lights: string;
  67497. Fragment_Before_Fog: string;
  67498. Fragment_Custom_Alpha: string;
  67499. Fragment_Before_FragColor: string;
  67500. Vertex_Begin: string;
  67501. Vertex_Definitions: string;
  67502. Vertex_MainBegin: string;
  67503. Vertex_Before_PositionUpdated: string;
  67504. Vertex_Before_NormalUpdated: string;
  67505. Vertex_MainEnd: string;
  67506. }
  67507. export class CustomMaterial extends BABYLON.StandardMaterial {
  67508. static ShaderIndexer: number;
  67509. CustomParts: ShaderSpecialParts;
  67510. _isCreatedShader: boolean;
  67511. _createdShaderName: string;
  67512. _customUniform: string[];
  67513. _newUniforms: string[];
  67514. _newUniformInstances: any[];
  67515. _newSamplerInstances: BABYLON.Texture[];
  67516. FragmentShader: string;
  67517. VertexShader: string;
  67518. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  67519. ReviewUniform(name: string, arr: string[]): string[];
  67520. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  67521. constructor(name: string, scene: BABYLON.Scene);
  67522. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  67523. Fragment_Begin(shaderPart: string): CustomMaterial;
  67524. Fragment_Definitions(shaderPart: string): CustomMaterial;
  67525. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  67526. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  67527. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  67528. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  67529. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  67530. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  67531. Vertex_Begin(shaderPart: string): CustomMaterial;
  67532. Vertex_Definitions(shaderPart: string): CustomMaterial;
  67533. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  67534. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  67535. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  67536. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  67537. }
  67538. }
  67539. declare module BABYLON {
  67540. export class ShaderAlebdoParts {
  67541. constructor();
  67542. Fragment_Begin: string;
  67543. Fragment_Definitions: string;
  67544. Fragment_MainBegin: string;
  67545. Fragment_Custom_Albedo: string;
  67546. Fragment_Before_Lights: string;
  67547. Fragment_Custom_MetallicRoughness: string;
  67548. Fragment_Custom_MicroSurface: string;
  67549. Fragment_Before_Fog: string;
  67550. Fragment_Custom_Alpha: string;
  67551. Fragment_Before_FragColor: string;
  67552. Vertex_Begin: string;
  67553. Vertex_Definitions: string;
  67554. Vertex_MainBegin: string;
  67555. Vertex_Before_PositionUpdated: string;
  67556. Vertex_Before_NormalUpdated: string;
  67557. Vertex_MainEnd: string;
  67558. }
  67559. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  67560. static ShaderIndexer: number;
  67561. CustomParts: ShaderAlebdoParts;
  67562. _isCreatedShader: boolean;
  67563. _createdShaderName: string;
  67564. _customUniform: string[];
  67565. _newUniforms: string[];
  67566. _newUniformInstances: any[];
  67567. _newSamplerInstances: BABYLON.Texture[];
  67568. FragmentShader: string;
  67569. VertexShader: string;
  67570. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  67571. ReviewUniform(name: string, arr: string[]): string[];
  67572. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  67573. constructor(name: string, scene: BABYLON.Scene);
  67574. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  67575. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  67576. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  67577. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  67578. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  67579. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  67580. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  67581. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  67582. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  67583. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  67584. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  67585. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  67586. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  67587. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  67588. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  67589. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  67590. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  67591. }
  67592. }
  67593. declare module BABYLON {
  67594. /** @hidden */
  67595. export var firePixelShader: {
  67596. name: string;
  67597. shader: string;
  67598. };
  67599. }
  67600. declare module BABYLON {
  67601. /** @hidden */
  67602. export var fireVertexShader: {
  67603. name: string;
  67604. shader: string;
  67605. };
  67606. }
  67607. declare module BABYLON {
  67608. export class FireMaterial extends BABYLON.PushMaterial {
  67609. private _diffuseTexture;
  67610. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67611. private _distortionTexture;
  67612. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67613. private _opacityTexture;
  67614. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67615. diffuseColor: BABYLON.Color3;
  67616. speed: number;
  67617. private _scaledDiffuse;
  67618. private _renderId;
  67619. private _lastTime;
  67620. constructor(name: string, scene: BABYLON.Scene);
  67621. needAlphaBlending(): boolean;
  67622. needAlphaTesting(): boolean;
  67623. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67624. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67625. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67626. getAnimatables(): BABYLON.IAnimatable[];
  67627. getActiveTextures(): BABYLON.BaseTexture[];
  67628. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67629. getClassName(): string;
  67630. dispose(forceDisposeEffect?: boolean): void;
  67631. clone(name: string): FireMaterial;
  67632. serialize(): any;
  67633. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  67634. }
  67635. }
  67636. declare module BABYLON {
  67637. /** @hidden */
  67638. export var furPixelShader: {
  67639. name: string;
  67640. shader: string;
  67641. };
  67642. }
  67643. declare module BABYLON {
  67644. /** @hidden */
  67645. export var furVertexShader: {
  67646. name: string;
  67647. shader: string;
  67648. };
  67649. }
  67650. declare module BABYLON {
  67651. export class FurMaterial extends BABYLON.PushMaterial {
  67652. private _diffuseTexture;
  67653. diffuseTexture: BABYLON.BaseTexture;
  67654. private _heightTexture;
  67655. heightTexture: BABYLON.BaseTexture;
  67656. diffuseColor: BABYLON.Color3;
  67657. furLength: number;
  67658. furAngle: number;
  67659. furColor: BABYLON.Color3;
  67660. furOffset: number;
  67661. furSpacing: number;
  67662. furGravity: BABYLON.Vector3;
  67663. furSpeed: number;
  67664. furDensity: number;
  67665. furOcclusion: number;
  67666. furTexture: BABYLON.DynamicTexture;
  67667. private _disableLighting;
  67668. disableLighting: boolean;
  67669. private _maxSimultaneousLights;
  67670. maxSimultaneousLights: number;
  67671. highLevelFur: boolean;
  67672. _meshes: BABYLON.AbstractMesh[];
  67673. private _renderId;
  67674. private _furTime;
  67675. constructor(name: string, scene: BABYLON.Scene);
  67676. furTime: number;
  67677. needAlphaBlending(): boolean;
  67678. needAlphaTesting(): boolean;
  67679. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67680. updateFur(): void;
  67681. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67682. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67683. getAnimatables(): BABYLON.IAnimatable[];
  67684. getActiveTextures(): BABYLON.BaseTexture[];
  67685. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67686. dispose(forceDisposeEffect?: boolean): void;
  67687. clone(name: string): FurMaterial;
  67688. serialize(): any;
  67689. getClassName(): string;
  67690. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  67691. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  67692. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  67693. }
  67694. }
  67695. declare module BABYLON {
  67696. /** @hidden */
  67697. export var gradientPixelShader: {
  67698. name: string;
  67699. shader: string;
  67700. };
  67701. }
  67702. declare module BABYLON {
  67703. /** @hidden */
  67704. export var gradientVertexShader: {
  67705. name: string;
  67706. shader: string;
  67707. };
  67708. }
  67709. declare module BABYLON {
  67710. export class GradientMaterial extends BABYLON.PushMaterial {
  67711. private _maxSimultaneousLights;
  67712. maxSimultaneousLights: number;
  67713. topColor: BABYLON.Color3;
  67714. topColorAlpha: number;
  67715. bottomColor: BABYLON.Color3;
  67716. bottomColorAlpha: number;
  67717. offset: number;
  67718. scale: number;
  67719. smoothness: number;
  67720. private _disableLighting;
  67721. disableLighting: boolean;
  67722. private _renderId;
  67723. constructor(name: string, scene: BABYLON.Scene);
  67724. needAlphaBlending(): boolean;
  67725. needAlphaTesting(): boolean;
  67726. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67727. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67728. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67729. getAnimatables(): BABYLON.IAnimatable[];
  67730. dispose(forceDisposeEffect?: boolean): void;
  67731. clone(name: string): GradientMaterial;
  67732. serialize(): any;
  67733. getClassName(): string;
  67734. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  67735. }
  67736. }
  67737. declare module BABYLON {
  67738. /** @hidden */
  67739. export var gridPixelShader: {
  67740. name: string;
  67741. shader: string;
  67742. };
  67743. }
  67744. declare module BABYLON {
  67745. /** @hidden */
  67746. export var gridVertexShader: {
  67747. name: string;
  67748. shader: string;
  67749. };
  67750. }
  67751. declare module BABYLON {
  67752. /**
  67753. * The grid materials allows you to wrap any shape with a grid.
  67754. * Colors are customizable.
  67755. */
  67756. export class GridMaterial extends BABYLON.PushMaterial {
  67757. /**
  67758. * Main color of the grid (e.g. between lines)
  67759. */
  67760. mainColor: BABYLON.Color3;
  67761. /**
  67762. * Color of the grid lines.
  67763. */
  67764. lineColor: BABYLON.Color3;
  67765. /**
  67766. * The scale of the grid compared to unit.
  67767. */
  67768. gridRatio: number;
  67769. /**
  67770. * Allows setting an offset for the grid lines.
  67771. */
  67772. gridOffset: BABYLON.Vector3;
  67773. /**
  67774. * The frequency of thicker lines.
  67775. */
  67776. majorUnitFrequency: number;
  67777. /**
  67778. * The visibility of minor units in the grid.
  67779. */
  67780. minorUnitVisibility: number;
  67781. /**
  67782. * The grid opacity outside of the lines.
  67783. */
  67784. opacity: number;
  67785. /**
  67786. * Determine RBG output is premultiplied by alpha value.
  67787. */
  67788. preMultiplyAlpha: boolean;
  67789. private _opacityTexture;
  67790. opacityTexture: BABYLON.BaseTexture;
  67791. private _gridControl;
  67792. private _renderId;
  67793. /**
  67794. * constructor
  67795. * @param name The name given to the material in order to identify it afterwards.
  67796. * @param scene The scene the material is used in.
  67797. */
  67798. constructor(name: string, scene: BABYLON.Scene);
  67799. /**
  67800. * Returns wehter or not the grid requires alpha blending.
  67801. */
  67802. needAlphaBlending(): boolean;
  67803. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  67804. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67805. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67806. /**
  67807. * Dispose the material and its associated resources.
  67808. * @param forceDisposeEffect will also dispose the used effect when true
  67809. */
  67810. dispose(forceDisposeEffect?: boolean): void;
  67811. clone(name: string): GridMaterial;
  67812. serialize(): any;
  67813. getClassName(): string;
  67814. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  67815. }
  67816. }
  67817. declare module BABYLON {
  67818. /** @hidden */
  67819. export var lavaPixelShader: {
  67820. name: string;
  67821. shader: string;
  67822. };
  67823. }
  67824. declare module BABYLON {
  67825. /** @hidden */
  67826. export var lavaVertexShader: {
  67827. name: string;
  67828. shader: string;
  67829. };
  67830. }
  67831. declare module BABYLON {
  67832. export class LavaMaterial extends BABYLON.PushMaterial {
  67833. private _diffuseTexture;
  67834. diffuseTexture: BABYLON.BaseTexture;
  67835. noiseTexture: BABYLON.BaseTexture;
  67836. fogColor: BABYLON.Color3;
  67837. speed: number;
  67838. movingSpeed: number;
  67839. lowFrequencySpeed: number;
  67840. fogDensity: number;
  67841. private _lastTime;
  67842. diffuseColor: BABYLON.Color3;
  67843. private _disableLighting;
  67844. disableLighting: boolean;
  67845. private _unlit;
  67846. unlit: boolean;
  67847. private _maxSimultaneousLights;
  67848. maxSimultaneousLights: number;
  67849. private _scaledDiffuse;
  67850. private _renderId;
  67851. constructor(name: string, scene: BABYLON.Scene);
  67852. needAlphaBlending(): boolean;
  67853. needAlphaTesting(): boolean;
  67854. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67855. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67856. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67857. getAnimatables(): BABYLON.IAnimatable[];
  67858. getActiveTextures(): BABYLON.BaseTexture[];
  67859. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67860. dispose(forceDisposeEffect?: boolean): void;
  67861. clone(name: string): LavaMaterial;
  67862. serialize(): any;
  67863. getClassName(): string;
  67864. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  67865. }
  67866. }
  67867. declare module BABYLON {
  67868. /** @hidden */
  67869. export var mixPixelShader: {
  67870. name: string;
  67871. shader: string;
  67872. };
  67873. }
  67874. declare module BABYLON {
  67875. /** @hidden */
  67876. export var mixVertexShader: {
  67877. name: string;
  67878. shader: string;
  67879. };
  67880. }
  67881. declare module BABYLON {
  67882. export class MixMaterial extends BABYLON.PushMaterial {
  67883. /**
  67884. * Mix textures
  67885. */
  67886. private _mixTexture1;
  67887. mixTexture1: BABYLON.BaseTexture;
  67888. private _mixTexture2;
  67889. mixTexture2: BABYLON.BaseTexture;
  67890. /**
  67891. * Diffuse textures
  67892. */
  67893. private _diffuseTexture1;
  67894. diffuseTexture1: BABYLON.Texture;
  67895. private _diffuseTexture2;
  67896. diffuseTexture2: BABYLON.Texture;
  67897. private _diffuseTexture3;
  67898. diffuseTexture3: BABYLON.Texture;
  67899. private _diffuseTexture4;
  67900. diffuseTexture4: BABYLON.Texture;
  67901. private _diffuseTexture5;
  67902. diffuseTexture5: BABYLON.Texture;
  67903. private _diffuseTexture6;
  67904. diffuseTexture6: BABYLON.Texture;
  67905. private _diffuseTexture7;
  67906. diffuseTexture7: BABYLON.Texture;
  67907. private _diffuseTexture8;
  67908. diffuseTexture8: BABYLON.Texture;
  67909. /**
  67910. * Uniforms
  67911. */
  67912. diffuseColor: BABYLON.Color3;
  67913. specularColor: BABYLON.Color3;
  67914. specularPower: number;
  67915. private _disableLighting;
  67916. disableLighting: boolean;
  67917. private _maxSimultaneousLights;
  67918. maxSimultaneousLights: number;
  67919. private _renderId;
  67920. constructor(name: string, scene: BABYLON.Scene);
  67921. needAlphaBlending(): boolean;
  67922. needAlphaTesting(): boolean;
  67923. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67924. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67925. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67926. getAnimatables(): BABYLON.IAnimatable[];
  67927. getActiveTextures(): BABYLON.BaseTexture[];
  67928. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67929. dispose(forceDisposeEffect?: boolean): void;
  67930. clone(name: string): MixMaterial;
  67931. serialize(): any;
  67932. getClassName(): string;
  67933. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  67934. }
  67935. }
  67936. declare module BABYLON {
  67937. /** @hidden */
  67938. export var normalPixelShader: {
  67939. name: string;
  67940. shader: string;
  67941. };
  67942. }
  67943. declare module BABYLON {
  67944. /** @hidden */
  67945. export var normalVertexShader: {
  67946. name: string;
  67947. shader: string;
  67948. };
  67949. }
  67950. declare module BABYLON {
  67951. export class NormalMaterial extends BABYLON.PushMaterial {
  67952. private _diffuseTexture;
  67953. diffuseTexture: BABYLON.BaseTexture;
  67954. diffuseColor: BABYLON.Color3;
  67955. private _disableLighting;
  67956. disableLighting: boolean;
  67957. private _maxSimultaneousLights;
  67958. maxSimultaneousLights: number;
  67959. private _renderId;
  67960. constructor(name: string, scene: BABYLON.Scene);
  67961. needAlphaBlending(): boolean;
  67962. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  67963. needAlphaTesting(): boolean;
  67964. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67965. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67966. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67967. getAnimatables(): BABYLON.IAnimatable[];
  67968. getActiveTextures(): BABYLON.BaseTexture[];
  67969. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67970. dispose(forceDisposeEffect?: boolean): void;
  67971. clone(name: string): NormalMaterial;
  67972. serialize(): any;
  67973. getClassName(): string;
  67974. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  67975. }
  67976. }
  67977. declare module BABYLON {
  67978. /** @hidden */
  67979. export var shadowOnlyPixelShader: {
  67980. name: string;
  67981. shader: string;
  67982. };
  67983. }
  67984. declare module BABYLON {
  67985. /** @hidden */
  67986. export var shadowOnlyVertexShader: {
  67987. name: string;
  67988. shader: string;
  67989. };
  67990. }
  67991. declare module BABYLON {
  67992. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  67993. private _renderId;
  67994. private _activeLight;
  67995. constructor(name: string, scene: BABYLON.Scene);
  67996. shadowColor: BABYLON.Color3;
  67997. needAlphaBlending(): boolean;
  67998. needAlphaTesting(): boolean;
  67999. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68000. activeLight: BABYLON.IShadowLight;
  68001. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68002. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68003. clone(name: string): ShadowOnlyMaterial;
  68004. serialize(): any;
  68005. getClassName(): string;
  68006. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  68007. }
  68008. }
  68009. declare module BABYLON {
  68010. /** @hidden */
  68011. export var simplePixelShader: {
  68012. name: string;
  68013. shader: string;
  68014. };
  68015. }
  68016. declare module BABYLON {
  68017. /** @hidden */
  68018. export var simpleVertexShader: {
  68019. name: string;
  68020. shader: string;
  68021. };
  68022. }
  68023. declare module BABYLON {
  68024. export class SimpleMaterial extends BABYLON.PushMaterial {
  68025. private _diffuseTexture;
  68026. diffuseTexture: BABYLON.BaseTexture;
  68027. diffuseColor: BABYLON.Color3;
  68028. private _disableLighting;
  68029. disableLighting: boolean;
  68030. private _maxSimultaneousLights;
  68031. maxSimultaneousLights: number;
  68032. private _renderId;
  68033. constructor(name: string, scene: BABYLON.Scene);
  68034. needAlphaBlending(): boolean;
  68035. needAlphaTesting(): boolean;
  68036. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68037. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68038. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68039. getAnimatables(): BABYLON.IAnimatable[];
  68040. getActiveTextures(): BABYLON.BaseTexture[];
  68041. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68042. dispose(forceDisposeEffect?: boolean): void;
  68043. clone(name: string): SimpleMaterial;
  68044. serialize(): any;
  68045. getClassName(): string;
  68046. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  68047. }
  68048. }
  68049. declare module BABYLON {
  68050. /** @hidden */
  68051. export var skyPixelShader: {
  68052. name: string;
  68053. shader: string;
  68054. };
  68055. }
  68056. declare module BABYLON {
  68057. /** @hidden */
  68058. export var skyVertexShader: {
  68059. name: string;
  68060. shader: string;
  68061. };
  68062. }
  68063. declare module BABYLON {
  68064. /**
  68065. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  68066. * @see https://doc.babylonjs.com/extensions/sky
  68067. */
  68068. export class SkyMaterial extends BABYLON.PushMaterial {
  68069. /**
  68070. * Defines the overall luminance of sky in interval ]0, 1[.
  68071. */
  68072. luminance: number;
  68073. /**
  68074. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  68075. */
  68076. turbidity: number;
  68077. /**
  68078. * Defines the sky appearance (light intensity).
  68079. */
  68080. rayleigh: number;
  68081. /**
  68082. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  68083. */
  68084. mieCoefficient: number;
  68085. /**
  68086. * Defines the amount of haze particles following the Mie scattering theory.
  68087. */
  68088. mieDirectionalG: number;
  68089. /**
  68090. * Defines the distance of the sun according to the active scene camera.
  68091. */
  68092. distance: number;
  68093. /**
  68094. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  68095. * "inclined".
  68096. */
  68097. inclination: number;
  68098. /**
  68099. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  68100. * an object direction and a reference direction.
  68101. */
  68102. azimuth: number;
  68103. /**
  68104. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  68105. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  68106. */
  68107. sunPosition: BABYLON.Vector3;
  68108. /**
  68109. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  68110. * .sunPosition property.
  68111. */
  68112. useSunPosition: boolean;
  68113. /**
  68114. * Defines an offset vector used to get a horizon offset.
  68115. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  68116. */
  68117. cameraOffset: BABYLON.Vector3;
  68118. private _cameraPosition;
  68119. private _renderId;
  68120. /**
  68121. * Instantiates a new sky material.
  68122. * This material allows to create dynamic and texture free
  68123. * effects for skyboxes by taking care of the atmosphere state.
  68124. * @see https://doc.babylonjs.com/extensions/sky
  68125. * @param name Define the name of the material in the scene
  68126. * @param scene Define the scene the material belong to
  68127. */
  68128. constructor(name: string, scene: BABYLON.Scene);
  68129. /**
  68130. * Specifies if the material will require alpha blending
  68131. * @returns a boolean specifying if alpha blending is needed
  68132. */
  68133. needAlphaBlending(): boolean;
  68134. /**
  68135. * Specifies if this material should be rendered in alpha test mode
  68136. * @returns false as the sky material doesn't need alpha testing.
  68137. */
  68138. needAlphaTesting(): boolean;
  68139. /**
  68140. * Get the texture used for alpha test purpose.
  68141. * @returns null as the sky material has no texture.
  68142. */
  68143. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68144. /**
  68145. * Get if the submesh is ready to be used and all its information available.
  68146. * Child classes can use it to update shaders
  68147. * @param mesh defines the mesh to check
  68148. * @param subMesh defines which submesh to check
  68149. * @param useInstances specifies that instances should be used
  68150. * @returns a boolean indicating that the submesh is ready or not
  68151. */
  68152. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68153. /**
  68154. * Binds the submesh to this material by preparing the effect and shader to draw
  68155. * @param world defines the world transformation matrix
  68156. * @param mesh defines the mesh containing the submesh
  68157. * @param subMesh defines the submesh to bind the material to
  68158. */
  68159. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68160. /**
  68161. * Get the list of animatables in the material.
  68162. * @returns the list of animatables object used in the material
  68163. */
  68164. getAnimatables(): BABYLON.IAnimatable[];
  68165. /**
  68166. * Disposes the material
  68167. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  68168. */
  68169. dispose(forceDisposeEffect?: boolean): void;
  68170. /**
  68171. * Makes a duplicate of the material, and gives it a new name
  68172. * @param name defines the new name for the duplicated material
  68173. * @returns the cloned material
  68174. */
  68175. clone(name: string): SkyMaterial;
  68176. /**
  68177. * Serializes this material in a JSON representation
  68178. * @returns the serialized material object
  68179. */
  68180. serialize(): any;
  68181. /**
  68182. * Gets the current class name of the material e.g. "SkyMaterial"
  68183. * Mainly use in serialization.
  68184. * @returns the class name
  68185. */
  68186. getClassName(): string;
  68187. /**
  68188. * Creates a sky material from parsed material data
  68189. * @param source defines the JSON representation of the material
  68190. * @param scene defines the hosting scene
  68191. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68192. * @returns a new sky material
  68193. */
  68194. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  68195. }
  68196. }
  68197. declare module BABYLON {
  68198. /** @hidden */
  68199. export var terrainPixelShader: {
  68200. name: string;
  68201. shader: string;
  68202. };
  68203. }
  68204. declare module BABYLON {
  68205. /** @hidden */
  68206. export var terrainVertexShader: {
  68207. name: string;
  68208. shader: string;
  68209. };
  68210. }
  68211. declare module BABYLON {
  68212. export class TerrainMaterial extends BABYLON.PushMaterial {
  68213. private _mixTexture;
  68214. mixTexture: BABYLON.BaseTexture;
  68215. private _diffuseTexture1;
  68216. diffuseTexture1: BABYLON.Texture;
  68217. private _diffuseTexture2;
  68218. diffuseTexture2: BABYLON.Texture;
  68219. private _diffuseTexture3;
  68220. diffuseTexture3: BABYLON.Texture;
  68221. private _bumpTexture1;
  68222. bumpTexture1: BABYLON.Texture;
  68223. private _bumpTexture2;
  68224. bumpTexture2: BABYLON.Texture;
  68225. private _bumpTexture3;
  68226. bumpTexture3: BABYLON.Texture;
  68227. diffuseColor: BABYLON.Color3;
  68228. specularColor: BABYLON.Color3;
  68229. specularPower: number;
  68230. private _disableLighting;
  68231. disableLighting: boolean;
  68232. private _maxSimultaneousLights;
  68233. maxSimultaneousLights: number;
  68234. private _renderId;
  68235. constructor(name: string, scene: BABYLON.Scene);
  68236. needAlphaBlending(): boolean;
  68237. needAlphaTesting(): boolean;
  68238. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68239. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68240. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68241. getAnimatables(): BABYLON.IAnimatable[];
  68242. getActiveTextures(): BABYLON.BaseTexture[];
  68243. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68244. dispose(forceDisposeEffect?: boolean): void;
  68245. clone(name: string): TerrainMaterial;
  68246. serialize(): any;
  68247. getClassName(): string;
  68248. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  68249. }
  68250. }
  68251. declare module BABYLON {
  68252. /** @hidden */
  68253. export var triplanarPixelShader: {
  68254. name: string;
  68255. shader: string;
  68256. };
  68257. }
  68258. declare module BABYLON {
  68259. /** @hidden */
  68260. export var triplanarVertexShader: {
  68261. name: string;
  68262. shader: string;
  68263. };
  68264. }
  68265. declare module BABYLON {
  68266. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  68267. mixTexture: BABYLON.BaseTexture;
  68268. private _diffuseTextureX;
  68269. diffuseTextureX: BABYLON.BaseTexture;
  68270. private _diffuseTextureY;
  68271. diffuseTextureY: BABYLON.BaseTexture;
  68272. private _diffuseTextureZ;
  68273. diffuseTextureZ: BABYLON.BaseTexture;
  68274. private _normalTextureX;
  68275. normalTextureX: BABYLON.BaseTexture;
  68276. private _normalTextureY;
  68277. normalTextureY: BABYLON.BaseTexture;
  68278. private _normalTextureZ;
  68279. normalTextureZ: BABYLON.BaseTexture;
  68280. tileSize: number;
  68281. diffuseColor: BABYLON.Color3;
  68282. specularColor: BABYLON.Color3;
  68283. specularPower: number;
  68284. private _disableLighting;
  68285. disableLighting: boolean;
  68286. private _maxSimultaneousLights;
  68287. maxSimultaneousLights: number;
  68288. private _renderId;
  68289. constructor(name: string, scene: BABYLON.Scene);
  68290. needAlphaBlending(): boolean;
  68291. needAlphaTesting(): boolean;
  68292. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68293. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68294. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68295. getAnimatables(): BABYLON.IAnimatable[];
  68296. getActiveTextures(): BABYLON.BaseTexture[];
  68297. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68298. dispose(forceDisposeEffect?: boolean): void;
  68299. clone(name: string): TriPlanarMaterial;
  68300. serialize(): any;
  68301. getClassName(): string;
  68302. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  68303. }
  68304. }
  68305. declare module BABYLON {
  68306. /** @hidden */
  68307. export var waterPixelShader: {
  68308. name: string;
  68309. shader: string;
  68310. };
  68311. }
  68312. declare module BABYLON {
  68313. /** @hidden */
  68314. export var waterVertexShader: {
  68315. name: string;
  68316. shader: string;
  68317. };
  68318. }
  68319. declare module BABYLON {
  68320. export class WaterMaterial extends BABYLON.PushMaterial {
  68321. renderTargetSize: BABYLON.Vector2;
  68322. private _bumpTexture;
  68323. bumpTexture: BABYLON.BaseTexture;
  68324. diffuseColor: BABYLON.Color3;
  68325. specularColor: BABYLON.Color3;
  68326. specularPower: number;
  68327. private _disableLighting;
  68328. disableLighting: boolean;
  68329. private _maxSimultaneousLights;
  68330. maxSimultaneousLights: number;
  68331. /**
  68332. * @param {number}: Represents the wind force
  68333. */
  68334. windForce: number;
  68335. /**
  68336. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  68337. */
  68338. windDirection: BABYLON.Vector2;
  68339. /**
  68340. * @param {number}: Wave height, represents the height of the waves
  68341. */
  68342. waveHeight: number;
  68343. /**
  68344. * @param {number}: Bump height, represents the bump height related to the bump map
  68345. */
  68346. bumpHeight: number;
  68347. /**
  68348. * @param {boolean}: Add a smaller moving bump to less steady waves.
  68349. */
  68350. private _bumpSuperimpose;
  68351. bumpSuperimpose: boolean;
  68352. /**
  68353. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  68354. */
  68355. private _fresnelSeparate;
  68356. fresnelSeparate: boolean;
  68357. /**
  68358. * @param {boolean}: bump Waves modify the reflection.
  68359. */
  68360. private _bumpAffectsReflection;
  68361. bumpAffectsReflection: boolean;
  68362. /**
  68363. * @param {number}: The water color blended with the refraction (near)
  68364. */
  68365. waterColor: BABYLON.Color3;
  68366. /**
  68367. * @param {number}: The blend factor related to the water color
  68368. */
  68369. colorBlendFactor: number;
  68370. /**
  68371. * @param {number}: The water color blended with the reflection (far)
  68372. */
  68373. waterColor2: BABYLON.Color3;
  68374. /**
  68375. * @param {number}: The blend factor related to the water color (reflection, far)
  68376. */
  68377. colorBlendFactor2: number;
  68378. /**
  68379. * @param {number}: Represents the maximum length of a wave
  68380. */
  68381. waveLength: number;
  68382. /**
  68383. * @param {number}: Defines the waves speed
  68384. */
  68385. waveSpeed: number;
  68386. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  68387. private _mesh;
  68388. private _refractionRTT;
  68389. private _reflectionRTT;
  68390. private _reflectionTransform;
  68391. private _lastTime;
  68392. private _lastDeltaTime;
  68393. private _renderId;
  68394. private _useLogarithmicDepth;
  68395. private _waitingRenderList;
  68396. /**
  68397. * Gets a boolean indicating that current material needs to register RTT
  68398. */
  68399. readonly hasRenderTargetTextures: boolean;
  68400. /**
  68401. * Constructor
  68402. */
  68403. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  68404. useLogarithmicDepth: boolean;
  68405. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  68406. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  68407. addToRenderList(node: any): void;
  68408. enableRenderTargets(enable: boolean): void;
  68409. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  68410. readonly renderTargetsEnabled: boolean;
  68411. needAlphaBlending(): boolean;
  68412. needAlphaTesting(): boolean;
  68413. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68414. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68415. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68416. private _createRenderTargets;
  68417. getAnimatables(): BABYLON.IAnimatable[];
  68418. getActiveTextures(): BABYLON.BaseTexture[];
  68419. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68420. dispose(forceDisposeEffect?: boolean): void;
  68421. clone(name: string): WaterMaterial;
  68422. serialize(): any;
  68423. getClassName(): string;
  68424. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  68425. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  68426. }
  68427. }
  68428. declare module BABYLON {
  68429. /** @hidden */
  68430. export var asciiartPixelShader: {
  68431. name: string;
  68432. shader: string;
  68433. };
  68434. }
  68435. declare module BABYLON {
  68436. /**
  68437. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  68438. *
  68439. * It basically takes care rendering the font front the given font size to a texture.
  68440. * This is used later on in the postprocess.
  68441. */
  68442. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  68443. private _font;
  68444. private _text;
  68445. private _charSize;
  68446. /**
  68447. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  68448. */
  68449. readonly charSize: number;
  68450. /**
  68451. * Create a new instance of the Ascii Art FontTexture class
  68452. * @param name the name of the texture
  68453. * @param font the font to use, use the W3C CSS notation
  68454. * @param text the caracter set to use in the rendering.
  68455. * @param scene the scene that owns the texture
  68456. */
  68457. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  68458. /**
  68459. * Gets the max char width of a font.
  68460. * @param font the font to use, use the W3C CSS notation
  68461. * @return the max char width
  68462. */
  68463. private getFontWidth;
  68464. /**
  68465. * Gets the max char height of a font.
  68466. * @param font the font to use, use the W3C CSS notation
  68467. * @return the max char height
  68468. */
  68469. private getFontHeight;
  68470. /**
  68471. * Clones the current AsciiArtTexture.
  68472. * @return the clone of the texture.
  68473. */
  68474. clone(): AsciiArtFontTexture;
  68475. /**
  68476. * Parses a json object representing the texture and returns an instance of it.
  68477. * @param source the source JSON representation
  68478. * @param scene the scene to create the texture for
  68479. * @return the parsed texture
  68480. */
  68481. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  68482. }
  68483. /**
  68484. * Option available in the Ascii Art Post Process.
  68485. */
  68486. export interface IAsciiArtPostProcessOptions {
  68487. /**
  68488. * The font to use following the w3c font definition.
  68489. */
  68490. font?: string;
  68491. /**
  68492. * The character set to use in the postprocess.
  68493. */
  68494. characterSet?: string;
  68495. /**
  68496. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  68497. * This number is defined between 0 and 1;
  68498. */
  68499. mixToTile?: number;
  68500. /**
  68501. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  68502. * This number is defined between 0 and 1;
  68503. */
  68504. mixToNormal?: number;
  68505. }
  68506. /**
  68507. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  68508. *
  68509. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68510. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  68511. */
  68512. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  68513. /**
  68514. * The font texture used to render the char in the post process.
  68515. */
  68516. private _asciiArtFontTexture;
  68517. /**
  68518. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  68519. * This number is defined between 0 and 1;
  68520. */
  68521. mixToTile: number;
  68522. /**
  68523. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  68524. * This number is defined between 0 and 1;
  68525. */
  68526. mixToNormal: number;
  68527. /**
  68528. * Instantiates a new Ascii Art Post Process.
  68529. * @param name the name to give to the postprocess
  68530. * @camera the camera to apply the post process to.
  68531. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  68532. */
  68533. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  68534. }
  68535. }
  68536. declare module BABYLON {
  68537. /** @hidden */
  68538. export var digitalrainPixelShader: {
  68539. name: string;
  68540. shader: string;
  68541. };
  68542. }
  68543. declare module BABYLON {
  68544. /**
  68545. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  68546. *
  68547. * It basically takes care rendering the font front the given font size to a texture.
  68548. * This is used later on in the postprocess.
  68549. */
  68550. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  68551. private _font;
  68552. private _text;
  68553. private _charSize;
  68554. /**
  68555. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  68556. */
  68557. readonly charSize: number;
  68558. /**
  68559. * Create a new instance of the Digital Rain FontTexture class
  68560. * @param name the name of the texture
  68561. * @param font the font to use, use the W3C CSS notation
  68562. * @param text the caracter set to use in the rendering.
  68563. * @param scene the scene that owns the texture
  68564. */
  68565. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  68566. /**
  68567. * Gets the max char width of a font.
  68568. * @param font the font to use, use the W3C CSS notation
  68569. * @return the max char width
  68570. */
  68571. private getFontWidth;
  68572. /**
  68573. * Gets the max char height of a font.
  68574. * @param font the font to use, use the W3C CSS notation
  68575. * @return the max char height
  68576. */
  68577. private getFontHeight;
  68578. /**
  68579. * Clones the current DigitalRainFontTexture.
  68580. * @return the clone of the texture.
  68581. */
  68582. clone(): DigitalRainFontTexture;
  68583. /**
  68584. * Parses a json object representing the texture and returns an instance of it.
  68585. * @param source the source JSON representation
  68586. * @param scene the scene to create the texture for
  68587. * @return the parsed texture
  68588. */
  68589. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  68590. }
  68591. /**
  68592. * Option available in the Digital Rain Post Process.
  68593. */
  68594. export interface IDigitalRainPostProcessOptions {
  68595. /**
  68596. * The font to use following the w3c font definition.
  68597. */
  68598. font?: string;
  68599. /**
  68600. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  68601. * This number is defined between 0 and 1;
  68602. */
  68603. mixToTile?: number;
  68604. /**
  68605. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  68606. * This number is defined between 0 and 1;
  68607. */
  68608. mixToNormal?: number;
  68609. }
  68610. /**
  68611. * DigitalRainPostProcess helps rendering everithing in digital rain.
  68612. *
  68613. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68614. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  68615. */
  68616. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  68617. /**
  68618. * The font texture used to render the char in the post process.
  68619. */
  68620. private _digitalRainFontTexture;
  68621. /**
  68622. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  68623. * This number is defined between 0 and 1;
  68624. */
  68625. mixToTile: number;
  68626. /**
  68627. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  68628. * This number is defined between 0 and 1;
  68629. */
  68630. mixToNormal: number;
  68631. /**
  68632. * Instantiates a new Digital Rain Post Process.
  68633. * @param name the name to give to the postprocess
  68634. * @camera the camera to apply the post process to.
  68635. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  68636. */
  68637. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  68638. }
  68639. }
  68640. declare module BABYLON {
  68641. /** @hidden */
  68642. export var oceanPostProcessPixelShader: {
  68643. name: string;
  68644. shader: string;
  68645. };
  68646. }
  68647. declare module BABYLON {
  68648. /**
  68649. * Option available in the Ocean Post Process.
  68650. */
  68651. export interface IOceanPostProcessOptions {
  68652. /**
  68653. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  68654. */
  68655. reflectionSize?: number | {
  68656. width: number;
  68657. height: number;
  68658. } | {
  68659. ratio: number;
  68660. };
  68661. /**
  68662. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  68663. */
  68664. refractionSize?: number | {
  68665. width: number;
  68666. height: number;
  68667. } | {
  68668. ratio: number;
  68669. };
  68670. }
  68671. /**
  68672. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  68673. *
  68674. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68675. * Example usage:
  68676. * var pp = new OceanPostProcess("myOcean", camera);
  68677. * pp.reflectionEnabled = true;
  68678. * pp.refractionEnabled = true;
  68679. */
  68680. export class OceanPostProcess extends BABYLON.PostProcess {
  68681. /**
  68682. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  68683. */
  68684. /**
  68685. * Sets weither or not the real-time reflection is enabled on the ocean.
  68686. * Is set to true, the reflection mirror texture will be used as reflection texture.
  68687. */
  68688. reflectionEnabled: boolean;
  68689. /**
  68690. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  68691. */
  68692. /**
  68693. * Sets weither or not the real-time refraction is enabled on the ocean.
  68694. * Is set to true, the refraction render target texture will be used as refraction texture.
  68695. */
  68696. refractionEnabled: boolean;
  68697. /**
  68698. * Gets wether or not the post-processes is supported by the running hardware.
  68699. * This requires draw buffer supports.
  68700. */
  68701. readonly isSupported: boolean;
  68702. /**
  68703. * This is the reflection mirror texture used to display reflections on the ocean.
  68704. * By default, render list is empty.
  68705. */
  68706. reflectionTexture: BABYLON.MirrorTexture;
  68707. /**
  68708. * This is the refraction render target texture used to display refraction on the ocean.
  68709. * By default, render list is empty.
  68710. */
  68711. refractionTexture: BABYLON.RenderTargetTexture;
  68712. private _time;
  68713. private _cameraRotation;
  68714. private _cameraViewMatrix;
  68715. private _reflectionEnabled;
  68716. private _refractionEnabled;
  68717. private _geometryRenderer;
  68718. /**
  68719. * Instantiates a new Ocean Post Process.
  68720. * @param name the name to give to the postprocess.
  68721. * @camera the camera to apply the post process to.
  68722. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  68723. */
  68724. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  68725. /**
  68726. * Returns the appropriate defines according to the current configuration.
  68727. */
  68728. private _getDefines;
  68729. /**
  68730. * Computes the current camera rotation as the shader requires a camera rotation.
  68731. */
  68732. private _computeCameraRotation;
  68733. }
  68734. }
  68735. declare module BABYLON {
  68736. /** @hidden */
  68737. export var brickProceduralTexturePixelShader: {
  68738. name: string;
  68739. shader: string;
  68740. };
  68741. }
  68742. declare module BABYLON {
  68743. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  68744. private _numberOfBricksHeight;
  68745. private _numberOfBricksWidth;
  68746. private _jointColor;
  68747. private _brickColor;
  68748. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68749. updateShaderUniforms(): void;
  68750. numberOfBricksHeight: number;
  68751. numberOfBricksWidth: number;
  68752. jointColor: BABYLON.Color3;
  68753. brickColor: BABYLON.Color3;
  68754. /**
  68755. * Serializes this brick procedural texture
  68756. * @returns a serialized brick procedural texture object
  68757. */
  68758. serialize(): any;
  68759. /**
  68760. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  68761. * @param parsedTexture defines parsed texture data
  68762. * @param scene defines the current scene
  68763. * @param rootUrl defines the root URL containing brick procedural texture information
  68764. * @returns a parsed Brick Procedural BABYLON.Texture
  68765. */
  68766. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  68767. }
  68768. }
  68769. declare module BABYLON {
  68770. /** @hidden */
  68771. export var cloudProceduralTexturePixelShader: {
  68772. name: string;
  68773. shader: string;
  68774. };
  68775. }
  68776. declare module BABYLON {
  68777. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  68778. private _skyColor;
  68779. private _cloudColor;
  68780. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68781. updateShaderUniforms(): void;
  68782. skyColor: BABYLON.Color4;
  68783. cloudColor: BABYLON.Color4;
  68784. /**
  68785. * Serializes this cloud procedural texture
  68786. * @returns a serialized cloud procedural texture object
  68787. */
  68788. serialize(): any;
  68789. /**
  68790. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  68791. * @param parsedTexture defines parsed texture data
  68792. * @param scene defines the current scene
  68793. * @param rootUrl defines the root URL containing cloud procedural texture information
  68794. * @returns a parsed Cloud Procedural BABYLON.Texture
  68795. */
  68796. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  68797. }
  68798. }
  68799. declare module BABYLON {
  68800. /** @hidden */
  68801. export var fireProceduralTexturePixelShader: {
  68802. name: string;
  68803. shader: string;
  68804. };
  68805. }
  68806. declare module BABYLON {
  68807. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  68808. private _time;
  68809. private _speed;
  68810. private _autoGenerateTime;
  68811. private _fireColors;
  68812. private _alphaThreshold;
  68813. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68814. updateShaderUniforms(): void;
  68815. render(useCameraPostProcess?: boolean): void;
  68816. static readonly PurpleFireColors: BABYLON.Color3[];
  68817. static readonly GreenFireColors: BABYLON.Color3[];
  68818. static readonly RedFireColors: BABYLON.Color3[];
  68819. static readonly BlueFireColors: BABYLON.Color3[];
  68820. autoGenerateTime: boolean;
  68821. fireColors: BABYLON.Color3[];
  68822. time: number;
  68823. speed: BABYLON.Vector2;
  68824. alphaThreshold: number;
  68825. /**
  68826. * Serializes this fire procedural texture
  68827. * @returns a serialized fire procedural texture object
  68828. */
  68829. serialize(): any;
  68830. /**
  68831. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  68832. * @param parsedTexture defines parsed texture data
  68833. * @param scene defines the current scene
  68834. * @param rootUrl defines the root URL containing fire procedural texture information
  68835. * @returns a parsed Fire Procedural BABYLON.Texture
  68836. */
  68837. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  68838. }
  68839. }
  68840. declare module BABYLON {
  68841. /** @hidden */
  68842. export var grassProceduralTexturePixelShader: {
  68843. name: string;
  68844. shader: string;
  68845. };
  68846. }
  68847. declare module BABYLON {
  68848. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  68849. private _grassColors;
  68850. private _groundColor;
  68851. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68852. updateShaderUniforms(): void;
  68853. grassColors: BABYLON.Color3[];
  68854. groundColor: BABYLON.Color3;
  68855. /**
  68856. * Serializes this grass procedural texture
  68857. * @returns a serialized grass procedural texture object
  68858. */
  68859. serialize(): any;
  68860. /**
  68861. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  68862. * @param parsedTexture defines parsed texture data
  68863. * @param scene defines the current scene
  68864. * @param rootUrl defines the root URL containing grass procedural texture information
  68865. * @returns a parsed Grass Procedural BABYLON.Texture
  68866. */
  68867. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  68868. }
  68869. }
  68870. declare module BABYLON {
  68871. /** @hidden */
  68872. export var marbleProceduralTexturePixelShader: {
  68873. name: string;
  68874. shader: string;
  68875. };
  68876. }
  68877. declare module BABYLON {
  68878. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  68879. private _numberOfTilesHeight;
  68880. private _numberOfTilesWidth;
  68881. private _amplitude;
  68882. private _jointColor;
  68883. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68884. updateShaderUniforms(): void;
  68885. numberOfTilesHeight: number;
  68886. amplitude: number;
  68887. numberOfTilesWidth: number;
  68888. jointColor: BABYLON.Color3;
  68889. /**
  68890. * Serializes this marble procedural texture
  68891. * @returns a serialized marble procedural texture object
  68892. */
  68893. serialize(): any;
  68894. /**
  68895. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  68896. * @param parsedTexture defines parsed texture data
  68897. * @param scene defines the current scene
  68898. * @param rootUrl defines the root URL containing marble procedural texture information
  68899. * @returns a parsed Marble Procedural BABYLON.Texture
  68900. */
  68901. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  68902. }
  68903. }
  68904. declare module BABYLON {
  68905. /** @hidden */
  68906. export var normalMapProceduralTexturePixelShader: {
  68907. name: string;
  68908. shader: string;
  68909. };
  68910. }
  68911. declare module BABYLON {
  68912. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  68913. private _baseTexture;
  68914. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68915. updateShaderUniforms(): void;
  68916. render(useCameraPostProcess?: boolean): void;
  68917. resize(size: any, generateMipMaps: any): void;
  68918. baseTexture: BABYLON.Texture;
  68919. /**
  68920. * Serializes this normal map procedural texture
  68921. * @returns a serialized normal map procedural texture object
  68922. */
  68923. serialize(): any;
  68924. /**
  68925. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  68926. * @param parsedTexture defines parsed texture data
  68927. * @param scene defines the current scene
  68928. * @param rootUrl defines the root URL containing normal map procedural texture information
  68929. * @returns a parsed Normal Map Procedural BABYLON.Texture
  68930. */
  68931. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  68932. }
  68933. }
  68934. declare module BABYLON {
  68935. /** @hidden */
  68936. export var perlinNoiseProceduralTexturePixelShader: {
  68937. name: string;
  68938. shader: string;
  68939. };
  68940. }
  68941. declare module BABYLON {
  68942. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  68943. time: number;
  68944. timeScale: number;
  68945. translationSpeed: number;
  68946. private _currentTranslation;
  68947. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68948. updateShaderUniforms(): void;
  68949. render(useCameraPostProcess?: boolean): void;
  68950. resize(size: any, generateMipMaps: any): void;
  68951. /**
  68952. * Serializes this perlin noise procedural texture
  68953. * @returns a serialized perlin noise procedural texture object
  68954. */
  68955. serialize(): any;
  68956. /**
  68957. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  68958. * @param parsedTexture defines parsed texture data
  68959. * @param scene defines the current scene
  68960. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  68961. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  68962. */
  68963. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  68964. }
  68965. }
  68966. declare module BABYLON {
  68967. /** @hidden */
  68968. export var roadProceduralTexturePixelShader: {
  68969. name: string;
  68970. shader: string;
  68971. };
  68972. }
  68973. declare module BABYLON {
  68974. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  68975. private _roadColor;
  68976. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68977. updateShaderUniforms(): void;
  68978. roadColor: BABYLON.Color3;
  68979. /**
  68980. * Serializes this road procedural texture
  68981. * @returns a serialized road procedural texture object
  68982. */
  68983. serialize(): any;
  68984. /**
  68985. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  68986. * @param parsedTexture defines parsed texture data
  68987. * @param scene defines the current scene
  68988. * @param rootUrl defines the root URL containing road procedural texture information
  68989. * @returns a parsed Road Procedural BABYLON.Texture
  68990. */
  68991. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  68992. }
  68993. }
  68994. declare module BABYLON {
  68995. /** @hidden */
  68996. export var starfieldProceduralTexturePixelShader: {
  68997. name: string;
  68998. shader: string;
  68999. };
  69000. }
  69001. declare module BABYLON {
  69002. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  69003. private _time;
  69004. private _alpha;
  69005. private _beta;
  69006. private _zoom;
  69007. private _formuparam;
  69008. private _stepsize;
  69009. private _tile;
  69010. private _brightness;
  69011. private _darkmatter;
  69012. private _distfading;
  69013. private _saturation;
  69014. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69015. updateShaderUniforms(): void;
  69016. time: number;
  69017. alpha: number;
  69018. beta: number;
  69019. formuparam: number;
  69020. stepsize: number;
  69021. zoom: number;
  69022. tile: number;
  69023. brightness: number;
  69024. darkmatter: number;
  69025. distfading: number;
  69026. saturation: number;
  69027. /**
  69028. * Serializes this starfield procedural texture
  69029. * @returns a serialized starfield procedural texture object
  69030. */
  69031. serialize(): any;
  69032. /**
  69033. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  69034. * @param parsedTexture defines parsed texture data
  69035. * @param scene defines the current scene
  69036. * @param rootUrl defines the root URL containing startfield procedural texture information
  69037. * @returns a parsed Starfield Procedural BABYLON.Texture
  69038. */
  69039. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  69040. }
  69041. }
  69042. declare module BABYLON {
  69043. /** @hidden */
  69044. export var woodProceduralTexturePixelShader: {
  69045. name: string;
  69046. shader: string;
  69047. };
  69048. }
  69049. declare module BABYLON {
  69050. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  69051. private _ampScale;
  69052. private _woodColor;
  69053. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69054. updateShaderUniforms(): void;
  69055. ampScale: number;
  69056. woodColor: BABYLON.Color3;
  69057. /**
  69058. * Serializes this wood procedural texture
  69059. * @returns a serialized wood procedural texture object
  69060. */
  69061. serialize(): any;
  69062. /**
  69063. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  69064. * @param parsedTexture defines parsed texture data
  69065. * @param scene defines the current scene
  69066. * @param rootUrl defines the root URL containing wood procedural texture information
  69067. * @returns a parsed Wood Procedural BABYLON.Texture
  69068. */
  69069. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  69070. }
  69071. }