documentation.d.ts 2.9 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531
  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 Vecto3
  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. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5299. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5300. }
  5301. }
  5302. declare module BABYLON {
  5303. /** @hidden */
  5304. export interface ProcessingOptions {
  5305. defines: string[];
  5306. indexParameters: any;
  5307. isFragment: boolean;
  5308. shouldUseHighPrecisionShader: boolean;
  5309. supportsUniformBuffers: boolean;
  5310. shadersRepository: string;
  5311. includesShadersStore: {
  5312. [key: string]: string;
  5313. };
  5314. processor?: IShaderProcessor;
  5315. version: string;
  5316. }
  5317. }
  5318. declare module BABYLON {
  5319. /** @hidden */
  5320. export class ShaderCodeNode {
  5321. line: string;
  5322. children: ShaderCodeNode[];
  5323. additionalDefineKey?: string;
  5324. additionalDefineValue?: string;
  5325. isValid(preprocessors: {
  5326. [key: string]: string;
  5327. }): boolean;
  5328. process(preprocessors: {
  5329. [key: string]: string;
  5330. }, options: ProcessingOptions): string;
  5331. private _lineStartsWith;
  5332. }
  5333. }
  5334. declare module BABYLON {
  5335. /** @hidden */
  5336. export class ShaderCodeCursor {
  5337. private _lines;
  5338. lineIndex: number;
  5339. readonly currentLine: string;
  5340. readonly canRead: boolean;
  5341. lines: string[];
  5342. }
  5343. }
  5344. declare module BABYLON {
  5345. /** @hidden */
  5346. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5347. process(preprocessors: {
  5348. [key: string]: string;
  5349. }, options: ProcessingOptions): string;
  5350. }
  5351. }
  5352. declare module BABYLON {
  5353. /** @hidden */
  5354. export class ShaderDefineExpression {
  5355. isTrue(preprocessors: {
  5356. [key: string]: string;
  5357. }): boolean;
  5358. }
  5359. }
  5360. declare module BABYLON {
  5361. /** @hidden */
  5362. export class ShaderCodeTestNode extends ShaderCodeNode {
  5363. testExpression: ShaderDefineExpression;
  5364. isValid(preprocessors: {
  5365. [key: string]: string;
  5366. }): boolean;
  5367. }
  5368. }
  5369. declare module BABYLON {
  5370. /** @hidden */
  5371. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5372. define: string;
  5373. not: boolean;
  5374. constructor(define: string, not?: boolean);
  5375. isTrue(preprocessors: {
  5376. [key: string]: string;
  5377. }): boolean;
  5378. }
  5379. }
  5380. declare module BABYLON {
  5381. /** @hidden */
  5382. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5383. leftOperand: ShaderDefineExpression;
  5384. rightOperand: ShaderDefineExpression;
  5385. isTrue(preprocessors: {
  5386. [key: string]: string;
  5387. }): boolean;
  5388. }
  5389. }
  5390. declare module BABYLON {
  5391. /** @hidden */
  5392. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5393. leftOperand: ShaderDefineExpression;
  5394. rightOperand: ShaderDefineExpression;
  5395. isTrue(preprocessors: {
  5396. [key: string]: string;
  5397. }): boolean;
  5398. }
  5399. }
  5400. declare module BABYLON {
  5401. /** @hidden */
  5402. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5403. define: string;
  5404. operand: string;
  5405. testValue: string;
  5406. constructor(define: string, operand: string, testValue: string);
  5407. isTrue(preprocessors: {
  5408. [key: string]: string;
  5409. }): boolean;
  5410. }
  5411. }
  5412. declare module BABYLON {
  5413. /** @hidden */
  5414. export class ShaderProcessor {
  5415. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5416. private static _ProcessPrecision;
  5417. private static _ExtractOperation;
  5418. private static _BuildSubExpression;
  5419. private static _BuildExpression;
  5420. private static _MoveCursorWithinIf;
  5421. private static _MoveCursor;
  5422. private static _EvaluatePreProcessors;
  5423. private static _PreparePreProcessors;
  5424. private static _ProcessShaderConversion;
  5425. private static _ProcessIncludes;
  5426. }
  5427. }
  5428. declare module BABYLON {
  5429. /**
  5430. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5431. */
  5432. export class PerformanceMonitor {
  5433. private _enabled;
  5434. private _rollingFrameTime;
  5435. private _lastFrameTimeMs;
  5436. /**
  5437. * constructor
  5438. * @param frameSampleSize The number of samples required to saturate the sliding window
  5439. */
  5440. constructor(frameSampleSize?: number);
  5441. /**
  5442. * Samples current frame
  5443. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5444. */
  5445. sampleFrame(timeMs?: number): void;
  5446. /**
  5447. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5448. */
  5449. readonly averageFrameTime: number;
  5450. /**
  5451. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5452. */
  5453. readonly averageFrameTimeVariance: number;
  5454. /**
  5455. * Returns the frame time of the most recent frame
  5456. */
  5457. readonly instantaneousFrameTime: number;
  5458. /**
  5459. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5460. */
  5461. readonly averageFPS: number;
  5462. /**
  5463. * Returns the average framerate in frames per second using the most recent frame time
  5464. */
  5465. readonly instantaneousFPS: number;
  5466. /**
  5467. * Returns true if enough samples have been taken to completely fill the sliding window
  5468. */
  5469. readonly isSaturated: boolean;
  5470. /**
  5471. * Enables contributions to the sliding window sample set
  5472. */
  5473. enable(): void;
  5474. /**
  5475. * Disables contributions to the sliding window sample set
  5476. * Samples will not be interpolated over the disabled period
  5477. */
  5478. disable(): void;
  5479. /**
  5480. * Returns true if sampling is enabled
  5481. */
  5482. readonly isEnabled: boolean;
  5483. /**
  5484. * Resets performance monitor
  5485. */
  5486. reset(): void;
  5487. }
  5488. /**
  5489. * RollingAverage
  5490. *
  5491. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5492. */
  5493. export class RollingAverage {
  5494. /**
  5495. * Current average
  5496. */
  5497. average: number;
  5498. /**
  5499. * Current variance
  5500. */
  5501. variance: number;
  5502. protected _samples: Array<number>;
  5503. protected _sampleCount: number;
  5504. protected _pos: number;
  5505. protected _m2: number;
  5506. /**
  5507. * constructor
  5508. * @param length The number of samples required to saturate the sliding window
  5509. */
  5510. constructor(length: number);
  5511. /**
  5512. * Adds a sample to the sample set
  5513. * @param v The sample value
  5514. */
  5515. add(v: number): void;
  5516. /**
  5517. * Returns previously added values or null if outside of history or outside the sliding window domain
  5518. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5519. * @return Value previously recorded with add() or null if outside of range
  5520. */
  5521. history(i: number): number;
  5522. /**
  5523. * Returns true if enough samples have been taken to completely fill the sliding window
  5524. * @return true if sample-set saturated
  5525. */
  5526. isSaturated(): boolean;
  5527. /**
  5528. * Resets the rolling average (equivalent to 0 samples taken so far)
  5529. */
  5530. reset(): void;
  5531. /**
  5532. * Wraps a value around the sample range boundaries
  5533. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5534. * @return Wrapped position in sample range
  5535. */
  5536. protected _wrapPosition(i: number): number;
  5537. }
  5538. }
  5539. declare module BABYLON {
  5540. /**
  5541. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5542. * The underlying implementation relies on an associative array to ensure the best performances.
  5543. * The value can be anything including 'null' but except 'undefined'
  5544. */
  5545. export class StringDictionary<T> {
  5546. /**
  5547. * This will clear this dictionary and copy the content from the 'source' one.
  5548. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5549. * @param source the dictionary to take the content from and copy to this dictionary
  5550. */
  5551. copyFrom(source: StringDictionary<T>): void;
  5552. /**
  5553. * Get a value based from its key
  5554. * @param key the given key to get the matching value from
  5555. * @return the value if found, otherwise undefined is returned
  5556. */
  5557. get(key: string): T | undefined;
  5558. /**
  5559. * Get a value from its key or add it if it doesn't exist.
  5560. * This method will ensure you that a given key/data will be present in the dictionary.
  5561. * @param key the given key to get the matching value from
  5562. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5563. * The factory will only be invoked if there's no data for the given key.
  5564. * @return the value corresponding to the key.
  5565. */
  5566. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5567. /**
  5568. * Get a value from its key if present in the dictionary otherwise add it
  5569. * @param key the key to get the value from
  5570. * @param val if there's no such key/value pair in the dictionary add it with this value
  5571. * @return the value corresponding to the key
  5572. */
  5573. getOrAdd(key: string, val: T): T;
  5574. /**
  5575. * Check if there's a given key in the dictionary
  5576. * @param key the key to check for
  5577. * @return true if the key is present, false otherwise
  5578. */
  5579. contains(key: string): boolean;
  5580. /**
  5581. * Add a new key and its corresponding value
  5582. * @param key the key to add
  5583. * @param value the value corresponding to the key
  5584. * @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
  5585. */
  5586. add(key: string, value: T): boolean;
  5587. /**
  5588. * Update a specific value associated to a key
  5589. * @param key defines the key to use
  5590. * @param value defines the value to store
  5591. * @returns true if the value was updated (or false if the key was not found)
  5592. */
  5593. set(key: string, value: T): boolean;
  5594. /**
  5595. * Get the element of the given key and remove it from the dictionary
  5596. * @param key defines the key to search
  5597. * @returns the value associated with the key or null if not found
  5598. */
  5599. getAndRemove(key: string): Nullable<T>;
  5600. /**
  5601. * Remove a key/value from the dictionary.
  5602. * @param key the key to remove
  5603. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5604. */
  5605. remove(key: string): boolean;
  5606. /**
  5607. * Clear the whole content of the dictionary
  5608. */
  5609. clear(): void;
  5610. /**
  5611. * Gets the current count
  5612. */
  5613. readonly count: number;
  5614. /**
  5615. * Execute a callback on each key/val of the dictionary.
  5616. * Note that you can remove any element in this dictionary in the callback implementation
  5617. * @param callback the callback to execute on a given key/value pair
  5618. */
  5619. forEach(callback: (key: string, val: T) => void): void;
  5620. /**
  5621. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5622. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5623. * Note that you can remove any element in this dictionary in the callback implementation
  5624. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5625. * @returns the first item
  5626. */
  5627. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5628. private _count;
  5629. private _data;
  5630. }
  5631. }
  5632. declare module BABYLON {
  5633. /**
  5634. * Helper class that provides a small promise polyfill
  5635. */
  5636. export class PromisePolyfill {
  5637. /**
  5638. * Static function used to check if the polyfill is required
  5639. * If this is the case then the function will inject the polyfill to window.Promise
  5640. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5641. */
  5642. static Apply(force?: boolean): void;
  5643. }
  5644. }
  5645. declare module BABYLON {
  5646. /**
  5647. * Class used to store data that will be store in GPU memory
  5648. */
  5649. export class Buffer {
  5650. private _engine;
  5651. private _buffer;
  5652. /** @hidden */
  5653. _data: Nullable<DataArray>;
  5654. private _updatable;
  5655. private _instanced;
  5656. /**
  5657. * Gets the byte stride.
  5658. */
  5659. readonly byteStride: number;
  5660. /**
  5661. * Constructor
  5662. * @param engine the engine
  5663. * @param data the data to use for this buffer
  5664. * @param updatable whether the data is updatable
  5665. * @param stride the stride (optional)
  5666. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5667. * @param instanced whether the buffer is instanced (optional)
  5668. * @param useBytes set to true if the stride in in bytes (optional)
  5669. */
  5670. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5671. /**
  5672. * Create a new VertexBuffer based on the current buffer
  5673. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5674. * @param offset defines offset in the buffer (0 by default)
  5675. * @param size defines the size in floats of attributes (position is 3 for instance)
  5676. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5677. * @param instanced defines if the vertex buffer contains indexed data
  5678. * @param useBytes defines if the offset and stride are in bytes
  5679. * @returns the new vertex buffer
  5680. */
  5681. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5682. /**
  5683. * Gets a boolean indicating if the Buffer is updatable?
  5684. * @returns true if the buffer is updatable
  5685. */
  5686. isUpdatable(): boolean;
  5687. /**
  5688. * Gets current buffer's data
  5689. * @returns a DataArray or null
  5690. */
  5691. getData(): Nullable<DataArray>;
  5692. /**
  5693. * Gets underlying native buffer
  5694. * @returns underlying native buffer
  5695. */
  5696. getBuffer(): Nullable<DataBuffer>;
  5697. /**
  5698. * Gets the stride in float32 units (i.e. byte stride / 4).
  5699. * May not be an integer if the byte stride is not divisible by 4.
  5700. * DEPRECATED. Use byteStride instead.
  5701. * @returns the stride in float32 units
  5702. */
  5703. getStrideSize(): number;
  5704. /**
  5705. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5706. * @param data defines the data to store
  5707. */
  5708. create(data?: Nullable<DataArray>): void;
  5709. /** @hidden */
  5710. _rebuild(): void;
  5711. /**
  5712. * Update current buffer data
  5713. * @param data defines the data to store
  5714. */
  5715. update(data: DataArray): void;
  5716. /**
  5717. * Updates the data directly.
  5718. * @param data the new data
  5719. * @param offset the new offset
  5720. * @param vertexCount the vertex count (optional)
  5721. * @param useBytes set to true if the offset is in bytes
  5722. */
  5723. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5724. /**
  5725. * Release all resources
  5726. */
  5727. dispose(): void;
  5728. }
  5729. /**
  5730. * Specialized buffer used to store vertex data
  5731. */
  5732. export class VertexBuffer {
  5733. /** @hidden */
  5734. _buffer: Buffer;
  5735. private _kind;
  5736. private _size;
  5737. private _ownsBuffer;
  5738. private _instanced;
  5739. private _instanceDivisor;
  5740. /**
  5741. * The byte type.
  5742. */
  5743. static readonly BYTE: number;
  5744. /**
  5745. * The unsigned byte type.
  5746. */
  5747. static readonly UNSIGNED_BYTE: number;
  5748. /**
  5749. * The short type.
  5750. */
  5751. static readonly SHORT: number;
  5752. /**
  5753. * The unsigned short type.
  5754. */
  5755. static readonly UNSIGNED_SHORT: number;
  5756. /**
  5757. * The integer type.
  5758. */
  5759. static readonly INT: number;
  5760. /**
  5761. * The unsigned integer type.
  5762. */
  5763. static readonly UNSIGNED_INT: number;
  5764. /**
  5765. * The float type.
  5766. */
  5767. static readonly FLOAT: number;
  5768. /**
  5769. * Gets or sets the instance divisor when in instanced mode
  5770. */
  5771. instanceDivisor: number;
  5772. /**
  5773. * Gets the byte stride.
  5774. */
  5775. readonly byteStride: number;
  5776. /**
  5777. * Gets the byte offset.
  5778. */
  5779. readonly byteOffset: number;
  5780. /**
  5781. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5782. */
  5783. readonly normalized: boolean;
  5784. /**
  5785. * Gets the data type of each component in the array.
  5786. */
  5787. readonly type: number;
  5788. /**
  5789. * Constructor
  5790. * @param engine the engine
  5791. * @param data the data to use for this vertex buffer
  5792. * @param kind the vertex buffer kind
  5793. * @param updatable whether the data is updatable
  5794. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5795. * @param stride the stride (optional)
  5796. * @param instanced whether the buffer is instanced (optional)
  5797. * @param offset the offset of the data (optional)
  5798. * @param size the number of components (optional)
  5799. * @param type the type of the component (optional)
  5800. * @param normalized whether the data contains normalized data (optional)
  5801. * @param useBytes set to true if stride and offset are in bytes (optional)
  5802. */
  5803. 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);
  5804. /** @hidden */
  5805. _rebuild(): void;
  5806. /**
  5807. * Returns the kind of the VertexBuffer (string)
  5808. * @returns a string
  5809. */
  5810. getKind(): string;
  5811. /**
  5812. * Gets a boolean indicating if the VertexBuffer is updatable?
  5813. * @returns true if the buffer is updatable
  5814. */
  5815. isUpdatable(): boolean;
  5816. /**
  5817. * Gets current buffer's data
  5818. * @returns a DataArray or null
  5819. */
  5820. getData(): Nullable<DataArray>;
  5821. /**
  5822. * Gets underlying native buffer
  5823. * @returns underlying native buffer
  5824. */
  5825. getBuffer(): Nullable<DataBuffer>;
  5826. /**
  5827. * Gets the stride in float32 units (i.e. byte stride / 4).
  5828. * May not be an integer if the byte stride is not divisible by 4.
  5829. * DEPRECATED. Use byteStride instead.
  5830. * @returns the stride in float32 units
  5831. */
  5832. getStrideSize(): number;
  5833. /**
  5834. * Returns the offset as a multiple of the type byte length.
  5835. * DEPRECATED. Use byteOffset instead.
  5836. * @returns the offset in bytes
  5837. */
  5838. getOffset(): number;
  5839. /**
  5840. * Returns the number of components per vertex attribute (integer)
  5841. * @returns the size in float
  5842. */
  5843. getSize(): number;
  5844. /**
  5845. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5846. * @returns true if this buffer is instanced
  5847. */
  5848. getIsInstanced(): boolean;
  5849. /**
  5850. * Returns the instancing divisor, zero for non-instanced (integer).
  5851. * @returns a number
  5852. */
  5853. getInstanceDivisor(): number;
  5854. /**
  5855. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5856. * @param data defines the data to store
  5857. */
  5858. create(data?: DataArray): void;
  5859. /**
  5860. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5861. * This function will create a new buffer if the current one is not updatable
  5862. * @param data defines the data to store
  5863. */
  5864. update(data: DataArray): void;
  5865. /**
  5866. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5867. * Returns the directly updated WebGLBuffer.
  5868. * @param data the new data
  5869. * @param offset the new offset
  5870. * @param useBytes set to true if the offset is in bytes
  5871. */
  5872. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5873. /**
  5874. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5875. */
  5876. dispose(): void;
  5877. /**
  5878. * Enumerates each value of this vertex buffer as numbers.
  5879. * @param count the number of values to enumerate
  5880. * @param callback the callback function called for each value
  5881. */
  5882. forEach(count: number, callback: (value: number, index: number) => void): void;
  5883. /**
  5884. * Positions
  5885. */
  5886. static readonly PositionKind: string;
  5887. /**
  5888. * Normals
  5889. */
  5890. static readonly NormalKind: string;
  5891. /**
  5892. * Tangents
  5893. */
  5894. static readonly TangentKind: string;
  5895. /**
  5896. * Texture coordinates
  5897. */
  5898. static readonly UVKind: string;
  5899. /**
  5900. * Texture coordinates 2
  5901. */
  5902. static readonly UV2Kind: string;
  5903. /**
  5904. * Texture coordinates 3
  5905. */
  5906. static readonly UV3Kind: string;
  5907. /**
  5908. * Texture coordinates 4
  5909. */
  5910. static readonly UV4Kind: string;
  5911. /**
  5912. * Texture coordinates 5
  5913. */
  5914. static readonly UV5Kind: string;
  5915. /**
  5916. * Texture coordinates 6
  5917. */
  5918. static readonly UV6Kind: string;
  5919. /**
  5920. * Colors
  5921. */
  5922. static readonly ColorKind: string;
  5923. /**
  5924. * Matrix indices (for bones)
  5925. */
  5926. static readonly MatricesIndicesKind: string;
  5927. /**
  5928. * Matrix weights (for bones)
  5929. */
  5930. static readonly MatricesWeightsKind: string;
  5931. /**
  5932. * Additional matrix indices (for bones)
  5933. */
  5934. static readonly MatricesIndicesExtraKind: string;
  5935. /**
  5936. * Additional matrix weights (for bones)
  5937. */
  5938. static readonly MatricesWeightsExtraKind: string;
  5939. /**
  5940. * Deduces the stride given a kind.
  5941. * @param kind The kind string to deduce
  5942. * @returns The deduced stride
  5943. */
  5944. static DeduceStride(kind: string): number;
  5945. /**
  5946. * Gets the byte length of the given type.
  5947. * @param type the type
  5948. * @returns the number of bytes
  5949. */
  5950. static GetTypeByteLength(type: number): number;
  5951. /**
  5952. * Enumerates each value of the given parameters as numbers.
  5953. * @param data the data to enumerate
  5954. * @param byteOffset the byte offset of the data
  5955. * @param byteStride the byte stride of the data
  5956. * @param componentCount the number of components per element
  5957. * @param componentType the type of the component
  5958. * @param count the total number of components
  5959. * @param normalized whether the data is normalized
  5960. * @param callback the callback function called for each value
  5961. */
  5962. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5963. private static _GetFloatValue;
  5964. }
  5965. }
  5966. declare module BABYLON {
  5967. /**
  5968. * Class representing spherical harmonics coefficients to the 3rd degree
  5969. */
  5970. export class SphericalHarmonics {
  5971. /**
  5972. * Defines whether or not the harmonics have been prescaled for rendering.
  5973. */
  5974. preScaled: boolean;
  5975. /**
  5976. * The l0,0 coefficients of the spherical harmonics
  5977. */
  5978. l00: Vector3;
  5979. /**
  5980. * The l1,-1 coefficients of the spherical harmonics
  5981. */
  5982. l1_1: Vector3;
  5983. /**
  5984. * The l1,0 coefficients of the spherical harmonics
  5985. */
  5986. l10: Vector3;
  5987. /**
  5988. * The l1,1 coefficients of the spherical harmonics
  5989. */
  5990. l11: Vector3;
  5991. /**
  5992. * The l2,-2 coefficients of the spherical harmonics
  5993. */
  5994. l2_2: Vector3;
  5995. /**
  5996. * The l2,-1 coefficients of the spherical harmonics
  5997. */
  5998. l2_1: Vector3;
  5999. /**
  6000. * The l2,0 coefficients of the spherical harmonics
  6001. */
  6002. l20: Vector3;
  6003. /**
  6004. * The l2,1 coefficients of the spherical harmonics
  6005. */
  6006. l21: Vector3;
  6007. /**
  6008. * The l2,2 coefficients of the spherical harmonics
  6009. */
  6010. l22: Vector3;
  6011. /**
  6012. * Adds a light to the spherical harmonics
  6013. * @param direction the direction of the light
  6014. * @param color the color of the light
  6015. * @param deltaSolidAngle the delta solid angle of the light
  6016. */
  6017. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6018. /**
  6019. * Scales the spherical harmonics by the given amount
  6020. * @param scale the amount to scale
  6021. */
  6022. scaleInPlace(scale: number): void;
  6023. /**
  6024. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6025. *
  6026. * ```
  6027. * E_lm = A_l * L_lm
  6028. * ```
  6029. *
  6030. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6031. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6032. * the scaling factors are given in equation 9.
  6033. */
  6034. convertIncidentRadianceToIrradiance(): void;
  6035. /**
  6036. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6037. *
  6038. * ```
  6039. * L = (1/pi) * E * rho
  6040. * ```
  6041. *
  6042. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6043. */
  6044. convertIrradianceToLambertianRadiance(): void;
  6045. /**
  6046. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6047. * required operations at run time.
  6048. *
  6049. * This is simply done by scaling back the SH with Ylm constants parameter.
  6050. * The trigonometric part being applied by the shader at run time.
  6051. */
  6052. preScaleForRendering(): void;
  6053. /**
  6054. * Constructs a spherical harmonics from an array.
  6055. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6056. * @returns the spherical harmonics
  6057. */
  6058. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6059. /**
  6060. * Gets the spherical harmonics from polynomial
  6061. * @param polynomial the spherical polynomial
  6062. * @returns the spherical harmonics
  6063. */
  6064. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6065. }
  6066. /**
  6067. * Class representing spherical polynomial coefficients to the 3rd degree
  6068. */
  6069. export class SphericalPolynomial {
  6070. private _harmonics;
  6071. /**
  6072. * The spherical harmonics used to create the polynomials.
  6073. */
  6074. readonly preScaledHarmonics: SphericalHarmonics;
  6075. /**
  6076. * The x coefficients of the spherical polynomial
  6077. */
  6078. x: Vector3;
  6079. /**
  6080. * The y coefficients of the spherical polynomial
  6081. */
  6082. y: Vector3;
  6083. /**
  6084. * The z coefficients of the spherical polynomial
  6085. */
  6086. z: Vector3;
  6087. /**
  6088. * The xx coefficients of the spherical polynomial
  6089. */
  6090. xx: Vector3;
  6091. /**
  6092. * The yy coefficients of the spherical polynomial
  6093. */
  6094. yy: Vector3;
  6095. /**
  6096. * The zz coefficients of the spherical polynomial
  6097. */
  6098. zz: Vector3;
  6099. /**
  6100. * The xy coefficients of the spherical polynomial
  6101. */
  6102. xy: Vector3;
  6103. /**
  6104. * The yz coefficients of the spherical polynomial
  6105. */
  6106. yz: Vector3;
  6107. /**
  6108. * The zx coefficients of the spherical polynomial
  6109. */
  6110. zx: Vector3;
  6111. /**
  6112. * Adds an ambient color to the spherical polynomial
  6113. * @param color the color to add
  6114. */
  6115. addAmbient(color: Color3): void;
  6116. /**
  6117. * Scales the spherical polynomial by the given amount
  6118. * @param scale the amount to scale
  6119. */
  6120. scaleInPlace(scale: number): void;
  6121. /**
  6122. * Gets the spherical polynomial from harmonics
  6123. * @param harmonics the spherical harmonics
  6124. * @returns the spherical polynomial
  6125. */
  6126. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6127. /**
  6128. * Constructs a spherical polynomial from an array.
  6129. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6130. * @returns the spherical polynomial
  6131. */
  6132. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6133. }
  6134. }
  6135. declare module BABYLON {
  6136. /**
  6137. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6138. */
  6139. export interface CubeMapInfo {
  6140. /**
  6141. * The pixel array for the front face.
  6142. * This is stored in format, left to right, up to down format.
  6143. */
  6144. front: Nullable<ArrayBufferView>;
  6145. /**
  6146. * The pixel array for the back face.
  6147. * This is stored in format, left to right, up to down format.
  6148. */
  6149. back: Nullable<ArrayBufferView>;
  6150. /**
  6151. * The pixel array for the left face.
  6152. * This is stored in format, left to right, up to down format.
  6153. */
  6154. left: Nullable<ArrayBufferView>;
  6155. /**
  6156. * The pixel array for the right face.
  6157. * This is stored in format, left to right, up to down format.
  6158. */
  6159. right: Nullable<ArrayBufferView>;
  6160. /**
  6161. * The pixel array for the up face.
  6162. * This is stored in format, left to right, up to down format.
  6163. */
  6164. up: Nullable<ArrayBufferView>;
  6165. /**
  6166. * The pixel array for the down face.
  6167. * This is stored in format, left to right, up to down format.
  6168. */
  6169. down: Nullable<ArrayBufferView>;
  6170. /**
  6171. * The size of the cubemap stored.
  6172. *
  6173. * Each faces will be size * size pixels.
  6174. */
  6175. size: number;
  6176. /**
  6177. * The format of the texture.
  6178. *
  6179. * RGBA, RGB.
  6180. */
  6181. format: number;
  6182. /**
  6183. * The type of the texture data.
  6184. *
  6185. * UNSIGNED_INT, FLOAT.
  6186. */
  6187. type: number;
  6188. /**
  6189. * Specifies whether the texture is in gamma space.
  6190. */
  6191. gammaSpace: boolean;
  6192. }
  6193. /**
  6194. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6195. */
  6196. export class PanoramaToCubeMapTools {
  6197. private static FACE_FRONT;
  6198. private static FACE_BACK;
  6199. private static FACE_RIGHT;
  6200. private static FACE_LEFT;
  6201. private static FACE_DOWN;
  6202. private static FACE_UP;
  6203. /**
  6204. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6205. *
  6206. * @param float32Array The source data.
  6207. * @param inputWidth The width of the input panorama.
  6208. * @param inputHeight The height of the input panorama.
  6209. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6210. * @return The cubemap data
  6211. */
  6212. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6213. private static CreateCubemapTexture;
  6214. private static CalcProjectionSpherical;
  6215. }
  6216. }
  6217. declare module BABYLON {
  6218. /**
  6219. * Helper class dealing with the extraction of spherical polynomial dataArray
  6220. * from a cube map.
  6221. */
  6222. export class CubeMapToSphericalPolynomialTools {
  6223. private static FileFaces;
  6224. /**
  6225. * Converts a texture to the according Spherical Polynomial data.
  6226. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6227. *
  6228. * @param texture The texture to extract the information from.
  6229. * @return The Spherical Polynomial data.
  6230. */
  6231. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6232. /**
  6233. * Converts a cubemap to the according Spherical Polynomial data.
  6234. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6235. *
  6236. * @param cubeInfo The Cube map to extract the information from.
  6237. * @return The Spherical Polynomial data.
  6238. */
  6239. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6240. }
  6241. }
  6242. declare module BABYLON {
  6243. /**
  6244. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6245. * during the life time of the application.
  6246. */
  6247. export class EngineStore {
  6248. /** Gets the list of created engines */
  6249. static Instances: Engine[];
  6250. /** @hidden */
  6251. static _LastCreatedScene: Nullable<Scene>;
  6252. /**
  6253. * Gets the latest created engine
  6254. */
  6255. static readonly LastCreatedEngine: Nullable<Engine>;
  6256. /**
  6257. * Gets the latest created scene
  6258. */
  6259. static readonly LastCreatedScene: Nullable<Scene>;
  6260. }
  6261. }
  6262. declare module BABYLON {
  6263. /**
  6264. * Define options used to create a render target texture
  6265. */
  6266. export class RenderTargetCreationOptions {
  6267. /**
  6268. * Specifies is mipmaps must be generated
  6269. */
  6270. generateMipMaps?: boolean;
  6271. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6272. generateDepthBuffer?: boolean;
  6273. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6274. generateStencilBuffer?: boolean;
  6275. /** Defines texture type (int by default) */
  6276. type?: number;
  6277. /** Defines sampling mode (trilinear by default) */
  6278. samplingMode?: number;
  6279. /** Defines format (RGBA by default) */
  6280. format?: number;
  6281. }
  6282. }
  6283. declare module BABYLON {
  6284. /**
  6285. * @hidden
  6286. **/
  6287. export class _AlphaState {
  6288. private _isAlphaBlendDirty;
  6289. private _isBlendFunctionParametersDirty;
  6290. private _isBlendEquationParametersDirty;
  6291. private _isBlendConstantsDirty;
  6292. private _alphaBlend;
  6293. private _blendFunctionParameters;
  6294. private _blendEquationParameters;
  6295. private _blendConstants;
  6296. /**
  6297. * Initializes the state.
  6298. */
  6299. constructor();
  6300. readonly isDirty: boolean;
  6301. alphaBlend: boolean;
  6302. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6303. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6304. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6305. reset(): void;
  6306. apply(gl: WebGLRenderingContext): void;
  6307. }
  6308. }
  6309. declare module BABYLON {
  6310. /**
  6311. * @hidden
  6312. **/
  6313. export class _DepthCullingState {
  6314. private _isDepthTestDirty;
  6315. private _isDepthMaskDirty;
  6316. private _isDepthFuncDirty;
  6317. private _isCullFaceDirty;
  6318. private _isCullDirty;
  6319. private _isZOffsetDirty;
  6320. private _isFrontFaceDirty;
  6321. private _depthTest;
  6322. private _depthMask;
  6323. private _depthFunc;
  6324. private _cull;
  6325. private _cullFace;
  6326. private _zOffset;
  6327. private _frontFace;
  6328. /**
  6329. * Initializes the state.
  6330. */
  6331. constructor();
  6332. readonly isDirty: boolean;
  6333. zOffset: number;
  6334. cullFace: Nullable<number>;
  6335. cull: Nullable<boolean>;
  6336. depthFunc: Nullable<number>;
  6337. depthMask: boolean;
  6338. depthTest: boolean;
  6339. frontFace: Nullable<number>;
  6340. reset(): void;
  6341. apply(gl: WebGLRenderingContext): void;
  6342. }
  6343. }
  6344. declare module BABYLON {
  6345. /**
  6346. * @hidden
  6347. **/
  6348. export class _StencilState {
  6349. /** 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 */
  6350. static readonly ALWAYS: number;
  6351. /** Passed to stencilOperation to specify that stencil value must be kept */
  6352. static readonly KEEP: number;
  6353. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6354. static readonly REPLACE: number;
  6355. private _isStencilTestDirty;
  6356. private _isStencilMaskDirty;
  6357. private _isStencilFuncDirty;
  6358. private _isStencilOpDirty;
  6359. private _stencilTest;
  6360. private _stencilMask;
  6361. private _stencilFunc;
  6362. private _stencilFuncRef;
  6363. private _stencilFuncMask;
  6364. private _stencilOpStencilFail;
  6365. private _stencilOpDepthFail;
  6366. private _stencilOpStencilDepthPass;
  6367. readonly isDirty: boolean;
  6368. stencilFunc: number;
  6369. stencilFuncRef: number;
  6370. stencilFuncMask: number;
  6371. stencilOpStencilFail: number;
  6372. stencilOpDepthFail: number;
  6373. stencilOpStencilDepthPass: number;
  6374. stencilMask: number;
  6375. stencilTest: boolean;
  6376. constructor();
  6377. reset(): void;
  6378. apply(gl: WebGLRenderingContext): void;
  6379. }
  6380. }
  6381. declare module BABYLON {
  6382. /**
  6383. * @hidden
  6384. **/
  6385. export class _TimeToken {
  6386. _startTimeQuery: Nullable<WebGLQuery>;
  6387. _endTimeQuery: Nullable<WebGLQuery>;
  6388. _timeElapsedQuery: Nullable<WebGLQuery>;
  6389. _timeElapsedQueryEnded: boolean;
  6390. }
  6391. }
  6392. declare module BABYLON {
  6393. /**
  6394. * Class used to store data associated with WebGL texture data for the engine
  6395. * This class should not be used directly
  6396. */
  6397. export class InternalTexture {
  6398. /** @hidden */
  6399. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6400. /**
  6401. * The source of the texture data is unknown
  6402. */
  6403. static DATASOURCE_UNKNOWN: number;
  6404. /**
  6405. * Texture data comes from an URL
  6406. */
  6407. static DATASOURCE_URL: number;
  6408. /**
  6409. * Texture data is only used for temporary storage
  6410. */
  6411. static DATASOURCE_TEMP: number;
  6412. /**
  6413. * Texture data comes from raw data (ArrayBuffer)
  6414. */
  6415. static DATASOURCE_RAW: number;
  6416. /**
  6417. * Texture content is dynamic (video or dynamic texture)
  6418. */
  6419. static DATASOURCE_DYNAMIC: number;
  6420. /**
  6421. * Texture content is generated by rendering to it
  6422. */
  6423. static DATASOURCE_RENDERTARGET: number;
  6424. /**
  6425. * Texture content is part of a multi render target process
  6426. */
  6427. static DATASOURCE_MULTIRENDERTARGET: number;
  6428. /**
  6429. * Texture data comes from a cube data file
  6430. */
  6431. static DATASOURCE_CUBE: number;
  6432. /**
  6433. * Texture data comes from a raw cube data
  6434. */
  6435. static DATASOURCE_CUBERAW: number;
  6436. /**
  6437. * Texture data come from a prefiltered cube data file
  6438. */
  6439. static DATASOURCE_CUBEPREFILTERED: number;
  6440. /**
  6441. * Texture content is raw 3D data
  6442. */
  6443. static DATASOURCE_RAW3D: number;
  6444. /**
  6445. * Texture content is a depth texture
  6446. */
  6447. static DATASOURCE_DEPTHTEXTURE: number;
  6448. /**
  6449. * Texture data comes from a raw cube data encoded with RGBD
  6450. */
  6451. static DATASOURCE_CUBERAW_RGBD: number;
  6452. /**
  6453. * Defines if the texture is ready
  6454. */
  6455. isReady: boolean;
  6456. /**
  6457. * Defines if the texture is a cube texture
  6458. */
  6459. isCube: boolean;
  6460. /**
  6461. * Defines if the texture contains 3D data
  6462. */
  6463. is3D: boolean;
  6464. /**
  6465. * Defines if the texture contains multiview data
  6466. */
  6467. isMultiview: boolean;
  6468. /**
  6469. * Gets the URL used to load this texture
  6470. */
  6471. url: string;
  6472. /**
  6473. * Gets the sampling mode of the texture
  6474. */
  6475. samplingMode: number;
  6476. /**
  6477. * Gets a boolean indicating if the texture needs mipmaps generation
  6478. */
  6479. generateMipMaps: boolean;
  6480. /**
  6481. * Gets the number of samples used by the texture (WebGL2+ only)
  6482. */
  6483. samples: number;
  6484. /**
  6485. * Gets the type of the texture (int, float...)
  6486. */
  6487. type: number;
  6488. /**
  6489. * Gets the format of the texture (RGB, RGBA...)
  6490. */
  6491. format: number;
  6492. /**
  6493. * Observable called when the texture is loaded
  6494. */
  6495. onLoadedObservable: Observable<InternalTexture>;
  6496. /**
  6497. * Gets the width of the texture
  6498. */
  6499. width: number;
  6500. /**
  6501. * Gets the height of the texture
  6502. */
  6503. height: number;
  6504. /**
  6505. * Gets the depth of the texture
  6506. */
  6507. depth: number;
  6508. /**
  6509. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6510. */
  6511. baseWidth: number;
  6512. /**
  6513. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6514. */
  6515. baseHeight: number;
  6516. /**
  6517. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6518. */
  6519. baseDepth: number;
  6520. /**
  6521. * Gets a boolean indicating if the texture is inverted on Y axis
  6522. */
  6523. invertY: boolean;
  6524. /** @hidden */
  6525. _invertVScale: boolean;
  6526. /** @hidden */
  6527. _associatedChannel: number;
  6528. /** @hidden */
  6529. _dataSource: number;
  6530. /** @hidden */
  6531. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6532. /** @hidden */
  6533. _bufferView: Nullable<ArrayBufferView>;
  6534. /** @hidden */
  6535. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6536. /** @hidden */
  6537. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6538. /** @hidden */
  6539. _size: number;
  6540. /** @hidden */
  6541. _extension: string;
  6542. /** @hidden */
  6543. _files: Nullable<string[]>;
  6544. /** @hidden */
  6545. _workingCanvas: Nullable<HTMLCanvasElement>;
  6546. /** @hidden */
  6547. _workingContext: Nullable<CanvasRenderingContext2D>;
  6548. /** @hidden */
  6549. _framebuffer: Nullable<WebGLFramebuffer>;
  6550. /** @hidden */
  6551. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6552. /** @hidden */
  6553. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6554. /** @hidden */
  6555. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6556. /** @hidden */
  6557. _attachments: Nullable<number[]>;
  6558. /** @hidden */
  6559. _cachedCoordinatesMode: Nullable<number>;
  6560. /** @hidden */
  6561. _cachedWrapU: Nullable<number>;
  6562. /** @hidden */
  6563. _cachedWrapV: Nullable<number>;
  6564. /** @hidden */
  6565. _cachedWrapR: Nullable<number>;
  6566. /** @hidden */
  6567. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6568. /** @hidden */
  6569. _isDisabled: boolean;
  6570. /** @hidden */
  6571. _compression: Nullable<string>;
  6572. /** @hidden */
  6573. _generateStencilBuffer: boolean;
  6574. /** @hidden */
  6575. _generateDepthBuffer: boolean;
  6576. /** @hidden */
  6577. _comparisonFunction: number;
  6578. /** @hidden */
  6579. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6580. /** @hidden */
  6581. _lodGenerationScale: number;
  6582. /** @hidden */
  6583. _lodGenerationOffset: number;
  6584. /** @hidden */
  6585. _colorTextureArray: Nullable<WebGLTexture>;
  6586. /** @hidden */
  6587. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6588. /** @hidden */
  6589. _lodTextureHigh: Nullable<BaseTexture>;
  6590. /** @hidden */
  6591. _lodTextureMid: Nullable<BaseTexture>;
  6592. /** @hidden */
  6593. _lodTextureLow: Nullable<BaseTexture>;
  6594. /** @hidden */
  6595. _isRGBD: boolean;
  6596. /** @hidden */
  6597. _linearSpecularLOD: boolean;
  6598. /** @hidden */
  6599. _irradianceTexture: Nullable<BaseTexture>;
  6600. /** @hidden */
  6601. _webGLTexture: Nullable<WebGLTexture>;
  6602. /** @hidden */
  6603. _references: number;
  6604. private _engine;
  6605. /**
  6606. * Gets the Engine the texture belongs to.
  6607. * @returns The babylon engine
  6608. */
  6609. getEngine(): Engine;
  6610. /**
  6611. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6612. */
  6613. readonly dataSource: number;
  6614. /**
  6615. * Creates a new InternalTexture
  6616. * @param engine defines the engine to use
  6617. * @param dataSource defines the type of data that will be used
  6618. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6619. */
  6620. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6621. /**
  6622. * Increments the number of references (ie. the number of Texture that point to it)
  6623. */
  6624. incrementReferences(): void;
  6625. /**
  6626. * Change the size of the texture (not the size of the content)
  6627. * @param width defines the new width
  6628. * @param height defines the new height
  6629. * @param depth defines the new depth (1 by default)
  6630. */
  6631. updateSize(width: int, height: int, depth?: int): void;
  6632. /** @hidden */
  6633. _rebuild(): void;
  6634. /** @hidden */
  6635. _swapAndDie(target: InternalTexture): void;
  6636. /**
  6637. * Dispose the current allocated resources
  6638. */
  6639. dispose(): void;
  6640. }
  6641. }
  6642. declare module BABYLON {
  6643. /**
  6644. * This represents the main contract an easing function should follow.
  6645. * Easing functions are used throughout the animation system.
  6646. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6647. */
  6648. export interface IEasingFunction {
  6649. /**
  6650. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6651. * of the easing function.
  6652. * The link below provides some of the most common examples of easing functions.
  6653. * @see https://easings.net/
  6654. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6655. * @returns the corresponding value on the curve defined by the easing function
  6656. */
  6657. ease(gradient: number): number;
  6658. }
  6659. /**
  6660. * Base class used for every default easing function.
  6661. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6662. */
  6663. export class EasingFunction implements IEasingFunction {
  6664. /**
  6665. * Interpolation follows the mathematical formula associated with the easing function.
  6666. */
  6667. static readonly EASINGMODE_EASEIN: number;
  6668. /**
  6669. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6670. */
  6671. static readonly EASINGMODE_EASEOUT: number;
  6672. /**
  6673. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6674. */
  6675. static readonly EASINGMODE_EASEINOUT: number;
  6676. private _easingMode;
  6677. /**
  6678. * Sets the easing mode of the current function.
  6679. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6680. */
  6681. setEasingMode(easingMode: number): void;
  6682. /**
  6683. * Gets the current easing mode.
  6684. * @returns the easing mode
  6685. */
  6686. getEasingMode(): number;
  6687. /**
  6688. * @hidden
  6689. */
  6690. easeInCore(gradient: number): number;
  6691. /**
  6692. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6693. * of the easing function.
  6694. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6695. * @returns the corresponding value on the curve defined by the easing function
  6696. */
  6697. ease(gradient: number): number;
  6698. }
  6699. /**
  6700. * Easing function with a circle shape (see link below).
  6701. * @see https://easings.net/#easeInCirc
  6702. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6703. */
  6704. export class CircleEase extends EasingFunction implements IEasingFunction {
  6705. /** @hidden */
  6706. easeInCore(gradient: number): number;
  6707. }
  6708. /**
  6709. * Easing function with a ease back shape (see link below).
  6710. * @see https://easings.net/#easeInBack
  6711. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6712. */
  6713. export class BackEase extends EasingFunction implements IEasingFunction {
  6714. /** Defines the amplitude of the function */
  6715. amplitude: number;
  6716. /**
  6717. * Instantiates a back ease easing
  6718. * @see https://easings.net/#easeInBack
  6719. * @param amplitude Defines the amplitude of the function
  6720. */
  6721. constructor(
  6722. /** Defines the amplitude of the function */
  6723. amplitude?: number);
  6724. /** @hidden */
  6725. easeInCore(gradient: number): number;
  6726. }
  6727. /**
  6728. * Easing function with a bouncing shape (see link below).
  6729. * @see https://easings.net/#easeInBounce
  6730. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6731. */
  6732. export class BounceEase extends EasingFunction implements IEasingFunction {
  6733. /** Defines the number of bounces */
  6734. bounces: number;
  6735. /** Defines the amplitude of the bounce */
  6736. bounciness: number;
  6737. /**
  6738. * Instantiates a bounce easing
  6739. * @see https://easings.net/#easeInBounce
  6740. * @param bounces Defines the number of bounces
  6741. * @param bounciness Defines the amplitude of the bounce
  6742. */
  6743. constructor(
  6744. /** Defines the number of bounces */
  6745. bounces?: number,
  6746. /** Defines the amplitude of the bounce */
  6747. bounciness?: number);
  6748. /** @hidden */
  6749. easeInCore(gradient: number): number;
  6750. }
  6751. /**
  6752. * Easing function with a power of 3 shape (see link below).
  6753. * @see https://easings.net/#easeInCubic
  6754. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6755. */
  6756. export class CubicEase extends EasingFunction implements IEasingFunction {
  6757. /** @hidden */
  6758. easeInCore(gradient: number): number;
  6759. }
  6760. /**
  6761. * Easing function with an elastic shape (see link below).
  6762. * @see https://easings.net/#easeInElastic
  6763. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6764. */
  6765. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6766. /** Defines the number of oscillations*/
  6767. oscillations: number;
  6768. /** Defines the amplitude of the oscillations*/
  6769. springiness: number;
  6770. /**
  6771. * Instantiates an elastic easing function
  6772. * @see https://easings.net/#easeInElastic
  6773. * @param oscillations Defines the number of oscillations
  6774. * @param springiness Defines the amplitude of the oscillations
  6775. */
  6776. constructor(
  6777. /** Defines the number of oscillations*/
  6778. oscillations?: number,
  6779. /** Defines the amplitude of the oscillations*/
  6780. springiness?: number);
  6781. /** @hidden */
  6782. easeInCore(gradient: number): number;
  6783. }
  6784. /**
  6785. * Easing function with an exponential shape (see link below).
  6786. * @see https://easings.net/#easeInExpo
  6787. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6788. */
  6789. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6790. /** Defines the exponent of the function */
  6791. exponent: number;
  6792. /**
  6793. * Instantiates an exponential easing function
  6794. * @see https://easings.net/#easeInExpo
  6795. * @param exponent Defines the exponent of the function
  6796. */
  6797. constructor(
  6798. /** Defines the exponent of the function */
  6799. exponent?: number);
  6800. /** @hidden */
  6801. easeInCore(gradient: number): number;
  6802. }
  6803. /**
  6804. * Easing function with a power shape (see link below).
  6805. * @see https://easings.net/#easeInQuad
  6806. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6807. */
  6808. export class PowerEase extends EasingFunction implements IEasingFunction {
  6809. /** Defines the power of the function */
  6810. power: number;
  6811. /**
  6812. * Instantiates an power base easing function
  6813. * @see https://easings.net/#easeInQuad
  6814. * @param power Defines the power of the function
  6815. */
  6816. constructor(
  6817. /** Defines the power of the function */
  6818. power?: number);
  6819. /** @hidden */
  6820. easeInCore(gradient: number): number;
  6821. }
  6822. /**
  6823. * Easing function with a power of 2 shape (see link below).
  6824. * @see https://easings.net/#easeInQuad
  6825. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6826. */
  6827. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6828. /** @hidden */
  6829. easeInCore(gradient: number): number;
  6830. }
  6831. /**
  6832. * Easing function with a power of 4 shape (see link below).
  6833. * @see https://easings.net/#easeInQuart
  6834. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6835. */
  6836. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6837. /** @hidden */
  6838. easeInCore(gradient: number): number;
  6839. }
  6840. /**
  6841. * Easing function with a power of 5 shape (see link below).
  6842. * @see https://easings.net/#easeInQuint
  6843. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6844. */
  6845. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6846. /** @hidden */
  6847. easeInCore(gradient: number): number;
  6848. }
  6849. /**
  6850. * Easing function with a sin shape (see link below).
  6851. * @see https://easings.net/#easeInSine
  6852. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6853. */
  6854. export class SineEase extends EasingFunction implements IEasingFunction {
  6855. /** @hidden */
  6856. easeInCore(gradient: number): number;
  6857. }
  6858. /**
  6859. * Easing function with a bezier shape (see link below).
  6860. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6861. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6862. */
  6863. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6864. /** Defines the x component of the start tangent in the bezier curve */
  6865. x1: number;
  6866. /** Defines the y component of the start tangent in the bezier curve */
  6867. y1: number;
  6868. /** Defines the x component of the end tangent in the bezier curve */
  6869. x2: number;
  6870. /** Defines the y component of the end tangent in the bezier curve */
  6871. y2: number;
  6872. /**
  6873. * Instantiates a bezier function
  6874. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6875. * @param x1 Defines the x component of the start tangent in the bezier curve
  6876. * @param y1 Defines the y component of the start tangent in the bezier curve
  6877. * @param x2 Defines the x component of the end tangent in the bezier curve
  6878. * @param y2 Defines the y component of the end tangent in the bezier curve
  6879. */
  6880. constructor(
  6881. /** Defines the x component of the start tangent in the bezier curve */
  6882. x1?: number,
  6883. /** Defines the y component of the start tangent in the bezier curve */
  6884. y1?: number,
  6885. /** Defines the x component of the end tangent in the bezier curve */
  6886. x2?: number,
  6887. /** Defines the y component of the end tangent in the bezier curve */
  6888. y2?: number);
  6889. /** @hidden */
  6890. easeInCore(gradient: number): number;
  6891. }
  6892. }
  6893. declare module BABYLON {
  6894. /**
  6895. * Defines an interface which represents an animation key frame
  6896. */
  6897. export interface IAnimationKey {
  6898. /**
  6899. * Frame of the key frame
  6900. */
  6901. frame: number;
  6902. /**
  6903. * Value at the specifies key frame
  6904. */
  6905. value: any;
  6906. /**
  6907. * The input tangent for the cubic hermite spline
  6908. */
  6909. inTangent?: any;
  6910. /**
  6911. * The output tangent for the cubic hermite spline
  6912. */
  6913. outTangent?: any;
  6914. /**
  6915. * The animation interpolation type
  6916. */
  6917. interpolation?: AnimationKeyInterpolation;
  6918. }
  6919. /**
  6920. * Enum for the animation key frame interpolation type
  6921. */
  6922. export enum AnimationKeyInterpolation {
  6923. /**
  6924. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6925. */
  6926. STEP = 1
  6927. }
  6928. }
  6929. declare module BABYLON {
  6930. /**
  6931. * Represents the range of an animation
  6932. */
  6933. export class AnimationRange {
  6934. /**The name of the animation range**/
  6935. name: string;
  6936. /**The starting frame of the animation */
  6937. from: number;
  6938. /**The ending frame of the animation*/
  6939. to: number;
  6940. /**
  6941. * Initializes the range of an animation
  6942. * @param name The name of the animation range
  6943. * @param from The starting frame of the animation
  6944. * @param to The ending frame of the animation
  6945. */
  6946. constructor(
  6947. /**The name of the animation range**/
  6948. name: string,
  6949. /**The starting frame of the animation */
  6950. from: number,
  6951. /**The ending frame of the animation*/
  6952. to: number);
  6953. /**
  6954. * Makes a copy of the animation range
  6955. * @returns A copy of the animation range
  6956. */
  6957. clone(): AnimationRange;
  6958. }
  6959. }
  6960. declare module BABYLON {
  6961. /**
  6962. * Composed of a frame, and an action function
  6963. */
  6964. export class AnimationEvent {
  6965. /** The frame for which the event is triggered **/
  6966. frame: number;
  6967. /** The event to perform when triggered **/
  6968. action: (currentFrame: number) => void;
  6969. /** Specifies if the event should be triggered only once**/
  6970. onlyOnce?: boolean | undefined;
  6971. /**
  6972. * Specifies if the animation event is done
  6973. */
  6974. isDone: boolean;
  6975. /**
  6976. * Initializes the animation event
  6977. * @param frame The frame for which the event is triggered
  6978. * @param action The event to perform when triggered
  6979. * @param onlyOnce Specifies if the event should be triggered only once
  6980. */
  6981. constructor(
  6982. /** The frame for which the event is triggered **/
  6983. frame: number,
  6984. /** The event to perform when triggered **/
  6985. action: (currentFrame: number) => void,
  6986. /** Specifies if the event should be triggered only once**/
  6987. onlyOnce?: boolean | undefined);
  6988. /** @hidden */
  6989. _clone(): AnimationEvent;
  6990. }
  6991. }
  6992. declare module BABYLON {
  6993. /**
  6994. * Interface used to define a behavior
  6995. */
  6996. export interface Behavior<T> {
  6997. /** gets or sets behavior's name */
  6998. name: string;
  6999. /**
  7000. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7001. */
  7002. init(): void;
  7003. /**
  7004. * Called when the behavior is attached to a target
  7005. * @param target defines the target where the behavior is attached to
  7006. */
  7007. attach(target: T): void;
  7008. /**
  7009. * Called when the behavior is detached from its target
  7010. */
  7011. detach(): void;
  7012. }
  7013. /**
  7014. * Interface implemented by classes supporting behaviors
  7015. */
  7016. export interface IBehaviorAware<T> {
  7017. /**
  7018. * Attach a behavior
  7019. * @param behavior defines the behavior to attach
  7020. * @returns the current host
  7021. */
  7022. addBehavior(behavior: Behavior<T>): T;
  7023. /**
  7024. * Remove a behavior from the current object
  7025. * @param behavior defines the behavior to detach
  7026. * @returns the current host
  7027. */
  7028. removeBehavior(behavior: Behavior<T>): T;
  7029. /**
  7030. * Gets a behavior using its name to search
  7031. * @param name defines the name to search
  7032. * @returns the behavior or null if not found
  7033. */
  7034. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7035. }
  7036. }
  7037. declare module BABYLON {
  7038. /**
  7039. * @hidden
  7040. */
  7041. export class IntersectionInfo {
  7042. bu: Nullable<number>;
  7043. bv: Nullable<number>;
  7044. distance: number;
  7045. faceId: number;
  7046. subMeshId: number;
  7047. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7048. }
  7049. }
  7050. declare module BABYLON {
  7051. /**
  7052. * Class used to store bounding sphere information
  7053. */
  7054. export class BoundingSphere {
  7055. /**
  7056. * Gets the center of the bounding sphere in local space
  7057. */
  7058. readonly center: Vector3;
  7059. /**
  7060. * Radius of the bounding sphere in local space
  7061. */
  7062. radius: number;
  7063. /**
  7064. * Gets the center of the bounding sphere in world space
  7065. */
  7066. readonly centerWorld: Vector3;
  7067. /**
  7068. * Radius of the bounding sphere in world space
  7069. */
  7070. radiusWorld: number;
  7071. /**
  7072. * Gets the minimum vector in local space
  7073. */
  7074. readonly minimum: Vector3;
  7075. /**
  7076. * Gets the maximum vector in local space
  7077. */
  7078. readonly maximum: Vector3;
  7079. private _worldMatrix;
  7080. private static readonly TmpVector3;
  7081. /**
  7082. * Creates a new bounding sphere
  7083. * @param min defines the minimum vector (in local space)
  7084. * @param max defines the maximum vector (in local space)
  7085. * @param worldMatrix defines the new world matrix
  7086. */
  7087. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7088. /**
  7089. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7090. * @param min defines the new minimum vector (in local space)
  7091. * @param max defines the new maximum vector (in local space)
  7092. * @param worldMatrix defines the new world matrix
  7093. */
  7094. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7095. /**
  7096. * Scale the current bounding sphere by applying a scale factor
  7097. * @param factor defines the scale factor to apply
  7098. * @returns the current bounding box
  7099. */
  7100. scale(factor: number): BoundingSphere;
  7101. /**
  7102. * Gets the world matrix of the bounding box
  7103. * @returns a matrix
  7104. */
  7105. getWorldMatrix(): DeepImmutable<Matrix>;
  7106. /** @hidden */
  7107. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7108. /**
  7109. * Tests if the bounding sphere is intersecting the frustum planes
  7110. * @param frustumPlanes defines the frustum planes to test
  7111. * @returns true if there is an intersection
  7112. */
  7113. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7114. /**
  7115. * Tests if the bounding sphere center is in between the frustum planes.
  7116. * Used for optimistic fast inclusion.
  7117. * @param frustumPlanes defines the frustum planes to test
  7118. * @returns true if the sphere center is in between the frustum planes
  7119. */
  7120. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7121. /**
  7122. * Tests if a point is inside the bounding sphere
  7123. * @param point defines the point to test
  7124. * @returns true if the point is inside the bounding sphere
  7125. */
  7126. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7127. /**
  7128. * Checks if two sphere intersct
  7129. * @param sphere0 sphere 0
  7130. * @param sphere1 sphere 1
  7131. * @returns true if the speres intersect
  7132. */
  7133. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7134. }
  7135. }
  7136. declare module BABYLON {
  7137. /**
  7138. * Class used to store bounding box information
  7139. */
  7140. export class BoundingBox implements ICullable {
  7141. /**
  7142. * Gets the 8 vectors representing the bounding box in local space
  7143. */
  7144. readonly vectors: Vector3[];
  7145. /**
  7146. * Gets the center of the bounding box in local space
  7147. */
  7148. readonly center: Vector3;
  7149. /**
  7150. * Gets the center of the bounding box in world space
  7151. */
  7152. readonly centerWorld: Vector3;
  7153. /**
  7154. * Gets the extend size in local space
  7155. */
  7156. readonly extendSize: Vector3;
  7157. /**
  7158. * Gets the extend size in world space
  7159. */
  7160. readonly extendSizeWorld: Vector3;
  7161. /**
  7162. * Gets the OBB (object bounding box) directions
  7163. */
  7164. readonly directions: Vector3[];
  7165. /**
  7166. * Gets the 8 vectors representing the bounding box in world space
  7167. */
  7168. readonly vectorsWorld: Vector3[];
  7169. /**
  7170. * Gets the minimum vector in world space
  7171. */
  7172. readonly minimumWorld: Vector3;
  7173. /**
  7174. * Gets the maximum vector in world space
  7175. */
  7176. readonly maximumWorld: Vector3;
  7177. /**
  7178. * Gets the minimum vector in local space
  7179. */
  7180. readonly minimum: Vector3;
  7181. /**
  7182. * Gets the maximum vector in local space
  7183. */
  7184. readonly maximum: Vector3;
  7185. private _worldMatrix;
  7186. private static readonly TmpVector3;
  7187. /**
  7188. * @hidden
  7189. */
  7190. _tag: number;
  7191. /**
  7192. * Creates a new bounding box
  7193. * @param min defines the minimum vector (in local space)
  7194. * @param max defines the maximum vector (in local space)
  7195. * @param worldMatrix defines the new world matrix
  7196. */
  7197. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7198. /**
  7199. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7200. * @param min defines the new minimum vector (in local space)
  7201. * @param max defines the new maximum vector (in local space)
  7202. * @param worldMatrix defines the new world matrix
  7203. */
  7204. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7205. /**
  7206. * Scale the current bounding box by applying a scale factor
  7207. * @param factor defines the scale factor to apply
  7208. * @returns the current bounding box
  7209. */
  7210. scale(factor: number): BoundingBox;
  7211. /**
  7212. * Gets the world matrix of the bounding box
  7213. * @returns a matrix
  7214. */
  7215. getWorldMatrix(): DeepImmutable<Matrix>;
  7216. /** @hidden */
  7217. _update(world: DeepImmutable<Matrix>): void;
  7218. /**
  7219. * Tests if the bounding box is intersecting the frustum planes
  7220. * @param frustumPlanes defines the frustum planes to test
  7221. * @returns true if there is an intersection
  7222. */
  7223. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7224. /**
  7225. * Tests if the bounding box is entirely inside the frustum planes
  7226. * @param frustumPlanes defines the frustum planes to test
  7227. * @returns true if there is an inclusion
  7228. */
  7229. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7230. /**
  7231. * Tests if a point is inside the bounding box
  7232. * @param point defines the point to test
  7233. * @returns true if the point is inside the bounding box
  7234. */
  7235. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7236. /**
  7237. * Tests if the bounding box intersects with a bounding sphere
  7238. * @param sphere defines the sphere to test
  7239. * @returns true if there is an intersection
  7240. */
  7241. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7242. /**
  7243. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7244. * @param min defines the min vector to use
  7245. * @param max defines the max vector to use
  7246. * @returns true if there is an intersection
  7247. */
  7248. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7249. /**
  7250. * Tests if two bounding boxes are intersections
  7251. * @param box0 defines the first box to test
  7252. * @param box1 defines the second box to test
  7253. * @returns true if there is an intersection
  7254. */
  7255. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7256. /**
  7257. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7258. * @param minPoint defines the minimum vector of the bounding box
  7259. * @param maxPoint defines the maximum vector of the bounding box
  7260. * @param sphereCenter defines the sphere center
  7261. * @param sphereRadius defines the sphere radius
  7262. * @returns true if there is an intersection
  7263. */
  7264. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7265. /**
  7266. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7267. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7268. * @param frustumPlanes defines the frustum planes to test
  7269. * @return true if there is an inclusion
  7270. */
  7271. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7272. /**
  7273. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7274. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7275. * @param frustumPlanes defines the frustum planes to test
  7276. * @return true if there is an intersection
  7277. */
  7278. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7279. }
  7280. }
  7281. declare module BABYLON {
  7282. /** @hidden */
  7283. export class Collider {
  7284. /** Define if a collision was found */
  7285. collisionFound: boolean;
  7286. /**
  7287. * Define last intersection point in local space
  7288. */
  7289. intersectionPoint: Vector3;
  7290. /**
  7291. * Define last collided mesh
  7292. */
  7293. collidedMesh: Nullable<AbstractMesh>;
  7294. private _collisionPoint;
  7295. private _planeIntersectionPoint;
  7296. private _tempVector;
  7297. private _tempVector2;
  7298. private _tempVector3;
  7299. private _tempVector4;
  7300. private _edge;
  7301. private _baseToVertex;
  7302. private _destinationPoint;
  7303. private _slidePlaneNormal;
  7304. private _displacementVector;
  7305. /** @hidden */
  7306. _radius: Vector3;
  7307. /** @hidden */
  7308. _retry: number;
  7309. private _velocity;
  7310. private _basePoint;
  7311. private _epsilon;
  7312. /** @hidden */
  7313. _velocityWorldLength: number;
  7314. /** @hidden */
  7315. _basePointWorld: Vector3;
  7316. private _velocityWorld;
  7317. private _normalizedVelocity;
  7318. /** @hidden */
  7319. _initialVelocity: Vector3;
  7320. /** @hidden */
  7321. _initialPosition: Vector3;
  7322. private _nearestDistance;
  7323. private _collisionMask;
  7324. collisionMask: number;
  7325. /**
  7326. * Gets the plane normal used to compute the sliding response (in local space)
  7327. */
  7328. readonly slidePlaneNormal: Vector3;
  7329. /** @hidden */
  7330. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7331. /** @hidden */
  7332. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7333. /** @hidden */
  7334. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7335. /** @hidden */
  7336. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7337. /** @hidden */
  7338. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7339. /** @hidden */
  7340. _getResponse(pos: Vector3, vel: Vector3): void;
  7341. }
  7342. }
  7343. declare module BABYLON {
  7344. /**
  7345. * Interface for cullable objects
  7346. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7347. */
  7348. export interface ICullable {
  7349. /**
  7350. * Checks if the object or part of the object is in the frustum
  7351. * @param frustumPlanes Camera near/planes
  7352. * @returns true if the object is in frustum otherwise false
  7353. */
  7354. isInFrustum(frustumPlanes: Plane[]): boolean;
  7355. /**
  7356. * Checks if a cullable object (mesh...) is in the camera frustum
  7357. * Unlike isInFrustum this cheks the full bounding box
  7358. * @param frustumPlanes Camera near/planes
  7359. * @returns true if the object is in frustum otherwise false
  7360. */
  7361. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7362. }
  7363. /**
  7364. * Info for a bounding data of a mesh
  7365. */
  7366. export class BoundingInfo implements ICullable {
  7367. /**
  7368. * Bounding box for the mesh
  7369. */
  7370. readonly boundingBox: BoundingBox;
  7371. /**
  7372. * Bounding sphere for the mesh
  7373. */
  7374. readonly boundingSphere: BoundingSphere;
  7375. private _isLocked;
  7376. private static readonly TmpVector3;
  7377. /**
  7378. * Constructs bounding info
  7379. * @param minimum min vector of the bounding box/sphere
  7380. * @param maximum max vector of the bounding box/sphere
  7381. * @param worldMatrix defines the new world matrix
  7382. */
  7383. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7384. /**
  7385. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7386. * @param min defines the new minimum vector (in local space)
  7387. * @param max defines the new maximum vector (in local space)
  7388. * @param worldMatrix defines the new world matrix
  7389. */
  7390. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7391. /**
  7392. * min vector of the bounding box/sphere
  7393. */
  7394. readonly minimum: Vector3;
  7395. /**
  7396. * max vector of the bounding box/sphere
  7397. */
  7398. readonly maximum: Vector3;
  7399. /**
  7400. * If the info is locked and won't be updated to avoid perf overhead
  7401. */
  7402. isLocked: boolean;
  7403. /**
  7404. * Updates the bounding sphere and box
  7405. * @param world world matrix to be used to update
  7406. */
  7407. update(world: DeepImmutable<Matrix>): void;
  7408. /**
  7409. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7410. * @param center New center of the bounding info
  7411. * @param extend New extend of the bounding info
  7412. * @returns the current bounding info
  7413. */
  7414. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7415. /**
  7416. * Scale the current bounding info by applying a scale factor
  7417. * @param factor defines the scale factor to apply
  7418. * @returns the current bounding info
  7419. */
  7420. scale(factor: number): BoundingInfo;
  7421. /**
  7422. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7423. * @param frustumPlanes defines the frustum to test
  7424. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7425. * @returns true if the bounding info is in the frustum planes
  7426. */
  7427. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7428. /**
  7429. * Gets the world distance between the min and max points of the bounding box
  7430. */
  7431. readonly diagonalLength: number;
  7432. /**
  7433. * Checks if a cullable object (mesh...) is in the camera frustum
  7434. * Unlike isInFrustum this cheks the full bounding box
  7435. * @param frustumPlanes Camera near/planes
  7436. * @returns true if the object is in frustum otherwise false
  7437. */
  7438. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7439. /** @hidden */
  7440. _checkCollision(collider: Collider): boolean;
  7441. /**
  7442. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7443. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7444. * @param point the point to check intersection with
  7445. * @returns if the point intersects
  7446. */
  7447. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7448. /**
  7449. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7450. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7451. * @param boundingInfo the bounding info to check intersection with
  7452. * @param precise if the intersection should be done using OBB
  7453. * @returns if the bounding info intersects
  7454. */
  7455. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7456. }
  7457. }
  7458. declare module BABYLON {
  7459. /**
  7460. * Defines an array and its length.
  7461. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7462. */
  7463. export interface ISmartArrayLike<T> {
  7464. /**
  7465. * The data of the array.
  7466. */
  7467. data: Array<T>;
  7468. /**
  7469. * The active length of the array.
  7470. */
  7471. length: number;
  7472. }
  7473. /**
  7474. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7475. */
  7476. export class SmartArray<T> implements ISmartArrayLike<T> {
  7477. /**
  7478. * The full set of data from the array.
  7479. */
  7480. data: Array<T>;
  7481. /**
  7482. * The active length of the array.
  7483. */
  7484. length: number;
  7485. protected _id: number;
  7486. /**
  7487. * Instantiates a Smart Array.
  7488. * @param capacity defines the default capacity of the array.
  7489. */
  7490. constructor(capacity: number);
  7491. /**
  7492. * Pushes a value at the end of the active data.
  7493. * @param value defines the object to push in the array.
  7494. */
  7495. push(value: T): void;
  7496. /**
  7497. * Iterates over the active data and apply the lambda to them.
  7498. * @param func defines the action to apply on each value.
  7499. */
  7500. forEach(func: (content: T) => void): void;
  7501. /**
  7502. * Sorts the full sets of data.
  7503. * @param compareFn defines the comparison function to apply.
  7504. */
  7505. sort(compareFn: (a: T, b: T) => number): void;
  7506. /**
  7507. * Resets the active data to an empty array.
  7508. */
  7509. reset(): void;
  7510. /**
  7511. * Releases all the data from the array as well as the array.
  7512. */
  7513. dispose(): void;
  7514. /**
  7515. * Concats the active data with a given array.
  7516. * @param array defines the data to concatenate with.
  7517. */
  7518. concat(array: any): void;
  7519. /**
  7520. * Returns the position of a value in the active data.
  7521. * @param value defines the value to find the index for
  7522. * @returns the index if found in the active data otherwise -1
  7523. */
  7524. indexOf(value: T): number;
  7525. /**
  7526. * Returns whether an element is part of the active data.
  7527. * @param value defines the value to look for
  7528. * @returns true if found in the active data otherwise false
  7529. */
  7530. contains(value: T): boolean;
  7531. private static _GlobalId;
  7532. }
  7533. /**
  7534. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7535. * The data in this array can only be present once
  7536. */
  7537. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7538. private _duplicateId;
  7539. /**
  7540. * Pushes a value at the end of the active data.
  7541. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7542. * @param value defines the object to push in the array.
  7543. */
  7544. push(value: T): void;
  7545. /**
  7546. * Pushes a value at the end of the active data.
  7547. * If the data is already present, it won t be added again
  7548. * @param value defines the object to push in the array.
  7549. * @returns true if added false if it was already present
  7550. */
  7551. pushNoDuplicate(value: T): boolean;
  7552. /**
  7553. * Resets the active data to an empty array.
  7554. */
  7555. reset(): void;
  7556. /**
  7557. * Concats the active data with a given array.
  7558. * This ensures no dupplicate will be present in the result.
  7559. * @param array defines the data to concatenate with.
  7560. */
  7561. concatWithNoDuplicate(array: any): void;
  7562. }
  7563. }
  7564. declare module BABYLON {
  7565. /**
  7566. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7567. * separate meshes. This can be use to improve performances.
  7568. * @see http://doc.babylonjs.com/how_to/multi_materials
  7569. */
  7570. export class MultiMaterial extends Material {
  7571. private _subMaterials;
  7572. /**
  7573. * Gets or Sets the list of Materials used within the multi material.
  7574. * They need to be ordered according to the submeshes order in the associated mesh
  7575. */
  7576. subMaterials: Nullable<Material>[];
  7577. /**
  7578. * Function used to align with Node.getChildren()
  7579. * @returns the list of Materials used within the multi material
  7580. */
  7581. getChildren(): Nullable<Material>[];
  7582. /**
  7583. * Instantiates a new Multi Material
  7584. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7585. * separate meshes. This can be use to improve performances.
  7586. * @see http://doc.babylonjs.com/how_to/multi_materials
  7587. * @param name Define the name in the scene
  7588. * @param scene Define the scene the material belongs to
  7589. */
  7590. constructor(name: string, scene: Scene);
  7591. private _hookArray;
  7592. /**
  7593. * Get one of the submaterial by its index in the submaterials array
  7594. * @param index The index to look the sub material at
  7595. * @returns The Material if the index has been defined
  7596. */
  7597. getSubMaterial(index: number): Nullable<Material>;
  7598. /**
  7599. * Get the list of active textures for the whole sub materials list.
  7600. * @returns All the textures that will be used during the rendering
  7601. */
  7602. getActiveTextures(): BaseTexture[];
  7603. /**
  7604. * Gets the current class name of the material e.g. "MultiMaterial"
  7605. * Mainly use in serialization.
  7606. * @returns the class name
  7607. */
  7608. getClassName(): string;
  7609. /**
  7610. * Checks if the material is ready to render the requested sub mesh
  7611. * @param mesh Define the mesh the submesh belongs to
  7612. * @param subMesh Define the sub mesh to look readyness for
  7613. * @param useInstances Define whether or not the material is used with instances
  7614. * @returns true if ready, otherwise false
  7615. */
  7616. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7617. /**
  7618. * Clones the current material and its related sub materials
  7619. * @param name Define the name of the newly cloned material
  7620. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7621. * @returns the cloned material
  7622. */
  7623. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7624. /**
  7625. * Serializes the materials into a JSON representation.
  7626. * @returns the JSON representation
  7627. */
  7628. serialize(): any;
  7629. /**
  7630. * Dispose the material and release its associated resources
  7631. * @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)
  7632. * @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)
  7633. * @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)
  7634. */
  7635. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7636. /**
  7637. * Creates a MultiMaterial from parsed MultiMaterial data.
  7638. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7639. * @param scene defines the hosting scene
  7640. * @returns a new MultiMaterial
  7641. */
  7642. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7643. }
  7644. }
  7645. declare module BABYLON {
  7646. /**
  7647. * Class used to represent data loading progression
  7648. */
  7649. export class SceneLoaderFlags {
  7650. private static _ForceFullSceneLoadingForIncremental;
  7651. private static _ShowLoadingScreen;
  7652. private static _CleanBoneMatrixWeights;
  7653. private static _loggingLevel;
  7654. /**
  7655. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7656. */
  7657. static ForceFullSceneLoadingForIncremental: boolean;
  7658. /**
  7659. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7660. */
  7661. static ShowLoadingScreen: boolean;
  7662. /**
  7663. * Defines the current logging level (while loading the scene)
  7664. * @ignorenaming
  7665. */
  7666. static loggingLevel: number;
  7667. /**
  7668. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7669. */
  7670. static CleanBoneMatrixWeights: boolean;
  7671. }
  7672. }
  7673. declare module BABYLON {
  7674. /**
  7675. * 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.
  7676. * @see https://doc.babylonjs.com/how_to/transformnode
  7677. */
  7678. export class TransformNode extends Node {
  7679. /**
  7680. * Object will not rotate to face the camera
  7681. */
  7682. static BILLBOARDMODE_NONE: number;
  7683. /**
  7684. * Object will rotate to face the camera but only on the x axis
  7685. */
  7686. static BILLBOARDMODE_X: number;
  7687. /**
  7688. * Object will rotate to face the camera but only on the y axis
  7689. */
  7690. static BILLBOARDMODE_Y: number;
  7691. /**
  7692. * Object will rotate to face the camera but only on the z axis
  7693. */
  7694. static BILLBOARDMODE_Z: number;
  7695. /**
  7696. * Object will rotate to face the camera
  7697. */
  7698. static BILLBOARDMODE_ALL: number;
  7699. private _forward;
  7700. private _forwardInverted;
  7701. private _up;
  7702. private _right;
  7703. private _rightInverted;
  7704. private _position;
  7705. private _rotation;
  7706. private _rotationQuaternion;
  7707. protected _scaling: Vector3;
  7708. protected _isDirty: boolean;
  7709. private _transformToBoneReferal;
  7710. private _billboardMode;
  7711. /**
  7712. * Gets or sets the billboard mode. Default is 0.
  7713. *
  7714. * | Value | Type | Description |
  7715. * | --- | --- | --- |
  7716. * | 0 | BILLBOARDMODE_NONE | |
  7717. * | 1 | BILLBOARDMODE_X | |
  7718. * | 2 | BILLBOARDMODE_Y | |
  7719. * | 4 | BILLBOARDMODE_Z | |
  7720. * | 7 | BILLBOARDMODE_ALL | |
  7721. *
  7722. */
  7723. billboardMode: number;
  7724. private _preserveParentRotationForBillboard;
  7725. /**
  7726. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7727. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7728. */
  7729. preserveParentRotationForBillboard: boolean;
  7730. /**
  7731. * 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
  7732. */
  7733. scalingDeterminant: number;
  7734. private _infiniteDistance;
  7735. /**
  7736. * Gets or sets the distance of the object to max, often used by skybox
  7737. */
  7738. infiniteDistance: boolean;
  7739. /**
  7740. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7741. * By default the system will update normals to compensate
  7742. */
  7743. ignoreNonUniformScaling: boolean;
  7744. /**
  7745. * 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
  7746. */
  7747. reIntegrateRotationIntoRotationQuaternion: boolean;
  7748. /** @hidden */
  7749. _poseMatrix: Nullable<Matrix>;
  7750. /** @hidden */
  7751. _localMatrix: Matrix;
  7752. private _usePivotMatrix;
  7753. private _absolutePosition;
  7754. private _pivotMatrix;
  7755. private _pivotMatrixInverse;
  7756. protected _postMultiplyPivotMatrix: boolean;
  7757. protected _isWorldMatrixFrozen: boolean;
  7758. /** @hidden */
  7759. _indexInSceneTransformNodesArray: number;
  7760. /**
  7761. * An event triggered after the world matrix is updated
  7762. */
  7763. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7764. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7765. /**
  7766. * Gets a string identifying the name of the class
  7767. * @returns "TransformNode" string
  7768. */
  7769. getClassName(): string;
  7770. /**
  7771. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7772. */
  7773. position: Vector3;
  7774. /**
  7775. * 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)).
  7776. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7777. */
  7778. rotation: Vector3;
  7779. /**
  7780. * 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)).
  7781. */
  7782. scaling: Vector3;
  7783. /**
  7784. * 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).
  7785. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7786. */
  7787. rotationQuaternion: Nullable<Quaternion>;
  7788. /**
  7789. * The forward direction of that transform in world space.
  7790. */
  7791. readonly forward: Vector3;
  7792. /**
  7793. * The up direction of that transform in world space.
  7794. */
  7795. readonly up: Vector3;
  7796. /**
  7797. * The right direction of that transform in world space.
  7798. */
  7799. readonly right: Vector3;
  7800. /**
  7801. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7802. * @param matrix the matrix to copy the pose from
  7803. * @returns this TransformNode.
  7804. */
  7805. updatePoseMatrix(matrix: Matrix): TransformNode;
  7806. /**
  7807. * Returns the mesh Pose matrix.
  7808. * @returns the pose matrix
  7809. */
  7810. getPoseMatrix(): Matrix;
  7811. /** @hidden */
  7812. _isSynchronized(): boolean;
  7813. /** @hidden */
  7814. _initCache(): void;
  7815. /**
  7816. * Flag the transform node as dirty (Forcing it to update everything)
  7817. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7818. * @returns this transform node
  7819. */
  7820. markAsDirty(property: string): TransformNode;
  7821. /**
  7822. * Returns the current mesh absolute position.
  7823. * Returns a Vector3.
  7824. */
  7825. readonly absolutePosition: Vector3;
  7826. /**
  7827. * Sets a new matrix to apply before all other transformation
  7828. * @param matrix defines the transform matrix
  7829. * @returns the current TransformNode
  7830. */
  7831. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7832. /**
  7833. * Sets a new pivot matrix to the current node
  7834. * @param matrix defines the new pivot matrix to use
  7835. * @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
  7836. * @returns the current TransformNode
  7837. */
  7838. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7839. /**
  7840. * Returns the mesh pivot matrix.
  7841. * Default : Identity.
  7842. * @returns the matrix
  7843. */
  7844. getPivotMatrix(): Matrix;
  7845. /**
  7846. * Prevents the World matrix to be computed any longer.
  7847. * @returns the TransformNode.
  7848. */
  7849. freezeWorldMatrix(): TransformNode;
  7850. /**
  7851. * Allows back the World matrix computation.
  7852. * @returns the TransformNode.
  7853. */
  7854. unfreezeWorldMatrix(): this;
  7855. /**
  7856. * True if the World matrix has been frozen.
  7857. */
  7858. readonly isWorldMatrixFrozen: boolean;
  7859. /**
  7860. * Retuns the mesh absolute position in the World.
  7861. * @returns a Vector3.
  7862. */
  7863. getAbsolutePosition(): Vector3;
  7864. /**
  7865. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7866. * @param absolutePosition the absolute position to set
  7867. * @returns the TransformNode.
  7868. */
  7869. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7870. /**
  7871. * Sets the mesh position in its local space.
  7872. * @param vector3 the position to set in localspace
  7873. * @returns the TransformNode.
  7874. */
  7875. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7876. /**
  7877. * Returns the mesh position in the local space from the current World matrix values.
  7878. * @returns a new Vector3.
  7879. */
  7880. getPositionExpressedInLocalSpace(): Vector3;
  7881. /**
  7882. * Translates the mesh along the passed Vector3 in its local space.
  7883. * @param vector3 the distance to translate in localspace
  7884. * @returns the TransformNode.
  7885. */
  7886. locallyTranslate(vector3: Vector3): TransformNode;
  7887. private static _lookAtVectorCache;
  7888. /**
  7889. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7890. * @param targetPoint the position (must be in same space as current mesh) to look at
  7891. * @param yawCor optional yaw (y-axis) correction in radians
  7892. * @param pitchCor optional pitch (x-axis) correction in radians
  7893. * @param rollCor optional roll (z-axis) correction in radians
  7894. * @param space the choosen space of the target
  7895. * @returns the TransformNode.
  7896. */
  7897. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7898. /**
  7899. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7900. * This Vector3 is expressed in the World space.
  7901. * @param localAxis axis to rotate
  7902. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7903. */
  7904. getDirection(localAxis: Vector3): Vector3;
  7905. /**
  7906. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7907. * localAxis is expressed in the mesh local space.
  7908. * result is computed in the Wordl space from the mesh World matrix.
  7909. * @param localAxis axis to rotate
  7910. * @param result the resulting transformnode
  7911. * @returns this TransformNode.
  7912. */
  7913. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7914. /**
  7915. * Sets this transform node rotation to the given local axis.
  7916. * @param localAxis the axis in local space
  7917. * @param yawCor optional yaw (y-axis) correction in radians
  7918. * @param pitchCor optional pitch (x-axis) correction in radians
  7919. * @param rollCor optional roll (z-axis) correction in radians
  7920. * @returns this TransformNode
  7921. */
  7922. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7923. /**
  7924. * Sets a new pivot point to the current node
  7925. * @param point defines the new pivot point to use
  7926. * @param space defines if the point is in world or local space (local by default)
  7927. * @returns the current TransformNode
  7928. */
  7929. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7930. /**
  7931. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7932. * @returns the pivot point
  7933. */
  7934. getPivotPoint(): Vector3;
  7935. /**
  7936. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7937. * @param result the vector3 to store the result
  7938. * @returns this TransformNode.
  7939. */
  7940. getPivotPointToRef(result: Vector3): TransformNode;
  7941. /**
  7942. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7943. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7944. */
  7945. getAbsolutePivotPoint(): Vector3;
  7946. /**
  7947. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7948. * @param result vector3 to store the result
  7949. * @returns this TransformNode.
  7950. */
  7951. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7952. /**
  7953. * Defines the passed node as the parent of the current node.
  7954. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7955. * @see https://doc.babylonjs.com/how_to/parenting
  7956. * @param node the node ot set as the parent
  7957. * @returns this TransformNode.
  7958. */
  7959. setParent(node: Nullable<Node>): TransformNode;
  7960. private _nonUniformScaling;
  7961. /**
  7962. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7963. */
  7964. readonly nonUniformScaling: boolean;
  7965. /** @hidden */
  7966. _updateNonUniformScalingState(value: boolean): boolean;
  7967. /**
  7968. * Attach the current TransformNode to another TransformNode associated with a bone
  7969. * @param bone Bone affecting the TransformNode
  7970. * @param affectedTransformNode TransformNode associated with the bone
  7971. * @returns this object
  7972. */
  7973. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7974. /**
  7975. * Detach the transform node if its associated with a bone
  7976. * @returns this object
  7977. */
  7978. detachFromBone(): TransformNode;
  7979. private static _rotationAxisCache;
  7980. /**
  7981. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7982. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7983. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7984. * The passed axis is also normalized.
  7985. * @param axis the axis to rotate around
  7986. * @param amount the amount to rotate in radians
  7987. * @param space Space to rotate in (Default: local)
  7988. * @returns the TransformNode.
  7989. */
  7990. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7991. /**
  7992. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7993. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7994. * The passed axis is also normalized. .
  7995. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7996. * @param point the point to rotate around
  7997. * @param axis the axis to rotate around
  7998. * @param amount the amount to rotate in radians
  7999. * @returns the TransformNode
  8000. */
  8001. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8002. /**
  8003. * Translates the mesh along the axis vector for the passed distance in the given space.
  8004. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8005. * @param axis the axis to translate in
  8006. * @param distance the distance to translate
  8007. * @param space Space to rotate in (Default: local)
  8008. * @returns the TransformNode.
  8009. */
  8010. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8011. /**
  8012. * Adds a rotation step to the mesh current rotation.
  8013. * x, y, z are Euler angles expressed in radians.
  8014. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8015. * This means this rotation is made in the mesh local space only.
  8016. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8017. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8018. * ```javascript
  8019. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8020. * ```
  8021. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8022. * 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.
  8023. * @param x Rotation to add
  8024. * @param y Rotation to add
  8025. * @param z Rotation to add
  8026. * @returns the TransformNode.
  8027. */
  8028. addRotation(x: number, y: number, z: number): TransformNode;
  8029. /**
  8030. * @hidden
  8031. */
  8032. protected _getEffectiveParent(): Nullable<Node>;
  8033. /**
  8034. * Computes the world matrix of the node
  8035. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8036. * @returns the world matrix
  8037. */
  8038. computeWorldMatrix(force?: boolean): Matrix;
  8039. protected _afterComputeWorldMatrix(): void;
  8040. /**
  8041. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8042. * @param func callback function to add
  8043. *
  8044. * @returns the TransformNode.
  8045. */
  8046. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8047. /**
  8048. * Removes a registered callback function.
  8049. * @param func callback function to remove
  8050. * @returns the TransformNode.
  8051. */
  8052. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8053. /**
  8054. * Gets the position of the current mesh in camera space
  8055. * @param camera defines the camera to use
  8056. * @returns a position
  8057. */
  8058. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8059. /**
  8060. * Returns the distance from the mesh to the active camera
  8061. * @param camera defines the camera to use
  8062. * @returns the distance
  8063. */
  8064. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8065. /**
  8066. * Clone the current transform node
  8067. * @param name Name of the new clone
  8068. * @param newParent New parent for the clone
  8069. * @param doNotCloneChildren Do not clone children hierarchy
  8070. * @returns the new transform node
  8071. */
  8072. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8073. /**
  8074. * Serializes the objects information.
  8075. * @param currentSerializationObject defines the object to serialize in
  8076. * @returns the serialized object
  8077. */
  8078. serialize(currentSerializationObject?: any): any;
  8079. /**
  8080. * Returns a new TransformNode object parsed from the source provided.
  8081. * @param parsedTransformNode is the source.
  8082. * @param scene the scne the object belongs to
  8083. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8084. * @returns a new TransformNode object parsed from the source provided.
  8085. */
  8086. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8087. /**
  8088. * Get all child-transformNodes of this node
  8089. * @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
  8090. * @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
  8091. * @returns an array of TransformNode
  8092. */
  8093. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8094. /**
  8095. * Releases resources associated with this transform node.
  8096. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8097. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8098. */
  8099. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8100. }
  8101. }
  8102. declare module BABYLON {
  8103. /**
  8104. * Class used to override all child animations of a given target
  8105. */
  8106. export class AnimationPropertiesOverride {
  8107. /**
  8108. * Gets or sets a value indicating if animation blending must be used
  8109. */
  8110. enableBlending: boolean;
  8111. /**
  8112. * Gets or sets the blending speed to use when enableBlending is true
  8113. */
  8114. blendingSpeed: number;
  8115. /**
  8116. * Gets or sets the default loop mode to use
  8117. */
  8118. loopMode: number;
  8119. }
  8120. }
  8121. declare module BABYLON {
  8122. /**
  8123. * Class used to store bone information
  8124. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8125. */
  8126. export class Bone extends Node {
  8127. /**
  8128. * defines the bone name
  8129. */
  8130. name: string;
  8131. private static _tmpVecs;
  8132. private static _tmpQuat;
  8133. private static _tmpMats;
  8134. /**
  8135. * Gets the list of child bones
  8136. */
  8137. children: Bone[];
  8138. /** Gets the animations associated with this bone */
  8139. animations: Animation[];
  8140. /**
  8141. * Gets or sets bone length
  8142. */
  8143. length: number;
  8144. /**
  8145. * @hidden Internal only
  8146. * Set this value to map this bone to a different index in the transform matrices
  8147. * Set this value to -1 to exclude the bone from the transform matrices
  8148. */
  8149. _index: Nullable<number>;
  8150. private _skeleton;
  8151. private _localMatrix;
  8152. private _restPose;
  8153. private _baseMatrix;
  8154. private _absoluteTransform;
  8155. private _invertedAbsoluteTransform;
  8156. private _parent;
  8157. private _scalingDeterminant;
  8158. private _worldTransform;
  8159. private _localScaling;
  8160. private _localRotation;
  8161. private _localPosition;
  8162. private _needToDecompose;
  8163. private _needToCompose;
  8164. /** @hidden */
  8165. _linkedTransformNode: Nullable<TransformNode>;
  8166. /** @hidden */
  8167. _waitingTransformNodeId: Nullable<string>;
  8168. /** @hidden */
  8169. /** @hidden */
  8170. _matrix: Matrix;
  8171. /**
  8172. * Create a new bone
  8173. * @param name defines the bone name
  8174. * @param skeleton defines the parent skeleton
  8175. * @param parentBone defines the parent (can be null if the bone is the root)
  8176. * @param localMatrix defines the local matrix
  8177. * @param restPose defines the rest pose matrix
  8178. * @param baseMatrix defines the base matrix
  8179. * @param index defines index of the bone in the hiearchy
  8180. */
  8181. constructor(
  8182. /**
  8183. * defines the bone name
  8184. */
  8185. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8186. /**
  8187. * Gets the current object class name.
  8188. * @return the class name
  8189. */
  8190. getClassName(): string;
  8191. /**
  8192. * Gets the parent skeleton
  8193. * @returns a skeleton
  8194. */
  8195. getSkeleton(): Skeleton;
  8196. /**
  8197. * Gets parent bone
  8198. * @returns a bone or null if the bone is the root of the bone hierarchy
  8199. */
  8200. getParent(): Nullable<Bone>;
  8201. /**
  8202. * Returns an array containing the root bones
  8203. * @returns an array containing the root bones
  8204. */
  8205. getChildren(): Array<Bone>;
  8206. /**
  8207. * Sets the parent bone
  8208. * @param parent defines the parent (can be null if the bone is the root)
  8209. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8210. */
  8211. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8212. /**
  8213. * Gets the local matrix
  8214. * @returns a matrix
  8215. */
  8216. getLocalMatrix(): Matrix;
  8217. /**
  8218. * Gets the base matrix (initial matrix which remains unchanged)
  8219. * @returns a matrix
  8220. */
  8221. getBaseMatrix(): Matrix;
  8222. /**
  8223. * Gets the rest pose matrix
  8224. * @returns a matrix
  8225. */
  8226. getRestPose(): Matrix;
  8227. /**
  8228. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8229. */
  8230. getWorldMatrix(): Matrix;
  8231. /**
  8232. * Sets the local matrix to rest pose matrix
  8233. */
  8234. returnToRest(): void;
  8235. /**
  8236. * Gets the inverse of the absolute transform matrix.
  8237. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8238. * @returns a matrix
  8239. */
  8240. getInvertedAbsoluteTransform(): Matrix;
  8241. /**
  8242. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8243. * @returns a matrix
  8244. */
  8245. getAbsoluteTransform(): Matrix;
  8246. /**
  8247. * Links with the given transform node.
  8248. * The local matrix of this bone is copied from the transform node every frame.
  8249. * @param transformNode defines the transform node to link to
  8250. */
  8251. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8252. /** Gets or sets current position (in local space) */
  8253. position: Vector3;
  8254. /** Gets or sets current rotation (in local space) */
  8255. rotation: Vector3;
  8256. /** Gets or sets current rotation quaternion (in local space) */
  8257. rotationQuaternion: Quaternion;
  8258. /** Gets or sets current scaling (in local space) */
  8259. scaling: Vector3;
  8260. /**
  8261. * Gets the animation properties override
  8262. */
  8263. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8264. private _decompose;
  8265. private _compose;
  8266. /**
  8267. * Update the base and local matrices
  8268. * @param matrix defines the new base or local matrix
  8269. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8270. * @param updateLocalMatrix defines if the local matrix should be updated
  8271. */
  8272. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8273. /** @hidden */
  8274. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8275. /**
  8276. * Flag the bone as dirty (Forcing it to update everything)
  8277. */
  8278. markAsDirty(): void;
  8279. /** @hidden */
  8280. _markAsDirtyAndCompose(): void;
  8281. private _markAsDirtyAndDecompose;
  8282. /**
  8283. * Translate the bone in local or world space
  8284. * @param vec The amount to translate the bone
  8285. * @param space The space that the translation is in
  8286. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8287. */
  8288. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8289. /**
  8290. * Set the postion of the bone in local or world space
  8291. * @param position The position to set the bone
  8292. * @param space The space that the position is in
  8293. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8294. */
  8295. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8296. /**
  8297. * Set the absolute position of the bone (world space)
  8298. * @param position The position to set the bone
  8299. * @param mesh The mesh that this bone is attached to
  8300. */
  8301. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8302. /**
  8303. * Scale the bone on the x, y and z axes (in local space)
  8304. * @param x The amount to scale the bone on the x axis
  8305. * @param y The amount to scale the bone on the y axis
  8306. * @param z The amount to scale the bone on the z axis
  8307. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8308. */
  8309. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8310. /**
  8311. * Set the bone scaling in local space
  8312. * @param scale defines the scaling vector
  8313. */
  8314. setScale(scale: Vector3): void;
  8315. /**
  8316. * Gets the current scaling in local space
  8317. * @returns the current scaling vector
  8318. */
  8319. getScale(): Vector3;
  8320. /**
  8321. * Gets the current scaling in local space and stores it in a target vector
  8322. * @param result defines the target vector
  8323. */
  8324. getScaleToRef(result: Vector3): void;
  8325. /**
  8326. * Set the yaw, pitch, and roll of the bone in local or world space
  8327. * @param yaw The rotation of the bone on the y axis
  8328. * @param pitch The rotation of the bone on the x axis
  8329. * @param roll The rotation of the bone on the z axis
  8330. * @param space The space that the axes of rotation are in
  8331. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8332. */
  8333. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8334. /**
  8335. * Add a rotation to the bone on an axis in local or world space
  8336. * @param axis The axis to rotate the bone on
  8337. * @param amount The amount to rotate the bone
  8338. * @param space The space that the axis is in
  8339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8340. */
  8341. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8342. /**
  8343. * Set the rotation of the bone to a particular axis angle in local or world space
  8344. * @param axis The axis to rotate the bone on
  8345. * @param angle The angle that the bone should be rotated to
  8346. * @param space The space that the axis is in
  8347. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8348. */
  8349. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8350. /**
  8351. * Set the euler rotation of the bone in local of world space
  8352. * @param rotation The euler rotation that the bone should be set to
  8353. * @param space The space that the rotation is in
  8354. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8355. */
  8356. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8357. /**
  8358. * Set the quaternion rotation of the bone in local of world space
  8359. * @param quat The quaternion rotation that the bone should be set to
  8360. * @param space The space that the rotation is in
  8361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8362. */
  8363. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8364. /**
  8365. * Set the rotation matrix of the bone in local of world space
  8366. * @param rotMat The rotation matrix that the bone should be set to
  8367. * @param space The space that the rotation is in
  8368. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8369. */
  8370. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8371. private _rotateWithMatrix;
  8372. private _getNegativeRotationToRef;
  8373. /**
  8374. * Get the position of the bone in local or world space
  8375. * @param space The space that the returned position is in
  8376. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8377. * @returns The position of the bone
  8378. */
  8379. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8380. /**
  8381. * Copy the position of the bone to a vector3 in local or world space
  8382. * @param space The space that the returned position is in
  8383. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8384. * @param result The vector3 to copy the position to
  8385. */
  8386. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8387. /**
  8388. * Get the absolute position of the bone (world space)
  8389. * @param mesh The mesh that this bone is attached to
  8390. * @returns The absolute position of the bone
  8391. */
  8392. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8393. /**
  8394. * Copy the absolute position of the bone (world space) to the result param
  8395. * @param mesh The mesh that this bone is attached to
  8396. * @param result The vector3 to copy the absolute position to
  8397. */
  8398. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8399. /**
  8400. * Compute the absolute transforms of this bone and its children
  8401. */
  8402. computeAbsoluteTransforms(): void;
  8403. /**
  8404. * Get the world direction from an axis that is in the local space of the bone
  8405. * @param localAxis The local direction that is used to compute the world direction
  8406. * @param mesh The mesh that this bone is attached to
  8407. * @returns The world direction
  8408. */
  8409. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8410. /**
  8411. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8412. * @param localAxis The local direction that is used to compute the world direction
  8413. * @param mesh The mesh that this bone is attached to
  8414. * @param result The vector3 that the world direction will be copied to
  8415. */
  8416. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8417. /**
  8418. * Get the euler rotation of the bone in local or world space
  8419. * @param space The space that the rotation should be in
  8420. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8421. * @returns The euler rotation
  8422. */
  8423. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8424. /**
  8425. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8426. * @param space The space that the rotation should be in
  8427. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8428. * @param result The vector3 that the rotation should be copied to
  8429. */
  8430. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8431. /**
  8432. * Get the quaternion rotation of the bone in either local or world space
  8433. * @param space The space that the rotation should be in
  8434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8435. * @returns The quaternion rotation
  8436. */
  8437. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8438. /**
  8439. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8440. * @param space The space that the rotation should be in
  8441. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8442. * @param result The quaternion that the rotation should be copied to
  8443. */
  8444. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8445. /**
  8446. * Get the rotation matrix of the bone in local or world space
  8447. * @param space The space that the rotation should be in
  8448. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8449. * @returns The rotation matrix
  8450. */
  8451. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8452. /**
  8453. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8454. * @param space The space that the rotation should be in
  8455. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8456. * @param result The quaternion that the rotation should be copied to
  8457. */
  8458. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8459. /**
  8460. * Get the world position of a point that is in the local space of the bone
  8461. * @param position The local position
  8462. * @param mesh The mesh that this bone is attached to
  8463. * @returns The world position
  8464. */
  8465. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8466. /**
  8467. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8468. * @param position The local position
  8469. * @param mesh The mesh that this bone is attached to
  8470. * @param result The vector3 that the world position should be copied to
  8471. */
  8472. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8473. /**
  8474. * Get the local position of a point that is in world space
  8475. * @param position The world position
  8476. * @param mesh The mesh that this bone is attached to
  8477. * @returns The local position
  8478. */
  8479. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8480. /**
  8481. * Get the local position of a point that is in world space and copy it to the result param
  8482. * @param position The world position
  8483. * @param mesh The mesh that this bone is attached to
  8484. * @param result The vector3 that the local position should be copied to
  8485. */
  8486. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8487. }
  8488. }
  8489. declare module BABYLON {
  8490. /**
  8491. * Enum that determines the text-wrapping mode to use.
  8492. */
  8493. export enum InspectableType {
  8494. /**
  8495. * Checkbox for booleans
  8496. */
  8497. Checkbox = 0,
  8498. /**
  8499. * Sliders for numbers
  8500. */
  8501. Slider = 1,
  8502. /**
  8503. * Vector3
  8504. */
  8505. Vector3 = 2,
  8506. /**
  8507. * Quaternions
  8508. */
  8509. Quaternion = 3,
  8510. /**
  8511. * Color3
  8512. */
  8513. Color3 = 4
  8514. }
  8515. /**
  8516. * Interface used to define custom inspectable properties.
  8517. * This interface is used by the inspector to display custom property grids
  8518. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8519. */
  8520. export interface IInspectable {
  8521. /**
  8522. * Gets the label to display
  8523. */
  8524. label: string;
  8525. /**
  8526. * Gets the name of the property to edit
  8527. */
  8528. propertyName: string;
  8529. /**
  8530. * Gets the type of the editor to use
  8531. */
  8532. type: InspectableType;
  8533. /**
  8534. * Gets the minimum value of the property when using in "slider" mode
  8535. */
  8536. min?: number;
  8537. /**
  8538. * Gets the maximum value of the property when using in "slider" mode
  8539. */
  8540. max?: number;
  8541. /**
  8542. * Gets the setp to use when using in "slider" mode
  8543. */
  8544. step?: number;
  8545. }
  8546. }
  8547. declare module BABYLON {
  8548. /**
  8549. * This represents the required contract to create a new type of texture loader.
  8550. */
  8551. export interface IInternalTextureLoader {
  8552. /**
  8553. * Defines wether the loader supports cascade loading the different faces.
  8554. */
  8555. supportCascades: boolean;
  8556. /**
  8557. * This returns if the loader support the current file information.
  8558. * @param extension defines the file extension of the file being loaded
  8559. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8560. * @param fallback defines the fallback internal texture if any
  8561. * @param isBase64 defines whether the texture is encoded as a base64
  8562. * @param isBuffer defines whether the texture data are stored as a buffer
  8563. * @returns true if the loader can load the specified file
  8564. */
  8565. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8566. /**
  8567. * Transform the url before loading if required.
  8568. * @param rootUrl the url of the texture
  8569. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8570. * @returns the transformed texture
  8571. */
  8572. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8573. /**
  8574. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8575. * @param rootUrl the url of the texture
  8576. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8577. * @returns the fallback texture
  8578. */
  8579. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8580. /**
  8581. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8582. * @param data contains the texture data
  8583. * @param texture defines the BabylonJS internal texture
  8584. * @param createPolynomials will be true if polynomials have been requested
  8585. * @param onLoad defines the callback to trigger once the texture is ready
  8586. * @param onError defines the callback to trigger in case of error
  8587. */
  8588. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8589. /**
  8590. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8591. * @param data contains the texture data
  8592. * @param texture defines the BabylonJS internal texture
  8593. * @param callback defines the method to call once ready to upload
  8594. */
  8595. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8596. }
  8597. }
  8598. declare module BABYLON {
  8599. interface Engine {
  8600. /**
  8601. * Creates a depth stencil cube texture.
  8602. * This is only available in WebGL 2.
  8603. * @param size The size of face edge in the cube texture.
  8604. * @param options The options defining the cube texture.
  8605. * @returns The cube texture
  8606. */
  8607. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8608. /**
  8609. * Creates a cube texture
  8610. * @param rootUrl defines the url where the files to load is located
  8611. * @param scene defines the current scene
  8612. * @param files defines the list of files to load (1 per face)
  8613. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8614. * @param onLoad defines an optional callback raised when the texture is loaded
  8615. * @param onError defines an optional callback raised if there is an issue to load the texture
  8616. * @param format defines the format of the data
  8617. * @param forcedExtension defines the extension to use to pick the right loader
  8618. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8619. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8620. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8621. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8622. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8623. * @returns the cube texture as an InternalTexture
  8624. */
  8625. 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;
  8626. /**
  8627. * Creates a cube texture
  8628. * @param rootUrl defines the url where the files to load is located
  8629. * @param scene defines the current scene
  8630. * @param files defines the list of files to load (1 per face)
  8631. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8632. * @param onLoad defines an optional callback raised when the texture is loaded
  8633. * @param onError defines an optional callback raised if there is an issue to load the texture
  8634. * @param format defines the format of the data
  8635. * @param forcedExtension defines the extension to use to pick the right loader
  8636. * @returns the cube texture as an InternalTexture
  8637. */
  8638. 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;
  8639. /**
  8640. * Creates a cube texture
  8641. * @param rootUrl defines the url where the files to load is located
  8642. * @param scene defines the current scene
  8643. * @param files defines the list of files to load (1 per face)
  8644. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8645. * @param onLoad defines an optional callback raised when the texture is loaded
  8646. * @param onError defines an optional callback raised if there is an issue to load the texture
  8647. * @param format defines the format of the data
  8648. * @param forcedExtension defines the extension to use to pick the right loader
  8649. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8650. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8651. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8652. * @returns the cube texture as an InternalTexture
  8653. */
  8654. 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;
  8655. /** @hidden */
  8656. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8657. /** @hidden */
  8658. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8659. /** @hidden */
  8660. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8661. /** @hidden */
  8662. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8663. }
  8664. }
  8665. declare module BABYLON {
  8666. /**
  8667. * Class for creating a cube texture
  8668. */
  8669. export class CubeTexture extends BaseTexture {
  8670. private _delayedOnLoad;
  8671. /**
  8672. * The url of the texture
  8673. */
  8674. url: string;
  8675. /**
  8676. * Gets or sets the center of the bounding box associated with the cube texture.
  8677. * It must define where the camera used to render the texture was set
  8678. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8679. */
  8680. boundingBoxPosition: Vector3;
  8681. private _boundingBoxSize;
  8682. /**
  8683. * Gets or sets the size of the bounding box associated with the cube texture
  8684. * When defined, the cubemap will switch to local mode
  8685. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8686. * @example https://www.babylonjs-playground.com/#RNASML
  8687. */
  8688. /**
  8689. * Returns the bounding box size
  8690. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8691. */
  8692. boundingBoxSize: Vector3;
  8693. protected _rotationY: number;
  8694. /**
  8695. * Sets texture matrix rotation angle around Y axis in radians.
  8696. */
  8697. /**
  8698. * Gets texture matrix rotation angle around Y axis radians.
  8699. */
  8700. rotationY: number;
  8701. /**
  8702. * Are mip maps generated for this texture or not.
  8703. */
  8704. readonly noMipmap: boolean;
  8705. private _noMipmap;
  8706. private _files;
  8707. private _extensions;
  8708. private _textureMatrix;
  8709. private _format;
  8710. private _createPolynomials;
  8711. /** @hidden */
  8712. _prefiltered: boolean;
  8713. /**
  8714. * Creates a cube texture from an array of image urls
  8715. * @param files defines an array of image urls
  8716. * @param scene defines the hosting scene
  8717. * @param noMipmap specifies if mip maps are not used
  8718. * @returns a cube texture
  8719. */
  8720. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8721. /**
  8722. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8723. * @param url defines the url of the prefiltered texture
  8724. * @param scene defines the scene the texture is attached to
  8725. * @param forcedExtension defines the extension of the file if different from the url
  8726. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8727. * @return the prefiltered texture
  8728. */
  8729. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8730. /**
  8731. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8732. * as prefiltered data.
  8733. * @param rootUrl defines the url of the texture or the root name of the six images
  8734. * @param scene defines the scene the texture is attached to
  8735. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8736. * @param noMipmap defines if mipmaps should be created or not
  8737. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8738. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8739. * @param onError defines a callback triggered in case of error during load
  8740. * @param format defines the internal format to use for the texture once loaded
  8741. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8742. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8743. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8744. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8745. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8746. * @return the cube texture
  8747. */
  8748. 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);
  8749. /**
  8750. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8751. */
  8752. readonly isPrefiltered: boolean;
  8753. /**
  8754. * Get the current class name of the texture useful for serialization or dynamic coding.
  8755. * @returns "CubeTexture"
  8756. */
  8757. getClassName(): string;
  8758. /**
  8759. * Update the url (and optional buffer) of this texture if url was null during construction.
  8760. * @param url the url of the texture
  8761. * @param forcedExtension defines the extension to use
  8762. * @param onLoad callback called when the texture is loaded (defaults to null)
  8763. */
  8764. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8765. /**
  8766. * Delays loading of the cube texture
  8767. * @param forcedExtension defines the extension to use
  8768. */
  8769. delayLoad(forcedExtension?: string): void;
  8770. /**
  8771. * Returns the reflection texture matrix
  8772. * @returns the reflection texture matrix
  8773. */
  8774. getReflectionTextureMatrix(): Matrix;
  8775. /**
  8776. * Sets the reflection texture matrix
  8777. * @param value Reflection texture matrix
  8778. */
  8779. setReflectionTextureMatrix(value: Matrix): void;
  8780. /**
  8781. * Parses text to create a cube texture
  8782. * @param parsedTexture define the serialized text to read from
  8783. * @param scene defines the hosting scene
  8784. * @param rootUrl defines the root url of the cube texture
  8785. * @returns a cube texture
  8786. */
  8787. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8788. /**
  8789. * Makes a clone, or deep copy, of the cube texture
  8790. * @returns a new cube texture
  8791. */
  8792. clone(): CubeTexture;
  8793. }
  8794. }
  8795. declare module BABYLON {
  8796. /** @hidden */
  8797. export var postprocessVertexShader: {
  8798. name: string;
  8799. shader: string;
  8800. };
  8801. }
  8802. declare module BABYLON {
  8803. /**
  8804. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8805. * This is the base of the follow, arc rotate cameras and Free camera
  8806. * @see http://doc.babylonjs.com/features/cameras
  8807. */
  8808. export class TargetCamera extends Camera {
  8809. private static _RigCamTransformMatrix;
  8810. private static _TargetTransformMatrix;
  8811. private static _TargetFocalPoint;
  8812. /**
  8813. * Define the current direction the camera is moving to
  8814. */
  8815. cameraDirection: Vector3;
  8816. /**
  8817. * Define the current rotation the camera is rotating to
  8818. */
  8819. cameraRotation: Vector2;
  8820. /**
  8821. * When set, the up vector of the camera will be updated by the rotation of the camera
  8822. */
  8823. updateUpVectorFromRotation: boolean;
  8824. private _tmpQuaternion;
  8825. /**
  8826. * Define the current rotation of the camera
  8827. */
  8828. rotation: Vector3;
  8829. /**
  8830. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8831. */
  8832. rotationQuaternion: Quaternion;
  8833. /**
  8834. * Define the current speed of the camera
  8835. */
  8836. speed: number;
  8837. /**
  8838. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8839. * around all axis.
  8840. */
  8841. noRotationConstraint: boolean;
  8842. /**
  8843. * Define the current target of the camera as an object or a position.
  8844. */
  8845. lockedTarget: any;
  8846. /** @hidden */
  8847. _currentTarget: Vector3;
  8848. /** @hidden */
  8849. _initialFocalDistance: number;
  8850. /** @hidden */
  8851. _viewMatrix: Matrix;
  8852. /** @hidden */
  8853. _camMatrix: Matrix;
  8854. /** @hidden */
  8855. _cameraTransformMatrix: Matrix;
  8856. /** @hidden */
  8857. _cameraRotationMatrix: Matrix;
  8858. /** @hidden */
  8859. _referencePoint: Vector3;
  8860. /** @hidden */
  8861. _transformedReferencePoint: Vector3;
  8862. protected _globalCurrentTarget: Vector3;
  8863. protected _globalCurrentUpVector: Vector3;
  8864. /** @hidden */
  8865. _reset: () => void;
  8866. private _defaultUp;
  8867. /**
  8868. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8869. * This is the base of the follow, arc rotate cameras and Free camera
  8870. * @see http://doc.babylonjs.com/features/cameras
  8871. * @param name Defines the name of the camera in the scene
  8872. * @param position Defines the start position of the camera in the scene
  8873. * @param scene Defines the scene the camera belongs to
  8874. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8875. */
  8876. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8877. /**
  8878. * Gets the position in front of the camera at a given distance.
  8879. * @param distance The distance from the camera we want the position to be
  8880. * @returns the position
  8881. */
  8882. getFrontPosition(distance: number): Vector3;
  8883. /** @hidden */
  8884. _getLockedTargetPosition(): Nullable<Vector3>;
  8885. private _storedPosition;
  8886. private _storedRotation;
  8887. private _storedRotationQuaternion;
  8888. /**
  8889. * Store current camera state of the camera (fov, position, rotation, etc..)
  8890. * @returns the camera
  8891. */
  8892. storeState(): Camera;
  8893. /**
  8894. * Restored camera state. You must call storeState() first
  8895. * @returns whether it was successful or not
  8896. * @hidden
  8897. */
  8898. _restoreStateValues(): boolean;
  8899. /** @hidden */
  8900. _initCache(): void;
  8901. /** @hidden */
  8902. _updateCache(ignoreParentClass?: boolean): void;
  8903. /** @hidden */
  8904. _isSynchronizedViewMatrix(): boolean;
  8905. /** @hidden */
  8906. _computeLocalCameraSpeed(): number;
  8907. /**
  8908. * Defines the target the camera should look at.
  8909. * This will automatically adapt alpha beta and radius to fit within the new target.
  8910. * @param target Defines the new target as a Vector or a mesh
  8911. */
  8912. setTarget(target: Vector3): void;
  8913. /**
  8914. * Return the current target position of the camera. This value is expressed in local space.
  8915. * @returns the target position
  8916. */
  8917. getTarget(): Vector3;
  8918. /** @hidden */
  8919. _decideIfNeedsToMove(): boolean;
  8920. /** @hidden */
  8921. _updatePosition(): void;
  8922. /** @hidden */
  8923. _checkInputs(): void;
  8924. protected _updateCameraRotationMatrix(): void;
  8925. /**
  8926. * 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)
  8927. * @returns the current camera
  8928. */
  8929. private _rotateUpVectorWithCameraRotationMatrix;
  8930. private _cachedRotationZ;
  8931. private _cachedQuaternionRotationZ;
  8932. /** @hidden */
  8933. _getViewMatrix(): Matrix;
  8934. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8935. /**
  8936. * @hidden
  8937. */
  8938. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8939. /**
  8940. * @hidden
  8941. */
  8942. _updateRigCameras(): void;
  8943. private _getRigCamPositionAndTarget;
  8944. /**
  8945. * Gets the current object class name.
  8946. * @return the class name
  8947. */
  8948. getClassName(): string;
  8949. }
  8950. }
  8951. declare module BABYLON {
  8952. /**
  8953. * @ignore
  8954. * This is a list of all the different input types that are available in the application.
  8955. * Fo instance: ArcRotateCameraGamepadInput...
  8956. */
  8957. export var CameraInputTypes: {};
  8958. /**
  8959. * This is the contract to implement in order to create a new input class.
  8960. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8961. */
  8962. export interface ICameraInput<TCamera extends Camera> {
  8963. /**
  8964. * Defines the camera the input is attached to.
  8965. */
  8966. camera: Nullable<TCamera>;
  8967. /**
  8968. * Gets the class name of the current intput.
  8969. * @returns the class name
  8970. */
  8971. getClassName(): string;
  8972. /**
  8973. * Get the friendly name associated with the input class.
  8974. * @returns the input friendly name
  8975. */
  8976. getSimpleName(): string;
  8977. /**
  8978. * Attach the input controls to a specific dom element to get the input from.
  8979. * @param element Defines the element the controls should be listened from
  8980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8981. */
  8982. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8983. /**
  8984. * Detach the current controls from the specified dom element.
  8985. * @param element Defines the element to stop listening the inputs from
  8986. */
  8987. detachControl(element: Nullable<HTMLElement>): void;
  8988. /**
  8989. * Update the current camera state depending on the inputs that have been used this frame.
  8990. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8991. */
  8992. checkInputs?: () => void;
  8993. }
  8994. /**
  8995. * Represents a map of input types to input instance or input index to input instance.
  8996. */
  8997. export interface CameraInputsMap<TCamera extends Camera> {
  8998. /**
  8999. * Accessor to the input by input type.
  9000. */
  9001. [name: string]: ICameraInput<TCamera>;
  9002. /**
  9003. * Accessor to the input by input index.
  9004. */
  9005. [idx: number]: ICameraInput<TCamera>;
  9006. }
  9007. /**
  9008. * This represents the input manager used within a camera.
  9009. * It helps dealing with all the different kind of input attached to a camera.
  9010. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9011. */
  9012. export class CameraInputsManager<TCamera extends Camera> {
  9013. /**
  9014. * Defines the list of inputs attahed to the camera.
  9015. */
  9016. attached: CameraInputsMap<TCamera>;
  9017. /**
  9018. * Defines the dom element the camera is collecting inputs from.
  9019. * This is null if the controls have not been attached.
  9020. */
  9021. attachedElement: Nullable<HTMLElement>;
  9022. /**
  9023. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9024. */
  9025. noPreventDefault: boolean;
  9026. /**
  9027. * Defined the camera the input manager belongs to.
  9028. */
  9029. camera: TCamera;
  9030. /**
  9031. * Update the current camera state depending on the inputs that have been used this frame.
  9032. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9033. */
  9034. checkInputs: () => void;
  9035. /**
  9036. * Instantiate a new Camera Input Manager.
  9037. * @param camera Defines the camera the input manager blongs to
  9038. */
  9039. constructor(camera: TCamera);
  9040. /**
  9041. * Add an input method to a camera
  9042. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9043. * @param input camera input method
  9044. */
  9045. add(input: ICameraInput<TCamera>): void;
  9046. /**
  9047. * Remove a specific input method from a camera
  9048. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9049. * @param inputToRemove camera input method
  9050. */
  9051. remove(inputToRemove: ICameraInput<TCamera>): void;
  9052. /**
  9053. * Remove a specific input type from a camera
  9054. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9055. * @param inputType the type of the input to remove
  9056. */
  9057. removeByType(inputType: string): void;
  9058. private _addCheckInputs;
  9059. /**
  9060. * Attach the input controls to the currently attached dom element to listen the events from.
  9061. * @param input Defines the input to attach
  9062. */
  9063. attachInput(input: ICameraInput<TCamera>): void;
  9064. /**
  9065. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9066. * @param element Defines the dom element to collect the events from
  9067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9068. */
  9069. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  9070. /**
  9071. * Detach the current manager inputs controls from a specific dom element.
  9072. * @param element Defines the dom element to collect the events from
  9073. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9074. */
  9075. detachElement(element: HTMLElement, disconnect?: boolean): void;
  9076. /**
  9077. * Rebuild the dynamic inputCheck function from the current list of
  9078. * defined inputs in the manager.
  9079. */
  9080. rebuildInputCheck(): void;
  9081. /**
  9082. * Remove all attached input methods from a camera
  9083. */
  9084. clear(): void;
  9085. /**
  9086. * Serialize the current input manager attached to a camera.
  9087. * This ensures than once parsed,
  9088. * the input associated to the camera will be identical to the current ones
  9089. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9090. */
  9091. serialize(serializedCamera: any): void;
  9092. /**
  9093. * Parses an input manager serialized JSON to restore the previous list of inputs
  9094. * and states associated to a camera.
  9095. * @param parsedCamera Defines the JSON to parse
  9096. */
  9097. parse(parsedCamera: any): void;
  9098. }
  9099. }
  9100. declare module BABYLON {
  9101. /**
  9102. * Gather the list of keyboard event types as constants.
  9103. */
  9104. export class KeyboardEventTypes {
  9105. /**
  9106. * The keydown event is fired when a key becomes active (pressed).
  9107. */
  9108. static readonly KEYDOWN: number;
  9109. /**
  9110. * The keyup event is fired when a key has been released.
  9111. */
  9112. static readonly KEYUP: number;
  9113. }
  9114. /**
  9115. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9116. */
  9117. export class KeyboardInfo {
  9118. /**
  9119. * Defines the type of event (KeyboardEventTypes)
  9120. */
  9121. type: number;
  9122. /**
  9123. * Defines the related dom event
  9124. */
  9125. event: KeyboardEvent;
  9126. /**
  9127. * Instantiates a new keyboard info.
  9128. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9129. * @param type Defines the type of event (KeyboardEventTypes)
  9130. * @param event Defines the related dom event
  9131. */
  9132. constructor(
  9133. /**
  9134. * Defines the type of event (KeyboardEventTypes)
  9135. */
  9136. type: number,
  9137. /**
  9138. * Defines the related dom event
  9139. */
  9140. event: KeyboardEvent);
  9141. }
  9142. /**
  9143. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9144. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9145. */
  9146. export class KeyboardInfoPre extends KeyboardInfo {
  9147. /**
  9148. * Defines the type of event (KeyboardEventTypes)
  9149. */
  9150. type: number;
  9151. /**
  9152. * Defines the related dom event
  9153. */
  9154. event: KeyboardEvent;
  9155. /**
  9156. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9157. */
  9158. skipOnPointerObservable: boolean;
  9159. /**
  9160. * Instantiates a new keyboard pre info.
  9161. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9162. * @param type Defines the type of event (KeyboardEventTypes)
  9163. * @param event Defines the related dom event
  9164. */
  9165. constructor(
  9166. /**
  9167. * Defines the type of event (KeyboardEventTypes)
  9168. */
  9169. type: number,
  9170. /**
  9171. * Defines the related dom event
  9172. */
  9173. event: KeyboardEvent);
  9174. }
  9175. }
  9176. declare module BABYLON {
  9177. /**
  9178. * Manage the keyboard inputs to control the movement of a free camera.
  9179. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9180. */
  9181. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9182. /**
  9183. * Defines the camera the input is attached to.
  9184. */
  9185. camera: FreeCamera;
  9186. /**
  9187. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9188. */
  9189. keysUp: number[];
  9190. /**
  9191. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9192. */
  9193. keysDown: number[];
  9194. /**
  9195. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9196. */
  9197. keysLeft: number[];
  9198. /**
  9199. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9200. */
  9201. keysRight: number[];
  9202. private _keys;
  9203. private _onCanvasBlurObserver;
  9204. private _onKeyboardObserver;
  9205. private _engine;
  9206. private _scene;
  9207. /**
  9208. * Attach the input controls to a specific dom element to get the input from.
  9209. * @param element Defines the element the controls should be listened from
  9210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9211. */
  9212. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9213. /**
  9214. * Detach the current controls from the specified dom element.
  9215. * @param element Defines the element to stop listening the inputs from
  9216. */
  9217. detachControl(element: Nullable<HTMLElement>): void;
  9218. /**
  9219. * Update the current camera state depending on the inputs that have been used this frame.
  9220. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9221. */
  9222. checkInputs(): void;
  9223. /**
  9224. * Gets the class name of the current intput.
  9225. * @returns the class name
  9226. */
  9227. getClassName(): string;
  9228. /** @hidden */
  9229. _onLostFocus(): void;
  9230. /**
  9231. * Get the friendly name associated with the input class.
  9232. * @returns the input friendly name
  9233. */
  9234. getSimpleName(): string;
  9235. }
  9236. }
  9237. declare module BABYLON {
  9238. /**
  9239. * Interface describing all the common properties and methods a shadow light needs to implement.
  9240. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9241. * as well as binding the different shadow properties to the effects.
  9242. */
  9243. export interface IShadowLight extends Light {
  9244. /**
  9245. * The light id in the scene (used in scene.findLighById for instance)
  9246. */
  9247. id: string;
  9248. /**
  9249. * The position the shdow will be casted from.
  9250. */
  9251. position: Vector3;
  9252. /**
  9253. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9254. */
  9255. direction: Vector3;
  9256. /**
  9257. * The transformed position. Position of the light in world space taking parenting in account.
  9258. */
  9259. transformedPosition: Vector3;
  9260. /**
  9261. * The transformed direction. Direction of the light in world space taking parenting in account.
  9262. */
  9263. transformedDirection: Vector3;
  9264. /**
  9265. * The friendly name of the light in the scene.
  9266. */
  9267. name: string;
  9268. /**
  9269. * Defines the shadow projection clipping minimum z value.
  9270. */
  9271. shadowMinZ: number;
  9272. /**
  9273. * Defines the shadow projection clipping maximum z value.
  9274. */
  9275. shadowMaxZ: number;
  9276. /**
  9277. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9278. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9279. */
  9280. computeTransformedInformation(): boolean;
  9281. /**
  9282. * Gets the scene the light belongs to.
  9283. * @returns The scene
  9284. */
  9285. getScene(): Scene;
  9286. /**
  9287. * Callback defining a custom Projection Matrix Builder.
  9288. * This can be used to override the default projection matrix computation.
  9289. */
  9290. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9291. /**
  9292. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9293. * @param matrix The materix to updated with the projection information
  9294. * @param viewMatrix The transform matrix of the light
  9295. * @param renderList The list of mesh to render in the map
  9296. * @returns The current light
  9297. */
  9298. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9299. /**
  9300. * Gets the current depth scale used in ESM.
  9301. * @returns The scale
  9302. */
  9303. getDepthScale(): number;
  9304. /**
  9305. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9306. * @returns true if a cube texture needs to be use
  9307. */
  9308. needCube(): boolean;
  9309. /**
  9310. * Detects if the projection matrix requires to be recomputed this frame.
  9311. * @returns true if it requires to be recomputed otherwise, false.
  9312. */
  9313. needProjectionMatrixCompute(): boolean;
  9314. /**
  9315. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9316. */
  9317. forceProjectionMatrixCompute(): void;
  9318. /**
  9319. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9320. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9321. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9322. */
  9323. getShadowDirection(faceIndex?: number): Vector3;
  9324. /**
  9325. * Gets the minZ used for shadow according to both the scene and the light.
  9326. * @param activeCamera The camera we are returning the min for
  9327. * @returns the depth min z
  9328. */
  9329. getDepthMinZ(activeCamera: Camera): number;
  9330. /**
  9331. * Gets the maxZ used for shadow according to both the scene and the light.
  9332. * @param activeCamera The camera we are returning the max for
  9333. * @returns the depth max z
  9334. */
  9335. getDepthMaxZ(activeCamera: Camera): number;
  9336. }
  9337. /**
  9338. * Base implementation IShadowLight
  9339. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9340. */
  9341. export abstract class ShadowLight extends Light implements IShadowLight {
  9342. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9343. protected _position: Vector3;
  9344. protected _setPosition(value: Vector3): void;
  9345. /**
  9346. * Sets the position the shadow will be casted from. Also use as the light position for both
  9347. * point and spot lights.
  9348. */
  9349. /**
  9350. * Sets the position the shadow will be casted from. Also use as the light position for both
  9351. * point and spot lights.
  9352. */
  9353. position: Vector3;
  9354. protected _direction: Vector3;
  9355. protected _setDirection(value: Vector3): void;
  9356. /**
  9357. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9358. * Also use as the light direction on spot and directional lights.
  9359. */
  9360. /**
  9361. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9362. * Also use as the light direction on spot and directional lights.
  9363. */
  9364. direction: Vector3;
  9365. private _shadowMinZ;
  9366. /**
  9367. * Gets the shadow projection clipping minimum z value.
  9368. */
  9369. /**
  9370. * Sets the shadow projection clipping minimum z value.
  9371. */
  9372. shadowMinZ: number;
  9373. private _shadowMaxZ;
  9374. /**
  9375. * Sets the shadow projection clipping maximum z value.
  9376. */
  9377. /**
  9378. * Gets the shadow projection clipping maximum z value.
  9379. */
  9380. shadowMaxZ: number;
  9381. /**
  9382. * Callback defining a custom Projection Matrix Builder.
  9383. * This can be used to override the default projection matrix computation.
  9384. */
  9385. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9386. /**
  9387. * The transformed position. Position of the light in world space taking parenting in account.
  9388. */
  9389. transformedPosition: Vector3;
  9390. /**
  9391. * The transformed direction. Direction of the light in world space taking parenting in account.
  9392. */
  9393. transformedDirection: Vector3;
  9394. private _needProjectionMatrixCompute;
  9395. /**
  9396. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9397. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9398. */
  9399. computeTransformedInformation(): boolean;
  9400. /**
  9401. * Return the depth scale used for the shadow map.
  9402. * @returns the depth scale.
  9403. */
  9404. getDepthScale(): number;
  9405. /**
  9406. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9407. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9408. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9409. */
  9410. getShadowDirection(faceIndex?: number): Vector3;
  9411. /**
  9412. * Returns the ShadowLight absolute position in the World.
  9413. * @returns the position vector in world space
  9414. */
  9415. getAbsolutePosition(): Vector3;
  9416. /**
  9417. * Sets the ShadowLight direction toward the passed target.
  9418. * @param target The point to target in local space
  9419. * @returns the updated ShadowLight direction
  9420. */
  9421. setDirectionToTarget(target: Vector3): Vector3;
  9422. /**
  9423. * Returns the light rotation in euler definition.
  9424. * @returns the x y z rotation in local space.
  9425. */
  9426. getRotation(): Vector3;
  9427. /**
  9428. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9429. * @returns true if a cube texture needs to be use
  9430. */
  9431. needCube(): boolean;
  9432. /**
  9433. * Detects if the projection matrix requires to be recomputed this frame.
  9434. * @returns true if it requires to be recomputed otherwise, false.
  9435. */
  9436. needProjectionMatrixCompute(): boolean;
  9437. /**
  9438. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9439. */
  9440. forceProjectionMatrixCompute(): void;
  9441. /** @hidden */
  9442. _initCache(): void;
  9443. /** @hidden */
  9444. _isSynchronized(): boolean;
  9445. /**
  9446. * Computes the world matrix of the node
  9447. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9448. * @returns the world matrix
  9449. */
  9450. computeWorldMatrix(force?: boolean): Matrix;
  9451. /**
  9452. * Gets the minZ used for shadow according to both the scene and the light.
  9453. * @param activeCamera The camera we are returning the min for
  9454. * @returns the depth min z
  9455. */
  9456. getDepthMinZ(activeCamera: Camera): number;
  9457. /**
  9458. * Gets the maxZ used for shadow according to both the scene and the light.
  9459. * @param activeCamera The camera we are returning the max for
  9460. * @returns the depth max z
  9461. */
  9462. getDepthMaxZ(activeCamera: Camera): number;
  9463. /**
  9464. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9465. * @param matrix The materix to updated with the projection information
  9466. * @param viewMatrix The transform matrix of the light
  9467. * @param renderList The list of mesh to render in the map
  9468. * @returns The current light
  9469. */
  9470. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9471. }
  9472. }
  9473. declare module BABYLON {
  9474. /**
  9475. * "Static Class" containing the most commonly used helper while dealing with material for
  9476. * rendering purpose.
  9477. *
  9478. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9479. *
  9480. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9481. */
  9482. export class MaterialHelper {
  9483. /**
  9484. * Bind the current view position to an effect.
  9485. * @param effect The effect to be bound
  9486. * @param scene The scene the eyes position is used from
  9487. */
  9488. static BindEyePosition(effect: Effect, scene: Scene): void;
  9489. /**
  9490. * Helps preparing the defines values about the UVs in used in the effect.
  9491. * UVs are shared as much as we can accross channels in the shaders.
  9492. * @param texture The texture we are preparing the UVs for
  9493. * @param defines The defines to update
  9494. * @param key The channel key "diffuse", "specular"... used in the shader
  9495. */
  9496. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9497. /**
  9498. * Binds a texture matrix value to its corrsponding uniform
  9499. * @param texture The texture to bind the matrix for
  9500. * @param uniformBuffer The uniform buffer receivin the data
  9501. * @param key The channel key "diffuse", "specular"... used in the shader
  9502. */
  9503. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9504. /**
  9505. * Gets the current status of the fog (should it be enabled?)
  9506. * @param mesh defines the mesh to evaluate for fog support
  9507. * @param scene defines the hosting scene
  9508. * @returns true if fog must be enabled
  9509. */
  9510. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9511. /**
  9512. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9513. * @param mesh defines the current mesh
  9514. * @param scene defines the current scene
  9515. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9516. * @param pointsCloud defines if point cloud rendering has to be turned on
  9517. * @param fogEnabled defines if fog has to be turned on
  9518. * @param alphaTest defines if alpha testing has to be turned on
  9519. * @param defines defines the current list of defines
  9520. */
  9521. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9522. /**
  9523. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9524. * @param scene defines the current scene
  9525. * @param engine defines the current engine
  9526. * @param defines specifies the list of active defines
  9527. * @param useInstances defines if instances have to be turned on
  9528. * @param useClipPlane defines if clip plane have to be turned on
  9529. */
  9530. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9531. /**
  9532. * Prepares the defines for bones
  9533. * @param mesh The mesh containing the geometry data we will draw
  9534. * @param defines The defines to update
  9535. */
  9536. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9537. /**
  9538. * Prepares the defines for morph targets
  9539. * @param mesh The mesh containing the geometry data we will draw
  9540. * @param defines The defines to update
  9541. */
  9542. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9543. /**
  9544. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9545. * @param mesh The mesh containing the geometry data we will draw
  9546. * @param defines The defines to update
  9547. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9548. * @param useBones Precise whether bones should be used or not (override mesh info)
  9549. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9550. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9551. * @returns false if defines are considered not dirty and have not been checked
  9552. */
  9553. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9554. /**
  9555. * Prepares the defines related to multiview
  9556. * @param scene The scene we are intending to draw
  9557. * @param defines The defines to update
  9558. */
  9559. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9560. /**
  9561. * Prepares the defines related to the light information passed in parameter
  9562. * @param scene The scene we are intending to draw
  9563. * @param mesh The mesh the effect is compiling for
  9564. * @param defines The defines to update
  9565. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9566. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9567. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9568. * @returns true if normals will be required for the rest of the effect
  9569. */
  9570. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9571. /**
  9572. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9573. * that won t be acctive due to defines being turned off.
  9574. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9575. * @param samplersList The samplers list
  9576. * @param defines The defines helping in the list generation
  9577. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9578. */
  9579. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9580. /**
  9581. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9582. * @param defines The defines to update while falling back
  9583. * @param fallbacks The authorized effect fallbacks
  9584. * @param maxSimultaneousLights The maximum number of lights allowed
  9585. * @param rank the current rank of the Effect
  9586. * @returns The newly affected rank
  9587. */
  9588. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9589. /**
  9590. * Prepares the list of attributes required for morph targets according to the effect defines.
  9591. * @param attribs The current list of supported attribs
  9592. * @param mesh The mesh to prepare the morph targets attributes for
  9593. * @param defines The current Defines of the effect
  9594. */
  9595. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9596. /**
  9597. * Prepares the list of attributes required for bones according to the effect defines.
  9598. * @param attribs The current list of supported attribs
  9599. * @param mesh The mesh to prepare the bones attributes for
  9600. * @param defines The current Defines of the effect
  9601. * @param fallbacks The current efffect fallback strategy
  9602. */
  9603. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9604. /**
  9605. * Check and prepare the list of attributes required for instances according to the effect defines.
  9606. * @param attribs The current list of supported attribs
  9607. * @param defines The current MaterialDefines of the effect
  9608. */
  9609. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9610. /**
  9611. * Add the list of attributes required for instances to the attribs array.
  9612. * @param attribs The current list of supported attribs
  9613. */
  9614. static PushAttributesForInstances(attribs: string[]): void;
  9615. /**
  9616. * Binds the light shadow information to the effect for the given mesh.
  9617. * @param light The light containing the generator
  9618. * @param scene The scene the lights belongs to
  9619. * @param mesh The mesh we are binding the information to render
  9620. * @param lightIndex The light index in the effect used to render the mesh
  9621. * @param effect The effect we are binding the data to
  9622. */
  9623. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9624. /**
  9625. * Binds the light information to the effect.
  9626. * @param light The light containing the generator
  9627. * @param effect The effect we are binding the data to
  9628. * @param lightIndex The light index in the effect used to render
  9629. */
  9630. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9631. /**
  9632. * Binds the lights information from the scene to the effect for the given mesh.
  9633. * @param scene The scene the lights belongs to
  9634. * @param mesh The mesh we are binding the information to render
  9635. * @param effect The effect we are binding the data to
  9636. * @param defines The generated defines for the effect
  9637. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9638. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9639. */
  9640. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9641. private static _tempFogColor;
  9642. /**
  9643. * Binds the fog information from the scene to the effect for the given mesh.
  9644. * @param scene The scene the lights belongs to
  9645. * @param mesh The mesh we are binding the information to render
  9646. * @param effect The effect we are binding the data to
  9647. * @param linearSpace Defines if the fog effect is applied in linear space
  9648. */
  9649. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9650. /**
  9651. * Binds the bones information from the mesh to the effect.
  9652. * @param mesh The mesh we are binding the information to render
  9653. * @param effect The effect we are binding the data to
  9654. */
  9655. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9656. /**
  9657. * Binds the morph targets information from the mesh to the effect.
  9658. * @param abstractMesh The mesh we are binding the information to render
  9659. * @param effect The effect we are binding the data to
  9660. */
  9661. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9662. /**
  9663. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9664. * @param defines The generated defines used in the effect
  9665. * @param effect The effect we are binding the data to
  9666. * @param scene The scene we are willing to render with logarithmic scale for
  9667. */
  9668. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9669. /**
  9670. * Binds the clip plane information from the scene to the effect.
  9671. * @param scene The scene the clip plane information are extracted from
  9672. * @param effect The effect we are binding the data to
  9673. */
  9674. static BindClipPlane(effect: Effect, scene: Scene): void;
  9675. }
  9676. }
  9677. declare module BABYLON {
  9678. /** @hidden */
  9679. export var kernelBlurVaryingDeclaration: {
  9680. name: string;
  9681. shader: string;
  9682. };
  9683. }
  9684. declare module BABYLON {
  9685. /** @hidden */
  9686. export var kernelBlurFragment: {
  9687. name: string;
  9688. shader: string;
  9689. };
  9690. }
  9691. declare module BABYLON {
  9692. /** @hidden */
  9693. export var kernelBlurFragment2: {
  9694. name: string;
  9695. shader: string;
  9696. };
  9697. }
  9698. declare module BABYLON {
  9699. /** @hidden */
  9700. export var kernelBlurPixelShader: {
  9701. name: string;
  9702. shader: string;
  9703. };
  9704. }
  9705. declare module BABYLON {
  9706. /** @hidden */
  9707. export var kernelBlurVertex: {
  9708. name: string;
  9709. shader: string;
  9710. };
  9711. }
  9712. declare module BABYLON {
  9713. /** @hidden */
  9714. export var kernelBlurVertexShader: {
  9715. name: string;
  9716. shader: string;
  9717. };
  9718. }
  9719. declare module BABYLON {
  9720. /**
  9721. * The Blur Post Process which blurs an image based on a kernel and direction.
  9722. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9723. */
  9724. export class BlurPostProcess extends PostProcess {
  9725. /** The direction in which to blur the image. */
  9726. direction: Vector2;
  9727. private blockCompilation;
  9728. protected _kernel: number;
  9729. protected _idealKernel: number;
  9730. protected _packedFloat: boolean;
  9731. private _staticDefines;
  9732. /**
  9733. * Sets the length in pixels of the blur sample region
  9734. */
  9735. /**
  9736. * Gets the length in pixels of the blur sample region
  9737. */
  9738. kernel: number;
  9739. /**
  9740. * Sets wether or not the blur needs to unpack/repack floats
  9741. */
  9742. /**
  9743. * Gets wether or not the blur is unpacking/repacking floats
  9744. */
  9745. packedFloat: boolean;
  9746. /**
  9747. * Creates a new instance BlurPostProcess
  9748. * @param name The name of the effect.
  9749. * @param direction The direction in which to blur the image.
  9750. * @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.
  9751. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9752. * @param camera The camera to apply the render pass to.
  9753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9754. * @param engine The engine which the post process will be applied. (default: current engine)
  9755. * @param reusable If the post process can be reused on the same frame. (default: false)
  9756. * @param textureType Type of textures used when performing the post process. (default: 0)
  9757. * @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)
  9758. */
  9759. constructor(name: string,
  9760. /** The direction in which to blur the image. */
  9761. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9762. /**
  9763. * Updates the effect with the current post process compile time values and recompiles the shader.
  9764. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9765. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9766. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9767. * @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
  9768. * @param onCompiled Called when the shader has been compiled.
  9769. * @param onError Called if there is an error when compiling a shader.
  9770. */
  9771. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9772. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9773. /**
  9774. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9775. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9776. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9777. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9778. * The gaps between physical kernels are compensated for in the weighting of the samples
  9779. * @param idealKernel Ideal blur kernel.
  9780. * @return Nearest best kernel.
  9781. */
  9782. protected _nearestBestKernel(idealKernel: number): number;
  9783. /**
  9784. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9785. * @param x The point on the Gaussian distribution to sample.
  9786. * @return the value of the Gaussian function at x.
  9787. */
  9788. protected _gaussianWeight(x: number): number;
  9789. /**
  9790. * Generates a string that can be used as a floating point number in GLSL.
  9791. * @param x Value to print.
  9792. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9793. * @return GLSL float string.
  9794. */
  9795. protected _glslFloat(x: number, decimalFigures?: number): string;
  9796. }
  9797. }
  9798. declare module BABYLON {
  9799. /** @hidden */
  9800. export var shadowMapPixelShader: {
  9801. name: string;
  9802. shader: string;
  9803. };
  9804. }
  9805. declare module BABYLON {
  9806. /** @hidden */
  9807. export var bonesDeclaration: {
  9808. name: string;
  9809. shader: string;
  9810. };
  9811. }
  9812. declare module BABYLON {
  9813. /** @hidden */
  9814. export var morphTargetsVertexGlobalDeclaration: {
  9815. name: string;
  9816. shader: string;
  9817. };
  9818. }
  9819. declare module BABYLON {
  9820. /** @hidden */
  9821. export var morphTargetsVertexDeclaration: {
  9822. name: string;
  9823. shader: string;
  9824. };
  9825. }
  9826. declare module BABYLON {
  9827. /** @hidden */
  9828. export var instancesDeclaration: {
  9829. name: string;
  9830. shader: string;
  9831. };
  9832. }
  9833. declare module BABYLON {
  9834. /** @hidden */
  9835. export var helperFunctions: {
  9836. name: string;
  9837. shader: string;
  9838. };
  9839. }
  9840. declare module BABYLON {
  9841. /** @hidden */
  9842. export var morphTargetsVertex: {
  9843. name: string;
  9844. shader: string;
  9845. };
  9846. }
  9847. declare module BABYLON {
  9848. /** @hidden */
  9849. export var instancesVertex: {
  9850. name: string;
  9851. shader: string;
  9852. };
  9853. }
  9854. declare module BABYLON {
  9855. /** @hidden */
  9856. export var bonesVertex: {
  9857. name: string;
  9858. shader: string;
  9859. };
  9860. }
  9861. declare module BABYLON {
  9862. /** @hidden */
  9863. export var shadowMapVertexShader: {
  9864. name: string;
  9865. shader: string;
  9866. };
  9867. }
  9868. declare module BABYLON {
  9869. /** @hidden */
  9870. export var depthBoxBlurPixelShader: {
  9871. name: string;
  9872. shader: string;
  9873. };
  9874. }
  9875. declare module BABYLON {
  9876. /**
  9877. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9878. */
  9879. export interface ICustomShaderOptions {
  9880. /**
  9881. * Gets or sets the custom shader name to use
  9882. */
  9883. shaderName: string;
  9884. /**
  9885. * The list of attribute names used in the shader
  9886. */
  9887. attributes?: string[];
  9888. /**
  9889. * The list of unifrom names used in the shader
  9890. */
  9891. uniforms?: string[];
  9892. /**
  9893. * The list of sampler names used in the shader
  9894. */
  9895. samplers?: string[];
  9896. /**
  9897. * The list of defines used in the shader
  9898. */
  9899. defines?: string[];
  9900. }
  9901. /**
  9902. * Interface to implement to create a shadow generator compatible with BJS.
  9903. */
  9904. export interface IShadowGenerator {
  9905. /**
  9906. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9907. * @returns The render target texture if present otherwise, null
  9908. */
  9909. getShadowMap(): Nullable<RenderTargetTexture>;
  9910. /**
  9911. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9912. * @returns The render target texture if the shadow map is present otherwise, null
  9913. */
  9914. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9915. /**
  9916. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9917. * @param subMesh The submesh we want to render in the shadow map
  9918. * @param useInstances Defines wether will draw in the map using instances
  9919. * @returns true if ready otherwise, false
  9920. */
  9921. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9922. /**
  9923. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9924. * @param defines Defines of the material we want to update
  9925. * @param lightIndex Index of the light in the enabled light list of the material
  9926. */
  9927. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9928. /**
  9929. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9930. * defined in the generator but impacting the effect).
  9931. * It implies the unifroms available on the materials are the standard BJS ones.
  9932. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9933. * @param effect The effect we are binfing the information for
  9934. */
  9935. bindShadowLight(lightIndex: string, effect: Effect): void;
  9936. /**
  9937. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9938. * (eq to shadow prjection matrix * light transform matrix)
  9939. * @returns The transform matrix used to create the shadow map
  9940. */
  9941. getTransformMatrix(): Matrix;
  9942. /**
  9943. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9944. * Cube and 2D textures for instance.
  9945. */
  9946. recreateShadowMap(): void;
  9947. /**
  9948. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9949. * @param onCompiled Callback triggered at the and of the effects compilation
  9950. * @param options Sets of optional options forcing the compilation with different modes
  9951. */
  9952. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9953. useInstances: boolean;
  9954. }>): void;
  9955. /**
  9956. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9957. * @param options Sets of optional options forcing the compilation with different modes
  9958. * @returns A promise that resolves when the compilation completes
  9959. */
  9960. forceCompilationAsync(options?: Partial<{
  9961. useInstances: boolean;
  9962. }>): Promise<void>;
  9963. /**
  9964. * Serializes the shadow generator setup to a json object.
  9965. * @returns The serialized JSON object
  9966. */
  9967. serialize(): any;
  9968. /**
  9969. * Disposes the Shadow map and related Textures and effects.
  9970. */
  9971. dispose(): void;
  9972. }
  9973. /**
  9974. * Default implementation IShadowGenerator.
  9975. * This is the main object responsible of generating shadows in the framework.
  9976. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9977. */
  9978. export class ShadowGenerator implements IShadowGenerator {
  9979. /**
  9980. * Shadow generator mode None: no filtering applied.
  9981. */
  9982. static readonly FILTER_NONE: number;
  9983. /**
  9984. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9985. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9986. */
  9987. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9988. /**
  9989. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9990. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9991. */
  9992. static readonly FILTER_POISSONSAMPLING: number;
  9993. /**
  9994. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9995. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9996. */
  9997. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9998. /**
  9999. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  10000. * edge artifacts on steep falloff.
  10001. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10002. */
  10003. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  10004. /**
  10005. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  10006. * edge artifacts on steep falloff.
  10007. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10008. */
  10009. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  10010. /**
  10011. * Shadow generator mode PCF: Percentage Closer Filtering
  10012. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10013. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  10014. */
  10015. static readonly FILTER_PCF: number;
  10016. /**
  10017. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  10018. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10019. * Contact Hardening
  10020. */
  10021. static readonly FILTER_PCSS: number;
  10022. /**
  10023. * Reserved for PCF and PCSS
  10024. * Highest Quality.
  10025. *
  10026. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  10027. *
  10028. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  10029. */
  10030. static readonly QUALITY_HIGH: number;
  10031. /**
  10032. * Reserved for PCF and PCSS
  10033. * Good tradeoff for quality/perf cross devices
  10034. *
  10035. * Execute PCF on a 3*3 kernel.
  10036. *
  10037. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  10038. */
  10039. static readonly QUALITY_MEDIUM: number;
  10040. /**
  10041. * Reserved for PCF and PCSS
  10042. * The lowest quality but the fastest.
  10043. *
  10044. * Execute PCF on a 1*1 kernel.
  10045. *
  10046. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  10047. */
  10048. static readonly QUALITY_LOW: number;
  10049. /** Gets or sets the custom shader name to use */
  10050. customShaderOptions: ICustomShaderOptions;
  10051. /**
  10052. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  10053. */
  10054. onBeforeShadowMapRenderObservable: Observable<Effect>;
  10055. /**
  10056. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  10057. */
  10058. onAfterShadowMapRenderObservable: Observable<Effect>;
  10059. /**
  10060. * Observable triggered before a mesh is rendered in the shadow map.
  10061. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  10062. */
  10063. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  10064. /**
  10065. * Observable triggered after a mesh is rendered in the shadow map.
  10066. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  10067. */
  10068. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  10069. private _bias;
  10070. /**
  10071. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10072. */
  10073. /**
  10074. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10075. */
  10076. bias: number;
  10077. private _normalBias;
  10078. /**
  10079. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10080. */
  10081. /**
  10082. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10083. */
  10084. normalBias: number;
  10085. private _blurBoxOffset;
  10086. /**
  10087. * Gets the blur box offset: offset applied during the blur pass.
  10088. * Only useful if useKernelBlur = false
  10089. */
  10090. /**
  10091. * Sets the blur box offset: offset applied during the blur pass.
  10092. * Only useful if useKernelBlur = false
  10093. */
  10094. blurBoxOffset: number;
  10095. private _blurScale;
  10096. /**
  10097. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10098. * 2 means half of the size.
  10099. */
  10100. /**
  10101. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10102. * 2 means half of the size.
  10103. */
  10104. blurScale: number;
  10105. private _blurKernel;
  10106. /**
  10107. * Gets the blur kernel: kernel size of the blur pass.
  10108. * Only useful if useKernelBlur = true
  10109. */
  10110. /**
  10111. * Sets the blur kernel: kernel size of the blur pass.
  10112. * Only useful if useKernelBlur = true
  10113. */
  10114. blurKernel: number;
  10115. private _useKernelBlur;
  10116. /**
  10117. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10118. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10119. */
  10120. /**
  10121. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10122. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10123. */
  10124. useKernelBlur: boolean;
  10125. private _depthScale;
  10126. /**
  10127. * Gets the depth scale used in ESM mode.
  10128. */
  10129. /**
  10130. * Sets the depth scale used in ESM mode.
  10131. * This can override the scale stored on the light.
  10132. */
  10133. depthScale: number;
  10134. private _filter;
  10135. /**
  10136. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10137. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10138. */
  10139. /**
  10140. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10141. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10142. */
  10143. filter: number;
  10144. /**
  10145. * Gets if the current filter is set to Poisson Sampling.
  10146. */
  10147. /**
  10148. * Sets the current filter to Poisson Sampling.
  10149. */
  10150. usePoissonSampling: boolean;
  10151. /**
  10152. * Gets if the current filter is set to ESM.
  10153. */
  10154. /**
  10155. * Sets the current filter is to ESM.
  10156. */
  10157. useExponentialShadowMap: boolean;
  10158. /**
  10159. * Gets if the current filter is set to filtered ESM.
  10160. */
  10161. /**
  10162. * Gets if the current filter is set to filtered ESM.
  10163. */
  10164. useBlurExponentialShadowMap: boolean;
  10165. /**
  10166. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10167. * exponential to prevent steep falloff artifacts).
  10168. */
  10169. /**
  10170. * Sets the current filter to "close ESM" (using the inverse of the
  10171. * exponential to prevent steep falloff artifacts).
  10172. */
  10173. useCloseExponentialShadowMap: boolean;
  10174. /**
  10175. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10176. * exponential to prevent steep falloff artifacts).
  10177. */
  10178. /**
  10179. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10180. * exponential to prevent steep falloff artifacts).
  10181. */
  10182. useBlurCloseExponentialShadowMap: boolean;
  10183. /**
  10184. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10185. */
  10186. /**
  10187. * Sets the current filter to "PCF" (percentage closer filtering).
  10188. */
  10189. usePercentageCloserFiltering: boolean;
  10190. private _filteringQuality;
  10191. /**
  10192. * Gets the PCF or PCSS Quality.
  10193. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10194. */
  10195. /**
  10196. * Sets the PCF or PCSS Quality.
  10197. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10198. */
  10199. filteringQuality: number;
  10200. /**
  10201. * Gets if the current filter is set to "PCSS" (contact hardening).
  10202. */
  10203. /**
  10204. * Sets the current filter to "PCSS" (contact hardening).
  10205. */
  10206. useContactHardeningShadow: boolean;
  10207. private _contactHardeningLightSizeUVRatio;
  10208. /**
  10209. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10210. * Using a ratio helps keeping shape stability independently of the map size.
  10211. *
  10212. * It does not account for the light projection as it was having too much
  10213. * instability during the light setup or during light position changes.
  10214. *
  10215. * Only valid if useContactHardeningShadow is true.
  10216. */
  10217. /**
  10218. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10219. * Using a ratio helps keeping shape stability independently of the map size.
  10220. *
  10221. * It does not account for the light projection as it was having too much
  10222. * instability during the light setup or during light position changes.
  10223. *
  10224. * Only valid if useContactHardeningShadow is true.
  10225. */
  10226. contactHardeningLightSizeUVRatio: number;
  10227. private _darkness;
  10228. /** Gets or sets the actual darkness of a shadow */
  10229. darkness: number;
  10230. /**
  10231. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10232. * 0 means strongest and 1 would means no shadow.
  10233. * @returns the darkness.
  10234. */
  10235. getDarkness(): number;
  10236. /**
  10237. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10238. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10239. * @returns the shadow generator allowing fluent coding.
  10240. */
  10241. setDarkness(darkness: number): ShadowGenerator;
  10242. private _transparencyShadow;
  10243. /** Gets or sets the ability to have transparent shadow */
  10244. transparencyShadow: boolean;
  10245. /**
  10246. * Sets the ability to have transparent shadow (boolean).
  10247. * @param transparent True if transparent else False
  10248. * @returns the shadow generator allowing fluent coding
  10249. */
  10250. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10251. private _shadowMap;
  10252. private _shadowMap2;
  10253. /**
  10254. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10255. * @returns The render target texture if present otherwise, null
  10256. */
  10257. getShadowMap(): Nullable<RenderTargetTexture>;
  10258. /**
  10259. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10260. * @returns The render target texture if the shadow map is present otherwise, null
  10261. */
  10262. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10263. /**
  10264. * Gets the class name of that object
  10265. * @returns "ShadowGenerator"
  10266. */
  10267. getClassName(): string;
  10268. /**
  10269. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10270. * @param mesh Mesh to add
  10271. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10272. * @returns the Shadow Generator itself
  10273. */
  10274. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10275. /**
  10276. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10277. * @param mesh Mesh to remove
  10278. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10279. * @returns the Shadow Generator itself
  10280. */
  10281. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10282. /**
  10283. * Controls the extent to which the shadows fade out at the edge of the frustum
  10284. * Used only by directionals and spots
  10285. */
  10286. frustumEdgeFalloff: number;
  10287. private _light;
  10288. /**
  10289. * Returns the associated light object.
  10290. * @returns the light generating the shadow
  10291. */
  10292. getLight(): IShadowLight;
  10293. /**
  10294. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10295. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10296. * It might on the other hand introduce peter panning.
  10297. */
  10298. forceBackFacesOnly: boolean;
  10299. private _scene;
  10300. private _lightDirection;
  10301. private _effect;
  10302. private _viewMatrix;
  10303. private _projectionMatrix;
  10304. private _transformMatrix;
  10305. private _cachedPosition;
  10306. private _cachedDirection;
  10307. private _cachedDefines;
  10308. private _currentRenderID;
  10309. private _boxBlurPostprocess;
  10310. private _kernelBlurXPostprocess;
  10311. private _kernelBlurYPostprocess;
  10312. private _blurPostProcesses;
  10313. private _mapSize;
  10314. private _currentFaceIndex;
  10315. private _currentFaceIndexCache;
  10316. private _textureType;
  10317. private _defaultTextureMatrix;
  10318. /** @hidden */
  10319. static _SceneComponentInitialization: (scene: Scene) => void;
  10320. /**
  10321. * Creates a ShadowGenerator object.
  10322. * A ShadowGenerator is the required tool to use the shadows.
  10323. * Each light casting shadows needs to use its own ShadowGenerator.
  10324. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10325. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10326. * @param light The light object generating the shadows.
  10327. * @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.
  10328. */
  10329. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10330. private _initializeGenerator;
  10331. private _initializeShadowMap;
  10332. private _initializeBlurRTTAndPostProcesses;
  10333. private _renderForShadowMap;
  10334. private _renderSubMeshForShadowMap;
  10335. private _applyFilterValues;
  10336. /**
  10337. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10338. * @param onCompiled Callback triggered at the and of the effects compilation
  10339. * @param options Sets of optional options forcing the compilation with different modes
  10340. */
  10341. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10342. useInstances: boolean;
  10343. }>): void;
  10344. /**
  10345. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10346. * @param options Sets of optional options forcing the compilation with different modes
  10347. * @returns A promise that resolves when the compilation completes
  10348. */
  10349. forceCompilationAsync(options?: Partial<{
  10350. useInstances: boolean;
  10351. }>): Promise<void>;
  10352. /**
  10353. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10354. * @param subMesh The submesh we want to render in the shadow map
  10355. * @param useInstances Defines wether will draw in the map using instances
  10356. * @returns true if ready otherwise, false
  10357. */
  10358. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10359. /**
  10360. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10361. * @param defines Defines of the material we want to update
  10362. * @param lightIndex Index of the light in the enabled light list of the material
  10363. */
  10364. prepareDefines(defines: any, lightIndex: number): void;
  10365. /**
  10366. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10367. * defined in the generator but impacting the effect).
  10368. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10369. * @param effect The effect we are binfing the information for
  10370. */
  10371. bindShadowLight(lightIndex: string, effect: Effect): void;
  10372. /**
  10373. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10374. * (eq to shadow prjection matrix * light transform matrix)
  10375. * @returns The transform matrix used to create the shadow map
  10376. */
  10377. getTransformMatrix(): Matrix;
  10378. /**
  10379. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10380. * Cube and 2D textures for instance.
  10381. */
  10382. recreateShadowMap(): void;
  10383. private _disposeBlurPostProcesses;
  10384. private _disposeRTTandPostProcesses;
  10385. /**
  10386. * Disposes the ShadowGenerator.
  10387. * Returns nothing.
  10388. */
  10389. dispose(): void;
  10390. /**
  10391. * Serializes the shadow generator setup to a json object.
  10392. * @returns The serialized JSON object
  10393. */
  10394. serialize(): any;
  10395. /**
  10396. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10397. * @param parsedShadowGenerator The JSON object to parse
  10398. * @param scene The scene to create the shadow map for
  10399. * @returns The parsed shadow generator
  10400. */
  10401. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10402. }
  10403. }
  10404. declare module BABYLON {
  10405. /**
  10406. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10407. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10408. * 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.
  10409. */
  10410. export abstract class Light extends Node {
  10411. /**
  10412. * Falloff Default: light is falling off following the material specification:
  10413. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10414. */
  10415. static readonly FALLOFF_DEFAULT: number;
  10416. /**
  10417. * Falloff Physical: light is falling off following the inverse squared distance law.
  10418. */
  10419. static readonly FALLOFF_PHYSICAL: number;
  10420. /**
  10421. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10422. * to enhance interoperability with other engines.
  10423. */
  10424. static readonly FALLOFF_GLTF: number;
  10425. /**
  10426. * Falloff Standard: light is falling off like in the standard material
  10427. * to enhance interoperability with other materials.
  10428. */
  10429. static readonly FALLOFF_STANDARD: number;
  10430. /**
  10431. * If every light affecting the material is in this lightmapMode,
  10432. * material.lightmapTexture adds or multiplies
  10433. * (depends on material.useLightmapAsShadowmap)
  10434. * after every other light calculations.
  10435. */
  10436. static readonly LIGHTMAP_DEFAULT: number;
  10437. /**
  10438. * material.lightmapTexture as only diffuse lighting from this light
  10439. * adds only specular lighting from this light
  10440. * adds dynamic shadows
  10441. */
  10442. static readonly LIGHTMAP_SPECULAR: number;
  10443. /**
  10444. * material.lightmapTexture as only lighting
  10445. * no light calculation from this light
  10446. * only adds dynamic shadows from this light
  10447. */
  10448. static readonly LIGHTMAP_SHADOWSONLY: number;
  10449. /**
  10450. * Each light type uses the default quantity according to its type:
  10451. * point/spot lights use luminous intensity
  10452. * directional lights use illuminance
  10453. */
  10454. static readonly INTENSITYMODE_AUTOMATIC: number;
  10455. /**
  10456. * lumen (lm)
  10457. */
  10458. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10459. /**
  10460. * candela (lm/sr)
  10461. */
  10462. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10463. /**
  10464. * lux (lm/m^2)
  10465. */
  10466. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10467. /**
  10468. * nit (cd/m^2)
  10469. */
  10470. static readonly INTENSITYMODE_LUMINANCE: number;
  10471. /**
  10472. * Light type const id of the point light.
  10473. */
  10474. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10475. /**
  10476. * Light type const id of the directional light.
  10477. */
  10478. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10479. /**
  10480. * Light type const id of the spot light.
  10481. */
  10482. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10483. /**
  10484. * Light type const id of the hemispheric light.
  10485. */
  10486. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10487. /**
  10488. * Diffuse gives the basic color to an object.
  10489. */
  10490. diffuse: Color3;
  10491. /**
  10492. * Specular produces a highlight color on an object.
  10493. * Note: This is note affecting PBR materials.
  10494. */
  10495. specular: Color3;
  10496. /**
  10497. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10498. * falling off base on range or angle.
  10499. * This can be set to any values in Light.FALLOFF_x.
  10500. *
  10501. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10502. * other types of materials.
  10503. */
  10504. falloffType: number;
  10505. /**
  10506. * Strength of the light.
  10507. * Note: By default it is define in the framework own unit.
  10508. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10509. */
  10510. intensity: number;
  10511. private _range;
  10512. protected _inverseSquaredRange: number;
  10513. /**
  10514. * Defines how far from the source the light is impacting in scene units.
  10515. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10516. */
  10517. /**
  10518. * Defines how far from the source the light is impacting in scene units.
  10519. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10520. */
  10521. range: number;
  10522. /**
  10523. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10524. * of light.
  10525. */
  10526. private _photometricScale;
  10527. private _intensityMode;
  10528. /**
  10529. * Gets the photometric scale used to interpret the intensity.
  10530. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10531. */
  10532. /**
  10533. * Sets the photometric scale used to interpret the intensity.
  10534. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10535. */
  10536. intensityMode: number;
  10537. private _radius;
  10538. /**
  10539. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10540. */
  10541. /**
  10542. * sets the light radius used by PBR Materials to simulate soft area lights.
  10543. */
  10544. radius: number;
  10545. private _renderPriority;
  10546. /**
  10547. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10548. * exceeding the number allowed of the materials.
  10549. */
  10550. renderPriority: number;
  10551. private _shadowEnabled;
  10552. /**
  10553. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10554. * the current shadow generator.
  10555. */
  10556. /**
  10557. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10558. * the current shadow generator.
  10559. */
  10560. shadowEnabled: boolean;
  10561. private _includedOnlyMeshes;
  10562. /**
  10563. * Gets the only meshes impacted by this light.
  10564. */
  10565. /**
  10566. * Sets the only meshes impacted by this light.
  10567. */
  10568. includedOnlyMeshes: AbstractMesh[];
  10569. private _excludedMeshes;
  10570. /**
  10571. * Gets the meshes not impacted by this light.
  10572. */
  10573. /**
  10574. * Sets the meshes not impacted by this light.
  10575. */
  10576. excludedMeshes: AbstractMesh[];
  10577. private _excludeWithLayerMask;
  10578. /**
  10579. * Gets the layer id use to find what meshes are not impacted by the light.
  10580. * Inactive if 0
  10581. */
  10582. /**
  10583. * Sets the layer id use to find what meshes are not impacted by the light.
  10584. * Inactive if 0
  10585. */
  10586. excludeWithLayerMask: number;
  10587. private _includeOnlyWithLayerMask;
  10588. /**
  10589. * Gets the layer id use to find what meshes are impacted by the light.
  10590. * Inactive if 0
  10591. */
  10592. /**
  10593. * Sets the layer id use to find what meshes are impacted by the light.
  10594. * Inactive if 0
  10595. */
  10596. includeOnlyWithLayerMask: number;
  10597. private _lightmapMode;
  10598. /**
  10599. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10600. */
  10601. /**
  10602. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10603. */
  10604. lightmapMode: number;
  10605. /**
  10606. * Shadow generator associted to the light.
  10607. * @hidden Internal use only.
  10608. */
  10609. _shadowGenerator: Nullable<IShadowGenerator>;
  10610. /**
  10611. * @hidden Internal use only.
  10612. */
  10613. _excludedMeshesIds: string[];
  10614. /**
  10615. * @hidden Internal use only.
  10616. */
  10617. _includedOnlyMeshesIds: string[];
  10618. /**
  10619. * The current light unifom buffer.
  10620. * @hidden Internal use only.
  10621. */
  10622. _uniformBuffer: UniformBuffer;
  10623. /**
  10624. * Creates a Light object in the scene.
  10625. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10626. * @param name The firendly name of the light
  10627. * @param scene The scene the light belongs too
  10628. */
  10629. constructor(name: string, scene: Scene);
  10630. protected abstract _buildUniformLayout(): void;
  10631. /**
  10632. * Sets the passed Effect "effect" with the Light information.
  10633. * @param effect The effect to update
  10634. * @param lightIndex The index of the light in the effect to update
  10635. * @returns The light
  10636. */
  10637. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10638. /**
  10639. * Returns the string "Light".
  10640. * @returns the class name
  10641. */
  10642. getClassName(): string;
  10643. /** @hidden */
  10644. readonly _isLight: boolean;
  10645. /**
  10646. * Converts the light information to a readable string for debug purpose.
  10647. * @param fullDetails Supports for multiple levels of logging within scene loading
  10648. * @returns the human readable light info
  10649. */
  10650. toString(fullDetails?: boolean): string;
  10651. /** @hidden */
  10652. protected _syncParentEnabledState(): void;
  10653. /**
  10654. * Set the enabled state of this node.
  10655. * @param value - the new enabled state
  10656. */
  10657. setEnabled(value: boolean): void;
  10658. /**
  10659. * Returns the Light associated shadow generator if any.
  10660. * @return the associated shadow generator.
  10661. */
  10662. getShadowGenerator(): Nullable<IShadowGenerator>;
  10663. /**
  10664. * Returns a Vector3, the absolute light position in the World.
  10665. * @returns the world space position of the light
  10666. */
  10667. getAbsolutePosition(): Vector3;
  10668. /**
  10669. * Specifies if the light will affect the passed mesh.
  10670. * @param mesh The mesh to test against the light
  10671. * @return true the mesh is affected otherwise, false.
  10672. */
  10673. canAffectMesh(mesh: AbstractMesh): boolean;
  10674. /**
  10675. * Sort function to order lights for rendering.
  10676. * @param a First Light object to compare to second.
  10677. * @param b Second Light object to compare first.
  10678. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10679. */
  10680. static CompareLightsPriority(a: Light, b: Light): number;
  10681. /**
  10682. * Releases resources associated with this node.
  10683. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10684. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10685. */
  10686. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10687. /**
  10688. * Returns the light type ID (integer).
  10689. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10690. */
  10691. getTypeID(): number;
  10692. /**
  10693. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10694. * @returns the scaled intensity in intensity mode unit
  10695. */
  10696. getScaledIntensity(): number;
  10697. /**
  10698. * Returns a new Light object, named "name", from the current one.
  10699. * @param name The name of the cloned light
  10700. * @returns the new created light
  10701. */
  10702. clone(name: string): Nullable<Light>;
  10703. /**
  10704. * Serializes the current light into a Serialization object.
  10705. * @returns the serialized object.
  10706. */
  10707. serialize(): any;
  10708. /**
  10709. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10710. * This new light is named "name" and added to the passed scene.
  10711. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10712. * @param name The friendly name of the light
  10713. * @param scene The scene the new light will belong to
  10714. * @returns the constructor function
  10715. */
  10716. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10717. /**
  10718. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10719. * @param parsedLight The JSON representation of the light
  10720. * @param scene The scene to create the parsed light in
  10721. * @returns the created light after parsing
  10722. */
  10723. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10724. private _hookArrayForExcluded;
  10725. private _hookArrayForIncludedOnly;
  10726. private _resyncMeshes;
  10727. /**
  10728. * Forces the meshes to update their light related information in their rendering used effects
  10729. * @hidden Internal Use Only
  10730. */
  10731. _markMeshesAsLightDirty(): void;
  10732. /**
  10733. * Recomputes the cached photometric scale if needed.
  10734. */
  10735. private _computePhotometricScale;
  10736. /**
  10737. * Returns the Photometric Scale according to the light type and intensity mode.
  10738. */
  10739. private _getPhotometricScale;
  10740. /**
  10741. * Reorder the light in the scene according to their defined priority.
  10742. * @hidden Internal Use Only
  10743. */
  10744. _reorderLightsInScene(): void;
  10745. /**
  10746. * Prepares the list of defines specific to the light type.
  10747. * @param defines the list of defines
  10748. * @param lightIndex defines the index of the light for the effect
  10749. */
  10750. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10751. }
  10752. }
  10753. declare module BABYLON {
  10754. /**
  10755. * Interface used to define Action
  10756. */
  10757. export interface IAction {
  10758. /**
  10759. * Trigger for the action
  10760. */
  10761. trigger: number;
  10762. /** Options of the trigger */
  10763. triggerOptions: any;
  10764. /**
  10765. * Gets the trigger parameters
  10766. * @returns the trigger parameters
  10767. */
  10768. getTriggerParameter(): any;
  10769. /**
  10770. * Internal only - executes current action event
  10771. * @hidden
  10772. */
  10773. _executeCurrent(evt?: ActionEvent): void;
  10774. /**
  10775. * Serialize placeholder for child classes
  10776. * @param parent of child
  10777. * @returns the serialized object
  10778. */
  10779. serialize(parent: any): any;
  10780. /**
  10781. * Internal only
  10782. * @hidden
  10783. */
  10784. _prepare(): void;
  10785. /**
  10786. * Internal only - manager for action
  10787. * @hidden
  10788. */
  10789. _actionManager: AbstractActionManager;
  10790. /**
  10791. * Adds action to chain of actions, may be a DoNothingAction
  10792. * @param action defines the next action to execute
  10793. * @returns The action passed in
  10794. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10795. */
  10796. then(action: IAction): IAction;
  10797. }
  10798. /**
  10799. * The action to be carried out following a trigger
  10800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10801. */
  10802. export class Action implements IAction {
  10803. /** the trigger, with or without parameters, for the action */
  10804. triggerOptions: any;
  10805. /**
  10806. * Trigger for the action
  10807. */
  10808. trigger: number;
  10809. /**
  10810. * Internal only - manager for action
  10811. * @hidden
  10812. */
  10813. _actionManager: ActionManager;
  10814. private _nextActiveAction;
  10815. private _child;
  10816. private _condition?;
  10817. private _triggerParameter;
  10818. /**
  10819. * An event triggered prior to action being executed.
  10820. */
  10821. onBeforeExecuteObservable: Observable<Action>;
  10822. /**
  10823. * Creates a new Action
  10824. * @param triggerOptions the trigger, with or without parameters, for the action
  10825. * @param condition an optional determinant of action
  10826. */
  10827. constructor(
  10828. /** the trigger, with or without parameters, for the action */
  10829. triggerOptions: any, condition?: Condition);
  10830. /**
  10831. * Internal only
  10832. * @hidden
  10833. */
  10834. _prepare(): void;
  10835. /**
  10836. * Gets the trigger parameters
  10837. * @returns the trigger parameters
  10838. */
  10839. getTriggerParameter(): any;
  10840. /**
  10841. * Internal only - executes current action event
  10842. * @hidden
  10843. */
  10844. _executeCurrent(evt?: ActionEvent): void;
  10845. /**
  10846. * Execute placeholder for child classes
  10847. * @param evt optional action event
  10848. */
  10849. execute(evt?: ActionEvent): void;
  10850. /**
  10851. * Skips to next active action
  10852. */
  10853. skipToNextActiveAction(): void;
  10854. /**
  10855. * Adds action to chain of actions, may be a DoNothingAction
  10856. * @param action defines the next action to execute
  10857. * @returns The action passed in
  10858. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10859. */
  10860. then(action: Action): Action;
  10861. /**
  10862. * Internal only
  10863. * @hidden
  10864. */
  10865. _getProperty(propertyPath: string): string;
  10866. /**
  10867. * Internal only
  10868. * @hidden
  10869. */
  10870. _getEffectiveTarget(target: any, propertyPath: string): any;
  10871. /**
  10872. * Serialize placeholder for child classes
  10873. * @param parent of child
  10874. * @returns the serialized object
  10875. */
  10876. serialize(parent: any): any;
  10877. /**
  10878. * Internal only called by serialize
  10879. * @hidden
  10880. */
  10881. protected _serialize(serializedAction: any, parent?: any): any;
  10882. /**
  10883. * Internal only
  10884. * @hidden
  10885. */
  10886. static _SerializeValueAsString: (value: any) => string;
  10887. /**
  10888. * Internal only
  10889. * @hidden
  10890. */
  10891. static _GetTargetProperty: (target: Scene | Node) => {
  10892. name: string;
  10893. targetType: string;
  10894. value: string;
  10895. };
  10896. }
  10897. }
  10898. declare module BABYLON {
  10899. /**
  10900. * A Condition applied to an Action
  10901. */
  10902. export class Condition {
  10903. /**
  10904. * Internal only - manager for action
  10905. * @hidden
  10906. */
  10907. _actionManager: ActionManager;
  10908. /**
  10909. * Internal only
  10910. * @hidden
  10911. */
  10912. _evaluationId: number;
  10913. /**
  10914. * Internal only
  10915. * @hidden
  10916. */
  10917. _currentResult: boolean;
  10918. /**
  10919. * Creates a new Condition
  10920. * @param actionManager the manager of the action the condition is applied to
  10921. */
  10922. constructor(actionManager: ActionManager);
  10923. /**
  10924. * Check if the current condition is valid
  10925. * @returns a boolean
  10926. */
  10927. isValid(): boolean;
  10928. /**
  10929. * Internal only
  10930. * @hidden
  10931. */
  10932. _getProperty(propertyPath: string): string;
  10933. /**
  10934. * Internal only
  10935. * @hidden
  10936. */
  10937. _getEffectiveTarget(target: any, propertyPath: string): any;
  10938. /**
  10939. * Serialize placeholder for child classes
  10940. * @returns the serialized object
  10941. */
  10942. serialize(): any;
  10943. /**
  10944. * Internal only
  10945. * @hidden
  10946. */
  10947. protected _serialize(serializedCondition: any): any;
  10948. }
  10949. /**
  10950. * Defines specific conditional operators as extensions of Condition
  10951. */
  10952. export class ValueCondition extends Condition {
  10953. /** path to specify the property of the target the conditional operator uses */
  10954. propertyPath: string;
  10955. /** the value compared by the conditional operator against the current value of the property */
  10956. value: any;
  10957. /** the conditional operator, default ValueCondition.IsEqual */
  10958. operator: number;
  10959. /**
  10960. * Internal only
  10961. * @hidden
  10962. */
  10963. private static _IsEqual;
  10964. /**
  10965. * Internal only
  10966. * @hidden
  10967. */
  10968. private static _IsDifferent;
  10969. /**
  10970. * Internal only
  10971. * @hidden
  10972. */
  10973. private static _IsGreater;
  10974. /**
  10975. * Internal only
  10976. * @hidden
  10977. */
  10978. private static _IsLesser;
  10979. /**
  10980. * returns the number for IsEqual
  10981. */
  10982. static readonly IsEqual: number;
  10983. /**
  10984. * Returns the number for IsDifferent
  10985. */
  10986. static readonly IsDifferent: number;
  10987. /**
  10988. * Returns the number for IsGreater
  10989. */
  10990. static readonly IsGreater: number;
  10991. /**
  10992. * Returns the number for IsLesser
  10993. */
  10994. static readonly IsLesser: number;
  10995. /**
  10996. * Internal only The action manager for the condition
  10997. * @hidden
  10998. */
  10999. _actionManager: ActionManager;
  11000. /**
  11001. * Internal only
  11002. * @hidden
  11003. */
  11004. private _target;
  11005. /**
  11006. * Internal only
  11007. * @hidden
  11008. */
  11009. private _effectiveTarget;
  11010. /**
  11011. * Internal only
  11012. * @hidden
  11013. */
  11014. private _property;
  11015. /**
  11016. * Creates a new ValueCondition
  11017. * @param actionManager manager for the action the condition applies to
  11018. * @param target for the action
  11019. * @param propertyPath path to specify the property of the target the conditional operator uses
  11020. * @param value the value compared by the conditional operator against the current value of the property
  11021. * @param operator the conditional operator, default ValueCondition.IsEqual
  11022. */
  11023. constructor(actionManager: ActionManager, target: any,
  11024. /** path to specify the property of the target the conditional operator uses */
  11025. propertyPath: string,
  11026. /** the value compared by the conditional operator against the current value of the property */
  11027. value: any,
  11028. /** the conditional operator, default ValueCondition.IsEqual */
  11029. operator?: number);
  11030. /**
  11031. * Compares the given value with the property value for the specified conditional operator
  11032. * @returns the result of the comparison
  11033. */
  11034. isValid(): boolean;
  11035. /**
  11036. * Serialize the ValueCondition into a JSON compatible object
  11037. * @returns serialization object
  11038. */
  11039. serialize(): any;
  11040. /**
  11041. * Gets the name of the conditional operator for the ValueCondition
  11042. * @param operator the conditional operator
  11043. * @returns the name
  11044. */
  11045. static GetOperatorName(operator: number): string;
  11046. }
  11047. /**
  11048. * Defines a predicate condition as an extension of Condition
  11049. */
  11050. export class PredicateCondition extends Condition {
  11051. /** defines the predicate function used to validate the condition */
  11052. predicate: () => boolean;
  11053. /**
  11054. * Internal only - manager for action
  11055. * @hidden
  11056. */
  11057. _actionManager: ActionManager;
  11058. /**
  11059. * Creates a new PredicateCondition
  11060. * @param actionManager manager for the action the condition applies to
  11061. * @param predicate defines the predicate function used to validate the condition
  11062. */
  11063. constructor(actionManager: ActionManager,
  11064. /** defines the predicate function used to validate the condition */
  11065. predicate: () => boolean);
  11066. /**
  11067. * @returns the validity of the predicate condition
  11068. */
  11069. isValid(): boolean;
  11070. }
  11071. /**
  11072. * Defines a state condition as an extension of Condition
  11073. */
  11074. export class StateCondition extends Condition {
  11075. /** Value to compare with target state */
  11076. value: string;
  11077. /**
  11078. * Internal only - manager for action
  11079. * @hidden
  11080. */
  11081. _actionManager: ActionManager;
  11082. /**
  11083. * Internal only
  11084. * @hidden
  11085. */
  11086. private _target;
  11087. /**
  11088. * Creates a new StateCondition
  11089. * @param actionManager manager for the action the condition applies to
  11090. * @param target of the condition
  11091. * @param value to compare with target state
  11092. */
  11093. constructor(actionManager: ActionManager, target: any,
  11094. /** Value to compare with target state */
  11095. value: string);
  11096. /**
  11097. * Gets a boolean indicating if the current condition is met
  11098. * @returns the validity of the state
  11099. */
  11100. isValid(): boolean;
  11101. /**
  11102. * Serialize the StateCondition into a JSON compatible object
  11103. * @returns serialization object
  11104. */
  11105. serialize(): any;
  11106. }
  11107. }
  11108. declare module BABYLON {
  11109. /**
  11110. * This defines an action responsible to toggle a boolean once triggered.
  11111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11112. */
  11113. export class SwitchBooleanAction extends Action {
  11114. /**
  11115. * The path to the boolean property in the target object
  11116. */
  11117. propertyPath: string;
  11118. private _target;
  11119. private _effectiveTarget;
  11120. private _property;
  11121. /**
  11122. * Instantiate the action
  11123. * @param triggerOptions defines the trigger options
  11124. * @param target defines the object containing the boolean
  11125. * @param propertyPath defines the path to the boolean property in the target object
  11126. * @param condition defines the trigger related conditions
  11127. */
  11128. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  11129. /** @hidden */
  11130. _prepare(): void;
  11131. /**
  11132. * Execute the action toggle the boolean value.
  11133. */
  11134. execute(): void;
  11135. /**
  11136. * Serializes the actions and its related information.
  11137. * @param parent defines the object to serialize in
  11138. * @returns the serialized object
  11139. */
  11140. serialize(parent: any): any;
  11141. }
  11142. /**
  11143. * This defines an action responsible to set a the state field of the target
  11144. * to a desired value once triggered.
  11145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11146. */
  11147. export class SetStateAction extends Action {
  11148. /**
  11149. * The value to store in the state field.
  11150. */
  11151. value: string;
  11152. private _target;
  11153. /**
  11154. * Instantiate the action
  11155. * @param triggerOptions defines the trigger options
  11156. * @param target defines the object containing the state property
  11157. * @param value defines the value to store in the state field
  11158. * @param condition defines the trigger related conditions
  11159. */
  11160. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11161. /**
  11162. * Execute the action and store the value on the target state property.
  11163. */
  11164. execute(): void;
  11165. /**
  11166. * Serializes the actions and its related information.
  11167. * @param parent defines the object to serialize in
  11168. * @returns the serialized object
  11169. */
  11170. serialize(parent: any): any;
  11171. }
  11172. /**
  11173. * This defines an action responsible to set a property of the target
  11174. * to a desired value once triggered.
  11175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11176. */
  11177. export class SetValueAction extends Action {
  11178. /**
  11179. * The path of the property to set in the target.
  11180. */
  11181. propertyPath: string;
  11182. /**
  11183. * The value to set in the property
  11184. */
  11185. value: any;
  11186. private _target;
  11187. private _effectiveTarget;
  11188. private _property;
  11189. /**
  11190. * Instantiate the action
  11191. * @param triggerOptions defines the trigger options
  11192. * @param target defines the object containing the property
  11193. * @param propertyPath defines the path of the property to set in the target
  11194. * @param value defines the value to set in the property
  11195. * @param condition defines the trigger related conditions
  11196. */
  11197. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11198. /** @hidden */
  11199. _prepare(): void;
  11200. /**
  11201. * Execute the action and set the targetted property to the desired value.
  11202. */
  11203. execute(): void;
  11204. /**
  11205. * Serializes the actions and its related information.
  11206. * @param parent defines the object to serialize in
  11207. * @returns the serialized object
  11208. */
  11209. serialize(parent: any): any;
  11210. }
  11211. /**
  11212. * This defines an action responsible to increment the target value
  11213. * to a desired value once triggered.
  11214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11215. */
  11216. export class IncrementValueAction extends Action {
  11217. /**
  11218. * The path of the property to increment in the target.
  11219. */
  11220. propertyPath: string;
  11221. /**
  11222. * The value we should increment the property by.
  11223. */
  11224. value: any;
  11225. private _target;
  11226. private _effectiveTarget;
  11227. private _property;
  11228. /**
  11229. * Instantiate the action
  11230. * @param triggerOptions defines the trigger options
  11231. * @param target defines the object containing the property
  11232. * @param propertyPath defines the path of the property to increment in the target
  11233. * @param value defines the value value we should increment the property by
  11234. * @param condition defines the trigger related conditions
  11235. */
  11236. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11237. /** @hidden */
  11238. _prepare(): void;
  11239. /**
  11240. * Execute the action and increment the target of the value amount.
  11241. */
  11242. execute(): void;
  11243. /**
  11244. * Serializes the actions and its related information.
  11245. * @param parent defines the object to serialize in
  11246. * @returns the serialized object
  11247. */
  11248. serialize(parent: any): any;
  11249. }
  11250. /**
  11251. * This defines an action responsible to start an animation once triggered.
  11252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11253. */
  11254. export class PlayAnimationAction extends Action {
  11255. /**
  11256. * Where the animation should start (animation frame)
  11257. */
  11258. from: number;
  11259. /**
  11260. * Where the animation should stop (animation frame)
  11261. */
  11262. to: number;
  11263. /**
  11264. * Define if the animation should loop or stop after the first play.
  11265. */
  11266. loop?: boolean;
  11267. private _target;
  11268. /**
  11269. * Instantiate the action
  11270. * @param triggerOptions defines the trigger options
  11271. * @param target defines the target animation or animation name
  11272. * @param from defines from where the animation should start (animation frame)
  11273. * @param end defines where the animation should stop (animation frame)
  11274. * @param loop defines if the animation should loop or stop after the first play
  11275. * @param condition defines the trigger related conditions
  11276. */
  11277. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11278. /** @hidden */
  11279. _prepare(): void;
  11280. /**
  11281. * Execute the action and play the animation.
  11282. */
  11283. execute(): void;
  11284. /**
  11285. * Serializes the actions and its related information.
  11286. * @param parent defines the object to serialize in
  11287. * @returns the serialized object
  11288. */
  11289. serialize(parent: any): any;
  11290. }
  11291. /**
  11292. * This defines an action responsible to stop an animation once triggered.
  11293. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11294. */
  11295. export class StopAnimationAction extends Action {
  11296. private _target;
  11297. /**
  11298. * Instantiate the action
  11299. * @param triggerOptions defines the trigger options
  11300. * @param target defines the target animation or animation name
  11301. * @param condition defines the trigger related conditions
  11302. */
  11303. constructor(triggerOptions: any, target: any, condition?: Condition);
  11304. /** @hidden */
  11305. _prepare(): void;
  11306. /**
  11307. * Execute the action and stop the animation.
  11308. */
  11309. execute(): void;
  11310. /**
  11311. * Serializes the actions and its related information.
  11312. * @param parent defines the object to serialize in
  11313. * @returns the serialized object
  11314. */
  11315. serialize(parent: any): any;
  11316. }
  11317. /**
  11318. * This defines an action responsible that does nothing once triggered.
  11319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11320. */
  11321. export class DoNothingAction extends Action {
  11322. /**
  11323. * Instantiate the action
  11324. * @param triggerOptions defines the trigger options
  11325. * @param condition defines the trigger related conditions
  11326. */
  11327. constructor(triggerOptions?: any, condition?: Condition);
  11328. /**
  11329. * Execute the action and do nothing.
  11330. */
  11331. execute(): void;
  11332. /**
  11333. * Serializes the actions and its related information.
  11334. * @param parent defines the object to serialize in
  11335. * @returns the serialized object
  11336. */
  11337. serialize(parent: any): any;
  11338. }
  11339. /**
  11340. * This defines an action responsible to trigger several actions once triggered.
  11341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11342. */
  11343. export class CombineAction extends Action {
  11344. /**
  11345. * The list of aggregated animations to run.
  11346. */
  11347. children: Action[];
  11348. /**
  11349. * Instantiate the action
  11350. * @param triggerOptions defines the trigger options
  11351. * @param children defines the list of aggregated animations to run
  11352. * @param condition defines the trigger related conditions
  11353. */
  11354. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11355. /** @hidden */
  11356. _prepare(): void;
  11357. /**
  11358. * Execute the action and executes all the aggregated actions.
  11359. */
  11360. execute(evt: ActionEvent): void;
  11361. /**
  11362. * Serializes the actions and its related information.
  11363. * @param parent defines the object to serialize in
  11364. * @returns the serialized object
  11365. */
  11366. serialize(parent: any): any;
  11367. }
  11368. /**
  11369. * This defines an action responsible to run code (external event) once triggered.
  11370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11371. */
  11372. export class ExecuteCodeAction extends Action {
  11373. /**
  11374. * The callback function to run.
  11375. */
  11376. func: (evt: ActionEvent) => void;
  11377. /**
  11378. * Instantiate the action
  11379. * @param triggerOptions defines the trigger options
  11380. * @param func defines the callback function to run
  11381. * @param condition defines the trigger related conditions
  11382. */
  11383. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11384. /**
  11385. * Execute the action and run the attached code.
  11386. */
  11387. execute(evt: ActionEvent): void;
  11388. }
  11389. /**
  11390. * This defines an action responsible to set the parent property of the target once triggered.
  11391. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11392. */
  11393. export class SetParentAction extends Action {
  11394. private _parent;
  11395. private _target;
  11396. /**
  11397. * Instantiate the action
  11398. * @param triggerOptions defines the trigger options
  11399. * @param target defines the target containing the parent property
  11400. * @param parent defines from where the animation should start (animation frame)
  11401. * @param condition defines the trigger related conditions
  11402. */
  11403. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11404. /** @hidden */
  11405. _prepare(): void;
  11406. /**
  11407. * Execute the action and set the parent property.
  11408. */
  11409. execute(): void;
  11410. /**
  11411. * Serializes the actions and its related information.
  11412. * @param parent defines the object to serialize in
  11413. * @returns the serialized object
  11414. */
  11415. serialize(parent: any): any;
  11416. }
  11417. }
  11418. declare module BABYLON {
  11419. /**
  11420. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11421. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11422. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11423. */
  11424. export class ActionManager extends AbstractActionManager {
  11425. /**
  11426. * Nothing
  11427. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11428. */
  11429. static readonly NothingTrigger: number;
  11430. /**
  11431. * On pick
  11432. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11433. */
  11434. static readonly OnPickTrigger: number;
  11435. /**
  11436. * On left pick
  11437. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11438. */
  11439. static readonly OnLeftPickTrigger: number;
  11440. /**
  11441. * On right pick
  11442. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11443. */
  11444. static readonly OnRightPickTrigger: number;
  11445. /**
  11446. * On center pick
  11447. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11448. */
  11449. static readonly OnCenterPickTrigger: number;
  11450. /**
  11451. * On pick down
  11452. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11453. */
  11454. static readonly OnPickDownTrigger: number;
  11455. /**
  11456. * On double pick
  11457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11458. */
  11459. static readonly OnDoublePickTrigger: number;
  11460. /**
  11461. * On pick up
  11462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11463. */
  11464. static readonly OnPickUpTrigger: number;
  11465. /**
  11466. * On pick out.
  11467. * This trigger will only be raised if you also declared a OnPickDown
  11468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11469. */
  11470. static readonly OnPickOutTrigger: number;
  11471. /**
  11472. * On long press
  11473. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11474. */
  11475. static readonly OnLongPressTrigger: number;
  11476. /**
  11477. * On pointer over
  11478. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11479. */
  11480. static readonly OnPointerOverTrigger: number;
  11481. /**
  11482. * On pointer out
  11483. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11484. */
  11485. static readonly OnPointerOutTrigger: number;
  11486. /**
  11487. * On every frame
  11488. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11489. */
  11490. static readonly OnEveryFrameTrigger: number;
  11491. /**
  11492. * On intersection enter
  11493. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11494. */
  11495. static readonly OnIntersectionEnterTrigger: number;
  11496. /**
  11497. * On intersection exit
  11498. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11499. */
  11500. static readonly OnIntersectionExitTrigger: number;
  11501. /**
  11502. * On key down
  11503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11504. */
  11505. static readonly OnKeyDownTrigger: number;
  11506. /**
  11507. * On key up
  11508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11509. */
  11510. static readonly OnKeyUpTrigger: number;
  11511. private _scene;
  11512. /**
  11513. * Creates a new action manager
  11514. * @param scene defines the hosting scene
  11515. */
  11516. constructor(scene: Scene);
  11517. /**
  11518. * Releases all associated resources
  11519. */
  11520. dispose(): void;
  11521. /**
  11522. * Gets hosting scene
  11523. * @returns the hosting scene
  11524. */
  11525. getScene(): Scene;
  11526. /**
  11527. * Does this action manager handles actions of any of the given triggers
  11528. * @param triggers defines the triggers to be tested
  11529. * @return a boolean indicating whether one (or more) of the triggers is handled
  11530. */
  11531. hasSpecificTriggers(triggers: number[]): boolean;
  11532. /**
  11533. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11534. * speed.
  11535. * @param triggerA defines the trigger to be tested
  11536. * @param triggerB defines the trigger to be tested
  11537. * @return a boolean indicating whether one (or more) of the triggers is handled
  11538. */
  11539. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11540. /**
  11541. * Does this action manager handles actions of a given trigger
  11542. * @param trigger defines the trigger to be tested
  11543. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11544. * @return whether the trigger is handled
  11545. */
  11546. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11547. /**
  11548. * Does this action manager has pointer triggers
  11549. */
  11550. readonly hasPointerTriggers: boolean;
  11551. /**
  11552. * Does this action manager has pick triggers
  11553. */
  11554. readonly hasPickTriggers: boolean;
  11555. /**
  11556. * Registers an action to this action manager
  11557. * @param action defines the action to be registered
  11558. * @return the action amended (prepared) after registration
  11559. */
  11560. registerAction(action: IAction): Nullable<IAction>;
  11561. /**
  11562. * Unregisters an action to this action manager
  11563. * @param action defines the action to be unregistered
  11564. * @return a boolean indicating whether the action has been unregistered
  11565. */
  11566. unregisterAction(action: IAction): Boolean;
  11567. /**
  11568. * Process a specific trigger
  11569. * @param trigger defines the trigger to process
  11570. * @param evt defines the event details to be processed
  11571. */
  11572. processTrigger(trigger: number, evt?: IActionEvent): void;
  11573. /** @hidden */
  11574. _getEffectiveTarget(target: any, propertyPath: string): any;
  11575. /** @hidden */
  11576. _getProperty(propertyPath: string): string;
  11577. /**
  11578. * Serialize this manager to a JSON object
  11579. * @param name defines the property name to store this manager
  11580. * @returns a JSON representation of this manager
  11581. */
  11582. serialize(name: string): any;
  11583. /**
  11584. * Creates a new ActionManager from a JSON data
  11585. * @param parsedActions defines the JSON data to read from
  11586. * @param object defines the hosting mesh
  11587. * @param scene defines the hosting scene
  11588. */
  11589. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11590. /**
  11591. * Get a trigger name by index
  11592. * @param trigger defines the trigger index
  11593. * @returns a trigger name
  11594. */
  11595. static GetTriggerName(trigger: number): string;
  11596. }
  11597. }
  11598. declare module BABYLON {
  11599. /**
  11600. * Class representing a ray with position and direction
  11601. */
  11602. export class Ray {
  11603. /** origin point */
  11604. origin: Vector3;
  11605. /** direction */
  11606. direction: Vector3;
  11607. /** length of the ray */
  11608. length: number;
  11609. private static readonly TmpVector3;
  11610. private _tmpRay;
  11611. /**
  11612. * Creates a new ray
  11613. * @param origin origin point
  11614. * @param direction direction
  11615. * @param length length of the ray
  11616. */
  11617. constructor(
  11618. /** origin point */
  11619. origin: Vector3,
  11620. /** direction */
  11621. direction: Vector3,
  11622. /** length of the ray */
  11623. length?: number);
  11624. /**
  11625. * Checks if the ray intersects a box
  11626. * @param minimum bound of the box
  11627. * @param maximum bound of the box
  11628. * @param intersectionTreshold extra extend to be added to the box in all direction
  11629. * @returns if the box was hit
  11630. */
  11631. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11632. /**
  11633. * Checks if the ray intersects a box
  11634. * @param box the bounding box to check
  11635. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11636. * @returns if the box was hit
  11637. */
  11638. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11639. /**
  11640. * If the ray hits a sphere
  11641. * @param sphere the bounding sphere to check
  11642. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11643. * @returns true if it hits the sphere
  11644. */
  11645. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11646. /**
  11647. * If the ray hits a triange
  11648. * @param vertex0 triangle vertex
  11649. * @param vertex1 triangle vertex
  11650. * @param vertex2 triangle vertex
  11651. * @returns intersection information if hit
  11652. */
  11653. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11654. /**
  11655. * Checks if ray intersects a plane
  11656. * @param plane the plane to check
  11657. * @returns the distance away it was hit
  11658. */
  11659. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11660. /**
  11661. * Checks if ray intersects a mesh
  11662. * @param mesh the mesh to check
  11663. * @param fastCheck if only the bounding box should checked
  11664. * @returns picking info of the intersecton
  11665. */
  11666. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11667. /**
  11668. * Checks if ray intersects a mesh
  11669. * @param meshes the meshes to check
  11670. * @param fastCheck if only the bounding box should checked
  11671. * @param results array to store result in
  11672. * @returns Array of picking infos
  11673. */
  11674. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11675. private _comparePickingInfo;
  11676. private static smallnum;
  11677. private static rayl;
  11678. /**
  11679. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11680. * @param sega the first point of the segment to test the intersection against
  11681. * @param segb the second point of the segment to test the intersection against
  11682. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11683. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11684. */
  11685. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11686. /**
  11687. * Update the ray from viewport position
  11688. * @param x position
  11689. * @param y y position
  11690. * @param viewportWidth viewport width
  11691. * @param viewportHeight viewport height
  11692. * @param world world matrix
  11693. * @param view view matrix
  11694. * @param projection projection matrix
  11695. * @returns this ray updated
  11696. */
  11697. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11698. /**
  11699. * Creates a ray with origin and direction of 0,0,0
  11700. * @returns the new ray
  11701. */
  11702. static Zero(): Ray;
  11703. /**
  11704. * Creates a new ray from screen space and viewport
  11705. * @param x position
  11706. * @param y y position
  11707. * @param viewportWidth viewport width
  11708. * @param viewportHeight viewport height
  11709. * @param world world matrix
  11710. * @param view view matrix
  11711. * @param projection projection matrix
  11712. * @returns new ray
  11713. */
  11714. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11715. /**
  11716. * 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
  11717. * transformed to the given world matrix.
  11718. * @param origin The origin point
  11719. * @param end The end point
  11720. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11721. * @returns the new ray
  11722. */
  11723. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11724. /**
  11725. * Transforms a ray by a matrix
  11726. * @param ray ray to transform
  11727. * @param matrix matrix to apply
  11728. * @returns the resulting new ray
  11729. */
  11730. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11731. /**
  11732. * Transforms a ray by a matrix
  11733. * @param ray ray to transform
  11734. * @param matrix matrix to apply
  11735. * @param result ray to store result in
  11736. */
  11737. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11738. /**
  11739. * Unproject a ray from screen space to object space
  11740. * @param sourceX defines the screen space x coordinate to use
  11741. * @param sourceY defines the screen space y coordinate to use
  11742. * @param viewportWidth defines the current width of the viewport
  11743. * @param viewportHeight defines the current height of the viewport
  11744. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11745. * @param view defines the view matrix to use
  11746. * @param projection defines the projection matrix to use
  11747. */
  11748. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11749. }
  11750. /**
  11751. * Type used to define predicate used to select faces when a mesh intersection is detected
  11752. */
  11753. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11754. interface Scene {
  11755. /** @hidden */
  11756. _tempPickingRay: Nullable<Ray>;
  11757. /** @hidden */
  11758. _cachedRayForTransform: Ray;
  11759. /** @hidden */
  11760. _pickWithRayInverseMatrix: Matrix;
  11761. /** @hidden */
  11762. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11763. /** @hidden */
  11764. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11765. }
  11766. }
  11767. declare module BABYLON {
  11768. /**
  11769. * Groups all the scene component constants in one place to ease maintenance.
  11770. * @hidden
  11771. */
  11772. export class SceneComponentConstants {
  11773. static readonly NAME_EFFECTLAYER: string;
  11774. static readonly NAME_LAYER: string;
  11775. static readonly NAME_LENSFLARESYSTEM: string;
  11776. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11777. static readonly NAME_PARTICLESYSTEM: string;
  11778. static readonly NAME_GAMEPAD: string;
  11779. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11780. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11781. static readonly NAME_DEPTHRENDERER: string;
  11782. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11783. static readonly NAME_SPRITE: string;
  11784. static readonly NAME_OUTLINERENDERER: string;
  11785. static readonly NAME_PROCEDURALTEXTURE: string;
  11786. static readonly NAME_SHADOWGENERATOR: string;
  11787. static readonly NAME_OCTREE: string;
  11788. static readonly NAME_PHYSICSENGINE: string;
  11789. static readonly NAME_AUDIO: string;
  11790. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11791. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11792. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11793. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11794. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11795. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11796. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11797. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11798. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11799. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11800. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11801. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11802. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11803. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11804. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11805. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11806. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11807. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11808. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11809. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11810. static readonly STEP_AFTERRENDER_AUDIO: number;
  11811. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11812. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11813. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11814. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11815. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11816. static readonly STEP_POINTERMOVE_SPRITE: number;
  11817. static readonly STEP_POINTERDOWN_SPRITE: number;
  11818. static readonly STEP_POINTERUP_SPRITE: number;
  11819. }
  11820. /**
  11821. * This represents a scene component.
  11822. *
  11823. * This is used to decouple the dependency the scene is having on the different workloads like
  11824. * layers, post processes...
  11825. */
  11826. export interface ISceneComponent {
  11827. /**
  11828. * The name of the component. Each component must have a unique name.
  11829. */
  11830. name: string;
  11831. /**
  11832. * The scene the component belongs to.
  11833. */
  11834. scene: Scene;
  11835. /**
  11836. * Register the component to one instance of a scene.
  11837. */
  11838. register(): void;
  11839. /**
  11840. * Rebuilds the elements related to this component in case of
  11841. * context lost for instance.
  11842. */
  11843. rebuild(): void;
  11844. /**
  11845. * Disposes the component and the associated ressources.
  11846. */
  11847. dispose(): void;
  11848. }
  11849. /**
  11850. * This represents a SERIALIZABLE scene component.
  11851. *
  11852. * This extends Scene Component to add Serialization methods on top.
  11853. */
  11854. export interface ISceneSerializableComponent extends ISceneComponent {
  11855. /**
  11856. * Adds all the elements from the container to the scene
  11857. * @param container the container holding the elements
  11858. */
  11859. addFromContainer(container: AbstractScene): void;
  11860. /**
  11861. * Removes all the elements in the container from the scene
  11862. * @param container contains the elements to remove
  11863. * @param dispose if the removed element should be disposed (default: false)
  11864. */
  11865. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11866. /**
  11867. * Serializes the component data to the specified json object
  11868. * @param serializationObject The object to serialize to
  11869. */
  11870. serialize(serializationObject: any): void;
  11871. }
  11872. /**
  11873. * Strong typing of a Mesh related stage step action
  11874. */
  11875. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11876. /**
  11877. * Strong typing of a Evaluate Sub Mesh related stage step action
  11878. */
  11879. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11880. /**
  11881. * Strong typing of a Active Mesh related stage step action
  11882. */
  11883. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11884. /**
  11885. * Strong typing of a Camera related stage step action
  11886. */
  11887. export type CameraStageAction = (camera: Camera) => void;
  11888. /**
  11889. * Strong typing of a Camera Frame buffer related stage step action
  11890. */
  11891. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11892. /**
  11893. * Strong typing of a Render Target related stage step action
  11894. */
  11895. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11896. /**
  11897. * Strong typing of a RenderingGroup related stage step action
  11898. */
  11899. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11900. /**
  11901. * Strong typing of a Mesh Render related stage step action
  11902. */
  11903. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11904. /**
  11905. * Strong typing of a simple stage step action
  11906. */
  11907. export type SimpleStageAction = () => void;
  11908. /**
  11909. * Strong typing of a render target action.
  11910. */
  11911. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11912. /**
  11913. * Strong typing of a pointer move action.
  11914. */
  11915. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11916. /**
  11917. * Strong typing of a pointer up/down action.
  11918. */
  11919. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11920. /**
  11921. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11922. * @hidden
  11923. */
  11924. export class Stage<T extends Function> extends Array<{
  11925. index: number;
  11926. component: ISceneComponent;
  11927. action: T;
  11928. }> {
  11929. /**
  11930. * Hide ctor from the rest of the world.
  11931. * @param items The items to add.
  11932. */
  11933. private constructor();
  11934. /**
  11935. * Creates a new Stage.
  11936. * @returns A new instance of a Stage
  11937. */
  11938. static Create<T extends Function>(): Stage<T>;
  11939. /**
  11940. * Registers a step in an ordered way in the targeted stage.
  11941. * @param index Defines the position to register the step in
  11942. * @param component Defines the component attached to the step
  11943. * @param action Defines the action to launch during the step
  11944. */
  11945. registerStep(index: number, component: ISceneComponent, action: T): void;
  11946. /**
  11947. * Clears all the steps from the stage.
  11948. */
  11949. clear(): void;
  11950. }
  11951. }
  11952. declare module BABYLON {
  11953. interface Scene {
  11954. /** @hidden */
  11955. _pointerOverSprite: Nullable<Sprite>;
  11956. /** @hidden */
  11957. _pickedDownSprite: Nullable<Sprite>;
  11958. /** @hidden */
  11959. _tempSpritePickingRay: Nullable<Ray>;
  11960. /**
  11961. * All of the sprite managers added to this scene
  11962. * @see http://doc.babylonjs.com/babylon101/sprites
  11963. */
  11964. spriteManagers: Array<ISpriteManager>;
  11965. /**
  11966. * An event triggered when sprites rendering is about to start
  11967. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11968. */
  11969. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11970. /**
  11971. * An event triggered when sprites rendering is done
  11972. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11973. */
  11974. onAfterSpritesRenderingObservable: Observable<Scene>;
  11975. /** @hidden */
  11976. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11977. /** Launch a ray to try to pick a sprite in the scene
  11978. * @param x position on screen
  11979. * @param y position on screen
  11980. * @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
  11981. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11982. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11983. * @returns a PickingInfo
  11984. */
  11985. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11986. /** Use the given ray to pick a sprite in the scene
  11987. * @param ray The ray (in world space) to use to pick meshes
  11988. * @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
  11989. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11990. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11991. * @returns a PickingInfo
  11992. */
  11993. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11994. /**
  11995. * Force the sprite under the pointer
  11996. * @param sprite defines the sprite to use
  11997. */
  11998. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11999. /**
  12000. * Gets the sprite under the pointer
  12001. * @returns a Sprite or null if no sprite is under the pointer
  12002. */
  12003. getPointerOverSprite(): Nullable<Sprite>;
  12004. }
  12005. /**
  12006. * Defines the sprite scene component responsible to manage sprites
  12007. * in a given scene.
  12008. */
  12009. export class SpriteSceneComponent implements ISceneComponent {
  12010. /**
  12011. * The component name helpfull to identify the component in the list of scene components.
  12012. */
  12013. readonly name: string;
  12014. /**
  12015. * The scene the component belongs to.
  12016. */
  12017. scene: Scene;
  12018. /** @hidden */
  12019. private _spritePredicate;
  12020. /**
  12021. * Creates a new instance of the component for the given scene
  12022. * @param scene Defines the scene to register the component in
  12023. */
  12024. constructor(scene: Scene);
  12025. /**
  12026. * Registers the component in a given scene
  12027. */
  12028. register(): void;
  12029. /**
  12030. * Rebuilds the elements related to this component in case of
  12031. * context lost for instance.
  12032. */
  12033. rebuild(): void;
  12034. /**
  12035. * Disposes the component and the associated ressources.
  12036. */
  12037. dispose(): void;
  12038. private _pickSpriteButKeepRay;
  12039. private _pointerMove;
  12040. private _pointerDown;
  12041. private _pointerUp;
  12042. }
  12043. }
  12044. declare module BABYLON {
  12045. /** @hidden */
  12046. export var fogFragmentDeclaration: {
  12047. name: string;
  12048. shader: string;
  12049. };
  12050. }
  12051. declare module BABYLON {
  12052. /** @hidden */
  12053. export var fogFragment: {
  12054. name: string;
  12055. shader: string;
  12056. };
  12057. }
  12058. declare module BABYLON {
  12059. /** @hidden */
  12060. export var spritesPixelShader: {
  12061. name: string;
  12062. shader: string;
  12063. };
  12064. }
  12065. declare module BABYLON {
  12066. /** @hidden */
  12067. export var fogVertexDeclaration: {
  12068. name: string;
  12069. shader: string;
  12070. };
  12071. }
  12072. declare module BABYLON {
  12073. /** @hidden */
  12074. export var spritesVertexShader: {
  12075. name: string;
  12076. shader: string;
  12077. };
  12078. }
  12079. declare module BABYLON {
  12080. /**
  12081. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12082. */
  12083. export interface ISpriteManager extends IDisposable {
  12084. /**
  12085. * Restricts the camera to viewing objects with the same layerMask.
  12086. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12087. */
  12088. layerMask: number;
  12089. /**
  12090. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12091. */
  12092. isPickable: boolean;
  12093. /**
  12094. * Specifies the rendering group id for this mesh (0 by default)
  12095. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12096. */
  12097. renderingGroupId: number;
  12098. /**
  12099. * Defines the list of sprites managed by the manager.
  12100. */
  12101. sprites: Array<Sprite>;
  12102. /**
  12103. * Tests the intersection of a sprite with a specific ray.
  12104. * @param ray The ray we are sending to test the collision
  12105. * @param camera The camera space we are sending rays in
  12106. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12107. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12108. * @returns picking info or null.
  12109. */
  12110. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12111. /**
  12112. * Renders the list of sprites on screen.
  12113. */
  12114. render(): void;
  12115. }
  12116. /**
  12117. * Class used to manage multiple sprites on the same spritesheet
  12118. * @see http://doc.babylonjs.com/babylon101/sprites
  12119. */
  12120. export class SpriteManager implements ISpriteManager {
  12121. /** defines the manager's name */
  12122. name: string;
  12123. /** Gets the list of sprites */
  12124. sprites: Sprite[];
  12125. /** Gets or sets the rendering group id (0 by default) */
  12126. renderingGroupId: number;
  12127. /** Gets or sets camera layer mask */
  12128. layerMask: number;
  12129. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12130. fogEnabled: boolean;
  12131. /** Gets or sets a boolean indicating if the sprites are pickable */
  12132. isPickable: boolean;
  12133. /** Defines the default width of a cell in the spritesheet */
  12134. cellWidth: number;
  12135. /** Defines the default height of a cell in the spritesheet */
  12136. cellHeight: number;
  12137. /**
  12138. * An event triggered when the manager is disposed.
  12139. */
  12140. onDisposeObservable: Observable<SpriteManager>;
  12141. private _onDisposeObserver;
  12142. /**
  12143. * Callback called when the manager is disposed
  12144. */
  12145. onDispose: () => void;
  12146. private _capacity;
  12147. private _spriteTexture;
  12148. private _epsilon;
  12149. private _scene;
  12150. private _vertexData;
  12151. private _buffer;
  12152. private _vertexBuffers;
  12153. private _indexBuffer;
  12154. private _effectBase;
  12155. private _effectFog;
  12156. /**
  12157. * Gets or sets the spritesheet texture
  12158. */
  12159. texture: Texture;
  12160. /**
  12161. * Creates a new sprite manager
  12162. * @param name defines the manager's name
  12163. * @param imgUrl defines the sprite sheet url
  12164. * @param capacity defines the maximum allowed number of sprites
  12165. * @param cellSize defines the size of a sprite cell
  12166. * @param scene defines the hosting scene
  12167. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12168. * @param samplingMode defines the smapling mode to use with spritesheet
  12169. */
  12170. constructor(
  12171. /** defines the manager's name */
  12172. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12173. private _appendSpriteVertex;
  12174. /**
  12175. * Intersects the sprites with a ray
  12176. * @param ray defines the ray to intersect with
  12177. * @param camera defines the current active camera
  12178. * @param predicate defines a predicate used to select candidate sprites
  12179. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12180. * @returns null if no hit or a PickingInfo
  12181. */
  12182. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12183. /**
  12184. * Render all child sprites
  12185. */
  12186. render(): void;
  12187. /**
  12188. * Release associated resources
  12189. */
  12190. dispose(): void;
  12191. }
  12192. }
  12193. declare module BABYLON {
  12194. /**
  12195. * Class used to represent a sprite
  12196. * @see http://doc.babylonjs.com/babylon101/sprites
  12197. */
  12198. export class Sprite {
  12199. /** defines the name */
  12200. name: string;
  12201. /** Gets or sets the current world position */
  12202. position: Vector3;
  12203. /** Gets or sets the main color */
  12204. color: Color4;
  12205. /** Gets or sets the width */
  12206. width: number;
  12207. /** Gets or sets the height */
  12208. height: number;
  12209. /** Gets or sets rotation angle */
  12210. angle: number;
  12211. /** Gets or sets the cell index in the sprite sheet */
  12212. cellIndex: number;
  12213. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12214. invertU: number;
  12215. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12216. invertV: number;
  12217. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12218. disposeWhenFinishedAnimating: boolean;
  12219. /** Gets the list of attached animations */
  12220. animations: Animation[];
  12221. /** Gets or sets a boolean indicating if the sprite can be picked */
  12222. isPickable: boolean;
  12223. /**
  12224. * Gets or sets the associated action manager
  12225. */
  12226. actionManager: Nullable<ActionManager>;
  12227. private _animationStarted;
  12228. private _loopAnimation;
  12229. private _fromIndex;
  12230. private _toIndex;
  12231. private _delay;
  12232. private _direction;
  12233. private _manager;
  12234. private _time;
  12235. private _onAnimationEnd;
  12236. /**
  12237. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12238. */
  12239. isVisible: boolean;
  12240. /**
  12241. * Gets or sets the sprite size
  12242. */
  12243. size: number;
  12244. /**
  12245. * Creates a new Sprite
  12246. * @param name defines the name
  12247. * @param manager defines the manager
  12248. */
  12249. constructor(
  12250. /** defines the name */
  12251. name: string, manager: ISpriteManager);
  12252. /**
  12253. * Starts an animation
  12254. * @param from defines the initial key
  12255. * @param to defines the end key
  12256. * @param loop defines if the animation must loop
  12257. * @param delay defines the start delay (in ms)
  12258. * @param onAnimationEnd defines a callback to call when animation ends
  12259. */
  12260. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12261. /** Stops current animation (if any) */
  12262. stopAnimation(): void;
  12263. /** @hidden */
  12264. _animate(deltaTime: number): void;
  12265. /** Release associated resources */
  12266. dispose(): void;
  12267. }
  12268. }
  12269. declare module BABYLON {
  12270. /**
  12271. * Information about the result of picking within a scene
  12272. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12273. */
  12274. export class PickingInfo {
  12275. /** @hidden */
  12276. _pickingUnavailable: boolean;
  12277. /**
  12278. * If the pick collided with an object
  12279. */
  12280. hit: boolean;
  12281. /**
  12282. * Distance away where the pick collided
  12283. */
  12284. distance: number;
  12285. /**
  12286. * The location of pick collision
  12287. */
  12288. pickedPoint: Nullable<Vector3>;
  12289. /**
  12290. * The mesh corresponding the the pick collision
  12291. */
  12292. pickedMesh: Nullable<AbstractMesh>;
  12293. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12294. bu: number;
  12295. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12296. bv: number;
  12297. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12298. faceId: number;
  12299. /** Id of the the submesh that was picked */
  12300. subMeshId: number;
  12301. /** If a sprite was picked, this will be the sprite the pick collided with */
  12302. pickedSprite: Nullable<Sprite>;
  12303. /**
  12304. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12305. */
  12306. originMesh: Nullable<AbstractMesh>;
  12307. /**
  12308. * The ray that was used to perform the picking.
  12309. */
  12310. ray: Nullable<Ray>;
  12311. /**
  12312. * Gets the normal correspodning to the face the pick collided with
  12313. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12314. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12315. * @returns The normal correspodning to the face the pick collided with
  12316. */
  12317. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12318. /**
  12319. * Gets the texture coordinates of where the pick occured
  12320. * @returns the vector containing the coordnates of the texture
  12321. */
  12322. getTextureCoordinates(): Nullable<Vector2>;
  12323. }
  12324. }
  12325. declare module BABYLON {
  12326. /**
  12327. * Gather the list of pointer event types as constants.
  12328. */
  12329. export class PointerEventTypes {
  12330. /**
  12331. * 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.
  12332. */
  12333. static readonly POINTERDOWN: number;
  12334. /**
  12335. * The pointerup event is fired when a pointer is no longer active.
  12336. */
  12337. static readonly POINTERUP: number;
  12338. /**
  12339. * The pointermove event is fired when a pointer changes coordinates.
  12340. */
  12341. static readonly POINTERMOVE: number;
  12342. /**
  12343. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12344. */
  12345. static readonly POINTERWHEEL: number;
  12346. /**
  12347. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12348. */
  12349. static readonly POINTERPICK: number;
  12350. /**
  12351. * The pointertap event is fired when a the object has been touched and released without drag.
  12352. */
  12353. static readonly POINTERTAP: number;
  12354. /**
  12355. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12356. */
  12357. static readonly POINTERDOUBLETAP: number;
  12358. }
  12359. /**
  12360. * Base class of pointer info types.
  12361. */
  12362. export class PointerInfoBase {
  12363. /**
  12364. * Defines the type of event (PointerEventTypes)
  12365. */
  12366. type: number;
  12367. /**
  12368. * Defines the related dom event
  12369. */
  12370. event: PointerEvent | MouseWheelEvent;
  12371. /**
  12372. * Instantiates the base class of pointers info.
  12373. * @param type Defines the type of event (PointerEventTypes)
  12374. * @param event Defines the related dom event
  12375. */
  12376. constructor(
  12377. /**
  12378. * Defines the type of event (PointerEventTypes)
  12379. */
  12380. type: number,
  12381. /**
  12382. * Defines the related dom event
  12383. */
  12384. event: PointerEvent | MouseWheelEvent);
  12385. }
  12386. /**
  12387. * This class is used to store pointer related info for the onPrePointerObservable event.
  12388. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12389. */
  12390. export class PointerInfoPre extends PointerInfoBase {
  12391. /**
  12392. * Ray from a pointer if availible (eg. 6dof controller)
  12393. */
  12394. ray: Nullable<Ray>;
  12395. /**
  12396. * Defines the local position of the pointer on the canvas.
  12397. */
  12398. localPosition: Vector2;
  12399. /**
  12400. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12401. */
  12402. skipOnPointerObservable: boolean;
  12403. /**
  12404. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12405. * @param type Defines the type of event (PointerEventTypes)
  12406. * @param event Defines the related dom event
  12407. * @param localX Defines the local x coordinates of the pointer when the event occured
  12408. * @param localY Defines the local y coordinates of the pointer when the event occured
  12409. */
  12410. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12411. }
  12412. /**
  12413. * This type contains all the data related to a pointer event in Babylon.js.
  12414. * 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.
  12415. */
  12416. export class PointerInfo extends PointerInfoBase {
  12417. /**
  12418. * Defines the picking info associated to the info (if any)\
  12419. */
  12420. pickInfo: Nullable<PickingInfo>;
  12421. /**
  12422. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12423. * @param type Defines the type of event (PointerEventTypes)
  12424. * @param event Defines the related dom event
  12425. * @param pickInfo Defines the picking info associated to the info (if any)\
  12426. */
  12427. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12428. /**
  12429. * Defines the picking info associated to the info (if any)\
  12430. */
  12431. pickInfo: Nullable<PickingInfo>);
  12432. }
  12433. /**
  12434. * Data relating to a touch event on the screen.
  12435. */
  12436. export interface PointerTouch {
  12437. /**
  12438. * X coordinate of touch.
  12439. */
  12440. x: number;
  12441. /**
  12442. * Y coordinate of touch.
  12443. */
  12444. y: number;
  12445. /**
  12446. * Id of touch. Unique for each finger.
  12447. */
  12448. pointerId: number;
  12449. /**
  12450. * Event type passed from DOM.
  12451. */
  12452. type: any;
  12453. }
  12454. }
  12455. declare module BABYLON {
  12456. /**
  12457. * Manage the mouse inputs to control the movement of a free camera.
  12458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12459. */
  12460. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12461. /**
  12462. * Define if touch is enabled in the mouse input
  12463. */
  12464. touchEnabled: boolean;
  12465. /**
  12466. * Defines the camera the input is attached to.
  12467. */
  12468. camera: FreeCamera;
  12469. /**
  12470. * Defines the buttons associated with the input to handle camera move.
  12471. */
  12472. buttons: number[];
  12473. /**
  12474. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12475. */
  12476. angularSensibility: number;
  12477. private _pointerInput;
  12478. private _onMouseMove;
  12479. private _observer;
  12480. private previousPosition;
  12481. /**
  12482. * Observable for when a pointer move event occurs containing the move offset
  12483. */
  12484. onPointerMovedObservable: Observable<{
  12485. offsetX: number;
  12486. offsetY: number;
  12487. }>;
  12488. /**
  12489. * @hidden
  12490. * If the camera should be rotated automatically based on pointer movement
  12491. */
  12492. _allowCameraRotation: boolean;
  12493. /**
  12494. * Manage the mouse inputs to control the movement of a free camera.
  12495. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12496. * @param touchEnabled Defines if touch is enabled or not
  12497. */
  12498. constructor(
  12499. /**
  12500. * Define if touch is enabled in the mouse input
  12501. */
  12502. touchEnabled?: boolean);
  12503. /**
  12504. * Attach the input controls to a specific dom element to get the input from.
  12505. * @param element Defines the element the controls should be listened from
  12506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12507. */
  12508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12509. /**
  12510. * Called on JS contextmenu event.
  12511. * Override this method to provide functionality.
  12512. */
  12513. protected onContextMenu(evt: PointerEvent): void;
  12514. /**
  12515. * Detach the current controls from the specified dom element.
  12516. * @param element Defines the element to stop listening the inputs from
  12517. */
  12518. detachControl(element: Nullable<HTMLElement>): void;
  12519. /**
  12520. * Gets the class name of the current intput.
  12521. * @returns the class name
  12522. */
  12523. getClassName(): string;
  12524. /**
  12525. * Get the friendly name associated with the input class.
  12526. * @returns the input friendly name
  12527. */
  12528. getSimpleName(): string;
  12529. }
  12530. }
  12531. declare module BABYLON {
  12532. /**
  12533. * Manage the touch inputs to control the movement of a free camera.
  12534. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12535. */
  12536. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12537. /**
  12538. * Defines the camera the input is attached to.
  12539. */
  12540. camera: FreeCamera;
  12541. /**
  12542. * Defines the touch sensibility for rotation.
  12543. * The higher the faster.
  12544. */
  12545. touchAngularSensibility: number;
  12546. /**
  12547. * Defines the touch sensibility for move.
  12548. * The higher the faster.
  12549. */
  12550. touchMoveSensibility: number;
  12551. private _offsetX;
  12552. private _offsetY;
  12553. private _pointerPressed;
  12554. private _pointerInput;
  12555. private _observer;
  12556. private _onLostFocus;
  12557. /**
  12558. * Attach the input controls to a specific dom element to get the input from.
  12559. * @param element Defines the element the controls should be listened from
  12560. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12561. */
  12562. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12563. /**
  12564. * Detach the current controls from the specified dom element.
  12565. * @param element Defines the element to stop listening the inputs from
  12566. */
  12567. detachControl(element: Nullable<HTMLElement>): void;
  12568. /**
  12569. * Update the current camera state depending on the inputs that have been used this frame.
  12570. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12571. */
  12572. checkInputs(): void;
  12573. /**
  12574. * Gets the class name of the current intput.
  12575. * @returns the class name
  12576. */
  12577. getClassName(): string;
  12578. /**
  12579. * Get the friendly name associated with the input class.
  12580. * @returns the input friendly name
  12581. */
  12582. getSimpleName(): string;
  12583. }
  12584. }
  12585. declare module BABYLON {
  12586. /**
  12587. * Default Inputs manager for the FreeCamera.
  12588. * It groups all the default supported inputs for ease of use.
  12589. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12590. */
  12591. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12592. /**
  12593. * @hidden
  12594. */
  12595. _mouseInput: Nullable<FreeCameraMouseInput>;
  12596. /**
  12597. * Instantiates a new FreeCameraInputsManager.
  12598. * @param camera Defines the camera the inputs belong to
  12599. */
  12600. constructor(camera: FreeCamera);
  12601. /**
  12602. * Add keyboard input support to the input manager.
  12603. * @returns the current input manager
  12604. */
  12605. addKeyboard(): FreeCameraInputsManager;
  12606. /**
  12607. * Add mouse input support to the input manager.
  12608. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12609. * @returns the current input manager
  12610. */
  12611. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12612. /**
  12613. * Removes the mouse input support from the manager
  12614. * @returns the current input manager
  12615. */
  12616. removeMouse(): FreeCameraInputsManager;
  12617. /**
  12618. * Add touch input support to the input manager.
  12619. * @returns the current input manager
  12620. */
  12621. addTouch(): FreeCameraInputsManager;
  12622. /**
  12623. * Remove all attached input methods from a camera
  12624. */
  12625. clear(): void;
  12626. }
  12627. }
  12628. declare module BABYLON {
  12629. /**
  12630. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12631. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12632. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12633. */
  12634. export class FreeCamera extends TargetCamera {
  12635. /**
  12636. * Define the collision ellipsoid of the camera.
  12637. * This is helpful to simulate a camera body like the player body around the camera
  12638. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12639. */
  12640. ellipsoid: Vector3;
  12641. /**
  12642. * Define an offset for the position of the ellipsoid around the camera.
  12643. * This can be helpful to determine the center of the body near the gravity center of the body
  12644. * instead of its head.
  12645. */
  12646. ellipsoidOffset: Vector3;
  12647. /**
  12648. * Enable or disable collisions of the camera with the rest of the scene objects.
  12649. */
  12650. checkCollisions: boolean;
  12651. /**
  12652. * Enable or disable gravity on the camera.
  12653. */
  12654. applyGravity: boolean;
  12655. /**
  12656. * Define the input manager associated to the camera.
  12657. */
  12658. inputs: FreeCameraInputsManager;
  12659. /**
  12660. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12661. * Higher values reduce sensitivity.
  12662. */
  12663. /**
  12664. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12665. * Higher values reduce sensitivity.
  12666. */
  12667. angularSensibility: number;
  12668. /**
  12669. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12670. */
  12671. keysUp: number[];
  12672. /**
  12673. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12674. */
  12675. keysDown: number[];
  12676. /**
  12677. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12678. */
  12679. keysLeft: number[];
  12680. /**
  12681. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12682. */
  12683. keysRight: number[];
  12684. /**
  12685. * Event raised when the camera collide with a mesh in the scene.
  12686. */
  12687. onCollide: (collidedMesh: AbstractMesh) => void;
  12688. private _collider;
  12689. private _needMoveForGravity;
  12690. private _oldPosition;
  12691. private _diffPosition;
  12692. private _newPosition;
  12693. /** @hidden */
  12694. _localDirection: Vector3;
  12695. /** @hidden */
  12696. _transformedDirection: Vector3;
  12697. /**
  12698. * Instantiates a Free Camera.
  12699. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12700. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12701. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12702. * @param name Define the name of the camera in the scene
  12703. * @param position Define the start position of the camera in the scene
  12704. * @param scene Define the scene the camera belongs to
  12705. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12706. */
  12707. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12708. /**
  12709. * Attached controls to the current camera.
  12710. * @param element Defines the element the controls should be listened from
  12711. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12712. */
  12713. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12714. /**
  12715. * Detach the current controls from the camera.
  12716. * The camera will stop reacting to inputs.
  12717. * @param element Defines the element to stop listening the inputs from
  12718. */
  12719. detachControl(element: HTMLElement): void;
  12720. private _collisionMask;
  12721. /**
  12722. * Define a collision mask to limit the list of object the camera can collide with
  12723. */
  12724. collisionMask: number;
  12725. /** @hidden */
  12726. _collideWithWorld(displacement: Vector3): void;
  12727. private _onCollisionPositionChange;
  12728. /** @hidden */
  12729. _checkInputs(): void;
  12730. /** @hidden */
  12731. _decideIfNeedsToMove(): boolean;
  12732. /** @hidden */
  12733. _updatePosition(): void;
  12734. /**
  12735. * Destroy the camera and release the current resources hold by it.
  12736. */
  12737. dispose(): void;
  12738. /**
  12739. * Gets the current object class name.
  12740. * @return the class name
  12741. */
  12742. getClassName(): string;
  12743. }
  12744. }
  12745. declare module BABYLON {
  12746. /**
  12747. * Represents a gamepad control stick position
  12748. */
  12749. export class StickValues {
  12750. /**
  12751. * The x component of the control stick
  12752. */
  12753. x: number;
  12754. /**
  12755. * The y component of the control stick
  12756. */
  12757. y: number;
  12758. /**
  12759. * Initializes the gamepad x and y control stick values
  12760. * @param x The x component of the gamepad control stick value
  12761. * @param y The y component of the gamepad control stick value
  12762. */
  12763. constructor(
  12764. /**
  12765. * The x component of the control stick
  12766. */
  12767. x: number,
  12768. /**
  12769. * The y component of the control stick
  12770. */
  12771. y: number);
  12772. }
  12773. /**
  12774. * An interface which manages callbacks for gamepad button changes
  12775. */
  12776. export interface GamepadButtonChanges {
  12777. /**
  12778. * Called when a gamepad has been changed
  12779. */
  12780. changed: boolean;
  12781. /**
  12782. * Called when a gamepad press event has been triggered
  12783. */
  12784. pressChanged: boolean;
  12785. /**
  12786. * Called when a touch event has been triggered
  12787. */
  12788. touchChanged: boolean;
  12789. /**
  12790. * Called when a value has changed
  12791. */
  12792. valueChanged: boolean;
  12793. }
  12794. /**
  12795. * Represents a gamepad
  12796. */
  12797. export class Gamepad {
  12798. /**
  12799. * The id of the gamepad
  12800. */
  12801. id: string;
  12802. /**
  12803. * The index of the gamepad
  12804. */
  12805. index: number;
  12806. /**
  12807. * The browser gamepad
  12808. */
  12809. browserGamepad: any;
  12810. /**
  12811. * Specifies what type of gamepad this represents
  12812. */
  12813. type: number;
  12814. private _leftStick;
  12815. private _rightStick;
  12816. /** @hidden */
  12817. _isConnected: boolean;
  12818. private _leftStickAxisX;
  12819. private _leftStickAxisY;
  12820. private _rightStickAxisX;
  12821. private _rightStickAxisY;
  12822. /**
  12823. * Triggered when the left control stick has been changed
  12824. */
  12825. private _onleftstickchanged;
  12826. /**
  12827. * Triggered when the right control stick has been changed
  12828. */
  12829. private _onrightstickchanged;
  12830. /**
  12831. * Represents a gamepad controller
  12832. */
  12833. static GAMEPAD: number;
  12834. /**
  12835. * Represents a generic controller
  12836. */
  12837. static GENERIC: number;
  12838. /**
  12839. * Represents an XBox controller
  12840. */
  12841. static XBOX: number;
  12842. /**
  12843. * Represents a pose-enabled controller
  12844. */
  12845. static POSE_ENABLED: number;
  12846. /**
  12847. * Specifies whether the left control stick should be Y-inverted
  12848. */
  12849. protected _invertLeftStickY: boolean;
  12850. /**
  12851. * Specifies if the gamepad has been connected
  12852. */
  12853. readonly isConnected: boolean;
  12854. /**
  12855. * Initializes the gamepad
  12856. * @param id The id of the gamepad
  12857. * @param index The index of the gamepad
  12858. * @param browserGamepad The browser gamepad
  12859. * @param leftStickX The x component of the left joystick
  12860. * @param leftStickY The y component of the left joystick
  12861. * @param rightStickX The x component of the right joystick
  12862. * @param rightStickY The y component of the right joystick
  12863. */
  12864. constructor(
  12865. /**
  12866. * The id of the gamepad
  12867. */
  12868. id: string,
  12869. /**
  12870. * The index of the gamepad
  12871. */
  12872. index: number,
  12873. /**
  12874. * The browser gamepad
  12875. */
  12876. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12877. /**
  12878. * Callback triggered when the left joystick has changed
  12879. * @param callback
  12880. */
  12881. onleftstickchanged(callback: (values: StickValues) => void): void;
  12882. /**
  12883. * Callback triggered when the right joystick has changed
  12884. * @param callback
  12885. */
  12886. onrightstickchanged(callback: (values: StickValues) => void): void;
  12887. /**
  12888. * Gets the left joystick
  12889. */
  12890. /**
  12891. * Sets the left joystick values
  12892. */
  12893. leftStick: StickValues;
  12894. /**
  12895. * Gets the right joystick
  12896. */
  12897. /**
  12898. * Sets the right joystick value
  12899. */
  12900. rightStick: StickValues;
  12901. /**
  12902. * Updates the gamepad joystick positions
  12903. */
  12904. update(): void;
  12905. /**
  12906. * Disposes the gamepad
  12907. */
  12908. dispose(): void;
  12909. }
  12910. /**
  12911. * Represents a generic gamepad
  12912. */
  12913. export class GenericPad extends Gamepad {
  12914. private _buttons;
  12915. private _onbuttondown;
  12916. private _onbuttonup;
  12917. /**
  12918. * Observable triggered when a button has been pressed
  12919. */
  12920. onButtonDownObservable: Observable<number>;
  12921. /**
  12922. * Observable triggered when a button has been released
  12923. */
  12924. onButtonUpObservable: Observable<number>;
  12925. /**
  12926. * Callback triggered when a button has been pressed
  12927. * @param callback Called when a button has been pressed
  12928. */
  12929. onbuttondown(callback: (buttonPressed: number) => void): void;
  12930. /**
  12931. * Callback triggered when a button has been released
  12932. * @param callback Called when a button has been released
  12933. */
  12934. onbuttonup(callback: (buttonReleased: number) => void): void;
  12935. /**
  12936. * Initializes the generic gamepad
  12937. * @param id The id of the generic gamepad
  12938. * @param index The index of the generic gamepad
  12939. * @param browserGamepad The browser gamepad
  12940. */
  12941. constructor(id: string, index: number, browserGamepad: any);
  12942. private _setButtonValue;
  12943. /**
  12944. * Updates the generic gamepad
  12945. */
  12946. update(): void;
  12947. /**
  12948. * Disposes the generic gamepad
  12949. */
  12950. dispose(): void;
  12951. }
  12952. }
  12953. declare module BABYLON {
  12954. /**
  12955. * Defines the types of pose enabled controllers that are supported
  12956. */
  12957. export enum PoseEnabledControllerType {
  12958. /**
  12959. * HTC Vive
  12960. */
  12961. VIVE = 0,
  12962. /**
  12963. * Oculus Rift
  12964. */
  12965. OCULUS = 1,
  12966. /**
  12967. * Windows mixed reality
  12968. */
  12969. WINDOWS = 2,
  12970. /**
  12971. * Samsung gear VR
  12972. */
  12973. GEAR_VR = 3,
  12974. /**
  12975. * Google Daydream
  12976. */
  12977. DAYDREAM = 4,
  12978. /**
  12979. * Generic
  12980. */
  12981. GENERIC = 5
  12982. }
  12983. /**
  12984. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12985. */
  12986. export interface MutableGamepadButton {
  12987. /**
  12988. * Value of the button/trigger
  12989. */
  12990. value: number;
  12991. /**
  12992. * If the button/trigger is currently touched
  12993. */
  12994. touched: boolean;
  12995. /**
  12996. * If the button/trigger is currently pressed
  12997. */
  12998. pressed: boolean;
  12999. }
  13000. /**
  13001. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13002. * @hidden
  13003. */
  13004. export interface ExtendedGamepadButton extends GamepadButton {
  13005. /**
  13006. * If the button/trigger is currently pressed
  13007. */
  13008. readonly pressed: boolean;
  13009. /**
  13010. * If the button/trigger is currently touched
  13011. */
  13012. readonly touched: boolean;
  13013. /**
  13014. * Value of the button/trigger
  13015. */
  13016. readonly value: number;
  13017. }
  13018. /** @hidden */
  13019. export interface _GamePadFactory {
  13020. /**
  13021. * Returns wether or not the current gamepad can be created for this type of controller.
  13022. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13023. * @returns true if it can be created, otherwise false
  13024. */
  13025. canCreate(gamepadInfo: any): boolean;
  13026. /**
  13027. * Creates a new instance of the Gamepad.
  13028. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13029. * @returns the new gamepad instance
  13030. */
  13031. create(gamepadInfo: any): Gamepad;
  13032. }
  13033. /**
  13034. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13035. */
  13036. export class PoseEnabledControllerHelper {
  13037. /** @hidden */
  13038. static _ControllerFactories: _GamePadFactory[];
  13039. /** @hidden */
  13040. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13041. /**
  13042. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13043. * @param vrGamepad the gamepad to initialized
  13044. * @returns a vr controller of the type the gamepad identified as
  13045. */
  13046. static InitiateController(vrGamepad: any): Gamepad;
  13047. }
  13048. /**
  13049. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13050. */
  13051. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13052. private _deviceRoomPosition;
  13053. private _deviceRoomRotationQuaternion;
  13054. /**
  13055. * The device position in babylon space
  13056. */
  13057. devicePosition: Vector3;
  13058. /**
  13059. * The device rotation in babylon space
  13060. */
  13061. deviceRotationQuaternion: Quaternion;
  13062. /**
  13063. * The scale factor of the device in babylon space
  13064. */
  13065. deviceScaleFactor: number;
  13066. /**
  13067. * (Likely devicePosition should be used instead) The device position in its room space
  13068. */
  13069. position: Vector3;
  13070. /**
  13071. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13072. */
  13073. rotationQuaternion: Quaternion;
  13074. /**
  13075. * The type of controller (Eg. Windows mixed reality)
  13076. */
  13077. controllerType: PoseEnabledControllerType;
  13078. protected _calculatedPosition: Vector3;
  13079. private _calculatedRotation;
  13080. /**
  13081. * The raw pose from the device
  13082. */
  13083. rawPose: DevicePose;
  13084. private _trackPosition;
  13085. private _maxRotationDistFromHeadset;
  13086. private _draggedRoomRotation;
  13087. /**
  13088. * @hidden
  13089. */
  13090. _disableTrackPosition(fixedPosition: Vector3): void;
  13091. /**
  13092. * Internal, the mesh attached to the controller
  13093. * @hidden
  13094. */
  13095. _mesh: Nullable<AbstractMesh>;
  13096. private _poseControlledCamera;
  13097. private _leftHandSystemQuaternion;
  13098. /**
  13099. * Internal, matrix used to convert room space to babylon space
  13100. * @hidden
  13101. */
  13102. _deviceToWorld: Matrix;
  13103. /**
  13104. * Node to be used when casting a ray from the controller
  13105. * @hidden
  13106. */
  13107. _pointingPoseNode: Nullable<TransformNode>;
  13108. /**
  13109. * Name of the child mesh that can be used to cast a ray from the controller
  13110. */
  13111. static readonly POINTING_POSE: string;
  13112. /**
  13113. * Creates a new PoseEnabledController from a gamepad
  13114. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13115. */
  13116. constructor(browserGamepad: any);
  13117. private _workingMatrix;
  13118. /**
  13119. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13120. */
  13121. update(): void;
  13122. /**
  13123. * Updates only the pose device and mesh without doing any button event checking
  13124. */
  13125. protected _updatePoseAndMesh(): void;
  13126. /**
  13127. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13128. * @param poseData raw pose fromthe device
  13129. */
  13130. updateFromDevice(poseData: DevicePose): void;
  13131. /**
  13132. * @hidden
  13133. */
  13134. _meshAttachedObservable: Observable<AbstractMesh>;
  13135. /**
  13136. * Attaches a mesh to the controller
  13137. * @param mesh the mesh to be attached
  13138. */
  13139. attachToMesh(mesh: AbstractMesh): void;
  13140. /**
  13141. * Attaches the controllers mesh to a camera
  13142. * @param camera the camera the mesh should be attached to
  13143. */
  13144. attachToPoseControlledCamera(camera: TargetCamera): void;
  13145. /**
  13146. * Disposes of the controller
  13147. */
  13148. dispose(): void;
  13149. /**
  13150. * The mesh that is attached to the controller
  13151. */
  13152. readonly mesh: Nullable<AbstractMesh>;
  13153. /**
  13154. * Gets the ray of the controller in the direction the controller is pointing
  13155. * @param length the length the resulting ray should be
  13156. * @returns a ray in the direction the controller is pointing
  13157. */
  13158. getForwardRay(length?: number): Ray;
  13159. }
  13160. }
  13161. declare module BABYLON {
  13162. /**
  13163. * Defines the WebVRController object that represents controllers tracked in 3D space
  13164. */
  13165. export abstract class WebVRController extends PoseEnabledController {
  13166. /**
  13167. * Internal, the default controller model for the controller
  13168. */
  13169. protected _defaultModel: AbstractMesh;
  13170. /**
  13171. * Fired when the trigger state has changed
  13172. */
  13173. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13174. /**
  13175. * Fired when the main button state has changed
  13176. */
  13177. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13178. /**
  13179. * Fired when the secondary button state has changed
  13180. */
  13181. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13182. /**
  13183. * Fired when the pad state has changed
  13184. */
  13185. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13186. /**
  13187. * Fired when controllers stick values have changed
  13188. */
  13189. onPadValuesChangedObservable: Observable<StickValues>;
  13190. /**
  13191. * Array of button availible on the controller
  13192. */
  13193. protected _buttons: Array<MutableGamepadButton>;
  13194. private _onButtonStateChange;
  13195. /**
  13196. * Fired when a controller button's state has changed
  13197. * @param callback the callback containing the button that was modified
  13198. */
  13199. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13200. /**
  13201. * X and Y axis corrisponding to the controllers joystick
  13202. */
  13203. pad: StickValues;
  13204. /**
  13205. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13206. */
  13207. hand: string;
  13208. /**
  13209. * The default controller model for the controller
  13210. */
  13211. readonly defaultModel: AbstractMesh;
  13212. /**
  13213. * Creates a new WebVRController from a gamepad
  13214. * @param vrGamepad the gamepad that the WebVRController should be created from
  13215. */
  13216. constructor(vrGamepad: any);
  13217. /**
  13218. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13219. */
  13220. update(): void;
  13221. /**
  13222. * Function to be called when a button is modified
  13223. */
  13224. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13225. /**
  13226. * Loads a mesh and attaches it to the controller
  13227. * @param scene the scene the mesh should be added to
  13228. * @param meshLoaded callback for when the mesh has been loaded
  13229. */
  13230. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13231. private _setButtonValue;
  13232. private _changes;
  13233. private _checkChanges;
  13234. /**
  13235. * Disposes of th webVRCOntroller
  13236. */
  13237. dispose(): void;
  13238. }
  13239. }
  13240. declare module BABYLON {
  13241. /**
  13242. * The HemisphericLight simulates the ambient environment light,
  13243. * so the passed direction is the light reflection direction, not the incoming direction.
  13244. */
  13245. export class HemisphericLight extends Light {
  13246. /**
  13247. * The groundColor is the light in the opposite direction to the one specified during creation.
  13248. * 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.
  13249. */
  13250. groundColor: Color3;
  13251. /**
  13252. * The light reflection direction, not the incoming direction.
  13253. */
  13254. direction: Vector3;
  13255. /**
  13256. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13257. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13258. * The HemisphericLight can't cast shadows.
  13259. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13260. * @param name The friendly name of the light
  13261. * @param direction The direction of the light reflection
  13262. * @param scene The scene the light belongs to
  13263. */
  13264. constructor(name: string, direction: Vector3, scene: Scene);
  13265. protected _buildUniformLayout(): void;
  13266. /**
  13267. * Returns the string "HemisphericLight".
  13268. * @return The class name
  13269. */
  13270. getClassName(): string;
  13271. /**
  13272. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13273. * Returns the updated direction.
  13274. * @param target The target the direction should point to
  13275. * @return The computed direction
  13276. */
  13277. setDirectionToTarget(target: Vector3): Vector3;
  13278. /**
  13279. * Returns the shadow generator associated to the light.
  13280. * @returns Always null for hemispheric lights because it does not support shadows.
  13281. */
  13282. getShadowGenerator(): Nullable<IShadowGenerator>;
  13283. /**
  13284. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13285. * @param effect The effect to update
  13286. * @param lightIndex The index of the light in the effect to update
  13287. * @returns The hemispheric light
  13288. */
  13289. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13290. /**
  13291. * Computes the world matrix of the node
  13292. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13293. * @param useWasUpdatedFlag defines a reserved property
  13294. * @returns the world matrix
  13295. */
  13296. computeWorldMatrix(): Matrix;
  13297. /**
  13298. * Returns the integer 3.
  13299. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13300. */
  13301. getTypeID(): number;
  13302. /**
  13303. * Prepares the list of defines specific to the light type.
  13304. * @param defines the list of defines
  13305. * @param lightIndex defines the index of the light for the effect
  13306. */
  13307. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13308. }
  13309. }
  13310. declare module BABYLON {
  13311. /** @hidden */
  13312. export var vrMultiviewToSingleviewPixelShader: {
  13313. name: string;
  13314. shader: string;
  13315. };
  13316. }
  13317. declare module BABYLON {
  13318. /**
  13319. * Renders to multiple views with a single draw call
  13320. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13321. */
  13322. export class MultiviewRenderTarget extends RenderTargetTexture {
  13323. /**
  13324. * Creates a multiview render target
  13325. * @param scene scene used with the render target
  13326. * @param size the size of the render target (used for each view)
  13327. */
  13328. constructor(scene: Scene, size?: number | {
  13329. width: number;
  13330. height: number;
  13331. } | {
  13332. ratio: number;
  13333. });
  13334. /**
  13335. * @hidden
  13336. * @param faceIndex the face index, if its a cube texture
  13337. */
  13338. _bindFrameBuffer(faceIndex?: number): void;
  13339. /**
  13340. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13341. * @returns the view count
  13342. */
  13343. getViewCount(): number;
  13344. }
  13345. }
  13346. declare module BABYLON {
  13347. interface Engine {
  13348. /**
  13349. * Creates a new multiview render target
  13350. * @param width defines the width of the texture
  13351. * @param height defines the height of the texture
  13352. * @returns the created multiview texture
  13353. */
  13354. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13355. /**
  13356. * Binds a multiview framebuffer to be drawn to
  13357. * @param multiviewTexture texture to bind
  13358. */
  13359. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13360. }
  13361. interface Camera {
  13362. /**
  13363. * @hidden
  13364. * 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)
  13365. */
  13366. _useMultiviewToSingleView: boolean;
  13367. /**
  13368. * @hidden
  13369. * 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)
  13370. */
  13371. _multiviewTexture: Nullable<RenderTargetTexture>;
  13372. /**
  13373. * @hidden
  13374. * ensures the multiview texture of the camera exists and has the specified width/height
  13375. * @param width height to set on the multiview texture
  13376. * @param height width to set on the multiview texture
  13377. */
  13378. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13379. }
  13380. interface Scene {
  13381. /** @hidden */
  13382. _transformMatrixR: Matrix;
  13383. /** @hidden */
  13384. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13385. /** @hidden */
  13386. _createMultiviewUbo(): void;
  13387. /** @hidden */
  13388. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13389. /** @hidden */
  13390. _renderMultiviewToSingleView(camera: Camera): void;
  13391. }
  13392. }
  13393. declare module BABYLON {
  13394. /**
  13395. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13396. * This will not be used for webXR as it supports displaying texture arrays directly
  13397. */
  13398. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13399. /**
  13400. * Initializes a VRMultiviewToSingleview
  13401. * @param name name of the post process
  13402. * @param camera camera to be applied to
  13403. * @param scaleFactor scaling factor to the size of the output texture
  13404. */
  13405. constructor(name: string, camera: Camera, scaleFactor: number);
  13406. }
  13407. }
  13408. declare module BABYLON {
  13409. interface Engine {
  13410. /** @hidden */
  13411. _vrDisplay: any;
  13412. /** @hidden */
  13413. _vrSupported: boolean;
  13414. /** @hidden */
  13415. _oldSize: Size;
  13416. /** @hidden */
  13417. _oldHardwareScaleFactor: number;
  13418. /** @hidden */
  13419. _vrExclusivePointerMode: boolean;
  13420. /** @hidden */
  13421. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13422. /** @hidden */
  13423. _onVRDisplayPointerRestricted: () => void;
  13424. /** @hidden */
  13425. _onVRDisplayPointerUnrestricted: () => void;
  13426. /** @hidden */
  13427. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13428. /** @hidden */
  13429. _onVrDisplayDisconnect: Nullable<() => void>;
  13430. /** @hidden */
  13431. _onVrDisplayPresentChange: Nullable<() => void>;
  13432. /**
  13433. * Observable signaled when VR display mode changes
  13434. */
  13435. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13436. /**
  13437. * Observable signaled when VR request present is complete
  13438. */
  13439. onVRRequestPresentComplete: Observable<boolean>;
  13440. /**
  13441. * Observable signaled when VR request present starts
  13442. */
  13443. onVRRequestPresentStart: Observable<Engine>;
  13444. /**
  13445. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13446. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13447. */
  13448. isInVRExclusivePointerMode: boolean;
  13449. /**
  13450. * Gets a boolean indicating if a webVR device was detected
  13451. * @returns true if a webVR device was detected
  13452. */
  13453. isVRDevicePresent(): boolean;
  13454. /**
  13455. * Gets the current webVR device
  13456. * @returns the current webVR device (or null)
  13457. */
  13458. getVRDevice(): any;
  13459. /**
  13460. * Initializes a webVR display and starts listening to display change events
  13461. * The onVRDisplayChangedObservable will be notified upon these changes
  13462. * @returns A promise containing a VRDisplay and if vr is supported
  13463. */
  13464. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13465. /** @hidden */
  13466. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13467. /**
  13468. * Call this function to switch to webVR mode
  13469. * Will do nothing if webVR is not supported or if there is no webVR device
  13470. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13471. */
  13472. enableVR(): void;
  13473. /** @hidden */
  13474. _onVRFullScreenTriggered(): void;
  13475. }
  13476. }
  13477. declare module BABYLON {
  13478. /**
  13479. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13480. * IMPORTANT!! The data is right-hand data.
  13481. * @export
  13482. * @interface DevicePose
  13483. */
  13484. export interface DevicePose {
  13485. /**
  13486. * The position of the device, values in array are [x,y,z].
  13487. */
  13488. readonly position: Nullable<Float32Array>;
  13489. /**
  13490. * The linearVelocity of the device, values in array are [x,y,z].
  13491. */
  13492. readonly linearVelocity: Nullable<Float32Array>;
  13493. /**
  13494. * The linearAcceleration of the device, values in array are [x,y,z].
  13495. */
  13496. readonly linearAcceleration: Nullable<Float32Array>;
  13497. /**
  13498. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13499. */
  13500. readonly orientation: Nullable<Float32Array>;
  13501. /**
  13502. * The angularVelocity of the device, values in array are [x,y,z].
  13503. */
  13504. readonly angularVelocity: Nullable<Float32Array>;
  13505. /**
  13506. * The angularAcceleration of the device, values in array are [x,y,z].
  13507. */
  13508. readonly angularAcceleration: Nullable<Float32Array>;
  13509. }
  13510. /**
  13511. * Interface representing a pose controlled object in Babylon.
  13512. * A pose controlled object has both regular pose values as well as pose values
  13513. * from an external device such as a VR head mounted display
  13514. */
  13515. export interface PoseControlled {
  13516. /**
  13517. * The position of the object in babylon space.
  13518. */
  13519. position: Vector3;
  13520. /**
  13521. * The rotation quaternion of the object in babylon space.
  13522. */
  13523. rotationQuaternion: Quaternion;
  13524. /**
  13525. * The position of the device in babylon space.
  13526. */
  13527. devicePosition?: Vector3;
  13528. /**
  13529. * The rotation quaternion of the device in babylon space.
  13530. */
  13531. deviceRotationQuaternion: Quaternion;
  13532. /**
  13533. * The raw pose coming from the device.
  13534. */
  13535. rawPose: Nullable<DevicePose>;
  13536. /**
  13537. * The scale of the device to be used when translating from device space to babylon space.
  13538. */
  13539. deviceScaleFactor: number;
  13540. /**
  13541. * Updates the poseControlled values based on the input device pose.
  13542. * @param poseData the pose data to update the object with
  13543. */
  13544. updateFromDevice(poseData: DevicePose): void;
  13545. }
  13546. /**
  13547. * Set of options to customize the webVRCamera
  13548. */
  13549. export interface WebVROptions {
  13550. /**
  13551. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13552. */
  13553. trackPosition?: boolean;
  13554. /**
  13555. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13556. */
  13557. positionScale?: number;
  13558. /**
  13559. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13560. */
  13561. displayName?: string;
  13562. /**
  13563. * Should the native controller meshes be initialized. (default: true)
  13564. */
  13565. controllerMeshes?: boolean;
  13566. /**
  13567. * Creating a default HemiLight only on controllers. (default: true)
  13568. */
  13569. defaultLightingOnControllers?: boolean;
  13570. /**
  13571. * If you don't want to use the default VR button of the helper. (default: false)
  13572. */
  13573. useCustomVRButton?: boolean;
  13574. /**
  13575. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13576. */
  13577. customVRButton?: HTMLButtonElement;
  13578. /**
  13579. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13580. */
  13581. rayLength?: number;
  13582. /**
  13583. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13584. */
  13585. defaultHeight?: number;
  13586. /**
  13587. * If multiview should be used if availible (default: false)
  13588. */
  13589. useMultiview?: boolean;
  13590. }
  13591. /**
  13592. * This represents a WebVR camera.
  13593. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13594. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13595. */
  13596. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13597. private webVROptions;
  13598. /**
  13599. * @hidden
  13600. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13601. */
  13602. _vrDevice: any;
  13603. /**
  13604. * The rawPose of the vrDevice.
  13605. */
  13606. rawPose: Nullable<DevicePose>;
  13607. private _onVREnabled;
  13608. private _specsVersion;
  13609. private _attached;
  13610. private _frameData;
  13611. protected _descendants: Array<Node>;
  13612. private _deviceRoomPosition;
  13613. /** @hidden */
  13614. _deviceRoomRotationQuaternion: Quaternion;
  13615. private _standingMatrix;
  13616. /**
  13617. * Represents device position in babylon space.
  13618. */
  13619. devicePosition: Vector3;
  13620. /**
  13621. * Represents device rotation in babylon space.
  13622. */
  13623. deviceRotationQuaternion: Quaternion;
  13624. /**
  13625. * The scale of the device to be used when translating from device space to babylon space.
  13626. */
  13627. deviceScaleFactor: number;
  13628. private _deviceToWorld;
  13629. private _worldToDevice;
  13630. /**
  13631. * References to the webVR controllers for the vrDevice.
  13632. */
  13633. controllers: Array<WebVRController>;
  13634. /**
  13635. * Emits an event when a controller is attached.
  13636. */
  13637. onControllersAttachedObservable: Observable<WebVRController[]>;
  13638. /**
  13639. * Emits an event when a controller's mesh has been loaded;
  13640. */
  13641. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13642. /**
  13643. * Emits an event when the HMD's pose has been updated.
  13644. */
  13645. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13646. private _poseSet;
  13647. /**
  13648. * If the rig cameras be used as parent instead of this camera.
  13649. */
  13650. rigParenting: boolean;
  13651. private _lightOnControllers;
  13652. private _defaultHeight?;
  13653. /**
  13654. * Instantiates a WebVRFreeCamera.
  13655. * @param name The name of the WebVRFreeCamera
  13656. * @param position The starting anchor position for the camera
  13657. * @param scene The scene the camera belongs to
  13658. * @param webVROptions a set of customizable options for the webVRCamera
  13659. */
  13660. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13661. /**
  13662. * Gets the device distance from the ground in meters.
  13663. * @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.
  13664. */
  13665. deviceDistanceToRoomGround(): number;
  13666. /**
  13667. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13668. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13669. */
  13670. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13671. /**
  13672. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13673. * @returns A promise with a boolean set to if the standing matrix is supported.
  13674. */
  13675. useStandingMatrixAsync(): Promise<boolean>;
  13676. /**
  13677. * Disposes the camera
  13678. */
  13679. dispose(): void;
  13680. /**
  13681. * Gets a vrController by name.
  13682. * @param name The name of the controller to retreive
  13683. * @returns the controller matching the name specified or null if not found
  13684. */
  13685. getControllerByName(name: string): Nullable<WebVRController>;
  13686. private _leftController;
  13687. /**
  13688. * The controller corrisponding to the users left hand.
  13689. */
  13690. readonly leftController: Nullable<WebVRController>;
  13691. private _rightController;
  13692. /**
  13693. * The controller corrisponding to the users right hand.
  13694. */
  13695. readonly rightController: Nullable<WebVRController>;
  13696. /**
  13697. * Casts a ray forward from the vrCamera's gaze.
  13698. * @param length Length of the ray (default: 100)
  13699. * @returns the ray corrisponding to the gaze
  13700. */
  13701. getForwardRay(length?: number): Ray;
  13702. /**
  13703. * @hidden
  13704. * Updates the camera based on device's frame data
  13705. */
  13706. _checkInputs(): void;
  13707. /**
  13708. * Updates the poseControlled values based on the input device pose.
  13709. * @param poseData Pose coming from the device
  13710. */
  13711. updateFromDevice(poseData: DevicePose): void;
  13712. private _htmlElementAttached;
  13713. private _detachIfAttached;
  13714. /**
  13715. * WebVR's attach control will start broadcasting frames to the device.
  13716. * Note that in certain browsers (chrome for example) this function must be called
  13717. * within a user-interaction callback. Example:
  13718. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13719. *
  13720. * @param element html element to attach the vrDevice to
  13721. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13722. */
  13723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13724. /**
  13725. * Detaches the camera from the html element and disables VR
  13726. *
  13727. * @param element html element to detach from
  13728. */
  13729. detachControl(element: HTMLElement): void;
  13730. /**
  13731. * @returns the name of this class
  13732. */
  13733. getClassName(): string;
  13734. /**
  13735. * Calls resetPose on the vrDisplay
  13736. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13737. */
  13738. resetToCurrentRotation(): void;
  13739. /**
  13740. * @hidden
  13741. * Updates the rig cameras (left and right eye)
  13742. */
  13743. _updateRigCameras(): void;
  13744. private _workingVector;
  13745. private _oneVector;
  13746. private _workingMatrix;
  13747. private updateCacheCalled;
  13748. private _correctPositionIfNotTrackPosition;
  13749. /**
  13750. * @hidden
  13751. * Updates the cached values of the camera
  13752. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13753. */
  13754. _updateCache(ignoreParentClass?: boolean): void;
  13755. /**
  13756. * @hidden
  13757. * Get current device position in babylon world
  13758. */
  13759. _computeDevicePosition(): void;
  13760. /**
  13761. * Updates the current device position and rotation in the babylon world
  13762. */
  13763. update(): void;
  13764. /**
  13765. * @hidden
  13766. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13767. * @returns an identity matrix
  13768. */
  13769. _getViewMatrix(): Matrix;
  13770. private _tmpMatrix;
  13771. /**
  13772. * This function is called by the two RIG cameras.
  13773. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13774. * @hidden
  13775. */
  13776. _getWebVRViewMatrix(): Matrix;
  13777. /** @hidden */
  13778. _getWebVRProjectionMatrix(): Matrix;
  13779. private _onGamepadConnectedObserver;
  13780. private _onGamepadDisconnectedObserver;
  13781. private _updateCacheWhenTrackingDisabledObserver;
  13782. /**
  13783. * Initializes the controllers and their meshes
  13784. */
  13785. initControllers(): void;
  13786. }
  13787. }
  13788. declare module BABYLON {
  13789. /**
  13790. * Size options for a post process
  13791. */
  13792. export type PostProcessOptions = {
  13793. width: number;
  13794. height: number;
  13795. };
  13796. /**
  13797. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13798. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13799. */
  13800. export class PostProcess {
  13801. /** Name of the PostProcess. */
  13802. name: string;
  13803. /**
  13804. * Gets or sets the unique id of the post process
  13805. */
  13806. uniqueId: number;
  13807. /**
  13808. * Width of the texture to apply the post process on
  13809. */
  13810. width: number;
  13811. /**
  13812. * Height of the texture to apply the post process on
  13813. */
  13814. height: number;
  13815. /**
  13816. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13817. * @hidden
  13818. */
  13819. _outputTexture: Nullable<InternalTexture>;
  13820. /**
  13821. * Sampling mode used by the shader
  13822. * See https://doc.babylonjs.com/classes/3.1/texture
  13823. */
  13824. renderTargetSamplingMode: number;
  13825. /**
  13826. * Clear color to use when screen clearing
  13827. */
  13828. clearColor: Color4;
  13829. /**
  13830. * If the buffer needs to be cleared before applying the post process. (default: true)
  13831. * Should be set to false if shader will overwrite all previous pixels.
  13832. */
  13833. autoClear: boolean;
  13834. /**
  13835. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13836. */
  13837. alphaMode: number;
  13838. /**
  13839. * Sets the setAlphaBlendConstants of the babylon engine
  13840. */
  13841. alphaConstants: Color4;
  13842. /**
  13843. * Animations to be used for the post processing
  13844. */
  13845. animations: Animation[];
  13846. /**
  13847. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13848. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13849. */
  13850. enablePixelPerfectMode: boolean;
  13851. /**
  13852. * Force the postprocess to be applied without taking in account viewport
  13853. */
  13854. forceFullscreenViewport: boolean;
  13855. /**
  13856. * List of inspectable custom properties (used by the Inspector)
  13857. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13858. */
  13859. inspectableCustomProperties: IInspectable[];
  13860. /**
  13861. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13862. *
  13863. * | Value | Type | Description |
  13864. * | ----- | ----------------------------------- | ----------- |
  13865. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13866. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13867. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13868. *
  13869. */
  13870. scaleMode: number;
  13871. /**
  13872. * Force textures to be a power of two (default: false)
  13873. */
  13874. alwaysForcePOT: boolean;
  13875. private _samples;
  13876. /**
  13877. * Number of sample textures (default: 1)
  13878. */
  13879. samples: number;
  13880. /**
  13881. * Modify the scale of the post process to be the same as the viewport (default: false)
  13882. */
  13883. adaptScaleToCurrentViewport: boolean;
  13884. private _camera;
  13885. private _scene;
  13886. private _engine;
  13887. private _options;
  13888. private _reusable;
  13889. private _textureType;
  13890. /**
  13891. * Smart array of input and output textures for the post process.
  13892. * @hidden
  13893. */
  13894. _textures: SmartArray<InternalTexture>;
  13895. /**
  13896. * The index in _textures that corresponds to the output texture.
  13897. * @hidden
  13898. */
  13899. _currentRenderTextureInd: number;
  13900. private _effect;
  13901. private _samplers;
  13902. private _fragmentUrl;
  13903. private _vertexUrl;
  13904. private _parameters;
  13905. private _scaleRatio;
  13906. protected _indexParameters: any;
  13907. private _shareOutputWithPostProcess;
  13908. private _texelSize;
  13909. private _forcedOutputTexture;
  13910. /**
  13911. * Returns the fragment url or shader name used in the post process.
  13912. * @returns the fragment url or name in the shader store.
  13913. */
  13914. getEffectName(): string;
  13915. /**
  13916. * An event triggered when the postprocess is activated.
  13917. */
  13918. onActivateObservable: Observable<Camera>;
  13919. private _onActivateObserver;
  13920. /**
  13921. * A function that is added to the onActivateObservable
  13922. */
  13923. onActivate: Nullable<(camera: Camera) => void>;
  13924. /**
  13925. * An event triggered when the postprocess changes its size.
  13926. */
  13927. onSizeChangedObservable: Observable<PostProcess>;
  13928. private _onSizeChangedObserver;
  13929. /**
  13930. * A function that is added to the onSizeChangedObservable
  13931. */
  13932. onSizeChanged: (postProcess: PostProcess) => void;
  13933. /**
  13934. * An event triggered when the postprocess applies its effect.
  13935. */
  13936. onApplyObservable: Observable<Effect>;
  13937. private _onApplyObserver;
  13938. /**
  13939. * A function that is added to the onApplyObservable
  13940. */
  13941. onApply: (effect: Effect) => void;
  13942. /**
  13943. * An event triggered before rendering the postprocess
  13944. */
  13945. onBeforeRenderObservable: Observable<Effect>;
  13946. private _onBeforeRenderObserver;
  13947. /**
  13948. * A function that is added to the onBeforeRenderObservable
  13949. */
  13950. onBeforeRender: (effect: Effect) => void;
  13951. /**
  13952. * An event triggered after rendering the postprocess
  13953. */
  13954. onAfterRenderObservable: Observable<Effect>;
  13955. private _onAfterRenderObserver;
  13956. /**
  13957. * A function that is added to the onAfterRenderObservable
  13958. */
  13959. onAfterRender: (efect: Effect) => void;
  13960. /**
  13961. * 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
  13962. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13963. */
  13964. inputTexture: InternalTexture;
  13965. /**
  13966. * Gets the camera which post process is applied to.
  13967. * @returns The camera the post process is applied to.
  13968. */
  13969. getCamera(): Camera;
  13970. /**
  13971. * Gets the texel size of the postprocess.
  13972. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13973. */
  13974. readonly texelSize: Vector2;
  13975. /**
  13976. * Creates a new instance PostProcess
  13977. * @param name The name of the PostProcess.
  13978. * @param fragmentUrl The url of the fragment shader to be used.
  13979. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13980. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13981. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13982. * @param camera The camera to apply the render pass to.
  13983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13984. * @param engine The engine which the post process will be applied. (default: current engine)
  13985. * @param reusable If the post process can be reused on the same frame. (default: false)
  13986. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13987. * @param textureType Type of textures used when performing the post process. (default: 0)
  13988. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13989. * @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
  13990. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13991. */
  13992. constructor(
  13993. /** Name of the PostProcess. */
  13994. 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);
  13995. /**
  13996. * Gets a string idenfifying the name of the class
  13997. * @returns "PostProcess" string
  13998. */
  13999. getClassName(): string;
  14000. /**
  14001. * Gets the engine which this post process belongs to.
  14002. * @returns The engine the post process was enabled with.
  14003. */
  14004. getEngine(): Engine;
  14005. /**
  14006. * The effect that is created when initializing the post process.
  14007. * @returns The created effect corrisponding the the postprocess.
  14008. */
  14009. getEffect(): Effect;
  14010. /**
  14011. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  14012. * @param postProcess The post process to share the output with.
  14013. * @returns This post process.
  14014. */
  14015. shareOutputWith(postProcess: PostProcess): PostProcess;
  14016. /**
  14017. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  14018. * This should be called if the post process that shares output with this post process is disabled/disposed.
  14019. */
  14020. useOwnOutput(): void;
  14021. /**
  14022. * Updates the effect with the current post process compile time values and recompiles the shader.
  14023. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  14024. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  14025. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  14026. * @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
  14027. * @param onCompiled Called when the shader has been compiled.
  14028. * @param onError Called if there is an error when compiling a shader.
  14029. */
  14030. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  14031. /**
  14032. * The post process is reusable if it can be used multiple times within one frame.
  14033. * @returns If the post process is reusable
  14034. */
  14035. isReusable(): boolean;
  14036. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  14037. markTextureDirty(): void;
  14038. /**
  14039. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  14040. * 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.
  14041. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  14042. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  14043. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  14044. * @returns The target texture that was bound to be written to.
  14045. */
  14046. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  14047. /**
  14048. * If the post process is supported.
  14049. */
  14050. readonly isSupported: boolean;
  14051. /**
  14052. * The aspect ratio of the output texture.
  14053. */
  14054. readonly aspectRatio: number;
  14055. /**
  14056. * Get a value indicating if the post-process is ready to be used
  14057. * @returns true if the post-process is ready (shader is compiled)
  14058. */
  14059. isReady(): boolean;
  14060. /**
  14061. * Binds all textures and uniforms to the shader, this will be run on every pass.
  14062. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  14063. */
  14064. apply(): Nullable<Effect>;
  14065. private _disposeTextures;
  14066. /**
  14067. * Disposes the post process.
  14068. * @param camera The camera to dispose the post process on.
  14069. */
  14070. dispose(camera?: Camera): void;
  14071. }
  14072. }
  14073. declare module BABYLON {
  14074. /**
  14075. * PostProcessManager is used to manage one or more post processes or post process pipelines
  14076. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14077. */
  14078. export class PostProcessManager {
  14079. private _scene;
  14080. private _indexBuffer;
  14081. private _vertexBuffers;
  14082. /**
  14083. * Creates a new instance PostProcess
  14084. * @param scene The scene that the post process is associated with.
  14085. */
  14086. constructor(scene: Scene);
  14087. private _prepareBuffers;
  14088. private _buildIndexBuffer;
  14089. /**
  14090. * Rebuilds the vertex buffers of the manager.
  14091. * @hidden
  14092. */
  14093. _rebuild(): void;
  14094. /**
  14095. * Prepares a frame to be run through a post process.
  14096. * @param sourceTexture The input texture to the post procesess. (default: null)
  14097. * @param postProcesses An array of post processes to be run. (default: null)
  14098. * @returns True if the post processes were able to be run.
  14099. * @hidden
  14100. */
  14101. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  14102. /**
  14103. * Manually render a set of post processes to a texture.
  14104. * @param postProcesses An array of post processes to be run.
  14105. * @param targetTexture The target texture to render to.
  14106. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  14107. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  14108. * @param lodLevel defines which lod of the texture to render to
  14109. */
  14110. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  14111. /**
  14112. * Finalize the result of the output of the postprocesses.
  14113. * @param doNotPresent If true the result will not be displayed to the screen.
  14114. * @param targetTexture The target texture to render to.
  14115. * @param faceIndex The index of the face to bind the target texture to.
  14116. * @param postProcesses The array of post processes to render.
  14117. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  14118. * @hidden
  14119. */
  14120. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  14121. /**
  14122. * Disposes of the post process manager.
  14123. */
  14124. dispose(): void;
  14125. }
  14126. }
  14127. declare module BABYLON {
  14128. interface AbstractScene {
  14129. /**
  14130. * The list of procedural textures added to the scene
  14131. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14132. */
  14133. proceduralTextures: Array<ProceduralTexture>;
  14134. }
  14135. /**
  14136. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14137. * in a given scene.
  14138. */
  14139. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14140. /**
  14141. * The component name helpfull to identify the component in the list of scene components.
  14142. */
  14143. readonly name: string;
  14144. /**
  14145. * The scene the component belongs to.
  14146. */
  14147. scene: Scene;
  14148. /**
  14149. * Creates a new instance of the component for the given scene
  14150. * @param scene Defines the scene to register the component in
  14151. */
  14152. constructor(scene: Scene);
  14153. /**
  14154. * Registers the component in a given scene
  14155. */
  14156. register(): void;
  14157. /**
  14158. * Rebuilds the elements related to this component in case of
  14159. * context lost for instance.
  14160. */
  14161. rebuild(): void;
  14162. /**
  14163. * Disposes the component and the associated ressources.
  14164. */
  14165. dispose(): void;
  14166. private _beforeClear;
  14167. }
  14168. }
  14169. declare module BABYLON {
  14170. interface Engine {
  14171. /**
  14172. * Creates a new render target cube texture
  14173. * @param size defines the size of the texture
  14174. * @param options defines the options used to create the texture
  14175. * @returns a new render target cube texture stored in an InternalTexture
  14176. */
  14177. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14178. }
  14179. }
  14180. declare module BABYLON {
  14181. /** @hidden */
  14182. export var proceduralVertexShader: {
  14183. name: string;
  14184. shader: string;
  14185. };
  14186. }
  14187. declare module BABYLON {
  14188. /**
  14189. * 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.
  14190. * This is the base class of any Procedural texture and contains most of the shareable code.
  14191. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14192. */
  14193. export class ProceduralTexture extends Texture {
  14194. isCube: boolean;
  14195. /**
  14196. * Define if the texture is enabled or not (disabled texture will not render)
  14197. */
  14198. isEnabled: boolean;
  14199. /**
  14200. * Define if the texture must be cleared before rendering (default is true)
  14201. */
  14202. autoClear: boolean;
  14203. /**
  14204. * Callback called when the texture is generated
  14205. */
  14206. onGenerated: () => void;
  14207. /**
  14208. * Event raised when the texture is generated
  14209. */
  14210. onGeneratedObservable: Observable<ProceduralTexture>;
  14211. /** @hidden */
  14212. _generateMipMaps: boolean;
  14213. /** @hidden **/
  14214. _effect: Effect;
  14215. /** @hidden */
  14216. _textures: {
  14217. [key: string]: Texture;
  14218. };
  14219. private _size;
  14220. private _currentRefreshId;
  14221. private _refreshRate;
  14222. private _vertexBuffers;
  14223. private _indexBuffer;
  14224. private _uniforms;
  14225. private _samplers;
  14226. private _fragment;
  14227. private _floats;
  14228. private _ints;
  14229. private _floatsArrays;
  14230. private _colors3;
  14231. private _colors4;
  14232. private _vectors2;
  14233. private _vectors3;
  14234. private _matrices;
  14235. private _fallbackTexture;
  14236. private _fallbackTextureUsed;
  14237. private _engine;
  14238. private _cachedDefines;
  14239. private _contentUpdateId;
  14240. private _contentData;
  14241. /**
  14242. * Instantiates a new procedural texture.
  14243. * 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.
  14244. * This is the base class of any Procedural texture and contains most of the shareable code.
  14245. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14246. * @param name Define the name of the texture
  14247. * @param size Define the size of the texture to create
  14248. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14249. * @param scene Define the scene the texture belongs to
  14250. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14251. * @param generateMipMaps Define if the texture should creates mip maps or not
  14252. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14253. */
  14254. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14255. /**
  14256. * The effect that is created when initializing the post process.
  14257. * @returns The created effect corrisponding the the postprocess.
  14258. */
  14259. getEffect(): Effect;
  14260. /**
  14261. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14262. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14263. */
  14264. getContent(): Nullable<ArrayBufferView>;
  14265. private _createIndexBuffer;
  14266. /** @hidden */
  14267. _rebuild(): void;
  14268. /**
  14269. * Resets the texture in order to recreate its associated resources.
  14270. * This can be called in case of context loss
  14271. */
  14272. reset(): void;
  14273. protected _getDefines(): string;
  14274. /**
  14275. * Is the texture ready to be used ? (rendered at least once)
  14276. * @returns true if ready, otherwise, false.
  14277. */
  14278. isReady(): boolean;
  14279. /**
  14280. * Resets the refresh counter of the texture and start bak from scratch.
  14281. * Could be useful to regenerate the texture if it is setup to render only once.
  14282. */
  14283. resetRefreshCounter(): void;
  14284. /**
  14285. * Set the fragment shader to use in order to render the texture.
  14286. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14287. */
  14288. setFragment(fragment: any): void;
  14289. /**
  14290. * Define the refresh rate of the texture or the rendering frequency.
  14291. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14292. */
  14293. refreshRate: number;
  14294. /** @hidden */
  14295. _shouldRender(): boolean;
  14296. /**
  14297. * Get the size the texture is rendering at.
  14298. * @returns the size (texture is always squared)
  14299. */
  14300. getRenderSize(): number;
  14301. /**
  14302. * Resize the texture to new value.
  14303. * @param size Define the new size the texture should have
  14304. * @param generateMipMaps Define whether the new texture should create mip maps
  14305. */
  14306. resize(size: number, generateMipMaps: boolean): void;
  14307. private _checkUniform;
  14308. /**
  14309. * Set a texture in the shader program used to render.
  14310. * @param name Define the name of the uniform samplers as defined in the shader
  14311. * @param texture Define the texture to bind to this sampler
  14312. * @return the texture itself allowing "fluent" like uniform updates
  14313. */
  14314. setTexture(name: string, texture: Texture): ProceduralTexture;
  14315. /**
  14316. * Set a float in the shader.
  14317. * @param name Define the name of the uniform as defined in the shader
  14318. * @param value Define the value to give to the uniform
  14319. * @return the texture itself allowing "fluent" like uniform updates
  14320. */
  14321. setFloat(name: string, value: number): ProceduralTexture;
  14322. /**
  14323. * Set a int in the shader.
  14324. * @param name Define the name of the uniform as defined in the shader
  14325. * @param value Define the value to give to the uniform
  14326. * @return the texture itself allowing "fluent" like uniform updates
  14327. */
  14328. setInt(name: string, value: number): ProceduralTexture;
  14329. /**
  14330. * Set an array of floats in the shader.
  14331. * @param name Define the name of the uniform as defined in the shader
  14332. * @param value Define the value to give to the uniform
  14333. * @return the texture itself allowing "fluent" like uniform updates
  14334. */
  14335. setFloats(name: string, value: number[]): ProceduralTexture;
  14336. /**
  14337. * Set a vec3 in the shader from a Color3.
  14338. * @param name Define the name of the uniform as defined in the shader
  14339. * @param value Define the value to give to the uniform
  14340. * @return the texture itself allowing "fluent" like uniform updates
  14341. */
  14342. setColor3(name: string, value: Color3): ProceduralTexture;
  14343. /**
  14344. * Set a vec4 in the shader from a Color4.
  14345. * @param name Define the name of the uniform as defined in the shader
  14346. * @param value Define the value to give to the uniform
  14347. * @return the texture itself allowing "fluent" like uniform updates
  14348. */
  14349. setColor4(name: string, value: Color4): ProceduralTexture;
  14350. /**
  14351. * Set a vec2 in the shader from a Vector2.
  14352. * @param name Define the name of the uniform as defined in the shader
  14353. * @param value Define the value to give to the uniform
  14354. * @return the texture itself allowing "fluent" like uniform updates
  14355. */
  14356. setVector2(name: string, value: Vector2): ProceduralTexture;
  14357. /**
  14358. * Set a vec3 in the shader from a Vector3.
  14359. * @param name Define the name of the uniform as defined in the shader
  14360. * @param value Define the value to give to the uniform
  14361. * @return the texture itself allowing "fluent" like uniform updates
  14362. */
  14363. setVector3(name: string, value: Vector3): ProceduralTexture;
  14364. /**
  14365. * Set a mat4 in the shader from a MAtrix.
  14366. * @param name Define the name of the uniform as defined in the shader
  14367. * @param value Define the value to give to the uniform
  14368. * @return the texture itself allowing "fluent" like uniform updates
  14369. */
  14370. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14371. /**
  14372. * Render the texture to its associated render target.
  14373. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14374. */
  14375. render(useCameraPostProcess?: boolean): void;
  14376. /**
  14377. * Clone the texture.
  14378. * @returns the cloned texture
  14379. */
  14380. clone(): ProceduralTexture;
  14381. /**
  14382. * Dispose the texture and release its asoociated resources.
  14383. */
  14384. dispose(): void;
  14385. }
  14386. }
  14387. declare module BABYLON {
  14388. /**
  14389. * This represents the base class for particle system in Babylon.
  14390. * 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.
  14391. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14392. * @example https://doc.babylonjs.com/babylon101/particles
  14393. */
  14394. export class BaseParticleSystem {
  14395. /**
  14396. * Source color is added to the destination color without alpha affecting the result
  14397. */
  14398. static BLENDMODE_ONEONE: number;
  14399. /**
  14400. * Blend current color and particle color using particle’s alpha
  14401. */
  14402. static BLENDMODE_STANDARD: number;
  14403. /**
  14404. * Add current color and particle color multiplied by particle’s alpha
  14405. */
  14406. static BLENDMODE_ADD: number;
  14407. /**
  14408. * Multiply current color with particle color
  14409. */
  14410. static BLENDMODE_MULTIPLY: number;
  14411. /**
  14412. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14413. */
  14414. static BLENDMODE_MULTIPLYADD: number;
  14415. /**
  14416. * List of animations used by the particle system.
  14417. */
  14418. animations: Animation[];
  14419. /**
  14420. * The id of the Particle system.
  14421. */
  14422. id: string;
  14423. /**
  14424. * The friendly name of the Particle system.
  14425. */
  14426. name: string;
  14427. /**
  14428. * The rendering group used by the Particle system to chose when to render.
  14429. */
  14430. renderingGroupId: number;
  14431. /**
  14432. * The emitter represents the Mesh or position we are attaching the particle system to.
  14433. */
  14434. emitter: Nullable<AbstractMesh | Vector3>;
  14435. /**
  14436. * The maximum number of particles to emit per frame
  14437. */
  14438. emitRate: number;
  14439. /**
  14440. * If you want to launch only a few particles at once, that can be done, as well.
  14441. */
  14442. manualEmitCount: number;
  14443. /**
  14444. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14445. */
  14446. updateSpeed: number;
  14447. /**
  14448. * The amount of time the particle system is running (depends of the overall update speed).
  14449. */
  14450. targetStopDuration: number;
  14451. /**
  14452. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14453. */
  14454. disposeOnStop: boolean;
  14455. /**
  14456. * Minimum power of emitting particles.
  14457. */
  14458. minEmitPower: number;
  14459. /**
  14460. * Maximum power of emitting particles.
  14461. */
  14462. maxEmitPower: number;
  14463. /**
  14464. * Minimum life time of emitting particles.
  14465. */
  14466. minLifeTime: number;
  14467. /**
  14468. * Maximum life time of emitting particles.
  14469. */
  14470. maxLifeTime: number;
  14471. /**
  14472. * Minimum Size of emitting particles.
  14473. */
  14474. minSize: number;
  14475. /**
  14476. * Maximum Size of emitting particles.
  14477. */
  14478. maxSize: number;
  14479. /**
  14480. * Minimum scale of emitting particles on X axis.
  14481. */
  14482. minScaleX: number;
  14483. /**
  14484. * Maximum scale of emitting particles on X axis.
  14485. */
  14486. maxScaleX: number;
  14487. /**
  14488. * Minimum scale of emitting particles on Y axis.
  14489. */
  14490. minScaleY: number;
  14491. /**
  14492. * Maximum scale of emitting particles on Y axis.
  14493. */
  14494. maxScaleY: number;
  14495. /**
  14496. * Gets or sets the minimal initial rotation in radians.
  14497. */
  14498. minInitialRotation: number;
  14499. /**
  14500. * Gets or sets the maximal initial rotation in radians.
  14501. */
  14502. maxInitialRotation: number;
  14503. /**
  14504. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14505. */
  14506. minAngularSpeed: number;
  14507. /**
  14508. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14509. */
  14510. maxAngularSpeed: number;
  14511. /**
  14512. * The texture used to render each particle. (this can be a spritesheet)
  14513. */
  14514. particleTexture: Nullable<Texture>;
  14515. /**
  14516. * The layer mask we are rendering the particles through.
  14517. */
  14518. layerMask: number;
  14519. /**
  14520. * This can help using your own shader to render the particle system.
  14521. * The according effect will be created
  14522. */
  14523. customShader: any;
  14524. /**
  14525. * By default particle system starts as soon as they are created. This prevents the
  14526. * automatic start to happen and let you decide when to start emitting particles.
  14527. */
  14528. preventAutoStart: boolean;
  14529. private _noiseTexture;
  14530. /**
  14531. * Gets or sets a texture used to add random noise to particle positions
  14532. */
  14533. noiseTexture: Nullable<ProceduralTexture>;
  14534. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14535. noiseStrength: Vector3;
  14536. /**
  14537. * Callback triggered when the particle animation is ending.
  14538. */
  14539. onAnimationEnd: Nullable<() => void>;
  14540. /**
  14541. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14542. */
  14543. blendMode: number;
  14544. /**
  14545. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14546. * to override the particles.
  14547. */
  14548. forceDepthWrite: boolean;
  14549. /** 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 */
  14550. preWarmCycles: number;
  14551. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14552. preWarmStepOffset: number;
  14553. /**
  14554. * 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)
  14555. */
  14556. spriteCellChangeSpeed: number;
  14557. /**
  14558. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14559. */
  14560. startSpriteCellID: number;
  14561. /**
  14562. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14563. */
  14564. endSpriteCellID: number;
  14565. /**
  14566. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14567. */
  14568. spriteCellWidth: number;
  14569. /**
  14570. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14571. */
  14572. spriteCellHeight: number;
  14573. /**
  14574. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14575. */
  14576. spriteRandomStartCell: boolean;
  14577. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14578. translationPivot: Vector2;
  14579. /** @hidden */
  14580. protected _isAnimationSheetEnabled: boolean;
  14581. /**
  14582. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14583. */
  14584. beginAnimationOnStart: boolean;
  14585. /**
  14586. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14587. */
  14588. beginAnimationFrom: number;
  14589. /**
  14590. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14591. */
  14592. beginAnimationTo: number;
  14593. /**
  14594. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14595. */
  14596. beginAnimationLoop: boolean;
  14597. /**
  14598. * Gets or sets a world offset applied to all particles
  14599. */
  14600. worldOffset: Vector3;
  14601. /**
  14602. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14603. */
  14604. isAnimationSheetEnabled: boolean;
  14605. /**
  14606. * Get hosting scene
  14607. * @returns the scene
  14608. */
  14609. getScene(): Scene;
  14610. /**
  14611. * You can use gravity if you want to give an orientation to your particles.
  14612. */
  14613. gravity: Vector3;
  14614. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14615. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14616. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14617. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14618. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14619. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14620. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14621. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14622. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14623. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14624. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14625. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14626. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14627. /**
  14628. * Defines the delay in milliseconds before starting the system (0 by default)
  14629. */
  14630. startDelay: number;
  14631. /**
  14632. * Gets the current list of drag gradients.
  14633. * You must use addDragGradient and removeDragGradient to udpate this list
  14634. * @returns the list of drag gradients
  14635. */
  14636. getDragGradients(): Nullable<Array<FactorGradient>>;
  14637. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14638. limitVelocityDamping: number;
  14639. /**
  14640. * Gets the current list of limit velocity gradients.
  14641. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14642. * @returns the list of limit velocity gradients
  14643. */
  14644. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14645. /**
  14646. * Gets the current list of color gradients.
  14647. * You must use addColorGradient and removeColorGradient to udpate this list
  14648. * @returns the list of color gradients
  14649. */
  14650. getColorGradients(): Nullable<Array<ColorGradient>>;
  14651. /**
  14652. * Gets the current list of size gradients.
  14653. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14654. * @returns the list of size gradients
  14655. */
  14656. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14657. /**
  14658. * Gets the current list of color remap gradients.
  14659. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14660. * @returns the list of color remap gradients
  14661. */
  14662. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14663. /**
  14664. * Gets the current list of alpha remap gradients.
  14665. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14666. * @returns the list of alpha remap gradients
  14667. */
  14668. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14669. /**
  14670. * Gets the current list of life time gradients.
  14671. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14672. * @returns the list of life time gradients
  14673. */
  14674. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14675. /**
  14676. * Gets the current list of angular speed gradients.
  14677. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14678. * @returns the list of angular speed gradients
  14679. */
  14680. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14681. /**
  14682. * Gets the current list of velocity gradients.
  14683. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14684. * @returns the list of velocity gradients
  14685. */
  14686. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14687. /**
  14688. * Gets the current list of start size gradients.
  14689. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14690. * @returns the list of start size gradients
  14691. */
  14692. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14693. /**
  14694. * Gets the current list of emit rate gradients.
  14695. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14696. * @returns the list of emit rate gradients
  14697. */
  14698. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14699. /**
  14700. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14701. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14702. */
  14703. direction1: Vector3;
  14704. /**
  14705. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14706. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14707. */
  14708. direction2: Vector3;
  14709. /**
  14710. * 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.
  14711. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14712. */
  14713. minEmitBox: Vector3;
  14714. /**
  14715. * 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.
  14716. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14717. */
  14718. maxEmitBox: Vector3;
  14719. /**
  14720. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14721. */
  14722. color1: Color4;
  14723. /**
  14724. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14725. */
  14726. color2: Color4;
  14727. /**
  14728. * Color the particle will have at the end of its lifetime
  14729. */
  14730. colorDead: Color4;
  14731. /**
  14732. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14733. */
  14734. textureMask: Color4;
  14735. /**
  14736. * The particle emitter type defines the emitter used by the particle system.
  14737. * It can be for example box, sphere, or cone...
  14738. */
  14739. particleEmitterType: IParticleEmitterType;
  14740. /** @hidden */
  14741. _isSubEmitter: boolean;
  14742. /**
  14743. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14744. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14745. */
  14746. billboardMode: number;
  14747. protected _isBillboardBased: boolean;
  14748. /**
  14749. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14750. */
  14751. isBillboardBased: boolean;
  14752. /**
  14753. * The scene the particle system belongs to.
  14754. */
  14755. protected _scene: Scene;
  14756. /**
  14757. * Local cache of defines for image processing.
  14758. */
  14759. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14760. /**
  14761. * Default configuration related to image processing available in the standard Material.
  14762. */
  14763. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14764. /**
  14765. * Gets the image processing configuration used either in this material.
  14766. */
  14767. /**
  14768. * Sets the Default image processing configuration used either in the this material.
  14769. *
  14770. * If sets to null, the scene one is in use.
  14771. */
  14772. imageProcessingConfiguration: ImageProcessingConfiguration;
  14773. /**
  14774. * Attaches a new image processing configuration to the Standard Material.
  14775. * @param configuration
  14776. */
  14777. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14778. /** @hidden */
  14779. protected _reset(): void;
  14780. /** @hidden */
  14781. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14782. /**
  14783. * Instantiates a particle system.
  14784. * 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.
  14785. * @param name The name of the particle system
  14786. */
  14787. constructor(name: string);
  14788. /**
  14789. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14790. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14791. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14792. * @returns the emitter
  14793. */
  14794. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14795. /**
  14796. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14797. * @param radius The radius of the hemisphere to emit from
  14798. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14799. * @returns the emitter
  14800. */
  14801. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14802. /**
  14803. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14804. * @param radius The radius of the sphere to emit from
  14805. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14806. * @returns the emitter
  14807. */
  14808. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14809. /**
  14810. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14811. * @param radius The radius of the sphere to emit from
  14812. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14813. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14814. * @returns the emitter
  14815. */
  14816. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14817. /**
  14818. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14819. * @param radius The radius of the emission cylinder
  14820. * @param height The height of the emission cylinder
  14821. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14822. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14823. * @returns the emitter
  14824. */
  14825. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14826. /**
  14827. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14828. * @param radius The radius of the cylinder to emit from
  14829. * @param height The height of the emission cylinder
  14830. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14831. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14832. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14833. * @returns the emitter
  14834. */
  14835. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14836. /**
  14837. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14838. * @param radius The radius of the cone to emit from
  14839. * @param angle The base angle of the cone
  14840. * @returns the emitter
  14841. */
  14842. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14843. /**
  14844. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14845. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14846. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14847. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14848. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14849. * @returns the emitter
  14850. */
  14851. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14852. }
  14853. }
  14854. declare module BABYLON {
  14855. /**
  14856. * Type of sub emitter
  14857. */
  14858. export enum SubEmitterType {
  14859. /**
  14860. * Attached to the particle over it's lifetime
  14861. */
  14862. ATTACHED = 0,
  14863. /**
  14864. * Created when the particle dies
  14865. */
  14866. END = 1
  14867. }
  14868. /**
  14869. * Sub emitter class used to emit particles from an existing particle
  14870. */
  14871. export class SubEmitter {
  14872. /**
  14873. * the particle system to be used by the sub emitter
  14874. */
  14875. particleSystem: ParticleSystem;
  14876. /**
  14877. * Type of the submitter (Default: END)
  14878. */
  14879. type: SubEmitterType;
  14880. /**
  14881. * 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)
  14882. * Note: This only is supported when using an emitter of type Mesh
  14883. */
  14884. inheritDirection: boolean;
  14885. /**
  14886. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14887. */
  14888. inheritedVelocityAmount: number;
  14889. /**
  14890. * Creates a sub emitter
  14891. * @param particleSystem the particle system to be used by the sub emitter
  14892. */
  14893. constructor(
  14894. /**
  14895. * the particle system to be used by the sub emitter
  14896. */
  14897. particleSystem: ParticleSystem);
  14898. /**
  14899. * Clones the sub emitter
  14900. * @returns the cloned sub emitter
  14901. */
  14902. clone(): SubEmitter;
  14903. /**
  14904. * Serialize current object to a JSON object
  14905. * @returns the serialized object
  14906. */
  14907. serialize(): any;
  14908. /** @hidden */
  14909. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14910. /**
  14911. * Creates a new SubEmitter from a serialized JSON version
  14912. * @param serializationObject defines the JSON object to read from
  14913. * @param scene defines the hosting scene
  14914. * @param rootUrl defines the rootUrl for data loading
  14915. * @returns a new SubEmitter
  14916. */
  14917. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14918. /** Release associated resources */
  14919. dispose(): void;
  14920. }
  14921. }
  14922. declare module BABYLON {
  14923. /** @hidden */
  14924. export var clipPlaneFragmentDeclaration: {
  14925. name: string;
  14926. shader: string;
  14927. };
  14928. }
  14929. declare module BABYLON {
  14930. /** @hidden */
  14931. export var imageProcessingDeclaration: {
  14932. name: string;
  14933. shader: string;
  14934. };
  14935. }
  14936. declare module BABYLON {
  14937. /** @hidden */
  14938. export var imageProcessingFunctions: {
  14939. name: string;
  14940. shader: string;
  14941. };
  14942. }
  14943. declare module BABYLON {
  14944. /** @hidden */
  14945. export var clipPlaneFragment: {
  14946. name: string;
  14947. shader: string;
  14948. };
  14949. }
  14950. declare module BABYLON {
  14951. /** @hidden */
  14952. export var particlesPixelShader: {
  14953. name: string;
  14954. shader: string;
  14955. };
  14956. }
  14957. declare module BABYLON {
  14958. /** @hidden */
  14959. export var clipPlaneVertexDeclaration: {
  14960. name: string;
  14961. shader: string;
  14962. };
  14963. }
  14964. declare module BABYLON {
  14965. /** @hidden */
  14966. export var clipPlaneVertex: {
  14967. name: string;
  14968. shader: string;
  14969. };
  14970. }
  14971. declare module BABYLON {
  14972. /** @hidden */
  14973. export var particlesVertexShader: {
  14974. name: string;
  14975. shader: string;
  14976. };
  14977. }
  14978. declare module BABYLON {
  14979. /**
  14980. * This represents a particle system in Babylon.
  14981. * 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.
  14982. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14983. * @example https://doc.babylonjs.com/babylon101/particles
  14984. */
  14985. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14986. /**
  14987. * Billboard mode will only apply to Y axis
  14988. */
  14989. static readonly BILLBOARDMODE_Y: number;
  14990. /**
  14991. * Billboard mode will apply to all axes
  14992. */
  14993. static readonly BILLBOARDMODE_ALL: number;
  14994. /**
  14995. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14996. */
  14997. static readonly BILLBOARDMODE_STRETCHED: number;
  14998. /**
  14999. * This function can be defined to provide custom update for active particles.
  15000. * This function will be called instead of regular update (age, position, color, etc.).
  15001. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15002. */
  15003. updateFunction: (particles: Particle[]) => void;
  15004. private _emitterWorldMatrix;
  15005. /**
  15006. * This function can be defined to specify initial direction for every new particle.
  15007. * It by default use the emitterType defined function
  15008. */
  15009. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15010. /**
  15011. * This function can be defined to specify initial position for every new particle.
  15012. * It by default use the emitterType defined function
  15013. */
  15014. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15015. /**
  15016. * @hidden
  15017. */
  15018. _inheritedVelocityOffset: Vector3;
  15019. /**
  15020. * An event triggered when the system is disposed
  15021. */
  15022. onDisposeObservable: Observable<ParticleSystem>;
  15023. private _onDisposeObserver;
  15024. /**
  15025. * Sets a callback that will be triggered when the system is disposed
  15026. */
  15027. onDispose: () => void;
  15028. private _particles;
  15029. private _epsilon;
  15030. private _capacity;
  15031. private _stockParticles;
  15032. private _newPartsExcess;
  15033. private _vertexData;
  15034. private _vertexBuffer;
  15035. private _vertexBuffers;
  15036. private _spriteBuffer;
  15037. private _indexBuffer;
  15038. private _effect;
  15039. private _customEffect;
  15040. private _cachedDefines;
  15041. private _scaledColorStep;
  15042. private _colorDiff;
  15043. private _scaledDirection;
  15044. private _scaledGravity;
  15045. private _currentRenderId;
  15046. private _alive;
  15047. private _useInstancing;
  15048. private _started;
  15049. private _stopped;
  15050. private _actualFrame;
  15051. private _scaledUpdateSpeed;
  15052. private _vertexBufferSize;
  15053. /** @hidden */
  15054. _currentEmitRateGradient: Nullable<FactorGradient>;
  15055. /** @hidden */
  15056. _currentEmitRate1: number;
  15057. /** @hidden */
  15058. _currentEmitRate2: number;
  15059. /** @hidden */
  15060. _currentStartSizeGradient: Nullable<FactorGradient>;
  15061. /** @hidden */
  15062. _currentStartSize1: number;
  15063. /** @hidden */
  15064. _currentStartSize2: number;
  15065. private readonly _rawTextureWidth;
  15066. private _rampGradientsTexture;
  15067. private _useRampGradients;
  15068. /** Gets or sets a boolean indicating that ramp gradients must be used
  15069. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15070. */
  15071. useRampGradients: boolean;
  15072. /**
  15073. * 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.
  15074. * 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: [])
  15075. */
  15076. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15077. private _subEmitters;
  15078. /**
  15079. * @hidden
  15080. * If the particle systems emitter should be disposed when the particle system is disposed
  15081. */
  15082. _disposeEmitterOnDispose: boolean;
  15083. /**
  15084. * The current active Sub-systems, this property is used by the root particle system only.
  15085. */
  15086. activeSubSystems: Array<ParticleSystem>;
  15087. private _rootParticleSystem;
  15088. /**
  15089. * Gets the current list of active particles
  15090. */
  15091. readonly particles: Particle[];
  15092. /**
  15093. * Returns the string "ParticleSystem"
  15094. * @returns a string containing the class name
  15095. */
  15096. getClassName(): string;
  15097. /**
  15098. * Instantiates a particle system.
  15099. * 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.
  15100. * @param name The name of the particle system
  15101. * @param capacity The max number of particles alive at the same time
  15102. * @param scene The scene the particle system belongs to
  15103. * @param customEffect a custom effect used to change the way particles are rendered by default
  15104. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15105. * @param epsilon Offset used to render the particles
  15106. */
  15107. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15108. private _addFactorGradient;
  15109. private _removeFactorGradient;
  15110. /**
  15111. * Adds a new life time gradient
  15112. * @param gradient defines the gradient to use (between 0 and 1)
  15113. * @param factor defines the life time factor to affect to the specified gradient
  15114. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15115. * @returns the current particle system
  15116. */
  15117. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15118. /**
  15119. * Remove a specific life time gradient
  15120. * @param gradient defines the gradient to remove
  15121. * @returns the current particle system
  15122. */
  15123. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15124. /**
  15125. * Adds a new size gradient
  15126. * @param gradient defines the gradient to use (between 0 and 1)
  15127. * @param factor defines the size factor to affect to the specified gradient
  15128. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15129. * @returns the current particle system
  15130. */
  15131. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15132. /**
  15133. * Remove a specific size gradient
  15134. * @param gradient defines the gradient to remove
  15135. * @returns the current particle system
  15136. */
  15137. removeSizeGradient(gradient: number): IParticleSystem;
  15138. /**
  15139. * Adds a new color remap gradient
  15140. * @param gradient defines the gradient to use (between 0 and 1)
  15141. * @param min defines the color remap minimal range
  15142. * @param max defines the color remap maximal range
  15143. * @returns the current particle system
  15144. */
  15145. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15146. /**
  15147. * Remove a specific color remap gradient
  15148. * @param gradient defines the gradient to remove
  15149. * @returns the current particle system
  15150. */
  15151. removeColorRemapGradient(gradient: number): IParticleSystem;
  15152. /**
  15153. * Adds a new alpha remap gradient
  15154. * @param gradient defines the gradient to use (between 0 and 1)
  15155. * @param min defines the alpha remap minimal range
  15156. * @param max defines the alpha remap maximal range
  15157. * @returns the current particle system
  15158. */
  15159. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15160. /**
  15161. * Remove a specific alpha remap gradient
  15162. * @param gradient defines the gradient to remove
  15163. * @returns the current particle system
  15164. */
  15165. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15166. /**
  15167. * Adds a new angular speed gradient
  15168. * @param gradient defines the gradient to use (between 0 and 1)
  15169. * @param factor defines the angular speed to affect to the specified gradient
  15170. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15171. * @returns the current particle system
  15172. */
  15173. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15174. /**
  15175. * Remove a specific angular speed gradient
  15176. * @param gradient defines the gradient to remove
  15177. * @returns the current particle system
  15178. */
  15179. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15180. /**
  15181. * Adds a new velocity gradient
  15182. * @param gradient defines the gradient to use (between 0 and 1)
  15183. * @param factor defines the velocity to affect to the specified gradient
  15184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15185. * @returns the current particle system
  15186. */
  15187. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15188. /**
  15189. * Remove a specific velocity gradient
  15190. * @param gradient defines the gradient to remove
  15191. * @returns the current particle system
  15192. */
  15193. removeVelocityGradient(gradient: number): IParticleSystem;
  15194. /**
  15195. * Adds a new limit velocity gradient
  15196. * @param gradient defines the gradient to use (between 0 and 1)
  15197. * @param factor defines the limit velocity value to affect to the specified gradient
  15198. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15199. * @returns the current particle system
  15200. */
  15201. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15202. /**
  15203. * Remove a specific limit velocity gradient
  15204. * @param gradient defines the gradient to remove
  15205. * @returns the current particle system
  15206. */
  15207. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15208. /**
  15209. * Adds a new drag gradient
  15210. * @param gradient defines the gradient to use (between 0 and 1)
  15211. * @param factor defines the drag value to affect to the specified gradient
  15212. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15213. * @returns the current particle system
  15214. */
  15215. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15216. /**
  15217. * Remove a specific drag gradient
  15218. * @param gradient defines the gradient to remove
  15219. * @returns the current particle system
  15220. */
  15221. removeDragGradient(gradient: number): IParticleSystem;
  15222. /**
  15223. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15224. * @param gradient defines the gradient to use (between 0 and 1)
  15225. * @param factor defines the emit rate value to affect to the specified gradient
  15226. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15227. * @returns the current particle system
  15228. */
  15229. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15230. /**
  15231. * Remove a specific emit rate gradient
  15232. * @param gradient defines the gradient to remove
  15233. * @returns the current particle system
  15234. */
  15235. removeEmitRateGradient(gradient: number): IParticleSystem;
  15236. /**
  15237. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15238. * @param gradient defines the gradient to use (between 0 and 1)
  15239. * @param factor defines the start size value to affect to the specified gradient
  15240. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15241. * @returns the current particle system
  15242. */
  15243. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15244. /**
  15245. * Remove a specific start size gradient
  15246. * @param gradient defines the gradient to remove
  15247. * @returns the current particle system
  15248. */
  15249. removeStartSizeGradient(gradient: number): IParticleSystem;
  15250. private _createRampGradientTexture;
  15251. /**
  15252. * Gets the current list of ramp gradients.
  15253. * You must use addRampGradient and removeRampGradient to udpate this list
  15254. * @returns the list of ramp gradients
  15255. */
  15256. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15257. /**
  15258. * Adds a new ramp gradient used to remap particle colors
  15259. * @param gradient defines the gradient to use (between 0 and 1)
  15260. * @param color defines the color to affect to the specified gradient
  15261. * @returns the current particle system
  15262. */
  15263. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15264. /**
  15265. * Remove a specific ramp gradient
  15266. * @param gradient defines the gradient to remove
  15267. * @returns the current particle system
  15268. */
  15269. removeRampGradient(gradient: number): ParticleSystem;
  15270. /**
  15271. * Adds a new color gradient
  15272. * @param gradient defines the gradient to use (between 0 and 1)
  15273. * @param color1 defines the color to affect to the specified gradient
  15274. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15275. * @returns this particle system
  15276. */
  15277. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15278. /**
  15279. * Remove a specific color gradient
  15280. * @param gradient defines the gradient to remove
  15281. * @returns this particle system
  15282. */
  15283. removeColorGradient(gradient: number): IParticleSystem;
  15284. private _fetchR;
  15285. protected _reset(): void;
  15286. private _resetEffect;
  15287. private _createVertexBuffers;
  15288. private _createIndexBuffer;
  15289. /**
  15290. * Gets the maximum number of particles active at the same time.
  15291. * @returns The max number of active particles.
  15292. */
  15293. getCapacity(): number;
  15294. /**
  15295. * Gets whether there are still active particles in the system.
  15296. * @returns True if it is alive, otherwise false.
  15297. */
  15298. isAlive(): boolean;
  15299. /**
  15300. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15301. * @returns True if it has been started, otherwise false.
  15302. */
  15303. isStarted(): boolean;
  15304. private _prepareSubEmitterInternalArray;
  15305. /**
  15306. * Starts the particle system and begins to emit
  15307. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15308. */
  15309. start(delay?: number): void;
  15310. /**
  15311. * Stops the particle system.
  15312. * @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.
  15313. */
  15314. stop(stopSubEmitters?: boolean): void;
  15315. /**
  15316. * Remove all active particles
  15317. */
  15318. reset(): void;
  15319. /**
  15320. * @hidden (for internal use only)
  15321. */
  15322. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15323. /**
  15324. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15325. * Its lifetime will start back at 0.
  15326. */
  15327. recycleParticle: (particle: Particle) => void;
  15328. private _stopSubEmitters;
  15329. private _createParticle;
  15330. private _removeFromRoot;
  15331. private _emitFromParticle;
  15332. private _update;
  15333. /** @hidden */
  15334. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15335. /** @hidden */
  15336. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15337. /** @hidden */
  15338. private _getEffect;
  15339. /**
  15340. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15341. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15342. */
  15343. animate(preWarmOnly?: boolean): void;
  15344. private _appendParticleVertices;
  15345. /**
  15346. * Rebuilds the particle system.
  15347. */
  15348. rebuild(): void;
  15349. /**
  15350. * Is this system ready to be used/rendered
  15351. * @return true if the system is ready
  15352. */
  15353. isReady(): boolean;
  15354. private _render;
  15355. /**
  15356. * Renders the particle system in its current state.
  15357. * @returns the current number of particles
  15358. */
  15359. render(): number;
  15360. /**
  15361. * Disposes the particle system and free the associated resources
  15362. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15363. */
  15364. dispose(disposeTexture?: boolean): void;
  15365. /**
  15366. * Clones the particle system.
  15367. * @param name The name of the cloned object
  15368. * @param newEmitter The new emitter to use
  15369. * @returns the cloned particle system
  15370. */
  15371. clone(name: string, newEmitter: any): ParticleSystem;
  15372. /**
  15373. * Serializes the particle system to a JSON object.
  15374. * @returns the JSON object
  15375. */
  15376. serialize(): any;
  15377. /** @hidden */
  15378. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15379. /** @hidden */
  15380. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15381. /**
  15382. * Parses a JSON object to create a particle system.
  15383. * @param parsedParticleSystem The JSON object to parse
  15384. * @param scene The scene to create the particle system in
  15385. * @param rootUrl The root url to use to load external dependencies like texture
  15386. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15387. * @returns the Parsed particle system
  15388. */
  15389. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15390. }
  15391. }
  15392. declare module BABYLON {
  15393. /**
  15394. * A particle represents one of the element emitted by a particle system.
  15395. * This is mainly define by its coordinates, direction, velocity and age.
  15396. */
  15397. export class Particle {
  15398. /**
  15399. * The particle system the particle belongs to.
  15400. */
  15401. particleSystem: ParticleSystem;
  15402. private static _Count;
  15403. /**
  15404. * Unique ID of the particle
  15405. */
  15406. id: number;
  15407. /**
  15408. * The world position of the particle in the scene.
  15409. */
  15410. position: Vector3;
  15411. /**
  15412. * The world direction of the particle in the scene.
  15413. */
  15414. direction: Vector3;
  15415. /**
  15416. * The color of the particle.
  15417. */
  15418. color: Color4;
  15419. /**
  15420. * The color change of the particle per step.
  15421. */
  15422. colorStep: Color4;
  15423. /**
  15424. * Defines how long will the life of the particle be.
  15425. */
  15426. lifeTime: number;
  15427. /**
  15428. * The current age of the particle.
  15429. */
  15430. age: number;
  15431. /**
  15432. * The current size of the particle.
  15433. */
  15434. size: number;
  15435. /**
  15436. * The current scale of the particle.
  15437. */
  15438. scale: Vector2;
  15439. /**
  15440. * The current angle of the particle.
  15441. */
  15442. angle: number;
  15443. /**
  15444. * Defines how fast is the angle changing.
  15445. */
  15446. angularSpeed: number;
  15447. /**
  15448. * Defines the cell index used by the particle to be rendered from a sprite.
  15449. */
  15450. cellIndex: number;
  15451. /**
  15452. * The information required to support color remapping
  15453. */
  15454. remapData: Vector4;
  15455. /** @hidden */
  15456. _randomCellOffset?: number;
  15457. /** @hidden */
  15458. _initialDirection: Nullable<Vector3>;
  15459. /** @hidden */
  15460. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15461. /** @hidden */
  15462. _initialStartSpriteCellID: number;
  15463. /** @hidden */
  15464. _initialEndSpriteCellID: number;
  15465. /** @hidden */
  15466. _currentColorGradient: Nullable<ColorGradient>;
  15467. /** @hidden */
  15468. _currentColor1: Color4;
  15469. /** @hidden */
  15470. _currentColor2: Color4;
  15471. /** @hidden */
  15472. _currentSizeGradient: Nullable<FactorGradient>;
  15473. /** @hidden */
  15474. _currentSize1: number;
  15475. /** @hidden */
  15476. _currentSize2: number;
  15477. /** @hidden */
  15478. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15479. /** @hidden */
  15480. _currentAngularSpeed1: number;
  15481. /** @hidden */
  15482. _currentAngularSpeed2: number;
  15483. /** @hidden */
  15484. _currentVelocityGradient: Nullable<FactorGradient>;
  15485. /** @hidden */
  15486. _currentVelocity1: number;
  15487. /** @hidden */
  15488. _currentVelocity2: number;
  15489. /** @hidden */
  15490. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15491. /** @hidden */
  15492. _currentLimitVelocity1: number;
  15493. /** @hidden */
  15494. _currentLimitVelocity2: number;
  15495. /** @hidden */
  15496. _currentDragGradient: Nullable<FactorGradient>;
  15497. /** @hidden */
  15498. _currentDrag1: number;
  15499. /** @hidden */
  15500. _currentDrag2: number;
  15501. /** @hidden */
  15502. _randomNoiseCoordinates1: Vector3;
  15503. /** @hidden */
  15504. _randomNoiseCoordinates2: Vector3;
  15505. /**
  15506. * Creates a new instance Particle
  15507. * @param particleSystem the particle system the particle belongs to
  15508. */
  15509. constructor(
  15510. /**
  15511. * The particle system the particle belongs to.
  15512. */
  15513. particleSystem: ParticleSystem);
  15514. private updateCellInfoFromSystem;
  15515. /**
  15516. * Defines how the sprite cell index is updated for the particle
  15517. */
  15518. updateCellIndex(): void;
  15519. /** @hidden */
  15520. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15521. /** @hidden */
  15522. _inheritParticleInfoToSubEmitters(): void;
  15523. /** @hidden */
  15524. _reset(): void;
  15525. /**
  15526. * Copy the properties of particle to another one.
  15527. * @param other the particle to copy the information to.
  15528. */
  15529. copyTo(other: Particle): void;
  15530. }
  15531. }
  15532. declare module BABYLON {
  15533. /**
  15534. * Particle emitter represents a volume emitting particles.
  15535. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15536. */
  15537. export interface IParticleEmitterType {
  15538. /**
  15539. * Called by the particle System when the direction is computed for the created particle.
  15540. * @param worldMatrix is the world matrix of the particle system
  15541. * @param directionToUpdate is the direction vector to update with the result
  15542. * @param particle is the particle we are computed the direction for
  15543. */
  15544. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15545. /**
  15546. * Called by the particle System when the position is computed for the created particle.
  15547. * @param worldMatrix is the world matrix of the particle system
  15548. * @param positionToUpdate is the position vector to update with the result
  15549. * @param particle is the particle we are computed the position for
  15550. */
  15551. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15552. /**
  15553. * Clones the current emitter and returns a copy of it
  15554. * @returns the new emitter
  15555. */
  15556. clone(): IParticleEmitterType;
  15557. /**
  15558. * Called by the GPUParticleSystem to setup the update shader
  15559. * @param effect defines the update shader
  15560. */
  15561. applyToShader(effect: Effect): void;
  15562. /**
  15563. * Returns a string to use to update the GPU particles update shader
  15564. * @returns the effect defines string
  15565. */
  15566. getEffectDefines(): string;
  15567. /**
  15568. * Returns a string representing the class name
  15569. * @returns a string containing the class name
  15570. */
  15571. getClassName(): string;
  15572. /**
  15573. * Serializes the particle system to a JSON object.
  15574. * @returns the JSON object
  15575. */
  15576. serialize(): any;
  15577. /**
  15578. * Parse properties from a JSON object
  15579. * @param serializationObject defines the JSON object
  15580. */
  15581. parse(serializationObject: any): void;
  15582. }
  15583. }
  15584. declare module BABYLON {
  15585. /**
  15586. * Particle emitter emitting particles from the inside of a box.
  15587. * It emits the particles randomly between 2 given directions.
  15588. */
  15589. export class BoxParticleEmitter implements IParticleEmitterType {
  15590. /**
  15591. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15592. */
  15593. direction1: Vector3;
  15594. /**
  15595. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15596. */
  15597. direction2: Vector3;
  15598. /**
  15599. * 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.
  15600. */
  15601. minEmitBox: Vector3;
  15602. /**
  15603. * 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.
  15604. */
  15605. maxEmitBox: Vector3;
  15606. /**
  15607. * Creates a new instance BoxParticleEmitter
  15608. */
  15609. constructor();
  15610. /**
  15611. * Called by the particle System when the direction is computed for the created particle.
  15612. * @param worldMatrix is the world matrix of the particle system
  15613. * @param directionToUpdate is the direction vector to update with the result
  15614. * @param particle is the particle we are computed the direction for
  15615. */
  15616. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15617. /**
  15618. * Called by the particle System when the position is computed for the created particle.
  15619. * @param worldMatrix is the world matrix of the particle system
  15620. * @param positionToUpdate is the position vector to update with the result
  15621. * @param particle is the particle we are computed the position for
  15622. */
  15623. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15624. /**
  15625. * Clones the current emitter and returns a copy of it
  15626. * @returns the new emitter
  15627. */
  15628. clone(): BoxParticleEmitter;
  15629. /**
  15630. * Called by the GPUParticleSystem to setup the update shader
  15631. * @param effect defines the update shader
  15632. */
  15633. applyToShader(effect: Effect): void;
  15634. /**
  15635. * Returns a string to use to update the GPU particles update shader
  15636. * @returns a string containng the defines string
  15637. */
  15638. getEffectDefines(): string;
  15639. /**
  15640. * Returns the string "BoxParticleEmitter"
  15641. * @returns a string containing the class name
  15642. */
  15643. getClassName(): string;
  15644. /**
  15645. * Serializes the particle system to a JSON object.
  15646. * @returns the JSON object
  15647. */
  15648. serialize(): any;
  15649. /**
  15650. * Parse properties from a JSON object
  15651. * @param serializationObject defines the JSON object
  15652. */
  15653. parse(serializationObject: any): void;
  15654. }
  15655. }
  15656. declare module BABYLON {
  15657. /**
  15658. * Particle emitter emitting particles from the inside of a cone.
  15659. * It emits the particles alongside the cone volume from the base to the particle.
  15660. * The emission direction might be randomized.
  15661. */
  15662. export class ConeParticleEmitter implements IParticleEmitterType {
  15663. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15664. directionRandomizer: number;
  15665. private _radius;
  15666. private _angle;
  15667. private _height;
  15668. /**
  15669. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15670. */
  15671. radiusRange: number;
  15672. /**
  15673. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15674. */
  15675. heightRange: number;
  15676. /**
  15677. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15678. */
  15679. emitFromSpawnPointOnly: boolean;
  15680. /**
  15681. * Gets or sets the radius of the emission cone
  15682. */
  15683. radius: number;
  15684. /**
  15685. * Gets or sets the angle of the emission cone
  15686. */
  15687. angle: number;
  15688. private _buildHeight;
  15689. /**
  15690. * Creates a new instance ConeParticleEmitter
  15691. * @param radius the radius of the emission cone (1 by default)
  15692. * @param angle the cone base angle (PI by default)
  15693. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15694. */
  15695. constructor(radius?: number, angle?: number,
  15696. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15697. directionRandomizer?: number);
  15698. /**
  15699. * Called by the particle System when the direction is computed for the created particle.
  15700. * @param worldMatrix is the world matrix of the particle system
  15701. * @param directionToUpdate is the direction vector to update with the result
  15702. * @param particle is the particle we are computed the direction for
  15703. */
  15704. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15705. /**
  15706. * Called by the particle System when the position is computed for the created particle.
  15707. * @param worldMatrix is the world matrix of the particle system
  15708. * @param positionToUpdate is the position vector to update with the result
  15709. * @param particle is the particle we are computed the position for
  15710. */
  15711. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15712. /**
  15713. * Clones the current emitter and returns a copy of it
  15714. * @returns the new emitter
  15715. */
  15716. clone(): ConeParticleEmitter;
  15717. /**
  15718. * Called by the GPUParticleSystem to setup the update shader
  15719. * @param effect defines the update shader
  15720. */
  15721. applyToShader(effect: Effect): void;
  15722. /**
  15723. * Returns a string to use to update the GPU particles update shader
  15724. * @returns a string containng the defines string
  15725. */
  15726. getEffectDefines(): string;
  15727. /**
  15728. * Returns the string "ConeParticleEmitter"
  15729. * @returns a string containing the class name
  15730. */
  15731. getClassName(): string;
  15732. /**
  15733. * Serializes the particle system to a JSON object.
  15734. * @returns the JSON object
  15735. */
  15736. serialize(): any;
  15737. /**
  15738. * Parse properties from a JSON object
  15739. * @param serializationObject defines the JSON object
  15740. */
  15741. parse(serializationObject: any): void;
  15742. }
  15743. }
  15744. declare module BABYLON {
  15745. /**
  15746. * Particle emitter emitting particles from the inside of a cylinder.
  15747. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15748. */
  15749. export class CylinderParticleEmitter implements IParticleEmitterType {
  15750. /**
  15751. * The radius of the emission cylinder.
  15752. */
  15753. radius: number;
  15754. /**
  15755. * The height of the emission cylinder.
  15756. */
  15757. height: number;
  15758. /**
  15759. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15760. */
  15761. radiusRange: number;
  15762. /**
  15763. * How much to randomize the particle direction [0-1].
  15764. */
  15765. directionRandomizer: number;
  15766. /**
  15767. * Creates a new instance CylinderParticleEmitter
  15768. * @param radius the radius of the emission cylinder (1 by default)
  15769. * @param height the height of the emission cylinder (1 by default)
  15770. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15771. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15772. */
  15773. constructor(
  15774. /**
  15775. * The radius of the emission cylinder.
  15776. */
  15777. radius?: number,
  15778. /**
  15779. * The height of the emission cylinder.
  15780. */
  15781. height?: number,
  15782. /**
  15783. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15784. */
  15785. radiusRange?: number,
  15786. /**
  15787. * How much to randomize the particle direction [0-1].
  15788. */
  15789. directionRandomizer?: number);
  15790. /**
  15791. * Called by the particle System when the direction is computed for the created particle.
  15792. * @param worldMatrix is the world matrix of the particle system
  15793. * @param directionToUpdate is the direction vector to update with the result
  15794. * @param particle is the particle we are computed the direction for
  15795. */
  15796. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15797. /**
  15798. * Called by the particle System when the position is computed for the created particle.
  15799. * @param worldMatrix is the world matrix of the particle system
  15800. * @param positionToUpdate is the position vector to update with the result
  15801. * @param particle is the particle we are computed the position for
  15802. */
  15803. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15804. /**
  15805. * Clones the current emitter and returns a copy of it
  15806. * @returns the new emitter
  15807. */
  15808. clone(): CylinderParticleEmitter;
  15809. /**
  15810. * Called by the GPUParticleSystem to setup the update shader
  15811. * @param effect defines the update shader
  15812. */
  15813. applyToShader(effect: Effect): void;
  15814. /**
  15815. * Returns a string to use to update the GPU particles update shader
  15816. * @returns a string containng the defines string
  15817. */
  15818. getEffectDefines(): string;
  15819. /**
  15820. * Returns the string "CylinderParticleEmitter"
  15821. * @returns a string containing the class name
  15822. */
  15823. getClassName(): string;
  15824. /**
  15825. * Serializes the particle system to a JSON object.
  15826. * @returns the JSON object
  15827. */
  15828. serialize(): any;
  15829. /**
  15830. * Parse properties from a JSON object
  15831. * @param serializationObject defines the JSON object
  15832. */
  15833. parse(serializationObject: any): void;
  15834. }
  15835. /**
  15836. * Particle emitter emitting particles from the inside of a cylinder.
  15837. * It emits the particles randomly between two vectors.
  15838. */
  15839. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15840. /**
  15841. * The min limit of the emission direction.
  15842. */
  15843. direction1: Vector3;
  15844. /**
  15845. * The max limit of the emission direction.
  15846. */
  15847. direction2: Vector3;
  15848. /**
  15849. * Creates a new instance CylinderDirectedParticleEmitter
  15850. * @param radius the radius of the emission cylinder (1 by default)
  15851. * @param height the height of the emission cylinder (1 by default)
  15852. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15853. * @param direction1 the min limit of the emission direction (up vector by default)
  15854. * @param direction2 the max limit of the emission direction (up vector by default)
  15855. */
  15856. constructor(radius?: number, height?: number, radiusRange?: number,
  15857. /**
  15858. * The min limit of the emission direction.
  15859. */
  15860. direction1?: Vector3,
  15861. /**
  15862. * The max limit of the emission direction.
  15863. */
  15864. direction2?: Vector3);
  15865. /**
  15866. * Called by the particle System when the direction is computed for the created particle.
  15867. * @param worldMatrix is the world matrix of the particle system
  15868. * @param directionToUpdate is the direction vector to update with the result
  15869. * @param particle is the particle we are computed the direction for
  15870. */
  15871. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15872. /**
  15873. * Clones the current emitter and returns a copy of it
  15874. * @returns the new emitter
  15875. */
  15876. clone(): CylinderDirectedParticleEmitter;
  15877. /**
  15878. * Called by the GPUParticleSystem to setup the update shader
  15879. * @param effect defines the update shader
  15880. */
  15881. applyToShader(effect: Effect): void;
  15882. /**
  15883. * Returns a string to use to update the GPU particles update shader
  15884. * @returns a string containng the defines string
  15885. */
  15886. getEffectDefines(): string;
  15887. /**
  15888. * Returns the string "CylinderDirectedParticleEmitter"
  15889. * @returns a string containing the class name
  15890. */
  15891. getClassName(): string;
  15892. /**
  15893. * Serializes the particle system to a JSON object.
  15894. * @returns the JSON object
  15895. */
  15896. serialize(): any;
  15897. /**
  15898. * Parse properties from a JSON object
  15899. * @param serializationObject defines the JSON object
  15900. */
  15901. parse(serializationObject: any): void;
  15902. }
  15903. }
  15904. declare module BABYLON {
  15905. /**
  15906. * Particle emitter emitting particles from the inside of a hemisphere.
  15907. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15908. */
  15909. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15910. /**
  15911. * The radius of the emission hemisphere.
  15912. */
  15913. radius: number;
  15914. /**
  15915. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15916. */
  15917. radiusRange: number;
  15918. /**
  15919. * How much to randomize the particle direction [0-1].
  15920. */
  15921. directionRandomizer: number;
  15922. /**
  15923. * Creates a new instance HemisphericParticleEmitter
  15924. * @param radius the radius of the emission hemisphere (1 by default)
  15925. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15926. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15927. */
  15928. constructor(
  15929. /**
  15930. * The radius of the emission hemisphere.
  15931. */
  15932. radius?: number,
  15933. /**
  15934. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15935. */
  15936. radiusRange?: number,
  15937. /**
  15938. * How much to randomize the particle direction [0-1].
  15939. */
  15940. directionRandomizer?: number);
  15941. /**
  15942. * Called by the particle System when the direction is computed for the created particle.
  15943. * @param worldMatrix is the world matrix of the particle system
  15944. * @param directionToUpdate is the direction vector to update with the result
  15945. * @param particle is the particle we are computed the direction for
  15946. */
  15947. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15948. /**
  15949. * Called by the particle System when the position is computed for the created particle.
  15950. * @param worldMatrix is the world matrix of the particle system
  15951. * @param positionToUpdate is the position vector to update with the result
  15952. * @param particle is the particle we are computed the position for
  15953. */
  15954. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15955. /**
  15956. * Clones the current emitter and returns a copy of it
  15957. * @returns the new emitter
  15958. */
  15959. clone(): HemisphericParticleEmitter;
  15960. /**
  15961. * Called by the GPUParticleSystem to setup the update shader
  15962. * @param effect defines the update shader
  15963. */
  15964. applyToShader(effect: Effect): void;
  15965. /**
  15966. * Returns a string to use to update the GPU particles update shader
  15967. * @returns a string containng the defines string
  15968. */
  15969. getEffectDefines(): string;
  15970. /**
  15971. * Returns the string "HemisphericParticleEmitter"
  15972. * @returns a string containing the class name
  15973. */
  15974. getClassName(): string;
  15975. /**
  15976. * Serializes the particle system to a JSON object.
  15977. * @returns the JSON object
  15978. */
  15979. serialize(): any;
  15980. /**
  15981. * Parse properties from a JSON object
  15982. * @param serializationObject defines the JSON object
  15983. */
  15984. parse(serializationObject: any): void;
  15985. }
  15986. }
  15987. declare module BABYLON {
  15988. /**
  15989. * Particle emitter emitting particles from a point.
  15990. * It emits the particles randomly between 2 given directions.
  15991. */
  15992. export class PointParticleEmitter implements IParticleEmitterType {
  15993. /**
  15994. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15995. */
  15996. direction1: Vector3;
  15997. /**
  15998. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15999. */
  16000. direction2: Vector3;
  16001. /**
  16002. * Creates a new instance PointParticleEmitter
  16003. */
  16004. constructor();
  16005. /**
  16006. * Called by the particle System when the direction is computed for the created particle.
  16007. * @param worldMatrix is the world matrix of the particle system
  16008. * @param directionToUpdate is the direction vector to update with the result
  16009. * @param particle is the particle we are computed the direction for
  16010. */
  16011. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16012. /**
  16013. * Called by the particle System when the position is computed for the created particle.
  16014. * @param worldMatrix is the world matrix of the particle system
  16015. * @param positionToUpdate is the position vector to update with the result
  16016. * @param particle is the particle we are computed the position for
  16017. */
  16018. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16019. /**
  16020. * Clones the current emitter and returns a copy of it
  16021. * @returns the new emitter
  16022. */
  16023. clone(): PointParticleEmitter;
  16024. /**
  16025. * Called by the GPUParticleSystem to setup the update shader
  16026. * @param effect defines the update shader
  16027. */
  16028. applyToShader(effect: Effect): void;
  16029. /**
  16030. * Returns a string to use to update the GPU particles update shader
  16031. * @returns a string containng the defines string
  16032. */
  16033. getEffectDefines(): string;
  16034. /**
  16035. * Returns the string "PointParticleEmitter"
  16036. * @returns a string containing the class name
  16037. */
  16038. getClassName(): string;
  16039. /**
  16040. * Serializes the particle system to a JSON object.
  16041. * @returns the JSON object
  16042. */
  16043. serialize(): any;
  16044. /**
  16045. * Parse properties from a JSON object
  16046. * @param serializationObject defines the JSON object
  16047. */
  16048. parse(serializationObject: any): void;
  16049. }
  16050. }
  16051. declare module BABYLON {
  16052. /**
  16053. * Particle emitter emitting particles from the inside of a sphere.
  16054. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16055. */
  16056. export class SphereParticleEmitter implements IParticleEmitterType {
  16057. /**
  16058. * The radius of the emission sphere.
  16059. */
  16060. radius: number;
  16061. /**
  16062. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16063. */
  16064. radiusRange: number;
  16065. /**
  16066. * How much to randomize the particle direction [0-1].
  16067. */
  16068. directionRandomizer: number;
  16069. /**
  16070. * Creates a new instance SphereParticleEmitter
  16071. * @param radius the radius of the emission sphere (1 by default)
  16072. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16073. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16074. */
  16075. constructor(
  16076. /**
  16077. * The radius of the emission sphere.
  16078. */
  16079. radius?: number,
  16080. /**
  16081. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16082. */
  16083. radiusRange?: number,
  16084. /**
  16085. * How much to randomize the particle direction [0-1].
  16086. */
  16087. directionRandomizer?: number);
  16088. /**
  16089. * Called by the particle System when the direction is computed for the created particle.
  16090. * @param worldMatrix is the world matrix of the particle system
  16091. * @param directionToUpdate is the direction vector to update with the result
  16092. * @param particle is the particle we are computed the direction for
  16093. */
  16094. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16095. /**
  16096. * Called by the particle System when the position is computed for the created particle.
  16097. * @param worldMatrix is the world matrix of the particle system
  16098. * @param positionToUpdate is the position vector to update with the result
  16099. * @param particle is the particle we are computed the position for
  16100. */
  16101. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16102. /**
  16103. * Clones the current emitter and returns a copy of it
  16104. * @returns the new emitter
  16105. */
  16106. clone(): SphereParticleEmitter;
  16107. /**
  16108. * Called by the GPUParticleSystem to setup the update shader
  16109. * @param effect defines the update shader
  16110. */
  16111. applyToShader(effect: Effect): void;
  16112. /**
  16113. * Returns a string to use to update the GPU particles update shader
  16114. * @returns a string containng the defines string
  16115. */
  16116. getEffectDefines(): string;
  16117. /**
  16118. * Returns the string "SphereParticleEmitter"
  16119. * @returns a string containing the class name
  16120. */
  16121. getClassName(): string;
  16122. /**
  16123. * Serializes the particle system to a JSON object.
  16124. * @returns the JSON object
  16125. */
  16126. serialize(): any;
  16127. /**
  16128. * Parse properties from a JSON object
  16129. * @param serializationObject defines the JSON object
  16130. */
  16131. parse(serializationObject: any): void;
  16132. }
  16133. /**
  16134. * Particle emitter emitting particles from the inside of a sphere.
  16135. * It emits the particles randomly between two vectors.
  16136. */
  16137. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16138. /**
  16139. * The min limit of the emission direction.
  16140. */
  16141. direction1: Vector3;
  16142. /**
  16143. * The max limit of the emission direction.
  16144. */
  16145. direction2: Vector3;
  16146. /**
  16147. * Creates a new instance SphereDirectedParticleEmitter
  16148. * @param radius the radius of the emission sphere (1 by default)
  16149. * @param direction1 the min limit of the emission direction (up vector by default)
  16150. * @param direction2 the max limit of the emission direction (up vector by default)
  16151. */
  16152. constructor(radius?: number,
  16153. /**
  16154. * The min limit of the emission direction.
  16155. */
  16156. direction1?: Vector3,
  16157. /**
  16158. * The max limit of the emission direction.
  16159. */
  16160. direction2?: Vector3);
  16161. /**
  16162. * Called by the particle System when the direction is computed for the created particle.
  16163. * @param worldMatrix is the world matrix of the particle system
  16164. * @param directionToUpdate is the direction vector to update with the result
  16165. * @param particle is the particle we are computed the direction for
  16166. */
  16167. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16168. /**
  16169. * Clones the current emitter and returns a copy of it
  16170. * @returns the new emitter
  16171. */
  16172. clone(): SphereDirectedParticleEmitter;
  16173. /**
  16174. * Called by the GPUParticleSystem to setup the update shader
  16175. * @param effect defines the update shader
  16176. */
  16177. applyToShader(effect: Effect): void;
  16178. /**
  16179. * Returns a string to use to update the GPU particles update shader
  16180. * @returns a string containng the defines string
  16181. */
  16182. getEffectDefines(): string;
  16183. /**
  16184. * Returns the string "SphereDirectedParticleEmitter"
  16185. * @returns a string containing the class name
  16186. */
  16187. getClassName(): string;
  16188. /**
  16189. * Serializes the particle system to a JSON object.
  16190. * @returns the JSON object
  16191. */
  16192. serialize(): any;
  16193. /**
  16194. * Parse properties from a JSON object
  16195. * @param serializationObject defines the JSON object
  16196. */
  16197. parse(serializationObject: any): void;
  16198. }
  16199. }
  16200. declare module BABYLON {
  16201. /**
  16202. * Interface representing a particle system in Babylon.js.
  16203. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16204. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16205. */
  16206. export interface IParticleSystem {
  16207. /**
  16208. * List of animations used by the particle system.
  16209. */
  16210. animations: Animation[];
  16211. /**
  16212. * The id of the Particle system.
  16213. */
  16214. id: string;
  16215. /**
  16216. * The name of the Particle system.
  16217. */
  16218. name: string;
  16219. /**
  16220. * The emitter represents the Mesh or position we are attaching the particle system to.
  16221. */
  16222. emitter: Nullable<AbstractMesh | Vector3>;
  16223. /**
  16224. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16225. */
  16226. isBillboardBased: boolean;
  16227. /**
  16228. * The rendering group used by the Particle system to chose when to render.
  16229. */
  16230. renderingGroupId: number;
  16231. /**
  16232. * The layer mask we are rendering the particles through.
  16233. */
  16234. layerMask: number;
  16235. /**
  16236. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16237. */
  16238. updateSpeed: number;
  16239. /**
  16240. * The amount of time the particle system is running (depends of the overall update speed).
  16241. */
  16242. targetStopDuration: number;
  16243. /**
  16244. * The texture used to render each particle. (this can be a spritesheet)
  16245. */
  16246. particleTexture: Nullable<Texture>;
  16247. /**
  16248. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16249. */
  16250. blendMode: number;
  16251. /**
  16252. * Minimum life time of emitting particles.
  16253. */
  16254. minLifeTime: number;
  16255. /**
  16256. * Maximum life time of emitting particles.
  16257. */
  16258. maxLifeTime: number;
  16259. /**
  16260. * Minimum Size of emitting particles.
  16261. */
  16262. minSize: number;
  16263. /**
  16264. * Maximum Size of emitting particles.
  16265. */
  16266. maxSize: number;
  16267. /**
  16268. * Minimum scale of emitting particles on X axis.
  16269. */
  16270. minScaleX: number;
  16271. /**
  16272. * Maximum scale of emitting particles on X axis.
  16273. */
  16274. maxScaleX: number;
  16275. /**
  16276. * Minimum scale of emitting particles on Y axis.
  16277. */
  16278. minScaleY: number;
  16279. /**
  16280. * Maximum scale of emitting particles on Y axis.
  16281. */
  16282. maxScaleY: number;
  16283. /**
  16284. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16285. */
  16286. color1: Color4;
  16287. /**
  16288. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16289. */
  16290. color2: Color4;
  16291. /**
  16292. * Color the particle will have at the end of its lifetime.
  16293. */
  16294. colorDead: Color4;
  16295. /**
  16296. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16297. */
  16298. emitRate: number;
  16299. /**
  16300. * You can use gravity if you want to give an orientation to your particles.
  16301. */
  16302. gravity: Vector3;
  16303. /**
  16304. * Minimum power of emitting particles.
  16305. */
  16306. minEmitPower: number;
  16307. /**
  16308. * Maximum power of emitting particles.
  16309. */
  16310. maxEmitPower: number;
  16311. /**
  16312. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16313. */
  16314. minAngularSpeed: number;
  16315. /**
  16316. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16317. */
  16318. maxAngularSpeed: number;
  16319. /**
  16320. * Gets or sets the minimal initial rotation in radians.
  16321. */
  16322. minInitialRotation: number;
  16323. /**
  16324. * Gets or sets the maximal initial rotation in radians.
  16325. */
  16326. maxInitialRotation: number;
  16327. /**
  16328. * The particle emitter type defines the emitter used by the particle system.
  16329. * It can be for example box, sphere, or cone...
  16330. */
  16331. particleEmitterType: Nullable<IParticleEmitterType>;
  16332. /**
  16333. * Defines the delay in milliseconds before starting the system (0 by default)
  16334. */
  16335. startDelay: number;
  16336. /**
  16337. * 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
  16338. */
  16339. preWarmCycles: number;
  16340. /**
  16341. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16342. */
  16343. preWarmStepOffset: number;
  16344. /**
  16345. * 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)
  16346. */
  16347. spriteCellChangeSpeed: number;
  16348. /**
  16349. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16350. */
  16351. startSpriteCellID: number;
  16352. /**
  16353. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16354. */
  16355. endSpriteCellID: number;
  16356. /**
  16357. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16358. */
  16359. spriteCellWidth: number;
  16360. /**
  16361. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16362. */
  16363. spriteCellHeight: number;
  16364. /**
  16365. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16366. */
  16367. spriteRandomStartCell: boolean;
  16368. /**
  16369. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16370. */
  16371. isAnimationSheetEnabled: boolean;
  16372. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16373. translationPivot: Vector2;
  16374. /**
  16375. * Gets or sets a texture used to add random noise to particle positions
  16376. */
  16377. noiseTexture: Nullable<BaseTexture>;
  16378. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16379. noiseStrength: Vector3;
  16380. /**
  16381. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16382. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16383. */
  16384. billboardMode: number;
  16385. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16386. limitVelocityDamping: number;
  16387. /**
  16388. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16389. */
  16390. beginAnimationOnStart: boolean;
  16391. /**
  16392. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16393. */
  16394. beginAnimationFrom: number;
  16395. /**
  16396. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16397. */
  16398. beginAnimationTo: number;
  16399. /**
  16400. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16401. */
  16402. beginAnimationLoop: boolean;
  16403. /**
  16404. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16405. */
  16406. disposeOnStop: boolean;
  16407. /**
  16408. * Gets the maximum number of particles active at the same time.
  16409. * @returns The max number of active particles.
  16410. */
  16411. getCapacity(): number;
  16412. /**
  16413. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16414. * @returns True if it has been started, otherwise false.
  16415. */
  16416. isStarted(): boolean;
  16417. /**
  16418. * Animates the particle system for this frame.
  16419. */
  16420. animate(): void;
  16421. /**
  16422. * Renders the particle system in its current state.
  16423. * @returns the current number of particles
  16424. */
  16425. render(): number;
  16426. /**
  16427. * Dispose the particle system and frees its associated resources.
  16428. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16429. */
  16430. dispose(disposeTexture?: boolean): void;
  16431. /**
  16432. * Clones the particle system.
  16433. * @param name The name of the cloned object
  16434. * @param newEmitter The new emitter to use
  16435. * @returns the cloned particle system
  16436. */
  16437. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16438. /**
  16439. * Serializes the particle system to a JSON object.
  16440. * @returns the JSON object
  16441. */
  16442. serialize(): any;
  16443. /**
  16444. * Rebuild the particle system
  16445. */
  16446. rebuild(): void;
  16447. /**
  16448. * Starts the particle system and begins to emit
  16449. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16450. */
  16451. start(delay?: number): void;
  16452. /**
  16453. * Stops the particle system.
  16454. */
  16455. stop(): void;
  16456. /**
  16457. * Remove all active particles
  16458. */
  16459. reset(): void;
  16460. /**
  16461. * Is this system ready to be used/rendered
  16462. * @return true if the system is ready
  16463. */
  16464. isReady(): boolean;
  16465. /**
  16466. * Adds a new color gradient
  16467. * @param gradient defines the gradient to use (between 0 and 1)
  16468. * @param color1 defines the color to affect to the specified gradient
  16469. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16470. * @returns the current particle system
  16471. */
  16472. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16473. /**
  16474. * Remove a specific color gradient
  16475. * @param gradient defines the gradient to remove
  16476. * @returns the current particle system
  16477. */
  16478. removeColorGradient(gradient: number): IParticleSystem;
  16479. /**
  16480. * Adds a new size gradient
  16481. * @param gradient defines the gradient to use (between 0 and 1)
  16482. * @param factor defines the size factor to affect to the specified gradient
  16483. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16484. * @returns the current particle system
  16485. */
  16486. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16487. /**
  16488. * Remove a specific size gradient
  16489. * @param gradient defines the gradient to remove
  16490. * @returns the current particle system
  16491. */
  16492. removeSizeGradient(gradient: number): IParticleSystem;
  16493. /**
  16494. * Gets the current list of color gradients.
  16495. * You must use addColorGradient and removeColorGradient to udpate this list
  16496. * @returns the list of color gradients
  16497. */
  16498. getColorGradients(): Nullable<Array<ColorGradient>>;
  16499. /**
  16500. * Gets the current list of size gradients.
  16501. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16502. * @returns the list of size gradients
  16503. */
  16504. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16505. /**
  16506. * Gets the current list of angular speed gradients.
  16507. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16508. * @returns the list of angular speed gradients
  16509. */
  16510. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16511. /**
  16512. * Adds a new angular speed gradient
  16513. * @param gradient defines the gradient to use (between 0 and 1)
  16514. * @param factor defines the angular speed to affect to the specified gradient
  16515. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16516. * @returns the current particle system
  16517. */
  16518. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16519. /**
  16520. * Remove a specific angular speed gradient
  16521. * @param gradient defines the gradient to remove
  16522. * @returns the current particle system
  16523. */
  16524. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16525. /**
  16526. * Gets the current list of velocity gradients.
  16527. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16528. * @returns the list of velocity gradients
  16529. */
  16530. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16531. /**
  16532. * Adds a new velocity gradient
  16533. * @param gradient defines the gradient to use (between 0 and 1)
  16534. * @param factor defines the velocity to affect to the specified gradient
  16535. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16536. * @returns the current particle system
  16537. */
  16538. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16539. /**
  16540. * Remove a specific velocity gradient
  16541. * @param gradient defines the gradient to remove
  16542. * @returns the current particle system
  16543. */
  16544. removeVelocityGradient(gradient: number): IParticleSystem;
  16545. /**
  16546. * Gets the current list of limit velocity gradients.
  16547. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16548. * @returns the list of limit velocity gradients
  16549. */
  16550. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16551. /**
  16552. * Adds a new limit velocity gradient
  16553. * @param gradient defines the gradient to use (between 0 and 1)
  16554. * @param factor defines the limit velocity to affect to the specified gradient
  16555. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16556. * @returns the current particle system
  16557. */
  16558. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16559. /**
  16560. * Remove a specific limit velocity gradient
  16561. * @param gradient defines the gradient to remove
  16562. * @returns the current particle system
  16563. */
  16564. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16565. /**
  16566. * Adds a new drag gradient
  16567. * @param gradient defines the gradient to use (between 0 and 1)
  16568. * @param factor defines the drag to affect to the specified gradient
  16569. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16570. * @returns the current particle system
  16571. */
  16572. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16573. /**
  16574. * Remove a specific drag gradient
  16575. * @param gradient defines the gradient to remove
  16576. * @returns the current particle system
  16577. */
  16578. removeDragGradient(gradient: number): IParticleSystem;
  16579. /**
  16580. * Gets the current list of drag gradients.
  16581. * You must use addDragGradient and removeDragGradient to udpate this list
  16582. * @returns the list of drag gradients
  16583. */
  16584. getDragGradients(): Nullable<Array<FactorGradient>>;
  16585. /**
  16586. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16587. * @param gradient defines the gradient to use (between 0 and 1)
  16588. * @param factor defines the emit rate to affect to the specified gradient
  16589. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16590. * @returns the current particle system
  16591. */
  16592. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16593. /**
  16594. * Remove a specific emit rate gradient
  16595. * @param gradient defines the gradient to remove
  16596. * @returns the current particle system
  16597. */
  16598. removeEmitRateGradient(gradient: number): IParticleSystem;
  16599. /**
  16600. * Gets the current list of emit rate gradients.
  16601. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16602. * @returns the list of emit rate gradients
  16603. */
  16604. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16605. /**
  16606. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16607. * @param gradient defines the gradient to use (between 0 and 1)
  16608. * @param factor defines the start size to affect to the specified gradient
  16609. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16610. * @returns the current particle system
  16611. */
  16612. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16613. /**
  16614. * Remove a specific start size gradient
  16615. * @param gradient defines the gradient to remove
  16616. * @returns the current particle system
  16617. */
  16618. removeStartSizeGradient(gradient: number): IParticleSystem;
  16619. /**
  16620. * Gets the current list of start size gradients.
  16621. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16622. * @returns the list of start size gradients
  16623. */
  16624. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16625. /**
  16626. * Adds a new life time gradient
  16627. * @param gradient defines the gradient to use (between 0 and 1)
  16628. * @param factor defines the life time factor to affect to the specified gradient
  16629. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16630. * @returns the current particle system
  16631. */
  16632. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16633. /**
  16634. * Remove a specific life time gradient
  16635. * @param gradient defines the gradient to remove
  16636. * @returns the current particle system
  16637. */
  16638. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16639. /**
  16640. * Gets the current list of life time gradients.
  16641. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16642. * @returns the list of life time gradients
  16643. */
  16644. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16645. /**
  16646. * Gets the current list of color gradients.
  16647. * You must use addColorGradient and removeColorGradient to udpate this list
  16648. * @returns the list of color gradients
  16649. */
  16650. getColorGradients(): Nullable<Array<ColorGradient>>;
  16651. /**
  16652. * Adds a new ramp gradient used to remap particle colors
  16653. * @param gradient defines the gradient to use (between 0 and 1)
  16654. * @param color defines the color to affect to the specified gradient
  16655. * @returns the current particle system
  16656. */
  16657. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16658. /**
  16659. * Gets the current list of ramp gradients.
  16660. * You must use addRampGradient and removeRampGradient to udpate this list
  16661. * @returns the list of ramp gradients
  16662. */
  16663. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16664. /** Gets or sets a boolean indicating that ramp gradients must be used
  16665. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16666. */
  16667. useRampGradients: boolean;
  16668. /**
  16669. * Adds a new color remap gradient
  16670. * @param gradient defines the gradient to use (between 0 and 1)
  16671. * @param min defines the color remap minimal range
  16672. * @param max defines the color remap maximal range
  16673. * @returns the current particle system
  16674. */
  16675. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16676. /**
  16677. * Gets the current list of color remap gradients.
  16678. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16679. * @returns the list of color remap gradients
  16680. */
  16681. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16682. /**
  16683. * Adds a new alpha remap gradient
  16684. * @param gradient defines the gradient to use (between 0 and 1)
  16685. * @param min defines the alpha remap minimal range
  16686. * @param max defines the alpha remap maximal range
  16687. * @returns the current particle system
  16688. */
  16689. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16690. /**
  16691. * Gets the current list of alpha remap gradients.
  16692. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16693. * @returns the list of alpha remap gradients
  16694. */
  16695. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16696. /**
  16697. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16698. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16699. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16700. * @returns the emitter
  16701. */
  16702. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16703. /**
  16704. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16705. * @param radius The radius of the hemisphere to emit from
  16706. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16707. * @returns the emitter
  16708. */
  16709. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16710. /**
  16711. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16712. * @param radius The radius of the sphere to emit from
  16713. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16714. * @returns the emitter
  16715. */
  16716. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16717. /**
  16718. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16719. * @param radius The radius of the sphere to emit from
  16720. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16721. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16722. * @returns the emitter
  16723. */
  16724. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16725. /**
  16726. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16727. * @param radius The radius of the emission cylinder
  16728. * @param height The height of the emission cylinder
  16729. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16730. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16731. * @returns the emitter
  16732. */
  16733. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16734. /**
  16735. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16736. * @param radius The radius of the cylinder to emit from
  16737. * @param height The height of the emission cylinder
  16738. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16739. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16740. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16741. * @returns the emitter
  16742. */
  16743. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16744. /**
  16745. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16746. * @param radius The radius of the cone to emit from
  16747. * @param angle The base angle of the cone
  16748. * @returns the emitter
  16749. */
  16750. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16751. /**
  16752. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16753. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16754. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16755. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16756. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16757. * @returns the emitter
  16758. */
  16759. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16760. /**
  16761. * Get hosting scene
  16762. * @returns the scene
  16763. */
  16764. getScene(): Scene;
  16765. }
  16766. }
  16767. declare module BABYLON {
  16768. /**
  16769. * Creates an instance based on a source mesh.
  16770. */
  16771. export class InstancedMesh extends AbstractMesh {
  16772. private _sourceMesh;
  16773. private _currentLOD;
  16774. /** @hidden */
  16775. _indexInSourceMeshInstanceArray: number;
  16776. constructor(name: string, source: Mesh);
  16777. /**
  16778. * Returns the string "InstancedMesh".
  16779. */
  16780. getClassName(): string;
  16781. /** Gets the list of lights affecting that mesh */
  16782. readonly lightSources: Light[];
  16783. _resyncLightSources(): void;
  16784. _resyncLighSource(light: Light): void;
  16785. _removeLightSource(light: Light): void;
  16786. /**
  16787. * If the source mesh receives shadows
  16788. */
  16789. readonly receiveShadows: boolean;
  16790. /**
  16791. * The material of the source mesh
  16792. */
  16793. readonly material: Nullable<Material>;
  16794. /**
  16795. * Visibility of the source mesh
  16796. */
  16797. readonly visibility: number;
  16798. /**
  16799. * Skeleton of the source mesh
  16800. */
  16801. readonly skeleton: Nullable<Skeleton>;
  16802. /**
  16803. * Rendering ground id of the source mesh
  16804. */
  16805. renderingGroupId: number;
  16806. /**
  16807. * Returns the total number of vertices (integer).
  16808. */
  16809. getTotalVertices(): number;
  16810. /**
  16811. * Returns a positive integer : the total number of indices in this mesh geometry.
  16812. * @returns the numner of indices or zero if the mesh has no geometry.
  16813. */
  16814. getTotalIndices(): number;
  16815. /**
  16816. * The source mesh of the instance
  16817. */
  16818. readonly sourceMesh: Mesh;
  16819. /**
  16820. * Is this node ready to be used/rendered
  16821. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16822. * @return {boolean} is it ready
  16823. */
  16824. isReady(completeCheck?: boolean): boolean;
  16825. /**
  16826. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16827. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16828. * @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.
  16829. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16830. */
  16831. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16832. /**
  16833. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16834. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16835. * The `data` are either a numeric array either a Float32Array.
  16836. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16837. * 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).
  16838. * Note that a new underlying VertexBuffer object is created each call.
  16839. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16840. *
  16841. * Possible `kind` values :
  16842. * - VertexBuffer.PositionKind
  16843. * - VertexBuffer.UVKind
  16844. * - VertexBuffer.UV2Kind
  16845. * - VertexBuffer.UV3Kind
  16846. * - VertexBuffer.UV4Kind
  16847. * - VertexBuffer.UV5Kind
  16848. * - VertexBuffer.UV6Kind
  16849. * - VertexBuffer.ColorKind
  16850. * - VertexBuffer.MatricesIndicesKind
  16851. * - VertexBuffer.MatricesIndicesExtraKind
  16852. * - VertexBuffer.MatricesWeightsKind
  16853. * - VertexBuffer.MatricesWeightsExtraKind
  16854. *
  16855. * Returns the Mesh.
  16856. */
  16857. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16858. /**
  16859. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16860. * If the mesh has no geometry, it is simply returned as it is.
  16861. * The `data` are either a numeric array either a Float32Array.
  16862. * No new underlying VertexBuffer object is created.
  16863. * 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.
  16864. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16865. *
  16866. * Possible `kind` values :
  16867. * - VertexBuffer.PositionKind
  16868. * - VertexBuffer.UVKind
  16869. * - VertexBuffer.UV2Kind
  16870. * - VertexBuffer.UV3Kind
  16871. * - VertexBuffer.UV4Kind
  16872. * - VertexBuffer.UV5Kind
  16873. * - VertexBuffer.UV6Kind
  16874. * - VertexBuffer.ColorKind
  16875. * - VertexBuffer.MatricesIndicesKind
  16876. * - VertexBuffer.MatricesIndicesExtraKind
  16877. * - VertexBuffer.MatricesWeightsKind
  16878. * - VertexBuffer.MatricesWeightsExtraKind
  16879. *
  16880. * Returns the Mesh.
  16881. */
  16882. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16883. /**
  16884. * Sets the mesh indices.
  16885. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16886. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16887. * This method creates a new index buffer each call.
  16888. * Returns the Mesh.
  16889. */
  16890. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16891. /**
  16892. * Boolean : True if the mesh owns the requested kind of data.
  16893. */
  16894. isVerticesDataPresent(kind: string): boolean;
  16895. /**
  16896. * Returns an array of indices (IndicesArray).
  16897. */
  16898. getIndices(): Nullable<IndicesArray>;
  16899. readonly _positions: Nullable<Vector3[]>;
  16900. /**
  16901. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16902. * This means the mesh underlying bounding box and sphere are recomputed.
  16903. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16904. * @returns the current mesh
  16905. */
  16906. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16907. /** @hidden */
  16908. _preActivate(): InstancedMesh;
  16909. /** @hidden */
  16910. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16911. /** @hidden */
  16912. _postActivate(): void;
  16913. getWorldMatrix(): Matrix;
  16914. readonly isAnInstance: boolean;
  16915. /**
  16916. * Returns the current associated LOD AbstractMesh.
  16917. */
  16918. getLOD(camera: Camera): AbstractMesh;
  16919. /** @hidden */
  16920. _syncSubMeshes(): InstancedMesh;
  16921. /** @hidden */
  16922. _generatePointsArray(): boolean;
  16923. /**
  16924. * Creates a new InstancedMesh from the current mesh.
  16925. * - name (string) : the cloned mesh name
  16926. * - newParent (optional Node) : the optional Node to parent the clone to.
  16927. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16928. *
  16929. * Returns the clone.
  16930. */
  16931. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16932. /**
  16933. * Disposes the InstancedMesh.
  16934. * Returns nothing.
  16935. */
  16936. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16937. }
  16938. }
  16939. declare module BABYLON {
  16940. /**
  16941. * Defines the options associated with the creation of a shader material.
  16942. */
  16943. export interface IShaderMaterialOptions {
  16944. /**
  16945. * Does the material work in alpha blend mode
  16946. */
  16947. needAlphaBlending: boolean;
  16948. /**
  16949. * Does the material work in alpha test mode
  16950. */
  16951. needAlphaTesting: boolean;
  16952. /**
  16953. * The list of attribute names used in the shader
  16954. */
  16955. attributes: string[];
  16956. /**
  16957. * The list of unifrom names used in the shader
  16958. */
  16959. uniforms: string[];
  16960. /**
  16961. * The list of UBO names used in the shader
  16962. */
  16963. uniformBuffers: string[];
  16964. /**
  16965. * The list of sampler names used in the shader
  16966. */
  16967. samplers: string[];
  16968. /**
  16969. * The list of defines used in the shader
  16970. */
  16971. defines: string[];
  16972. }
  16973. /**
  16974. * 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.
  16975. *
  16976. * This returned material effects how the mesh will look based on the code in the shaders.
  16977. *
  16978. * @see http://doc.babylonjs.com/how_to/shader_material
  16979. */
  16980. export class ShaderMaterial extends Material {
  16981. private _shaderPath;
  16982. private _options;
  16983. private _textures;
  16984. private _textureArrays;
  16985. private _floats;
  16986. private _ints;
  16987. private _floatsArrays;
  16988. private _colors3;
  16989. private _colors3Arrays;
  16990. private _colors4;
  16991. private _vectors2;
  16992. private _vectors3;
  16993. private _vectors4;
  16994. private _matrices;
  16995. private _matrices3x3;
  16996. private _matrices2x2;
  16997. private _vectors2Arrays;
  16998. private _vectors3Arrays;
  16999. private _cachedWorldViewMatrix;
  17000. private _cachedWorldViewProjectionMatrix;
  17001. private _renderId;
  17002. /**
  17003. * Instantiate a new shader material.
  17004. * 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.
  17005. * This returned material effects how the mesh will look based on the code in the shaders.
  17006. * @see http://doc.babylonjs.com/how_to/shader_material
  17007. * @param name Define the name of the material in the scene
  17008. * @param scene Define the scene the material belongs to
  17009. * @param shaderPath Defines the route to the shader code in one of three ways:
  17010. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17011. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17012. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17013. * @param options Define the options used to create the shader
  17014. */
  17015. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17016. /**
  17017. * Gets the options used to compile the shader.
  17018. * They can be modified to trigger a new compilation
  17019. */
  17020. readonly options: IShaderMaterialOptions;
  17021. /**
  17022. * Gets the current class name of the material e.g. "ShaderMaterial"
  17023. * Mainly use in serialization.
  17024. * @returns the class name
  17025. */
  17026. getClassName(): string;
  17027. /**
  17028. * Specifies if the material will require alpha blending
  17029. * @returns a boolean specifying if alpha blending is needed
  17030. */
  17031. needAlphaBlending(): boolean;
  17032. /**
  17033. * Specifies if this material should be rendered in alpha test mode
  17034. * @returns a boolean specifying if an alpha test is needed.
  17035. */
  17036. needAlphaTesting(): boolean;
  17037. private _checkUniform;
  17038. /**
  17039. * Set a texture in the shader.
  17040. * @param name Define the name of the uniform samplers as defined in the shader
  17041. * @param texture Define the texture to bind to this sampler
  17042. * @return the material itself allowing "fluent" like uniform updates
  17043. */
  17044. setTexture(name: string, texture: Texture): ShaderMaterial;
  17045. /**
  17046. * Set a texture array in the shader.
  17047. * @param name Define the name of the uniform sampler array as defined in the shader
  17048. * @param textures Define the list of textures to bind to this sampler
  17049. * @return the material itself allowing "fluent" like uniform updates
  17050. */
  17051. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17052. /**
  17053. * Set a float in the shader.
  17054. * @param name Define the name of the uniform as defined in the shader
  17055. * @param value Define the value to give to the uniform
  17056. * @return the material itself allowing "fluent" like uniform updates
  17057. */
  17058. setFloat(name: string, value: number): ShaderMaterial;
  17059. /**
  17060. * Set a int in the shader.
  17061. * @param name Define the name of the uniform as defined in the shader
  17062. * @param value Define the value to give to the uniform
  17063. * @return the material itself allowing "fluent" like uniform updates
  17064. */
  17065. setInt(name: string, value: number): ShaderMaterial;
  17066. /**
  17067. * Set an array of floats in the shader.
  17068. * @param name Define the name of the uniform as defined in the shader
  17069. * @param value Define the value to give to the uniform
  17070. * @return the material itself allowing "fluent" like uniform updates
  17071. */
  17072. setFloats(name: string, value: number[]): ShaderMaterial;
  17073. /**
  17074. * Set a vec3 in the shader from a Color3.
  17075. * @param name Define the name of the uniform as defined in the shader
  17076. * @param value Define the value to give to the uniform
  17077. * @return the material itself allowing "fluent" like uniform updates
  17078. */
  17079. setColor3(name: string, value: Color3): ShaderMaterial;
  17080. /**
  17081. * Set a vec3 array in the shader from a Color3 array.
  17082. * @param name Define the name of the uniform as defined in the shader
  17083. * @param value Define the value to give to the uniform
  17084. * @return the material itself allowing "fluent" like uniform updates
  17085. */
  17086. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17087. /**
  17088. * Set a vec4 in the shader from a Color4.
  17089. * @param name Define the name of the uniform as defined in the shader
  17090. * @param value Define the value to give to the uniform
  17091. * @return the material itself allowing "fluent" like uniform updates
  17092. */
  17093. setColor4(name: string, value: Color4): ShaderMaterial;
  17094. /**
  17095. * Set a vec2 in the shader from a Vector2.
  17096. * @param name Define the name of the uniform as defined in the shader
  17097. * @param value Define the value to give to the uniform
  17098. * @return the material itself allowing "fluent" like uniform updates
  17099. */
  17100. setVector2(name: string, value: Vector2): ShaderMaterial;
  17101. /**
  17102. * Set a vec3 in the shader from a Vector3.
  17103. * @param name Define the name of the uniform as defined in the shader
  17104. * @param value Define the value to give to the uniform
  17105. * @return the material itself allowing "fluent" like uniform updates
  17106. */
  17107. setVector3(name: string, value: Vector3): ShaderMaterial;
  17108. /**
  17109. * Set a vec4 in the shader from a Vector4.
  17110. * @param name Define the name of the uniform as defined in the shader
  17111. * @param value Define the value to give to the uniform
  17112. * @return the material itself allowing "fluent" like uniform updates
  17113. */
  17114. setVector4(name: string, value: Vector4): ShaderMaterial;
  17115. /**
  17116. * Set a mat4 in the shader from a Matrix.
  17117. * @param name Define the name of the uniform as defined in the shader
  17118. * @param value Define the value to give to the uniform
  17119. * @return the material itself allowing "fluent" like uniform updates
  17120. */
  17121. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17122. /**
  17123. * Set a mat3 in the shader from a Float32Array.
  17124. * @param name Define the name of the uniform as defined in the shader
  17125. * @param value Define the value to give to the uniform
  17126. * @return the material itself allowing "fluent" like uniform updates
  17127. */
  17128. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17129. /**
  17130. * Set a mat2 in the shader from a Float32Array.
  17131. * @param name Define the name of the uniform as defined in the shader
  17132. * @param value Define the value to give to the uniform
  17133. * @return the material itself allowing "fluent" like uniform updates
  17134. */
  17135. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17136. /**
  17137. * Set a vec2 array in the shader from a number array.
  17138. * @param name Define the name of the uniform as defined in the shader
  17139. * @param value Define the value to give to the uniform
  17140. * @return the material itself allowing "fluent" like uniform updates
  17141. */
  17142. setArray2(name: string, value: number[]): ShaderMaterial;
  17143. /**
  17144. * Set a vec3 array in the shader from a number array.
  17145. * @param name Define the name of the uniform as defined in the shader
  17146. * @param value Define the value to give to the uniform
  17147. * @return the material itself allowing "fluent" like uniform updates
  17148. */
  17149. setArray3(name: string, value: number[]): ShaderMaterial;
  17150. private _checkCache;
  17151. /**
  17152. * Specifies that the submesh is ready to be used
  17153. * @param mesh defines the mesh to check
  17154. * @param subMesh defines which submesh to check
  17155. * @param useInstances specifies that instances should be used
  17156. * @returns a boolean indicating that the submesh is ready or not
  17157. */
  17158. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17159. /**
  17160. * Checks if the material is ready to render the requested mesh
  17161. * @param mesh Define the mesh to render
  17162. * @param useInstances Define whether or not the material is used with instances
  17163. * @returns true if ready, otherwise false
  17164. */
  17165. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17166. /**
  17167. * Binds the world matrix to the material
  17168. * @param world defines the world transformation matrix
  17169. */
  17170. bindOnlyWorldMatrix(world: Matrix): void;
  17171. /**
  17172. * Binds the material to the mesh
  17173. * @param world defines the world transformation matrix
  17174. * @param mesh defines the mesh to bind the material to
  17175. */
  17176. bind(world: Matrix, mesh?: Mesh): void;
  17177. /**
  17178. * Gets the active textures from the material
  17179. * @returns an array of textures
  17180. */
  17181. getActiveTextures(): BaseTexture[];
  17182. /**
  17183. * Specifies if the material uses a texture
  17184. * @param texture defines the texture to check against the material
  17185. * @returns a boolean specifying if the material uses the texture
  17186. */
  17187. hasTexture(texture: BaseTexture): boolean;
  17188. /**
  17189. * Makes a duplicate of the material, and gives it a new name
  17190. * @param name defines the new name for the duplicated material
  17191. * @returns the cloned material
  17192. */
  17193. clone(name: string): ShaderMaterial;
  17194. /**
  17195. * Disposes the material
  17196. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17197. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17198. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17199. */
  17200. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17201. /**
  17202. * Serializes this material in a JSON representation
  17203. * @returns the serialized material object
  17204. */
  17205. serialize(): any;
  17206. /**
  17207. * Creates a shader material from parsed shader material data
  17208. * @param source defines the JSON represnetation of the material
  17209. * @param scene defines the hosting scene
  17210. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17211. * @returns a new material
  17212. */
  17213. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17214. }
  17215. }
  17216. declare module BABYLON {
  17217. /** @hidden */
  17218. export var colorPixelShader: {
  17219. name: string;
  17220. shader: string;
  17221. };
  17222. }
  17223. declare module BABYLON {
  17224. /** @hidden */
  17225. export var colorVertexShader: {
  17226. name: string;
  17227. shader: string;
  17228. };
  17229. }
  17230. declare module BABYLON {
  17231. /**
  17232. * Line mesh
  17233. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17234. */
  17235. export class LinesMesh extends Mesh {
  17236. /**
  17237. * If vertex color should be applied to the mesh
  17238. */
  17239. readonly useVertexColor?: boolean | undefined;
  17240. /**
  17241. * If vertex alpha should be applied to the mesh
  17242. */
  17243. readonly useVertexAlpha?: boolean | undefined;
  17244. /**
  17245. * Color of the line (Default: White)
  17246. */
  17247. color: Color3;
  17248. /**
  17249. * Alpha of the line (Default: 1)
  17250. */
  17251. alpha: number;
  17252. /**
  17253. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17254. * This margin is expressed in world space coordinates, so its value may vary.
  17255. * Default value is 0.1
  17256. */
  17257. intersectionThreshold: number;
  17258. private _colorShader;
  17259. private color4;
  17260. /**
  17261. * Creates a new LinesMesh
  17262. * @param name defines the name
  17263. * @param scene defines the hosting scene
  17264. * @param parent defines the parent mesh if any
  17265. * @param source defines the optional source LinesMesh used to clone data from
  17266. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17267. * When false, achieved by calling a clone(), also passing False.
  17268. * This will make creation of children, recursive.
  17269. * @param useVertexColor defines if this LinesMesh supports vertex color
  17270. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17271. */
  17272. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17273. /**
  17274. * If vertex color should be applied to the mesh
  17275. */
  17276. useVertexColor?: boolean | undefined,
  17277. /**
  17278. * If vertex alpha should be applied to the mesh
  17279. */
  17280. useVertexAlpha?: boolean | undefined);
  17281. private _addClipPlaneDefine;
  17282. private _removeClipPlaneDefine;
  17283. isReady(): boolean;
  17284. /**
  17285. * Returns the string "LineMesh"
  17286. */
  17287. getClassName(): string;
  17288. /**
  17289. * @hidden
  17290. */
  17291. /**
  17292. * @hidden
  17293. */
  17294. material: Material;
  17295. /**
  17296. * @hidden
  17297. */
  17298. readonly checkCollisions: boolean;
  17299. /** @hidden */
  17300. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17301. /** @hidden */
  17302. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17303. /**
  17304. * Disposes of the line mesh
  17305. * @param doNotRecurse If children should be disposed
  17306. */
  17307. dispose(doNotRecurse?: boolean): void;
  17308. /**
  17309. * Returns a new LineMesh object cloned from the current one.
  17310. */
  17311. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17312. /**
  17313. * Creates a new InstancedLinesMesh object from the mesh model.
  17314. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17315. * @param name defines the name of the new instance
  17316. * @returns a new InstancedLinesMesh
  17317. */
  17318. createInstance(name: string): InstancedLinesMesh;
  17319. }
  17320. /**
  17321. * Creates an instance based on a source LinesMesh
  17322. */
  17323. export class InstancedLinesMesh extends InstancedMesh {
  17324. /**
  17325. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17326. * This margin is expressed in world space coordinates, so its value may vary.
  17327. * Initilized with the intersectionThreshold value of the source LinesMesh
  17328. */
  17329. intersectionThreshold: number;
  17330. constructor(name: string, source: LinesMesh);
  17331. /**
  17332. * Returns the string "InstancedLinesMesh".
  17333. */
  17334. getClassName(): string;
  17335. }
  17336. }
  17337. declare module BABYLON {
  17338. /** @hidden */
  17339. export var linePixelShader: {
  17340. name: string;
  17341. shader: string;
  17342. };
  17343. }
  17344. declare module BABYLON {
  17345. /** @hidden */
  17346. export var lineVertexShader: {
  17347. name: string;
  17348. shader: string;
  17349. };
  17350. }
  17351. declare module BABYLON {
  17352. interface AbstractMesh {
  17353. /**
  17354. * Gets the edgesRenderer associated with the mesh
  17355. */
  17356. edgesRenderer: Nullable<EdgesRenderer>;
  17357. }
  17358. interface LinesMesh {
  17359. /**
  17360. * Enables the edge rendering mode on the mesh.
  17361. * This mode makes the mesh edges visible
  17362. * @param epsilon defines the maximal distance between two angles to detect a face
  17363. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17364. * @returns the currentAbstractMesh
  17365. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17366. */
  17367. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17368. }
  17369. interface InstancedLinesMesh {
  17370. /**
  17371. * Enables the edge rendering mode on the mesh.
  17372. * This mode makes the mesh edges visible
  17373. * @param epsilon defines the maximal distance between two angles to detect a face
  17374. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17375. * @returns the current InstancedLinesMesh
  17376. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17377. */
  17378. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17379. }
  17380. /**
  17381. * Defines the minimum contract an Edges renderer should follow.
  17382. */
  17383. export interface IEdgesRenderer extends IDisposable {
  17384. /**
  17385. * Gets or sets a boolean indicating if the edgesRenderer is active
  17386. */
  17387. isEnabled: boolean;
  17388. /**
  17389. * Renders the edges of the attached mesh,
  17390. */
  17391. render(): void;
  17392. /**
  17393. * Checks wether or not the edges renderer is ready to render.
  17394. * @return true if ready, otherwise false.
  17395. */
  17396. isReady(): boolean;
  17397. }
  17398. /**
  17399. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17400. */
  17401. export class EdgesRenderer implements IEdgesRenderer {
  17402. /**
  17403. * Define the size of the edges with an orthographic camera
  17404. */
  17405. edgesWidthScalerForOrthographic: number;
  17406. /**
  17407. * Define the size of the edges with a perspective camera
  17408. */
  17409. edgesWidthScalerForPerspective: number;
  17410. protected _source: AbstractMesh;
  17411. protected _linesPositions: number[];
  17412. protected _linesNormals: number[];
  17413. protected _linesIndices: number[];
  17414. protected _epsilon: number;
  17415. protected _indicesCount: number;
  17416. protected _lineShader: ShaderMaterial;
  17417. protected _ib: DataBuffer;
  17418. protected _buffers: {
  17419. [key: string]: Nullable<VertexBuffer>;
  17420. };
  17421. protected _checkVerticesInsteadOfIndices: boolean;
  17422. private _meshRebuildObserver;
  17423. private _meshDisposeObserver;
  17424. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17425. isEnabled: boolean;
  17426. /**
  17427. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17428. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17429. * @param source Mesh used to create edges
  17430. * @param epsilon sum of angles in adjacency to check for edge
  17431. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17432. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17433. */
  17434. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17435. protected _prepareRessources(): void;
  17436. /** @hidden */
  17437. _rebuild(): void;
  17438. /**
  17439. * Releases the required resources for the edges renderer
  17440. */
  17441. dispose(): void;
  17442. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17443. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17444. /**
  17445. * Checks if the pair of p0 and p1 is en edge
  17446. * @param faceIndex
  17447. * @param edge
  17448. * @param faceNormals
  17449. * @param p0
  17450. * @param p1
  17451. * @private
  17452. */
  17453. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17454. /**
  17455. * push line into the position, normal and index buffer
  17456. * @protected
  17457. */
  17458. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17459. /**
  17460. * Generates lines edges from adjacencjes
  17461. * @private
  17462. */
  17463. _generateEdgesLines(): void;
  17464. /**
  17465. * Checks wether or not the edges renderer is ready to render.
  17466. * @return true if ready, otherwise false.
  17467. */
  17468. isReady(): boolean;
  17469. /**
  17470. * Renders the edges of the attached mesh,
  17471. */
  17472. render(): void;
  17473. }
  17474. /**
  17475. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17476. */
  17477. export class LineEdgesRenderer extends EdgesRenderer {
  17478. /**
  17479. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17480. * @param source LineMesh used to generate edges
  17481. * @param epsilon not important (specified angle for edge detection)
  17482. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17483. */
  17484. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17485. /**
  17486. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17487. */
  17488. _generateEdgesLines(): void;
  17489. }
  17490. }
  17491. declare module BABYLON {
  17492. /**
  17493. * This represents the object necessary to create a rendering group.
  17494. * This is exclusively used and created by the rendering manager.
  17495. * To modify the behavior, you use the available helpers in your scene or meshes.
  17496. * @hidden
  17497. */
  17498. export class RenderingGroup {
  17499. index: number;
  17500. private static _zeroVector;
  17501. private _scene;
  17502. private _opaqueSubMeshes;
  17503. private _transparentSubMeshes;
  17504. private _alphaTestSubMeshes;
  17505. private _depthOnlySubMeshes;
  17506. private _particleSystems;
  17507. private _spriteManagers;
  17508. private _opaqueSortCompareFn;
  17509. private _alphaTestSortCompareFn;
  17510. private _transparentSortCompareFn;
  17511. private _renderOpaque;
  17512. private _renderAlphaTest;
  17513. private _renderTransparent;
  17514. /** @hidden */
  17515. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17516. onBeforeTransparentRendering: () => void;
  17517. /**
  17518. * Set the opaque sort comparison function.
  17519. * If null the sub meshes will be render in the order they were created
  17520. */
  17521. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17522. /**
  17523. * Set the alpha test sort comparison function.
  17524. * If null the sub meshes will be render in the order they were created
  17525. */
  17526. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17527. /**
  17528. * Set the transparent sort comparison function.
  17529. * If null the sub meshes will be render in the order they were created
  17530. */
  17531. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17532. /**
  17533. * Creates a new rendering group.
  17534. * @param index The rendering group index
  17535. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17536. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17537. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17538. */
  17539. 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>);
  17540. /**
  17541. * Render all the sub meshes contained in the group.
  17542. * @param customRenderFunction Used to override the default render behaviour of the group.
  17543. * @returns true if rendered some submeshes.
  17544. */
  17545. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17546. /**
  17547. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17548. * @param subMeshes The submeshes to render
  17549. */
  17550. private renderOpaqueSorted;
  17551. /**
  17552. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17553. * @param subMeshes The submeshes to render
  17554. */
  17555. private renderAlphaTestSorted;
  17556. /**
  17557. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17558. * @param subMeshes The submeshes to render
  17559. */
  17560. private renderTransparentSorted;
  17561. /**
  17562. * Renders the submeshes in a specified order.
  17563. * @param subMeshes The submeshes to sort before render
  17564. * @param sortCompareFn The comparison function use to sort
  17565. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17566. * @param transparent Specifies to activate blending if true
  17567. */
  17568. private static renderSorted;
  17569. /**
  17570. * Renders the submeshes in the order they were dispatched (no sort applied).
  17571. * @param subMeshes The submeshes to render
  17572. */
  17573. private static renderUnsorted;
  17574. /**
  17575. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17576. * are rendered back to front if in the same alpha index.
  17577. *
  17578. * @param a The first submesh
  17579. * @param b The second submesh
  17580. * @returns The result of the comparison
  17581. */
  17582. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17583. /**
  17584. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17585. * are rendered back to front.
  17586. *
  17587. * @param a The first submesh
  17588. * @param b The second submesh
  17589. * @returns The result of the comparison
  17590. */
  17591. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17592. /**
  17593. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17594. * are rendered front to back (prevent overdraw).
  17595. *
  17596. * @param a The first submesh
  17597. * @param b The second submesh
  17598. * @returns The result of the comparison
  17599. */
  17600. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17601. /**
  17602. * Resets the different lists of submeshes to prepare a new frame.
  17603. */
  17604. prepare(): void;
  17605. dispose(): void;
  17606. /**
  17607. * Inserts the submesh in its correct queue depending on its material.
  17608. * @param subMesh The submesh to dispatch
  17609. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17610. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17611. */
  17612. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17613. dispatchSprites(spriteManager: ISpriteManager): void;
  17614. dispatchParticles(particleSystem: IParticleSystem): void;
  17615. private _renderParticles;
  17616. private _renderSprites;
  17617. }
  17618. }
  17619. declare module BABYLON {
  17620. /**
  17621. * Interface describing the different options available in the rendering manager
  17622. * regarding Auto Clear between groups.
  17623. */
  17624. export interface IRenderingManagerAutoClearSetup {
  17625. /**
  17626. * Defines whether or not autoclear is enable.
  17627. */
  17628. autoClear: boolean;
  17629. /**
  17630. * Defines whether or not to autoclear the depth buffer.
  17631. */
  17632. depth: boolean;
  17633. /**
  17634. * Defines whether or not to autoclear the stencil buffer.
  17635. */
  17636. stencil: boolean;
  17637. }
  17638. /**
  17639. * This class is used by the onRenderingGroupObservable
  17640. */
  17641. export class RenderingGroupInfo {
  17642. /**
  17643. * The Scene that being rendered
  17644. */
  17645. scene: Scene;
  17646. /**
  17647. * The camera currently used for the rendering pass
  17648. */
  17649. camera: Nullable<Camera>;
  17650. /**
  17651. * The ID of the renderingGroup being processed
  17652. */
  17653. renderingGroupId: number;
  17654. }
  17655. /**
  17656. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17657. * It is enable to manage the different groups as well as the different necessary sort functions.
  17658. * This should not be used directly aside of the few static configurations
  17659. */
  17660. export class RenderingManager {
  17661. /**
  17662. * The max id used for rendering groups (not included)
  17663. */
  17664. static MAX_RENDERINGGROUPS: number;
  17665. /**
  17666. * The min id used for rendering groups (included)
  17667. */
  17668. static MIN_RENDERINGGROUPS: number;
  17669. /**
  17670. * Used to globally prevent autoclearing scenes.
  17671. */
  17672. static AUTOCLEAR: boolean;
  17673. /**
  17674. * @hidden
  17675. */
  17676. _useSceneAutoClearSetup: boolean;
  17677. private _scene;
  17678. private _renderingGroups;
  17679. private _depthStencilBufferAlreadyCleaned;
  17680. private _autoClearDepthStencil;
  17681. private _customOpaqueSortCompareFn;
  17682. private _customAlphaTestSortCompareFn;
  17683. private _customTransparentSortCompareFn;
  17684. private _renderingGroupInfo;
  17685. /**
  17686. * Instantiates a new rendering group for a particular scene
  17687. * @param scene Defines the scene the groups belongs to
  17688. */
  17689. constructor(scene: Scene);
  17690. private _clearDepthStencilBuffer;
  17691. /**
  17692. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17693. * @hidden
  17694. */
  17695. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17696. /**
  17697. * Resets the different information of the group to prepare a new frame
  17698. * @hidden
  17699. */
  17700. reset(): void;
  17701. /**
  17702. * Dispose and release the group and its associated resources.
  17703. * @hidden
  17704. */
  17705. dispose(): void;
  17706. /**
  17707. * Clear the info related to rendering groups preventing retention points during dispose.
  17708. */
  17709. freeRenderingGroups(): void;
  17710. private _prepareRenderingGroup;
  17711. /**
  17712. * Add a sprite manager to the rendering manager in order to render it this frame.
  17713. * @param spriteManager Define the sprite manager to render
  17714. */
  17715. dispatchSprites(spriteManager: ISpriteManager): void;
  17716. /**
  17717. * Add a particle system to the rendering manager in order to render it this frame.
  17718. * @param particleSystem Define the particle system to render
  17719. */
  17720. dispatchParticles(particleSystem: IParticleSystem): void;
  17721. /**
  17722. * Add a submesh to the manager in order to render it this frame
  17723. * @param subMesh The submesh to dispatch
  17724. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17725. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17726. */
  17727. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17728. /**
  17729. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17730. * This allowed control for front to back rendering or reversly depending of the special needs.
  17731. *
  17732. * @param renderingGroupId The rendering group id corresponding to its index
  17733. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17734. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17735. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17736. */
  17737. 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;
  17738. /**
  17739. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17740. *
  17741. * @param renderingGroupId The rendering group id corresponding to its index
  17742. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17743. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17744. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17745. */
  17746. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17747. /**
  17748. * Gets the current auto clear configuration for one rendering group of the rendering
  17749. * manager.
  17750. * @param index the rendering group index to get the information for
  17751. * @returns The auto clear setup for the requested rendering group
  17752. */
  17753. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17754. }
  17755. }
  17756. declare module BABYLON {
  17757. /**
  17758. * This Helps creating a texture that will be created from a camera in your scene.
  17759. * It is basically a dynamic texture that could be used to create special effects for instance.
  17760. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17761. */
  17762. export class RenderTargetTexture extends Texture {
  17763. isCube: boolean;
  17764. /**
  17765. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17766. */
  17767. static readonly REFRESHRATE_RENDER_ONCE: number;
  17768. /**
  17769. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17770. */
  17771. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17772. /**
  17773. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17774. * the central point of your effect and can save a lot of performances.
  17775. */
  17776. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17777. /**
  17778. * Use this predicate to dynamically define the list of mesh you want to render.
  17779. * If set, the renderList property will be overwritten.
  17780. */
  17781. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17782. private _renderList;
  17783. /**
  17784. * Use this list to define the list of mesh you want to render.
  17785. */
  17786. renderList: Nullable<Array<AbstractMesh>>;
  17787. private _hookArray;
  17788. /**
  17789. * Define if particles should be rendered in your texture.
  17790. */
  17791. renderParticles: boolean;
  17792. /**
  17793. * Define if sprites should be rendered in your texture.
  17794. */
  17795. renderSprites: boolean;
  17796. /**
  17797. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17798. */
  17799. coordinatesMode: number;
  17800. /**
  17801. * Define the camera used to render the texture.
  17802. */
  17803. activeCamera: Nullable<Camera>;
  17804. /**
  17805. * Override the render function of the texture with your own one.
  17806. */
  17807. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17808. /**
  17809. * Define if camera post processes should be use while rendering the texture.
  17810. */
  17811. useCameraPostProcesses: boolean;
  17812. /**
  17813. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17814. */
  17815. ignoreCameraViewport: boolean;
  17816. private _postProcessManager;
  17817. private _postProcesses;
  17818. private _resizeObserver;
  17819. /**
  17820. * An event triggered when the texture is unbind.
  17821. */
  17822. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17823. /**
  17824. * An event triggered when the texture is unbind.
  17825. */
  17826. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17827. private _onAfterUnbindObserver;
  17828. /**
  17829. * Set a after unbind callback in the texture.
  17830. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17831. */
  17832. onAfterUnbind: () => void;
  17833. /**
  17834. * An event triggered before rendering the texture
  17835. */
  17836. onBeforeRenderObservable: Observable<number>;
  17837. private _onBeforeRenderObserver;
  17838. /**
  17839. * Set a before render callback in the texture.
  17840. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17841. */
  17842. onBeforeRender: (faceIndex: number) => void;
  17843. /**
  17844. * An event triggered after rendering the texture
  17845. */
  17846. onAfterRenderObservable: Observable<number>;
  17847. private _onAfterRenderObserver;
  17848. /**
  17849. * Set a after render callback in the texture.
  17850. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17851. */
  17852. onAfterRender: (faceIndex: number) => void;
  17853. /**
  17854. * An event triggered after the texture clear
  17855. */
  17856. onClearObservable: Observable<Engine>;
  17857. private _onClearObserver;
  17858. /**
  17859. * Set a clear callback in the texture.
  17860. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17861. */
  17862. onClear: (Engine: Engine) => void;
  17863. /**
  17864. * Define the clear color of the Render Target if it should be different from the scene.
  17865. */
  17866. clearColor: Color4;
  17867. protected _size: number | {
  17868. width: number;
  17869. height: number;
  17870. };
  17871. protected _initialSizeParameter: number | {
  17872. width: number;
  17873. height: number;
  17874. } | {
  17875. ratio: number;
  17876. };
  17877. protected _sizeRatio: Nullable<number>;
  17878. /** @hidden */
  17879. _generateMipMaps: boolean;
  17880. protected _renderingManager: RenderingManager;
  17881. /** @hidden */
  17882. _waitingRenderList: string[];
  17883. protected _doNotChangeAspectRatio: boolean;
  17884. protected _currentRefreshId: number;
  17885. protected _refreshRate: number;
  17886. protected _textureMatrix: Matrix;
  17887. protected _samples: number;
  17888. protected _renderTargetOptions: RenderTargetCreationOptions;
  17889. /**
  17890. * Gets render target creation options that were used.
  17891. */
  17892. readonly renderTargetOptions: RenderTargetCreationOptions;
  17893. protected _engine: Engine;
  17894. protected _onRatioRescale(): void;
  17895. /**
  17896. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17897. * It must define where the camera used to render the texture is set
  17898. */
  17899. boundingBoxPosition: Vector3;
  17900. private _boundingBoxSize;
  17901. /**
  17902. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17903. * When defined, the cubemap will switch to local mode
  17904. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17905. * @example https://www.babylonjs-playground.com/#RNASML
  17906. */
  17907. boundingBoxSize: Vector3;
  17908. /**
  17909. * In case the RTT has been created with a depth texture, get the associated
  17910. * depth texture.
  17911. * Otherwise, return null.
  17912. */
  17913. depthStencilTexture: Nullable<InternalTexture>;
  17914. /**
  17915. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17916. * or used a shadow, depth texture...
  17917. * @param name The friendly name of the texture
  17918. * @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)
  17919. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17920. * @param generateMipMaps True if mip maps need to be generated after render.
  17921. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17922. * @param type The type of the buffer in the RTT (int, half float, float...)
  17923. * @param isCube True if a cube texture needs to be created
  17924. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17925. * @param generateDepthBuffer True to generate a depth buffer
  17926. * @param generateStencilBuffer True to generate a stencil buffer
  17927. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17928. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17929. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17930. */
  17931. constructor(name: string, size: number | {
  17932. width: number;
  17933. height: number;
  17934. } | {
  17935. ratio: number;
  17936. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17937. /**
  17938. * Creates a depth stencil texture.
  17939. * This is only available in WebGL 2 or with the depth texture extension available.
  17940. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17941. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17942. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17943. */
  17944. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17945. private _processSizeParameter;
  17946. /**
  17947. * Define the number of samples to use in case of MSAA.
  17948. * It defaults to one meaning no MSAA has been enabled.
  17949. */
  17950. samples: number;
  17951. /**
  17952. * Resets the refresh counter of the texture and start bak from scratch.
  17953. * Could be useful to regenerate the texture if it is setup to render only once.
  17954. */
  17955. resetRefreshCounter(): void;
  17956. /**
  17957. * Define the refresh rate of the texture or the rendering frequency.
  17958. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17959. */
  17960. refreshRate: number;
  17961. /**
  17962. * Adds a post process to the render target rendering passes.
  17963. * @param postProcess define the post process to add
  17964. */
  17965. addPostProcess(postProcess: PostProcess): void;
  17966. /**
  17967. * Clear all the post processes attached to the render target
  17968. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17969. */
  17970. clearPostProcesses(dispose?: boolean): void;
  17971. /**
  17972. * Remove one of the post process from the list of attached post processes to the texture
  17973. * @param postProcess define the post process to remove from the list
  17974. */
  17975. removePostProcess(postProcess: PostProcess): void;
  17976. /** @hidden */
  17977. _shouldRender(): boolean;
  17978. /**
  17979. * Gets the actual render size of the texture.
  17980. * @returns the width of the render size
  17981. */
  17982. getRenderSize(): number;
  17983. /**
  17984. * Gets the actual render width of the texture.
  17985. * @returns the width of the render size
  17986. */
  17987. getRenderWidth(): number;
  17988. /**
  17989. * Gets the actual render height of the texture.
  17990. * @returns the height of the render size
  17991. */
  17992. getRenderHeight(): number;
  17993. /**
  17994. * Get if the texture can be rescaled or not.
  17995. */
  17996. readonly canRescale: boolean;
  17997. /**
  17998. * Resize the texture using a ratio.
  17999. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18000. */
  18001. scale(ratio: number): void;
  18002. /**
  18003. * Get the texture reflection matrix used to rotate/transform the reflection.
  18004. * @returns the reflection matrix
  18005. */
  18006. getReflectionTextureMatrix(): Matrix;
  18007. /**
  18008. * Resize the texture to a new desired size.
  18009. * Be carrefull as it will recreate all the data in the new texture.
  18010. * @param size Define the new size. It can be:
  18011. * - a number for squared texture,
  18012. * - an object containing { width: number, height: number }
  18013. * - or an object containing a ratio { ratio: number }
  18014. */
  18015. resize(size: number | {
  18016. width: number;
  18017. height: number;
  18018. } | {
  18019. ratio: number;
  18020. }): void;
  18021. /**
  18022. * Renders all the objects from the render list into the texture.
  18023. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18024. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18025. */
  18026. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18027. private _bestReflectionRenderTargetDimension;
  18028. /**
  18029. * @hidden
  18030. * @param faceIndex face index to bind to if this is a cubetexture
  18031. */
  18032. _bindFrameBuffer(faceIndex?: number): void;
  18033. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18034. private renderToTarget;
  18035. /**
  18036. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18037. * This allowed control for front to back rendering or reversly depending of the special needs.
  18038. *
  18039. * @param renderingGroupId The rendering group id corresponding to its index
  18040. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18041. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18042. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18043. */
  18044. 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;
  18045. /**
  18046. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18047. *
  18048. * @param renderingGroupId The rendering group id corresponding to its index
  18049. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18050. */
  18051. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18052. /**
  18053. * Clones the texture.
  18054. * @returns the cloned texture
  18055. */
  18056. clone(): RenderTargetTexture;
  18057. /**
  18058. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18059. * @returns The JSON representation of the texture
  18060. */
  18061. serialize(): any;
  18062. /**
  18063. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18064. */
  18065. disposeFramebufferObjects(): void;
  18066. /**
  18067. * Dispose the texture and release its associated resources.
  18068. */
  18069. dispose(): void;
  18070. /** @hidden */
  18071. _rebuild(): void;
  18072. /**
  18073. * Clear the info related to rendering groups preventing retention point in material dispose.
  18074. */
  18075. freeRenderingGroups(): void;
  18076. /**
  18077. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18078. * @returns the view count
  18079. */
  18080. getViewCount(): number;
  18081. }
  18082. }
  18083. declare module BABYLON {
  18084. /**
  18085. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18086. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18087. * You can then easily use it as a reflectionTexture on a flat surface.
  18088. * In case the surface is not a plane, please consider relying on reflection probes.
  18089. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18090. */
  18091. export class MirrorTexture extends RenderTargetTexture {
  18092. private scene;
  18093. /**
  18094. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18095. * 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.
  18096. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18097. */
  18098. mirrorPlane: Plane;
  18099. /**
  18100. * Define the blur ratio used to blur the reflection if needed.
  18101. */
  18102. blurRatio: number;
  18103. /**
  18104. * Define the adaptive blur kernel used to blur the reflection if needed.
  18105. * This will autocompute the closest best match for the `blurKernel`
  18106. */
  18107. adaptiveBlurKernel: number;
  18108. /**
  18109. * Define the blur kernel used to blur the reflection if needed.
  18110. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18111. */
  18112. blurKernel: number;
  18113. /**
  18114. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18115. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18116. */
  18117. blurKernelX: number;
  18118. /**
  18119. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18120. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18121. */
  18122. blurKernelY: number;
  18123. private _autoComputeBlurKernel;
  18124. protected _onRatioRescale(): void;
  18125. private _updateGammaSpace;
  18126. private _imageProcessingConfigChangeObserver;
  18127. private _transformMatrix;
  18128. private _mirrorMatrix;
  18129. private _savedViewMatrix;
  18130. private _blurX;
  18131. private _blurY;
  18132. private _adaptiveBlurKernel;
  18133. private _blurKernelX;
  18134. private _blurKernelY;
  18135. private _blurRatio;
  18136. /**
  18137. * Instantiates a Mirror Texture.
  18138. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18139. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18140. * You can then easily use it as a reflectionTexture on a flat surface.
  18141. * In case the surface is not a plane, please consider relying on reflection probes.
  18142. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18143. * @param name
  18144. * @param size
  18145. * @param scene
  18146. * @param generateMipMaps
  18147. * @param type
  18148. * @param samplingMode
  18149. * @param generateDepthBuffer
  18150. */
  18151. constructor(name: string, size: number | {
  18152. width: number;
  18153. height: number;
  18154. } | {
  18155. ratio: number;
  18156. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18157. private _preparePostProcesses;
  18158. /**
  18159. * Clone the mirror texture.
  18160. * @returns the cloned texture
  18161. */
  18162. clone(): MirrorTexture;
  18163. /**
  18164. * Serialize the texture to a JSON representation you could use in Parse later on
  18165. * @returns the serialized JSON representation
  18166. */
  18167. serialize(): any;
  18168. /**
  18169. * Dispose the texture and release its associated resources.
  18170. */
  18171. dispose(): void;
  18172. }
  18173. }
  18174. declare module BABYLON {
  18175. /**
  18176. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18177. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18178. */
  18179. export class Texture extends BaseTexture {
  18180. /** @hidden */
  18181. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18182. /** @hidden */
  18183. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18184. /** @hidden */
  18185. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18186. /** nearest is mag = nearest and min = nearest and mip = linear */
  18187. static readonly NEAREST_SAMPLINGMODE: number;
  18188. /** nearest is mag = nearest and min = nearest and mip = linear */
  18189. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18190. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18191. static readonly BILINEAR_SAMPLINGMODE: number;
  18192. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18193. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18194. /** Trilinear is mag = linear and min = linear and mip = linear */
  18195. static readonly TRILINEAR_SAMPLINGMODE: number;
  18196. /** Trilinear is mag = linear and min = linear and mip = linear */
  18197. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18198. /** mag = nearest and min = nearest and mip = nearest */
  18199. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18200. /** mag = nearest and min = linear and mip = nearest */
  18201. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18202. /** mag = nearest and min = linear and mip = linear */
  18203. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18204. /** mag = nearest and min = linear and mip = none */
  18205. static readonly NEAREST_LINEAR: number;
  18206. /** mag = nearest and min = nearest and mip = none */
  18207. static readonly NEAREST_NEAREST: number;
  18208. /** mag = linear and min = nearest and mip = nearest */
  18209. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18210. /** mag = linear and min = nearest and mip = linear */
  18211. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18212. /** mag = linear and min = linear and mip = none */
  18213. static readonly LINEAR_LINEAR: number;
  18214. /** mag = linear and min = nearest and mip = none */
  18215. static readonly LINEAR_NEAREST: number;
  18216. /** Explicit coordinates mode */
  18217. static readonly EXPLICIT_MODE: number;
  18218. /** Spherical coordinates mode */
  18219. static readonly SPHERICAL_MODE: number;
  18220. /** Planar coordinates mode */
  18221. static readonly PLANAR_MODE: number;
  18222. /** Cubic coordinates mode */
  18223. static readonly CUBIC_MODE: number;
  18224. /** Projection coordinates mode */
  18225. static readonly PROJECTION_MODE: number;
  18226. /** Inverse Cubic coordinates mode */
  18227. static readonly SKYBOX_MODE: number;
  18228. /** Inverse Cubic coordinates mode */
  18229. static readonly INVCUBIC_MODE: number;
  18230. /** Equirectangular coordinates mode */
  18231. static readonly EQUIRECTANGULAR_MODE: number;
  18232. /** Equirectangular Fixed coordinates mode */
  18233. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18234. /** Equirectangular Fixed Mirrored coordinates mode */
  18235. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18236. /** Texture is not repeating outside of 0..1 UVs */
  18237. static readonly CLAMP_ADDRESSMODE: number;
  18238. /** Texture is repeating outside of 0..1 UVs */
  18239. static readonly WRAP_ADDRESSMODE: number;
  18240. /** Texture is repeating and mirrored */
  18241. static readonly MIRROR_ADDRESSMODE: number;
  18242. /**
  18243. * 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
  18244. */
  18245. static UseSerializedUrlIfAny: boolean;
  18246. /**
  18247. * Define the url of the texture.
  18248. */
  18249. url: Nullable<string>;
  18250. /**
  18251. * Define an offset on the texture to offset the u coordinates of the UVs
  18252. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18253. */
  18254. uOffset: number;
  18255. /**
  18256. * Define an offset on the texture to offset the v coordinates of the UVs
  18257. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18258. */
  18259. vOffset: number;
  18260. /**
  18261. * Define an offset on the texture to scale the u coordinates of the UVs
  18262. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18263. */
  18264. uScale: number;
  18265. /**
  18266. * Define an offset on the texture to scale the v coordinates of the UVs
  18267. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18268. */
  18269. vScale: number;
  18270. /**
  18271. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18272. * @see http://doc.babylonjs.com/how_to/more_materials
  18273. */
  18274. uAng: number;
  18275. /**
  18276. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18277. * @see http://doc.babylonjs.com/how_to/more_materials
  18278. */
  18279. vAng: number;
  18280. /**
  18281. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18282. * @see http://doc.babylonjs.com/how_to/more_materials
  18283. */
  18284. wAng: number;
  18285. /**
  18286. * Defines the center of rotation (U)
  18287. */
  18288. uRotationCenter: number;
  18289. /**
  18290. * Defines the center of rotation (V)
  18291. */
  18292. vRotationCenter: number;
  18293. /**
  18294. * Defines the center of rotation (W)
  18295. */
  18296. wRotationCenter: number;
  18297. /**
  18298. * Are mip maps generated for this texture or not.
  18299. */
  18300. readonly noMipmap: boolean;
  18301. /**
  18302. * List of inspectable custom properties (used by the Inspector)
  18303. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18304. */
  18305. inspectableCustomProperties: Nullable<IInspectable[]>;
  18306. private _noMipmap;
  18307. /** @hidden */
  18308. _invertY: boolean;
  18309. private _rowGenerationMatrix;
  18310. private _cachedTextureMatrix;
  18311. private _projectionModeMatrix;
  18312. private _t0;
  18313. private _t1;
  18314. private _t2;
  18315. private _cachedUOffset;
  18316. private _cachedVOffset;
  18317. private _cachedUScale;
  18318. private _cachedVScale;
  18319. private _cachedUAng;
  18320. private _cachedVAng;
  18321. private _cachedWAng;
  18322. private _cachedProjectionMatrixId;
  18323. private _cachedCoordinatesMode;
  18324. /** @hidden */
  18325. protected _initialSamplingMode: number;
  18326. /** @hidden */
  18327. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18328. private _deleteBuffer;
  18329. protected _format: Nullable<number>;
  18330. private _delayedOnLoad;
  18331. private _delayedOnError;
  18332. /**
  18333. * Observable triggered once the texture has been loaded.
  18334. */
  18335. onLoadObservable: Observable<Texture>;
  18336. protected _isBlocking: boolean;
  18337. /**
  18338. * Is the texture preventing material to render while loading.
  18339. * If false, a default texture will be used instead of the loading one during the preparation step.
  18340. */
  18341. isBlocking: boolean;
  18342. /**
  18343. * Get the current sampling mode associated with the texture.
  18344. */
  18345. readonly samplingMode: number;
  18346. /**
  18347. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18348. */
  18349. readonly invertY: boolean;
  18350. /**
  18351. * Instantiates a new texture.
  18352. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18353. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18354. * @param url define the url of the picture to load as a texture
  18355. * @param scene define the scene the texture will belong to
  18356. * @param noMipmap define if the texture will require mip maps or not
  18357. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18358. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18359. * @param onLoad define a callback triggered when the texture has been loaded
  18360. * @param onError define a callback triggered when an error occurred during the loading session
  18361. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18362. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18363. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18364. */
  18365. 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);
  18366. /**
  18367. * Update the url (and optional buffer) of this texture if url was null during construction.
  18368. * @param url the url of the texture
  18369. * @param buffer the buffer of the texture (defaults to null)
  18370. * @param onLoad callback called when the texture is loaded (defaults to null)
  18371. */
  18372. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18373. /**
  18374. * Finish the loading sequence of a texture flagged as delayed load.
  18375. * @hidden
  18376. */
  18377. delayLoad(): void;
  18378. private _prepareRowForTextureGeneration;
  18379. /**
  18380. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18381. * @returns the transform matrix of the texture.
  18382. */
  18383. getTextureMatrix(): Matrix;
  18384. /**
  18385. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18386. * @returns The reflection texture transform
  18387. */
  18388. getReflectionTextureMatrix(): Matrix;
  18389. /**
  18390. * Clones the texture.
  18391. * @returns the cloned texture
  18392. */
  18393. clone(): Texture;
  18394. /**
  18395. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18396. * @returns The JSON representation of the texture
  18397. */
  18398. serialize(): any;
  18399. /**
  18400. * Get the current class name of the texture useful for serialization or dynamic coding.
  18401. * @returns "Texture"
  18402. */
  18403. getClassName(): string;
  18404. /**
  18405. * Dispose the texture and release its associated resources.
  18406. */
  18407. dispose(): void;
  18408. /**
  18409. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18410. * @param parsedTexture Define the JSON representation of the texture
  18411. * @param scene Define the scene the parsed texture should be instantiated in
  18412. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18413. * @returns The parsed texture if successful
  18414. */
  18415. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18416. /**
  18417. * Creates a texture from its base 64 representation.
  18418. * @param data Define the base64 payload without the data: prefix
  18419. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18420. * @param scene Define the scene the texture should belong to
  18421. * @param noMipmap Forces the texture to not create mip map information if true
  18422. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18423. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18424. * @param onLoad define a callback triggered when the texture has been loaded
  18425. * @param onError define a callback triggered when an error occurred during the loading session
  18426. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18427. * @returns the created texture
  18428. */
  18429. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18430. /**
  18431. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18432. * @param data Define the base64 payload without the data: prefix
  18433. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18434. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18435. * @param scene Define the scene the texture should belong to
  18436. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18437. * @param noMipmap Forces the texture to not create mip map information if true
  18438. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18439. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18440. * @param onLoad define a callback triggered when the texture has been loaded
  18441. * @param onError define a callback triggered when an error occurred during the loading session
  18442. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18443. * @returns the created texture
  18444. */
  18445. 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;
  18446. }
  18447. }
  18448. declare module BABYLON {
  18449. interface Engine {
  18450. /**
  18451. * Creates a raw texture
  18452. * @param data defines the data to store in the texture
  18453. * @param width defines the width of the texture
  18454. * @param height defines the height of the texture
  18455. * @param format defines the format of the data
  18456. * @param generateMipMaps defines if the engine should generate the mip levels
  18457. * @param invertY defines if data must be stored with Y axis inverted
  18458. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18459. * @param compression defines the compression used (null by default)
  18460. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18461. * @returns the raw texture inside an InternalTexture
  18462. */
  18463. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18464. /**
  18465. * Update a raw texture
  18466. * @param texture defines the texture to update
  18467. * @param data defines the data to store in the texture
  18468. * @param format defines the format of the data
  18469. * @param invertY defines if data must be stored with Y axis inverted
  18470. */
  18471. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18472. /**
  18473. * Update a raw texture
  18474. * @param texture defines the texture to update
  18475. * @param data defines the data to store in the texture
  18476. * @param format defines the format of the data
  18477. * @param invertY defines if data must be stored with Y axis inverted
  18478. * @param compression defines the compression used (null by default)
  18479. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18480. */
  18481. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18482. /**
  18483. * Creates a new raw cube texture
  18484. * @param data defines the array of data to use to create each face
  18485. * @param size defines the size of the textures
  18486. * @param format defines the format of the data
  18487. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18488. * @param generateMipMaps defines if the engine should generate the mip levels
  18489. * @param invertY defines if data must be stored with Y axis inverted
  18490. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18491. * @param compression defines the compression used (null by default)
  18492. * @returns the cube texture as an InternalTexture
  18493. */
  18494. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18495. /**
  18496. * Update a raw cube texture
  18497. * @param texture defines the texture to udpdate
  18498. * @param data defines the data to store
  18499. * @param format defines the data format
  18500. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18501. * @param invertY defines if data must be stored with Y axis inverted
  18502. */
  18503. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18504. /**
  18505. * Update a raw cube texture
  18506. * @param texture defines the texture to udpdate
  18507. * @param data defines the data to store
  18508. * @param format defines the data format
  18509. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18510. * @param invertY defines if data must be stored with Y axis inverted
  18511. * @param compression defines the compression used (null by default)
  18512. */
  18513. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18514. /**
  18515. * Update a raw cube texture
  18516. * @param texture defines the texture to udpdate
  18517. * @param data defines the data to store
  18518. * @param format defines the data format
  18519. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18520. * @param invertY defines if data must be stored with Y axis inverted
  18521. * @param compression defines the compression used (null by default)
  18522. * @param level defines which level of the texture to update
  18523. */
  18524. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18525. /**
  18526. * Creates a new raw cube texture from a specified url
  18527. * @param url defines the url where the data is located
  18528. * @param scene defines the current scene
  18529. * @param size defines the size of the textures
  18530. * @param format defines the format of the data
  18531. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18532. * @param noMipmap defines if the engine should avoid generating the mip levels
  18533. * @param callback defines a callback used to extract texture data from loaded data
  18534. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18535. * @param onLoad defines a callback called when texture is loaded
  18536. * @param onError defines a callback called if there is an error
  18537. * @returns the cube texture as an InternalTexture
  18538. */
  18539. 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;
  18540. /**
  18541. * Creates a new raw cube texture from a specified url
  18542. * @param url defines the url where the data is located
  18543. * @param scene defines the current scene
  18544. * @param size defines the size of the textures
  18545. * @param format defines the format of the data
  18546. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18547. * @param noMipmap defines if the engine should avoid generating the mip levels
  18548. * @param callback defines a callback used to extract texture data from loaded data
  18549. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18550. * @param onLoad defines a callback called when texture is loaded
  18551. * @param onError defines a callback called if there is an error
  18552. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18553. * @param invertY defines if data must be stored with Y axis inverted
  18554. * @returns the cube texture as an InternalTexture
  18555. */
  18556. 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;
  18557. /**
  18558. * Creates a new raw 3D texture
  18559. * @param data defines the data used to create the texture
  18560. * @param width defines the width of the texture
  18561. * @param height defines the height of the texture
  18562. * @param depth defines the depth of the texture
  18563. * @param format defines the format of the texture
  18564. * @param generateMipMaps defines if the engine must generate mip levels
  18565. * @param invertY defines if data must be stored with Y axis inverted
  18566. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18567. * @param compression defines the compressed used (can be null)
  18568. * @param textureType defines the compressed used (can be null)
  18569. * @returns a new raw 3D texture (stored in an InternalTexture)
  18570. */
  18571. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18572. /**
  18573. * Update a raw 3D texture
  18574. * @param texture defines the texture to update
  18575. * @param data defines the data to store
  18576. * @param format defines the data format
  18577. * @param invertY defines if data must be stored with Y axis inverted
  18578. */
  18579. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18580. /**
  18581. * Update a raw 3D texture
  18582. * @param texture defines the texture to update
  18583. * @param data defines the data to store
  18584. * @param format defines the data format
  18585. * @param invertY defines if data must be stored with Y axis inverted
  18586. * @param compression defines the used compression (can be null)
  18587. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18588. */
  18589. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18590. }
  18591. }
  18592. declare module BABYLON {
  18593. /**
  18594. * Raw texture can help creating a texture directly from an array of data.
  18595. * This can be super useful if you either get the data from an uncompressed source or
  18596. * if you wish to create your texture pixel by pixel.
  18597. */
  18598. export class RawTexture extends Texture {
  18599. /**
  18600. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18601. */
  18602. format: number;
  18603. private _engine;
  18604. /**
  18605. * Instantiates a new RawTexture.
  18606. * Raw texture can help creating a texture directly from an array of data.
  18607. * This can be super useful if you either get the data from an uncompressed source or
  18608. * if you wish to create your texture pixel by pixel.
  18609. * @param data define the array of data to use to create the texture
  18610. * @param width define the width of the texture
  18611. * @param height define the height of the texture
  18612. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18613. * @param scene define the scene the texture belongs to
  18614. * @param generateMipMaps define whether mip maps should be generated or not
  18615. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18616. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18617. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18618. */
  18619. constructor(data: ArrayBufferView, width: number, height: number,
  18620. /**
  18621. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18622. */
  18623. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18624. /**
  18625. * Updates the texture underlying data.
  18626. * @param data Define the new data of the texture
  18627. */
  18628. update(data: ArrayBufferView): void;
  18629. /**
  18630. * Creates a luminance texture from some data.
  18631. * @param data Define the texture data
  18632. * @param width Define the width of the texture
  18633. * @param height Define the height of the texture
  18634. * @param scene Define the scene the texture belongs to
  18635. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18636. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18637. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18638. * @returns the luminance texture
  18639. */
  18640. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18641. /**
  18642. * Creates a luminance alpha texture from some data.
  18643. * @param data Define the texture data
  18644. * @param width Define the width of the texture
  18645. * @param height Define the height of the texture
  18646. * @param scene Define the scene the texture belongs to
  18647. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18648. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18649. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18650. * @returns the luminance alpha texture
  18651. */
  18652. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18653. /**
  18654. * Creates an alpha texture from some data.
  18655. * @param data Define the texture data
  18656. * @param width Define the width of the texture
  18657. * @param height Define the height of the texture
  18658. * @param scene Define the scene the texture belongs to
  18659. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18660. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18661. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18662. * @returns the alpha texture
  18663. */
  18664. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18665. /**
  18666. * Creates a RGB texture from some data.
  18667. * @param data Define the texture data
  18668. * @param width Define the width of the texture
  18669. * @param height Define the height of the texture
  18670. * @param scene Define the scene the texture belongs to
  18671. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18672. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18673. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18674. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18675. * @returns the RGB alpha texture
  18676. */
  18677. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18678. /**
  18679. * Creates a RGBA texture from some data.
  18680. * @param data Define the texture data
  18681. * @param width Define the width of the texture
  18682. * @param height Define the height of the texture
  18683. * @param scene Define the scene the texture belongs to
  18684. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18685. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18686. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18687. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18688. * @returns the RGBA texture
  18689. */
  18690. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18691. /**
  18692. * Creates a R texture from some data.
  18693. * @param data Define the texture data
  18694. * @param width Define the width of the texture
  18695. * @param height Define the height of the texture
  18696. * @param scene Define the scene the texture belongs to
  18697. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18698. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18699. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18700. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18701. * @returns the R texture
  18702. */
  18703. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18704. }
  18705. }
  18706. declare module BABYLON {
  18707. /**
  18708. * Defines a runtime animation
  18709. */
  18710. export class RuntimeAnimation {
  18711. private _events;
  18712. /**
  18713. * The current frame of the runtime animation
  18714. */
  18715. private _currentFrame;
  18716. /**
  18717. * The animation used by the runtime animation
  18718. */
  18719. private _animation;
  18720. /**
  18721. * The target of the runtime animation
  18722. */
  18723. private _target;
  18724. /**
  18725. * The initiating animatable
  18726. */
  18727. private _host;
  18728. /**
  18729. * The original value of the runtime animation
  18730. */
  18731. private _originalValue;
  18732. /**
  18733. * The original blend value of the runtime animation
  18734. */
  18735. private _originalBlendValue;
  18736. /**
  18737. * The offsets cache of the runtime animation
  18738. */
  18739. private _offsetsCache;
  18740. /**
  18741. * The high limits cache of the runtime animation
  18742. */
  18743. private _highLimitsCache;
  18744. /**
  18745. * Specifies if the runtime animation has been stopped
  18746. */
  18747. private _stopped;
  18748. /**
  18749. * The blending factor of the runtime animation
  18750. */
  18751. private _blendingFactor;
  18752. /**
  18753. * The BabylonJS scene
  18754. */
  18755. private _scene;
  18756. /**
  18757. * The current value of the runtime animation
  18758. */
  18759. private _currentValue;
  18760. /** @hidden */
  18761. _animationState: _IAnimationState;
  18762. /**
  18763. * The active target of the runtime animation
  18764. */
  18765. private _activeTargets;
  18766. private _currentActiveTarget;
  18767. private _directTarget;
  18768. /**
  18769. * The target path of the runtime animation
  18770. */
  18771. private _targetPath;
  18772. /**
  18773. * The weight of the runtime animation
  18774. */
  18775. private _weight;
  18776. /**
  18777. * The ratio offset of the runtime animation
  18778. */
  18779. private _ratioOffset;
  18780. /**
  18781. * The previous delay of the runtime animation
  18782. */
  18783. private _previousDelay;
  18784. /**
  18785. * The previous ratio of the runtime animation
  18786. */
  18787. private _previousRatio;
  18788. private _enableBlending;
  18789. private _keys;
  18790. private _minFrame;
  18791. private _maxFrame;
  18792. private _minValue;
  18793. private _maxValue;
  18794. private _targetIsArray;
  18795. /**
  18796. * Gets the current frame of the runtime animation
  18797. */
  18798. readonly currentFrame: number;
  18799. /**
  18800. * Gets the weight of the runtime animation
  18801. */
  18802. readonly weight: number;
  18803. /**
  18804. * Gets the current value of the runtime animation
  18805. */
  18806. readonly currentValue: any;
  18807. /**
  18808. * Gets the target path of the runtime animation
  18809. */
  18810. readonly targetPath: string;
  18811. /**
  18812. * Gets the actual target of the runtime animation
  18813. */
  18814. readonly target: any;
  18815. /** @hidden */
  18816. _onLoop: () => void;
  18817. /**
  18818. * Create a new RuntimeAnimation object
  18819. * @param target defines the target of the animation
  18820. * @param animation defines the source animation object
  18821. * @param scene defines the hosting scene
  18822. * @param host defines the initiating Animatable
  18823. */
  18824. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18825. private _preparePath;
  18826. /**
  18827. * Gets the animation from the runtime animation
  18828. */
  18829. readonly animation: Animation;
  18830. /**
  18831. * Resets the runtime animation to the beginning
  18832. * @param restoreOriginal defines whether to restore the target property to the original value
  18833. */
  18834. reset(restoreOriginal?: boolean): void;
  18835. /**
  18836. * Specifies if the runtime animation is stopped
  18837. * @returns Boolean specifying if the runtime animation is stopped
  18838. */
  18839. isStopped(): boolean;
  18840. /**
  18841. * Disposes of the runtime animation
  18842. */
  18843. dispose(): void;
  18844. /**
  18845. * Apply the interpolated value to the target
  18846. * @param currentValue defines the value computed by the animation
  18847. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18848. */
  18849. setValue(currentValue: any, weight: number): void;
  18850. private _getOriginalValues;
  18851. private _setValue;
  18852. /**
  18853. * Gets the loop pmode of the runtime animation
  18854. * @returns Loop Mode
  18855. */
  18856. private _getCorrectLoopMode;
  18857. /**
  18858. * Move the current animation to a given frame
  18859. * @param frame defines the frame to move to
  18860. */
  18861. goToFrame(frame: number): void;
  18862. /**
  18863. * @hidden Internal use only
  18864. */
  18865. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18866. /**
  18867. * Execute the current animation
  18868. * @param delay defines the delay to add to the current frame
  18869. * @param from defines the lower bound of the animation range
  18870. * @param to defines the upper bound of the animation range
  18871. * @param loop defines if the current animation must loop
  18872. * @param speedRatio defines the current speed ratio
  18873. * @param weight defines the weight of the animation (default is -1 so no weight)
  18874. * @param onLoop optional callback called when animation loops
  18875. * @returns a boolean indicating if the animation is running
  18876. */
  18877. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18878. }
  18879. }
  18880. declare module BABYLON {
  18881. /**
  18882. * Class used to store an actual running animation
  18883. */
  18884. export class Animatable {
  18885. /** defines the target object */
  18886. target: any;
  18887. /** defines the starting frame number (default is 0) */
  18888. fromFrame: number;
  18889. /** defines the ending frame number (default is 100) */
  18890. toFrame: number;
  18891. /** defines if the animation must loop (default is false) */
  18892. loopAnimation: boolean;
  18893. /** defines a callback to call when animation ends if it is not looping */
  18894. onAnimationEnd?: (() => void) | null | undefined;
  18895. /** defines a callback to call when animation loops */
  18896. onAnimationLoop?: (() => void) | null | undefined;
  18897. private _localDelayOffset;
  18898. private _pausedDelay;
  18899. private _runtimeAnimations;
  18900. private _paused;
  18901. private _scene;
  18902. private _speedRatio;
  18903. private _weight;
  18904. private _syncRoot;
  18905. /**
  18906. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18907. * This will only apply for non looping animation (default is true)
  18908. */
  18909. disposeOnEnd: boolean;
  18910. /**
  18911. * Gets a boolean indicating if the animation has started
  18912. */
  18913. animationStarted: boolean;
  18914. /**
  18915. * Observer raised when the animation ends
  18916. */
  18917. onAnimationEndObservable: Observable<Animatable>;
  18918. /**
  18919. * Observer raised when the animation loops
  18920. */
  18921. onAnimationLoopObservable: Observable<Animatable>;
  18922. /**
  18923. * Gets the root Animatable used to synchronize and normalize animations
  18924. */
  18925. readonly syncRoot: Nullable<Animatable>;
  18926. /**
  18927. * Gets the current frame of the first RuntimeAnimation
  18928. * Used to synchronize Animatables
  18929. */
  18930. readonly masterFrame: number;
  18931. /**
  18932. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18933. */
  18934. weight: number;
  18935. /**
  18936. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18937. */
  18938. speedRatio: number;
  18939. /**
  18940. * Creates a new Animatable
  18941. * @param scene defines the hosting scene
  18942. * @param target defines the target object
  18943. * @param fromFrame defines the starting frame number (default is 0)
  18944. * @param toFrame defines the ending frame number (default is 100)
  18945. * @param loopAnimation defines if the animation must loop (default is false)
  18946. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18947. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18948. * @param animations defines a group of animation to add to the new Animatable
  18949. * @param onAnimationLoop defines a callback to call when animation loops
  18950. */
  18951. constructor(scene: Scene,
  18952. /** defines the target object */
  18953. target: any,
  18954. /** defines the starting frame number (default is 0) */
  18955. fromFrame?: number,
  18956. /** defines the ending frame number (default is 100) */
  18957. toFrame?: number,
  18958. /** defines if the animation must loop (default is false) */
  18959. loopAnimation?: boolean, speedRatio?: number,
  18960. /** defines a callback to call when animation ends if it is not looping */
  18961. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18962. /** defines a callback to call when animation loops */
  18963. onAnimationLoop?: (() => void) | null | undefined);
  18964. /**
  18965. * Synchronize and normalize current Animatable with a source Animatable
  18966. * This is useful when using animation weights and when animations are not of the same length
  18967. * @param root defines the root Animatable to synchronize with
  18968. * @returns the current Animatable
  18969. */
  18970. syncWith(root: Animatable): Animatable;
  18971. /**
  18972. * Gets the list of runtime animations
  18973. * @returns an array of RuntimeAnimation
  18974. */
  18975. getAnimations(): RuntimeAnimation[];
  18976. /**
  18977. * Adds more animations to the current animatable
  18978. * @param target defines the target of the animations
  18979. * @param animations defines the new animations to add
  18980. */
  18981. appendAnimations(target: any, animations: Animation[]): void;
  18982. /**
  18983. * Gets the source animation for a specific property
  18984. * @param property defines the propertyu to look for
  18985. * @returns null or the source animation for the given property
  18986. */
  18987. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18988. /**
  18989. * Gets the runtime animation for a specific property
  18990. * @param property defines the propertyu to look for
  18991. * @returns null or the runtime animation for the given property
  18992. */
  18993. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18994. /**
  18995. * Resets the animatable to its original state
  18996. */
  18997. reset(): void;
  18998. /**
  18999. * Allows the animatable to blend with current running animations
  19000. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19001. * @param blendingSpeed defines the blending speed to use
  19002. */
  19003. enableBlending(blendingSpeed: number): void;
  19004. /**
  19005. * Disable animation blending
  19006. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19007. */
  19008. disableBlending(): void;
  19009. /**
  19010. * Jump directly to a given frame
  19011. * @param frame defines the frame to jump to
  19012. */
  19013. goToFrame(frame: number): void;
  19014. /**
  19015. * Pause the animation
  19016. */
  19017. pause(): void;
  19018. /**
  19019. * Restart the animation
  19020. */
  19021. restart(): void;
  19022. private _raiseOnAnimationEnd;
  19023. /**
  19024. * Stop and delete the current animation
  19025. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19026. * @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)
  19027. */
  19028. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19029. /**
  19030. * Wait asynchronously for the animation to end
  19031. * @returns a promise which will be fullfilled when the animation ends
  19032. */
  19033. waitAsync(): Promise<Animatable>;
  19034. /** @hidden */
  19035. _animate(delay: number): boolean;
  19036. }
  19037. interface Scene {
  19038. /** @hidden */
  19039. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19040. /** @hidden */
  19041. _processLateAnimationBindingsForMatrices(holder: {
  19042. totalWeight: number;
  19043. animations: RuntimeAnimation[];
  19044. originalValue: Matrix;
  19045. }): any;
  19046. /** @hidden */
  19047. _processLateAnimationBindingsForQuaternions(holder: {
  19048. totalWeight: number;
  19049. animations: RuntimeAnimation[];
  19050. originalValue: Quaternion;
  19051. }, refQuaternion: Quaternion): Quaternion;
  19052. /** @hidden */
  19053. _processLateAnimationBindings(): void;
  19054. /**
  19055. * Will start the animation sequence of a given target
  19056. * @param target defines the target
  19057. * @param from defines from which frame should animation start
  19058. * @param to defines until which frame should animation run.
  19059. * @param weight defines the weight to apply to the animation (1.0 by default)
  19060. * @param loop defines if the animation loops
  19061. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19062. * @param onAnimationEnd defines the function to be executed when the animation ends
  19063. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19064. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19065. * @param onAnimationLoop defines the callback to call when an animation loops
  19066. * @returns the animatable object created for this animation
  19067. */
  19068. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19069. /**
  19070. * Will start the animation sequence of a given target
  19071. * @param target defines the target
  19072. * @param from defines from which frame should animation start
  19073. * @param to defines until which frame should animation run.
  19074. * @param loop defines if the animation loops
  19075. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19076. * @param onAnimationEnd defines the function to be executed when the animation ends
  19077. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19078. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19079. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19080. * @param onAnimationLoop defines the callback to call when an animation loops
  19081. * @returns the animatable object created for this animation
  19082. */
  19083. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19084. /**
  19085. * Will start the animation sequence of a given target and its hierarchy
  19086. * @param target defines the target
  19087. * @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.
  19088. * @param from defines from which frame should animation start
  19089. * @param to defines until which frame should animation run.
  19090. * @param loop defines if the animation loops
  19091. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19092. * @param onAnimationEnd defines the function to be executed when the animation ends
  19093. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19094. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19095. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19096. * @param onAnimationLoop defines the callback to call when an animation loops
  19097. * @returns the list of created animatables
  19098. */
  19099. 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[];
  19100. /**
  19101. * Begin a new animation on a given node
  19102. * @param target defines the target where the animation will take place
  19103. * @param animations defines the list of animations to start
  19104. * @param from defines the initial value
  19105. * @param to defines the final value
  19106. * @param loop defines if you want animation to loop (off by default)
  19107. * @param speedRatio defines the speed ratio to apply to all animations
  19108. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19109. * @param onAnimationLoop defines the callback to call when an animation loops
  19110. * @returns the list of created animatables
  19111. */
  19112. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19113. /**
  19114. * Begin a new animation on a given node and its hierarchy
  19115. * @param target defines the root node where the animation will take place
  19116. * @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.
  19117. * @param animations defines the list of animations to start
  19118. * @param from defines the initial value
  19119. * @param to defines the final value
  19120. * @param loop defines if you want animation to loop (off by default)
  19121. * @param speedRatio defines the speed ratio to apply to all animations
  19122. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19123. * @param onAnimationLoop defines the callback to call when an animation loops
  19124. * @returns the list of animatables created for all nodes
  19125. */
  19126. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19127. /**
  19128. * Gets the animatable associated with a specific target
  19129. * @param target defines the target of the animatable
  19130. * @returns the required animatable if found
  19131. */
  19132. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19133. /**
  19134. * Gets all animatables associated with a given target
  19135. * @param target defines the target to look animatables for
  19136. * @returns an array of Animatables
  19137. */
  19138. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19139. /**
  19140. * Stops and removes all animations that have been applied to the scene
  19141. */
  19142. stopAllAnimations(): void;
  19143. }
  19144. interface Bone {
  19145. /**
  19146. * Copy an animation range from another bone
  19147. * @param source defines the source bone
  19148. * @param rangeName defines the range name to copy
  19149. * @param frameOffset defines the frame offset
  19150. * @param rescaleAsRequired defines if rescaling must be applied if required
  19151. * @param skelDimensionsRatio defines the scaling ratio
  19152. * @returns true if operation was successful
  19153. */
  19154. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19155. }
  19156. }
  19157. declare module BABYLON {
  19158. /**
  19159. * Class used to handle skinning animations
  19160. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19161. */
  19162. export class Skeleton implements IAnimatable {
  19163. /** defines the skeleton name */
  19164. name: string;
  19165. /** defines the skeleton Id */
  19166. id: string;
  19167. /**
  19168. * Defines the list of child bones
  19169. */
  19170. bones: Bone[];
  19171. /**
  19172. * Defines an estimate of the dimension of the skeleton at rest
  19173. */
  19174. dimensionsAtRest: Vector3;
  19175. /**
  19176. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19177. */
  19178. needInitialSkinMatrix: boolean;
  19179. /**
  19180. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19181. */
  19182. overrideMesh: Nullable<AbstractMesh>;
  19183. /**
  19184. * Gets the list of animations attached to this skeleton
  19185. */
  19186. animations: Array<Animation>;
  19187. private _scene;
  19188. private _isDirty;
  19189. private _transformMatrices;
  19190. private _transformMatrixTexture;
  19191. private _meshesWithPoseMatrix;
  19192. private _animatables;
  19193. private _identity;
  19194. private _synchronizedWithMesh;
  19195. private _ranges;
  19196. private _lastAbsoluteTransformsUpdateId;
  19197. private _canUseTextureForBones;
  19198. private _uniqueId;
  19199. /** @hidden */
  19200. _numBonesWithLinkedTransformNode: number;
  19201. /** @hidden */
  19202. _hasWaitingData: Nullable<boolean>;
  19203. /**
  19204. * Specifies if the skeleton should be serialized
  19205. */
  19206. doNotSerialize: boolean;
  19207. private _useTextureToStoreBoneMatrices;
  19208. /**
  19209. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19210. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19211. */
  19212. useTextureToStoreBoneMatrices: boolean;
  19213. private _animationPropertiesOverride;
  19214. /**
  19215. * Gets or sets the animation properties override
  19216. */
  19217. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19218. /**
  19219. * List of inspectable custom properties (used by the Inspector)
  19220. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19221. */
  19222. inspectableCustomProperties: IInspectable[];
  19223. /**
  19224. * An observable triggered before computing the skeleton's matrices
  19225. */
  19226. onBeforeComputeObservable: Observable<Skeleton>;
  19227. /**
  19228. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19229. */
  19230. readonly isUsingTextureForMatrices: boolean;
  19231. /**
  19232. * Gets the unique ID of this skeleton
  19233. */
  19234. readonly uniqueId: number;
  19235. /**
  19236. * Creates a new skeleton
  19237. * @param name defines the skeleton name
  19238. * @param id defines the skeleton Id
  19239. * @param scene defines the hosting scene
  19240. */
  19241. constructor(
  19242. /** defines the skeleton name */
  19243. name: string,
  19244. /** defines the skeleton Id */
  19245. id: string, scene: Scene);
  19246. /**
  19247. * Gets the current object class name.
  19248. * @return the class name
  19249. */
  19250. getClassName(): string;
  19251. /**
  19252. * Returns an array containing the root bones
  19253. * @returns an array containing the root bones
  19254. */
  19255. getChildren(): Array<Bone>;
  19256. /**
  19257. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19258. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19259. * @returns a Float32Array containing matrices data
  19260. */
  19261. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19262. /**
  19263. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19264. * @returns a raw texture containing the data
  19265. */
  19266. getTransformMatrixTexture(): Nullable<RawTexture>;
  19267. /**
  19268. * Gets the current hosting scene
  19269. * @returns a scene object
  19270. */
  19271. getScene(): Scene;
  19272. /**
  19273. * Gets a string representing the current skeleton data
  19274. * @param fullDetails defines a boolean indicating if we want a verbose version
  19275. * @returns a string representing the current skeleton data
  19276. */
  19277. toString(fullDetails?: boolean): string;
  19278. /**
  19279. * Get bone's index searching by name
  19280. * @param name defines bone's name to search for
  19281. * @return the indice of the bone. Returns -1 if not found
  19282. */
  19283. getBoneIndexByName(name: string): number;
  19284. /**
  19285. * Creater a new animation range
  19286. * @param name defines the name of the range
  19287. * @param from defines the start key
  19288. * @param to defines the end key
  19289. */
  19290. createAnimationRange(name: string, from: number, to: number): void;
  19291. /**
  19292. * Delete a specific animation range
  19293. * @param name defines the name of the range
  19294. * @param deleteFrames defines if frames must be removed as well
  19295. */
  19296. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19297. /**
  19298. * Gets a specific animation range
  19299. * @param name defines the name of the range to look for
  19300. * @returns the requested animation range or null if not found
  19301. */
  19302. getAnimationRange(name: string): Nullable<AnimationRange>;
  19303. /**
  19304. * Gets the list of all animation ranges defined on this skeleton
  19305. * @returns an array
  19306. */
  19307. getAnimationRanges(): Nullable<AnimationRange>[];
  19308. /**
  19309. * Copy animation range from a source skeleton.
  19310. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19311. * @param source defines the source skeleton
  19312. * @param name defines the name of the range to copy
  19313. * @param rescaleAsRequired defines if rescaling must be applied if required
  19314. * @returns true if operation was successful
  19315. */
  19316. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19317. /**
  19318. * Forces the skeleton to go to rest pose
  19319. */
  19320. returnToRest(): void;
  19321. private _getHighestAnimationFrame;
  19322. /**
  19323. * Begin a specific animation range
  19324. * @param name defines the name of the range to start
  19325. * @param loop defines if looping must be turned on (false by default)
  19326. * @param speedRatio defines the speed ratio to apply (1 by default)
  19327. * @param onAnimationEnd defines a callback which will be called when animation will end
  19328. * @returns a new animatable
  19329. */
  19330. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19331. /** @hidden */
  19332. _markAsDirty(): void;
  19333. /** @hidden */
  19334. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19335. /** @hidden */
  19336. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19337. private _computeTransformMatrices;
  19338. /**
  19339. * Build all resources required to render a skeleton
  19340. */
  19341. prepare(): void;
  19342. /**
  19343. * Gets the list of animatables currently running for this skeleton
  19344. * @returns an array of animatables
  19345. */
  19346. getAnimatables(): IAnimatable[];
  19347. /**
  19348. * Clone the current skeleton
  19349. * @param name defines the name of the new skeleton
  19350. * @param id defines the id of the new skeleton
  19351. * @returns the new skeleton
  19352. */
  19353. clone(name: string, id: string): Skeleton;
  19354. /**
  19355. * Enable animation blending for this skeleton
  19356. * @param blendingSpeed defines the blending speed to apply
  19357. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19358. */
  19359. enableBlending(blendingSpeed?: number): void;
  19360. /**
  19361. * Releases all resources associated with the current skeleton
  19362. */
  19363. dispose(): void;
  19364. /**
  19365. * Serialize the skeleton in a JSON object
  19366. * @returns a JSON object
  19367. */
  19368. serialize(): any;
  19369. /**
  19370. * Creates a new skeleton from serialized data
  19371. * @param parsedSkeleton defines the serialized data
  19372. * @param scene defines the hosting scene
  19373. * @returns a new skeleton
  19374. */
  19375. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19376. /**
  19377. * Compute all node absolute transforms
  19378. * @param forceUpdate defines if computation must be done even if cache is up to date
  19379. */
  19380. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19381. /**
  19382. * Gets the root pose matrix
  19383. * @returns a matrix
  19384. */
  19385. getPoseMatrix(): Nullable<Matrix>;
  19386. /**
  19387. * Sorts bones per internal index
  19388. */
  19389. sortBones(): void;
  19390. private _sortBones;
  19391. }
  19392. }
  19393. declare module BABYLON {
  19394. /**
  19395. * Defines a target to use with MorphTargetManager
  19396. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19397. */
  19398. export class MorphTarget implements IAnimatable {
  19399. /** defines the name of the target */
  19400. name: string;
  19401. /**
  19402. * Gets or sets the list of animations
  19403. */
  19404. animations: Animation[];
  19405. private _scene;
  19406. private _positions;
  19407. private _normals;
  19408. private _tangents;
  19409. private _influence;
  19410. /**
  19411. * Observable raised when the influence changes
  19412. */
  19413. onInfluenceChanged: Observable<boolean>;
  19414. /** @hidden */
  19415. _onDataLayoutChanged: Observable<void>;
  19416. /**
  19417. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19418. */
  19419. influence: number;
  19420. /**
  19421. * Gets or sets the id of the morph Target
  19422. */
  19423. id: string;
  19424. private _animationPropertiesOverride;
  19425. /**
  19426. * Gets or sets the animation properties override
  19427. */
  19428. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19429. /**
  19430. * Creates a new MorphTarget
  19431. * @param name defines the name of the target
  19432. * @param influence defines the influence to use
  19433. * @param scene defines the scene the morphtarget belongs to
  19434. */
  19435. constructor(
  19436. /** defines the name of the target */
  19437. name: string, influence?: number, scene?: Nullable<Scene>);
  19438. /**
  19439. * Gets a boolean defining if the target contains position data
  19440. */
  19441. readonly hasPositions: boolean;
  19442. /**
  19443. * Gets a boolean defining if the target contains normal data
  19444. */
  19445. readonly hasNormals: boolean;
  19446. /**
  19447. * Gets a boolean defining if the target contains tangent data
  19448. */
  19449. readonly hasTangents: boolean;
  19450. /**
  19451. * Affects position data to this target
  19452. * @param data defines the position data to use
  19453. */
  19454. setPositions(data: Nullable<FloatArray>): void;
  19455. /**
  19456. * Gets the position data stored in this target
  19457. * @returns a FloatArray containing the position data (or null if not present)
  19458. */
  19459. getPositions(): Nullable<FloatArray>;
  19460. /**
  19461. * Affects normal data to this target
  19462. * @param data defines the normal data to use
  19463. */
  19464. setNormals(data: Nullable<FloatArray>): void;
  19465. /**
  19466. * Gets the normal data stored in this target
  19467. * @returns a FloatArray containing the normal data (or null if not present)
  19468. */
  19469. getNormals(): Nullable<FloatArray>;
  19470. /**
  19471. * Affects tangent data to this target
  19472. * @param data defines the tangent data to use
  19473. */
  19474. setTangents(data: Nullable<FloatArray>): void;
  19475. /**
  19476. * Gets the tangent data stored in this target
  19477. * @returns a FloatArray containing the tangent data (or null if not present)
  19478. */
  19479. getTangents(): Nullable<FloatArray>;
  19480. /**
  19481. * Serializes the current target into a Serialization object
  19482. * @returns the serialized object
  19483. */
  19484. serialize(): any;
  19485. /**
  19486. * Returns the string "MorphTarget"
  19487. * @returns "MorphTarget"
  19488. */
  19489. getClassName(): string;
  19490. /**
  19491. * Creates a new target from serialized data
  19492. * @param serializationObject defines the serialized data to use
  19493. * @returns a new MorphTarget
  19494. */
  19495. static Parse(serializationObject: any): MorphTarget;
  19496. /**
  19497. * Creates a MorphTarget from mesh data
  19498. * @param mesh defines the source mesh
  19499. * @param name defines the name to use for the new target
  19500. * @param influence defines the influence to attach to the target
  19501. * @returns a new MorphTarget
  19502. */
  19503. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19504. }
  19505. }
  19506. declare module BABYLON {
  19507. /**
  19508. * This class is used to deform meshes using morphing between different targets
  19509. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19510. */
  19511. export class MorphTargetManager {
  19512. private _targets;
  19513. private _targetInfluenceChangedObservers;
  19514. private _targetDataLayoutChangedObservers;
  19515. private _activeTargets;
  19516. private _scene;
  19517. private _influences;
  19518. private _supportsNormals;
  19519. private _supportsTangents;
  19520. private _vertexCount;
  19521. private _uniqueId;
  19522. private _tempInfluences;
  19523. /**
  19524. * Creates a new MorphTargetManager
  19525. * @param scene defines the current scene
  19526. */
  19527. constructor(scene?: Nullable<Scene>);
  19528. /**
  19529. * Gets the unique ID of this manager
  19530. */
  19531. readonly uniqueId: number;
  19532. /**
  19533. * Gets the number of vertices handled by this manager
  19534. */
  19535. readonly vertexCount: number;
  19536. /**
  19537. * Gets a boolean indicating if this manager supports morphing of normals
  19538. */
  19539. readonly supportsNormals: boolean;
  19540. /**
  19541. * Gets a boolean indicating if this manager supports morphing of tangents
  19542. */
  19543. readonly supportsTangents: boolean;
  19544. /**
  19545. * Gets the number of targets stored in this manager
  19546. */
  19547. readonly numTargets: number;
  19548. /**
  19549. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19550. */
  19551. readonly numInfluencers: number;
  19552. /**
  19553. * Gets the list of influences (one per target)
  19554. */
  19555. readonly influences: Float32Array;
  19556. /**
  19557. * Gets the active target at specified index. An active target is a target with an influence > 0
  19558. * @param index defines the index to check
  19559. * @returns the requested target
  19560. */
  19561. getActiveTarget(index: number): MorphTarget;
  19562. /**
  19563. * Gets the target at specified index
  19564. * @param index defines the index to check
  19565. * @returns the requested target
  19566. */
  19567. getTarget(index: number): MorphTarget;
  19568. /**
  19569. * Add a new target to this manager
  19570. * @param target defines the target to add
  19571. */
  19572. addTarget(target: MorphTarget): void;
  19573. /**
  19574. * Removes a target from the manager
  19575. * @param target defines the target to remove
  19576. */
  19577. removeTarget(target: MorphTarget): void;
  19578. /**
  19579. * Serializes the current manager into a Serialization object
  19580. * @returns the serialized object
  19581. */
  19582. serialize(): any;
  19583. private _syncActiveTargets;
  19584. /**
  19585. * Syncrhonize the targets with all the meshes using this morph target manager
  19586. */
  19587. synchronize(): void;
  19588. /**
  19589. * Creates a new MorphTargetManager from serialized data
  19590. * @param serializationObject defines the serialized data
  19591. * @param scene defines the hosting scene
  19592. * @returns the new MorphTargetManager
  19593. */
  19594. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19595. }
  19596. }
  19597. declare module BABYLON {
  19598. /**
  19599. * Class used to represent a specific level of detail of a mesh
  19600. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19601. */
  19602. export class MeshLODLevel {
  19603. /** Defines the distance where this level should star being displayed */
  19604. distance: number;
  19605. /** Defines the mesh to use to render this level */
  19606. mesh: Nullable<Mesh>;
  19607. /**
  19608. * Creates a new LOD level
  19609. * @param distance defines the distance where this level should star being displayed
  19610. * @param mesh defines the mesh to use to render this level
  19611. */
  19612. constructor(
  19613. /** Defines the distance where this level should star being displayed */
  19614. distance: number,
  19615. /** Defines the mesh to use to render this level */
  19616. mesh: Nullable<Mesh>);
  19617. }
  19618. }
  19619. declare module BABYLON {
  19620. /**
  19621. * Mesh representing the gorund
  19622. */
  19623. export class GroundMesh extends Mesh {
  19624. /** If octree should be generated */
  19625. generateOctree: boolean;
  19626. private _heightQuads;
  19627. /** @hidden */
  19628. _subdivisionsX: number;
  19629. /** @hidden */
  19630. _subdivisionsY: number;
  19631. /** @hidden */
  19632. _width: number;
  19633. /** @hidden */
  19634. _height: number;
  19635. /** @hidden */
  19636. _minX: number;
  19637. /** @hidden */
  19638. _maxX: number;
  19639. /** @hidden */
  19640. _minZ: number;
  19641. /** @hidden */
  19642. _maxZ: number;
  19643. constructor(name: string, scene: Scene);
  19644. /**
  19645. * "GroundMesh"
  19646. * @returns "GroundMesh"
  19647. */
  19648. getClassName(): string;
  19649. /**
  19650. * The minimum of x and y subdivisions
  19651. */
  19652. readonly subdivisions: number;
  19653. /**
  19654. * X subdivisions
  19655. */
  19656. readonly subdivisionsX: number;
  19657. /**
  19658. * Y subdivisions
  19659. */
  19660. readonly subdivisionsY: number;
  19661. /**
  19662. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19663. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19664. * @param chunksCount the number of subdivisions for x and y
  19665. * @param octreeBlocksSize (Default: 32)
  19666. */
  19667. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19668. /**
  19669. * Returns a height (y) value in the Worl system :
  19670. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19671. * @param x x coordinate
  19672. * @param z z coordinate
  19673. * @returns the ground y position if (x, z) are outside the ground surface.
  19674. */
  19675. getHeightAtCoordinates(x: number, z: number): number;
  19676. /**
  19677. * Returns a normalized vector (Vector3) orthogonal to the ground
  19678. * at the ground coordinates (x, z) expressed in the World system.
  19679. * @param x x coordinate
  19680. * @param z z coordinate
  19681. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19682. */
  19683. getNormalAtCoordinates(x: number, z: number): Vector3;
  19684. /**
  19685. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19686. * at the ground coordinates (x, z) expressed in the World system.
  19687. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19688. * @param x x coordinate
  19689. * @param z z coordinate
  19690. * @param ref vector to store the result
  19691. * @returns the GroundMesh.
  19692. */
  19693. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19694. /**
  19695. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19696. * if the ground has been updated.
  19697. * This can be used in the render loop.
  19698. * @returns the GroundMesh.
  19699. */
  19700. updateCoordinateHeights(): GroundMesh;
  19701. private _getFacetAt;
  19702. private _initHeightQuads;
  19703. private _computeHeightQuads;
  19704. /**
  19705. * Serializes this ground mesh
  19706. * @param serializationObject object to write serialization to
  19707. */
  19708. serialize(serializationObject: any): void;
  19709. /**
  19710. * Parses a serialized ground mesh
  19711. * @param parsedMesh the serialized mesh
  19712. * @param scene the scene to create the ground mesh in
  19713. * @returns the created ground mesh
  19714. */
  19715. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19716. }
  19717. }
  19718. declare module BABYLON {
  19719. /**
  19720. * Interface for Physics-Joint data
  19721. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19722. */
  19723. export interface PhysicsJointData {
  19724. /**
  19725. * The main pivot of the joint
  19726. */
  19727. mainPivot?: Vector3;
  19728. /**
  19729. * The connected pivot of the joint
  19730. */
  19731. connectedPivot?: Vector3;
  19732. /**
  19733. * The main axis of the joint
  19734. */
  19735. mainAxis?: Vector3;
  19736. /**
  19737. * The connected axis of the joint
  19738. */
  19739. connectedAxis?: Vector3;
  19740. /**
  19741. * The collision of the joint
  19742. */
  19743. collision?: boolean;
  19744. /**
  19745. * Native Oimo/Cannon/Energy data
  19746. */
  19747. nativeParams?: any;
  19748. }
  19749. /**
  19750. * This is a holder class for the physics joint created by the physics plugin
  19751. * It holds a set of functions to control the underlying joint
  19752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19753. */
  19754. export class PhysicsJoint {
  19755. /**
  19756. * The type of the physics joint
  19757. */
  19758. type: number;
  19759. /**
  19760. * The data for the physics joint
  19761. */
  19762. jointData: PhysicsJointData;
  19763. private _physicsJoint;
  19764. protected _physicsPlugin: IPhysicsEnginePlugin;
  19765. /**
  19766. * Initializes the physics joint
  19767. * @param type The type of the physics joint
  19768. * @param jointData The data for the physics joint
  19769. */
  19770. constructor(
  19771. /**
  19772. * The type of the physics joint
  19773. */
  19774. type: number,
  19775. /**
  19776. * The data for the physics joint
  19777. */
  19778. jointData: PhysicsJointData);
  19779. /**
  19780. * Gets the physics joint
  19781. */
  19782. /**
  19783. * Sets the physics joint
  19784. */
  19785. physicsJoint: any;
  19786. /**
  19787. * Sets the physics plugin
  19788. */
  19789. physicsPlugin: IPhysicsEnginePlugin;
  19790. /**
  19791. * Execute a function that is physics-plugin specific.
  19792. * @param {Function} func the function that will be executed.
  19793. * It accepts two parameters: the physics world and the physics joint
  19794. */
  19795. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19796. /**
  19797. * Distance-Joint type
  19798. */
  19799. static DistanceJoint: number;
  19800. /**
  19801. * Hinge-Joint type
  19802. */
  19803. static HingeJoint: number;
  19804. /**
  19805. * Ball-and-Socket joint type
  19806. */
  19807. static BallAndSocketJoint: number;
  19808. /**
  19809. * Wheel-Joint type
  19810. */
  19811. static WheelJoint: number;
  19812. /**
  19813. * Slider-Joint type
  19814. */
  19815. static SliderJoint: number;
  19816. /**
  19817. * Prismatic-Joint type
  19818. */
  19819. static PrismaticJoint: number;
  19820. /**
  19821. * Universal-Joint type
  19822. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19823. */
  19824. static UniversalJoint: number;
  19825. /**
  19826. * Hinge-Joint 2 type
  19827. */
  19828. static Hinge2Joint: number;
  19829. /**
  19830. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19831. */
  19832. static PointToPointJoint: number;
  19833. /**
  19834. * Spring-Joint type
  19835. */
  19836. static SpringJoint: number;
  19837. /**
  19838. * Lock-Joint type
  19839. */
  19840. static LockJoint: number;
  19841. }
  19842. /**
  19843. * A class representing a physics distance joint
  19844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19845. */
  19846. export class DistanceJoint extends PhysicsJoint {
  19847. /**
  19848. *
  19849. * @param jointData The data for the Distance-Joint
  19850. */
  19851. constructor(jointData: DistanceJointData);
  19852. /**
  19853. * Update the predefined distance.
  19854. * @param maxDistance The maximum preferred distance
  19855. * @param minDistance The minimum preferred distance
  19856. */
  19857. updateDistance(maxDistance: number, minDistance?: number): void;
  19858. }
  19859. /**
  19860. * Represents a Motor-Enabled Joint
  19861. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19862. */
  19863. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19864. /**
  19865. * Initializes the Motor-Enabled Joint
  19866. * @param type The type of the joint
  19867. * @param jointData The physica joint data for the joint
  19868. */
  19869. constructor(type: number, jointData: PhysicsJointData);
  19870. /**
  19871. * Set the motor values.
  19872. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19873. * @param force the force to apply
  19874. * @param maxForce max force for this motor.
  19875. */
  19876. setMotor(force?: number, maxForce?: number): void;
  19877. /**
  19878. * Set the motor's limits.
  19879. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19880. * @param upperLimit The upper limit of the motor
  19881. * @param lowerLimit The lower limit of the motor
  19882. */
  19883. setLimit(upperLimit: number, lowerLimit?: number): void;
  19884. }
  19885. /**
  19886. * This class represents a single physics Hinge-Joint
  19887. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19888. */
  19889. export class HingeJoint extends MotorEnabledJoint {
  19890. /**
  19891. * Initializes the Hinge-Joint
  19892. * @param jointData The joint data for the Hinge-Joint
  19893. */
  19894. constructor(jointData: PhysicsJointData);
  19895. /**
  19896. * Set the motor values.
  19897. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19898. * @param {number} force the force to apply
  19899. * @param {number} maxForce max force for this motor.
  19900. */
  19901. setMotor(force?: number, maxForce?: number): void;
  19902. /**
  19903. * Set the motor's limits.
  19904. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19905. * @param upperLimit The upper limit of the motor
  19906. * @param lowerLimit The lower limit of the motor
  19907. */
  19908. setLimit(upperLimit: number, lowerLimit?: number): void;
  19909. }
  19910. /**
  19911. * This class represents a dual hinge physics joint (same as wheel joint)
  19912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19913. */
  19914. export class Hinge2Joint extends MotorEnabledJoint {
  19915. /**
  19916. * Initializes the Hinge2-Joint
  19917. * @param jointData The joint data for the Hinge2-Joint
  19918. */
  19919. constructor(jointData: PhysicsJointData);
  19920. /**
  19921. * Set the motor values.
  19922. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19923. * @param {number} targetSpeed the speed the motor is to reach
  19924. * @param {number} maxForce max force for this motor.
  19925. * @param {motorIndex} the motor's index, 0 or 1.
  19926. */
  19927. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19928. /**
  19929. * Set the motor limits.
  19930. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19931. * @param {number} upperLimit the upper limit
  19932. * @param {number} lowerLimit lower limit
  19933. * @param {motorIndex} the motor's index, 0 or 1.
  19934. */
  19935. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19936. }
  19937. /**
  19938. * Interface for a motor enabled joint
  19939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19940. */
  19941. export interface IMotorEnabledJoint {
  19942. /**
  19943. * Physics joint
  19944. */
  19945. physicsJoint: any;
  19946. /**
  19947. * Sets the motor of the motor-enabled joint
  19948. * @param force The force of the motor
  19949. * @param maxForce The maximum force of the motor
  19950. * @param motorIndex The index of the motor
  19951. */
  19952. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19953. /**
  19954. * Sets the limit of the motor
  19955. * @param upperLimit The upper limit of the motor
  19956. * @param lowerLimit The lower limit of the motor
  19957. * @param motorIndex The index of the motor
  19958. */
  19959. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19960. }
  19961. /**
  19962. * Joint data for a Distance-Joint
  19963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19964. */
  19965. export interface DistanceJointData extends PhysicsJointData {
  19966. /**
  19967. * Max distance the 2 joint objects can be apart
  19968. */
  19969. maxDistance: number;
  19970. }
  19971. /**
  19972. * Joint data from a spring joint
  19973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19974. */
  19975. export interface SpringJointData extends PhysicsJointData {
  19976. /**
  19977. * Length of the spring
  19978. */
  19979. length: number;
  19980. /**
  19981. * Stiffness of the spring
  19982. */
  19983. stiffness: number;
  19984. /**
  19985. * Damping of the spring
  19986. */
  19987. damping: number;
  19988. /** this callback will be called when applying the force to the impostors. */
  19989. forceApplicationCallback: () => void;
  19990. }
  19991. }
  19992. declare module BABYLON {
  19993. /**
  19994. * Holds the data for the raycast result
  19995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19996. */
  19997. export class PhysicsRaycastResult {
  19998. private _hasHit;
  19999. private _hitDistance;
  20000. private _hitNormalWorld;
  20001. private _hitPointWorld;
  20002. private _rayFromWorld;
  20003. private _rayToWorld;
  20004. /**
  20005. * Gets if there was a hit
  20006. */
  20007. readonly hasHit: boolean;
  20008. /**
  20009. * Gets the distance from the hit
  20010. */
  20011. readonly hitDistance: number;
  20012. /**
  20013. * Gets the hit normal/direction in the world
  20014. */
  20015. readonly hitNormalWorld: Vector3;
  20016. /**
  20017. * Gets the hit point in the world
  20018. */
  20019. readonly hitPointWorld: Vector3;
  20020. /**
  20021. * Gets the ray "start point" of the ray in the world
  20022. */
  20023. readonly rayFromWorld: Vector3;
  20024. /**
  20025. * Gets the ray "end point" of the ray in the world
  20026. */
  20027. readonly rayToWorld: Vector3;
  20028. /**
  20029. * Sets the hit data (normal & point in world space)
  20030. * @param hitNormalWorld defines the normal in world space
  20031. * @param hitPointWorld defines the point in world space
  20032. */
  20033. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20034. /**
  20035. * Sets the distance from the start point to the hit point
  20036. * @param distance
  20037. */
  20038. setHitDistance(distance: number): void;
  20039. /**
  20040. * Calculates the distance manually
  20041. */
  20042. calculateHitDistance(): void;
  20043. /**
  20044. * Resets all the values to default
  20045. * @param from The from point on world space
  20046. * @param to The to point on world space
  20047. */
  20048. reset(from?: Vector3, to?: Vector3): void;
  20049. }
  20050. /**
  20051. * Interface for the size containing width and height
  20052. */
  20053. interface IXYZ {
  20054. /**
  20055. * X
  20056. */
  20057. x: number;
  20058. /**
  20059. * Y
  20060. */
  20061. y: number;
  20062. /**
  20063. * Z
  20064. */
  20065. z: number;
  20066. }
  20067. }
  20068. declare module BABYLON {
  20069. /**
  20070. * Interface used to describe a physics joint
  20071. */
  20072. export interface PhysicsImpostorJoint {
  20073. /** Defines the main impostor to which the joint is linked */
  20074. mainImpostor: PhysicsImpostor;
  20075. /** Defines the impostor that is connected to the main impostor using this joint */
  20076. connectedImpostor: PhysicsImpostor;
  20077. /** Defines the joint itself */
  20078. joint: PhysicsJoint;
  20079. }
  20080. /** @hidden */
  20081. export interface IPhysicsEnginePlugin {
  20082. world: any;
  20083. name: string;
  20084. setGravity(gravity: Vector3): void;
  20085. setTimeStep(timeStep: number): void;
  20086. getTimeStep(): number;
  20087. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20088. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20089. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20090. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20091. removePhysicsBody(impostor: PhysicsImpostor): void;
  20092. generateJoint(joint: PhysicsImpostorJoint): void;
  20093. removeJoint(joint: PhysicsImpostorJoint): void;
  20094. isSupported(): boolean;
  20095. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20096. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20097. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20098. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20099. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20100. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20101. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20102. getBodyMass(impostor: PhysicsImpostor): number;
  20103. getBodyFriction(impostor: PhysicsImpostor): number;
  20104. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20105. getBodyRestitution(impostor: PhysicsImpostor): number;
  20106. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20107. getBodyPressure?(impostor: PhysicsImpostor): number;
  20108. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20109. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20110. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20111. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20112. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20113. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20114. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20115. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20116. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20117. sleepBody(impostor: PhysicsImpostor): void;
  20118. wakeUpBody(impostor: PhysicsImpostor): void;
  20119. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20120. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20121. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20122. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20123. getRadius(impostor: PhysicsImpostor): number;
  20124. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20125. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20126. dispose(): void;
  20127. }
  20128. /**
  20129. * Interface used to define a physics engine
  20130. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20131. */
  20132. export interface IPhysicsEngine {
  20133. /**
  20134. * Gets the gravity vector used by the simulation
  20135. */
  20136. gravity: Vector3;
  20137. /**
  20138. * Sets the gravity vector used by the simulation
  20139. * @param gravity defines the gravity vector to use
  20140. */
  20141. setGravity(gravity: Vector3): void;
  20142. /**
  20143. * Set the time step of the physics engine.
  20144. * Default is 1/60.
  20145. * To slow it down, enter 1/600 for example.
  20146. * To speed it up, 1/30
  20147. * @param newTimeStep the new timestep to apply to this world.
  20148. */
  20149. setTimeStep(newTimeStep: number): void;
  20150. /**
  20151. * Get the time step of the physics engine.
  20152. * @returns the current time step
  20153. */
  20154. getTimeStep(): number;
  20155. /**
  20156. * Release all resources
  20157. */
  20158. dispose(): void;
  20159. /**
  20160. * Gets the name of the current physics plugin
  20161. * @returns the name of the plugin
  20162. */
  20163. getPhysicsPluginName(): string;
  20164. /**
  20165. * Adding a new impostor for the impostor tracking.
  20166. * This will be done by the impostor itself.
  20167. * @param impostor the impostor to add
  20168. */
  20169. addImpostor(impostor: PhysicsImpostor): void;
  20170. /**
  20171. * Remove an impostor from the engine.
  20172. * This impostor and its mesh will not longer be updated by the physics engine.
  20173. * @param impostor the impostor to remove
  20174. */
  20175. removeImpostor(impostor: PhysicsImpostor): void;
  20176. /**
  20177. * Add a joint to the physics engine
  20178. * @param mainImpostor defines the main impostor to which the joint is added.
  20179. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20180. * @param joint defines the joint that will connect both impostors.
  20181. */
  20182. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20183. /**
  20184. * Removes a joint from the simulation
  20185. * @param mainImpostor defines the impostor used with the joint
  20186. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20187. * @param joint defines the joint to remove
  20188. */
  20189. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20190. /**
  20191. * Gets the current plugin used to run the simulation
  20192. * @returns current plugin
  20193. */
  20194. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20195. /**
  20196. * Gets the list of physic impostors
  20197. * @returns an array of PhysicsImpostor
  20198. */
  20199. getImpostors(): Array<PhysicsImpostor>;
  20200. /**
  20201. * Gets the impostor for a physics enabled object
  20202. * @param object defines the object impersonated by the impostor
  20203. * @returns the PhysicsImpostor or null if not found
  20204. */
  20205. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20206. /**
  20207. * Gets the impostor for a physics body object
  20208. * @param body defines physics body used by the impostor
  20209. * @returns the PhysicsImpostor or null if not found
  20210. */
  20211. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20212. /**
  20213. * Does a raycast in the physics world
  20214. * @param from when should the ray start?
  20215. * @param to when should the ray end?
  20216. * @returns PhysicsRaycastResult
  20217. */
  20218. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20219. /**
  20220. * Called by the scene. No need to call it.
  20221. * @param delta defines the timespam between frames
  20222. */
  20223. _step(delta: number): void;
  20224. }
  20225. }
  20226. declare module BABYLON {
  20227. /**
  20228. * The interface for the physics imposter parameters
  20229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20230. */
  20231. export interface PhysicsImpostorParameters {
  20232. /**
  20233. * The mass of the physics imposter
  20234. */
  20235. mass: number;
  20236. /**
  20237. * The friction of the physics imposter
  20238. */
  20239. friction?: number;
  20240. /**
  20241. * The coefficient of restitution of the physics imposter
  20242. */
  20243. restitution?: number;
  20244. /**
  20245. * The native options of the physics imposter
  20246. */
  20247. nativeOptions?: any;
  20248. /**
  20249. * Specifies if the parent should be ignored
  20250. */
  20251. ignoreParent?: boolean;
  20252. /**
  20253. * Specifies if bi-directional transformations should be disabled
  20254. */
  20255. disableBidirectionalTransformation?: boolean;
  20256. /**
  20257. * The pressure inside the physics imposter, soft object only
  20258. */
  20259. pressure?: number;
  20260. /**
  20261. * The stiffness the physics imposter, soft object only
  20262. */
  20263. stiffness?: number;
  20264. /**
  20265. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20266. */
  20267. velocityIterations?: number;
  20268. /**
  20269. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20270. */
  20271. positionIterations?: number;
  20272. /**
  20273. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20274. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20275. * Add to fix multiple points
  20276. */
  20277. fixedPoints?: number;
  20278. /**
  20279. * The collision margin around a soft object
  20280. */
  20281. margin?: number;
  20282. /**
  20283. * The collision margin around a soft object
  20284. */
  20285. damping?: number;
  20286. /**
  20287. * The path for a rope based on an extrusion
  20288. */
  20289. path?: any;
  20290. /**
  20291. * The shape of an extrusion used for a rope based on an extrusion
  20292. */
  20293. shape?: any;
  20294. }
  20295. /**
  20296. * Interface for a physics-enabled object
  20297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20298. */
  20299. export interface IPhysicsEnabledObject {
  20300. /**
  20301. * The position of the physics-enabled object
  20302. */
  20303. position: Vector3;
  20304. /**
  20305. * The rotation of the physics-enabled object
  20306. */
  20307. rotationQuaternion: Nullable<Quaternion>;
  20308. /**
  20309. * The scale of the physics-enabled object
  20310. */
  20311. scaling: Vector3;
  20312. /**
  20313. * The rotation of the physics-enabled object
  20314. */
  20315. rotation?: Vector3;
  20316. /**
  20317. * The parent of the physics-enabled object
  20318. */
  20319. parent?: any;
  20320. /**
  20321. * The bounding info of the physics-enabled object
  20322. * @returns The bounding info of the physics-enabled object
  20323. */
  20324. getBoundingInfo(): BoundingInfo;
  20325. /**
  20326. * Computes the world matrix
  20327. * @param force Specifies if the world matrix should be computed by force
  20328. * @returns A world matrix
  20329. */
  20330. computeWorldMatrix(force: boolean): Matrix;
  20331. /**
  20332. * Gets the world matrix
  20333. * @returns A world matrix
  20334. */
  20335. getWorldMatrix?(): Matrix;
  20336. /**
  20337. * Gets the child meshes
  20338. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20339. * @returns An array of abstract meshes
  20340. */
  20341. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20342. /**
  20343. * Gets the vertex data
  20344. * @param kind The type of vertex data
  20345. * @returns A nullable array of numbers, or a float32 array
  20346. */
  20347. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20348. /**
  20349. * Gets the indices from the mesh
  20350. * @returns A nullable array of index arrays
  20351. */
  20352. getIndices?(): Nullable<IndicesArray>;
  20353. /**
  20354. * Gets the scene from the mesh
  20355. * @returns the indices array or null
  20356. */
  20357. getScene?(): Scene;
  20358. /**
  20359. * Gets the absolute position from the mesh
  20360. * @returns the absolute position
  20361. */
  20362. getAbsolutePosition(): Vector3;
  20363. /**
  20364. * Gets the absolute pivot point from the mesh
  20365. * @returns the absolute pivot point
  20366. */
  20367. getAbsolutePivotPoint(): Vector3;
  20368. /**
  20369. * Rotates the mesh
  20370. * @param axis The axis of rotation
  20371. * @param amount The amount of rotation
  20372. * @param space The space of the rotation
  20373. * @returns The rotation transform node
  20374. */
  20375. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20376. /**
  20377. * Translates the mesh
  20378. * @param axis The axis of translation
  20379. * @param distance The distance of translation
  20380. * @param space The space of the translation
  20381. * @returns The transform node
  20382. */
  20383. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20384. /**
  20385. * Sets the absolute position of the mesh
  20386. * @param absolutePosition The absolute position of the mesh
  20387. * @returns The transform node
  20388. */
  20389. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20390. /**
  20391. * Gets the class name of the mesh
  20392. * @returns The class name
  20393. */
  20394. getClassName(): string;
  20395. }
  20396. /**
  20397. * Represents a physics imposter
  20398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20399. */
  20400. export class PhysicsImpostor {
  20401. /**
  20402. * The physics-enabled object used as the physics imposter
  20403. */
  20404. object: IPhysicsEnabledObject;
  20405. /**
  20406. * The type of the physics imposter
  20407. */
  20408. type: number;
  20409. private _options;
  20410. private _scene?;
  20411. /**
  20412. * The default object size of the imposter
  20413. */
  20414. static DEFAULT_OBJECT_SIZE: Vector3;
  20415. /**
  20416. * The identity quaternion of the imposter
  20417. */
  20418. static IDENTITY_QUATERNION: Quaternion;
  20419. /** @hidden */
  20420. _pluginData: any;
  20421. private _physicsEngine;
  20422. private _physicsBody;
  20423. private _bodyUpdateRequired;
  20424. private _onBeforePhysicsStepCallbacks;
  20425. private _onAfterPhysicsStepCallbacks;
  20426. /** @hidden */
  20427. _onPhysicsCollideCallbacks: Array<{
  20428. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20429. otherImpostors: Array<PhysicsImpostor>;
  20430. }>;
  20431. private _deltaPosition;
  20432. private _deltaRotation;
  20433. private _deltaRotationConjugated;
  20434. /** @hidden */
  20435. _isFromLine: boolean;
  20436. private _parent;
  20437. private _isDisposed;
  20438. private static _tmpVecs;
  20439. private static _tmpQuat;
  20440. /**
  20441. * Specifies if the physics imposter is disposed
  20442. */
  20443. readonly isDisposed: boolean;
  20444. /**
  20445. * Gets the mass of the physics imposter
  20446. */
  20447. mass: number;
  20448. /**
  20449. * Gets the coefficient of friction
  20450. */
  20451. /**
  20452. * Sets the coefficient of friction
  20453. */
  20454. friction: number;
  20455. /**
  20456. * Gets the coefficient of restitution
  20457. */
  20458. /**
  20459. * Sets the coefficient of restitution
  20460. */
  20461. restitution: number;
  20462. /**
  20463. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20464. */
  20465. /**
  20466. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20467. */
  20468. pressure: number;
  20469. /**
  20470. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20471. */
  20472. /**
  20473. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20474. */
  20475. stiffness: number;
  20476. /**
  20477. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20478. */
  20479. /**
  20480. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20481. */
  20482. velocityIterations: number;
  20483. /**
  20484. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20485. */
  20486. /**
  20487. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20488. */
  20489. positionIterations: number;
  20490. /**
  20491. * The unique id of the physics imposter
  20492. * set by the physics engine when adding this impostor to the array
  20493. */
  20494. uniqueId: number;
  20495. /**
  20496. * @hidden
  20497. */
  20498. soft: boolean;
  20499. /**
  20500. * @hidden
  20501. */
  20502. segments: number;
  20503. private _joints;
  20504. /**
  20505. * Initializes the physics imposter
  20506. * @param object The physics-enabled object used as the physics imposter
  20507. * @param type The type of the physics imposter
  20508. * @param _options The options for the physics imposter
  20509. * @param _scene The Babylon scene
  20510. */
  20511. constructor(
  20512. /**
  20513. * The physics-enabled object used as the physics imposter
  20514. */
  20515. object: IPhysicsEnabledObject,
  20516. /**
  20517. * The type of the physics imposter
  20518. */
  20519. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20520. /**
  20521. * This function will completly initialize this impostor.
  20522. * It will create a new body - but only if this mesh has no parent.
  20523. * If it has, this impostor will not be used other than to define the impostor
  20524. * of the child mesh.
  20525. * @hidden
  20526. */
  20527. _init(): void;
  20528. private _getPhysicsParent;
  20529. /**
  20530. * Should a new body be generated.
  20531. * @returns boolean specifying if body initialization is required
  20532. */
  20533. isBodyInitRequired(): boolean;
  20534. /**
  20535. * Sets the updated scaling
  20536. * @param updated Specifies if the scaling is updated
  20537. */
  20538. setScalingUpdated(): void;
  20539. /**
  20540. * Force a regeneration of this or the parent's impostor's body.
  20541. * Use under cautious - This will remove all joints already implemented.
  20542. */
  20543. forceUpdate(): void;
  20544. /**
  20545. * Gets the body that holds this impostor. Either its own, or its parent.
  20546. */
  20547. /**
  20548. * Set the physics body. Used mainly by the physics engine/plugin
  20549. */
  20550. physicsBody: any;
  20551. /**
  20552. * Get the parent of the physics imposter
  20553. * @returns Physics imposter or null
  20554. */
  20555. /**
  20556. * Sets the parent of the physics imposter
  20557. */
  20558. parent: Nullable<PhysicsImpostor>;
  20559. /**
  20560. * Resets the update flags
  20561. */
  20562. resetUpdateFlags(): void;
  20563. /**
  20564. * Gets the object extend size
  20565. * @returns the object extend size
  20566. */
  20567. getObjectExtendSize(): Vector3;
  20568. /**
  20569. * Gets the object center
  20570. * @returns The object center
  20571. */
  20572. getObjectCenter(): Vector3;
  20573. /**
  20574. * Get a specific parametes from the options parameter
  20575. * @param paramName The object parameter name
  20576. * @returns The object parameter
  20577. */
  20578. getParam(paramName: string): any;
  20579. /**
  20580. * Sets a specific parameter in the options given to the physics plugin
  20581. * @param paramName The parameter name
  20582. * @param value The value of the parameter
  20583. */
  20584. setParam(paramName: string, value: number): void;
  20585. /**
  20586. * Specifically change the body's mass option. Won't recreate the physics body object
  20587. * @param mass The mass of the physics imposter
  20588. */
  20589. setMass(mass: number): void;
  20590. /**
  20591. * Gets the linear velocity
  20592. * @returns linear velocity or null
  20593. */
  20594. getLinearVelocity(): Nullable<Vector3>;
  20595. /**
  20596. * Sets the linear velocity
  20597. * @param velocity linear velocity or null
  20598. */
  20599. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20600. /**
  20601. * Gets the angular velocity
  20602. * @returns angular velocity or null
  20603. */
  20604. getAngularVelocity(): Nullable<Vector3>;
  20605. /**
  20606. * Sets the angular velocity
  20607. * @param velocity The velocity or null
  20608. */
  20609. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20610. /**
  20611. * Execute a function with the physics plugin native code
  20612. * Provide a function the will have two variables - the world object and the physics body object
  20613. * @param func The function to execute with the physics plugin native code
  20614. */
  20615. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20616. /**
  20617. * Register a function that will be executed before the physics world is stepping forward
  20618. * @param func The function to execute before the physics world is stepped forward
  20619. */
  20620. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20621. /**
  20622. * Unregister a function that will be executed before the physics world is stepping forward
  20623. * @param func The function to execute before the physics world is stepped forward
  20624. */
  20625. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20626. /**
  20627. * Register a function that will be executed after the physics step
  20628. * @param func The function to execute after physics step
  20629. */
  20630. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20631. /**
  20632. * Unregisters a function that will be executed after the physics step
  20633. * @param func The function to execute after physics step
  20634. */
  20635. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20636. /**
  20637. * register a function that will be executed when this impostor collides against a different body
  20638. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20639. * @param func Callback that is executed on collision
  20640. */
  20641. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20642. /**
  20643. * Unregisters the physics imposter on contact
  20644. * @param collideAgainst The physics object to collide against
  20645. * @param func Callback to execute on collision
  20646. */
  20647. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20648. private _tmpQuat;
  20649. private _tmpQuat2;
  20650. /**
  20651. * Get the parent rotation
  20652. * @returns The parent rotation
  20653. */
  20654. getParentsRotation(): Quaternion;
  20655. /**
  20656. * this function is executed by the physics engine.
  20657. */
  20658. beforeStep: () => void;
  20659. /**
  20660. * this function is executed by the physics engine
  20661. */
  20662. afterStep: () => void;
  20663. /**
  20664. * Legacy collision detection event support
  20665. */
  20666. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20667. /**
  20668. * event and body object due to cannon's event-based architecture.
  20669. */
  20670. onCollide: (e: {
  20671. body: any;
  20672. }) => void;
  20673. /**
  20674. * Apply a force
  20675. * @param force The force to apply
  20676. * @param contactPoint The contact point for the force
  20677. * @returns The physics imposter
  20678. */
  20679. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20680. /**
  20681. * Apply an impulse
  20682. * @param force The impulse force
  20683. * @param contactPoint The contact point for the impulse force
  20684. * @returns The physics imposter
  20685. */
  20686. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20687. /**
  20688. * A help function to create a joint
  20689. * @param otherImpostor A physics imposter used to create a joint
  20690. * @param jointType The type of joint
  20691. * @param jointData The data for the joint
  20692. * @returns The physics imposter
  20693. */
  20694. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20695. /**
  20696. * Add a joint to this impostor with a different impostor
  20697. * @param otherImpostor A physics imposter used to add a joint
  20698. * @param joint The joint to add
  20699. * @returns The physics imposter
  20700. */
  20701. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20702. /**
  20703. * Add an anchor to a cloth impostor
  20704. * @param otherImpostor rigid impostor to anchor to
  20705. * @param width ratio across width from 0 to 1
  20706. * @param height ratio up height from 0 to 1
  20707. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20708. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20709. * @returns impostor the soft imposter
  20710. */
  20711. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20712. /**
  20713. * Add a hook to a rope impostor
  20714. * @param otherImpostor rigid impostor to anchor to
  20715. * @param length ratio across rope from 0 to 1
  20716. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20717. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20718. * @returns impostor the rope imposter
  20719. */
  20720. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20721. /**
  20722. * Will keep this body still, in a sleep mode.
  20723. * @returns the physics imposter
  20724. */
  20725. sleep(): PhysicsImpostor;
  20726. /**
  20727. * Wake the body up.
  20728. * @returns The physics imposter
  20729. */
  20730. wakeUp(): PhysicsImpostor;
  20731. /**
  20732. * Clones the physics imposter
  20733. * @param newObject The physics imposter clones to this physics-enabled object
  20734. * @returns A nullable physics imposter
  20735. */
  20736. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20737. /**
  20738. * Disposes the physics imposter
  20739. */
  20740. dispose(): void;
  20741. /**
  20742. * Sets the delta position
  20743. * @param position The delta position amount
  20744. */
  20745. setDeltaPosition(position: Vector3): void;
  20746. /**
  20747. * Sets the delta rotation
  20748. * @param rotation The delta rotation amount
  20749. */
  20750. setDeltaRotation(rotation: Quaternion): void;
  20751. /**
  20752. * Gets the box size of the physics imposter and stores the result in the input parameter
  20753. * @param result Stores the box size
  20754. * @returns The physics imposter
  20755. */
  20756. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20757. /**
  20758. * Gets the radius of the physics imposter
  20759. * @returns Radius of the physics imposter
  20760. */
  20761. getRadius(): number;
  20762. /**
  20763. * Sync a bone with this impostor
  20764. * @param bone The bone to sync to the impostor.
  20765. * @param boneMesh The mesh that the bone is influencing.
  20766. * @param jointPivot The pivot of the joint / bone in local space.
  20767. * @param distToJoint Optional distance from the impostor to the joint.
  20768. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20769. */
  20770. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20771. /**
  20772. * Sync impostor to a bone
  20773. * @param bone The bone that the impostor will be synced to.
  20774. * @param boneMesh The mesh that the bone is influencing.
  20775. * @param jointPivot The pivot of the joint / bone in local space.
  20776. * @param distToJoint Optional distance from the impostor to the joint.
  20777. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20778. * @param boneAxis Optional vector3 axis the bone is aligned with
  20779. */
  20780. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20781. /**
  20782. * No-Imposter type
  20783. */
  20784. static NoImpostor: number;
  20785. /**
  20786. * Sphere-Imposter type
  20787. */
  20788. static SphereImpostor: number;
  20789. /**
  20790. * Box-Imposter type
  20791. */
  20792. static BoxImpostor: number;
  20793. /**
  20794. * Plane-Imposter type
  20795. */
  20796. static PlaneImpostor: number;
  20797. /**
  20798. * Mesh-imposter type
  20799. */
  20800. static MeshImpostor: number;
  20801. /**
  20802. * Cylinder-Imposter type
  20803. */
  20804. static CylinderImpostor: number;
  20805. /**
  20806. * Particle-Imposter type
  20807. */
  20808. static ParticleImpostor: number;
  20809. /**
  20810. * Heightmap-Imposter type
  20811. */
  20812. static HeightmapImpostor: number;
  20813. /**
  20814. * ConvexHull-Impostor type (Ammo.js plugin only)
  20815. */
  20816. static ConvexHullImpostor: number;
  20817. /**
  20818. * Rope-Imposter type
  20819. */
  20820. static RopeImpostor: number;
  20821. /**
  20822. * Cloth-Imposter type
  20823. */
  20824. static ClothImpostor: number;
  20825. /**
  20826. * Softbody-Imposter type
  20827. */
  20828. static SoftbodyImpostor: number;
  20829. }
  20830. }
  20831. declare module BABYLON {
  20832. /**
  20833. * @hidden
  20834. **/
  20835. export class _CreationDataStorage {
  20836. closePath?: boolean;
  20837. closeArray?: boolean;
  20838. idx: number[];
  20839. dashSize: number;
  20840. gapSize: number;
  20841. path3D: Path3D;
  20842. pathArray: Vector3[][];
  20843. arc: number;
  20844. radius: number;
  20845. cap: number;
  20846. tessellation: number;
  20847. }
  20848. /**
  20849. * @hidden
  20850. **/
  20851. class _InstanceDataStorage {
  20852. visibleInstances: any;
  20853. batchCache: _InstancesBatch;
  20854. instancesBufferSize: number;
  20855. instancesBuffer: Nullable<Buffer>;
  20856. instancesData: Float32Array;
  20857. overridenInstanceCount: number;
  20858. isFrozen: boolean;
  20859. previousBatch: _InstancesBatch;
  20860. hardwareInstancedRendering: boolean;
  20861. sideOrientation: number;
  20862. }
  20863. /**
  20864. * @hidden
  20865. **/
  20866. export class _InstancesBatch {
  20867. mustReturn: boolean;
  20868. visibleInstances: Nullable<InstancedMesh[]>[];
  20869. renderSelf: boolean[];
  20870. hardwareInstancedRendering: boolean[];
  20871. }
  20872. /**
  20873. * Class used to represent renderable models
  20874. */
  20875. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20876. /**
  20877. * Mesh side orientation : usually the external or front surface
  20878. */
  20879. static readonly FRONTSIDE: number;
  20880. /**
  20881. * Mesh side orientation : usually the internal or back surface
  20882. */
  20883. static readonly BACKSIDE: number;
  20884. /**
  20885. * Mesh side orientation : both internal and external or front and back surfaces
  20886. */
  20887. static readonly DOUBLESIDE: number;
  20888. /**
  20889. * Mesh side orientation : by default, `FRONTSIDE`
  20890. */
  20891. static readonly DEFAULTSIDE: number;
  20892. /**
  20893. * Mesh cap setting : no cap
  20894. */
  20895. static readonly NO_CAP: number;
  20896. /**
  20897. * Mesh cap setting : one cap at the beginning of the mesh
  20898. */
  20899. static readonly CAP_START: number;
  20900. /**
  20901. * Mesh cap setting : one cap at the end of the mesh
  20902. */
  20903. static readonly CAP_END: number;
  20904. /**
  20905. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20906. */
  20907. static readonly CAP_ALL: number;
  20908. /**
  20909. * Mesh pattern setting : no flip or rotate
  20910. */
  20911. static readonly NO_FLIP: number;
  20912. /**
  20913. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  20914. */
  20915. static readonly FLIP_TILE: number;
  20916. /**
  20917. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  20918. */
  20919. static readonly ROTATE_TILE: number;
  20920. /**
  20921. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  20922. */
  20923. static readonly FLIP_ROW: number;
  20924. /**
  20925. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  20926. */
  20927. static readonly ROTATE_ROW: number;
  20928. /**
  20929. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  20930. */
  20931. static readonly FLIP_N_ROTATE_TILE: number;
  20932. /**
  20933. * Mesh pattern setting : rotate pattern and rotate
  20934. */
  20935. static readonly FLIP_N_ROTATE_ROW: number;
  20936. /**
  20937. * Mesh tile positioning : part tiles same on left/right or top/bottom
  20938. */
  20939. static readonly CENTER: number;
  20940. /**
  20941. * Mesh tile positioning : part tiles on left
  20942. */
  20943. static readonly LEFT: number;
  20944. /**
  20945. * Mesh tile positioning : part tiles on right
  20946. */
  20947. static readonly RIGHT: number;
  20948. /**
  20949. * Mesh tile positioning : part tiles on top
  20950. */
  20951. static readonly TOP: number;
  20952. /**
  20953. * Mesh tile positioning : part tiles on bottom
  20954. */
  20955. static readonly BOTTOM: number;
  20956. /**
  20957. * Gets the default side orientation.
  20958. * @param orientation the orientation to value to attempt to get
  20959. * @returns the default orientation
  20960. * @hidden
  20961. */
  20962. static _GetDefaultSideOrientation(orientation?: number): number;
  20963. private _internalMeshDataInfo;
  20964. /**
  20965. * An event triggered before rendering the mesh
  20966. */
  20967. readonly onBeforeRenderObservable: Observable<Mesh>;
  20968. /**
  20969. * An event triggered before binding the mesh
  20970. */
  20971. readonly onBeforeBindObservable: Observable<Mesh>;
  20972. /**
  20973. * An event triggered after rendering the mesh
  20974. */
  20975. readonly onAfterRenderObservable: Observable<Mesh>;
  20976. /**
  20977. * An event triggered before drawing the mesh
  20978. */
  20979. readonly onBeforeDrawObservable: Observable<Mesh>;
  20980. private _onBeforeDrawObserver;
  20981. /**
  20982. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20983. */
  20984. onBeforeDraw: () => void;
  20985. /**
  20986. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20987. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20988. */
  20989. delayLoadState: number;
  20990. /**
  20991. * Gets the list of instances created from this mesh
  20992. * it is not supposed to be modified manually.
  20993. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20994. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20995. */
  20996. instances: InstancedMesh[];
  20997. /**
  20998. * Gets the file containing delay loading data for this mesh
  20999. */
  21000. delayLoadingFile: string;
  21001. /** @hidden */
  21002. _binaryInfo: any;
  21003. /**
  21004. * User defined function used to change how LOD level selection is done
  21005. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21006. */
  21007. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21008. /**
  21009. * Gets or sets the morph target manager
  21010. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21011. */
  21012. morphTargetManager: Nullable<MorphTargetManager>;
  21013. /** @hidden */
  21014. _creationDataStorage: Nullable<_CreationDataStorage>;
  21015. /** @hidden */
  21016. _geometry: Nullable<Geometry>;
  21017. /** @hidden */
  21018. _delayInfo: Array<string>;
  21019. /** @hidden */
  21020. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21021. /** @hidden */
  21022. _instanceDataStorage: _InstanceDataStorage;
  21023. private _effectiveMaterial;
  21024. /** @hidden */
  21025. _shouldGenerateFlatShading: boolean;
  21026. /** @hidden */
  21027. _originalBuilderSideOrientation: number;
  21028. /**
  21029. * Use this property to change the original side orientation defined at construction time
  21030. */
  21031. overrideMaterialSideOrientation: Nullable<number>;
  21032. /**
  21033. * Gets the source mesh (the one used to clone this one from)
  21034. */
  21035. readonly source: Nullable<Mesh>;
  21036. /**
  21037. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21038. */
  21039. isUnIndexed: boolean;
  21040. /**
  21041. * @constructor
  21042. * @param name The value used by scene.getMeshByName() to do a lookup.
  21043. * @param scene The scene to add this mesh to.
  21044. * @param parent The parent of this mesh, if it has one
  21045. * @param source An optional Mesh from which geometry is shared, cloned.
  21046. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21047. * When false, achieved by calling a clone(), also passing False.
  21048. * This will make creation of children, recursive.
  21049. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21050. */
  21051. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21052. /**
  21053. * Gets the class name
  21054. * @returns the string "Mesh".
  21055. */
  21056. getClassName(): string;
  21057. /** @hidden */
  21058. readonly _isMesh: boolean;
  21059. /**
  21060. * Returns a description of this mesh
  21061. * @param fullDetails define if full details about this mesh must be used
  21062. * @returns a descriptive string representing this mesh
  21063. */
  21064. toString(fullDetails?: boolean): string;
  21065. /** @hidden */
  21066. _unBindEffect(): void;
  21067. /**
  21068. * Gets a boolean indicating if this mesh has LOD
  21069. */
  21070. readonly hasLODLevels: boolean;
  21071. /**
  21072. * Gets the list of MeshLODLevel associated with the current mesh
  21073. * @returns an array of MeshLODLevel
  21074. */
  21075. getLODLevels(): MeshLODLevel[];
  21076. private _sortLODLevels;
  21077. /**
  21078. * Add a mesh as LOD level triggered at the given distance.
  21079. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21080. * @param distance The distance from the center of the object to show this level
  21081. * @param mesh The mesh to be added as LOD level (can be null)
  21082. * @return This mesh (for chaining)
  21083. */
  21084. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21085. /**
  21086. * Returns the LOD level mesh at the passed distance or null if not found.
  21087. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21088. * @param distance The distance from the center of the object to show this level
  21089. * @returns a Mesh or `null`
  21090. */
  21091. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21092. /**
  21093. * Remove a mesh from the LOD array
  21094. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21095. * @param mesh defines the mesh to be removed
  21096. * @return This mesh (for chaining)
  21097. */
  21098. removeLODLevel(mesh: Mesh): Mesh;
  21099. /**
  21100. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21101. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21102. * @param camera defines the camera to use to compute distance
  21103. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21104. * @return This mesh (for chaining)
  21105. */
  21106. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21107. /**
  21108. * Gets the mesh internal Geometry object
  21109. */
  21110. readonly geometry: Nullable<Geometry>;
  21111. /**
  21112. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21113. * @returns the total number of vertices
  21114. */
  21115. getTotalVertices(): number;
  21116. /**
  21117. * Returns the content of an associated vertex buffer
  21118. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21119. * - VertexBuffer.PositionKind
  21120. * - VertexBuffer.UVKind
  21121. * - VertexBuffer.UV2Kind
  21122. * - VertexBuffer.UV3Kind
  21123. * - VertexBuffer.UV4Kind
  21124. * - VertexBuffer.UV5Kind
  21125. * - VertexBuffer.UV6Kind
  21126. * - VertexBuffer.ColorKind
  21127. * - VertexBuffer.MatricesIndicesKind
  21128. * - VertexBuffer.MatricesIndicesExtraKind
  21129. * - VertexBuffer.MatricesWeightsKind
  21130. * - VertexBuffer.MatricesWeightsExtraKind
  21131. * @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
  21132. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21133. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21134. */
  21135. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21136. /**
  21137. * Returns the mesh VertexBuffer object from the requested `kind`
  21138. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21139. * - VertexBuffer.PositionKind
  21140. * - VertexBuffer.NormalKind
  21141. * - VertexBuffer.UVKind
  21142. * - VertexBuffer.UV2Kind
  21143. * - VertexBuffer.UV3Kind
  21144. * - VertexBuffer.UV4Kind
  21145. * - VertexBuffer.UV5Kind
  21146. * - VertexBuffer.UV6Kind
  21147. * - VertexBuffer.ColorKind
  21148. * - VertexBuffer.MatricesIndicesKind
  21149. * - VertexBuffer.MatricesIndicesExtraKind
  21150. * - VertexBuffer.MatricesWeightsKind
  21151. * - VertexBuffer.MatricesWeightsExtraKind
  21152. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21153. */
  21154. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21155. /**
  21156. * Tests if a specific vertex buffer is associated with this mesh
  21157. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21158. * - VertexBuffer.PositionKind
  21159. * - VertexBuffer.NormalKind
  21160. * - VertexBuffer.UVKind
  21161. * - VertexBuffer.UV2Kind
  21162. * - VertexBuffer.UV3Kind
  21163. * - VertexBuffer.UV4Kind
  21164. * - VertexBuffer.UV5Kind
  21165. * - VertexBuffer.UV6Kind
  21166. * - VertexBuffer.ColorKind
  21167. * - VertexBuffer.MatricesIndicesKind
  21168. * - VertexBuffer.MatricesIndicesExtraKind
  21169. * - VertexBuffer.MatricesWeightsKind
  21170. * - VertexBuffer.MatricesWeightsExtraKind
  21171. * @returns a boolean
  21172. */
  21173. isVerticesDataPresent(kind: string): boolean;
  21174. /**
  21175. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21176. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21177. * - VertexBuffer.PositionKind
  21178. * - VertexBuffer.UVKind
  21179. * - VertexBuffer.UV2Kind
  21180. * - VertexBuffer.UV3Kind
  21181. * - VertexBuffer.UV4Kind
  21182. * - VertexBuffer.UV5Kind
  21183. * - VertexBuffer.UV6Kind
  21184. * - VertexBuffer.ColorKind
  21185. * - VertexBuffer.MatricesIndicesKind
  21186. * - VertexBuffer.MatricesIndicesExtraKind
  21187. * - VertexBuffer.MatricesWeightsKind
  21188. * - VertexBuffer.MatricesWeightsExtraKind
  21189. * @returns a boolean
  21190. */
  21191. isVertexBufferUpdatable(kind: string): boolean;
  21192. /**
  21193. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21194. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21195. * - VertexBuffer.PositionKind
  21196. * - VertexBuffer.NormalKind
  21197. * - VertexBuffer.UVKind
  21198. * - VertexBuffer.UV2Kind
  21199. * - VertexBuffer.UV3Kind
  21200. * - VertexBuffer.UV4Kind
  21201. * - VertexBuffer.UV5Kind
  21202. * - VertexBuffer.UV6Kind
  21203. * - VertexBuffer.ColorKind
  21204. * - VertexBuffer.MatricesIndicesKind
  21205. * - VertexBuffer.MatricesIndicesExtraKind
  21206. * - VertexBuffer.MatricesWeightsKind
  21207. * - VertexBuffer.MatricesWeightsExtraKind
  21208. * @returns an array of strings
  21209. */
  21210. getVerticesDataKinds(): string[];
  21211. /**
  21212. * Returns a positive integer : the total number of indices in this mesh geometry.
  21213. * @returns the numner of indices or zero if the mesh has no geometry.
  21214. */
  21215. getTotalIndices(): number;
  21216. /**
  21217. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21218. * @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.
  21219. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21220. * @returns the indices array or an empty array if the mesh has no geometry
  21221. */
  21222. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21223. readonly isBlocked: boolean;
  21224. /**
  21225. * Determine if the current mesh is ready to be rendered
  21226. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21227. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21228. * @returns true if all associated assets are ready (material, textures, shaders)
  21229. */
  21230. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21231. /**
  21232. * 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.
  21233. */
  21234. readonly areNormalsFrozen: boolean;
  21235. /**
  21236. * 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.
  21237. * @returns the current mesh
  21238. */
  21239. freezeNormals(): Mesh;
  21240. /**
  21241. * 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
  21242. * @returns the current mesh
  21243. */
  21244. unfreezeNormals(): Mesh;
  21245. /**
  21246. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21247. */
  21248. overridenInstanceCount: number;
  21249. /** @hidden */
  21250. _preActivate(): Mesh;
  21251. /** @hidden */
  21252. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21253. /** @hidden */
  21254. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21255. /**
  21256. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21257. * This means the mesh underlying bounding box and sphere are recomputed.
  21258. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21259. * @returns the current mesh
  21260. */
  21261. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21262. /** @hidden */
  21263. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21264. /**
  21265. * This function will subdivide the mesh into multiple submeshes
  21266. * @param count defines the expected number of submeshes
  21267. */
  21268. subdivide(count: number): void;
  21269. /**
  21270. * Copy a FloatArray into a specific associated vertex buffer
  21271. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21272. * - VertexBuffer.PositionKind
  21273. * - VertexBuffer.UVKind
  21274. * - VertexBuffer.UV2Kind
  21275. * - VertexBuffer.UV3Kind
  21276. * - VertexBuffer.UV4Kind
  21277. * - VertexBuffer.UV5Kind
  21278. * - VertexBuffer.UV6Kind
  21279. * - VertexBuffer.ColorKind
  21280. * - VertexBuffer.MatricesIndicesKind
  21281. * - VertexBuffer.MatricesIndicesExtraKind
  21282. * - VertexBuffer.MatricesWeightsKind
  21283. * - VertexBuffer.MatricesWeightsExtraKind
  21284. * @param data defines the data source
  21285. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21286. * @param stride defines the data stride size (can be null)
  21287. * @returns the current mesh
  21288. */
  21289. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21290. /**
  21291. * Flags an associated vertex buffer as updatable
  21292. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21293. * - VertexBuffer.PositionKind
  21294. * - VertexBuffer.UVKind
  21295. * - VertexBuffer.UV2Kind
  21296. * - VertexBuffer.UV3Kind
  21297. * - VertexBuffer.UV4Kind
  21298. * - VertexBuffer.UV5Kind
  21299. * - VertexBuffer.UV6Kind
  21300. * - VertexBuffer.ColorKind
  21301. * - VertexBuffer.MatricesIndicesKind
  21302. * - VertexBuffer.MatricesIndicesExtraKind
  21303. * - VertexBuffer.MatricesWeightsKind
  21304. * - VertexBuffer.MatricesWeightsExtraKind
  21305. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21306. */
  21307. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21308. /**
  21309. * Sets the mesh global Vertex Buffer
  21310. * @param buffer defines the buffer to use
  21311. * @returns the current mesh
  21312. */
  21313. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21314. /**
  21315. * Update a specific associated vertex buffer
  21316. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21317. * - VertexBuffer.PositionKind
  21318. * - VertexBuffer.UVKind
  21319. * - VertexBuffer.UV2Kind
  21320. * - VertexBuffer.UV3Kind
  21321. * - VertexBuffer.UV4Kind
  21322. * - VertexBuffer.UV5Kind
  21323. * - VertexBuffer.UV6Kind
  21324. * - VertexBuffer.ColorKind
  21325. * - VertexBuffer.MatricesIndicesKind
  21326. * - VertexBuffer.MatricesIndicesExtraKind
  21327. * - VertexBuffer.MatricesWeightsKind
  21328. * - VertexBuffer.MatricesWeightsExtraKind
  21329. * @param data defines the data source
  21330. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21331. * @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)
  21332. * @returns the current mesh
  21333. */
  21334. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21335. /**
  21336. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21337. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21338. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21339. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21340. * @returns the current mesh
  21341. */
  21342. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21343. /**
  21344. * Creates a un-shared specific occurence of the geometry for the mesh.
  21345. * @returns the current mesh
  21346. */
  21347. makeGeometryUnique(): Mesh;
  21348. /**
  21349. * Set the index buffer of this mesh
  21350. * @param indices defines the source data
  21351. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21352. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21353. * @returns the current mesh
  21354. */
  21355. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21356. /**
  21357. * Update the current index buffer
  21358. * @param indices defines the source data
  21359. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21360. * @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)
  21361. * @returns the current mesh
  21362. */
  21363. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21364. /**
  21365. * Invert the geometry to move from a right handed system to a left handed one.
  21366. * @returns the current mesh
  21367. */
  21368. toLeftHanded(): Mesh;
  21369. /** @hidden */
  21370. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21371. /** @hidden */
  21372. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21373. /**
  21374. * Registers for this mesh a javascript function called just before the rendering process
  21375. * @param func defines the function to call before rendering this mesh
  21376. * @returns the current mesh
  21377. */
  21378. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21379. /**
  21380. * Disposes a previously registered javascript function called before the rendering
  21381. * @param func defines the function to remove
  21382. * @returns the current mesh
  21383. */
  21384. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21385. /**
  21386. * Registers for this mesh a javascript function called just after the rendering is complete
  21387. * @param func defines the function to call after rendering this mesh
  21388. * @returns the current mesh
  21389. */
  21390. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21391. /**
  21392. * Disposes a previously registered javascript function called after the rendering.
  21393. * @param func defines the function to remove
  21394. * @returns the current mesh
  21395. */
  21396. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21397. /** @hidden */
  21398. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21399. /** @hidden */
  21400. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21401. /** @hidden */
  21402. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21403. /** @hidden */
  21404. _freeze(): void;
  21405. /** @hidden */
  21406. _unFreeze(): void;
  21407. /**
  21408. * 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
  21409. * @param subMesh defines the subMesh to render
  21410. * @param enableAlphaMode defines if alpha mode can be changed
  21411. * @returns the current mesh
  21412. */
  21413. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21414. private _onBeforeDraw;
  21415. /**
  21416. * Renormalize the mesh and patch it up if there are no weights
  21417. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21418. * However in the case of zero weights then we set just a single influence to 1.
  21419. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21420. */
  21421. cleanMatrixWeights(): void;
  21422. private normalizeSkinFourWeights;
  21423. private normalizeSkinWeightsAndExtra;
  21424. /**
  21425. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21426. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21427. * the user know there was an issue with importing the mesh
  21428. * @returns a validation object with skinned, valid and report string
  21429. */
  21430. validateSkinning(): {
  21431. skinned: boolean;
  21432. valid: boolean;
  21433. report: string;
  21434. };
  21435. /** @hidden */
  21436. _checkDelayState(): Mesh;
  21437. private _queueLoad;
  21438. /**
  21439. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21440. * A mesh is in the frustum if its bounding box intersects the frustum
  21441. * @param frustumPlanes defines the frustum to test
  21442. * @returns true if the mesh is in the frustum planes
  21443. */
  21444. isInFrustum(frustumPlanes: Plane[]): boolean;
  21445. /**
  21446. * Sets the mesh material by the material or multiMaterial `id` property
  21447. * @param id is a string identifying the material or the multiMaterial
  21448. * @returns the current mesh
  21449. */
  21450. setMaterialByID(id: string): Mesh;
  21451. /**
  21452. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21453. * @returns an array of IAnimatable
  21454. */
  21455. getAnimatables(): IAnimatable[];
  21456. /**
  21457. * Modifies the mesh geometry according to the passed transformation matrix.
  21458. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21459. * The mesh normals are modified using the same transformation.
  21460. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21461. * @param transform defines the transform matrix to use
  21462. * @see http://doc.babylonjs.com/resources/baking_transformations
  21463. * @returns the current mesh
  21464. */
  21465. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21466. /**
  21467. * Modifies the mesh geometry according to its own current World Matrix.
  21468. * The mesh World Matrix is then reset.
  21469. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21470. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21471. * @see http://doc.babylonjs.com/resources/baking_transformations
  21472. * @returns the current mesh
  21473. */
  21474. bakeCurrentTransformIntoVertices(): Mesh;
  21475. /** @hidden */
  21476. readonly _positions: Nullable<Vector3[]>;
  21477. /** @hidden */
  21478. _resetPointsArrayCache(): Mesh;
  21479. /** @hidden */
  21480. _generatePointsArray(): boolean;
  21481. /**
  21482. * Returns a new Mesh object generated from the current mesh properties.
  21483. * This method must not get confused with createInstance()
  21484. * @param name is a string, the name given to the new mesh
  21485. * @param newParent can be any Node object (default `null`)
  21486. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21487. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21488. * @returns a new mesh
  21489. */
  21490. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21491. /**
  21492. * Releases resources associated with this mesh.
  21493. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21494. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21495. */
  21496. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21497. /**
  21498. * Modifies the mesh geometry according to a displacement map.
  21499. * 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.
  21500. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21501. * @param url is a string, the URL from the image file is to be downloaded.
  21502. * @param minHeight is the lower limit of the displacement.
  21503. * @param maxHeight is the upper limit of the displacement.
  21504. * @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.
  21505. * @param uvOffset is an optional vector2 used to offset UV.
  21506. * @param uvScale is an optional vector2 used to scale UV.
  21507. * @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.
  21508. * @returns the Mesh.
  21509. */
  21510. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21511. /**
  21512. * Modifies the mesh geometry according to a displacementMap buffer.
  21513. * 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.
  21514. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21515. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21516. * @param heightMapWidth is the width of the buffer image.
  21517. * @param heightMapHeight is the height of the buffer image.
  21518. * @param minHeight is the lower limit of the displacement.
  21519. * @param maxHeight is the upper limit of the displacement.
  21520. * @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.
  21521. * @param uvOffset is an optional vector2 used to offset UV.
  21522. * @param uvScale is an optional vector2 used to scale UV.
  21523. * @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.
  21524. * @returns the Mesh.
  21525. */
  21526. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21527. /**
  21528. * Modify the mesh to get a flat shading rendering.
  21529. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21530. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21531. * @returns current mesh
  21532. */
  21533. convertToFlatShadedMesh(): Mesh;
  21534. /**
  21535. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21536. * In other words, more vertices, no more indices and a single bigger VBO.
  21537. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21538. * @returns current mesh
  21539. */
  21540. convertToUnIndexedMesh(): Mesh;
  21541. /**
  21542. * Inverses facet orientations.
  21543. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21544. * @param flipNormals will also inverts the normals
  21545. * @returns current mesh
  21546. */
  21547. flipFaces(flipNormals?: boolean): Mesh;
  21548. /**
  21549. * Increase the number of facets and hence vertices in a mesh
  21550. * Vertex normals are interpolated from existing vertex normals
  21551. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21552. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21553. */
  21554. increaseVertices(numberPerEdge: number): void;
  21555. /**
  21556. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21557. * This will undo any application of covertToFlatShadedMesh
  21558. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21559. */
  21560. forceSharedVertices(): void;
  21561. /** @hidden */
  21562. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21563. /** @hidden */
  21564. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21565. /**
  21566. * Creates a new InstancedMesh object from the mesh model.
  21567. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21568. * @param name defines the name of the new instance
  21569. * @returns a new InstancedMesh
  21570. */
  21571. createInstance(name: string): InstancedMesh;
  21572. /**
  21573. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21574. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21575. * @returns the current mesh
  21576. */
  21577. synchronizeInstances(): Mesh;
  21578. /**
  21579. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21580. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21581. * This should be used together with the simplification to avoid disappearing triangles.
  21582. * @param successCallback an optional success callback to be called after the optimization finished.
  21583. * @returns the current mesh
  21584. */
  21585. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21586. /**
  21587. * Serialize current mesh
  21588. * @param serializationObject defines the object which will receive the serialization data
  21589. */
  21590. serialize(serializationObject: any): void;
  21591. /** @hidden */
  21592. _syncGeometryWithMorphTargetManager(): void;
  21593. /** @hidden */
  21594. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21595. /**
  21596. * Returns a new Mesh object parsed from the source provided.
  21597. * @param parsedMesh is the source
  21598. * @param scene defines the hosting scene
  21599. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21600. * @returns a new Mesh
  21601. */
  21602. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21603. /**
  21604. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21605. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21606. * @param name defines the name of the mesh to create
  21607. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21608. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21609. * @param closePath creates a seam between the first and the last points of each path of the path array
  21610. * @param offset is taken in account only if the `pathArray` is containing a single path
  21611. * @param scene defines the hosting scene
  21612. * @param updatable defines if the mesh must be flagged as updatable
  21613. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21614. * @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)
  21615. * @returns a new Mesh
  21616. */
  21617. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21618. /**
  21619. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21620. * @param name defines the name of the mesh to create
  21621. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21622. * @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
  21623. * @param scene defines the hosting scene
  21624. * @param updatable defines if the mesh must be flagged as updatable
  21625. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21626. * @returns a new Mesh
  21627. */
  21628. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21629. /**
  21630. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21631. * @param name defines the name of the mesh to create
  21632. * @param size sets the size (float) of each box side (default 1)
  21633. * @param scene defines the hosting scene
  21634. * @param updatable defines if the mesh must be flagged as updatable
  21635. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21636. * @returns a new Mesh
  21637. */
  21638. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21639. /**
  21640. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21641. * @param name defines the name of the mesh to create
  21642. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21643. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21644. * @param scene defines the hosting scene
  21645. * @param updatable defines if the mesh must be flagged as updatable
  21646. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21647. * @returns a new Mesh
  21648. */
  21649. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21650. /**
  21651. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21652. * @param name defines the name of the mesh to create
  21653. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21654. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21655. * @param scene defines the hosting scene
  21656. * @returns a new Mesh
  21657. */
  21658. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21659. /**
  21660. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21661. * @param name defines the name of the mesh to create
  21662. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21663. * @param diameterTop set the top cap diameter (floats, default 1)
  21664. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21665. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21666. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21667. * @param scene defines the hosting scene
  21668. * @param updatable defines if the mesh must be flagged as updatable
  21669. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21670. * @returns a new Mesh
  21671. */
  21672. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21673. /**
  21674. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21675. * @param name defines the name of the mesh to create
  21676. * @param diameter sets the diameter size (float) of the torus (default 1)
  21677. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21678. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21679. * @param scene defines the hosting scene
  21680. * @param updatable defines if the mesh must be flagged as updatable
  21681. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21682. * @returns a new Mesh
  21683. */
  21684. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21685. /**
  21686. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21687. * @param name defines the name of the mesh to create
  21688. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21689. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21690. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21691. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21692. * @param p the number of windings on X axis (positive integers, default 2)
  21693. * @param q the number of windings on Y axis (positive integers, default 3)
  21694. * @param scene defines the hosting scene
  21695. * @param updatable defines if the mesh must be flagged as updatable
  21696. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21697. * @returns a new Mesh
  21698. */
  21699. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21700. /**
  21701. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21702. * @param name defines the name of the mesh to create
  21703. * @param points is an array successive Vector3
  21704. * @param scene defines the hosting scene
  21705. * @param updatable defines if the mesh must be flagged as updatable
  21706. * @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).
  21707. * @returns a new Mesh
  21708. */
  21709. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21710. /**
  21711. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21712. * @param name defines the name of the mesh to create
  21713. * @param points is an array successive Vector3
  21714. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21715. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21716. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21717. * @param scene defines the hosting scene
  21718. * @param updatable defines if the mesh must be flagged as updatable
  21719. * @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)
  21720. * @returns a new Mesh
  21721. */
  21722. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21723. /**
  21724. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21725. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21726. * 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.
  21727. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21728. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21729. * Remember you can only change the shape positions, not their number when updating a polygon.
  21730. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21731. * @param name defines the name of the mesh to create
  21732. * @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
  21733. * @param scene defines the hosting scene
  21734. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21735. * @param updatable defines if the mesh must be flagged as updatable
  21736. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21737. * @param earcutInjection can be used to inject your own earcut reference
  21738. * @returns a new Mesh
  21739. */
  21740. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21741. /**
  21742. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21743. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21744. * @param name defines the name of the mesh to create
  21745. * @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
  21746. * @param depth defines the height of extrusion
  21747. * @param scene defines the hosting scene
  21748. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21749. * @param updatable defines if the mesh must be flagged as updatable
  21750. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21751. * @param earcutInjection can be used to inject your own earcut reference
  21752. * @returns a new Mesh
  21753. */
  21754. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21755. /**
  21756. * Creates an extruded shape mesh.
  21757. * 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
  21758. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21759. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21760. * @param name defines the name of the mesh to create
  21761. * @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
  21762. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21763. * @param scale is the value to scale the shape
  21764. * @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
  21765. * @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
  21766. * @param scene defines the hosting scene
  21767. * @param updatable defines if the mesh must be flagged as updatable
  21768. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21769. * @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)
  21770. * @returns a new Mesh
  21771. */
  21772. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21773. /**
  21774. * Creates an custom extruded shape mesh.
  21775. * The custom extrusion is a parametric shape.
  21776. * It has no predefined shape. Its final shape will depend on the input parameters.
  21777. * Please consider using the same method from the MeshBuilder class instead
  21778. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21779. * @param name defines the name of the mesh to create
  21780. * @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
  21781. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21782. * @param scaleFunction is a custom Javascript function called on each path point
  21783. * @param rotationFunction is a custom Javascript function called on each path point
  21784. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21785. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21786. * @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
  21787. * @param scene defines the hosting scene
  21788. * @param updatable defines if the mesh must be flagged as updatable
  21789. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21790. * @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)
  21791. * @returns a new Mesh
  21792. */
  21793. 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;
  21794. /**
  21795. * Creates lathe mesh.
  21796. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21797. * Please consider using the same method from the MeshBuilder class instead
  21798. * @param name defines the name of the mesh to create
  21799. * @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
  21800. * @param radius is the radius value of the lathe
  21801. * @param tessellation is the side number of the lathe.
  21802. * @param scene defines the hosting scene
  21803. * @param updatable defines if the mesh must be flagged as updatable
  21804. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21805. * @returns a new Mesh
  21806. */
  21807. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21808. /**
  21809. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21810. * @param name defines the name of the mesh to create
  21811. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21812. * @param scene defines the hosting scene
  21813. * @param updatable defines if the mesh must be flagged as updatable
  21814. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21815. * @returns a new Mesh
  21816. */
  21817. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21818. /**
  21819. * Creates a ground mesh.
  21820. * Please consider using the same method from the MeshBuilder class instead
  21821. * @param name defines the name of the mesh to create
  21822. * @param width set the width of the ground
  21823. * @param height set the height of the ground
  21824. * @param subdivisions sets the number of subdivisions per side
  21825. * @param scene defines the hosting scene
  21826. * @param updatable defines if the mesh must be flagged as updatable
  21827. * @returns a new Mesh
  21828. */
  21829. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21830. /**
  21831. * Creates a tiled ground mesh.
  21832. * Please consider using the same method from the MeshBuilder class instead
  21833. * @param name defines the name of the mesh to create
  21834. * @param xmin set the ground minimum X coordinate
  21835. * @param zmin set the ground minimum Y coordinate
  21836. * @param xmax set the ground maximum X coordinate
  21837. * @param zmax set the ground maximum Z coordinate
  21838. * @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
  21839. * @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
  21840. * @param scene defines the hosting scene
  21841. * @param updatable defines if the mesh must be flagged as updatable
  21842. * @returns a new Mesh
  21843. */
  21844. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21845. w: number;
  21846. h: number;
  21847. }, precision: {
  21848. w: number;
  21849. h: number;
  21850. }, scene: Scene, updatable?: boolean): Mesh;
  21851. /**
  21852. * Creates a ground mesh from a height map.
  21853. * Please consider using the same method from the MeshBuilder class instead
  21854. * @see http://doc.babylonjs.com/babylon101/height_map
  21855. * @param name defines the name of the mesh to create
  21856. * @param url sets the URL of the height map image resource
  21857. * @param width set the ground width size
  21858. * @param height set the ground height size
  21859. * @param subdivisions sets the number of subdivision per side
  21860. * @param minHeight is the minimum altitude on the ground
  21861. * @param maxHeight is the maximum altitude on the ground
  21862. * @param scene defines the hosting scene
  21863. * @param updatable defines if the mesh must be flagged as updatable
  21864. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21865. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21866. * @returns a new Mesh
  21867. */
  21868. 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;
  21869. /**
  21870. * Creates a tube mesh.
  21871. * The tube is a parametric shape.
  21872. * It has no predefined shape. Its final shape will depend on the input parameters.
  21873. * Please consider using the same method from the MeshBuilder class instead
  21874. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21875. * @param name defines the name of the mesh to create
  21876. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21877. * @param radius sets the tube radius size
  21878. * @param tessellation is the number of sides on the tubular surface
  21879. * @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
  21880. * @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
  21881. * @param scene defines the hosting scene
  21882. * @param updatable defines if the mesh must be flagged as updatable
  21883. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21884. * @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)
  21885. * @returns a new Mesh
  21886. */
  21887. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21888. (i: number, distance: number): number;
  21889. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21890. /**
  21891. * Creates a polyhedron mesh.
  21892. * Please consider using the same method from the MeshBuilder class instead.
  21893. * * 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
  21894. * * The parameter `size` (positive float, default 1) sets the polygon size
  21895. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21896. * * 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`
  21897. * * 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
  21898. * * 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)`)
  21899. * * 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
  21900. * * 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
  21901. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21902. * * 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
  21903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21904. * @param name defines the name of the mesh to create
  21905. * @param options defines the options used to create the mesh
  21906. * @param scene defines the hosting scene
  21907. * @returns a new Mesh
  21908. */
  21909. static CreatePolyhedron(name: string, options: {
  21910. type?: number;
  21911. size?: number;
  21912. sizeX?: number;
  21913. sizeY?: number;
  21914. sizeZ?: number;
  21915. custom?: any;
  21916. faceUV?: Vector4[];
  21917. faceColors?: Color4[];
  21918. updatable?: boolean;
  21919. sideOrientation?: number;
  21920. }, scene: Scene): Mesh;
  21921. /**
  21922. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21923. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21924. * * 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`)
  21925. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21926. * * 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
  21927. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21928. * * 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
  21929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21930. * @param name defines the name of the mesh
  21931. * @param options defines the options used to create the mesh
  21932. * @param scene defines the hosting scene
  21933. * @returns a new Mesh
  21934. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21935. */
  21936. static CreateIcoSphere(name: string, options: {
  21937. radius?: number;
  21938. flat?: boolean;
  21939. subdivisions?: number;
  21940. sideOrientation?: number;
  21941. updatable?: boolean;
  21942. }, scene: Scene): Mesh;
  21943. /**
  21944. * Creates a decal mesh.
  21945. * Please consider using the same method from the MeshBuilder class instead.
  21946. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21947. * @param name defines the name of the mesh
  21948. * @param sourceMesh defines the mesh receiving the decal
  21949. * @param position sets the position of the decal in world coordinates
  21950. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21951. * @param size sets the decal scaling
  21952. * @param angle sets the angle to rotate the decal
  21953. * @returns a new Mesh
  21954. */
  21955. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21956. /**
  21957. * Prepare internal position array for software CPU skinning
  21958. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21959. */
  21960. setPositionsForCPUSkinning(): Float32Array;
  21961. /**
  21962. * Prepare internal normal array for software CPU skinning
  21963. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21964. */
  21965. setNormalsForCPUSkinning(): Float32Array;
  21966. /**
  21967. * Updates the vertex buffer by applying transformation from the bones
  21968. * @param skeleton defines the skeleton to apply to current mesh
  21969. * @returns the current mesh
  21970. */
  21971. applySkeleton(skeleton: Skeleton): Mesh;
  21972. /**
  21973. * 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
  21974. * @param meshes defines the list of meshes to scan
  21975. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21976. */
  21977. static MinMax(meshes: AbstractMesh[]): {
  21978. min: Vector3;
  21979. max: Vector3;
  21980. };
  21981. /**
  21982. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21983. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21984. * @returns a vector3
  21985. */
  21986. static Center(meshesOrMinMaxVector: {
  21987. min: Vector3;
  21988. max: Vector3;
  21989. } | AbstractMesh[]): Vector3;
  21990. /**
  21991. * Merge the array of meshes into a single mesh for performance reasons.
  21992. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21993. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21994. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21995. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21996. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21997. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21998. * @returns a new mesh
  21999. */
  22000. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22001. /** @hidden */
  22002. addInstance(instance: InstancedMesh): void;
  22003. /** @hidden */
  22004. removeInstance(instance: InstancedMesh): void;
  22005. }
  22006. }
  22007. declare module BABYLON {
  22008. /**
  22009. * Base class for the main features of a material in Babylon.js
  22010. */
  22011. export class Material implements IAnimatable {
  22012. /**
  22013. * Returns the triangle fill mode
  22014. */
  22015. static readonly TriangleFillMode: number;
  22016. /**
  22017. * Returns the wireframe mode
  22018. */
  22019. static readonly WireFrameFillMode: number;
  22020. /**
  22021. * Returns the point fill mode
  22022. */
  22023. static readonly PointFillMode: number;
  22024. /**
  22025. * Returns the point list draw mode
  22026. */
  22027. static readonly PointListDrawMode: number;
  22028. /**
  22029. * Returns the line list draw mode
  22030. */
  22031. static readonly LineListDrawMode: number;
  22032. /**
  22033. * Returns the line loop draw mode
  22034. */
  22035. static readonly LineLoopDrawMode: number;
  22036. /**
  22037. * Returns the line strip draw mode
  22038. */
  22039. static readonly LineStripDrawMode: number;
  22040. /**
  22041. * Returns the triangle strip draw mode
  22042. */
  22043. static readonly TriangleStripDrawMode: number;
  22044. /**
  22045. * Returns the triangle fan draw mode
  22046. */
  22047. static readonly TriangleFanDrawMode: number;
  22048. /**
  22049. * Stores the clock-wise side orientation
  22050. */
  22051. static readonly ClockWiseSideOrientation: number;
  22052. /**
  22053. * Stores the counter clock-wise side orientation
  22054. */
  22055. static readonly CounterClockWiseSideOrientation: number;
  22056. /**
  22057. * The dirty texture flag value
  22058. */
  22059. static readonly TextureDirtyFlag: number;
  22060. /**
  22061. * The dirty light flag value
  22062. */
  22063. static readonly LightDirtyFlag: number;
  22064. /**
  22065. * The dirty fresnel flag value
  22066. */
  22067. static readonly FresnelDirtyFlag: number;
  22068. /**
  22069. * The dirty attribute flag value
  22070. */
  22071. static readonly AttributesDirtyFlag: number;
  22072. /**
  22073. * The dirty misc flag value
  22074. */
  22075. static readonly MiscDirtyFlag: number;
  22076. /**
  22077. * The all dirty flag value
  22078. */
  22079. static readonly AllDirtyFlag: number;
  22080. /**
  22081. * The ID of the material
  22082. */
  22083. id: string;
  22084. /**
  22085. * Gets or sets the unique id of the material
  22086. */
  22087. uniqueId: number;
  22088. /**
  22089. * The name of the material
  22090. */
  22091. name: string;
  22092. /**
  22093. * Gets or sets user defined metadata
  22094. */
  22095. metadata: any;
  22096. /**
  22097. * For internal use only. Please do not use.
  22098. */
  22099. reservedDataStore: any;
  22100. /**
  22101. * Specifies if the ready state should be checked on each call
  22102. */
  22103. checkReadyOnEveryCall: boolean;
  22104. /**
  22105. * Specifies if the ready state should be checked once
  22106. */
  22107. checkReadyOnlyOnce: boolean;
  22108. /**
  22109. * The state of the material
  22110. */
  22111. state: string;
  22112. /**
  22113. * The alpha value of the material
  22114. */
  22115. protected _alpha: number;
  22116. /**
  22117. * List of inspectable custom properties (used by the Inspector)
  22118. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22119. */
  22120. inspectableCustomProperties: IInspectable[];
  22121. /**
  22122. * Sets the alpha value of the material
  22123. */
  22124. /**
  22125. * Gets the alpha value of the material
  22126. */
  22127. alpha: number;
  22128. /**
  22129. * Specifies if back face culling is enabled
  22130. */
  22131. protected _backFaceCulling: boolean;
  22132. /**
  22133. * Sets the back-face culling state
  22134. */
  22135. /**
  22136. * Gets the back-face culling state
  22137. */
  22138. backFaceCulling: boolean;
  22139. /**
  22140. * Stores the value for side orientation
  22141. */
  22142. sideOrientation: number;
  22143. /**
  22144. * Callback triggered when the material is compiled
  22145. */
  22146. onCompiled: Nullable<(effect: Effect) => void>;
  22147. /**
  22148. * Callback triggered when an error occurs
  22149. */
  22150. onError: Nullable<(effect: Effect, errors: string) => void>;
  22151. /**
  22152. * Callback triggered to get the render target textures
  22153. */
  22154. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22155. /**
  22156. * Gets a boolean indicating that current material needs to register RTT
  22157. */
  22158. readonly hasRenderTargetTextures: boolean;
  22159. /**
  22160. * Specifies if the material should be serialized
  22161. */
  22162. doNotSerialize: boolean;
  22163. /**
  22164. * @hidden
  22165. */
  22166. _storeEffectOnSubMeshes: boolean;
  22167. /**
  22168. * Stores the animations for the material
  22169. */
  22170. animations: Nullable<Array<Animation>>;
  22171. /**
  22172. * An event triggered when the material is disposed
  22173. */
  22174. onDisposeObservable: Observable<Material>;
  22175. /**
  22176. * An observer which watches for dispose events
  22177. */
  22178. private _onDisposeObserver;
  22179. private _onUnBindObservable;
  22180. /**
  22181. * Called during a dispose event
  22182. */
  22183. onDispose: () => void;
  22184. private _onBindObservable;
  22185. /**
  22186. * An event triggered when the material is bound
  22187. */
  22188. readonly onBindObservable: Observable<AbstractMesh>;
  22189. /**
  22190. * An observer which watches for bind events
  22191. */
  22192. private _onBindObserver;
  22193. /**
  22194. * Called during a bind event
  22195. */
  22196. onBind: (Mesh: AbstractMesh) => void;
  22197. /**
  22198. * An event triggered when the material is unbound
  22199. */
  22200. readonly onUnBindObservable: Observable<Material>;
  22201. /**
  22202. * Stores the value of the alpha mode
  22203. */
  22204. private _alphaMode;
  22205. /**
  22206. * Sets the value of the alpha mode.
  22207. *
  22208. * | Value | Type | Description |
  22209. * | --- | --- | --- |
  22210. * | 0 | ALPHA_DISABLE | |
  22211. * | 1 | ALPHA_ADD | |
  22212. * | 2 | ALPHA_COMBINE | |
  22213. * | 3 | ALPHA_SUBTRACT | |
  22214. * | 4 | ALPHA_MULTIPLY | |
  22215. * | 5 | ALPHA_MAXIMIZED | |
  22216. * | 6 | ALPHA_ONEONE | |
  22217. * | 7 | ALPHA_PREMULTIPLIED | |
  22218. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22219. * | 9 | ALPHA_INTERPOLATE | |
  22220. * | 10 | ALPHA_SCREENMODE | |
  22221. *
  22222. */
  22223. /**
  22224. * Gets the value of the alpha mode
  22225. */
  22226. alphaMode: number;
  22227. /**
  22228. * Stores the state of the need depth pre-pass value
  22229. */
  22230. private _needDepthPrePass;
  22231. /**
  22232. * Sets the need depth pre-pass value
  22233. */
  22234. /**
  22235. * Gets the depth pre-pass value
  22236. */
  22237. needDepthPrePass: boolean;
  22238. /**
  22239. * Specifies if depth writing should be disabled
  22240. */
  22241. disableDepthWrite: boolean;
  22242. /**
  22243. * Specifies if depth writing should be forced
  22244. */
  22245. forceDepthWrite: boolean;
  22246. /**
  22247. * Specifies if there should be a separate pass for culling
  22248. */
  22249. separateCullingPass: boolean;
  22250. /**
  22251. * Stores the state specifing if fog should be enabled
  22252. */
  22253. private _fogEnabled;
  22254. /**
  22255. * Sets the state for enabling fog
  22256. */
  22257. /**
  22258. * Gets the value of the fog enabled state
  22259. */
  22260. fogEnabled: boolean;
  22261. /**
  22262. * Stores the size of points
  22263. */
  22264. pointSize: number;
  22265. /**
  22266. * Stores the z offset value
  22267. */
  22268. zOffset: number;
  22269. /**
  22270. * Gets a value specifying if wireframe mode is enabled
  22271. */
  22272. /**
  22273. * Sets the state of wireframe mode
  22274. */
  22275. wireframe: boolean;
  22276. /**
  22277. * Gets the value specifying if point clouds are enabled
  22278. */
  22279. /**
  22280. * Sets the state of point cloud mode
  22281. */
  22282. pointsCloud: boolean;
  22283. /**
  22284. * Gets the material fill mode
  22285. */
  22286. /**
  22287. * Sets the material fill mode
  22288. */
  22289. fillMode: number;
  22290. /**
  22291. * @hidden
  22292. * Stores the effects for the material
  22293. */
  22294. _effect: Nullable<Effect>;
  22295. /**
  22296. * @hidden
  22297. * Specifies if the material was previously ready
  22298. */
  22299. _wasPreviouslyReady: boolean;
  22300. /**
  22301. * Specifies if uniform buffers should be used
  22302. */
  22303. private _useUBO;
  22304. /**
  22305. * Stores a reference to the scene
  22306. */
  22307. private _scene;
  22308. /**
  22309. * Stores the fill mode state
  22310. */
  22311. private _fillMode;
  22312. /**
  22313. * Specifies if the depth write state should be cached
  22314. */
  22315. private _cachedDepthWriteState;
  22316. /**
  22317. * Stores the uniform buffer
  22318. */
  22319. protected _uniformBuffer: UniformBuffer;
  22320. /** @hidden */
  22321. _indexInSceneMaterialArray: number;
  22322. /** @hidden */
  22323. meshMap: Nullable<{
  22324. [id: string]: AbstractMesh | undefined;
  22325. }>;
  22326. /**
  22327. * Creates a material instance
  22328. * @param name defines the name of the material
  22329. * @param scene defines the scene to reference
  22330. * @param doNotAdd specifies if the material should be added to the scene
  22331. */
  22332. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22333. /**
  22334. * Returns a string representation of the current material
  22335. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22336. * @returns a string with material information
  22337. */
  22338. toString(fullDetails?: boolean): string;
  22339. /**
  22340. * Gets the class name of the material
  22341. * @returns a string with the class name of the material
  22342. */
  22343. getClassName(): string;
  22344. /**
  22345. * Specifies if updates for the material been locked
  22346. */
  22347. readonly isFrozen: boolean;
  22348. /**
  22349. * Locks updates for the material
  22350. */
  22351. freeze(): void;
  22352. /**
  22353. * Unlocks updates for the material
  22354. */
  22355. unfreeze(): void;
  22356. /**
  22357. * Specifies if the material is ready to be used
  22358. * @param mesh defines the mesh to check
  22359. * @param useInstances specifies if instances should be used
  22360. * @returns a boolean indicating if the material is ready to be used
  22361. */
  22362. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22363. /**
  22364. * Specifies that the submesh is ready to be used
  22365. * @param mesh defines the mesh to check
  22366. * @param subMesh defines which submesh to check
  22367. * @param useInstances specifies that instances should be used
  22368. * @returns a boolean indicating that the submesh is ready or not
  22369. */
  22370. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22371. /**
  22372. * Returns the material effect
  22373. * @returns the effect associated with the material
  22374. */
  22375. getEffect(): Nullable<Effect>;
  22376. /**
  22377. * Returns the current scene
  22378. * @returns a Scene
  22379. */
  22380. getScene(): Scene;
  22381. /**
  22382. * Specifies if the material will require alpha blending
  22383. * @returns a boolean specifying if alpha blending is needed
  22384. */
  22385. needAlphaBlending(): boolean;
  22386. /**
  22387. * Specifies if the mesh will require alpha blending
  22388. * @param mesh defines the mesh to check
  22389. * @returns a boolean specifying if alpha blending is needed for the mesh
  22390. */
  22391. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22392. /**
  22393. * Specifies if this material should be rendered in alpha test mode
  22394. * @returns a boolean specifying if an alpha test is needed.
  22395. */
  22396. needAlphaTesting(): boolean;
  22397. /**
  22398. * Gets the texture used for the alpha test
  22399. * @returns the texture to use for alpha testing
  22400. */
  22401. getAlphaTestTexture(): Nullable<BaseTexture>;
  22402. /**
  22403. * Marks the material to indicate that it needs to be re-calculated
  22404. */
  22405. markDirty(): void;
  22406. /** @hidden */
  22407. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22408. /**
  22409. * Binds the material to the mesh
  22410. * @param world defines the world transformation matrix
  22411. * @param mesh defines the mesh to bind the material to
  22412. */
  22413. bind(world: Matrix, mesh?: Mesh): void;
  22414. /**
  22415. * Binds the submesh to the material
  22416. * @param world defines the world transformation matrix
  22417. * @param mesh defines the mesh containing the submesh
  22418. * @param subMesh defines the submesh to bind the material to
  22419. */
  22420. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22421. /**
  22422. * Binds the world matrix to the material
  22423. * @param world defines the world transformation matrix
  22424. */
  22425. bindOnlyWorldMatrix(world: Matrix): void;
  22426. /**
  22427. * Binds the scene's uniform buffer to the effect.
  22428. * @param effect defines the effect to bind to the scene uniform buffer
  22429. * @param sceneUbo defines the uniform buffer storing scene data
  22430. */
  22431. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22432. /**
  22433. * Binds the view matrix to the effect
  22434. * @param effect defines the effect to bind the view matrix to
  22435. */
  22436. bindView(effect: Effect): void;
  22437. /**
  22438. * Binds the view projection matrix to the effect
  22439. * @param effect defines the effect to bind the view projection matrix to
  22440. */
  22441. bindViewProjection(effect: Effect): void;
  22442. /**
  22443. * Specifies if material alpha testing should be turned on for the mesh
  22444. * @param mesh defines the mesh to check
  22445. */
  22446. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22447. /**
  22448. * Processes to execute after binding the material to a mesh
  22449. * @param mesh defines the rendered mesh
  22450. */
  22451. protected _afterBind(mesh?: Mesh): void;
  22452. /**
  22453. * Unbinds the material from the mesh
  22454. */
  22455. unbind(): void;
  22456. /**
  22457. * Gets the active textures from the material
  22458. * @returns an array of textures
  22459. */
  22460. getActiveTextures(): BaseTexture[];
  22461. /**
  22462. * Specifies if the material uses a texture
  22463. * @param texture defines the texture to check against the material
  22464. * @returns a boolean specifying if the material uses the texture
  22465. */
  22466. hasTexture(texture: BaseTexture): boolean;
  22467. /**
  22468. * Makes a duplicate of the material, and gives it a new name
  22469. * @param name defines the new name for the duplicated material
  22470. * @returns the cloned material
  22471. */
  22472. clone(name: string): Nullable<Material>;
  22473. /**
  22474. * Gets the meshes bound to the material
  22475. * @returns an array of meshes bound to the material
  22476. */
  22477. getBindedMeshes(): AbstractMesh[];
  22478. /**
  22479. * Force shader compilation
  22480. * @param mesh defines the mesh associated with this material
  22481. * @param onCompiled defines a function to execute once the material is compiled
  22482. * @param options defines the options to configure the compilation
  22483. */
  22484. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22485. clipPlane: boolean;
  22486. }>): void;
  22487. /**
  22488. * Force shader compilation
  22489. * @param mesh defines the mesh that will use this material
  22490. * @param options defines additional options for compiling the shaders
  22491. * @returns a promise that resolves when the compilation completes
  22492. */
  22493. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22494. clipPlane: boolean;
  22495. }>): Promise<void>;
  22496. private static readonly _AllDirtyCallBack;
  22497. private static readonly _ImageProcessingDirtyCallBack;
  22498. private static readonly _TextureDirtyCallBack;
  22499. private static readonly _FresnelDirtyCallBack;
  22500. private static readonly _MiscDirtyCallBack;
  22501. private static readonly _LightsDirtyCallBack;
  22502. private static readonly _AttributeDirtyCallBack;
  22503. private static _FresnelAndMiscDirtyCallBack;
  22504. private static _TextureAndMiscDirtyCallBack;
  22505. private static readonly _DirtyCallbackArray;
  22506. private static readonly _RunDirtyCallBacks;
  22507. /**
  22508. * Marks a define in the material to indicate that it needs to be re-computed
  22509. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22510. */
  22511. markAsDirty(flag: number): void;
  22512. /**
  22513. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22514. * @param func defines a function which checks material defines against the submeshes
  22515. */
  22516. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22517. /**
  22518. * Indicates that we need to re-calculated for all submeshes
  22519. */
  22520. protected _markAllSubMeshesAsAllDirty(): void;
  22521. /**
  22522. * Indicates that image processing needs to be re-calculated for all submeshes
  22523. */
  22524. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22525. /**
  22526. * Indicates that textures need to be re-calculated for all submeshes
  22527. */
  22528. protected _markAllSubMeshesAsTexturesDirty(): void;
  22529. /**
  22530. * Indicates that fresnel needs to be re-calculated for all submeshes
  22531. */
  22532. protected _markAllSubMeshesAsFresnelDirty(): void;
  22533. /**
  22534. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22535. */
  22536. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22537. /**
  22538. * Indicates that lights need to be re-calculated for all submeshes
  22539. */
  22540. protected _markAllSubMeshesAsLightsDirty(): void;
  22541. /**
  22542. * Indicates that attributes need to be re-calculated for all submeshes
  22543. */
  22544. protected _markAllSubMeshesAsAttributesDirty(): void;
  22545. /**
  22546. * Indicates that misc needs to be re-calculated for all submeshes
  22547. */
  22548. protected _markAllSubMeshesAsMiscDirty(): void;
  22549. /**
  22550. * Indicates that textures and misc need to be re-calculated for all submeshes
  22551. */
  22552. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22553. /**
  22554. * Disposes the material
  22555. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22556. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22557. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22558. */
  22559. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22560. /** @hidden */
  22561. private releaseVertexArrayObject;
  22562. /**
  22563. * Serializes this material
  22564. * @returns the serialized material object
  22565. */
  22566. serialize(): any;
  22567. /**
  22568. * Creates a material from parsed material data
  22569. * @param parsedMaterial defines parsed material data
  22570. * @param scene defines the hosting scene
  22571. * @param rootUrl defines the root URL to use to load textures
  22572. * @returns a new material
  22573. */
  22574. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22575. }
  22576. }
  22577. declare module BABYLON {
  22578. /**
  22579. * Base class for submeshes
  22580. */
  22581. export class BaseSubMesh {
  22582. /** @hidden */
  22583. _materialDefines: Nullable<MaterialDefines>;
  22584. /** @hidden */
  22585. _materialEffect: Nullable<Effect>;
  22586. /**
  22587. * Gets associated effect
  22588. */
  22589. readonly effect: Nullable<Effect>;
  22590. /**
  22591. * Sets associated effect (effect used to render this submesh)
  22592. * @param effect defines the effect to associate with
  22593. * @param defines defines the set of defines used to compile this effect
  22594. */
  22595. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22596. }
  22597. /**
  22598. * Defines a subdivision inside a mesh
  22599. */
  22600. export class SubMesh extends BaseSubMesh implements ICullable {
  22601. /** the material index to use */
  22602. materialIndex: number;
  22603. /** vertex index start */
  22604. verticesStart: number;
  22605. /** vertices count */
  22606. verticesCount: number;
  22607. /** index start */
  22608. indexStart: number;
  22609. /** indices count */
  22610. indexCount: number;
  22611. /** @hidden */
  22612. _linesIndexCount: number;
  22613. private _mesh;
  22614. private _renderingMesh;
  22615. private _boundingInfo;
  22616. private _linesIndexBuffer;
  22617. /** @hidden */
  22618. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22619. /** @hidden */
  22620. _trianglePlanes: Plane[];
  22621. /** @hidden */
  22622. _lastColliderTransformMatrix: Nullable<Matrix>;
  22623. /** @hidden */
  22624. _renderId: number;
  22625. /** @hidden */
  22626. _alphaIndex: number;
  22627. /** @hidden */
  22628. _distanceToCamera: number;
  22629. /** @hidden */
  22630. _id: number;
  22631. private _currentMaterial;
  22632. /**
  22633. * Add a new submesh to a mesh
  22634. * @param materialIndex defines the material index to use
  22635. * @param verticesStart defines vertex index start
  22636. * @param verticesCount defines vertices count
  22637. * @param indexStart defines index start
  22638. * @param indexCount defines indices count
  22639. * @param mesh defines the parent mesh
  22640. * @param renderingMesh defines an optional rendering mesh
  22641. * @param createBoundingBox defines if bounding box should be created for this submesh
  22642. * @returns the new submesh
  22643. */
  22644. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22645. /**
  22646. * Creates a new submesh
  22647. * @param materialIndex defines the material index to use
  22648. * @param verticesStart defines vertex index start
  22649. * @param verticesCount defines vertices count
  22650. * @param indexStart defines index start
  22651. * @param indexCount defines indices count
  22652. * @param mesh defines the parent mesh
  22653. * @param renderingMesh defines an optional rendering mesh
  22654. * @param createBoundingBox defines if bounding box should be created for this submesh
  22655. */
  22656. constructor(
  22657. /** the material index to use */
  22658. materialIndex: number,
  22659. /** vertex index start */
  22660. verticesStart: number,
  22661. /** vertices count */
  22662. verticesCount: number,
  22663. /** index start */
  22664. indexStart: number,
  22665. /** indices count */
  22666. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22667. /**
  22668. * Returns true if this submesh covers the entire parent mesh
  22669. * @ignorenaming
  22670. */
  22671. readonly IsGlobal: boolean;
  22672. /**
  22673. * Returns the submesh BoudingInfo object
  22674. * @returns current bounding info (or mesh's one if the submesh is global)
  22675. */
  22676. getBoundingInfo(): BoundingInfo;
  22677. /**
  22678. * Sets the submesh BoundingInfo
  22679. * @param boundingInfo defines the new bounding info to use
  22680. * @returns the SubMesh
  22681. */
  22682. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22683. /**
  22684. * Returns the mesh of the current submesh
  22685. * @return the parent mesh
  22686. */
  22687. getMesh(): AbstractMesh;
  22688. /**
  22689. * Returns the rendering mesh of the submesh
  22690. * @returns the rendering mesh (could be different from parent mesh)
  22691. */
  22692. getRenderingMesh(): Mesh;
  22693. /**
  22694. * Returns the submesh material
  22695. * @returns null or the current material
  22696. */
  22697. getMaterial(): Nullable<Material>;
  22698. /**
  22699. * Sets a new updated BoundingInfo object to the submesh
  22700. * @param data defines an optional position array to use to determine the bounding info
  22701. * @returns the SubMesh
  22702. */
  22703. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22704. /** @hidden */
  22705. _checkCollision(collider: Collider): boolean;
  22706. /**
  22707. * Updates the submesh BoundingInfo
  22708. * @param world defines the world matrix to use to update the bounding info
  22709. * @returns the submesh
  22710. */
  22711. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22712. /**
  22713. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22714. * @param frustumPlanes defines the frustum planes
  22715. * @returns true if the submesh is intersecting with the frustum
  22716. */
  22717. isInFrustum(frustumPlanes: Plane[]): boolean;
  22718. /**
  22719. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22720. * @param frustumPlanes defines the frustum planes
  22721. * @returns true if the submesh is inside the frustum
  22722. */
  22723. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22724. /**
  22725. * Renders the submesh
  22726. * @param enableAlphaMode defines if alpha needs to be used
  22727. * @returns the submesh
  22728. */
  22729. render(enableAlphaMode: boolean): SubMesh;
  22730. /**
  22731. * @hidden
  22732. */
  22733. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22734. /**
  22735. * Checks if the submesh intersects with a ray
  22736. * @param ray defines the ray to test
  22737. * @returns true is the passed ray intersects the submesh bounding box
  22738. */
  22739. canIntersects(ray: Ray): boolean;
  22740. /**
  22741. * Intersects current submesh with a ray
  22742. * @param ray defines the ray to test
  22743. * @param positions defines mesh's positions array
  22744. * @param indices defines mesh's indices array
  22745. * @param fastCheck defines if only bounding info should be used
  22746. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22747. * @returns intersection info or null if no intersection
  22748. */
  22749. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22750. /** @hidden */
  22751. private _intersectLines;
  22752. /** @hidden */
  22753. private _intersectUnIndexedLines;
  22754. /** @hidden */
  22755. private _intersectTriangles;
  22756. /** @hidden */
  22757. private _intersectUnIndexedTriangles;
  22758. /** @hidden */
  22759. _rebuild(): void;
  22760. /**
  22761. * Creates a new submesh from the passed mesh
  22762. * @param newMesh defines the new hosting mesh
  22763. * @param newRenderingMesh defines an optional rendering mesh
  22764. * @returns the new submesh
  22765. */
  22766. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22767. /**
  22768. * Release associated resources
  22769. */
  22770. dispose(): void;
  22771. /**
  22772. * Gets the class name
  22773. * @returns the string "SubMesh".
  22774. */
  22775. getClassName(): string;
  22776. /**
  22777. * Creates a new submesh from indices data
  22778. * @param materialIndex the index of the main mesh material
  22779. * @param startIndex the index where to start the copy in the mesh indices array
  22780. * @param indexCount the number of indices to copy then from the startIndex
  22781. * @param mesh the main mesh to create the submesh from
  22782. * @param renderingMesh the optional rendering mesh
  22783. * @returns a new submesh
  22784. */
  22785. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22786. }
  22787. }
  22788. declare module BABYLON {
  22789. /**
  22790. * Class used to store geometry data (vertex buffers + index buffer)
  22791. */
  22792. export class Geometry implements IGetSetVerticesData {
  22793. /**
  22794. * Gets or sets the ID of the geometry
  22795. */
  22796. id: string;
  22797. /**
  22798. * Gets or sets the unique ID of the geometry
  22799. */
  22800. uniqueId: number;
  22801. /**
  22802. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22803. */
  22804. delayLoadState: number;
  22805. /**
  22806. * Gets the file containing the data to load when running in delay load state
  22807. */
  22808. delayLoadingFile: Nullable<string>;
  22809. /**
  22810. * Callback called when the geometry is updated
  22811. */
  22812. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22813. private _scene;
  22814. private _engine;
  22815. private _meshes;
  22816. private _totalVertices;
  22817. /** @hidden */
  22818. _indices: IndicesArray;
  22819. /** @hidden */
  22820. _vertexBuffers: {
  22821. [key: string]: VertexBuffer;
  22822. };
  22823. private _isDisposed;
  22824. private _extend;
  22825. private _boundingBias;
  22826. /** @hidden */
  22827. _delayInfo: Array<string>;
  22828. private _indexBuffer;
  22829. private _indexBufferIsUpdatable;
  22830. /** @hidden */
  22831. _boundingInfo: Nullable<BoundingInfo>;
  22832. /** @hidden */
  22833. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22834. /** @hidden */
  22835. _softwareSkinningFrameId: number;
  22836. private _vertexArrayObjects;
  22837. private _updatable;
  22838. /** @hidden */
  22839. _positions: Nullable<Vector3[]>;
  22840. /**
  22841. * 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
  22842. */
  22843. /**
  22844. * 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
  22845. */
  22846. boundingBias: Vector2;
  22847. /**
  22848. * Static function used to attach a new empty geometry to a mesh
  22849. * @param mesh defines the mesh to attach the geometry to
  22850. * @returns the new Geometry
  22851. */
  22852. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22853. /**
  22854. * Creates a new geometry
  22855. * @param id defines the unique ID
  22856. * @param scene defines the hosting scene
  22857. * @param vertexData defines the VertexData used to get geometry data
  22858. * @param updatable defines if geometry must be updatable (false by default)
  22859. * @param mesh defines the mesh that will be associated with the geometry
  22860. */
  22861. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22862. /**
  22863. * Gets the current extend of the geometry
  22864. */
  22865. readonly extend: {
  22866. minimum: Vector3;
  22867. maximum: Vector3;
  22868. };
  22869. /**
  22870. * Gets the hosting scene
  22871. * @returns the hosting Scene
  22872. */
  22873. getScene(): Scene;
  22874. /**
  22875. * Gets the hosting engine
  22876. * @returns the hosting Engine
  22877. */
  22878. getEngine(): Engine;
  22879. /**
  22880. * Defines if the geometry is ready to use
  22881. * @returns true if the geometry is ready to be used
  22882. */
  22883. isReady(): boolean;
  22884. /**
  22885. * Gets a value indicating that the geometry should not be serialized
  22886. */
  22887. readonly doNotSerialize: boolean;
  22888. /** @hidden */
  22889. _rebuild(): void;
  22890. /**
  22891. * Affects all geometry data in one call
  22892. * @param vertexData defines the geometry data
  22893. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22894. */
  22895. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22896. /**
  22897. * Set specific vertex data
  22898. * @param kind defines the data kind (Position, normal, etc...)
  22899. * @param data defines the vertex data to use
  22900. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22901. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22902. */
  22903. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22904. /**
  22905. * Removes a specific vertex data
  22906. * @param kind defines the data kind (Position, normal, etc...)
  22907. */
  22908. removeVerticesData(kind: string): void;
  22909. /**
  22910. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22911. * @param buffer defines the vertex buffer to use
  22912. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22913. */
  22914. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22915. /**
  22916. * Update a specific vertex buffer
  22917. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22918. * It will do nothing if the buffer is not updatable
  22919. * @param kind defines the data kind (Position, normal, etc...)
  22920. * @param data defines the data to use
  22921. * @param offset defines the offset in the target buffer where to store the data
  22922. * @param useBytes set to true if the offset is in bytes
  22923. */
  22924. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22925. /**
  22926. * Update a specific vertex buffer
  22927. * This function will create a new buffer if the current one is not updatable
  22928. * @param kind defines the data kind (Position, normal, etc...)
  22929. * @param data defines the data to use
  22930. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22931. */
  22932. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22933. private _updateBoundingInfo;
  22934. /** @hidden */
  22935. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22936. /**
  22937. * Gets total number of vertices
  22938. * @returns the total number of vertices
  22939. */
  22940. getTotalVertices(): number;
  22941. /**
  22942. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22943. * @param kind defines the data kind (Position, normal, etc...)
  22944. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22945. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22946. * @returns a float array containing vertex data
  22947. */
  22948. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22949. /**
  22950. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22951. * @param kind defines the data kind (Position, normal, etc...)
  22952. * @returns true if the vertex buffer with the specified kind is updatable
  22953. */
  22954. isVertexBufferUpdatable(kind: string): boolean;
  22955. /**
  22956. * Gets a specific vertex buffer
  22957. * @param kind defines the data kind (Position, normal, etc...)
  22958. * @returns a VertexBuffer
  22959. */
  22960. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22961. /**
  22962. * Returns all vertex buffers
  22963. * @return an object holding all vertex buffers indexed by kind
  22964. */
  22965. getVertexBuffers(): Nullable<{
  22966. [key: string]: VertexBuffer;
  22967. }>;
  22968. /**
  22969. * Gets a boolean indicating if specific vertex buffer is present
  22970. * @param kind defines the data kind (Position, normal, etc...)
  22971. * @returns true if data is present
  22972. */
  22973. isVerticesDataPresent(kind: string): boolean;
  22974. /**
  22975. * Gets a list of all attached data kinds (Position, normal, etc...)
  22976. * @returns a list of string containing all kinds
  22977. */
  22978. getVerticesDataKinds(): string[];
  22979. /**
  22980. * Update index buffer
  22981. * @param indices defines the indices to store in the index buffer
  22982. * @param offset defines the offset in the target buffer where to store the data
  22983. * @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)
  22984. */
  22985. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22986. /**
  22987. * Creates a new index buffer
  22988. * @param indices defines the indices to store in the index buffer
  22989. * @param totalVertices defines the total number of vertices (could be null)
  22990. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22991. */
  22992. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22993. /**
  22994. * Return the total number of indices
  22995. * @returns the total number of indices
  22996. */
  22997. getTotalIndices(): number;
  22998. /**
  22999. * Gets the index buffer array
  23000. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23001. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23002. * @returns the index buffer array
  23003. */
  23004. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23005. /**
  23006. * Gets the index buffer
  23007. * @return the index buffer
  23008. */
  23009. getIndexBuffer(): Nullable<DataBuffer>;
  23010. /** @hidden */
  23011. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23012. /**
  23013. * Release the associated resources for a specific mesh
  23014. * @param mesh defines the source mesh
  23015. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23016. */
  23017. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23018. /**
  23019. * Apply current geometry to a given mesh
  23020. * @param mesh defines the mesh to apply geometry to
  23021. */
  23022. applyToMesh(mesh: Mesh): void;
  23023. private _updateExtend;
  23024. private _applyToMesh;
  23025. private notifyUpdate;
  23026. /**
  23027. * Load the geometry if it was flagged as delay loaded
  23028. * @param scene defines the hosting scene
  23029. * @param onLoaded defines a callback called when the geometry is loaded
  23030. */
  23031. load(scene: Scene, onLoaded?: () => void): void;
  23032. private _queueLoad;
  23033. /**
  23034. * Invert the geometry to move from a right handed system to a left handed one.
  23035. */
  23036. toLeftHanded(): void;
  23037. /** @hidden */
  23038. _resetPointsArrayCache(): void;
  23039. /** @hidden */
  23040. _generatePointsArray(): boolean;
  23041. /**
  23042. * Gets a value indicating if the geometry is disposed
  23043. * @returns true if the geometry was disposed
  23044. */
  23045. isDisposed(): boolean;
  23046. private _disposeVertexArrayObjects;
  23047. /**
  23048. * Free all associated resources
  23049. */
  23050. dispose(): void;
  23051. /**
  23052. * Clone the current geometry into a new geometry
  23053. * @param id defines the unique ID of the new geometry
  23054. * @returns a new geometry object
  23055. */
  23056. copy(id: string): Geometry;
  23057. /**
  23058. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23059. * @return a JSON representation of the current geometry data (without the vertices data)
  23060. */
  23061. serialize(): any;
  23062. private toNumberArray;
  23063. /**
  23064. * Serialize all vertices data into a JSON oject
  23065. * @returns a JSON representation of the current geometry data
  23066. */
  23067. serializeVerticeData(): any;
  23068. /**
  23069. * Extracts a clone of a mesh geometry
  23070. * @param mesh defines the source mesh
  23071. * @param id defines the unique ID of the new geometry object
  23072. * @returns the new geometry object
  23073. */
  23074. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23075. /**
  23076. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23077. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23078. * Be aware Math.random() could cause collisions, but:
  23079. * "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"
  23080. * @returns a string containing a new GUID
  23081. */
  23082. static RandomId(): string;
  23083. /** @hidden */
  23084. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23085. private static _CleanMatricesWeights;
  23086. /**
  23087. * Create a new geometry from persisted data (Using .babylon file format)
  23088. * @param parsedVertexData defines the persisted data
  23089. * @param scene defines the hosting scene
  23090. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23091. * @returns the new geometry object
  23092. */
  23093. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23094. }
  23095. }
  23096. declare module BABYLON {
  23097. /**
  23098. * Define an interface for all classes that will get and set the data on vertices
  23099. */
  23100. export interface IGetSetVerticesData {
  23101. /**
  23102. * Gets a boolean indicating if specific vertex data is present
  23103. * @param kind defines the vertex data kind to use
  23104. * @returns true is data kind is present
  23105. */
  23106. isVerticesDataPresent(kind: string): boolean;
  23107. /**
  23108. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23109. * @param kind defines the data kind (Position, normal, etc...)
  23110. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23111. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23112. * @returns a float array containing vertex data
  23113. */
  23114. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23115. /**
  23116. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23117. * @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.
  23118. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23119. * @returns the indices array or an empty array if the mesh has no geometry
  23120. */
  23121. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23122. /**
  23123. * Set specific vertex data
  23124. * @param kind defines the data kind (Position, normal, etc...)
  23125. * @param data defines the vertex data to use
  23126. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23127. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23128. */
  23129. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23130. /**
  23131. * Update a specific associated vertex buffer
  23132. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23133. * - VertexBuffer.PositionKind
  23134. * - VertexBuffer.UVKind
  23135. * - VertexBuffer.UV2Kind
  23136. * - VertexBuffer.UV3Kind
  23137. * - VertexBuffer.UV4Kind
  23138. * - VertexBuffer.UV5Kind
  23139. * - VertexBuffer.UV6Kind
  23140. * - VertexBuffer.ColorKind
  23141. * - VertexBuffer.MatricesIndicesKind
  23142. * - VertexBuffer.MatricesIndicesExtraKind
  23143. * - VertexBuffer.MatricesWeightsKind
  23144. * - VertexBuffer.MatricesWeightsExtraKind
  23145. * @param data defines the data source
  23146. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23147. * @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)
  23148. */
  23149. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23150. /**
  23151. * Creates a new index buffer
  23152. * @param indices defines the indices to store in the index buffer
  23153. * @param totalVertices defines the total number of vertices (could be null)
  23154. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23155. */
  23156. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23157. }
  23158. /**
  23159. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23160. */
  23161. export class VertexData {
  23162. /**
  23163. * Mesh side orientation : usually the external or front surface
  23164. */
  23165. static readonly FRONTSIDE: number;
  23166. /**
  23167. * Mesh side orientation : usually the internal or back surface
  23168. */
  23169. static readonly BACKSIDE: number;
  23170. /**
  23171. * Mesh side orientation : both internal and external or front and back surfaces
  23172. */
  23173. static readonly DOUBLESIDE: number;
  23174. /**
  23175. * Mesh side orientation : by default, `FRONTSIDE`
  23176. */
  23177. static readonly DEFAULTSIDE: number;
  23178. /**
  23179. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23180. */
  23181. positions: Nullable<FloatArray>;
  23182. /**
  23183. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23184. */
  23185. normals: Nullable<FloatArray>;
  23186. /**
  23187. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23188. */
  23189. tangents: Nullable<FloatArray>;
  23190. /**
  23191. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23192. */
  23193. uvs: Nullable<FloatArray>;
  23194. /**
  23195. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23196. */
  23197. uvs2: Nullable<FloatArray>;
  23198. /**
  23199. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23200. */
  23201. uvs3: Nullable<FloatArray>;
  23202. /**
  23203. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23204. */
  23205. uvs4: Nullable<FloatArray>;
  23206. /**
  23207. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23208. */
  23209. uvs5: Nullable<FloatArray>;
  23210. /**
  23211. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23212. */
  23213. uvs6: Nullable<FloatArray>;
  23214. /**
  23215. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23216. */
  23217. colors: Nullable<FloatArray>;
  23218. /**
  23219. * 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).
  23220. */
  23221. matricesIndices: Nullable<FloatArray>;
  23222. /**
  23223. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23224. */
  23225. matricesWeights: Nullable<FloatArray>;
  23226. /**
  23227. * An array extending the number of possible indices
  23228. */
  23229. matricesIndicesExtra: Nullable<FloatArray>;
  23230. /**
  23231. * An array extending the number of possible weights when the number of indices is extended
  23232. */
  23233. matricesWeightsExtra: Nullable<FloatArray>;
  23234. /**
  23235. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23236. */
  23237. indices: Nullable<IndicesArray>;
  23238. /**
  23239. * Uses the passed data array to set the set the values for the specified kind of data
  23240. * @param data a linear array of floating numbers
  23241. * @param kind the type of data that is being set, eg positions, colors etc
  23242. */
  23243. set(data: FloatArray, kind: string): void;
  23244. /**
  23245. * Associates the vertexData to the passed Mesh.
  23246. * Sets it as updatable or not (default `false`)
  23247. * @param mesh the mesh the vertexData is applied to
  23248. * @param updatable when used and having the value true allows new data to update the vertexData
  23249. * @returns the VertexData
  23250. */
  23251. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23252. /**
  23253. * Associates the vertexData to the passed Geometry.
  23254. * Sets it as updatable or not (default `false`)
  23255. * @param geometry the geometry the vertexData is applied to
  23256. * @param updatable when used and having the value true allows new data to update the vertexData
  23257. * @returns VertexData
  23258. */
  23259. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23260. /**
  23261. * Updates the associated mesh
  23262. * @param mesh the mesh to be updated
  23263. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23264. * @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
  23265. * @returns VertexData
  23266. */
  23267. updateMesh(mesh: Mesh): VertexData;
  23268. /**
  23269. * Updates the associated geometry
  23270. * @param geometry the geometry to be updated
  23271. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23272. * @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
  23273. * @returns VertexData.
  23274. */
  23275. updateGeometry(geometry: Geometry): VertexData;
  23276. private _applyTo;
  23277. private _update;
  23278. /**
  23279. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23280. * @param matrix the transforming matrix
  23281. * @returns the VertexData
  23282. */
  23283. transform(matrix: Matrix): VertexData;
  23284. /**
  23285. * Merges the passed VertexData into the current one
  23286. * @param other the VertexData to be merged into the current one
  23287. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23288. * @returns the modified VertexData
  23289. */
  23290. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23291. private _mergeElement;
  23292. private _validate;
  23293. /**
  23294. * Serializes the VertexData
  23295. * @returns a serialized object
  23296. */
  23297. serialize(): any;
  23298. /**
  23299. * Extracts the vertexData from a mesh
  23300. * @param mesh the mesh from which to extract the VertexData
  23301. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23302. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23303. * @returns the object VertexData associated to the passed mesh
  23304. */
  23305. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23306. /**
  23307. * Extracts the vertexData from the geometry
  23308. * @param geometry the geometry from which to extract the VertexData
  23309. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23310. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23311. * @returns the object VertexData associated to the passed mesh
  23312. */
  23313. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23314. private static _ExtractFrom;
  23315. /**
  23316. * Creates the VertexData for a Ribbon
  23317. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23318. * * pathArray array of paths, each of which an array of successive Vector3
  23319. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23320. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23321. * * 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
  23322. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23323. * * 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)
  23324. * * 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)
  23325. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23326. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23327. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23328. * @returns the VertexData of the ribbon
  23329. */
  23330. static CreateRibbon(options: {
  23331. pathArray: Vector3[][];
  23332. closeArray?: boolean;
  23333. closePath?: boolean;
  23334. offset?: number;
  23335. sideOrientation?: number;
  23336. frontUVs?: Vector4;
  23337. backUVs?: Vector4;
  23338. invertUV?: boolean;
  23339. uvs?: Vector2[];
  23340. colors?: Color4[];
  23341. }): VertexData;
  23342. /**
  23343. * Creates the VertexData for a box
  23344. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23345. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23346. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23347. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23348. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23349. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23350. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23351. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23352. * * 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)
  23353. * * 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)
  23354. * @returns the VertexData of the box
  23355. */
  23356. static CreateBox(options: {
  23357. size?: number;
  23358. width?: number;
  23359. height?: number;
  23360. depth?: number;
  23361. faceUV?: Vector4[];
  23362. faceColors?: Color4[];
  23363. sideOrientation?: number;
  23364. frontUVs?: Vector4;
  23365. backUVs?: Vector4;
  23366. }): VertexData;
  23367. /**
  23368. * Creates the VertexData for a tiled box
  23369. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23370. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23371. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23372. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23373. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23374. * @returns the VertexData of the box
  23375. */
  23376. static CreateTiledBox(options: {
  23377. pattern?: number;
  23378. width?: number;
  23379. height?: number;
  23380. depth?: number;
  23381. tileSize?: number;
  23382. tileWidth?: number;
  23383. tileHeight?: number;
  23384. alignHorizontal?: number;
  23385. alignVertical?: number;
  23386. faceUV?: Vector4[];
  23387. faceColors?: Color4[];
  23388. sideOrientation?: number;
  23389. }): VertexData;
  23390. /**
  23391. * Creates the VertexData for a tiled plane
  23392. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23393. * * pattern a limited pattern arrangement depending on the number
  23394. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23395. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23396. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23397. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23398. * * 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)
  23399. * * 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)
  23400. * @returns the VertexData of the tiled plane
  23401. */
  23402. static CreateTiledPlane(options: {
  23403. pattern?: number;
  23404. tileSize?: number;
  23405. tileWidth?: number;
  23406. tileHeight?: number;
  23407. size?: number;
  23408. width?: number;
  23409. height?: number;
  23410. alignHorizontal?: number;
  23411. alignVertical?: number;
  23412. sideOrientation?: number;
  23413. frontUVs?: Vector4;
  23414. backUVs?: Vector4;
  23415. }): VertexData;
  23416. /**
  23417. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23418. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23419. * * segments sets the number of horizontal strips optional, default 32
  23420. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23421. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23422. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23423. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23424. * * 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
  23425. * * 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
  23426. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23427. * * 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)
  23428. * * 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)
  23429. * @returns the VertexData of the ellipsoid
  23430. */
  23431. static CreateSphere(options: {
  23432. segments?: number;
  23433. diameter?: number;
  23434. diameterX?: number;
  23435. diameterY?: number;
  23436. diameterZ?: number;
  23437. arc?: number;
  23438. slice?: number;
  23439. sideOrientation?: number;
  23440. frontUVs?: Vector4;
  23441. backUVs?: Vector4;
  23442. }): VertexData;
  23443. /**
  23444. * Creates the VertexData for a cylinder, cone or prism
  23445. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23446. * * height sets the height (y direction) of the cylinder, optional, default 2
  23447. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23448. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23449. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23450. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23451. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23452. * * 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
  23453. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23454. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23455. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23456. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23457. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23458. * * 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)
  23459. * * 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)
  23460. * @returns the VertexData of the cylinder, cone or prism
  23461. */
  23462. static CreateCylinder(options: {
  23463. height?: number;
  23464. diameterTop?: number;
  23465. diameterBottom?: number;
  23466. diameter?: number;
  23467. tessellation?: number;
  23468. subdivisions?: number;
  23469. arc?: number;
  23470. faceColors?: Color4[];
  23471. faceUV?: Vector4[];
  23472. hasRings?: boolean;
  23473. enclose?: boolean;
  23474. sideOrientation?: number;
  23475. frontUVs?: Vector4;
  23476. backUVs?: Vector4;
  23477. }): VertexData;
  23478. /**
  23479. * Creates the VertexData for a torus
  23480. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23481. * * diameter the diameter of the torus, optional default 1
  23482. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23483. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23484. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23485. * * 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)
  23486. * * 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)
  23487. * @returns the VertexData of the torus
  23488. */
  23489. static CreateTorus(options: {
  23490. diameter?: number;
  23491. thickness?: number;
  23492. tessellation?: number;
  23493. sideOrientation?: number;
  23494. frontUVs?: Vector4;
  23495. backUVs?: Vector4;
  23496. }): VertexData;
  23497. /**
  23498. * Creates the VertexData of the LineSystem
  23499. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23500. * - lines an array of lines, each line being an array of successive Vector3
  23501. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23502. * @returns the VertexData of the LineSystem
  23503. */
  23504. static CreateLineSystem(options: {
  23505. lines: Vector3[][];
  23506. colors?: Nullable<Color4[][]>;
  23507. }): VertexData;
  23508. /**
  23509. * Create the VertexData for a DashedLines
  23510. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23511. * - points an array successive Vector3
  23512. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23513. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23514. * - dashNb the intended total number of dashes, optional, default 200
  23515. * @returns the VertexData for the DashedLines
  23516. */
  23517. static CreateDashedLines(options: {
  23518. points: Vector3[];
  23519. dashSize?: number;
  23520. gapSize?: number;
  23521. dashNb?: number;
  23522. }): VertexData;
  23523. /**
  23524. * Creates the VertexData for a Ground
  23525. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23526. * - width the width (x direction) of the ground, optional, default 1
  23527. * - height the height (z direction) of the ground, optional, default 1
  23528. * - subdivisions the number of subdivisions per side, optional, default 1
  23529. * @returns the VertexData of the Ground
  23530. */
  23531. static CreateGround(options: {
  23532. width?: number;
  23533. height?: number;
  23534. subdivisions?: number;
  23535. subdivisionsX?: number;
  23536. subdivisionsY?: number;
  23537. }): VertexData;
  23538. /**
  23539. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23540. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23541. * * xmin the ground minimum X coordinate, optional, default -1
  23542. * * zmin the ground minimum Z coordinate, optional, default -1
  23543. * * xmax the ground maximum X coordinate, optional, default 1
  23544. * * zmax the ground maximum Z coordinate, optional, default 1
  23545. * * 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}
  23546. * * 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}
  23547. * @returns the VertexData of the TiledGround
  23548. */
  23549. static CreateTiledGround(options: {
  23550. xmin: number;
  23551. zmin: number;
  23552. xmax: number;
  23553. zmax: number;
  23554. subdivisions?: {
  23555. w: number;
  23556. h: number;
  23557. };
  23558. precision?: {
  23559. w: number;
  23560. h: number;
  23561. };
  23562. }): VertexData;
  23563. /**
  23564. * Creates the VertexData of the Ground designed from a heightmap
  23565. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23566. * * width the width (x direction) of the ground
  23567. * * height the height (z direction) of the ground
  23568. * * subdivisions the number of subdivisions per side
  23569. * * minHeight the minimum altitude on the ground, optional, default 0
  23570. * * maxHeight the maximum altitude on the ground, optional default 1
  23571. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23572. * * buffer the array holding the image color data
  23573. * * bufferWidth the width of image
  23574. * * bufferHeight the height of image
  23575. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23576. * @returns the VertexData of the Ground designed from a heightmap
  23577. */
  23578. static CreateGroundFromHeightMap(options: {
  23579. width: number;
  23580. height: number;
  23581. subdivisions: number;
  23582. minHeight: number;
  23583. maxHeight: number;
  23584. colorFilter: Color3;
  23585. buffer: Uint8Array;
  23586. bufferWidth: number;
  23587. bufferHeight: number;
  23588. alphaFilter: number;
  23589. }): VertexData;
  23590. /**
  23591. * Creates the VertexData for a Plane
  23592. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23593. * * size sets the width and height of the plane to the value of size, optional default 1
  23594. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23595. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23596. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23597. * * 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)
  23598. * * 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)
  23599. * @returns the VertexData of the box
  23600. */
  23601. static CreatePlane(options: {
  23602. size?: number;
  23603. width?: number;
  23604. height?: number;
  23605. sideOrientation?: number;
  23606. frontUVs?: Vector4;
  23607. backUVs?: Vector4;
  23608. }): VertexData;
  23609. /**
  23610. * Creates the VertexData of the Disc or regular Polygon
  23611. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23612. * * radius the radius of the disc, optional default 0.5
  23613. * * tessellation the number of polygon sides, optional, default 64
  23614. * * 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
  23615. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23616. * * 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)
  23617. * * 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)
  23618. * @returns the VertexData of the box
  23619. */
  23620. static CreateDisc(options: {
  23621. radius?: number;
  23622. tessellation?: number;
  23623. arc?: number;
  23624. sideOrientation?: number;
  23625. frontUVs?: Vector4;
  23626. backUVs?: Vector4;
  23627. }): VertexData;
  23628. /**
  23629. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23630. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23631. * @param polygon a mesh built from polygonTriangulation.build()
  23632. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23633. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23634. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23635. * @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)
  23636. * @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)
  23637. * @returns the VertexData of the Polygon
  23638. */
  23639. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23640. /**
  23641. * Creates the VertexData of the IcoSphere
  23642. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23643. * * radius the radius of the IcoSphere, optional default 1
  23644. * * radiusX allows stretching in the x direction, optional, default radius
  23645. * * radiusY allows stretching in the y direction, optional, default radius
  23646. * * radiusZ allows stretching in the z direction, optional, default radius
  23647. * * flat when true creates a flat shaded mesh, optional, default true
  23648. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23649. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23650. * * 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)
  23651. * * 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)
  23652. * @returns the VertexData of the IcoSphere
  23653. */
  23654. static CreateIcoSphere(options: {
  23655. radius?: number;
  23656. radiusX?: number;
  23657. radiusY?: number;
  23658. radiusZ?: number;
  23659. flat?: boolean;
  23660. subdivisions?: number;
  23661. sideOrientation?: number;
  23662. frontUVs?: Vector4;
  23663. backUVs?: Vector4;
  23664. }): VertexData;
  23665. /**
  23666. * Creates the VertexData for a Polyhedron
  23667. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23668. * * type provided types are:
  23669. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23670. * * 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)
  23671. * * size the size of the IcoSphere, optional default 1
  23672. * * sizeX allows stretching in the x direction, optional, default size
  23673. * * sizeY allows stretching in the y direction, optional, default size
  23674. * * sizeZ allows stretching in the z direction, optional, default size
  23675. * * 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
  23676. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23677. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23678. * * flat when true creates a flat shaded mesh, optional, default true
  23679. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23680. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23681. * * 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)
  23682. * * 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)
  23683. * @returns the VertexData of the Polyhedron
  23684. */
  23685. static CreatePolyhedron(options: {
  23686. type?: number;
  23687. size?: number;
  23688. sizeX?: number;
  23689. sizeY?: number;
  23690. sizeZ?: number;
  23691. custom?: any;
  23692. faceUV?: Vector4[];
  23693. faceColors?: Color4[];
  23694. flat?: boolean;
  23695. sideOrientation?: number;
  23696. frontUVs?: Vector4;
  23697. backUVs?: Vector4;
  23698. }): VertexData;
  23699. /**
  23700. * Creates the VertexData for a TorusKnot
  23701. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23702. * * radius the radius of the torus knot, optional, default 2
  23703. * * tube the thickness of the tube, optional, default 0.5
  23704. * * radialSegments the number of sides on each tube segments, optional, default 32
  23705. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23706. * * p the number of windings around the z axis, optional, default 2
  23707. * * q the number of windings around the x axis, optional, default 3
  23708. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23709. * * 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)
  23710. * * 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)
  23711. * @returns the VertexData of the Torus Knot
  23712. */
  23713. static CreateTorusKnot(options: {
  23714. radius?: number;
  23715. tube?: number;
  23716. radialSegments?: number;
  23717. tubularSegments?: number;
  23718. p?: number;
  23719. q?: number;
  23720. sideOrientation?: number;
  23721. frontUVs?: Vector4;
  23722. backUVs?: Vector4;
  23723. }): VertexData;
  23724. /**
  23725. * Compute normals for given positions and indices
  23726. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23727. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23728. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23729. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23730. * * facetNormals : optional array of facet normals (vector3)
  23731. * * facetPositions : optional array of facet positions (vector3)
  23732. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23733. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23734. * * bInfo : optional bounding info, required for facetPartitioning computation
  23735. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23736. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23737. * * useRightHandedSystem: optional boolean to for right handed system computation
  23738. * * depthSort : optional boolean to enable the facet depth sort computation
  23739. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23740. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23741. */
  23742. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23743. facetNormals?: any;
  23744. facetPositions?: any;
  23745. facetPartitioning?: any;
  23746. ratio?: number;
  23747. bInfo?: any;
  23748. bbSize?: Vector3;
  23749. subDiv?: any;
  23750. useRightHandedSystem?: boolean;
  23751. depthSort?: boolean;
  23752. distanceTo?: Vector3;
  23753. depthSortedFacets?: any;
  23754. }): void;
  23755. /** @hidden */
  23756. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23757. /**
  23758. * Applies VertexData created from the imported parameters to the geometry
  23759. * @param parsedVertexData the parsed data from an imported file
  23760. * @param geometry the geometry to apply the VertexData to
  23761. */
  23762. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23763. }
  23764. }
  23765. declare module BABYLON {
  23766. /**
  23767. * Class containing static functions to help procedurally build meshes
  23768. */
  23769. export class DiscBuilder {
  23770. /**
  23771. * Creates a plane polygonal mesh. By default, this is a disc
  23772. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23773. * * 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
  23774. * * 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
  23775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23776. * * 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
  23777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23778. * @param name defines the name of the mesh
  23779. * @param options defines the options used to create the mesh
  23780. * @param scene defines the hosting scene
  23781. * @returns the plane polygonal mesh
  23782. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23783. */
  23784. static CreateDisc(name: string, options: {
  23785. radius?: number;
  23786. tessellation?: number;
  23787. arc?: number;
  23788. updatable?: boolean;
  23789. sideOrientation?: number;
  23790. frontUVs?: Vector4;
  23791. backUVs?: Vector4;
  23792. }, scene?: Nullable<Scene>): Mesh;
  23793. }
  23794. }
  23795. declare module BABYLON {
  23796. /**
  23797. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23798. *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.
  23799. * The SPS is also a particle system. It provides some methods to manage the particles.
  23800. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23801. *
  23802. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23803. */
  23804. export class SolidParticleSystem implements IDisposable {
  23805. /**
  23806. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23807. * Example : var p = SPS.particles[i];
  23808. */
  23809. particles: SolidParticle[];
  23810. /**
  23811. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23812. */
  23813. nbParticles: number;
  23814. /**
  23815. * If the particles must ever face the camera (default false). Useful for planar particles.
  23816. */
  23817. billboard: boolean;
  23818. /**
  23819. * Recompute normals when adding a shape
  23820. */
  23821. recomputeNormals: boolean;
  23822. /**
  23823. * This a counter ofr your own usage. It's not set by any SPS functions.
  23824. */
  23825. counter: number;
  23826. /**
  23827. * The SPS name. This name is also given to the underlying mesh.
  23828. */
  23829. name: string;
  23830. /**
  23831. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23832. */
  23833. mesh: Mesh;
  23834. /**
  23835. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23836. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23837. */
  23838. vars: any;
  23839. /**
  23840. * This array is populated when the SPS is set as 'pickable'.
  23841. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23842. * Each element of this array is an object `{idx: int, faceId: int}`.
  23843. * `idx` is the picked particle index in the `SPS.particles` array
  23844. * `faceId` is the picked face index counted within this particle.
  23845. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23846. */
  23847. pickedParticles: {
  23848. idx: number;
  23849. faceId: number;
  23850. }[];
  23851. /**
  23852. * This array is populated when `enableDepthSort` is set to true.
  23853. * Each element of this array is an instance of the class DepthSortedParticle.
  23854. */
  23855. depthSortedParticles: DepthSortedParticle[];
  23856. /**
  23857. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23858. * @hidden
  23859. */
  23860. _bSphereOnly: boolean;
  23861. /**
  23862. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23863. * @hidden
  23864. */
  23865. _bSphereRadiusFactor: number;
  23866. private _scene;
  23867. private _positions;
  23868. private _indices;
  23869. private _normals;
  23870. private _colors;
  23871. private _uvs;
  23872. private _indices32;
  23873. private _positions32;
  23874. private _normals32;
  23875. private _fixedNormal32;
  23876. private _colors32;
  23877. private _uvs32;
  23878. private _index;
  23879. private _updatable;
  23880. private _pickable;
  23881. private _isVisibilityBoxLocked;
  23882. private _alwaysVisible;
  23883. private _depthSort;
  23884. private _shapeCounter;
  23885. private _copy;
  23886. private _color;
  23887. private _computeParticleColor;
  23888. private _computeParticleTexture;
  23889. private _computeParticleRotation;
  23890. private _computeParticleVertex;
  23891. private _computeBoundingBox;
  23892. private _depthSortParticles;
  23893. private _camera;
  23894. private _mustUnrotateFixedNormals;
  23895. private _particlesIntersect;
  23896. private _needs32Bits;
  23897. /**
  23898. * Creates a SPS (Solid Particle System) object.
  23899. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23900. * @param scene (Scene) is the scene in which the SPS is added.
  23901. * @param options defines the options of the sps e.g.
  23902. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23903. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23904. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23905. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23906. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23907. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23908. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23909. */
  23910. constructor(name: string, scene: Scene, options?: {
  23911. updatable?: boolean;
  23912. isPickable?: boolean;
  23913. enableDepthSort?: boolean;
  23914. particleIntersection?: boolean;
  23915. boundingSphereOnly?: boolean;
  23916. bSphereRadiusFactor?: number;
  23917. });
  23918. /**
  23919. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23920. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23921. * @returns the created mesh
  23922. */
  23923. buildMesh(): Mesh;
  23924. /**
  23925. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23926. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23927. * Thus the particles generated from `digest()` have their property `position` set yet.
  23928. * @param mesh ( Mesh ) is the mesh to be digested
  23929. * @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
  23930. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23931. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23932. * @returns the current SPS
  23933. */
  23934. digest(mesh: Mesh, options?: {
  23935. facetNb?: number;
  23936. number?: number;
  23937. delta?: number;
  23938. }): SolidParticleSystem;
  23939. private _unrotateFixedNormals;
  23940. private _resetCopy;
  23941. private _meshBuilder;
  23942. private _posToShape;
  23943. private _uvsToShapeUV;
  23944. private _addParticle;
  23945. /**
  23946. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23947. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23948. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23949. * @param nb (positive integer) the number of particles to be created from this model
  23950. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23951. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23952. * @returns the number of shapes in the system
  23953. */
  23954. addShape(mesh: Mesh, nb: number, options?: {
  23955. positionFunction?: any;
  23956. vertexFunction?: any;
  23957. }): number;
  23958. private _rebuildParticle;
  23959. /**
  23960. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23961. * @returns the SPS.
  23962. */
  23963. rebuildMesh(): SolidParticleSystem;
  23964. /**
  23965. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23966. * This method calls `updateParticle()` for each particle of the SPS.
  23967. * For an animated SPS, it is usually called within the render loop.
  23968. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23969. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23970. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23971. * @returns the SPS.
  23972. */
  23973. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23974. /**
  23975. * Disposes the SPS.
  23976. */
  23977. dispose(): void;
  23978. /**
  23979. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23980. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23981. * @returns the SPS.
  23982. */
  23983. refreshVisibleSize(): SolidParticleSystem;
  23984. /**
  23985. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23986. * @param size the size (float) of the visibility box
  23987. * note : this doesn't lock the SPS mesh bounding box.
  23988. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23989. */
  23990. setVisibilityBox(size: number): void;
  23991. /**
  23992. * Gets whether the SPS as always visible or not
  23993. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23994. */
  23995. /**
  23996. * Sets the SPS as always visible or not
  23997. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23998. */
  23999. isAlwaysVisible: boolean;
  24000. /**
  24001. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24002. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24003. */
  24004. /**
  24005. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24006. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24007. */
  24008. isVisibilityBoxLocked: boolean;
  24009. /**
  24010. * Tells to `setParticles()` to compute the particle rotations or not.
  24011. * Default value : true. The SPS is faster when it's set to false.
  24012. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24013. */
  24014. /**
  24015. * Gets if `setParticles()` computes the particle rotations or not.
  24016. * Default value : true. The SPS is faster when it's set to false.
  24017. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24018. */
  24019. computeParticleRotation: boolean;
  24020. /**
  24021. * Tells to `setParticles()` to compute the particle colors or not.
  24022. * Default value : true. The SPS is faster when it's set to false.
  24023. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24024. */
  24025. /**
  24026. * Gets if `setParticles()` computes the particle colors or not.
  24027. * Default value : true. The SPS is faster when it's set to false.
  24028. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24029. */
  24030. computeParticleColor: boolean;
  24031. /**
  24032. * Gets if `setParticles()` computes the particle textures or not.
  24033. * Default value : true. The SPS is faster when it's set to false.
  24034. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24035. */
  24036. computeParticleTexture: boolean;
  24037. /**
  24038. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24039. * Default value : false. The SPS is faster when it's set to false.
  24040. * Note : the particle custom vertex positions aren't stored values.
  24041. */
  24042. /**
  24043. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24044. * Default value : false. The SPS is faster when it's set to false.
  24045. * Note : the particle custom vertex positions aren't stored values.
  24046. */
  24047. computeParticleVertex: boolean;
  24048. /**
  24049. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24050. */
  24051. /**
  24052. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24053. */
  24054. computeBoundingBox: boolean;
  24055. /**
  24056. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24057. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24058. * Default : `true`
  24059. */
  24060. /**
  24061. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24062. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24063. * Default : `true`
  24064. */
  24065. depthSortParticles: boolean;
  24066. /**
  24067. * This function does nothing. It may be overwritten to set all the particle first values.
  24068. * The SPS doesn't call this function, you may have to call it by your own.
  24069. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24070. */
  24071. initParticles(): void;
  24072. /**
  24073. * This function does nothing. It may be overwritten to recycle a particle.
  24074. * The SPS doesn't call this function, you may have to call it by your own.
  24075. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24076. * @param particle The particle to recycle
  24077. * @returns the recycled particle
  24078. */
  24079. recycleParticle(particle: SolidParticle): SolidParticle;
  24080. /**
  24081. * Updates a particle : this function should be overwritten by the user.
  24082. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24083. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24084. * @example : just set a particle position or velocity and recycle conditions
  24085. * @param particle The particle to update
  24086. * @returns the updated particle
  24087. */
  24088. updateParticle(particle: SolidParticle): SolidParticle;
  24089. /**
  24090. * Updates a vertex of a particle : it can be overwritten by the user.
  24091. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24092. * @param particle the current particle
  24093. * @param vertex the current index of the current particle
  24094. * @param pt the index of the current vertex in the particle shape
  24095. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24096. * @example : just set a vertex particle position
  24097. * @returns the updated vertex
  24098. */
  24099. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24100. /**
  24101. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24102. * This does nothing and may be overwritten by the user.
  24103. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24104. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24105. * @param update the boolean update value actually passed to setParticles()
  24106. */
  24107. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24108. /**
  24109. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24110. * This will be passed three parameters.
  24111. * This does nothing and may be overwritten by the user.
  24112. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24113. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24114. * @param update the boolean update value actually passed to setParticles()
  24115. */
  24116. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24117. }
  24118. }
  24119. declare module BABYLON {
  24120. /**
  24121. * Represents one particle of a solid particle system.
  24122. */
  24123. export class SolidParticle {
  24124. /**
  24125. * particle global index
  24126. */
  24127. idx: number;
  24128. /**
  24129. * The color of the particle
  24130. */
  24131. color: Nullable<Color4>;
  24132. /**
  24133. * The world space position of the particle.
  24134. */
  24135. position: Vector3;
  24136. /**
  24137. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24138. */
  24139. rotation: Vector3;
  24140. /**
  24141. * The world space rotation quaternion of the particle.
  24142. */
  24143. rotationQuaternion: Nullable<Quaternion>;
  24144. /**
  24145. * The scaling of the particle.
  24146. */
  24147. scaling: Vector3;
  24148. /**
  24149. * The uvs of the particle.
  24150. */
  24151. uvs: Vector4;
  24152. /**
  24153. * The current speed of the particle.
  24154. */
  24155. velocity: Vector3;
  24156. /**
  24157. * The pivot point in the particle local space.
  24158. */
  24159. pivot: Vector3;
  24160. /**
  24161. * Must the particle be translated from its pivot point in its local space ?
  24162. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24163. * Default : false
  24164. */
  24165. translateFromPivot: boolean;
  24166. /**
  24167. * Is the particle active or not ?
  24168. */
  24169. alive: boolean;
  24170. /**
  24171. * Is the particle visible or not ?
  24172. */
  24173. isVisible: boolean;
  24174. /**
  24175. * Index of this particle in the global "positions" array (Internal use)
  24176. * @hidden
  24177. */
  24178. _pos: number;
  24179. /**
  24180. * @hidden Index of this particle in the global "indices" array (Internal use)
  24181. */
  24182. _ind: number;
  24183. /**
  24184. * @hidden ModelShape of this particle (Internal use)
  24185. */
  24186. _model: ModelShape;
  24187. /**
  24188. * ModelShape id of this particle
  24189. */
  24190. shapeId: number;
  24191. /**
  24192. * Index of the particle in its shape id (Internal use)
  24193. */
  24194. idxInShape: number;
  24195. /**
  24196. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24197. */
  24198. _modelBoundingInfo: BoundingInfo;
  24199. /**
  24200. * @hidden Particle BoundingInfo object (Internal use)
  24201. */
  24202. _boundingInfo: BoundingInfo;
  24203. /**
  24204. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24205. */
  24206. _sps: SolidParticleSystem;
  24207. /**
  24208. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24209. */
  24210. _stillInvisible: boolean;
  24211. /**
  24212. * @hidden Last computed particle rotation matrix
  24213. */
  24214. _rotationMatrix: number[];
  24215. /**
  24216. * Parent particle Id, if any.
  24217. * Default null.
  24218. */
  24219. parentId: Nullable<number>;
  24220. /**
  24221. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24222. * The possible values are :
  24223. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24224. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24225. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24226. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24227. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24228. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24229. * */
  24230. cullingStrategy: number;
  24231. /**
  24232. * @hidden Internal global position in the SPS.
  24233. */
  24234. _globalPosition: Vector3;
  24235. /**
  24236. * Creates a Solid Particle object.
  24237. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24238. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24239. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24240. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24241. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24242. * @param shapeId (integer) is the model shape identifier in the SPS.
  24243. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24244. * @param sps defines the sps it is associated to
  24245. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24246. */
  24247. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24248. /**
  24249. * Legacy support, changed scale to scaling
  24250. */
  24251. /**
  24252. * Legacy support, changed scale to scaling
  24253. */
  24254. scale: Vector3;
  24255. /**
  24256. * Legacy support, changed quaternion to rotationQuaternion
  24257. */
  24258. /**
  24259. * Legacy support, changed quaternion to rotationQuaternion
  24260. */
  24261. quaternion: Nullable<Quaternion>;
  24262. /**
  24263. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24264. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24265. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24266. * @returns true if it intersects
  24267. */
  24268. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24269. /**
  24270. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24271. * A particle is in the frustum if its bounding box intersects the frustum
  24272. * @param frustumPlanes defines the frustum to test
  24273. * @returns true if the particle is in the frustum planes
  24274. */
  24275. isInFrustum(frustumPlanes: Plane[]): boolean;
  24276. /**
  24277. * get the rotation matrix of the particle
  24278. * @hidden
  24279. */
  24280. getRotationMatrix(m: Matrix): void;
  24281. }
  24282. /**
  24283. * Represents the shape of the model used by one particle of a solid particle system.
  24284. * SPS internal tool, don't use it manually.
  24285. */
  24286. export class ModelShape {
  24287. /**
  24288. * The shape id
  24289. * @hidden
  24290. */
  24291. shapeID: number;
  24292. /**
  24293. * flat array of model positions (internal use)
  24294. * @hidden
  24295. */
  24296. _shape: Vector3[];
  24297. /**
  24298. * flat array of model UVs (internal use)
  24299. * @hidden
  24300. */
  24301. _shapeUV: number[];
  24302. /**
  24303. * length of the shape in the model indices array (internal use)
  24304. * @hidden
  24305. */
  24306. _indicesLength: number;
  24307. /**
  24308. * Custom position function (internal use)
  24309. * @hidden
  24310. */
  24311. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24312. /**
  24313. * Custom vertex function (internal use)
  24314. * @hidden
  24315. */
  24316. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24317. /**
  24318. * 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.
  24319. * SPS internal tool, don't use it manually.
  24320. * @hidden
  24321. */
  24322. 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>);
  24323. }
  24324. /**
  24325. * Represents a Depth Sorted Particle in the solid particle system.
  24326. */
  24327. export class DepthSortedParticle {
  24328. /**
  24329. * Index of the particle in the "indices" array
  24330. */
  24331. ind: number;
  24332. /**
  24333. * Length of the particle shape in the "indices" array
  24334. */
  24335. indicesLength: number;
  24336. /**
  24337. * Squared distance from the particle to the camera
  24338. */
  24339. sqDistance: number;
  24340. }
  24341. }
  24342. declare module BABYLON {
  24343. /**
  24344. * @hidden
  24345. */
  24346. export class _MeshCollisionData {
  24347. _checkCollisions: boolean;
  24348. _collisionMask: number;
  24349. _collisionGroup: number;
  24350. _collider: Nullable<Collider>;
  24351. _oldPositionForCollisions: Vector3;
  24352. _diffPositionForCollisions: Vector3;
  24353. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24354. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24355. }
  24356. }
  24357. declare module BABYLON {
  24358. /** @hidden */
  24359. class _FacetDataStorage {
  24360. facetPositions: Vector3[];
  24361. facetNormals: Vector3[];
  24362. facetPartitioning: number[][];
  24363. facetNb: number;
  24364. partitioningSubdivisions: number;
  24365. partitioningBBoxRatio: number;
  24366. facetDataEnabled: boolean;
  24367. facetParameters: any;
  24368. bbSize: Vector3;
  24369. subDiv: {
  24370. max: number;
  24371. X: number;
  24372. Y: number;
  24373. Z: number;
  24374. };
  24375. facetDepthSort: boolean;
  24376. facetDepthSortEnabled: boolean;
  24377. depthSortedIndices: IndicesArray;
  24378. depthSortedFacets: {
  24379. ind: number;
  24380. sqDistance: number;
  24381. }[];
  24382. facetDepthSortFunction: (f1: {
  24383. ind: number;
  24384. sqDistance: number;
  24385. }, f2: {
  24386. ind: number;
  24387. sqDistance: number;
  24388. }) => number;
  24389. facetDepthSortFrom: Vector3;
  24390. facetDepthSortOrigin: Vector3;
  24391. invertedMatrix: Matrix;
  24392. }
  24393. /**
  24394. * @hidden
  24395. **/
  24396. class _InternalAbstractMeshDataInfo {
  24397. _hasVertexAlpha: boolean;
  24398. _useVertexColors: boolean;
  24399. _numBoneInfluencers: number;
  24400. _applyFog: boolean;
  24401. _receiveShadows: boolean;
  24402. _facetData: _FacetDataStorage;
  24403. _visibility: number;
  24404. _skeleton: Nullable<Skeleton>;
  24405. _layerMask: number;
  24406. _computeBonesUsingShaders: boolean;
  24407. _isActive: boolean;
  24408. _onlyForInstances: boolean;
  24409. _isActiveIntermediate: boolean;
  24410. _onlyForInstancesIntermediate: boolean;
  24411. }
  24412. /**
  24413. * Class used to store all common mesh properties
  24414. */
  24415. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24416. /** No occlusion */
  24417. static OCCLUSION_TYPE_NONE: number;
  24418. /** Occlusion set to optimisitic */
  24419. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24420. /** Occlusion set to strict */
  24421. static OCCLUSION_TYPE_STRICT: number;
  24422. /** Use an accurante occlusion algorithm */
  24423. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24424. /** Use a conservative occlusion algorithm */
  24425. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24426. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24427. * Test order :
  24428. * Is the bounding sphere outside the frustum ?
  24429. * If not, are the bounding box vertices outside the frustum ?
  24430. * It not, then the cullable object is in the frustum.
  24431. */
  24432. static readonly CULLINGSTRATEGY_STANDARD: number;
  24433. /** Culling strategy : Bounding Sphere Only.
  24434. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24435. * It's also less accurate than the standard because some not visible objects can still be selected.
  24436. * Test : is the bounding sphere outside the frustum ?
  24437. * If not, then the cullable object is in the frustum.
  24438. */
  24439. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24440. /** Culling strategy : Optimistic Inclusion.
  24441. * This in an inclusion test first, then the standard exclusion test.
  24442. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24443. * 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.
  24444. * Anyway, it's as accurate as the standard strategy.
  24445. * Test :
  24446. * Is the cullable object bounding sphere center in the frustum ?
  24447. * If not, apply the default culling strategy.
  24448. */
  24449. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24450. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24451. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24452. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24453. * 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.
  24454. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24455. * Test :
  24456. * Is the cullable object bounding sphere center in the frustum ?
  24457. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24458. */
  24459. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24460. /**
  24461. * No billboard
  24462. */
  24463. static readonly BILLBOARDMODE_NONE: number;
  24464. /** Billboard on X axis */
  24465. static readonly BILLBOARDMODE_X: number;
  24466. /** Billboard on Y axis */
  24467. static readonly BILLBOARDMODE_Y: number;
  24468. /** Billboard on Z axis */
  24469. static readonly BILLBOARDMODE_Z: number;
  24470. /** Billboard on all axes */
  24471. static readonly BILLBOARDMODE_ALL: number;
  24472. /** @hidden */
  24473. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  24474. /**
  24475. * The culling strategy to use to check whether the mesh must be rendered or not.
  24476. * This value can be changed at any time and will be used on the next render mesh selection.
  24477. * The possible values are :
  24478. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24479. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24480. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24481. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24482. * Please read each static variable documentation to get details about the culling process.
  24483. * */
  24484. cullingStrategy: number;
  24485. /**
  24486. * Gets the number of facets in the mesh
  24487. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24488. */
  24489. readonly facetNb: number;
  24490. /**
  24491. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24492. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24493. */
  24494. partitioningSubdivisions: number;
  24495. /**
  24496. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24497. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24498. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24499. */
  24500. partitioningBBoxRatio: number;
  24501. /**
  24502. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24503. * Works only for updatable meshes.
  24504. * Doesn't work with multi-materials
  24505. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24506. */
  24507. mustDepthSortFacets: boolean;
  24508. /**
  24509. * The location (Vector3) where the facet depth sort must be computed from.
  24510. * By default, the active camera position.
  24511. * Used only when facet depth sort is enabled
  24512. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24513. */
  24514. facetDepthSortFrom: Vector3;
  24515. /**
  24516. * gets a boolean indicating if facetData is enabled
  24517. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24518. */
  24519. readonly isFacetDataEnabled: boolean;
  24520. /** @hidden */
  24521. _updateNonUniformScalingState(value: boolean): boolean;
  24522. /**
  24523. * An event triggered when this mesh collides with another one
  24524. */
  24525. onCollideObservable: Observable<AbstractMesh>;
  24526. /** Set a function to call when this mesh collides with another one */
  24527. onCollide: () => void;
  24528. /**
  24529. * An event triggered when the collision's position changes
  24530. */
  24531. onCollisionPositionChangeObservable: Observable<Vector3>;
  24532. /** Set a function to call when the collision's position changes */
  24533. onCollisionPositionChange: () => void;
  24534. /**
  24535. * An event triggered when material is changed
  24536. */
  24537. onMaterialChangedObservable: Observable<AbstractMesh>;
  24538. /**
  24539. * Gets or sets the orientation for POV movement & rotation
  24540. */
  24541. definedFacingForward: boolean;
  24542. /** @hidden */
  24543. _occlusionQuery: Nullable<WebGLQuery>;
  24544. /** @hidden */
  24545. _renderingGroup: Nullable<RenderingGroup>;
  24546. /**
  24547. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24548. */
  24549. /**
  24550. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24551. */
  24552. visibility: number;
  24553. /** Gets or sets the alpha index used to sort transparent meshes
  24554. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24555. */
  24556. alphaIndex: number;
  24557. /**
  24558. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24559. */
  24560. isVisible: boolean;
  24561. /**
  24562. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24563. */
  24564. isPickable: boolean;
  24565. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24566. showSubMeshesBoundingBox: boolean;
  24567. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24568. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24569. */
  24570. isBlocker: boolean;
  24571. /**
  24572. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24573. */
  24574. enablePointerMoveEvents: boolean;
  24575. /**
  24576. * Specifies the rendering group id for this mesh (0 by default)
  24577. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24578. */
  24579. renderingGroupId: number;
  24580. private _material;
  24581. /** Gets or sets current material */
  24582. material: Nullable<Material>;
  24583. /**
  24584. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24585. * @see http://doc.babylonjs.com/babylon101/shadows
  24586. */
  24587. receiveShadows: boolean;
  24588. /** Defines color to use when rendering outline */
  24589. outlineColor: Color3;
  24590. /** Define width to use when rendering outline */
  24591. outlineWidth: number;
  24592. /** Defines color to use when rendering overlay */
  24593. overlayColor: Color3;
  24594. /** Defines alpha to use when rendering overlay */
  24595. overlayAlpha: number;
  24596. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24597. hasVertexAlpha: boolean;
  24598. /** 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) */
  24599. useVertexColors: boolean;
  24600. /**
  24601. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24602. */
  24603. computeBonesUsingShaders: boolean;
  24604. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24605. numBoneInfluencers: number;
  24606. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24607. applyFog: boolean;
  24608. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24609. useOctreeForRenderingSelection: boolean;
  24610. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24611. useOctreeForPicking: boolean;
  24612. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24613. useOctreeForCollisions: boolean;
  24614. /**
  24615. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24616. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24617. */
  24618. layerMask: number;
  24619. /**
  24620. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24621. */
  24622. alwaysSelectAsActiveMesh: boolean;
  24623. /**
  24624. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24625. */
  24626. doNotSyncBoundingInfo: boolean;
  24627. /**
  24628. * Gets or sets the current action manager
  24629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24630. */
  24631. actionManager: Nullable<AbstractActionManager>;
  24632. private _meshCollisionData;
  24633. /**
  24634. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24635. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24636. */
  24637. ellipsoid: Vector3;
  24638. /**
  24639. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24640. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24641. */
  24642. ellipsoidOffset: Vector3;
  24643. /**
  24644. * Gets or sets a collision mask used to mask collisions (default is -1).
  24645. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24646. */
  24647. collisionMask: number;
  24648. /**
  24649. * Gets or sets the current collision group mask (-1 by default).
  24650. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24651. */
  24652. collisionGroup: number;
  24653. /**
  24654. * Defines edge width used when edgesRenderer is enabled
  24655. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24656. */
  24657. edgesWidth: number;
  24658. /**
  24659. * Defines edge color used when edgesRenderer is enabled
  24660. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24661. */
  24662. edgesColor: Color4;
  24663. /** @hidden */
  24664. _edgesRenderer: Nullable<IEdgesRenderer>;
  24665. /** @hidden */
  24666. _masterMesh: Nullable<AbstractMesh>;
  24667. /** @hidden */
  24668. _boundingInfo: Nullable<BoundingInfo>;
  24669. /** @hidden */
  24670. _renderId: number;
  24671. /**
  24672. * Gets or sets the list of subMeshes
  24673. * @see http://doc.babylonjs.com/how_to/multi_materials
  24674. */
  24675. subMeshes: SubMesh[];
  24676. /** @hidden */
  24677. _intersectionsInProgress: AbstractMesh[];
  24678. /** @hidden */
  24679. _unIndexed: boolean;
  24680. /** @hidden */
  24681. _lightSources: Light[];
  24682. /** Gets the list of lights affecting that mesh */
  24683. readonly lightSources: Light[];
  24684. /** @hidden */
  24685. readonly _positions: Nullable<Vector3[]>;
  24686. /** @hidden */
  24687. _waitingData: {
  24688. lods: Nullable<any>;
  24689. actions: Nullable<any>;
  24690. freezeWorldMatrix: Nullable<boolean>;
  24691. };
  24692. /** @hidden */
  24693. _bonesTransformMatrices: Nullable<Float32Array>;
  24694. /**
  24695. * Gets or sets a skeleton to apply skining transformations
  24696. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24697. */
  24698. skeleton: Nullable<Skeleton>;
  24699. /**
  24700. * An event triggered when the mesh is rebuilt.
  24701. */
  24702. onRebuildObservable: Observable<AbstractMesh>;
  24703. /**
  24704. * Creates a new AbstractMesh
  24705. * @param name defines the name of the mesh
  24706. * @param scene defines the hosting scene
  24707. */
  24708. constructor(name: string, scene?: Nullable<Scene>);
  24709. /**
  24710. * Returns the string "AbstractMesh"
  24711. * @returns "AbstractMesh"
  24712. */
  24713. getClassName(): string;
  24714. /**
  24715. * Gets a string representation of the current mesh
  24716. * @param fullDetails defines a boolean indicating if full details must be included
  24717. * @returns a string representation of the current mesh
  24718. */
  24719. toString(fullDetails?: boolean): string;
  24720. /**
  24721. * @hidden
  24722. */
  24723. protected _getEffectiveParent(): Nullable<Node>;
  24724. /** @hidden */
  24725. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24726. /** @hidden */
  24727. _rebuild(): void;
  24728. /** @hidden */
  24729. _resyncLightSources(): void;
  24730. /** @hidden */
  24731. _resyncLighSource(light: Light): void;
  24732. /** @hidden */
  24733. _unBindEffect(): void;
  24734. /** @hidden */
  24735. _removeLightSource(light: Light): void;
  24736. private _markSubMeshesAsDirty;
  24737. /** @hidden */
  24738. _markSubMeshesAsLightDirty(): void;
  24739. /** @hidden */
  24740. _markSubMeshesAsAttributesDirty(): void;
  24741. /** @hidden */
  24742. _markSubMeshesAsMiscDirty(): void;
  24743. /**
  24744. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24745. */
  24746. scaling: Vector3;
  24747. /**
  24748. * Returns true if the mesh is blocked. Implemented by child classes
  24749. */
  24750. readonly isBlocked: boolean;
  24751. /**
  24752. * Returns the mesh itself by default. Implemented by child classes
  24753. * @param camera defines the camera to use to pick the right LOD level
  24754. * @returns the currentAbstractMesh
  24755. */
  24756. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24757. /**
  24758. * Returns 0 by default. Implemented by child classes
  24759. * @returns an integer
  24760. */
  24761. getTotalVertices(): number;
  24762. /**
  24763. * Returns a positive integer : the total number of indices in this mesh geometry.
  24764. * @returns the numner of indices or zero if the mesh has no geometry.
  24765. */
  24766. getTotalIndices(): number;
  24767. /**
  24768. * Returns null by default. Implemented by child classes
  24769. * @returns null
  24770. */
  24771. getIndices(): Nullable<IndicesArray>;
  24772. /**
  24773. * Returns the array of the requested vertex data kind. Implemented by child classes
  24774. * @param kind defines the vertex data kind to use
  24775. * @returns null
  24776. */
  24777. getVerticesData(kind: string): Nullable<FloatArray>;
  24778. /**
  24779. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24780. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24781. * Note that a new underlying VertexBuffer object is created each call.
  24782. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24783. * @param kind defines vertex data kind:
  24784. * * VertexBuffer.PositionKind
  24785. * * VertexBuffer.UVKind
  24786. * * VertexBuffer.UV2Kind
  24787. * * VertexBuffer.UV3Kind
  24788. * * VertexBuffer.UV4Kind
  24789. * * VertexBuffer.UV5Kind
  24790. * * VertexBuffer.UV6Kind
  24791. * * VertexBuffer.ColorKind
  24792. * * VertexBuffer.MatricesIndicesKind
  24793. * * VertexBuffer.MatricesIndicesExtraKind
  24794. * * VertexBuffer.MatricesWeightsKind
  24795. * * VertexBuffer.MatricesWeightsExtraKind
  24796. * @param data defines the data source
  24797. * @param updatable defines if the data must be flagged as updatable (or static)
  24798. * @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
  24799. * @returns the current mesh
  24800. */
  24801. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24802. /**
  24803. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24804. * If the mesh has no geometry, it is simply returned as it is.
  24805. * @param kind defines vertex data kind:
  24806. * * VertexBuffer.PositionKind
  24807. * * VertexBuffer.UVKind
  24808. * * VertexBuffer.UV2Kind
  24809. * * VertexBuffer.UV3Kind
  24810. * * VertexBuffer.UV4Kind
  24811. * * VertexBuffer.UV5Kind
  24812. * * VertexBuffer.UV6Kind
  24813. * * VertexBuffer.ColorKind
  24814. * * VertexBuffer.MatricesIndicesKind
  24815. * * VertexBuffer.MatricesIndicesExtraKind
  24816. * * VertexBuffer.MatricesWeightsKind
  24817. * * VertexBuffer.MatricesWeightsExtraKind
  24818. * @param data defines the data source
  24819. * @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
  24820. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24821. * @returns the current mesh
  24822. */
  24823. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24824. /**
  24825. * Sets the mesh indices,
  24826. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24827. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24828. * @param totalVertices Defines the total number of vertices
  24829. * @returns the current mesh
  24830. */
  24831. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24832. /**
  24833. * Gets a boolean indicating if specific vertex data is present
  24834. * @param kind defines the vertex data kind to use
  24835. * @returns true is data kind is present
  24836. */
  24837. isVerticesDataPresent(kind: string): boolean;
  24838. /**
  24839. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24840. * @returns a BoundingInfo
  24841. */
  24842. getBoundingInfo(): BoundingInfo;
  24843. /**
  24844. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24845. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24846. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24847. * @returns the current mesh
  24848. */
  24849. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24850. /**
  24851. * Overwrite the current bounding info
  24852. * @param boundingInfo defines the new bounding info
  24853. * @returns the current mesh
  24854. */
  24855. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24856. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24857. readonly useBones: boolean;
  24858. /** @hidden */
  24859. _preActivate(): void;
  24860. /** @hidden */
  24861. _preActivateForIntermediateRendering(renderId: number): void;
  24862. /** @hidden */
  24863. _activate(renderId: number, intermediateRendering: boolean): boolean;
  24864. /** @hidden */
  24865. _postActivate(): void;
  24866. /** @hidden */
  24867. _freeze(): void;
  24868. /** @hidden */
  24869. _unFreeze(): void;
  24870. /**
  24871. * Gets the current world matrix
  24872. * @returns a Matrix
  24873. */
  24874. getWorldMatrix(): Matrix;
  24875. /** @hidden */
  24876. _getWorldMatrixDeterminant(): number;
  24877. /**
  24878. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24879. */
  24880. readonly isAnInstance: boolean;
  24881. /**
  24882. * Perform relative position change from the point of view of behind the front of the mesh.
  24883. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24884. * Supports definition of mesh facing forward or backward
  24885. * @param amountRight defines the distance on the right axis
  24886. * @param amountUp defines the distance on the up axis
  24887. * @param amountForward defines the distance on the forward axis
  24888. * @returns the current mesh
  24889. */
  24890. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24891. /**
  24892. * Calculate relative position change from the point of view of behind the front of the mesh.
  24893. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24894. * Supports definition of mesh facing forward or backward
  24895. * @param amountRight defines the distance on the right axis
  24896. * @param amountUp defines the distance on the up axis
  24897. * @param amountForward defines the distance on the forward axis
  24898. * @returns the new displacement vector
  24899. */
  24900. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24901. /**
  24902. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24903. * Supports definition of mesh facing forward or backward
  24904. * @param flipBack defines the flip
  24905. * @param twirlClockwise defines the twirl
  24906. * @param tiltRight defines the tilt
  24907. * @returns the current mesh
  24908. */
  24909. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24910. /**
  24911. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24912. * Supports definition of mesh facing forward or backward.
  24913. * @param flipBack defines the flip
  24914. * @param twirlClockwise defines the twirl
  24915. * @param tiltRight defines the tilt
  24916. * @returns the new rotation vector
  24917. */
  24918. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24919. /**
  24920. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24921. * This means the mesh underlying bounding box and sphere are recomputed.
  24922. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24923. * @returns the current mesh
  24924. */
  24925. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24926. /** @hidden */
  24927. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24928. /** @hidden */
  24929. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24930. /** @hidden */
  24931. _updateBoundingInfo(): AbstractMesh;
  24932. /** @hidden */
  24933. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24934. /** @hidden */
  24935. protected _afterComputeWorldMatrix(): void;
  24936. /** @hidden */
  24937. readonly _effectiveMesh: AbstractMesh;
  24938. /**
  24939. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24940. * A mesh is in the frustum if its bounding box intersects the frustum
  24941. * @param frustumPlanes defines the frustum to test
  24942. * @returns true if the mesh is in the frustum planes
  24943. */
  24944. isInFrustum(frustumPlanes: Plane[]): boolean;
  24945. /**
  24946. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24947. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24948. * @param frustumPlanes defines the frustum to test
  24949. * @returns true if the mesh is completely in the frustum planes
  24950. */
  24951. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24952. /**
  24953. * True if the mesh intersects another mesh or a SolidParticle object
  24954. * @param mesh defines a target mesh or SolidParticle to test
  24955. * @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)
  24956. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24957. * @returns true if there is an intersection
  24958. */
  24959. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24960. /**
  24961. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24962. * @param point defines the point to test
  24963. * @returns true if there is an intersection
  24964. */
  24965. intersectsPoint(point: Vector3): boolean;
  24966. /**
  24967. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24968. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24969. */
  24970. checkCollisions: boolean;
  24971. /**
  24972. * Gets Collider object used to compute collisions (not physics)
  24973. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24974. */
  24975. readonly collider: Nullable<Collider>;
  24976. /**
  24977. * Move the mesh using collision engine
  24978. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24979. * @param displacement defines the requested displacement vector
  24980. * @returns the current mesh
  24981. */
  24982. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24983. private _onCollisionPositionChange;
  24984. /** @hidden */
  24985. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24986. /** @hidden */
  24987. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24988. /** @hidden */
  24989. _checkCollision(collider: Collider): AbstractMesh;
  24990. /** @hidden */
  24991. _generatePointsArray(): boolean;
  24992. /**
  24993. * Checks if the passed Ray intersects with the mesh
  24994. * @param ray defines the ray to use
  24995. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24996. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24997. * @returns the picking info
  24998. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24999. */
  25000. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25001. /**
  25002. * Clones the current mesh
  25003. * @param name defines the mesh name
  25004. * @param newParent defines the new mesh parent
  25005. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25006. * @returns the new mesh
  25007. */
  25008. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25009. /**
  25010. * Disposes all the submeshes of the current meshnp
  25011. * @returns the current mesh
  25012. */
  25013. releaseSubMeshes(): AbstractMesh;
  25014. /**
  25015. * Releases resources associated with this abstract mesh.
  25016. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25017. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25018. */
  25019. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25020. /**
  25021. * Adds the passed mesh as a child to the current mesh
  25022. * @param mesh defines the child mesh
  25023. * @returns the current mesh
  25024. */
  25025. addChild(mesh: AbstractMesh): AbstractMesh;
  25026. /**
  25027. * Removes the passed mesh from the current mesh children list
  25028. * @param mesh defines the child mesh
  25029. * @returns the current mesh
  25030. */
  25031. removeChild(mesh: AbstractMesh): AbstractMesh;
  25032. /** @hidden */
  25033. private _initFacetData;
  25034. /**
  25035. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25036. * This method can be called within the render loop.
  25037. * 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
  25038. * @returns the current mesh
  25039. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25040. */
  25041. updateFacetData(): AbstractMesh;
  25042. /**
  25043. * Returns the facetLocalNormals array.
  25044. * The normals are expressed in the mesh local spac
  25045. * @returns an array of Vector3
  25046. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25047. */
  25048. getFacetLocalNormals(): Vector3[];
  25049. /**
  25050. * Returns the facetLocalPositions array.
  25051. * The facet positions are expressed in the mesh local space
  25052. * @returns an array of Vector3
  25053. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25054. */
  25055. getFacetLocalPositions(): Vector3[];
  25056. /**
  25057. * Returns the facetLocalPartioning array
  25058. * @returns an array of array of numbers
  25059. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25060. */
  25061. getFacetLocalPartitioning(): number[][];
  25062. /**
  25063. * Returns the i-th facet position in the world system.
  25064. * This method allocates a new Vector3 per call
  25065. * @param i defines the facet index
  25066. * @returns a new Vector3
  25067. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25068. */
  25069. getFacetPosition(i: number): Vector3;
  25070. /**
  25071. * Sets the reference Vector3 with the i-th facet position in the world system
  25072. * @param i defines the facet index
  25073. * @param ref defines the target vector
  25074. * @returns the current mesh
  25075. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25076. */
  25077. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25078. /**
  25079. * Returns the i-th facet normal in the world system.
  25080. * This method allocates a new Vector3 per call
  25081. * @param i defines the facet index
  25082. * @returns a new Vector3
  25083. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25084. */
  25085. getFacetNormal(i: number): Vector3;
  25086. /**
  25087. * Sets the reference Vector3 with the i-th facet normal in the world system
  25088. * @param i defines the facet index
  25089. * @param ref defines the target vector
  25090. * @returns the current mesh
  25091. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25092. */
  25093. getFacetNormalToRef(i: number, ref: Vector3): this;
  25094. /**
  25095. * 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)
  25096. * @param x defines x coordinate
  25097. * @param y defines y coordinate
  25098. * @param z defines z coordinate
  25099. * @returns the array of facet indexes
  25100. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25101. */
  25102. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25103. /**
  25104. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25105. * @param projected sets as the (x,y,z) world projection on the facet
  25106. * @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
  25107. * @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
  25108. * @param x defines x coordinate
  25109. * @param y defines y coordinate
  25110. * @param z defines z coordinate
  25111. * @returns the face index if found (or null instead)
  25112. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25113. */
  25114. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25115. /**
  25116. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25117. * @param projected sets as the (x,y,z) local projection on the facet
  25118. * @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
  25119. * @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
  25120. * @param x defines x coordinate
  25121. * @param y defines y coordinate
  25122. * @param z defines z coordinate
  25123. * @returns the face index if found (or null instead)
  25124. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25125. */
  25126. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25127. /**
  25128. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25129. * @returns the parameters
  25130. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25131. */
  25132. getFacetDataParameters(): any;
  25133. /**
  25134. * Disables the feature FacetData and frees the related memory
  25135. * @returns the current mesh
  25136. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25137. */
  25138. disableFacetData(): AbstractMesh;
  25139. /**
  25140. * Updates the AbstractMesh indices array
  25141. * @param indices defines the data source
  25142. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25143. * @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)
  25144. * @returns the current mesh
  25145. */
  25146. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25147. /**
  25148. * Creates new normals data for the mesh
  25149. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25150. * @returns the current mesh
  25151. */
  25152. createNormals(updatable: boolean): AbstractMesh;
  25153. /**
  25154. * Align the mesh with a normal
  25155. * @param normal defines the normal to use
  25156. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25157. * @returns the current mesh
  25158. */
  25159. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25160. /** @hidden */
  25161. _checkOcclusionQuery(): boolean;
  25162. /**
  25163. * Disables the mesh edge rendering mode
  25164. * @returns the currentAbstractMesh
  25165. */
  25166. disableEdgesRendering(): AbstractMesh;
  25167. /**
  25168. * Enables the edge rendering mode on the mesh.
  25169. * This mode makes the mesh edges visible
  25170. * @param epsilon defines the maximal distance between two angles to detect a face
  25171. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25172. * @returns the currentAbstractMesh
  25173. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25174. */
  25175. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25176. }
  25177. }
  25178. declare module BABYLON {
  25179. /**
  25180. * Interface used to define ActionEvent
  25181. */
  25182. export interface IActionEvent {
  25183. /** The mesh or sprite that triggered the action */
  25184. source: any;
  25185. /** The X mouse cursor position at the time of the event */
  25186. pointerX: number;
  25187. /** The Y mouse cursor position at the time of the event */
  25188. pointerY: number;
  25189. /** The mesh that is currently pointed at (can be null) */
  25190. meshUnderPointer: Nullable<AbstractMesh>;
  25191. /** the original (browser) event that triggered the ActionEvent */
  25192. sourceEvent?: any;
  25193. /** additional data for the event */
  25194. additionalData?: any;
  25195. }
  25196. /**
  25197. * ActionEvent is the event being sent when an action is triggered.
  25198. */
  25199. export class ActionEvent implements IActionEvent {
  25200. /** The mesh or sprite that triggered the action */
  25201. source: any;
  25202. /** The X mouse cursor position at the time of the event */
  25203. pointerX: number;
  25204. /** The Y mouse cursor position at the time of the event */
  25205. pointerY: number;
  25206. /** The mesh that is currently pointed at (can be null) */
  25207. meshUnderPointer: Nullable<AbstractMesh>;
  25208. /** the original (browser) event that triggered the ActionEvent */
  25209. sourceEvent?: any;
  25210. /** additional data for the event */
  25211. additionalData?: any;
  25212. /**
  25213. * Creates a new ActionEvent
  25214. * @param source The mesh or sprite that triggered the action
  25215. * @param pointerX The X mouse cursor position at the time of the event
  25216. * @param pointerY The Y mouse cursor position at the time of the event
  25217. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25218. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25219. * @param additionalData additional data for the event
  25220. */
  25221. constructor(
  25222. /** The mesh or sprite that triggered the action */
  25223. source: any,
  25224. /** The X mouse cursor position at the time of the event */
  25225. pointerX: number,
  25226. /** The Y mouse cursor position at the time of the event */
  25227. pointerY: number,
  25228. /** The mesh that is currently pointed at (can be null) */
  25229. meshUnderPointer: Nullable<AbstractMesh>,
  25230. /** the original (browser) event that triggered the ActionEvent */
  25231. sourceEvent?: any,
  25232. /** additional data for the event */
  25233. additionalData?: any);
  25234. /**
  25235. * Helper function to auto-create an ActionEvent from a source mesh.
  25236. * @param source The source mesh that triggered the event
  25237. * @param evt The original (browser) event
  25238. * @param additionalData additional data for the event
  25239. * @returns the new ActionEvent
  25240. */
  25241. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25242. /**
  25243. * Helper function to auto-create an ActionEvent from a source sprite
  25244. * @param source The source sprite that triggered the event
  25245. * @param scene Scene associated with the sprite
  25246. * @param evt The original (browser) event
  25247. * @param additionalData additional data for the event
  25248. * @returns the new ActionEvent
  25249. */
  25250. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25251. /**
  25252. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25253. * @param scene the scene where the event occurred
  25254. * @param evt The original (browser) event
  25255. * @returns the new ActionEvent
  25256. */
  25257. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25258. /**
  25259. * Helper function to auto-create an ActionEvent from a primitive
  25260. * @param prim defines the target primitive
  25261. * @param pointerPos defines the pointer position
  25262. * @param evt The original (browser) event
  25263. * @param additionalData additional data for the event
  25264. * @returns the new ActionEvent
  25265. */
  25266. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25267. }
  25268. }
  25269. declare module BABYLON {
  25270. /**
  25271. * Abstract class used to decouple action Manager from scene and meshes.
  25272. * Do not instantiate.
  25273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25274. */
  25275. export abstract class AbstractActionManager implements IDisposable {
  25276. /** Gets the list of active triggers */
  25277. static Triggers: {
  25278. [key: string]: number;
  25279. };
  25280. /** Gets the cursor to use when hovering items */
  25281. hoverCursor: string;
  25282. /** Gets the list of actions */
  25283. actions: IAction[];
  25284. /**
  25285. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25286. */
  25287. isRecursive: boolean;
  25288. /**
  25289. * Releases all associated resources
  25290. */
  25291. abstract dispose(): void;
  25292. /**
  25293. * Does this action manager has pointer triggers
  25294. */
  25295. abstract readonly hasPointerTriggers: boolean;
  25296. /**
  25297. * Does this action manager has pick triggers
  25298. */
  25299. abstract readonly hasPickTriggers: boolean;
  25300. /**
  25301. * Process a specific trigger
  25302. * @param trigger defines the trigger to process
  25303. * @param evt defines the event details to be processed
  25304. */
  25305. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25306. /**
  25307. * Does this action manager handles actions of any of the given triggers
  25308. * @param triggers defines the triggers to be tested
  25309. * @return a boolean indicating whether one (or more) of the triggers is handled
  25310. */
  25311. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25312. /**
  25313. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25314. * speed.
  25315. * @param triggerA defines the trigger to be tested
  25316. * @param triggerB defines the trigger to be tested
  25317. * @return a boolean indicating whether one (or more) of the triggers is handled
  25318. */
  25319. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25320. /**
  25321. * Does this action manager handles actions of a given trigger
  25322. * @param trigger defines the trigger to be tested
  25323. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25324. * @return whether the trigger is handled
  25325. */
  25326. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25327. /**
  25328. * Serialize this manager to a JSON object
  25329. * @param name defines the property name to store this manager
  25330. * @returns a JSON representation of this manager
  25331. */
  25332. abstract serialize(name: string): any;
  25333. /**
  25334. * Registers an action to this action manager
  25335. * @param action defines the action to be registered
  25336. * @return the action amended (prepared) after registration
  25337. */
  25338. abstract registerAction(action: IAction): Nullable<IAction>;
  25339. /**
  25340. * Unregisters an action to this action manager
  25341. * @param action defines the action to be unregistered
  25342. * @return a boolean indicating whether the action has been unregistered
  25343. */
  25344. abstract unregisterAction(action: IAction): Boolean;
  25345. /**
  25346. * Does exist one action manager with at least one trigger
  25347. **/
  25348. static readonly HasTriggers: boolean;
  25349. /**
  25350. * Does exist one action manager with at least one pick trigger
  25351. **/
  25352. static readonly HasPickTriggers: boolean;
  25353. /**
  25354. * Does exist one action manager that handles actions of a given trigger
  25355. * @param trigger defines the trigger to be tested
  25356. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25357. **/
  25358. static HasSpecificTrigger(trigger: number): boolean;
  25359. }
  25360. }
  25361. declare module BABYLON {
  25362. /**
  25363. * Defines how a node can be built from a string name.
  25364. */
  25365. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25366. /**
  25367. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25368. */
  25369. export class Node implements IBehaviorAware<Node> {
  25370. /** @hidden */
  25371. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25372. private static _NodeConstructors;
  25373. /**
  25374. * Add a new node constructor
  25375. * @param type defines the type name of the node to construct
  25376. * @param constructorFunc defines the constructor function
  25377. */
  25378. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25379. /**
  25380. * Returns a node constructor based on type name
  25381. * @param type defines the type name
  25382. * @param name defines the new node name
  25383. * @param scene defines the hosting scene
  25384. * @param options defines optional options to transmit to constructors
  25385. * @returns the new constructor or null
  25386. */
  25387. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25388. /**
  25389. * Gets or sets the name of the node
  25390. */
  25391. name: string;
  25392. /**
  25393. * Gets or sets the id of the node
  25394. */
  25395. id: string;
  25396. /**
  25397. * Gets or sets the unique id of the node
  25398. */
  25399. uniqueId: number;
  25400. /**
  25401. * Gets or sets a string used to store user defined state for the node
  25402. */
  25403. state: string;
  25404. /**
  25405. * Gets or sets an object used to store user defined information for the node
  25406. */
  25407. metadata: any;
  25408. /**
  25409. * For internal use only. Please do not use.
  25410. */
  25411. reservedDataStore: any;
  25412. /**
  25413. * List of inspectable custom properties (used by the Inspector)
  25414. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25415. */
  25416. inspectableCustomProperties: IInspectable[];
  25417. /**
  25418. * Gets or sets a boolean used to define if the node must be serialized
  25419. */
  25420. doNotSerialize: boolean;
  25421. /** @hidden */
  25422. _isDisposed: boolean;
  25423. /**
  25424. * Gets a list of Animations associated with the node
  25425. */
  25426. animations: Animation[];
  25427. protected _ranges: {
  25428. [name: string]: Nullable<AnimationRange>;
  25429. };
  25430. /**
  25431. * Callback raised when the node is ready to be used
  25432. */
  25433. onReady: Nullable<(node: Node) => void>;
  25434. private _isEnabled;
  25435. private _isParentEnabled;
  25436. private _isReady;
  25437. /** @hidden */
  25438. _currentRenderId: number;
  25439. private _parentUpdateId;
  25440. /** @hidden */
  25441. _childUpdateId: number;
  25442. /** @hidden */
  25443. _waitingParentId: Nullable<string>;
  25444. /** @hidden */
  25445. _scene: Scene;
  25446. /** @hidden */
  25447. _cache: any;
  25448. private _parentNode;
  25449. private _children;
  25450. /** @hidden */
  25451. _worldMatrix: Matrix;
  25452. /** @hidden */
  25453. _worldMatrixDeterminant: number;
  25454. /** @hidden */
  25455. _worldMatrixDeterminantIsDirty: boolean;
  25456. /** @hidden */
  25457. private _sceneRootNodesIndex;
  25458. /**
  25459. * Gets a boolean indicating if the node has been disposed
  25460. * @returns true if the node was disposed
  25461. */
  25462. isDisposed(): boolean;
  25463. /**
  25464. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25465. * @see https://doc.babylonjs.com/how_to/parenting
  25466. */
  25467. parent: Nullable<Node>;
  25468. private addToSceneRootNodes;
  25469. private removeFromSceneRootNodes;
  25470. private _animationPropertiesOverride;
  25471. /**
  25472. * Gets or sets the animation properties override
  25473. */
  25474. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25475. /**
  25476. * Gets a string idenfifying the name of the class
  25477. * @returns "Node" string
  25478. */
  25479. getClassName(): string;
  25480. /** @hidden */
  25481. readonly _isNode: boolean;
  25482. /**
  25483. * An event triggered when the mesh is disposed
  25484. */
  25485. onDisposeObservable: Observable<Node>;
  25486. private _onDisposeObserver;
  25487. /**
  25488. * Sets a callback that will be raised when the node will be disposed
  25489. */
  25490. onDispose: () => void;
  25491. /**
  25492. * Creates a new Node
  25493. * @param name the name and id to be given to this node
  25494. * @param scene the scene this node will be added to
  25495. * @param addToRootNodes the node will be added to scene.rootNodes
  25496. */
  25497. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25498. /**
  25499. * Gets the scene of the node
  25500. * @returns a scene
  25501. */
  25502. getScene(): Scene;
  25503. /**
  25504. * Gets the engine of the node
  25505. * @returns a Engine
  25506. */
  25507. getEngine(): Engine;
  25508. private _behaviors;
  25509. /**
  25510. * Attach a behavior to the node
  25511. * @see http://doc.babylonjs.com/features/behaviour
  25512. * @param behavior defines the behavior to attach
  25513. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25514. * @returns the current Node
  25515. */
  25516. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25517. /**
  25518. * Remove an attached behavior
  25519. * @see http://doc.babylonjs.com/features/behaviour
  25520. * @param behavior defines the behavior to attach
  25521. * @returns the current Node
  25522. */
  25523. removeBehavior(behavior: Behavior<Node>): Node;
  25524. /**
  25525. * Gets the list of attached behaviors
  25526. * @see http://doc.babylonjs.com/features/behaviour
  25527. */
  25528. readonly behaviors: Behavior<Node>[];
  25529. /**
  25530. * Gets an attached behavior by name
  25531. * @param name defines the name of the behavior to look for
  25532. * @see http://doc.babylonjs.com/features/behaviour
  25533. * @returns null if behavior was not found else the requested behavior
  25534. */
  25535. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25536. /**
  25537. * Returns the latest update of the World matrix
  25538. * @returns a Matrix
  25539. */
  25540. getWorldMatrix(): Matrix;
  25541. /** @hidden */
  25542. _getWorldMatrixDeterminant(): number;
  25543. /**
  25544. * Returns directly the latest state of the mesh World matrix.
  25545. * A Matrix is returned.
  25546. */
  25547. readonly worldMatrixFromCache: Matrix;
  25548. /** @hidden */
  25549. _initCache(): void;
  25550. /** @hidden */
  25551. updateCache(force?: boolean): void;
  25552. /** @hidden */
  25553. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25554. /** @hidden */
  25555. _updateCache(ignoreParentClass?: boolean): void;
  25556. /** @hidden */
  25557. _isSynchronized(): boolean;
  25558. /** @hidden */
  25559. _markSyncedWithParent(): void;
  25560. /** @hidden */
  25561. isSynchronizedWithParent(): boolean;
  25562. /** @hidden */
  25563. isSynchronized(): boolean;
  25564. /**
  25565. * Is this node ready to be used/rendered
  25566. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25567. * @return true if the node is ready
  25568. */
  25569. isReady(completeCheck?: boolean): boolean;
  25570. /**
  25571. * Is this node enabled?
  25572. * 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
  25573. * @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
  25574. * @return whether this node (and its parent) is enabled
  25575. */
  25576. isEnabled(checkAncestors?: boolean): boolean;
  25577. /** @hidden */
  25578. protected _syncParentEnabledState(): void;
  25579. /**
  25580. * Set the enabled state of this node
  25581. * @param value defines the new enabled state
  25582. */
  25583. setEnabled(value: boolean): void;
  25584. /**
  25585. * Is this node a descendant of the given node?
  25586. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25587. * @param ancestor defines the parent node to inspect
  25588. * @returns a boolean indicating if this node is a descendant of the given node
  25589. */
  25590. isDescendantOf(ancestor: Node): boolean;
  25591. /** @hidden */
  25592. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25593. /**
  25594. * Will return all nodes that have this node as ascendant
  25595. * @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
  25596. * @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
  25597. * @return all children nodes of all types
  25598. */
  25599. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25600. /**
  25601. * Get all child-meshes of this node
  25602. * @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)
  25603. * @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
  25604. * @returns an array of AbstractMesh
  25605. */
  25606. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25607. /**
  25608. * Get all direct children of this node
  25609. * @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
  25610. * @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)
  25611. * @returns an array of Node
  25612. */
  25613. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25614. /** @hidden */
  25615. _setReady(state: boolean): void;
  25616. /**
  25617. * Get an animation by name
  25618. * @param name defines the name of the animation to look for
  25619. * @returns null if not found else the requested animation
  25620. */
  25621. getAnimationByName(name: string): Nullable<Animation>;
  25622. /**
  25623. * Creates an animation range for this node
  25624. * @param name defines the name of the range
  25625. * @param from defines the starting key
  25626. * @param to defines the end key
  25627. */
  25628. createAnimationRange(name: string, from: number, to: number): void;
  25629. /**
  25630. * Delete a specific animation range
  25631. * @param name defines the name of the range to delete
  25632. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25633. */
  25634. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25635. /**
  25636. * Get an animation range by name
  25637. * @param name defines the name of the animation range to look for
  25638. * @returns null if not found else the requested animation range
  25639. */
  25640. getAnimationRange(name: string): Nullable<AnimationRange>;
  25641. /**
  25642. * Gets the list of all animation ranges defined on this node
  25643. * @returns an array
  25644. */
  25645. getAnimationRanges(): Nullable<AnimationRange>[];
  25646. /**
  25647. * Will start the animation sequence
  25648. * @param name defines the range frames for animation sequence
  25649. * @param loop defines if the animation should loop (false by default)
  25650. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25651. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25652. * @returns the object created for this animation. If range does not exist, it will return null
  25653. */
  25654. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25655. /**
  25656. * Serialize animation ranges into a JSON compatible object
  25657. * @returns serialization object
  25658. */
  25659. serializeAnimationRanges(): any;
  25660. /**
  25661. * Computes the world matrix of the node
  25662. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25663. * @returns the world matrix
  25664. */
  25665. computeWorldMatrix(force?: boolean): Matrix;
  25666. /**
  25667. * Releases resources associated with this node.
  25668. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25669. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25670. */
  25671. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25672. /**
  25673. * Parse animation range data from a serialization object and store them into a given node
  25674. * @param node defines where to store the animation ranges
  25675. * @param parsedNode defines the serialization object to read data from
  25676. * @param scene defines the hosting scene
  25677. */
  25678. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25679. /**
  25680. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25681. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25682. * @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
  25683. * @returns the new bounding vectors
  25684. */
  25685. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25686. min: Vector3;
  25687. max: Vector3;
  25688. };
  25689. }
  25690. }
  25691. declare module BABYLON {
  25692. /**
  25693. * @hidden
  25694. */
  25695. export class _IAnimationState {
  25696. key: number;
  25697. repeatCount: number;
  25698. workValue?: any;
  25699. loopMode?: number;
  25700. offsetValue?: any;
  25701. highLimitValue?: any;
  25702. }
  25703. /**
  25704. * Class used to store any kind of animation
  25705. */
  25706. export class Animation {
  25707. /**Name of the animation */
  25708. name: string;
  25709. /**Property to animate */
  25710. targetProperty: string;
  25711. /**The frames per second of the animation */
  25712. framePerSecond: number;
  25713. /**The data type of the animation */
  25714. dataType: number;
  25715. /**The loop mode of the animation */
  25716. loopMode?: number | undefined;
  25717. /**Specifies if blending should be enabled */
  25718. enableBlending?: boolean | undefined;
  25719. /**
  25720. * Use matrix interpolation instead of using direct key value when animating matrices
  25721. */
  25722. static AllowMatricesInterpolation: boolean;
  25723. /**
  25724. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25725. */
  25726. static AllowMatrixDecomposeForInterpolation: boolean;
  25727. /**
  25728. * Stores the key frames of the animation
  25729. */
  25730. private _keys;
  25731. /**
  25732. * Stores the easing function of the animation
  25733. */
  25734. private _easingFunction;
  25735. /**
  25736. * @hidden Internal use only
  25737. */
  25738. _runtimeAnimations: RuntimeAnimation[];
  25739. /**
  25740. * The set of event that will be linked to this animation
  25741. */
  25742. private _events;
  25743. /**
  25744. * Stores an array of target property paths
  25745. */
  25746. targetPropertyPath: string[];
  25747. /**
  25748. * Stores the blending speed of the animation
  25749. */
  25750. blendingSpeed: number;
  25751. /**
  25752. * Stores the animation ranges for the animation
  25753. */
  25754. private _ranges;
  25755. /**
  25756. * @hidden Internal use
  25757. */
  25758. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25759. /**
  25760. * Sets up an animation
  25761. * @param property The property to animate
  25762. * @param animationType The animation type to apply
  25763. * @param framePerSecond The frames per second of the animation
  25764. * @param easingFunction The easing function used in the animation
  25765. * @returns The created animation
  25766. */
  25767. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25768. /**
  25769. * Create and start an animation on a node
  25770. * @param name defines the name of the global animation that will be run on all nodes
  25771. * @param node defines the root node where the animation will take place
  25772. * @param targetProperty defines property to animate
  25773. * @param framePerSecond defines the number of frame per second yo use
  25774. * @param totalFrame defines the number of frames in total
  25775. * @param from defines the initial value
  25776. * @param to defines the final value
  25777. * @param loopMode defines which loop mode you want to use (off by default)
  25778. * @param easingFunction defines the easing function to use (linear by default)
  25779. * @param onAnimationEnd defines the callback to call when animation end
  25780. * @returns the animatable created for this animation
  25781. */
  25782. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25783. /**
  25784. * Create and start an animation on a node and its descendants
  25785. * @param name defines the name of the global animation that will be run on all nodes
  25786. * @param node defines the root node where the animation will take place
  25787. * @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
  25788. * @param targetProperty defines property to animate
  25789. * @param framePerSecond defines the number of frame per second to use
  25790. * @param totalFrame defines the number of frames in total
  25791. * @param from defines the initial value
  25792. * @param to defines the final value
  25793. * @param loopMode defines which loop mode you want to use (off by default)
  25794. * @param easingFunction defines the easing function to use (linear by default)
  25795. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25796. * @returns the list of animatables created for all nodes
  25797. * @example https://www.babylonjs-playground.com/#MH0VLI
  25798. */
  25799. 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[]>;
  25800. /**
  25801. * Creates a new animation, merges it with the existing animations and starts it
  25802. * @param name Name of the animation
  25803. * @param node Node which contains the scene that begins the animations
  25804. * @param targetProperty Specifies which property to animate
  25805. * @param framePerSecond The frames per second of the animation
  25806. * @param totalFrame The total number of frames
  25807. * @param from The frame at the beginning of the animation
  25808. * @param to The frame at the end of the animation
  25809. * @param loopMode Specifies the loop mode of the animation
  25810. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25811. * @param onAnimationEnd Callback to run once the animation is complete
  25812. * @returns Nullable animation
  25813. */
  25814. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25815. /**
  25816. * Transition property of an host to the target Value
  25817. * @param property The property to transition
  25818. * @param targetValue The target Value of the property
  25819. * @param host The object where the property to animate belongs
  25820. * @param scene Scene used to run the animation
  25821. * @param frameRate Framerate (in frame/s) to use
  25822. * @param transition The transition type we want to use
  25823. * @param duration The duration of the animation, in milliseconds
  25824. * @param onAnimationEnd Callback trigger at the end of the animation
  25825. * @returns Nullable animation
  25826. */
  25827. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25828. /**
  25829. * Return the array of runtime animations currently using this animation
  25830. */
  25831. readonly runtimeAnimations: RuntimeAnimation[];
  25832. /**
  25833. * Specifies if any of the runtime animations are currently running
  25834. */
  25835. readonly hasRunningRuntimeAnimations: boolean;
  25836. /**
  25837. * Initializes the animation
  25838. * @param name Name of the animation
  25839. * @param targetProperty Property to animate
  25840. * @param framePerSecond The frames per second of the animation
  25841. * @param dataType The data type of the animation
  25842. * @param loopMode The loop mode of the animation
  25843. * @param enableBlending Specifies if blending should be enabled
  25844. */
  25845. constructor(
  25846. /**Name of the animation */
  25847. name: string,
  25848. /**Property to animate */
  25849. targetProperty: string,
  25850. /**The frames per second of the animation */
  25851. framePerSecond: number,
  25852. /**The data type of the animation */
  25853. dataType: number,
  25854. /**The loop mode of the animation */
  25855. loopMode?: number | undefined,
  25856. /**Specifies if blending should be enabled */
  25857. enableBlending?: boolean | undefined);
  25858. /**
  25859. * Converts the animation to a string
  25860. * @param fullDetails support for multiple levels of logging within scene loading
  25861. * @returns String form of the animation
  25862. */
  25863. toString(fullDetails?: boolean): string;
  25864. /**
  25865. * Add an event to this animation
  25866. * @param event Event to add
  25867. */
  25868. addEvent(event: AnimationEvent): void;
  25869. /**
  25870. * Remove all events found at the given frame
  25871. * @param frame The frame to remove events from
  25872. */
  25873. removeEvents(frame: number): void;
  25874. /**
  25875. * Retrieves all the events from the animation
  25876. * @returns Events from the animation
  25877. */
  25878. getEvents(): AnimationEvent[];
  25879. /**
  25880. * Creates an animation range
  25881. * @param name Name of the animation range
  25882. * @param from Starting frame of the animation range
  25883. * @param to Ending frame of the animation
  25884. */
  25885. createRange(name: string, from: number, to: number): void;
  25886. /**
  25887. * Deletes an animation range by name
  25888. * @param name Name of the animation range to delete
  25889. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25890. */
  25891. deleteRange(name: string, deleteFrames?: boolean): void;
  25892. /**
  25893. * Gets the animation range by name, or null if not defined
  25894. * @param name Name of the animation range
  25895. * @returns Nullable animation range
  25896. */
  25897. getRange(name: string): Nullable<AnimationRange>;
  25898. /**
  25899. * Gets the key frames from the animation
  25900. * @returns The key frames of the animation
  25901. */
  25902. getKeys(): Array<IAnimationKey>;
  25903. /**
  25904. * Gets the highest frame rate of the animation
  25905. * @returns Highest frame rate of the animation
  25906. */
  25907. getHighestFrame(): number;
  25908. /**
  25909. * Gets the easing function of the animation
  25910. * @returns Easing function of the animation
  25911. */
  25912. getEasingFunction(): IEasingFunction;
  25913. /**
  25914. * Sets the easing function of the animation
  25915. * @param easingFunction A custom mathematical formula for animation
  25916. */
  25917. setEasingFunction(easingFunction: EasingFunction): void;
  25918. /**
  25919. * Interpolates a scalar linearly
  25920. * @param startValue Start value of the animation curve
  25921. * @param endValue End value of the animation curve
  25922. * @param gradient Scalar amount to interpolate
  25923. * @returns Interpolated scalar value
  25924. */
  25925. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25926. /**
  25927. * Interpolates a scalar cubically
  25928. * @param startValue Start value of the animation curve
  25929. * @param outTangent End tangent of the animation
  25930. * @param endValue End value of the animation curve
  25931. * @param inTangent Start tangent of the animation curve
  25932. * @param gradient Scalar amount to interpolate
  25933. * @returns Interpolated scalar value
  25934. */
  25935. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25936. /**
  25937. * Interpolates a quaternion using a spherical linear interpolation
  25938. * @param startValue Start value of the animation curve
  25939. * @param endValue End value of the animation curve
  25940. * @param gradient Scalar amount to interpolate
  25941. * @returns Interpolated quaternion value
  25942. */
  25943. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25944. /**
  25945. * Interpolates a quaternion cubically
  25946. * @param startValue Start value of the animation curve
  25947. * @param outTangent End tangent of the animation curve
  25948. * @param endValue End value of the animation curve
  25949. * @param inTangent Start tangent of the animation curve
  25950. * @param gradient Scalar amount to interpolate
  25951. * @returns Interpolated quaternion value
  25952. */
  25953. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25954. /**
  25955. * Interpolates a Vector3 linearl
  25956. * @param startValue Start value of the animation curve
  25957. * @param endValue End value of the animation curve
  25958. * @param gradient Scalar amount to interpolate
  25959. * @returns Interpolated scalar value
  25960. */
  25961. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25962. /**
  25963. * Interpolates a Vector3 cubically
  25964. * @param startValue Start value of the animation curve
  25965. * @param outTangent End tangent of the animation
  25966. * @param endValue End value of the animation curve
  25967. * @param inTangent Start tangent of the animation curve
  25968. * @param gradient Scalar amount to interpolate
  25969. * @returns InterpolatedVector3 value
  25970. */
  25971. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25972. /**
  25973. * Interpolates a Vector2 linearly
  25974. * @param startValue Start value of the animation curve
  25975. * @param endValue End value of the animation curve
  25976. * @param gradient Scalar amount to interpolate
  25977. * @returns Interpolated Vector2 value
  25978. */
  25979. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25980. /**
  25981. * Interpolates a Vector2 cubically
  25982. * @param startValue Start value of the animation curve
  25983. * @param outTangent End tangent of the animation
  25984. * @param endValue End value of the animation curve
  25985. * @param inTangent Start tangent of the animation curve
  25986. * @param gradient Scalar amount to interpolate
  25987. * @returns Interpolated Vector2 value
  25988. */
  25989. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25990. /**
  25991. * Interpolates a size linearly
  25992. * @param startValue Start value of the animation curve
  25993. * @param endValue End value of the animation curve
  25994. * @param gradient Scalar amount to interpolate
  25995. * @returns Interpolated Size value
  25996. */
  25997. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25998. /**
  25999. * Interpolates a Color3 linearly
  26000. * @param startValue Start value of the animation curve
  26001. * @param endValue End value of the animation curve
  26002. * @param gradient Scalar amount to interpolate
  26003. * @returns Interpolated Color3 value
  26004. */
  26005. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26006. /**
  26007. * @hidden Internal use only
  26008. */
  26009. _getKeyValue(value: any): any;
  26010. /**
  26011. * @hidden Internal use only
  26012. */
  26013. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26014. /**
  26015. * Defines the function to use to interpolate matrices
  26016. * @param startValue defines the start matrix
  26017. * @param endValue defines the end matrix
  26018. * @param gradient defines the gradient between both matrices
  26019. * @param result defines an optional target matrix where to store the interpolation
  26020. * @returns the interpolated matrix
  26021. */
  26022. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26023. /**
  26024. * Makes a copy of the animation
  26025. * @returns Cloned animation
  26026. */
  26027. clone(): Animation;
  26028. /**
  26029. * Sets the key frames of the animation
  26030. * @param values The animation key frames to set
  26031. */
  26032. setKeys(values: Array<IAnimationKey>): void;
  26033. /**
  26034. * Serializes the animation to an object
  26035. * @returns Serialized object
  26036. */
  26037. serialize(): any;
  26038. /**
  26039. * Float animation type
  26040. */
  26041. private static _ANIMATIONTYPE_FLOAT;
  26042. /**
  26043. * Vector3 animation type
  26044. */
  26045. private static _ANIMATIONTYPE_VECTOR3;
  26046. /**
  26047. * Quaternion animation type
  26048. */
  26049. private static _ANIMATIONTYPE_QUATERNION;
  26050. /**
  26051. * Matrix animation type
  26052. */
  26053. private static _ANIMATIONTYPE_MATRIX;
  26054. /**
  26055. * Color3 animation type
  26056. */
  26057. private static _ANIMATIONTYPE_COLOR3;
  26058. /**
  26059. * Vector2 animation type
  26060. */
  26061. private static _ANIMATIONTYPE_VECTOR2;
  26062. /**
  26063. * Size animation type
  26064. */
  26065. private static _ANIMATIONTYPE_SIZE;
  26066. /**
  26067. * Relative Loop Mode
  26068. */
  26069. private static _ANIMATIONLOOPMODE_RELATIVE;
  26070. /**
  26071. * Cycle Loop Mode
  26072. */
  26073. private static _ANIMATIONLOOPMODE_CYCLE;
  26074. /**
  26075. * Constant Loop Mode
  26076. */
  26077. private static _ANIMATIONLOOPMODE_CONSTANT;
  26078. /**
  26079. * Get the float animation type
  26080. */
  26081. static readonly ANIMATIONTYPE_FLOAT: number;
  26082. /**
  26083. * Get the Vector3 animation type
  26084. */
  26085. static readonly ANIMATIONTYPE_VECTOR3: number;
  26086. /**
  26087. * Get the Vector2 animation type
  26088. */
  26089. static readonly ANIMATIONTYPE_VECTOR2: number;
  26090. /**
  26091. * Get the Size animation type
  26092. */
  26093. static readonly ANIMATIONTYPE_SIZE: number;
  26094. /**
  26095. * Get the Quaternion animation type
  26096. */
  26097. static readonly ANIMATIONTYPE_QUATERNION: number;
  26098. /**
  26099. * Get the Matrix animation type
  26100. */
  26101. static readonly ANIMATIONTYPE_MATRIX: number;
  26102. /**
  26103. * Get the Color3 animation type
  26104. */
  26105. static readonly ANIMATIONTYPE_COLOR3: number;
  26106. /**
  26107. * Get the Relative Loop Mode
  26108. */
  26109. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26110. /**
  26111. * Get the Cycle Loop Mode
  26112. */
  26113. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26114. /**
  26115. * Get the Constant Loop Mode
  26116. */
  26117. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26118. /** @hidden */
  26119. static _UniversalLerp(left: any, right: any, amount: number): any;
  26120. /**
  26121. * Parses an animation object and creates an animation
  26122. * @param parsedAnimation Parsed animation object
  26123. * @returns Animation object
  26124. */
  26125. static Parse(parsedAnimation: any): Animation;
  26126. /**
  26127. * Appends the serialized animations from the source animations
  26128. * @param source Source containing the animations
  26129. * @param destination Target to store the animations
  26130. */
  26131. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26132. }
  26133. }
  26134. declare module BABYLON {
  26135. /**
  26136. * Base class of all the textures in babylon.
  26137. * It groups all the common properties the materials, post process, lights... might need
  26138. * in order to make a correct use of the texture.
  26139. */
  26140. export class BaseTexture implements IAnimatable {
  26141. /**
  26142. * Default anisotropic filtering level for the application.
  26143. * It is set to 4 as a good tradeoff between perf and quality.
  26144. */
  26145. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26146. /**
  26147. * Gets or sets the unique id of the texture
  26148. */
  26149. uniqueId: number;
  26150. /**
  26151. * Define the name of the texture.
  26152. */
  26153. name: string;
  26154. /**
  26155. * Gets or sets an object used to store user defined information.
  26156. */
  26157. metadata: any;
  26158. /**
  26159. * For internal use only. Please do not use.
  26160. */
  26161. reservedDataStore: any;
  26162. private _hasAlpha;
  26163. /**
  26164. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26165. */
  26166. hasAlpha: boolean;
  26167. /**
  26168. * Defines if the alpha value should be determined via the rgb values.
  26169. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26170. */
  26171. getAlphaFromRGB: boolean;
  26172. /**
  26173. * Intensity or strength of the texture.
  26174. * It is commonly used by materials to fine tune the intensity of the texture
  26175. */
  26176. level: number;
  26177. /**
  26178. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26179. * This is part of the texture as textures usually maps to one uv set.
  26180. */
  26181. coordinatesIndex: number;
  26182. private _coordinatesMode;
  26183. /**
  26184. * How a texture is mapped.
  26185. *
  26186. * | Value | Type | Description |
  26187. * | ----- | ----------------------------------- | ----------- |
  26188. * | 0 | EXPLICIT_MODE | |
  26189. * | 1 | SPHERICAL_MODE | |
  26190. * | 2 | PLANAR_MODE | |
  26191. * | 3 | CUBIC_MODE | |
  26192. * | 4 | PROJECTION_MODE | |
  26193. * | 5 | SKYBOX_MODE | |
  26194. * | 6 | INVCUBIC_MODE | |
  26195. * | 7 | EQUIRECTANGULAR_MODE | |
  26196. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26197. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26198. */
  26199. coordinatesMode: number;
  26200. /**
  26201. * | Value | Type | Description |
  26202. * | ----- | ------------------ | ----------- |
  26203. * | 0 | CLAMP_ADDRESSMODE | |
  26204. * | 1 | WRAP_ADDRESSMODE | |
  26205. * | 2 | MIRROR_ADDRESSMODE | |
  26206. */
  26207. wrapU: number;
  26208. /**
  26209. * | Value | Type | Description |
  26210. * | ----- | ------------------ | ----------- |
  26211. * | 0 | CLAMP_ADDRESSMODE | |
  26212. * | 1 | WRAP_ADDRESSMODE | |
  26213. * | 2 | MIRROR_ADDRESSMODE | |
  26214. */
  26215. wrapV: number;
  26216. /**
  26217. * | Value | Type | Description |
  26218. * | ----- | ------------------ | ----------- |
  26219. * | 0 | CLAMP_ADDRESSMODE | |
  26220. * | 1 | WRAP_ADDRESSMODE | |
  26221. * | 2 | MIRROR_ADDRESSMODE | |
  26222. */
  26223. wrapR: number;
  26224. /**
  26225. * With compliant hardware and browser (supporting anisotropic filtering)
  26226. * this defines the level of anisotropic filtering in the texture.
  26227. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26228. */
  26229. anisotropicFilteringLevel: number;
  26230. /**
  26231. * Define if the texture is a cube texture or if false a 2d texture.
  26232. */
  26233. isCube: boolean;
  26234. /**
  26235. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26236. */
  26237. is3D: boolean;
  26238. /**
  26239. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26240. * HDR texture are usually stored in linear space.
  26241. * This only impacts the PBR and Background materials
  26242. */
  26243. gammaSpace: boolean;
  26244. /**
  26245. * Gets whether or not the texture contains RGBD data.
  26246. */
  26247. readonly isRGBD: boolean;
  26248. /**
  26249. * Is Z inverted in the texture (useful in a cube texture).
  26250. */
  26251. invertZ: boolean;
  26252. /**
  26253. * Are mip maps generated for this texture or not.
  26254. */
  26255. readonly noMipmap: boolean;
  26256. /**
  26257. * @hidden
  26258. */
  26259. lodLevelInAlpha: boolean;
  26260. /**
  26261. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26262. */
  26263. lodGenerationOffset: number;
  26264. /**
  26265. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26266. */
  26267. lodGenerationScale: number;
  26268. /**
  26269. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  26270. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  26271. * average roughness values.
  26272. */
  26273. linearSpecularLOD: boolean;
  26274. /**
  26275. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  26276. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  26277. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  26278. */
  26279. irradianceTexture: Nullable<BaseTexture>;
  26280. /**
  26281. * Define if the texture is a render target.
  26282. */
  26283. isRenderTarget: boolean;
  26284. /**
  26285. * Define the unique id of the texture in the scene.
  26286. */
  26287. readonly uid: string;
  26288. /**
  26289. * Return a string representation of the texture.
  26290. * @returns the texture as a string
  26291. */
  26292. toString(): string;
  26293. /**
  26294. * Get the class name of the texture.
  26295. * @returns "BaseTexture"
  26296. */
  26297. getClassName(): string;
  26298. /**
  26299. * Define the list of animation attached to the texture.
  26300. */
  26301. animations: Animation[];
  26302. /**
  26303. * An event triggered when the texture is disposed.
  26304. */
  26305. onDisposeObservable: Observable<BaseTexture>;
  26306. private _onDisposeObserver;
  26307. /**
  26308. * Callback triggered when the texture has been disposed.
  26309. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26310. */
  26311. onDispose: () => void;
  26312. /**
  26313. * Define the current state of the loading sequence when in delayed load mode.
  26314. */
  26315. delayLoadState: number;
  26316. private _scene;
  26317. /** @hidden */
  26318. _texture: Nullable<InternalTexture>;
  26319. private _uid;
  26320. /**
  26321. * Define if the texture is preventinga material to render or not.
  26322. * If not and the texture is not ready, the engine will use a default black texture instead.
  26323. */
  26324. readonly isBlocking: boolean;
  26325. /**
  26326. * Instantiates a new BaseTexture.
  26327. * Base class of all the textures in babylon.
  26328. * It groups all the common properties the materials, post process, lights... might need
  26329. * in order to make a correct use of the texture.
  26330. * @param scene Define the scene the texture blongs to
  26331. */
  26332. constructor(scene: Nullable<Scene>);
  26333. /**
  26334. * Get the scene the texture belongs to.
  26335. * @returns the scene or null if undefined
  26336. */
  26337. getScene(): Nullable<Scene>;
  26338. /**
  26339. * Get the texture transform matrix used to offset tile the texture for istance.
  26340. * @returns the transformation matrix
  26341. */
  26342. getTextureMatrix(): Matrix;
  26343. /**
  26344. * Get the texture reflection matrix used to rotate/transform the reflection.
  26345. * @returns the reflection matrix
  26346. */
  26347. getReflectionTextureMatrix(): Matrix;
  26348. /**
  26349. * Get the underlying lower level texture from Babylon.
  26350. * @returns the insternal texture
  26351. */
  26352. getInternalTexture(): Nullable<InternalTexture>;
  26353. /**
  26354. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26355. * @returns true if ready or not blocking
  26356. */
  26357. isReadyOrNotBlocking(): boolean;
  26358. /**
  26359. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26360. * @returns true if fully ready
  26361. */
  26362. isReady(): boolean;
  26363. private _cachedSize;
  26364. /**
  26365. * Get the size of the texture.
  26366. * @returns the texture size.
  26367. */
  26368. getSize(): ISize;
  26369. /**
  26370. * Get the base size of the texture.
  26371. * It can be different from the size if the texture has been resized for POT for instance
  26372. * @returns the base size
  26373. */
  26374. getBaseSize(): ISize;
  26375. /**
  26376. * Update the sampling mode of the texture.
  26377. * Default is Trilinear mode.
  26378. *
  26379. * | Value | Type | Description |
  26380. * | ----- | ------------------ | ----------- |
  26381. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26382. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26383. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26384. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26385. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26386. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26387. * | 7 | NEAREST_LINEAR | |
  26388. * | 8 | NEAREST_NEAREST | |
  26389. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26390. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26391. * | 11 | LINEAR_LINEAR | |
  26392. * | 12 | LINEAR_NEAREST | |
  26393. *
  26394. * > _mag_: magnification filter (close to the viewer)
  26395. * > _min_: minification filter (far from the viewer)
  26396. * > _mip_: filter used between mip map levels
  26397. *@param samplingMode Define the new sampling mode of the texture
  26398. */
  26399. updateSamplingMode(samplingMode: number): void;
  26400. /**
  26401. * Scales the texture if is `canRescale()`
  26402. * @param ratio the resize factor we want to use to rescale
  26403. */
  26404. scale(ratio: number): void;
  26405. /**
  26406. * Get if the texture can rescale.
  26407. */
  26408. readonly canRescale: boolean;
  26409. /** @hidden */
  26410. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26411. /** @hidden */
  26412. _rebuild(): void;
  26413. /**
  26414. * Triggers the load sequence in delayed load mode.
  26415. */
  26416. delayLoad(): void;
  26417. /**
  26418. * Clones the texture.
  26419. * @returns the cloned texture
  26420. */
  26421. clone(): Nullable<BaseTexture>;
  26422. /**
  26423. * Get the texture underlying type (INT, FLOAT...)
  26424. */
  26425. readonly textureType: number;
  26426. /**
  26427. * Get the texture underlying format (RGB, RGBA...)
  26428. */
  26429. readonly textureFormat: number;
  26430. /**
  26431. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26432. * This will returns an RGBA array buffer containing either in values (0-255) or
  26433. * float values (0-1) depending of the underlying buffer type.
  26434. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26435. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26436. * @param buffer defines a user defined buffer to fill with data (can be null)
  26437. * @returns The Array buffer containing the pixels data.
  26438. */
  26439. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26440. /**
  26441. * Release and destroy the underlying lower level texture aka internalTexture.
  26442. */
  26443. releaseInternalTexture(): void;
  26444. /**
  26445. * Get the polynomial representation of the texture data.
  26446. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26447. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26448. */
  26449. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26450. /** @hidden */
  26451. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26452. /** @hidden */
  26453. readonly _lodTextureMid: Nullable<BaseTexture>;
  26454. /** @hidden */
  26455. readonly _lodTextureLow: Nullable<BaseTexture>;
  26456. /**
  26457. * Dispose the texture and release its associated resources.
  26458. */
  26459. dispose(): void;
  26460. /**
  26461. * Serialize the texture into a JSON representation that can be parsed later on.
  26462. * @returns the JSON representation of the texture
  26463. */
  26464. serialize(): any;
  26465. /**
  26466. * Helper function to be called back once a list of texture contains only ready textures.
  26467. * @param textures Define the list of textures to wait for
  26468. * @param callback Define the callback triggered once the entire list will be ready
  26469. */
  26470. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26471. }
  26472. }
  26473. declare module BABYLON {
  26474. /**
  26475. * Uniform buffer objects.
  26476. *
  26477. * Handles blocks of uniform on the GPU.
  26478. *
  26479. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26480. *
  26481. * For more information, please refer to :
  26482. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26483. */
  26484. export class UniformBuffer {
  26485. private _engine;
  26486. private _buffer;
  26487. private _data;
  26488. private _bufferData;
  26489. private _dynamic?;
  26490. private _uniformLocations;
  26491. private _uniformSizes;
  26492. private _uniformLocationPointer;
  26493. private _needSync;
  26494. private _noUBO;
  26495. private _currentEffect;
  26496. private static _MAX_UNIFORM_SIZE;
  26497. private static _tempBuffer;
  26498. /**
  26499. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26500. * This is dynamic to allow compat with webgl 1 and 2.
  26501. * You will need to pass the name of the uniform as well as the value.
  26502. */
  26503. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26504. /**
  26505. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26506. * This is dynamic to allow compat with webgl 1 and 2.
  26507. * You will need to pass the name of the uniform as well as the value.
  26508. */
  26509. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26510. /**
  26511. * Lambda to Update a single float in a uniform buffer.
  26512. * This is dynamic to allow compat with webgl 1 and 2.
  26513. * You will need to pass the name of the uniform as well as the value.
  26514. */
  26515. updateFloat: (name: string, x: number) => void;
  26516. /**
  26517. * Lambda to Update a vec2 of float in a uniform buffer.
  26518. * This is dynamic to allow compat with webgl 1 and 2.
  26519. * You will need to pass the name of the uniform as well as the value.
  26520. */
  26521. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26522. /**
  26523. * Lambda to Update a vec3 of float in a uniform buffer.
  26524. * This is dynamic to allow compat with webgl 1 and 2.
  26525. * You will need to pass the name of the uniform as well as the value.
  26526. */
  26527. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26528. /**
  26529. * Lambda to Update a vec4 of float in a uniform buffer.
  26530. * This is dynamic to allow compat with webgl 1 and 2.
  26531. * You will need to pass the name of the uniform as well as the value.
  26532. */
  26533. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26534. /**
  26535. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26536. * This is dynamic to allow compat with webgl 1 and 2.
  26537. * You will need to pass the name of the uniform as well as the value.
  26538. */
  26539. updateMatrix: (name: string, mat: Matrix) => void;
  26540. /**
  26541. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26542. * This is dynamic to allow compat with webgl 1 and 2.
  26543. * You will need to pass the name of the uniform as well as the value.
  26544. */
  26545. updateVector3: (name: string, vector: Vector3) => void;
  26546. /**
  26547. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26548. * This is dynamic to allow compat with webgl 1 and 2.
  26549. * You will need to pass the name of the uniform as well as the value.
  26550. */
  26551. updateVector4: (name: string, vector: Vector4) => void;
  26552. /**
  26553. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26554. * This is dynamic to allow compat with webgl 1 and 2.
  26555. * You will need to pass the name of the uniform as well as the value.
  26556. */
  26557. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26558. /**
  26559. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26560. * This is dynamic to allow compat with webgl 1 and 2.
  26561. * You will need to pass the name of the uniform as well as the value.
  26562. */
  26563. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26564. /**
  26565. * Instantiates a new Uniform buffer objects.
  26566. *
  26567. * Handles blocks of uniform on the GPU.
  26568. *
  26569. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26570. *
  26571. * For more information, please refer to :
  26572. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26573. * @param engine Define the engine the buffer is associated with
  26574. * @param data Define the data contained in the buffer
  26575. * @param dynamic Define if the buffer is updatable
  26576. */
  26577. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26578. /**
  26579. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26580. * or just falling back on setUniformXXX calls.
  26581. */
  26582. readonly useUbo: boolean;
  26583. /**
  26584. * Indicates if the WebGL underlying uniform buffer is in sync
  26585. * with the javascript cache data.
  26586. */
  26587. readonly isSync: boolean;
  26588. /**
  26589. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26590. * Also, a dynamic UniformBuffer will disable cache verification and always
  26591. * update the underlying WebGL uniform buffer to the GPU.
  26592. * @returns if Dynamic, otherwise false
  26593. */
  26594. isDynamic(): boolean;
  26595. /**
  26596. * The data cache on JS side.
  26597. * @returns the underlying data as a float array
  26598. */
  26599. getData(): Float32Array;
  26600. /**
  26601. * The underlying WebGL Uniform buffer.
  26602. * @returns the webgl buffer
  26603. */
  26604. getBuffer(): Nullable<DataBuffer>;
  26605. /**
  26606. * std140 layout specifies how to align data within an UBO structure.
  26607. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26608. * for specs.
  26609. */
  26610. private _fillAlignment;
  26611. /**
  26612. * Adds an uniform in the buffer.
  26613. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26614. * for the layout to be correct !
  26615. * @param name Name of the uniform, as used in the uniform block in the shader.
  26616. * @param size Data size, or data directly.
  26617. */
  26618. addUniform(name: string, size: number | number[]): void;
  26619. /**
  26620. * Adds a Matrix 4x4 to the uniform buffer.
  26621. * @param name Name of the uniform, as used in the uniform block in the shader.
  26622. * @param mat A 4x4 matrix.
  26623. */
  26624. addMatrix(name: string, mat: Matrix): void;
  26625. /**
  26626. * Adds a vec2 to the uniform buffer.
  26627. * @param name Name of the uniform, as used in the uniform block in the shader.
  26628. * @param x Define the x component value of the vec2
  26629. * @param y Define the y component value of the vec2
  26630. */
  26631. addFloat2(name: string, x: number, y: number): void;
  26632. /**
  26633. * Adds a vec3 to the uniform buffer.
  26634. * @param name Name of the uniform, as used in the uniform block in the shader.
  26635. * @param x Define the x component value of the vec3
  26636. * @param y Define the y component value of the vec3
  26637. * @param z Define the z component value of the vec3
  26638. */
  26639. addFloat3(name: string, x: number, y: number, z: number): void;
  26640. /**
  26641. * Adds a vec3 to the uniform buffer.
  26642. * @param name Name of the uniform, as used in the uniform block in the shader.
  26643. * @param color Define the vec3 from a Color
  26644. */
  26645. addColor3(name: string, color: Color3): void;
  26646. /**
  26647. * Adds a vec4 to the uniform buffer.
  26648. * @param name Name of the uniform, as used in the uniform block in the shader.
  26649. * @param color Define the rgb components from a Color
  26650. * @param alpha Define the a component of the vec4
  26651. */
  26652. addColor4(name: string, color: Color3, alpha: number): void;
  26653. /**
  26654. * Adds a vec3 to the uniform buffer.
  26655. * @param name Name of the uniform, as used in the uniform block in the shader.
  26656. * @param vector Define the vec3 components from a Vector
  26657. */
  26658. addVector3(name: string, vector: Vector3): void;
  26659. /**
  26660. * Adds a Matrix 3x3 to the uniform buffer.
  26661. * @param name Name of the uniform, as used in the uniform block in the shader.
  26662. */
  26663. addMatrix3x3(name: string): void;
  26664. /**
  26665. * Adds a Matrix 2x2 to the uniform buffer.
  26666. * @param name Name of the uniform, as used in the uniform block in the shader.
  26667. */
  26668. addMatrix2x2(name: string): void;
  26669. /**
  26670. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26671. */
  26672. create(): void;
  26673. /** @hidden */
  26674. _rebuild(): void;
  26675. /**
  26676. * Updates the WebGL Uniform Buffer on the GPU.
  26677. * If the `dynamic` flag is set to true, no cache comparison is done.
  26678. * Otherwise, the buffer will be updated only if the cache differs.
  26679. */
  26680. update(): void;
  26681. /**
  26682. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26683. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26684. * @param data Define the flattened data
  26685. * @param size Define the size of the data.
  26686. */
  26687. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26688. private _updateMatrix3x3ForUniform;
  26689. private _updateMatrix3x3ForEffect;
  26690. private _updateMatrix2x2ForEffect;
  26691. private _updateMatrix2x2ForUniform;
  26692. private _updateFloatForEffect;
  26693. private _updateFloatForUniform;
  26694. private _updateFloat2ForEffect;
  26695. private _updateFloat2ForUniform;
  26696. private _updateFloat3ForEffect;
  26697. private _updateFloat3ForUniform;
  26698. private _updateFloat4ForEffect;
  26699. private _updateFloat4ForUniform;
  26700. private _updateMatrixForEffect;
  26701. private _updateMatrixForUniform;
  26702. private _updateVector3ForEffect;
  26703. private _updateVector3ForUniform;
  26704. private _updateVector4ForEffect;
  26705. private _updateVector4ForUniform;
  26706. private _updateColor3ForEffect;
  26707. private _updateColor3ForUniform;
  26708. private _updateColor4ForEffect;
  26709. private _updateColor4ForUniform;
  26710. /**
  26711. * Sets a sampler uniform on the effect.
  26712. * @param name Define the name of the sampler.
  26713. * @param texture Define the texture to set in the sampler
  26714. */
  26715. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26716. /**
  26717. * Directly updates the value of the uniform in the cache AND on the GPU.
  26718. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26719. * @param data Define the flattened data
  26720. */
  26721. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26722. /**
  26723. * Binds this uniform buffer to an effect.
  26724. * @param effect Define the effect to bind the buffer to
  26725. * @param name Name of the uniform block in the shader.
  26726. */
  26727. bindToEffect(effect: Effect, name: string): void;
  26728. /**
  26729. * Disposes the uniform buffer.
  26730. */
  26731. dispose(): void;
  26732. }
  26733. }
  26734. declare module BABYLON {
  26735. /**
  26736. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26738. */
  26739. export class Analyser {
  26740. /**
  26741. * Gets or sets the smoothing
  26742. * @ignorenaming
  26743. */
  26744. SMOOTHING: number;
  26745. /**
  26746. * Gets or sets the FFT table size
  26747. * @ignorenaming
  26748. */
  26749. FFT_SIZE: number;
  26750. /**
  26751. * Gets or sets the bar graph amplitude
  26752. * @ignorenaming
  26753. */
  26754. BARGRAPHAMPLITUDE: number;
  26755. /**
  26756. * Gets or sets the position of the debug canvas
  26757. * @ignorenaming
  26758. */
  26759. DEBUGCANVASPOS: {
  26760. x: number;
  26761. y: number;
  26762. };
  26763. /**
  26764. * Gets or sets the debug canvas size
  26765. * @ignorenaming
  26766. */
  26767. DEBUGCANVASSIZE: {
  26768. width: number;
  26769. height: number;
  26770. };
  26771. private _byteFreqs;
  26772. private _byteTime;
  26773. private _floatFreqs;
  26774. private _webAudioAnalyser;
  26775. private _debugCanvas;
  26776. private _debugCanvasContext;
  26777. private _scene;
  26778. private _registerFunc;
  26779. private _audioEngine;
  26780. /**
  26781. * Creates a new analyser
  26782. * @param scene defines hosting scene
  26783. */
  26784. constructor(scene: Scene);
  26785. /**
  26786. * Get the number of data values you will have to play with for the visualization
  26787. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26788. * @returns a number
  26789. */
  26790. getFrequencyBinCount(): number;
  26791. /**
  26792. * Gets the current frequency data as a byte array
  26793. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26794. * @returns a Uint8Array
  26795. */
  26796. getByteFrequencyData(): Uint8Array;
  26797. /**
  26798. * Gets the current waveform as a byte array
  26799. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26800. * @returns a Uint8Array
  26801. */
  26802. getByteTimeDomainData(): Uint8Array;
  26803. /**
  26804. * Gets the current frequency data as a float array
  26805. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26806. * @returns a Float32Array
  26807. */
  26808. getFloatFrequencyData(): Float32Array;
  26809. /**
  26810. * Renders the debug canvas
  26811. */
  26812. drawDebugCanvas(): void;
  26813. /**
  26814. * Stops rendering the debug canvas and removes it
  26815. */
  26816. stopDebugCanvas(): void;
  26817. /**
  26818. * Connects two audio nodes
  26819. * @param inputAudioNode defines first node to connect
  26820. * @param outputAudioNode defines second node to connect
  26821. */
  26822. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26823. /**
  26824. * Releases all associated resources
  26825. */
  26826. dispose(): void;
  26827. }
  26828. }
  26829. declare module BABYLON {
  26830. /**
  26831. * This represents an audio engine and it is responsible
  26832. * to play, synchronize and analyse sounds throughout the application.
  26833. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26834. */
  26835. export interface IAudioEngine extends IDisposable {
  26836. /**
  26837. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26838. */
  26839. readonly canUseWebAudio: boolean;
  26840. /**
  26841. * Gets the current AudioContext if available.
  26842. */
  26843. readonly audioContext: Nullable<AudioContext>;
  26844. /**
  26845. * The master gain node defines the global audio volume of your audio engine.
  26846. */
  26847. readonly masterGain: GainNode;
  26848. /**
  26849. * Gets whether or not mp3 are supported by your browser.
  26850. */
  26851. readonly isMP3supported: boolean;
  26852. /**
  26853. * Gets whether or not ogg are supported by your browser.
  26854. */
  26855. readonly isOGGsupported: boolean;
  26856. /**
  26857. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26858. * @ignoreNaming
  26859. */
  26860. WarnedWebAudioUnsupported: boolean;
  26861. /**
  26862. * Defines if the audio engine relies on a custom unlocked button.
  26863. * In this case, the embedded button will not be displayed.
  26864. */
  26865. useCustomUnlockedButton: boolean;
  26866. /**
  26867. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26868. */
  26869. readonly unlocked: boolean;
  26870. /**
  26871. * Event raised when audio has been unlocked on the browser.
  26872. */
  26873. onAudioUnlockedObservable: Observable<AudioEngine>;
  26874. /**
  26875. * Event raised when audio has been locked on the browser.
  26876. */
  26877. onAudioLockedObservable: Observable<AudioEngine>;
  26878. /**
  26879. * Flags the audio engine in Locked state.
  26880. * This happens due to new browser policies preventing audio to autoplay.
  26881. */
  26882. lock(): void;
  26883. /**
  26884. * Unlocks the audio engine once a user action has been done on the dom.
  26885. * This is helpful to resume play once browser policies have been satisfied.
  26886. */
  26887. unlock(): void;
  26888. }
  26889. /**
  26890. * This represents the default audio engine used in babylon.
  26891. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26893. */
  26894. export class AudioEngine implements IAudioEngine {
  26895. private _audioContext;
  26896. private _audioContextInitialized;
  26897. private _muteButton;
  26898. private _hostElement;
  26899. /**
  26900. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26901. */
  26902. canUseWebAudio: boolean;
  26903. /**
  26904. * The master gain node defines the global audio volume of your audio engine.
  26905. */
  26906. masterGain: GainNode;
  26907. /**
  26908. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26909. * @ignoreNaming
  26910. */
  26911. WarnedWebAudioUnsupported: boolean;
  26912. /**
  26913. * Gets whether or not mp3 are supported by your browser.
  26914. */
  26915. isMP3supported: boolean;
  26916. /**
  26917. * Gets whether or not ogg are supported by your browser.
  26918. */
  26919. isOGGsupported: boolean;
  26920. /**
  26921. * Gets whether audio has been unlocked on the device.
  26922. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26923. * a user interaction has happened.
  26924. */
  26925. unlocked: boolean;
  26926. /**
  26927. * Defines if the audio engine relies on a custom unlocked button.
  26928. * In this case, the embedded button will not be displayed.
  26929. */
  26930. useCustomUnlockedButton: boolean;
  26931. /**
  26932. * Event raised when audio has been unlocked on the browser.
  26933. */
  26934. onAudioUnlockedObservable: Observable<AudioEngine>;
  26935. /**
  26936. * Event raised when audio has been locked on the browser.
  26937. */
  26938. onAudioLockedObservable: Observable<AudioEngine>;
  26939. /**
  26940. * Gets the current AudioContext if available.
  26941. */
  26942. readonly audioContext: Nullable<AudioContext>;
  26943. private _connectedAnalyser;
  26944. /**
  26945. * Instantiates a new audio engine.
  26946. *
  26947. * There should be only one per page as some browsers restrict the number
  26948. * of audio contexts you can create.
  26949. * @param hostElement defines the host element where to display the mute icon if necessary
  26950. */
  26951. constructor(hostElement?: Nullable<HTMLElement>);
  26952. /**
  26953. * Flags the audio engine in Locked state.
  26954. * This happens due to new browser policies preventing audio to autoplay.
  26955. */
  26956. lock(): void;
  26957. /**
  26958. * Unlocks the audio engine once a user action has been done on the dom.
  26959. * This is helpful to resume play once browser policies have been satisfied.
  26960. */
  26961. unlock(): void;
  26962. private _resumeAudioContext;
  26963. private _initializeAudioContext;
  26964. private _tryToRun;
  26965. private _triggerRunningState;
  26966. private _triggerSuspendedState;
  26967. private _displayMuteButton;
  26968. private _moveButtonToTopLeft;
  26969. private _onResize;
  26970. private _hideMuteButton;
  26971. /**
  26972. * Destroy and release the resources associated with the audio ccontext.
  26973. */
  26974. dispose(): void;
  26975. /**
  26976. * Gets the global volume sets on the master gain.
  26977. * @returns the global volume if set or -1 otherwise
  26978. */
  26979. getGlobalVolume(): number;
  26980. /**
  26981. * Sets the global volume of your experience (sets on the master gain).
  26982. * @param newVolume Defines the new global volume of the application
  26983. */
  26984. setGlobalVolume(newVolume: number): void;
  26985. /**
  26986. * Connect the audio engine to an audio analyser allowing some amazing
  26987. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26988. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26989. * @param analyser The analyser to connect to the engine
  26990. */
  26991. connectToAnalyser(analyser: Analyser): void;
  26992. }
  26993. }
  26994. declare module BABYLON {
  26995. /**
  26996. * Interface used to present a loading screen while loading a scene
  26997. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26998. */
  26999. export interface ILoadingScreen {
  27000. /**
  27001. * Function called to display the loading screen
  27002. */
  27003. displayLoadingUI: () => void;
  27004. /**
  27005. * Function called to hide the loading screen
  27006. */
  27007. hideLoadingUI: () => void;
  27008. /**
  27009. * Gets or sets the color to use for the background
  27010. */
  27011. loadingUIBackgroundColor: string;
  27012. /**
  27013. * Gets or sets the text to display while loading
  27014. */
  27015. loadingUIText: string;
  27016. }
  27017. /**
  27018. * Class used for the default loading screen
  27019. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27020. */
  27021. export class DefaultLoadingScreen implements ILoadingScreen {
  27022. private _renderingCanvas;
  27023. private _loadingText;
  27024. private _loadingDivBackgroundColor;
  27025. private _loadingDiv;
  27026. private _loadingTextDiv;
  27027. /** Gets or sets the logo url to use for the default loading screen */
  27028. static DefaultLogoUrl: string;
  27029. /** Gets or sets the spinner url to use for the default loading screen */
  27030. static DefaultSpinnerUrl: string;
  27031. /**
  27032. * Creates a new default loading screen
  27033. * @param _renderingCanvas defines the canvas used to render the scene
  27034. * @param _loadingText defines the default text to display
  27035. * @param _loadingDivBackgroundColor defines the default background color
  27036. */
  27037. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27038. /**
  27039. * Function called to display the loading screen
  27040. */
  27041. displayLoadingUI(): void;
  27042. /**
  27043. * Function called to hide the loading screen
  27044. */
  27045. hideLoadingUI(): void;
  27046. /**
  27047. * Gets or sets the text to display while loading
  27048. */
  27049. loadingUIText: string;
  27050. /**
  27051. * Gets or sets the color to use for the background
  27052. */
  27053. loadingUIBackgroundColor: string;
  27054. private _resizeLoadingUI;
  27055. }
  27056. }
  27057. declare module BABYLON {
  27058. /** @hidden */
  27059. export class WebGLPipelineContext implements IPipelineContext {
  27060. engine: Engine;
  27061. program: Nullable<WebGLProgram>;
  27062. context?: WebGLRenderingContext;
  27063. vertexShader?: WebGLShader;
  27064. fragmentShader?: WebGLShader;
  27065. isParallelCompiled: boolean;
  27066. onCompiled?: () => void;
  27067. transformFeedback?: WebGLTransformFeedback | null;
  27068. readonly isAsync: boolean;
  27069. readonly isReady: boolean;
  27070. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27071. }
  27072. }
  27073. declare module BABYLON {
  27074. /** @hidden */
  27075. export class WebGLDataBuffer extends DataBuffer {
  27076. private _buffer;
  27077. constructor(resource: WebGLBuffer);
  27078. readonly underlyingResource: any;
  27079. }
  27080. }
  27081. declare module BABYLON {
  27082. /** @hidden */
  27083. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27084. attributeProcessor(attribute: string): string;
  27085. varyingProcessor(varying: string, isFragment: boolean): string;
  27086. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27087. }
  27088. }
  27089. declare module BABYLON {
  27090. /**
  27091. * Settings for finer control over video usage
  27092. */
  27093. export interface VideoTextureSettings {
  27094. /**
  27095. * Applies `autoplay` to video, if specified
  27096. */
  27097. autoPlay?: boolean;
  27098. /**
  27099. * Applies `loop` to video, if specified
  27100. */
  27101. loop?: boolean;
  27102. /**
  27103. * Automatically updates internal texture from video at every frame in the render loop
  27104. */
  27105. autoUpdateTexture: boolean;
  27106. /**
  27107. * Image src displayed during the video loading or until the user interacts with the video.
  27108. */
  27109. poster?: string;
  27110. }
  27111. /**
  27112. * If you want to display a video in your scene, this is the special texture for that.
  27113. * This special texture works similar to other textures, with the exception of a few parameters.
  27114. * @see https://doc.babylonjs.com/how_to/video_texture
  27115. */
  27116. export class VideoTexture extends Texture {
  27117. /**
  27118. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27119. */
  27120. readonly autoUpdateTexture: boolean;
  27121. /**
  27122. * The video instance used by the texture internally
  27123. */
  27124. readonly video: HTMLVideoElement;
  27125. private _onUserActionRequestedObservable;
  27126. /**
  27127. * Event triggerd when a dom action is required by the user to play the video.
  27128. * This happens due to recent changes in browser policies preventing video to auto start.
  27129. */
  27130. readonly onUserActionRequestedObservable: Observable<Texture>;
  27131. private _generateMipMaps;
  27132. private _engine;
  27133. private _stillImageCaptured;
  27134. private _displayingPosterTexture;
  27135. private _settings;
  27136. private _createInternalTextureOnEvent;
  27137. /**
  27138. * Creates a video texture.
  27139. * If you want to display a video in your scene, this is the special texture for that.
  27140. * This special texture works similar to other textures, with the exception of a few parameters.
  27141. * @see https://doc.babylonjs.com/how_to/video_texture
  27142. * @param name optional name, will detect from video source, if not defined
  27143. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27144. * @param scene is obviously the current scene.
  27145. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27146. * @param invertY is false by default but can be used to invert video on Y axis
  27147. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27148. * @param settings allows finer control over video usage
  27149. */
  27150. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27151. private _getName;
  27152. private _getVideo;
  27153. private _createInternalTexture;
  27154. private reset;
  27155. /**
  27156. * @hidden Internal method to initiate `update`.
  27157. */
  27158. _rebuild(): void;
  27159. /**
  27160. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27161. */
  27162. update(): void;
  27163. /**
  27164. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27165. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27166. */
  27167. updateTexture(isVisible: boolean): void;
  27168. protected _updateInternalTexture: () => void;
  27169. /**
  27170. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27171. * @param url New url.
  27172. */
  27173. updateURL(url: string): void;
  27174. /**
  27175. * Dispose the texture and release its associated resources.
  27176. */
  27177. dispose(): void;
  27178. /**
  27179. * Creates a video texture straight from a stream.
  27180. * @param scene Define the scene the texture should be created in
  27181. * @param stream Define the stream the texture should be created from
  27182. * @returns The created video texture as a promise
  27183. */
  27184. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27185. /**
  27186. * Creates a video texture straight from your WebCam video feed.
  27187. * @param scene Define the scene the texture should be created in
  27188. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27189. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27190. * @returns The created video texture as a promise
  27191. */
  27192. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27193. minWidth: number;
  27194. maxWidth: number;
  27195. minHeight: number;
  27196. maxHeight: number;
  27197. deviceId: string;
  27198. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27199. /**
  27200. * Creates a video texture straight from your WebCam video feed.
  27201. * @param scene Define the scene the texture should be created in
  27202. * @param onReady Define a callback to triggered once the texture will be ready
  27203. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27204. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27205. */
  27206. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27207. minWidth: number;
  27208. maxWidth: number;
  27209. minHeight: number;
  27210. maxHeight: number;
  27211. deviceId: string;
  27212. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27213. }
  27214. }
  27215. declare module BABYLON {
  27216. /**
  27217. * Interface for attribute information associated with buffer instanciation
  27218. */
  27219. export class InstancingAttributeInfo {
  27220. /**
  27221. * Index/offset of the attribute in the vertex shader
  27222. */
  27223. index: number;
  27224. /**
  27225. * size of the attribute, 1, 2, 3 or 4
  27226. */
  27227. attributeSize: number;
  27228. /**
  27229. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27230. * default is FLOAT
  27231. */
  27232. attribyteType: number;
  27233. /**
  27234. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27235. */
  27236. normalized: boolean;
  27237. /**
  27238. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27239. */
  27240. offset: number;
  27241. /**
  27242. * Name of the GLSL attribute, for debugging purpose only
  27243. */
  27244. attributeName: string;
  27245. }
  27246. /**
  27247. * Define options used to create a depth texture
  27248. */
  27249. export class DepthTextureCreationOptions {
  27250. /** Specifies whether or not a stencil should be allocated in the texture */
  27251. generateStencil?: boolean;
  27252. /** Specifies whether or not bilinear filtering is enable on the texture */
  27253. bilinearFiltering?: boolean;
  27254. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27255. comparisonFunction?: number;
  27256. /** Specifies if the created texture is a cube texture */
  27257. isCube?: boolean;
  27258. }
  27259. /**
  27260. * Class used to describe the capabilities of the engine relatively to the current browser
  27261. */
  27262. export class EngineCapabilities {
  27263. /** Maximum textures units per fragment shader */
  27264. maxTexturesImageUnits: number;
  27265. /** Maximum texture units per vertex shader */
  27266. maxVertexTextureImageUnits: number;
  27267. /** Maximum textures units in the entire pipeline */
  27268. maxCombinedTexturesImageUnits: number;
  27269. /** Maximum texture size */
  27270. maxTextureSize: number;
  27271. /** Maximum cube texture size */
  27272. maxCubemapTextureSize: number;
  27273. /** Maximum render texture size */
  27274. maxRenderTextureSize: number;
  27275. /** Maximum number of vertex attributes */
  27276. maxVertexAttribs: number;
  27277. /** Maximum number of varyings */
  27278. maxVaryingVectors: number;
  27279. /** Maximum number of uniforms per vertex shader */
  27280. maxVertexUniformVectors: number;
  27281. /** Maximum number of uniforms per fragment shader */
  27282. maxFragmentUniformVectors: number;
  27283. /** Defines if standard derivates (dx/dy) are supported */
  27284. standardDerivatives: boolean;
  27285. /** Defines if s3tc texture compression is supported */
  27286. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27287. /** Defines if pvrtc texture compression is supported */
  27288. pvrtc: any;
  27289. /** Defines if etc1 texture compression is supported */
  27290. etc1: any;
  27291. /** Defines if etc2 texture compression is supported */
  27292. etc2: any;
  27293. /** Defines if astc texture compression is supported */
  27294. astc: any;
  27295. /** Defines if float textures are supported */
  27296. textureFloat: boolean;
  27297. /** Defines if vertex array objects are supported */
  27298. vertexArrayObject: boolean;
  27299. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27300. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27301. /** Gets the maximum level of anisotropy supported */
  27302. maxAnisotropy: number;
  27303. /** Defines if instancing is supported */
  27304. instancedArrays: boolean;
  27305. /** Defines if 32 bits indices are supported */
  27306. uintIndices: boolean;
  27307. /** Defines if high precision shaders are supported */
  27308. highPrecisionShaderSupported: boolean;
  27309. /** Defines if depth reading in the fragment shader is supported */
  27310. fragmentDepthSupported: boolean;
  27311. /** Defines if float texture linear filtering is supported*/
  27312. textureFloatLinearFiltering: boolean;
  27313. /** Defines if rendering to float textures is supported */
  27314. textureFloatRender: boolean;
  27315. /** Defines if half float textures are supported*/
  27316. textureHalfFloat: boolean;
  27317. /** Defines if half float texture linear filtering is supported*/
  27318. textureHalfFloatLinearFiltering: boolean;
  27319. /** Defines if rendering to half float textures is supported */
  27320. textureHalfFloatRender: boolean;
  27321. /** Defines if textureLOD shader command is supported */
  27322. textureLOD: boolean;
  27323. /** Defines if draw buffers extension is supported */
  27324. drawBuffersExtension: boolean;
  27325. /** Defines if depth textures are supported */
  27326. depthTextureExtension: boolean;
  27327. /** Defines if float color buffer are supported */
  27328. colorBufferFloat: boolean;
  27329. /** Gets disjoint timer query extension (null if not supported) */
  27330. timerQuery: EXT_disjoint_timer_query;
  27331. /** Defines if timestamp can be used with timer query */
  27332. canUseTimestampForTimerQuery: boolean;
  27333. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27334. multiview: any;
  27335. /** Function used to let the system compiles shaders in background */
  27336. parallelShaderCompile: {
  27337. COMPLETION_STATUS_KHR: number;
  27338. };
  27339. }
  27340. /** Interface defining initialization parameters for Engine class */
  27341. export interface EngineOptions extends WebGLContextAttributes {
  27342. /**
  27343. * Defines if the engine should no exceed a specified device ratio
  27344. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27345. */
  27346. limitDeviceRatio?: number;
  27347. /**
  27348. * Defines if webvr should be enabled automatically
  27349. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27350. */
  27351. autoEnableWebVR?: boolean;
  27352. /**
  27353. * Defines if webgl2 should be turned off even if supported
  27354. * @see http://doc.babylonjs.com/features/webgl2
  27355. */
  27356. disableWebGL2Support?: boolean;
  27357. /**
  27358. * Defines if webaudio should be initialized as well
  27359. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27360. */
  27361. audioEngine?: boolean;
  27362. /**
  27363. * Defines if animations should run using a deterministic lock step
  27364. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27365. */
  27366. deterministicLockstep?: boolean;
  27367. /** Defines the maximum steps to use with deterministic lock step mode */
  27368. lockstepMaxSteps?: number;
  27369. /**
  27370. * Defines that engine should ignore context lost events
  27371. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27372. */
  27373. doNotHandleContextLost?: boolean;
  27374. /**
  27375. * Defines that engine should ignore modifying touch action attribute and style
  27376. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27377. */
  27378. doNotHandleTouchAction?: boolean;
  27379. /**
  27380. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27381. */
  27382. useHighPrecisionFloats?: boolean;
  27383. }
  27384. /**
  27385. * Defines the interface used by display changed events
  27386. */
  27387. export interface IDisplayChangedEventArgs {
  27388. /** Gets the vrDisplay object (if any) */
  27389. vrDisplay: Nullable<any>;
  27390. /** Gets a boolean indicating if webVR is supported */
  27391. vrSupported: boolean;
  27392. }
  27393. /**
  27394. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27395. */
  27396. export class Engine {
  27397. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27398. static ExceptionList: ({
  27399. key: string;
  27400. capture: string;
  27401. captureConstraint: number;
  27402. targets: string[];
  27403. } | {
  27404. key: string;
  27405. capture: null;
  27406. captureConstraint: null;
  27407. targets: string[];
  27408. })[];
  27409. /** Gets the list of created engines */
  27410. static readonly Instances: Engine[];
  27411. /**
  27412. * Gets the latest created engine
  27413. */
  27414. static readonly LastCreatedEngine: Nullable<Engine>;
  27415. /**
  27416. * Gets the latest created scene
  27417. */
  27418. static readonly LastCreatedScene: Nullable<Scene>;
  27419. /**
  27420. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27421. * @param flag defines which part of the materials must be marked as dirty
  27422. * @param predicate defines a predicate used to filter which materials should be affected
  27423. */
  27424. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27425. /** @hidden */
  27426. static _TextureLoaders: IInternalTextureLoader[];
  27427. /** Defines that alpha blending is disabled */
  27428. static readonly ALPHA_DISABLE: number;
  27429. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27430. static readonly ALPHA_ADD: number;
  27431. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27432. static readonly ALPHA_COMBINE: number;
  27433. /** Defines that alpha blending to DEST - SRC * DEST */
  27434. static readonly ALPHA_SUBTRACT: number;
  27435. /** Defines that alpha blending to SRC * DEST */
  27436. static readonly ALPHA_MULTIPLY: number;
  27437. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27438. static readonly ALPHA_MAXIMIZED: number;
  27439. /** Defines that alpha blending to SRC + DEST */
  27440. static readonly ALPHA_ONEONE: number;
  27441. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27442. static readonly ALPHA_PREMULTIPLIED: number;
  27443. /**
  27444. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27445. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27446. */
  27447. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27448. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27449. static readonly ALPHA_INTERPOLATE: number;
  27450. /**
  27451. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27452. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27453. */
  27454. static readonly ALPHA_SCREENMODE: number;
  27455. /** Defines that the ressource is not delayed*/
  27456. static readonly DELAYLOADSTATE_NONE: number;
  27457. /** Defines that the ressource was successfully delay loaded */
  27458. static readonly DELAYLOADSTATE_LOADED: number;
  27459. /** Defines that the ressource is currently delay loading */
  27460. static readonly DELAYLOADSTATE_LOADING: number;
  27461. /** Defines that the ressource is delayed and has not started loading */
  27462. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27463. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27464. static readonly NEVER: number;
  27465. /** 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 */
  27466. static readonly ALWAYS: number;
  27467. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27468. static readonly LESS: number;
  27469. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27470. static readonly EQUAL: number;
  27471. /** 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 */
  27472. static readonly LEQUAL: number;
  27473. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27474. static readonly GREATER: number;
  27475. /** 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 */
  27476. static readonly GEQUAL: number;
  27477. /** 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 */
  27478. static readonly NOTEQUAL: number;
  27479. /** Passed to stencilOperation to specify that stencil value must be kept */
  27480. static readonly KEEP: number;
  27481. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27482. static readonly REPLACE: number;
  27483. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27484. static readonly INCR: number;
  27485. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27486. static readonly DECR: number;
  27487. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27488. static readonly INVERT: number;
  27489. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27490. static readonly INCR_WRAP: number;
  27491. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27492. static readonly DECR_WRAP: number;
  27493. /** Texture is not repeating outside of 0..1 UVs */
  27494. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27495. /** Texture is repeating outside of 0..1 UVs */
  27496. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27497. /** Texture is repeating and mirrored */
  27498. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27499. /** ALPHA */
  27500. static readonly TEXTUREFORMAT_ALPHA: number;
  27501. /** LUMINANCE */
  27502. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27503. /** LUMINANCE_ALPHA */
  27504. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27505. /** RGB */
  27506. static readonly TEXTUREFORMAT_RGB: number;
  27507. /** RGBA */
  27508. static readonly TEXTUREFORMAT_RGBA: number;
  27509. /** RED */
  27510. static readonly TEXTUREFORMAT_RED: number;
  27511. /** RED (2nd reference) */
  27512. static readonly TEXTUREFORMAT_R: number;
  27513. /** RG */
  27514. static readonly TEXTUREFORMAT_RG: number;
  27515. /** RED_INTEGER */
  27516. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27517. /** RED_INTEGER (2nd reference) */
  27518. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27519. /** RG_INTEGER */
  27520. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27521. /** RGB_INTEGER */
  27522. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27523. /** RGBA_INTEGER */
  27524. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27525. /** UNSIGNED_BYTE */
  27526. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27527. /** UNSIGNED_BYTE (2nd reference) */
  27528. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27529. /** FLOAT */
  27530. static readonly TEXTURETYPE_FLOAT: number;
  27531. /** HALF_FLOAT */
  27532. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27533. /** BYTE */
  27534. static readonly TEXTURETYPE_BYTE: number;
  27535. /** SHORT */
  27536. static readonly TEXTURETYPE_SHORT: number;
  27537. /** UNSIGNED_SHORT */
  27538. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27539. /** INT */
  27540. static readonly TEXTURETYPE_INT: number;
  27541. /** UNSIGNED_INT */
  27542. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27543. /** UNSIGNED_SHORT_4_4_4_4 */
  27544. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27545. /** UNSIGNED_SHORT_5_5_5_1 */
  27546. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27547. /** UNSIGNED_SHORT_5_6_5 */
  27548. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27549. /** UNSIGNED_INT_2_10_10_10_REV */
  27550. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27551. /** UNSIGNED_INT_24_8 */
  27552. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27553. /** UNSIGNED_INT_10F_11F_11F_REV */
  27554. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27555. /** UNSIGNED_INT_5_9_9_9_REV */
  27556. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27557. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27558. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27559. /** nearest is mag = nearest and min = nearest and mip = linear */
  27560. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27561. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27562. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27563. /** Trilinear is mag = linear and min = linear and mip = linear */
  27564. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27565. /** nearest is mag = nearest and min = nearest and mip = linear */
  27566. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27567. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27568. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27569. /** Trilinear is mag = linear and min = linear and mip = linear */
  27570. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27571. /** mag = nearest and min = nearest and mip = nearest */
  27572. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27573. /** mag = nearest and min = linear and mip = nearest */
  27574. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27575. /** mag = nearest and min = linear and mip = linear */
  27576. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27577. /** mag = nearest and min = linear and mip = none */
  27578. static readonly TEXTURE_NEAREST_LINEAR: number;
  27579. /** mag = nearest and min = nearest and mip = none */
  27580. static readonly TEXTURE_NEAREST_NEAREST: number;
  27581. /** mag = linear and min = nearest and mip = nearest */
  27582. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27583. /** mag = linear and min = nearest and mip = linear */
  27584. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27585. /** mag = linear and min = linear and mip = none */
  27586. static readonly TEXTURE_LINEAR_LINEAR: number;
  27587. /** mag = linear and min = nearest and mip = none */
  27588. static readonly TEXTURE_LINEAR_NEAREST: number;
  27589. /** Explicit coordinates mode */
  27590. static readonly TEXTURE_EXPLICIT_MODE: number;
  27591. /** Spherical coordinates mode */
  27592. static readonly TEXTURE_SPHERICAL_MODE: number;
  27593. /** Planar coordinates mode */
  27594. static readonly TEXTURE_PLANAR_MODE: number;
  27595. /** Cubic coordinates mode */
  27596. static readonly TEXTURE_CUBIC_MODE: number;
  27597. /** Projection coordinates mode */
  27598. static readonly TEXTURE_PROJECTION_MODE: number;
  27599. /** Skybox coordinates mode */
  27600. static readonly TEXTURE_SKYBOX_MODE: number;
  27601. /** Inverse Cubic coordinates mode */
  27602. static readonly TEXTURE_INVCUBIC_MODE: number;
  27603. /** Equirectangular coordinates mode */
  27604. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27605. /** Equirectangular Fixed coordinates mode */
  27606. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27607. /** Equirectangular Fixed Mirrored coordinates mode */
  27608. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27609. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27610. static readonly SCALEMODE_FLOOR: number;
  27611. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27612. static readonly SCALEMODE_NEAREST: number;
  27613. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27614. static readonly SCALEMODE_CEILING: number;
  27615. /**
  27616. * Returns the current npm package of the sdk
  27617. */
  27618. static readonly NpmPackage: string;
  27619. /**
  27620. * Returns the current version of the framework
  27621. */
  27622. static readonly Version: string;
  27623. /**
  27624. * Returns a string describing the current engine
  27625. */
  27626. readonly description: string;
  27627. /**
  27628. * Gets or sets the epsilon value used by collision engine
  27629. */
  27630. static CollisionsEpsilon: number;
  27631. /**
  27632. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27633. */
  27634. static ShadersRepository: string;
  27635. /**
  27636. * Method called to create the default loading screen.
  27637. * This can be overriden in your own app.
  27638. * @param canvas The rendering canvas element
  27639. * @returns The loading screen
  27640. */
  27641. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27642. /**
  27643. * Method called to create the default rescale post process on each engine.
  27644. */
  27645. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27646. /** @hidden */
  27647. _shaderProcessor: IShaderProcessor;
  27648. /**
  27649. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27650. */
  27651. forcePOTTextures: boolean;
  27652. /**
  27653. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27654. */
  27655. isFullscreen: boolean;
  27656. /**
  27657. * Gets a boolean indicating if the pointer is currently locked
  27658. */
  27659. isPointerLock: boolean;
  27660. /**
  27661. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27662. */
  27663. cullBackFaces: boolean;
  27664. /**
  27665. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27666. */
  27667. renderEvenInBackground: boolean;
  27668. /**
  27669. * Gets or sets a boolean indicating that cache can be kept between frames
  27670. */
  27671. preventCacheWipeBetweenFrames: boolean;
  27672. /**
  27673. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27674. **/
  27675. enableOfflineSupport: boolean;
  27676. /**
  27677. * 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)
  27678. **/
  27679. disableManifestCheck: boolean;
  27680. /**
  27681. * Gets the list of created scenes
  27682. */
  27683. scenes: Scene[];
  27684. /**
  27685. * Event raised when a new scene is created
  27686. */
  27687. onNewSceneAddedObservable: Observable<Scene>;
  27688. /**
  27689. * Gets the list of created postprocesses
  27690. */
  27691. postProcesses: PostProcess[];
  27692. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27693. validateShaderPrograms: boolean;
  27694. /**
  27695. * Observable event triggered each time the rendering canvas is resized
  27696. */
  27697. onResizeObservable: Observable<Engine>;
  27698. /**
  27699. * Observable event triggered each time the canvas loses focus
  27700. */
  27701. onCanvasBlurObservable: Observable<Engine>;
  27702. /**
  27703. * Observable event triggered each time the canvas gains focus
  27704. */
  27705. onCanvasFocusObservable: Observable<Engine>;
  27706. /**
  27707. * Observable event triggered each time the canvas receives pointerout event
  27708. */
  27709. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27710. /**
  27711. * Observable event triggered before each texture is initialized
  27712. */
  27713. onBeforeTextureInitObservable: Observable<Texture>;
  27714. /**
  27715. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27716. */
  27717. disableUniformBuffers: boolean;
  27718. /** @hidden */
  27719. _uniformBuffers: UniformBuffer[];
  27720. /**
  27721. * Gets a boolean indicating that the engine supports uniform buffers
  27722. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27723. */
  27724. readonly supportsUniformBuffers: boolean;
  27725. /**
  27726. * Observable raised when the engine begins a new frame
  27727. */
  27728. onBeginFrameObservable: Observable<Engine>;
  27729. /**
  27730. * If set, will be used to request the next animation frame for the render loop
  27731. */
  27732. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27733. /**
  27734. * Observable raised when the engine ends the current frame
  27735. */
  27736. onEndFrameObservable: Observable<Engine>;
  27737. /**
  27738. * Observable raised when the engine is about to compile a shader
  27739. */
  27740. onBeforeShaderCompilationObservable: Observable<Engine>;
  27741. /**
  27742. * Observable raised when the engine has jsut compiled a shader
  27743. */
  27744. onAfterShaderCompilationObservable: Observable<Engine>;
  27745. /** @hidden */
  27746. _gl: WebGLRenderingContext;
  27747. private _renderingCanvas;
  27748. private _windowIsBackground;
  27749. private _webGLVersion;
  27750. protected _highPrecisionShadersAllowed: boolean;
  27751. /** @hidden */
  27752. readonly _shouldUseHighPrecisionShader: boolean;
  27753. /**
  27754. * Gets a boolean indicating that only power of 2 textures are supported
  27755. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27756. */
  27757. readonly needPOTTextures: boolean;
  27758. /** @hidden */
  27759. _badOS: boolean;
  27760. /** @hidden */
  27761. _badDesktopOS: boolean;
  27762. /**
  27763. * Gets the audio engine
  27764. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27765. * @ignorenaming
  27766. */
  27767. static audioEngine: IAudioEngine;
  27768. /**
  27769. * Default AudioEngine factory responsible of creating the Audio Engine.
  27770. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27771. */
  27772. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27773. /**
  27774. * Default offline support factory responsible of creating a tool used to store data locally.
  27775. * By default, this will create a Database object if the workload has been embedded.
  27776. */
  27777. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27778. private _onFocus;
  27779. private _onBlur;
  27780. private _onCanvasPointerOut;
  27781. private _onCanvasBlur;
  27782. private _onCanvasFocus;
  27783. private _onFullscreenChange;
  27784. private _onPointerLockChange;
  27785. private _hardwareScalingLevel;
  27786. /** @hidden */
  27787. _caps: EngineCapabilities;
  27788. private _pointerLockRequested;
  27789. private _isStencilEnable;
  27790. private _colorWrite;
  27791. private _loadingScreen;
  27792. /** @hidden */
  27793. _drawCalls: PerfCounter;
  27794. private _glVersion;
  27795. private _glRenderer;
  27796. private _glVendor;
  27797. private _videoTextureSupported;
  27798. private _renderingQueueLaunched;
  27799. private _activeRenderLoops;
  27800. private _deterministicLockstep;
  27801. private _lockstepMaxSteps;
  27802. /**
  27803. * Observable signaled when a context lost event is raised
  27804. */
  27805. onContextLostObservable: Observable<Engine>;
  27806. /**
  27807. * Observable signaled when a context restored event is raised
  27808. */
  27809. onContextRestoredObservable: Observable<Engine>;
  27810. private _onContextLost;
  27811. private _onContextRestored;
  27812. private _contextWasLost;
  27813. /** @hidden */
  27814. _doNotHandleContextLost: boolean;
  27815. /**
  27816. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27817. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27818. */
  27819. doNotHandleContextLost: boolean;
  27820. private _performanceMonitor;
  27821. private _fps;
  27822. private _deltaTime;
  27823. /**
  27824. * Turn this value on if you want to pause FPS computation when in background
  27825. */
  27826. disablePerformanceMonitorInBackground: boolean;
  27827. /**
  27828. * Gets the performance monitor attached to this engine
  27829. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27830. */
  27831. readonly performanceMonitor: PerformanceMonitor;
  27832. /**
  27833. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27834. */
  27835. disableVertexArrayObjects: boolean;
  27836. /** @hidden */
  27837. protected _depthCullingState: _DepthCullingState;
  27838. /** @hidden */
  27839. protected _stencilState: _StencilState;
  27840. /** @hidden */
  27841. protected _alphaState: _AlphaState;
  27842. /** @hidden */
  27843. protected _alphaMode: number;
  27844. /** @hidden */
  27845. _internalTexturesCache: InternalTexture[];
  27846. /** @hidden */
  27847. protected _activeChannel: number;
  27848. private _currentTextureChannel;
  27849. /** @hidden */
  27850. protected _boundTexturesCache: {
  27851. [key: string]: Nullable<InternalTexture>;
  27852. };
  27853. /** @hidden */
  27854. protected _currentEffect: Nullable<Effect>;
  27855. /** @hidden */
  27856. protected _currentProgram: Nullable<WebGLProgram>;
  27857. private _compiledEffects;
  27858. private _vertexAttribArraysEnabled;
  27859. /** @hidden */
  27860. protected _cachedViewport: Nullable<Viewport>;
  27861. private _cachedVertexArrayObject;
  27862. /** @hidden */
  27863. protected _cachedVertexBuffers: any;
  27864. /** @hidden */
  27865. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27866. /** @hidden */
  27867. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27868. /** @hidden */
  27869. _currentRenderTarget: Nullable<InternalTexture>;
  27870. private _uintIndicesCurrentlySet;
  27871. private _currentBoundBuffer;
  27872. /** @hidden */
  27873. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27874. private _currentBufferPointers;
  27875. private _currentInstanceLocations;
  27876. private _currentInstanceBuffers;
  27877. private _textureUnits;
  27878. /** @hidden */
  27879. _workingCanvas: Nullable<HTMLCanvasElement>;
  27880. /** @hidden */
  27881. _workingContext: Nullable<CanvasRenderingContext2D>;
  27882. private _rescalePostProcess;
  27883. private _dummyFramebuffer;
  27884. private _externalData;
  27885. /** @hidden */
  27886. _bindedRenderFunction: any;
  27887. private _vaoRecordInProgress;
  27888. private _mustWipeVertexAttributes;
  27889. private _emptyTexture;
  27890. private _emptyCubeTexture;
  27891. private _emptyTexture3D;
  27892. /** @hidden */
  27893. _frameHandler: number;
  27894. private _nextFreeTextureSlots;
  27895. private _maxSimultaneousTextures;
  27896. private _activeRequests;
  27897. private _texturesSupported;
  27898. /** @hidden */
  27899. _textureFormatInUse: Nullable<string>;
  27900. /**
  27901. * Gets the list of texture formats supported
  27902. */
  27903. readonly texturesSupported: Array<string>;
  27904. /**
  27905. * Gets the list of texture formats in use
  27906. */
  27907. readonly textureFormatInUse: Nullable<string>;
  27908. /**
  27909. * Gets the current viewport
  27910. */
  27911. readonly currentViewport: Nullable<Viewport>;
  27912. /**
  27913. * Gets the default empty texture
  27914. */
  27915. readonly emptyTexture: InternalTexture;
  27916. /**
  27917. * Gets the default empty 3D texture
  27918. */
  27919. readonly emptyTexture3D: InternalTexture;
  27920. /**
  27921. * Gets the default empty cube texture
  27922. */
  27923. readonly emptyCubeTexture: InternalTexture;
  27924. /**
  27925. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27926. */
  27927. readonly premultipliedAlpha: boolean;
  27928. /**
  27929. * Creates a new engine
  27930. * @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
  27931. * @param antialias defines enable antialiasing (default: false)
  27932. * @param options defines further options to be sent to the getContext() function
  27933. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27934. */
  27935. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27936. /**
  27937. * Initializes a webVR display and starts listening to display change events
  27938. * The onVRDisplayChangedObservable will be notified upon these changes
  27939. * @returns The onVRDisplayChangedObservable
  27940. */
  27941. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27942. /** @hidden */
  27943. _prepareVRComponent(): void;
  27944. /** @hidden */
  27945. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27946. /** @hidden */
  27947. _submitVRFrame(): void;
  27948. /**
  27949. * Call this function to leave webVR mode
  27950. * Will do nothing if webVR is not supported or if there is no webVR device
  27951. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27952. */
  27953. disableVR(): void;
  27954. /**
  27955. * Gets a boolean indicating that the system is in VR mode and is presenting
  27956. * @returns true if VR mode is engaged
  27957. */
  27958. isVRPresenting(): boolean;
  27959. /** @hidden */
  27960. _requestVRFrame(): void;
  27961. private _disableTouchAction;
  27962. private _rebuildInternalTextures;
  27963. private _rebuildEffects;
  27964. /**
  27965. * Gets a boolean indicating if all created effects are ready
  27966. * @returns true if all effects are ready
  27967. */
  27968. areAllEffectsReady(): boolean;
  27969. private _rebuildBuffers;
  27970. private _initGLContext;
  27971. /**
  27972. * Gets version of the current webGL context
  27973. */
  27974. readonly webGLVersion: number;
  27975. /**
  27976. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27977. */
  27978. readonly isStencilEnable: boolean;
  27979. /** @hidden */
  27980. _prepareWorkingCanvas(): void;
  27981. /**
  27982. * Reset the texture cache to empty state
  27983. */
  27984. resetTextureCache(): void;
  27985. /**
  27986. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27987. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27988. * @returns true if engine is in deterministic lock step mode
  27989. */
  27990. isDeterministicLockStep(): boolean;
  27991. /**
  27992. * Gets the max steps when engine is running in deterministic lock step
  27993. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27994. * @returns the max steps
  27995. */
  27996. getLockstepMaxSteps(): number;
  27997. /**
  27998. * Gets an object containing information about the current webGL context
  27999. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28000. */
  28001. getGlInfo(): {
  28002. vendor: string;
  28003. renderer: string;
  28004. version: string;
  28005. };
  28006. /**
  28007. * Gets current aspect ratio
  28008. * @param camera defines the camera to use to get the aspect ratio
  28009. * @param useScreen defines if screen size must be used (or the current render target if any)
  28010. * @returns a number defining the aspect ratio
  28011. */
  28012. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28013. /**
  28014. * Gets current screen aspect ratio
  28015. * @returns a number defining the aspect ratio
  28016. */
  28017. getScreenAspectRatio(): number;
  28018. /**
  28019. * Gets the current render width
  28020. * @param useScreen defines if screen size must be used (or the current render target if any)
  28021. * @returns a number defining the current render width
  28022. */
  28023. getRenderWidth(useScreen?: boolean): number;
  28024. /**
  28025. * Gets the current render height
  28026. * @param useScreen defines if screen size must be used (or the current render target if any)
  28027. * @returns a number defining the current render height
  28028. */
  28029. getRenderHeight(useScreen?: boolean): number;
  28030. /**
  28031. * Gets the HTML canvas attached with the current webGL context
  28032. * @returns a HTML canvas
  28033. */
  28034. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28035. /**
  28036. * Gets the client rect of the HTML canvas attached with the current webGL context
  28037. * @returns a client rectanglee
  28038. */
  28039. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28040. /**
  28041. * Defines the hardware scaling level.
  28042. * By default the hardware scaling level is computed from the window device ratio.
  28043. * 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.
  28044. * @param level defines the level to use
  28045. */
  28046. setHardwareScalingLevel(level: number): void;
  28047. /**
  28048. * Gets the current hardware scaling level.
  28049. * By default the hardware scaling level is computed from the window device ratio.
  28050. * 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.
  28051. * @returns a number indicating the current hardware scaling level
  28052. */
  28053. getHardwareScalingLevel(): number;
  28054. /**
  28055. * Gets the list of loaded textures
  28056. * @returns an array containing all loaded textures
  28057. */
  28058. getLoadedTexturesCache(): InternalTexture[];
  28059. /**
  28060. * Gets the object containing all engine capabilities
  28061. * @returns the EngineCapabilities object
  28062. */
  28063. getCaps(): EngineCapabilities;
  28064. /**
  28065. * Gets the current depth function
  28066. * @returns a number defining the depth function
  28067. */
  28068. getDepthFunction(): Nullable<number>;
  28069. /**
  28070. * Sets the current depth function
  28071. * @param depthFunc defines the function to use
  28072. */
  28073. setDepthFunction(depthFunc: number): void;
  28074. /**
  28075. * Sets the current depth function to GREATER
  28076. */
  28077. setDepthFunctionToGreater(): void;
  28078. /**
  28079. * Sets the current depth function to GEQUAL
  28080. */
  28081. setDepthFunctionToGreaterOrEqual(): void;
  28082. /**
  28083. * Sets the current depth function to LESS
  28084. */
  28085. setDepthFunctionToLess(): void;
  28086. private _cachedStencilBuffer;
  28087. private _cachedStencilFunction;
  28088. private _cachedStencilMask;
  28089. private _cachedStencilOperationPass;
  28090. private _cachedStencilOperationFail;
  28091. private _cachedStencilOperationDepthFail;
  28092. private _cachedStencilReference;
  28093. /**
  28094. * Caches the the state of the stencil buffer
  28095. */
  28096. cacheStencilState(): void;
  28097. /**
  28098. * Restores the state of the stencil buffer
  28099. */
  28100. restoreStencilState(): void;
  28101. /**
  28102. * Sets the current depth function to LEQUAL
  28103. */
  28104. setDepthFunctionToLessOrEqual(): void;
  28105. /**
  28106. * Gets a boolean indicating if stencil buffer is enabled
  28107. * @returns the current stencil buffer state
  28108. */
  28109. getStencilBuffer(): boolean;
  28110. /**
  28111. * Enable or disable the stencil buffer
  28112. * @param enable defines if the stencil buffer must be enabled or disabled
  28113. */
  28114. setStencilBuffer(enable: boolean): void;
  28115. /**
  28116. * Gets the current stencil mask
  28117. * @returns a number defining the new stencil mask to use
  28118. */
  28119. getStencilMask(): number;
  28120. /**
  28121. * Sets the current stencil mask
  28122. * @param mask defines the new stencil mask to use
  28123. */
  28124. setStencilMask(mask: number): void;
  28125. /**
  28126. * Gets the current stencil function
  28127. * @returns a number defining the stencil function to use
  28128. */
  28129. getStencilFunction(): number;
  28130. /**
  28131. * Gets the current stencil reference value
  28132. * @returns a number defining the stencil reference value to use
  28133. */
  28134. getStencilFunctionReference(): number;
  28135. /**
  28136. * Gets the current stencil mask
  28137. * @returns a number defining the stencil mask to use
  28138. */
  28139. getStencilFunctionMask(): number;
  28140. /**
  28141. * Sets the current stencil function
  28142. * @param stencilFunc defines the new stencil function to use
  28143. */
  28144. setStencilFunction(stencilFunc: number): void;
  28145. /**
  28146. * Sets the current stencil reference
  28147. * @param reference defines the new stencil reference to use
  28148. */
  28149. setStencilFunctionReference(reference: number): void;
  28150. /**
  28151. * Sets the current stencil mask
  28152. * @param mask defines the new stencil mask to use
  28153. */
  28154. setStencilFunctionMask(mask: number): void;
  28155. /**
  28156. * Gets the current stencil operation when stencil fails
  28157. * @returns a number defining stencil operation to use when stencil fails
  28158. */
  28159. getStencilOperationFail(): number;
  28160. /**
  28161. * Gets the current stencil operation when depth fails
  28162. * @returns a number defining stencil operation to use when depth fails
  28163. */
  28164. getStencilOperationDepthFail(): number;
  28165. /**
  28166. * Gets the current stencil operation when stencil passes
  28167. * @returns a number defining stencil operation to use when stencil passes
  28168. */
  28169. getStencilOperationPass(): number;
  28170. /**
  28171. * Sets the stencil operation to use when stencil fails
  28172. * @param operation defines the stencil operation to use when stencil fails
  28173. */
  28174. setStencilOperationFail(operation: number): void;
  28175. /**
  28176. * Sets the stencil operation to use when depth fails
  28177. * @param operation defines the stencil operation to use when depth fails
  28178. */
  28179. setStencilOperationDepthFail(operation: number): void;
  28180. /**
  28181. * Sets the stencil operation to use when stencil passes
  28182. * @param operation defines the stencil operation to use when stencil passes
  28183. */
  28184. setStencilOperationPass(operation: number): void;
  28185. /**
  28186. * Sets a boolean indicating if the dithering state is enabled or disabled
  28187. * @param value defines the dithering state
  28188. */
  28189. setDitheringState(value: boolean): void;
  28190. /**
  28191. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28192. * @param value defines the rasterizer state
  28193. */
  28194. setRasterizerState(value: boolean): void;
  28195. /**
  28196. * stop executing a render loop function and remove it from the execution array
  28197. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28198. */
  28199. stopRenderLoop(renderFunction?: () => void): void;
  28200. /** @hidden */
  28201. _renderLoop(): void;
  28202. /**
  28203. * Register and execute a render loop. The engine can have more than one render function
  28204. * @param renderFunction defines the function to continuously execute
  28205. */
  28206. runRenderLoop(renderFunction: () => void): void;
  28207. /**
  28208. * Toggle full screen mode
  28209. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28210. */
  28211. switchFullscreen(requestPointerLock: boolean): void;
  28212. /**
  28213. * Enters full screen mode
  28214. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28215. */
  28216. enterFullscreen(requestPointerLock: boolean): void;
  28217. /**
  28218. * Exits full screen mode
  28219. */
  28220. exitFullscreen(): void;
  28221. /**
  28222. * Enters Pointerlock mode
  28223. */
  28224. enterPointerlock(): void;
  28225. /**
  28226. * Exits Pointerlock mode
  28227. */
  28228. exitPointerlock(): void;
  28229. /**
  28230. * Clear the current render buffer or the current render target (if any is set up)
  28231. * @param color defines the color to use
  28232. * @param backBuffer defines if the back buffer must be cleared
  28233. * @param depth defines if the depth buffer must be cleared
  28234. * @param stencil defines if the stencil buffer must be cleared
  28235. */
  28236. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28237. /**
  28238. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28239. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28240. * @param y defines the y-coordinate of the corner of the clear rectangle
  28241. * @param width defines the width of the clear rectangle
  28242. * @param height defines the height of the clear rectangle
  28243. * @param clearColor defines the clear color
  28244. */
  28245. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28246. /**
  28247. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28248. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28249. * @param y defines the y-coordinate of the corner of the clear rectangle
  28250. * @param width defines the width of the clear rectangle
  28251. * @param height defines the height of the clear rectangle
  28252. */
  28253. enableScissor(x: number, y: number, width: number, height: number): void;
  28254. /**
  28255. * Disable previously set scissor test rectangle
  28256. */
  28257. disableScissor(): void;
  28258. private _viewportCached;
  28259. /** @hidden */
  28260. _viewport(x: number, y: number, width: number, height: number): void;
  28261. /**
  28262. * Set the WebGL's viewport
  28263. * @param viewport defines the viewport element to be used
  28264. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28265. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28266. */
  28267. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28268. /**
  28269. * Directly set the WebGL Viewport
  28270. * @param x defines the x coordinate of the viewport (in screen space)
  28271. * @param y defines the y coordinate of the viewport (in screen space)
  28272. * @param width defines the width of the viewport (in screen space)
  28273. * @param height defines the height of the viewport (in screen space)
  28274. * @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
  28275. */
  28276. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28277. /**
  28278. * Begin a new frame
  28279. */
  28280. beginFrame(): void;
  28281. /**
  28282. * Enf the current frame
  28283. */
  28284. endFrame(): void;
  28285. /**
  28286. * Resize the view according to the canvas' size
  28287. */
  28288. resize(): void;
  28289. /**
  28290. * Force a specific size of the canvas
  28291. * @param width defines the new canvas' width
  28292. * @param height defines the new canvas' height
  28293. */
  28294. setSize(width: number, height: number): void;
  28295. /**
  28296. * Binds the frame buffer to the specified texture.
  28297. * @param texture The texture to render to or null for the default canvas
  28298. * @param faceIndex The face of the texture to render to in case of cube texture
  28299. * @param requiredWidth The width of the target to render to
  28300. * @param requiredHeight The height of the target to render to
  28301. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28302. * @param depthStencilTexture The depth stencil texture to use to render
  28303. * @param lodLevel defines le lod level to bind to the frame buffer
  28304. */
  28305. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28306. /** @hidden */
  28307. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28308. /**
  28309. * Unbind the current render target texture from the webGL context
  28310. * @param texture defines the render target texture to unbind
  28311. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28312. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28313. */
  28314. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28315. /**
  28316. * Force the mipmap generation for the given render target texture
  28317. * @param texture defines the render target texture to use
  28318. */
  28319. generateMipMapsForCubemap(texture: InternalTexture): void;
  28320. /**
  28321. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28322. */
  28323. flushFramebuffer(): void;
  28324. /**
  28325. * Unbind the current render target and bind the default framebuffer
  28326. */
  28327. restoreDefaultFramebuffer(): void;
  28328. /**
  28329. * Create an uniform buffer
  28330. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28331. * @param elements defines the content of the uniform buffer
  28332. * @returns the webGL uniform buffer
  28333. */
  28334. createUniformBuffer(elements: FloatArray): DataBuffer;
  28335. /**
  28336. * Create a dynamic uniform buffer
  28337. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28338. * @param elements defines the content of the uniform buffer
  28339. * @returns the webGL uniform buffer
  28340. */
  28341. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28342. /**
  28343. * Update an existing uniform buffer
  28344. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28345. * @param uniformBuffer defines the target uniform buffer
  28346. * @param elements defines the content to update
  28347. * @param offset defines the offset in the uniform buffer where update should start
  28348. * @param count defines the size of the data to update
  28349. */
  28350. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28351. private _resetVertexBufferBinding;
  28352. /**
  28353. * Creates a vertex buffer
  28354. * @param data the data for the vertex buffer
  28355. * @returns the new WebGL static buffer
  28356. */
  28357. createVertexBuffer(data: DataArray): DataBuffer;
  28358. /**
  28359. * Creates a dynamic vertex buffer
  28360. * @param data the data for the dynamic vertex buffer
  28361. * @returns the new WebGL dynamic buffer
  28362. */
  28363. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28364. /**
  28365. * Update a dynamic index buffer
  28366. * @param indexBuffer defines the target index buffer
  28367. * @param indices defines the data to update
  28368. * @param offset defines the offset in the target index buffer where update should start
  28369. */
  28370. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28371. /**
  28372. * Updates a dynamic vertex buffer.
  28373. * @param vertexBuffer the vertex buffer to update
  28374. * @param data the data used to update the vertex buffer
  28375. * @param byteOffset the byte offset of the data
  28376. * @param byteLength the byte length of the data
  28377. */
  28378. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28379. private _resetIndexBufferBinding;
  28380. /**
  28381. * Creates a new index buffer
  28382. * @param indices defines the content of the index buffer
  28383. * @param updatable defines if the index buffer must be updatable
  28384. * @returns a new webGL buffer
  28385. */
  28386. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28387. /**
  28388. * Bind a webGL buffer to the webGL context
  28389. * @param buffer defines the buffer to bind
  28390. */
  28391. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28392. /**
  28393. * Bind an uniform buffer to the current webGL context
  28394. * @param buffer defines the buffer to bind
  28395. */
  28396. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28397. /**
  28398. * Bind a buffer to the current webGL context at a given location
  28399. * @param buffer defines the buffer to bind
  28400. * @param location defines the index where to bind the buffer
  28401. */
  28402. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28403. /**
  28404. * Bind a specific block at a given index in a specific shader program
  28405. * @param pipelineContext defines the pipeline context to use
  28406. * @param blockName defines the block name
  28407. * @param index defines the index where to bind the block
  28408. */
  28409. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28410. private bindIndexBuffer;
  28411. private bindBuffer;
  28412. /**
  28413. * update the bound buffer with the given data
  28414. * @param data defines the data to update
  28415. */
  28416. updateArrayBuffer(data: Float32Array): void;
  28417. private _vertexAttribPointer;
  28418. private _bindIndexBufferWithCache;
  28419. private _bindVertexBuffersAttributes;
  28420. /**
  28421. * Records a vertex array object
  28422. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28423. * @param vertexBuffers defines the list of vertex buffers to store
  28424. * @param indexBuffer defines the index buffer to store
  28425. * @param effect defines the effect to store
  28426. * @returns the new vertex array object
  28427. */
  28428. recordVertexArrayObject(vertexBuffers: {
  28429. [key: string]: VertexBuffer;
  28430. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28431. /**
  28432. * Bind a specific vertex array object
  28433. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28434. * @param vertexArrayObject defines the vertex array object to bind
  28435. * @param indexBuffer defines the index buffer to bind
  28436. */
  28437. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28438. /**
  28439. * Bind webGl buffers directly to the webGL context
  28440. * @param vertexBuffer defines the vertex buffer to bind
  28441. * @param indexBuffer defines the index buffer to bind
  28442. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28443. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28444. * @param effect defines the effect associated with the vertex buffer
  28445. */
  28446. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28447. private _unbindVertexArrayObject;
  28448. /**
  28449. * Bind a list of vertex buffers to the webGL context
  28450. * @param vertexBuffers defines the list of vertex buffers to bind
  28451. * @param indexBuffer defines the index buffer to bind
  28452. * @param effect defines the effect associated with the vertex buffers
  28453. */
  28454. bindBuffers(vertexBuffers: {
  28455. [key: string]: Nullable<VertexBuffer>;
  28456. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28457. /**
  28458. * Unbind all instance attributes
  28459. */
  28460. unbindInstanceAttributes(): void;
  28461. /**
  28462. * Release and free the memory of a vertex array object
  28463. * @param vao defines the vertex array object to delete
  28464. */
  28465. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28466. /** @hidden */
  28467. _releaseBuffer(buffer: DataBuffer): boolean;
  28468. /**
  28469. * Creates a webGL buffer to use with instanciation
  28470. * @param capacity defines the size of the buffer
  28471. * @returns the webGL buffer
  28472. */
  28473. createInstancesBuffer(capacity: number): DataBuffer;
  28474. /**
  28475. * Delete a webGL buffer used with instanciation
  28476. * @param buffer defines the webGL buffer to delete
  28477. */
  28478. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28479. /**
  28480. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28481. * @param instancesBuffer defines the webGL buffer to update and bind
  28482. * @param data defines the data to store in the buffer
  28483. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28484. */
  28485. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28486. /**
  28487. * Apply all cached states (depth, culling, stencil and alpha)
  28488. */
  28489. applyStates(): void;
  28490. /**
  28491. * Send a draw order
  28492. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28493. * @param indexStart defines the starting index
  28494. * @param indexCount defines the number of index to draw
  28495. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28496. */
  28497. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28498. /**
  28499. * Draw a list of points
  28500. * @param verticesStart defines the index of first vertex to draw
  28501. * @param verticesCount defines the count of vertices to draw
  28502. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28503. */
  28504. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28505. /**
  28506. * Draw a list of unindexed primitives
  28507. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28508. * @param verticesStart defines the index of first vertex to draw
  28509. * @param verticesCount defines the count of vertices to draw
  28510. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28511. */
  28512. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28513. /**
  28514. * Draw a list of indexed primitives
  28515. * @param fillMode defines the primitive to use
  28516. * @param indexStart defines the starting index
  28517. * @param indexCount defines the number of index to draw
  28518. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28519. */
  28520. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28521. /**
  28522. * Draw a list of unindexed primitives
  28523. * @param fillMode defines the primitive to use
  28524. * @param verticesStart defines the index of first vertex to draw
  28525. * @param verticesCount defines the count of vertices to draw
  28526. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28527. */
  28528. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28529. private _drawMode;
  28530. /** @hidden */
  28531. _releaseEffect(effect: Effect): void;
  28532. /** @hidden */
  28533. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28534. /**
  28535. * Create a new effect (used to store vertex/fragment shaders)
  28536. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28537. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28538. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28539. * @param samplers defines an array of string used to represent textures
  28540. * @param defines defines the string containing the defines to use to compile the shaders
  28541. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28542. * @param onCompiled defines a function to call when the effect creation is successful
  28543. * @param onError defines a function to call when the effect creation has failed
  28544. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28545. * @returns the new Effect
  28546. */
  28547. 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;
  28548. private _compileShader;
  28549. private _compileRawShader;
  28550. /**
  28551. * Directly creates a webGL program
  28552. * @param pipelineContext defines the pipeline context to attach to
  28553. * @param vertexCode defines the vertex shader code to use
  28554. * @param fragmentCode defines the fragment shader code to use
  28555. * @param context defines the webGL context to use (if not set, the current one will be used)
  28556. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28557. * @returns the new webGL program
  28558. */
  28559. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28560. /**
  28561. * Creates a webGL program
  28562. * @param pipelineContext defines the pipeline context to attach to
  28563. * @param vertexCode defines the vertex shader code to use
  28564. * @param fragmentCode defines the fragment shader code to use
  28565. * @param defines defines the string containing the defines to use to compile the shaders
  28566. * @param context defines the webGL context to use (if not set, the current one will be used)
  28567. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28568. * @returns the new webGL program
  28569. */
  28570. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28571. /**
  28572. * Creates a new pipeline context
  28573. * @returns the new pipeline
  28574. */
  28575. createPipelineContext(): WebGLPipelineContext;
  28576. private _createShaderProgram;
  28577. private _finalizePipelineContext;
  28578. /** @hidden */
  28579. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28580. /** @hidden */
  28581. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28582. /** @hidden */
  28583. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28584. /**
  28585. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28586. * @param pipelineContext defines the pipeline context to use
  28587. * @param uniformsNames defines the list of uniform names
  28588. * @returns an array of webGL uniform locations
  28589. */
  28590. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28591. /**
  28592. * Gets the lsit of active attributes for a given webGL program
  28593. * @param pipelineContext defines the pipeline context to use
  28594. * @param attributesNames defines the list of attribute names to get
  28595. * @returns an array of indices indicating the offset of each attribute
  28596. */
  28597. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28598. /**
  28599. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28600. * @param effect defines the effect to activate
  28601. */
  28602. enableEffect(effect: Nullable<Effect>): void;
  28603. /**
  28604. * Set the value of an uniform to an array of int32
  28605. * @param uniform defines the webGL uniform location where to store the value
  28606. * @param array defines the array of int32 to store
  28607. */
  28608. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28609. /**
  28610. * Set the value of an uniform to an array of int32 (stored as vec2)
  28611. * @param uniform defines the webGL uniform location where to store the value
  28612. * @param array defines the array of int32 to store
  28613. */
  28614. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28615. /**
  28616. * Set the value of an uniform to an array of int32 (stored as vec3)
  28617. * @param uniform defines the webGL uniform location where to store the value
  28618. * @param array defines the array of int32 to store
  28619. */
  28620. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28621. /**
  28622. * Set the value of an uniform to an array of int32 (stored as vec4)
  28623. * @param uniform defines the webGL uniform location where to store the value
  28624. * @param array defines the array of int32 to store
  28625. */
  28626. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28627. /**
  28628. * Set the value of an uniform to an array of float32
  28629. * @param uniform defines the webGL uniform location where to store the value
  28630. * @param array defines the array of float32 to store
  28631. */
  28632. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28633. /**
  28634. * Set the value of an uniform to an array of float32 (stored as vec2)
  28635. * @param uniform defines the webGL uniform location where to store the value
  28636. * @param array defines the array of float32 to store
  28637. */
  28638. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28639. /**
  28640. * Set the value of an uniform to an array of float32 (stored as vec3)
  28641. * @param uniform defines the webGL uniform location where to store the value
  28642. * @param array defines the array of float32 to store
  28643. */
  28644. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28645. /**
  28646. * Set the value of an uniform to an array of float32 (stored as vec4)
  28647. * @param uniform defines the webGL uniform location where to store the value
  28648. * @param array defines the array of float32 to store
  28649. */
  28650. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28651. /**
  28652. * Set the value of an uniform to an array of number
  28653. * @param uniform defines the webGL uniform location where to store the value
  28654. * @param array defines the array of number to store
  28655. */
  28656. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28657. /**
  28658. * Set the value of an uniform to an array of number (stored as vec2)
  28659. * @param uniform defines the webGL uniform location where to store the value
  28660. * @param array defines the array of number to store
  28661. */
  28662. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28663. /**
  28664. * Set the value of an uniform to an array of number (stored as vec3)
  28665. * @param uniform defines the webGL uniform location where to store the value
  28666. * @param array defines the array of number to store
  28667. */
  28668. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28669. /**
  28670. * Set the value of an uniform to an array of number (stored as vec4)
  28671. * @param uniform defines the webGL uniform location where to store the value
  28672. * @param array defines the array of number to store
  28673. */
  28674. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28675. /**
  28676. * Set the value of an uniform to an array of float32 (stored as matrices)
  28677. * @param uniform defines the webGL uniform location where to store the value
  28678. * @param matrices defines the array of float32 to store
  28679. */
  28680. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28681. /**
  28682. * Set the value of an uniform to a matrix
  28683. * @param uniform defines the webGL uniform location where to store the value
  28684. * @param matrix defines the matrix to store
  28685. */
  28686. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28687. /**
  28688. * Set the value of an uniform to a matrix (3x3)
  28689. * @param uniform defines the webGL uniform location where to store the value
  28690. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28691. */
  28692. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28693. /**
  28694. * Set the value of an uniform to a matrix (2x2)
  28695. * @param uniform defines the webGL uniform location where to store the value
  28696. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28697. */
  28698. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28699. /**
  28700. * Set the value of an uniform to a number (int)
  28701. * @param uniform defines the webGL uniform location where to store the value
  28702. * @param value defines the int number to store
  28703. */
  28704. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28705. /**
  28706. * Set the value of an uniform to a number (float)
  28707. * @param uniform defines the webGL uniform location where to store the value
  28708. * @param value defines the float number to store
  28709. */
  28710. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28711. /**
  28712. * Set the value of an uniform to a vec2
  28713. * @param uniform defines the webGL uniform location where to store the value
  28714. * @param x defines the 1st component of the value
  28715. * @param y defines the 2nd component of the value
  28716. */
  28717. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28718. /**
  28719. * Set the value of an uniform to a vec3
  28720. * @param uniform defines the webGL uniform location where to store the value
  28721. * @param x defines the 1st component of the value
  28722. * @param y defines the 2nd component of the value
  28723. * @param z defines the 3rd component of the value
  28724. */
  28725. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28726. /**
  28727. * Set the value of an uniform to a boolean
  28728. * @param uniform defines the webGL uniform location where to store the value
  28729. * @param bool defines the boolean to store
  28730. */
  28731. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28732. /**
  28733. * Set the value of an uniform to a vec4
  28734. * @param uniform defines the webGL uniform location where to store the value
  28735. * @param x defines the 1st component of the value
  28736. * @param y defines the 2nd component of the value
  28737. * @param z defines the 3rd component of the value
  28738. * @param w defines the 4th component of the value
  28739. */
  28740. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28741. /**
  28742. * Set the value of an uniform to a Color3
  28743. * @param uniform defines the webGL uniform location where to store the value
  28744. * @param color3 defines the color to store
  28745. */
  28746. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28747. /**
  28748. * Set the value of an uniform to a Color3 and an alpha value
  28749. * @param uniform defines the webGL uniform location where to store the value
  28750. * @param color3 defines the color to store
  28751. * @param alpha defines the alpha component to store
  28752. */
  28753. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28754. /**
  28755. * Sets a Color4 on a uniform variable
  28756. * @param uniform defines the uniform location
  28757. * @param color4 defines the value to be set
  28758. */
  28759. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28760. /**
  28761. * Set various states to the webGL context
  28762. * @param culling defines backface culling state
  28763. * @param zOffset defines the value to apply to zOffset (0 by default)
  28764. * @param force defines if states must be applied even if cache is up to date
  28765. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28766. */
  28767. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28768. /**
  28769. * Set the z offset to apply to current rendering
  28770. * @param value defines the offset to apply
  28771. */
  28772. setZOffset(value: number): void;
  28773. /**
  28774. * Gets the current value of the zOffset
  28775. * @returns the current zOffset state
  28776. */
  28777. getZOffset(): number;
  28778. /**
  28779. * Enable or disable depth buffering
  28780. * @param enable defines the state to set
  28781. */
  28782. setDepthBuffer(enable: boolean): void;
  28783. /**
  28784. * Gets a boolean indicating if depth writing is enabled
  28785. * @returns the current depth writing state
  28786. */
  28787. getDepthWrite(): boolean;
  28788. /**
  28789. * Enable or disable depth writing
  28790. * @param enable defines the state to set
  28791. */
  28792. setDepthWrite(enable: boolean): void;
  28793. /**
  28794. * Enable or disable color writing
  28795. * @param enable defines the state to set
  28796. */
  28797. setColorWrite(enable: boolean): void;
  28798. /**
  28799. * Gets a boolean indicating if color writing is enabled
  28800. * @returns the current color writing state
  28801. */
  28802. getColorWrite(): boolean;
  28803. /**
  28804. * Sets alpha constants used by some alpha blending modes
  28805. * @param r defines the red component
  28806. * @param g defines the green component
  28807. * @param b defines the blue component
  28808. * @param a defines the alpha component
  28809. */
  28810. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28811. /**
  28812. * Sets the current alpha mode
  28813. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28814. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28815. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28816. */
  28817. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28818. /**
  28819. * Gets the current alpha mode
  28820. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28821. * @returns the current alpha mode
  28822. */
  28823. getAlphaMode(): number;
  28824. /**
  28825. * Clears the list of texture accessible through engine.
  28826. * This can help preventing texture load conflict due to name collision.
  28827. */
  28828. clearInternalTexturesCache(): void;
  28829. /**
  28830. * Force the entire cache to be cleared
  28831. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28832. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28833. */
  28834. wipeCaches(bruteForce?: boolean): void;
  28835. /**
  28836. * Set the compressed texture format to use, based on the formats you have, and the formats
  28837. * supported by the hardware / browser.
  28838. *
  28839. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28840. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28841. * to API arguments needed to compressed textures. This puts the burden on the container
  28842. * generator to house the arcane code for determining these for current & future formats.
  28843. *
  28844. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28845. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28846. *
  28847. * Note: The result of this call is not taken into account when a texture is base64.
  28848. *
  28849. * @param formatsAvailable defines the list of those format families you have created
  28850. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28851. *
  28852. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28853. * @returns The extension selected.
  28854. */
  28855. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28856. /** @hidden */
  28857. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28858. min: number;
  28859. mag: number;
  28860. };
  28861. /** @hidden */
  28862. _createTexture(): WebGLTexture;
  28863. /**
  28864. * Usually called from Texture.ts.
  28865. * Passed information to create a WebGLTexture
  28866. * @param urlArg defines a value which contains one of the following:
  28867. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28868. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28869. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28870. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28871. * @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)
  28872. * @param scene needed for loading to the correct scene
  28873. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28874. * @param onLoad optional callback to be called upon successful completion
  28875. * @param onError optional callback to be called upon failure
  28876. * @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
  28877. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28878. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28879. * @param forcedExtension defines the extension to use to pick the right loader
  28880. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28881. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28882. */
  28883. 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;
  28884. private _rescaleTexture;
  28885. private _unpackFlipYCached;
  28886. /**
  28887. * In case you are sharing the context with other applications, it might
  28888. * be interested to not cache the unpack flip y state to ensure a consistent
  28889. * value would be set.
  28890. */
  28891. enableUnpackFlipYCached: boolean;
  28892. /** @hidden */
  28893. _unpackFlipY(value: boolean): void;
  28894. /** @hidden */
  28895. _getUnpackAlignement(): number;
  28896. /**
  28897. * Creates a dynamic texture
  28898. * @param width defines the width of the texture
  28899. * @param height defines the height of the texture
  28900. * @param generateMipMaps defines if the engine should generate the mip levels
  28901. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28902. * @returns the dynamic texture inside an InternalTexture
  28903. */
  28904. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28905. /**
  28906. * Update the sampling mode of a given texture
  28907. * @param samplingMode defines the required sampling mode
  28908. * @param texture defines the texture to update
  28909. */
  28910. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28911. /**
  28912. * Update the content of a dynamic texture
  28913. * @param texture defines the texture to update
  28914. * @param canvas defines the canvas containing the source
  28915. * @param invertY defines if data must be stored with Y axis inverted
  28916. * @param premulAlpha defines if alpha is stored as premultiplied
  28917. * @param format defines the format of the data
  28918. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28919. */
  28920. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28921. /**
  28922. * Update a video texture
  28923. * @param texture defines the texture to update
  28924. * @param video defines the video element to use
  28925. * @param invertY defines if data must be stored with Y axis inverted
  28926. */
  28927. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28928. /**
  28929. * Updates a depth texture Comparison Mode and Function.
  28930. * If the comparison Function is equal to 0, the mode will be set to none.
  28931. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28932. * @param texture The texture to set the comparison function for
  28933. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28934. */
  28935. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28936. /** @hidden */
  28937. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28938. width: number;
  28939. height: number;
  28940. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28941. /**
  28942. * Creates a depth stencil texture.
  28943. * This is only available in WebGL 2 or with the depth texture extension available.
  28944. * @param size The size of face edge in the texture.
  28945. * @param options The options defining the texture.
  28946. * @returns The texture
  28947. */
  28948. createDepthStencilTexture(size: number | {
  28949. width: number;
  28950. height: number;
  28951. }, options: DepthTextureCreationOptions): InternalTexture;
  28952. /**
  28953. * Creates a depth stencil texture.
  28954. * This is only available in WebGL 2 or with the depth texture extension available.
  28955. * @param size The size of face edge in the texture.
  28956. * @param options The options defining the texture.
  28957. * @returns The texture
  28958. */
  28959. private _createDepthStencilTexture;
  28960. /**
  28961. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28962. * @param renderTarget The render target to set the frame buffer for
  28963. */
  28964. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28965. /**
  28966. * Creates a new render target texture
  28967. * @param size defines the size of the texture
  28968. * @param options defines the options used to create the texture
  28969. * @returns a new render target texture stored in an InternalTexture
  28970. */
  28971. createRenderTargetTexture(size: number | {
  28972. width: number;
  28973. height: number;
  28974. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28975. /** @hidden */
  28976. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28977. /**
  28978. * Updates the sample count of a render target texture
  28979. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28980. * @param texture defines the texture to update
  28981. * @param samples defines the sample count to set
  28982. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28983. */
  28984. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28985. /** @hidden */
  28986. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28987. /** @hidden */
  28988. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28989. /** @hidden */
  28990. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28991. /** @hidden */
  28992. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28993. /**
  28994. * @hidden
  28995. */
  28996. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28997. private _prepareWebGLTextureContinuation;
  28998. private _prepareWebGLTexture;
  28999. /** @hidden */
  29000. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29001. /** @hidden */
  29002. _releaseFramebufferObjects(texture: InternalTexture): void;
  29003. /** @hidden */
  29004. _releaseTexture(texture: InternalTexture): void;
  29005. private setProgram;
  29006. private _boundUniforms;
  29007. /**
  29008. * Binds an effect to the webGL context
  29009. * @param effect defines the effect to bind
  29010. */
  29011. bindSamplers(effect: Effect): void;
  29012. private _activateCurrentTexture;
  29013. /** @hidden */
  29014. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29015. /** @hidden */
  29016. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29017. /**
  29018. * Sets a texture to the webGL context from a postprocess
  29019. * @param channel defines the channel to use
  29020. * @param postProcess defines the source postprocess
  29021. */
  29022. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29023. /**
  29024. * Binds the output of the passed in post process to the texture channel specified
  29025. * @param channel The channel the texture should be bound to
  29026. * @param postProcess The post process which's output should be bound
  29027. */
  29028. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29029. /**
  29030. * Unbind all textures from the webGL context
  29031. */
  29032. unbindAllTextures(): void;
  29033. /**
  29034. * Sets a texture to the according uniform.
  29035. * @param channel The texture channel
  29036. * @param uniform The uniform to set
  29037. * @param texture The texture to apply
  29038. */
  29039. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29040. /**
  29041. * Sets a depth stencil texture from a render target to the according uniform.
  29042. * @param channel The texture channel
  29043. * @param uniform The uniform to set
  29044. * @param texture The render target texture containing the depth stencil texture to apply
  29045. */
  29046. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29047. private _bindSamplerUniformToChannel;
  29048. private _getTextureWrapMode;
  29049. private _setTexture;
  29050. /**
  29051. * Sets an array of texture to the webGL context
  29052. * @param channel defines the channel where the texture array must be set
  29053. * @param uniform defines the associated uniform location
  29054. * @param textures defines the array of textures to bind
  29055. */
  29056. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29057. /** @hidden */
  29058. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29059. private _setTextureParameterFloat;
  29060. private _setTextureParameterInteger;
  29061. /**
  29062. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29063. * @param x defines the x coordinate of the rectangle where pixels must be read
  29064. * @param y defines the y coordinate of the rectangle where pixels must be read
  29065. * @param width defines the width of the rectangle where pixels must be read
  29066. * @param height defines the height of the rectangle where pixels must be read
  29067. * @returns a Uint8Array containing RGBA colors
  29068. */
  29069. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29070. /**
  29071. * Add an externaly attached data from its key.
  29072. * This method call will fail and return false, if such key already exists.
  29073. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29074. * @param key the unique key that identifies the data
  29075. * @param data the data object to associate to the key for this Engine instance
  29076. * @return true if no such key were already present and the data was added successfully, false otherwise
  29077. */
  29078. addExternalData<T>(key: string, data: T): boolean;
  29079. /**
  29080. * Get an externaly attached data from its key
  29081. * @param key the unique key that identifies the data
  29082. * @return the associated data, if present (can be null), or undefined if not present
  29083. */
  29084. getExternalData<T>(key: string): T;
  29085. /**
  29086. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29087. * @param key the unique key that identifies the data
  29088. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29089. * @return the associated data, can be null if the factory returned null.
  29090. */
  29091. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29092. /**
  29093. * Remove an externaly attached data from the Engine instance
  29094. * @param key the unique key that identifies the data
  29095. * @return true if the data was successfully removed, false if it doesn't exist
  29096. */
  29097. removeExternalData(key: string): boolean;
  29098. /**
  29099. * Unbind all vertex attributes from the webGL context
  29100. */
  29101. unbindAllAttributes(): void;
  29102. /**
  29103. * 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
  29104. */
  29105. releaseEffects(): void;
  29106. /**
  29107. * Dispose and release all associated resources
  29108. */
  29109. dispose(): void;
  29110. /**
  29111. * Display the loading screen
  29112. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29113. */
  29114. displayLoadingUI(): void;
  29115. /**
  29116. * Hide the loading screen
  29117. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29118. */
  29119. hideLoadingUI(): void;
  29120. /**
  29121. * Gets the current loading screen object
  29122. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29123. */
  29124. /**
  29125. * Sets the current loading screen object
  29126. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29127. */
  29128. loadingScreen: ILoadingScreen;
  29129. /**
  29130. * Sets the current loading screen text
  29131. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29132. */
  29133. loadingUIText: string;
  29134. /**
  29135. * Sets the current loading screen background color
  29136. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29137. */
  29138. loadingUIBackgroundColor: string;
  29139. /**
  29140. * Attach a new callback raised when context lost event is fired
  29141. * @param callback defines the callback to call
  29142. */
  29143. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29144. /**
  29145. * Attach a new callback raised when context restored event is fired
  29146. * @param callback defines the callback to call
  29147. */
  29148. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29149. /**
  29150. * Gets the source code of the vertex shader associated with a specific webGL program
  29151. * @param program defines the program to use
  29152. * @returns a string containing the source code of the vertex shader associated with the program
  29153. */
  29154. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29155. /**
  29156. * Gets the source code of the fragment shader associated with a specific webGL program
  29157. * @param program defines the program to use
  29158. * @returns a string containing the source code of the fragment shader associated with the program
  29159. */
  29160. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29161. /**
  29162. * Get the current error code of the webGL context
  29163. * @returns the error code
  29164. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29165. */
  29166. getError(): number;
  29167. /**
  29168. * Gets the current framerate
  29169. * @returns a number representing the framerate
  29170. */
  29171. getFps(): number;
  29172. /**
  29173. * Gets the time spent between current and previous frame
  29174. * @returns a number representing the delta time in ms
  29175. */
  29176. getDeltaTime(): number;
  29177. private _measureFps;
  29178. /** @hidden */
  29179. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29180. private _canRenderToFloatFramebuffer;
  29181. private _canRenderToHalfFloatFramebuffer;
  29182. private _canRenderToFramebuffer;
  29183. /** @hidden */
  29184. _getWebGLTextureType(type: number): number;
  29185. /** @hidden */
  29186. _getInternalFormat(format: number): number;
  29187. /** @hidden */
  29188. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29189. /** @hidden */
  29190. _getRGBAMultiSampleBufferFormat(type: number): number;
  29191. /** @hidden */
  29192. _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;
  29193. /** @hidden */
  29194. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29195. /**
  29196. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29197. * @returns true if the engine can be created
  29198. * @ignorenaming
  29199. */
  29200. static isSupported(): boolean;
  29201. }
  29202. }
  29203. declare module BABYLON {
  29204. /**
  29205. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29206. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29207. */
  29208. export class EffectFallbacks {
  29209. private _defines;
  29210. private _currentRank;
  29211. private _maxRank;
  29212. private _mesh;
  29213. /**
  29214. * Removes the fallback from the bound mesh.
  29215. */
  29216. unBindMesh(): void;
  29217. /**
  29218. * Adds a fallback on the specified property.
  29219. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29220. * @param define The name of the define in the shader
  29221. */
  29222. addFallback(rank: number, define: string): void;
  29223. /**
  29224. * Sets the mesh to use CPU skinning when needing to fallback.
  29225. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29226. * @param mesh The mesh to use the fallbacks.
  29227. */
  29228. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29229. /**
  29230. * Checks to see if more fallbacks are still availible.
  29231. */
  29232. readonly isMoreFallbacks: boolean;
  29233. /**
  29234. * Removes the defines that should be removed when falling back.
  29235. * @param currentDefines defines the current define statements for the shader.
  29236. * @param effect defines the current effect we try to compile
  29237. * @returns The resulting defines with defines of the current rank removed.
  29238. */
  29239. reduce(currentDefines: string, effect: Effect): string;
  29240. }
  29241. /**
  29242. * Options to be used when creating an effect.
  29243. */
  29244. export class EffectCreationOptions {
  29245. /**
  29246. * Atrributes that will be used in the shader.
  29247. */
  29248. attributes: string[];
  29249. /**
  29250. * Uniform varible names that will be set in the shader.
  29251. */
  29252. uniformsNames: string[];
  29253. /**
  29254. * Uniform buffer varible names that will be set in the shader.
  29255. */
  29256. uniformBuffersNames: string[];
  29257. /**
  29258. * Sampler texture variable names that will be set in the shader.
  29259. */
  29260. samplers: string[];
  29261. /**
  29262. * Define statements that will be set in the shader.
  29263. */
  29264. defines: any;
  29265. /**
  29266. * Possible fallbacks for this effect to improve performance when needed.
  29267. */
  29268. fallbacks: Nullable<EffectFallbacks>;
  29269. /**
  29270. * Callback that will be called when the shader is compiled.
  29271. */
  29272. onCompiled: Nullable<(effect: Effect) => void>;
  29273. /**
  29274. * Callback that will be called if an error occurs during shader compilation.
  29275. */
  29276. onError: Nullable<(effect: Effect, errors: string) => void>;
  29277. /**
  29278. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29279. */
  29280. indexParameters: any;
  29281. /**
  29282. * Max number of lights that can be used in the shader.
  29283. */
  29284. maxSimultaneousLights: number;
  29285. /**
  29286. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29287. */
  29288. transformFeedbackVaryings: Nullable<string[]>;
  29289. }
  29290. /**
  29291. * Effect containing vertex and fragment shader that can be executed on an object.
  29292. */
  29293. export class Effect implements IDisposable {
  29294. /**
  29295. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29296. */
  29297. static ShadersRepository: string;
  29298. /**
  29299. * Name of the effect.
  29300. */
  29301. name: any;
  29302. /**
  29303. * String container all the define statements that should be set on the shader.
  29304. */
  29305. defines: string;
  29306. /**
  29307. * Callback that will be called when the shader is compiled.
  29308. */
  29309. onCompiled: Nullable<(effect: Effect) => void>;
  29310. /**
  29311. * Callback that will be called if an error occurs during shader compilation.
  29312. */
  29313. onError: Nullable<(effect: Effect, errors: string) => void>;
  29314. /**
  29315. * Callback that will be called when effect is bound.
  29316. */
  29317. onBind: Nullable<(effect: Effect) => void>;
  29318. /**
  29319. * Unique ID of the effect.
  29320. */
  29321. uniqueId: number;
  29322. /**
  29323. * Observable that will be called when the shader is compiled.
  29324. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29325. */
  29326. onCompileObservable: Observable<Effect>;
  29327. /**
  29328. * Observable that will be called if an error occurs during shader compilation.
  29329. */
  29330. onErrorObservable: Observable<Effect>;
  29331. /** @hidden */
  29332. _onBindObservable: Nullable<Observable<Effect>>;
  29333. /**
  29334. * Observable that will be called when effect is bound.
  29335. */
  29336. readonly onBindObservable: Observable<Effect>;
  29337. /** @hidden */
  29338. _bonesComputationForcedToCPU: boolean;
  29339. private static _uniqueIdSeed;
  29340. private _engine;
  29341. private _uniformBuffersNames;
  29342. private _uniformsNames;
  29343. private _samplerList;
  29344. private _samplers;
  29345. private _isReady;
  29346. private _compilationError;
  29347. private _attributesNames;
  29348. private _attributes;
  29349. private _uniforms;
  29350. /**
  29351. * Key for the effect.
  29352. * @hidden
  29353. */
  29354. _key: string;
  29355. private _indexParameters;
  29356. private _fallbacks;
  29357. private _vertexSourceCode;
  29358. private _fragmentSourceCode;
  29359. private _vertexSourceCodeOverride;
  29360. private _fragmentSourceCodeOverride;
  29361. private _transformFeedbackVaryings;
  29362. /**
  29363. * Compiled shader to webGL program.
  29364. * @hidden
  29365. */
  29366. _pipelineContext: Nullable<IPipelineContext>;
  29367. private _valueCache;
  29368. private static _baseCache;
  29369. /**
  29370. * Instantiates an effect.
  29371. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29372. * @param baseName Name of the effect.
  29373. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29374. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29375. * @param samplers List of sampler variables that will be passed to the shader.
  29376. * @param engine Engine to be used to render the effect
  29377. * @param defines Define statements to be added to the shader.
  29378. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29379. * @param onCompiled Callback that will be called when the shader is compiled.
  29380. * @param onError Callback that will be called if an error occurs during shader compilation.
  29381. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29382. */
  29383. 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);
  29384. private _useFinalCode;
  29385. /**
  29386. * Unique key for this effect
  29387. */
  29388. readonly key: string;
  29389. /**
  29390. * If the effect has been compiled and prepared.
  29391. * @returns if the effect is compiled and prepared.
  29392. */
  29393. isReady(): boolean;
  29394. /**
  29395. * The engine the effect was initialized with.
  29396. * @returns the engine.
  29397. */
  29398. getEngine(): Engine;
  29399. /**
  29400. * The pipeline context for this effect
  29401. * @returns the associated pipeline context
  29402. */
  29403. getPipelineContext(): Nullable<IPipelineContext>;
  29404. /**
  29405. * The set of names of attribute variables for the shader.
  29406. * @returns An array of attribute names.
  29407. */
  29408. getAttributesNames(): string[];
  29409. /**
  29410. * Returns the attribute at the given index.
  29411. * @param index The index of the attribute.
  29412. * @returns The location of the attribute.
  29413. */
  29414. getAttributeLocation(index: number): number;
  29415. /**
  29416. * Returns the attribute based on the name of the variable.
  29417. * @param name of the attribute to look up.
  29418. * @returns the attribute location.
  29419. */
  29420. getAttributeLocationByName(name: string): number;
  29421. /**
  29422. * The number of attributes.
  29423. * @returns the numnber of attributes.
  29424. */
  29425. getAttributesCount(): number;
  29426. /**
  29427. * Gets the index of a uniform variable.
  29428. * @param uniformName of the uniform to look up.
  29429. * @returns the index.
  29430. */
  29431. getUniformIndex(uniformName: string): number;
  29432. /**
  29433. * Returns the attribute based on the name of the variable.
  29434. * @param uniformName of the uniform to look up.
  29435. * @returns the location of the uniform.
  29436. */
  29437. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29438. /**
  29439. * Returns an array of sampler variable names
  29440. * @returns The array of sampler variable neames.
  29441. */
  29442. getSamplers(): string[];
  29443. /**
  29444. * The error from the last compilation.
  29445. * @returns the error string.
  29446. */
  29447. getCompilationError(): string;
  29448. /**
  29449. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29450. * @param func The callback to be used.
  29451. */
  29452. executeWhenCompiled(func: (effect: Effect) => void): void;
  29453. private _checkIsReady;
  29454. /** @hidden */
  29455. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29456. /** @hidden */
  29457. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29458. /** @hidden */
  29459. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29460. /**
  29461. * Recompiles the webGL program
  29462. * @param vertexSourceCode The source code for the vertex shader.
  29463. * @param fragmentSourceCode The source code for the fragment shader.
  29464. * @param onCompiled Callback called when completed.
  29465. * @param onError Callback called on error.
  29466. * @hidden
  29467. */
  29468. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29469. /**
  29470. * Prepares the effect
  29471. * @hidden
  29472. */
  29473. _prepareEffect(): void;
  29474. /**
  29475. * Checks if the effect is supported. (Must be called after compilation)
  29476. */
  29477. readonly isSupported: boolean;
  29478. /**
  29479. * Binds a texture to the engine to be used as output of the shader.
  29480. * @param channel Name of the output variable.
  29481. * @param texture Texture to bind.
  29482. * @hidden
  29483. */
  29484. _bindTexture(channel: string, texture: InternalTexture): void;
  29485. /**
  29486. * Sets a texture on the engine to be used in the shader.
  29487. * @param channel Name of the sampler variable.
  29488. * @param texture Texture to set.
  29489. */
  29490. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29491. /**
  29492. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29493. * @param channel Name of the sampler variable.
  29494. * @param texture Texture to set.
  29495. */
  29496. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29497. /**
  29498. * Sets an array of textures on the engine to be used in the shader.
  29499. * @param channel Name of the variable.
  29500. * @param textures Textures to set.
  29501. */
  29502. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29503. /**
  29504. * 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)
  29505. * @param channel Name of the sampler variable.
  29506. * @param postProcess Post process to get the input texture from.
  29507. */
  29508. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29509. /**
  29510. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29511. * 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)
  29512. * @param channel Name of the sampler variable.
  29513. * @param postProcess Post process to get the output texture from.
  29514. */
  29515. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29516. /** @hidden */
  29517. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29518. /** @hidden */
  29519. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29520. /** @hidden */
  29521. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29522. /** @hidden */
  29523. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29524. /**
  29525. * Binds a buffer to a uniform.
  29526. * @param buffer Buffer to bind.
  29527. * @param name Name of the uniform variable to bind to.
  29528. */
  29529. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29530. /**
  29531. * Binds block to a uniform.
  29532. * @param blockName Name of the block to bind.
  29533. * @param index Index to bind.
  29534. */
  29535. bindUniformBlock(blockName: string, index: number): void;
  29536. /**
  29537. * Sets an interger value on a uniform variable.
  29538. * @param uniformName Name of the variable.
  29539. * @param value Value to be set.
  29540. * @returns this effect.
  29541. */
  29542. setInt(uniformName: string, value: number): Effect;
  29543. /**
  29544. * Sets an int array on a uniform variable.
  29545. * @param uniformName Name of the variable.
  29546. * @param array array to be set.
  29547. * @returns this effect.
  29548. */
  29549. setIntArray(uniformName: string, array: Int32Array): Effect;
  29550. /**
  29551. * 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)
  29552. * @param uniformName Name of the variable.
  29553. * @param array array to be set.
  29554. * @returns this effect.
  29555. */
  29556. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29557. /**
  29558. * 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)
  29559. * @param uniformName Name of the variable.
  29560. * @param array array to be set.
  29561. * @returns this effect.
  29562. */
  29563. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29564. /**
  29565. * 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)
  29566. * @param uniformName Name of the variable.
  29567. * @param array array to be set.
  29568. * @returns this effect.
  29569. */
  29570. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29571. /**
  29572. * Sets an float array on a uniform variable.
  29573. * @param uniformName Name of the variable.
  29574. * @param array array to be set.
  29575. * @returns this effect.
  29576. */
  29577. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29578. /**
  29579. * 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)
  29580. * @param uniformName Name of the variable.
  29581. * @param array array to be set.
  29582. * @returns this effect.
  29583. */
  29584. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29585. /**
  29586. * 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)
  29587. * @param uniformName Name of the variable.
  29588. * @param array array to be set.
  29589. * @returns this effect.
  29590. */
  29591. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29592. /**
  29593. * 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)
  29594. * @param uniformName Name of the variable.
  29595. * @param array array to be set.
  29596. * @returns this effect.
  29597. */
  29598. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29599. /**
  29600. * Sets an array on a uniform variable.
  29601. * @param uniformName Name of the variable.
  29602. * @param array array to be set.
  29603. * @returns this effect.
  29604. */
  29605. setArray(uniformName: string, array: number[]): Effect;
  29606. /**
  29607. * 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)
  29608. * @param uniformName Name of the variable.
  29609. * @param array array to be set.
  29610. * @returns this effect.
  29611. */
  29612. setArray2(uniformName: string, array: number[]): Effect;
  29613. /**
  29614. * 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)
  29615. * @param uniformName Name of the variable.
  29616. * @param array array to be set.
  29617. * @returns this effect.
  29618. */
  29619. setArray3(uniformName: string, array: number[]): Effect;
  29620. /**
  29621. * 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)
  29622. * @param uniformName Name of the variable.
  29623. * @param array array to be set.
  29624. * @returns this effect.
  29625. */
  29626. setArray4(uniformName: string, array: number[]): Effect;
  29627. /**
  29628. * Sets matrices on a uniform variable.
  29629. * @param uniformName Name of the variable.
  29630. * @param matrices matrices to be set.
  29631. * @returns this effect.
  29632. */
  29633. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29634. /**
  29635. * Sets matrix on a uniform variable.
  29636. * @param uniformName Name of the variable.
  29637. * @param matrix matrix to be set.
  29638. * @returns this effect.
  29639. */
  29640. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29641. /**
  29642. * 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)
  29643. * @param uniformName Name of the variable.
  29644. * @param matrix matrix to be set.
  29645. * @returns this effect.
  29646. */
  29647. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29648. /**
  29649. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29650. * @param uniformName Name of the variable.
  29651. * @param matrix matrix to be set.
  29652. * @returns this effect.
  29653. */
  29654. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29655. /**
  29656. * Sets a float on a uniform variable.
  29657. * @param uniformName Name of the variable.
  29658. * @param value value to be set.
  29659. * @returns this effect.
  29660. */
  29661. setFloat(uniformName: string, value: number): Effect;
  29662. /**
  29663. * Sets a boolean on a uniform variable.
  29664. * @param uniformName Name of the variable.
  29665. * @param bool value to be set.
  29666. * @returns this effect.
  29667. */
  29668. setBool(uniformName: string, bool: boolean): Effect;
  29669. /**
  29670. * Sets a Vector2 on a uniform variable.
  29671. * @param uniformName Name of the variable.
  29672. * @param vector2 vector2 to be set.
  29673. * @returns this effect.
  29674. */
  29675. setVector2(uniformName: string, vector2: Vector2): Effect;
  29676. /**
  29677. * Sets a float2 on a uniform variable.
  29678. * @param uniformName Name of the variable.
  29679. * @param x First float in float2.
  29680. * @param y Second float in float2.
  29681. * @returns this effect.
  29682. */
  29683. setFloat2(uniformName: string, x: number, y: number): Effect;
  29684. /**
  29685. * Sets a Vector3 on a uniform variable.
  29686. * @param uniformName Name of the variable.
  29687. * @param vector3 Value to be set.
  29688. * @returns this effect.
  29689. */
  29690. setVector3(uniformName: string, vector3: Vector3): Effect;
  29691. /**
  29692. * Sets a float3 on a uniform variable.
  29693. * @param uniformName Name of the variable.
  29694. * @param x First float in float3.
  29695. * @param y Second float in float3.
  29696. * @param z Third float in float3.
  29697. * @returns this effect.
  29698. */
  29699. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29700. /**
  29701. * Sets a Vector4 on a uniform variable.
  29702. * @param uniformName Name of the variable.
  29703. * @param vector4 Value to be set.
  29704. * @returns this effect.
  29705. */
  29706. setVector4(uniformName: string, vector4: Vector4): Effect;
  29707. /**
  29708. * Sets a float4 on a uniform variable.
  29709. * @param uniformName Name of the variable.
  29710. * @param x First float in float4.
  29711. * @param y Second float in float4.
  29712. * @param z Third float in float4.
  29713. * @param w Fourth float in float4.
  29714. * @returns this effect.
  29715. */
  29716. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29717. /**
  29718. * Sets a Color3 on a uniform variable.
  29719. * @param uniformName Name of the variable.
  29720. * @param color3 Value to be set.
  29721. * @returns this effect.
  29722. */
  29723. setColor3(uniformName: string, color3: Color3): Effect;
  29724. /**
  29725. * Sets a Color4 on a uniform variable.
  29726. * @param uniformName Name of the variable.
  29727. * @param color3 Value to be set.
  29728. * @param alpha Alpha value to be set.
  29729. * @returns this effect.
  29730. */
  29731. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29732. /**
  29733. * Sets a Color4 on a uniform variable
  29734. * @param uniformName defines the name of the variable
  29735. * @param color4 defines the value to be set
  29736. * @returns this effect.
  29737. */
  29738. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29739. /** Release all associated resources */
  29740. dispose(): void;
  29741. /**
  29742. * This function will add a new shader to the shader store
  29743. * @param name the name of the shader
  29744. * @param pixelShader optional pixel shader content
  29745. * @param vertexShader optional vertex shader content
  29746. */
  29747. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29748. /**
  29749. * Store of each shader (The can be looked up using effect.key)
  29750. */
  29751. static ShadersStore: {
  29752. [key: string]: string;
  29753. };
  29754. /**
  29755. * Store of each included file for a shader (The can be looked up using effect.key)
  29756. */
  29757. static IncludesShadersStore: {
  29758. [key: string]: string;
  29759. };
  29760. /**
  29761. * Resets the cache of effects.
  29762. */
  29763. static ResetCache(): void;
  29764. }
  29765. }
  29766. declare module BABYLON {
  29767. /**
  29768. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29769. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29770. * 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;
  29771. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29772. */
  29773. export class ColorCurves {
  29774. private _dirty;
  29775. private _tempColor;
  29776. private _globalCurve;
  29777. private _highlightsCurve;
  29778. private _midtonesCurve;
  29779. private _shadowsCurve;
  29780. private _positiveCurve;
  29781. private _negativeCurve;
  29782. private _globalHue;
  29783. private _globalDensity;
  29784. private _globalSaturation;
  29785. private _globalExposure;
  29786. /**
  29787. * Gets the global Hue value.
  29788. * 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).
  29789. */
  29790. /**
  29791. * Sets the global Hue value.
  29792. * 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).
  29793. */
  29794. globalHue: number;
  29795. /**
  29796. * Gets the global Density value.
  29797. * 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.
  29798. * Values less than zero provide a filter of opposite hue.
  29799. */
  29800. /**
  29801. * Sets the global Density value.
  29802. * 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.
  29803. * Values less than zero provide a filter of opposite hue.
  29804. */
  29805. globalDensity: number;
  29806. /**
  29807. * Gets the global Saturation value.
  29808. * 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.
  29809. */
  29810. /**
  29811. * Sets the global Saturation value.
  29812. * 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.
  29813. */
  29814. globalSaturation: number;
  29815. /**
  29816. * Gets the global Exposure value.
  29817. * 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.
  29818. */
  29819. /**
  29820. * Sets the global Exposure value.
  29821. * 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.
  29822. */
  29823. globalExposure: number;
  29824. private _highlightsHue;
  29825. private _highlightsDensity;
  29826. private _highlightsSaturation;
  29827. private _highlightsExposure;
  29828. /**
  29829. * Gets the highlights Hue value.
  29830. * 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).
  29831. */
  29832. /**
  29833. * Sets the highlights Hue value.
  29834. * 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).
  29835. */
  29836. highlightsHue: number;
  29837. /**
  29838. * Gets the highlights Density value.
  29839. * 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.
  29840. * Values less than zero provide a filter of opposite hue.
  29841. */
  29842. /**
  29843. * Sets the highlights Density value.
  29844. * 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.
  29845. * Values less than zero provide a filter of opposite hue.
  29846. */
  29847. highlightsDensity: number;
  29848. /**
  29849. * Gets the highlights Saturation value.
  29850. * 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.
  29851. */
  29852. /**
  29853. * Sets the highlights Saturation value.
  29854. * 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.
  29855. */
  29856. highlightsSaturation: number;
  29857. /**
  29858. * Gets the highlights Exposure value.
  29859. * 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.
  29860. */
  29861. /**
  29862. * Sets the highlights Exposure value.
  29863. * 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.
  29864. */
  29865. highlightsExposure: number;
  29866. private _midtonesHue;
  29867. private _midtonesDensity;
  29868. private _midtonesSaturation;
  29869. private _midtonesExposure;
  29870. /**
  29871. * Gets the midtones Hue value.
  29872. * 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).
  29873. */
  29874. /**
  29875. * Sets the midtones Hue value.
  29876. * 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).
  29877. */
  29878. midtonesHue: number;
  29879. /**
  29880. * Gets the midtones Density value.
  29881. * 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.
  29882. * Values less than zero provide a filter of opposite hue.
  29883. */
  29884. /**
  29885. * Sets the midtones Density value.
  29886. * 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.
  29887. * Values less than zero provide a filter of opposite hue.
  29888. */
  29889. midtonesDensity: number;
  29890. /**
  29891. * Gets the midtones Saturation value.
  29892. * 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.
  29893. */
  29894. /**
  29895. * Sets the midtones Saturation value.
  29896. * 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.
  29897. */
  29898. midtonesSaturation: number;
  29899. /**
  29900. * Gets the midtones Exposure value.
  29901. * 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.
  29902. */
  29903. /**
  29904. * Sets the midtones Exposure value.
  29905. * 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.
  29906. */
  29907. midtonesExposure: number;
  29908. private _shadowsHue;
  29909. private _shadowsDensity;
  29910. private _shadowsSaturation;
  29911. private _shadowsExposure;
  29912. /**
  29913. * Gets the shadows Hue value.
  29914. * 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).
  29915. */
  29916. /**
  29917. * Sets the shadows Hue value.
  29918. * 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).
  29919. */
  29920. shadowsHue: number;
  29921. /**
  29922. * Gets the shadows Density value.
  29923. * 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.
  29924. * Values less than zero provide a filter of opposite hue.
  29925. */
  29926. /**
  29927. * Sets the shadows Density value.
  29928. * 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.
  29929. * Values less than zero provide a filter of opposite hue.
  29930. */
  29931. shadowsDensity: number;
  29932. /**
  29933. * Gets the shadows Saturation value.
  29934. * 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.
  29935. */
  29936. /**
  29937. * Sets the shadows Saturation value.
  29938. * 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.
  29939. */
  29940. shadowsSaturation: number;
  29941. /**
  29942. * Gets the shadows Exposure value.
  29943. * 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.
  29944. */
  29945. /**
  29946. * Sets the shadows Exposure value.
  29947. * 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.
  29948. */
  29949. shadowsExposure: number;
  29950. /**
  29951. * Returns the class name
  29952. * @returns The class name
  29953. */
  29954. getClassName(): string;
  29955. /**
  29956. * Binds the color curves to the shader.
  29957. * @param colorCurves The color curve to bind
  29958. * @param effect The effect to bind to
  29959. * @param positiveUniform The positive uniform shader parameter
  29960. * @param neutralUniform The neutral uniform shader parameter
  29961. * @param negativeUniform The negative uniform shader parameter
  29962. */
  29963. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29964. /**
  29965. * Prepare the list of uniforms associated with the ColorCurves effects.
  29966. * @param uniformsList The list of uniforms used in the effect
  29967. */
  29968. static PrepareUniforms(uniformsList: string[]): void;
  29969. /**
  29970. * Returns color grading data based on a hue, density, saturation and exposure value.
  29971. * @param filterHue The hue of the color filter.
  29972. * @param filterDensity The density of the color filter.
  29973. * @param saturation The saturation.
  29974. * @param exposure The exposure.
  29975. * @param result The result data container.
  29976. */
  29977. private getColorGradingDataToRef;
  29978. /**
  29979. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29980. * @param value The input slider value in range [-100,100].
  29981. * @returns Adjusted value.
  29982. */
  29983. private static applyColorGradingSliderNonlinear;
  29984. /**
  29985. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29986. * @param hue The hue (H) input.
  29987. * @param saturation The saturation (S) input.
  29988. * @param brightness The brightness (B) input.
  29989. * @result An RGBA color represented as Vector4.
  29990. */
  29991. private static fromHSBToRef;
  29992. /**
  29993. * Returns a value clamped between min and max
  29994. * @param value The value to clamp
  29995. * @param min The minimum of value
  29996. * @param max The maximum of value
  29997. * @returns The clamped value.
  29998. */
  29999. private static clamp;
  30000. /**
  30001. * Clones the current color curve instance.
  30002. * @return The cloned curves
  30003. */
  30004. clone(): ColorCurves;
  30005. /**
  30006. * Serializes the current color curve instance to a json representation.
  30007. * @return a JSON representation
  30008. */
  30009. serialize(): any;
  30010. /**
  30011. * Parses the color curve from a json representation.
  30012. * @param source the JSON source to parse
  30013. * @return The parsed curves
  30014. */
  30015. static Parse(source: any): ColorCurves;
  30016. }
  30017. }
  30018. declare module BABYLON {
  30019. /**
  30020. * Interface to follow in your material defines to integrate easily the
  30021. * Image proccessing functions.
  30022. * @hidden
  30023. */
  30024. export interface IImageProcessingConfigurationDefines {
  30025. IMAGEPROCESSING: boolean;
  30026. VIGNETTE: boolean;
  30027. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30028. VIGNETTEBLENDMODEOPAQUE: boolean;
  30029. TONEMAPPING: boolean;
  30030. TONEMAPPING_ACES: boolean;
  30031. CONTRAST: boolean;
  30032. EXPOSURE: boolean;
  30033. COLORCURVES: boolean;
  30034. COLORGRADING: boolean;
  30035. COLORGRADING3D: boolean;
  30036. SAMPLER3DGREENDEPTH: boolean;
  30037. SAMPLER3DBGRMAP: boolean;
  30038. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30039. }
  30040. /**
  30041. * @hidden
  30042. */
  30043. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30044. IMAGEPROCESSING: boolean;
  30045. VIGNETTE: boolean;
  30046. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30047. VIGNETTEBLENDMODEOPAQUE: boolean;
  30048. TONEMAPPING: boolean;
  30049. TONEMAPPING_ACES: boolean;
  30050. CONTRAST: boolean;
  30051. COLORCURVES: boolean;
  30052. COLORGRADING: boolean;
  30053. COLORGRADING3D: boolean;
  30054. SAMPLER3DGREENDEPTH: boolean;
  30055. SAMPLER3DBGRMAP: boolean;
  30056. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30057. EXPOSURE: boolean;
  30058. constructor();
  30059. }
  30060. /**
  30061. * This groups together the common properties used for image processing either in direct forward pass
  30062. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30063. * or not.
  30064. */
  30065. export class ImageProcessingConfiguration {
  30066. /**
  30067. * Default tone mapping applied in BabylonJS.
  30068. */
  30069. static readonly TONEMAPPING_STANDARD: number;
  30070. /**
  30071. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30072. * to other engines rendering to increase portability.
  30073. */
  30074. static readonly TONEMAPPING_ACES: number;
  30075. /**
  30076. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30077. */
  30078. colorCurves: Nullable<ColorCurves>;
  30079. private _colorCurvesEnabled;
  30080. /**
  30081. * Gets wether the color curves effect is enabled.
  30082. */
  30083. /**
  30084. * Sets wether the color curves effect is enabled.
  30085. */
  30086. colorCurvesEnabled: boolean;
  30087. private _colorGradingTexture;
  30088. /**
  30089. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30090. */
  30091. /**
  30092. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30093. */
  30094. colorGradingTexture: Nullable<BaseTexture>;
  30095. private _colorGradingEnabled;
  30096. /**
  30097. * Gets wether the color grading effect is enabled.
  30098. */
  30099. /**
  30100. * Sets wether the color grading effect is enabled.
  30101. */
  30102. colorGradingEnabled: boolean;
  30103. private _colorGradingWithGreenDepth;
  30104. /**
  30105. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30106. */
  30107. /**
  30108. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30109. */
  30110. colorGradingWithGreenDepth: boolean;
  30111. private _colorGradingBGR;
  30112. /**
  30113. * Gets wether the color grading texture contains BGR values.
  30114. */
  30115. /**
  30116. * Sets wether the color grading texture contains BGR values.
  30117. */
  30118. colorGradingBGR: boolean;
  30119. /** @hidden */
  30120. _exposure: number;
  30121. /**
  30122. * Gets the Exposure used in the effect.
  30123. */
  30124. /**
  30125. * Sets the Exposure used in the effect.
  30126. */
  30127. exposure: number;
  30128. private _toneMappingEnabled;
  30129. /**
  30130. * Gets wether the tone mapping effect is enabled.
  30131. */
  30132. /**
  30133. * Sets wether the tone mapping effect is enabled.
  30134. */
  30135. toneMappingEnabled: boolean;
  30136. private _toneMappingType;
  30137. /**
  30138. * Gets the type of tone mapping effect.
  30139. */
  30140. /**
  30141. * Sets the type of tone mapping effect used in BabylonJS.
  30142. */
  30143. toneMappingType: number;
  30144. protected _contrast: number;
  30145. /**
  30146. * Gets the contrast used in the effect.
  30147. */
  30148. /**
  30149. * Sets the contrast used in the effect.
  30150. */
  30151. contrast: number;
  30152. /**
  30153. * Vignette stretch size.
  30154. */
  30155. vignetteStretch: number;
  30156. /**
  30157. * Vignette centre X Offset.
  30158. */
  30159. vignetteCentreX: number;
  30160. /**
  30161. * Vignette centre Y Offset.
  30162. */
  30163. vignetteCentreY: number;
  30164. /**
  30165. * Vignette weight or intensity of the vignette effect.
  30166. */
  30167. vignetteWeight: number;
  30168. /**
  30169. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30170. * if vignetteEnabled is set to true.
  30171. */
  30172. vignetteColor: Color4;
  30173. /**
  30174. * Camera field of view used by the Vignette effect.
  30175. */
  30176. vignetteCameraFov: number;
  30177. private _vignetteBlendMode;
  30178. /**
  30179. * Gets the vignette blend mode allowing different kind of effect.
  30180. */
  30181. /**
  30182. * Sets the vignette blend mode allowing different kind of effect.
  30183. */
  30184. vignetteBlendMode: number;
  30185. private _vignetteEnabled;
  30186. /**
  30187. * Gets wether the vignette effect is enabled.
  30188. */
  30189. /**
  30190. * Sets wether the vignette effect is enabled.
  30191. */
  30192. vignetteEnabled: boolean;
  30193. private _applyByPostProcess;
  30194. /**
  30195. * Gets wether the image processing is applied through a post process or not.
  30196. */
  30197. /**
  30198. * Sets wether the image processing is applied through a post process or not.
  30199. */
  30200. applyByPostProcess: boolean;
  30201. private _isEnabled;
  30202. /**
  30203. * Gets wether the image processing is enabled or not.
  30204. */
  30205. /**
  30206. * Sets wether the image processing is enabled or not.
  30207. */
  30208. isEnabled: boolean;
  30209. /**
  30210. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30211. */
  30212. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30213. /**
  30214. * Method called each time the image processing information changes requires to recompile the effect.
  30215. */
  30216. protected _updateParameters(): void;
  30217. /**
  30218. * Gets the current class name.
  30219. * @return "ImageProcessingConfiguration"
  30220. */
  30221. getClassName(): string;
  30222. /**
  30223. * Prepare the list of uniforms associated with the Image Processing effects.
  30224. * @param uniforms The list of uniforms used in the effect
  30225. * @param defines the list of defines currently in use
  30226. */
  30227. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30228. /**
  30229. * Prepare the list of samplers associated with the Image Processing effects.
  30230. * @param samplersList The list of uniforms used in the effect
  30231. * @param defines the list of defines currently in use
  30232. */
  30233. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30234. /**
  30235. * Prepare the list of defines associated to the shader.
  30236. * @param defines the list of defines to complete
  30237. * @param forPostProcess Define if we are currently in post process mode or not
  30238. */
  30239. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30240. /**
  30241. * Returns true if all the image processing information are ready.
  30242. * @returns True if ready, otherwise, false
  30243. */
  30244. isReady(): boolean;
  30245. /**
  30246. * Binds the image processing to the shader.
  30247. * @param effect The effect to bind to
  30248. * @param aspectRatio Define the current aspect ratio of the effect
  30249. */
  30250. bind(effect: Effect, aspectRatio?: number): void;
  30251. /**
  30252. * Clones the current image processing instance.
  30253. * @return The cloned image processing
  30254. */
  30255. clone(): ImageProcessingConfiguration;
  30256. /**
  30257. * Serializes the current image processing instance to a json representation.
  30258. * @return a JSON representation
  30259. */
  30260. serialize(): any;
  30261. /**
  30262. * Parses the image processing from a json representation.
  30263. * @param source the JSON source to parse
  30264. * @return The parsed image processing
  30265. */
  30266. static Parse(source: any): ImageProcessingConfiguration;
  30267. private static _VIGNETTEMODE_MULTIPLY;
  30268. private static _VIGNETTEMODE_OPAQUE;
  30269. /**
  30270. * Used to apply the vignette as a mix with the pixel color.
  30271. */
  30272. static readonly VIGNETTEMODE_MULTIPLY: number;
  30273. /**
  30274. * Used to apply the vignette as a replacement of the pixel color.
  30275. */
  30276. static readonly VIGNETTEMODE_OPAQUE: number;
  30277. }
  30278. }
  30279. declare module BABYLON {
  30280. /**
  30281. * This represents all the required information to add a fresnel effect on a material:
  30282. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30283. */
  30284. export class FresnelParameters {
  30285. private _isEnabled;
  30286. /**
  30287. * Define if the fresnel effect is enable or not.
  30288. */
  30289. isEnabled: boolean;
  30290. /**
  30291. * Define the color used on edges (grazing angle)
  30292. */
  30293. leftColor: Color3;
  30294. /**
  30295. * Define the color used on center
  30296. */
  30297. rightColor: Color3;
  30298. /**
  30299. * Define bias applied to computed fresnel term
  30300. */
  30301. bias: number;
  30302. /**
  30303. * Defined the power exponent applied to fresnel term
  30304. */
  30305. power: number;
  30306. /**
  30307. * Clones the current fresnel and its valuues
  30308. * @returns a clone fresnel configuration
  30309. */
  30310. clone(): FresnelParameters;
  30311. /**
  30312. * Serializes the current fresnel parameters to a JSON representation.
  30313. * @return the JSON serialization
  30314. */
  30315. serialize(): any;
  30316. /**
  30317. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30318. * @param parsedFresnelParameters Define the JSON representation
  30319. * @returns the parsed parameters
  30320. */
  30321. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30322. }
  30323. }
  30324. declare module BABYLON {
  30325. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30326. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30327. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30328. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30329. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30330. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30331. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30332. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30333. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30334. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30335. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30336. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30337. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30338. /**
  30339. * Decorator used to define property that can be serialized as reference to a camera
  30340. * @param sourceName defines the name of the property to decorate
  30341. */
  30342. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30343. /**
  30344. * Class used to help serialization objects
  30345. */
  30346. export class SerializationHelper {
  30347. /** @hidden */
  30348. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30349. /** @hidden */
  30350. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30351. /** @hidden */
  30352. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30353. /** @hidden */
  30354. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30355. /**
  30356. * Appends the serialized animations from the source animations
  30357. * @param source Source containing the animations
  30358. * @param destination Target to store the animations
  30359. */
  30360. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30361. /**
  30362. * Static function used to serialized a specific entity
  30363. * @param entity defines the entity to serialize
  30364. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30365. * @returns a JSON compatible object representing the serialization of the entity
  30366. */
  30367. static Serialize<T>(entity: T, serializationObject?: any): any;
  30368. /**
  30369. * Creates a new entity from a serialization data object
  30370. * @param creationFunction defines a function used to instanciated the new entity
  30371. * @param source defines the source serialization data
  30372. * @param scene defines the hosting scene
  30373. * @param rootUrl defines the root url for resources
  30374. * @returns a new entity
  30375. */
  30376. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30377. /**
  30378. * Clones an object
  30379. * @param creationFunction defines the function used to instanciate the new object
  30380. * @param source defines the source object
  30381. * @returns the cloned object
  30382. */
  30383. static Clone<T>(creationFunction: () => T, source: T): T;
  30384. /**
  30385. * Instanciates a new object based on a source one (some data will be shared between both object)
  30386. * @param creationFunction defines the function used to instanciate the new object
  30387. * @param source defines the source object
  30388. * @returns the new object
  30389. */
  30390. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30391. }
  30392. }
  30393. declare module BABYLON {
  30394. /**
  30395. * This is the base class of all the camera used in the application.
  30396. * @see http://doc.babylonjs.com/features/cameras
  30397. */
  30398. export class Camera extends Node {
  30399. /** @hidden */
  30400. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30401. /**
  30402. * This is the default projection mode used by the cameras.
  30403. * It helps recreating a feeling of perspective and better appreciate depth.
  30404. * This is the best way to simulate real life cameras.
  30405. */
  30406. static readonly PERSPECTIVE_CAMERA: number;
  30407. /**
  30408. * This helps creating camera with an orthographic mode.
  30409. * 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.
  30410. */
  30411. static readonly ORTHOGRAPHIC_CAMERA: number;
  30412. /**
  30413. * This is the default FOV mode for perspective cameras.
  30414. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30415. */
  30416. static readonly FOVMODE_VERTICAL_FIXED: number;
  30417. /**
  30418. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30419. */
  30420. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30421. /**
  30422. * This specifies ther is no need for a camera rig.
  30423. * Basically only one eye is rendered corresponding to the camera.
  30424. */
  30425. static readonly RIG_MODE_NONE: number;
  30426. /**
  30427. * Simulates a camera Rig with one blue eye and one red eye.
  30428. * This can be use with 3d blue and red glasses.
  30429. */
  30430. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30431. /**
  30432. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30433. */
  30434. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30435. /**
  30436. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30437. */
  30438. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30439. /**
  30440. * Defines that both eyes of the camera will be rendered over under each other.
  30441. */
  30442. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30443. /**
  30444. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30445. */
  30446. static readonly RIG_MODE_VR: number;
  30447. /**
  30448. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30449. */
  30450. static readonly RIG_MODE_WEBVR: number;
  30451. /**
  30452. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30453. */
  30454. static readonly RIG_MODE_CUSTOM: number;
  30455. /**
  30456. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30457. */
  30458. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30459. /**
  30460. * Define the input manager associated with the camera.
  30461. */
  30462. inputs: CameraInputsManager<Camera>;
  30463. /** @hidden */
  30464. _position: Vector3;
  30465. /**
  30466. * Define the current local position of the camera in the scene
  30467. */
  30468. position: Vector3;
  30469. /**
  30470. * The vector the camera should consider as up.
  30471. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30472. */
  30473. upVector: Vector3;
  30474. /**
  30475. * Define the current limit on the left side for an orthographic camera
  30476. * In scene unit
  30477. */
  30478. orthoLeft: Nullable<number>;
  30479. /**
  30480. * Define the current limit on the right side for an orthographic camera
  30481. * In scene unit
  30482. */
  30483. orthoRight: Nullable<number>;
  30484. /**
  30485. * Define the current limit on the bottom side for an orthographic camera
  30486. * In scene unit
  30487. */
  30488. orthoBottom: Nullable<number>;
  30489. /**
  30490. * Define the current limit on the top side for an orthographic camera
  30491. * In scene unit
  30492. */
  30493. orthoTop: Nullable<number>;
  30494. /**
  30495. * Field Of View is set in Radians. (default is 0.8)
  30496. */
  30497. fov: number;
  30498. /**
  30499. * Define the minimum distance the camera can see from.
  30500. * This is important to note that the depth buffer are not infinite and the closer it starts
  30501. * the more your scene might encounter depth fighting issue.
  30502. */
  30503. minZ: number;
  30504. /**
  30505. * Define the maximum distance the camera can see to.
  30506. * This is important to note that the depth buffer are not infinite and the further it end
  30507. * the more your scene might encounter depth fighting issue.
  30508. */
  30509. maxZ: number;
  30510. /**
  30511. * Define the default inertia of the camera.
  30512. * This helps giving a smooth feeling to the camera movement.
  30513. */
  30514. inertia: number;
  30515. /**
  30516. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30517. */
  30518. mode: number;
  30519. /**
  30520. * Define wether the camera is intermediate.
  30521. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30522. */
  30523. isIntermediate: boolean;
  30524. /**
  30525. * Define the viewport of the camera.
  30526. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30527. */
  30528. viewport: Viewport;
  30529. /**
  30530. * Restricts the camera to viewing objects with the same layerMask.
  30531. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30532. */
  30533. layerMask: number;
  30534. /**
  30535. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30536. */
  30537. fovMode: number;
  30538. /**
  30539. * Rig mode of the camera.
  30540. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30541. * This is normally controlled byt the camera themselves as internal use.
  30542. */
  30543. cameraRigMode: number;
  30544. /**
  30545. * Defines the distance between both "eyes" in case of a RIG
  30546. */
  30547. interaxialDistance: number;
  30548. /**
  30549. * Defines if stereoscopic rendering is done side by side or over under.
  30550. */
  30551. isStereoscopicSideBySide: boolean;
  30552. /**
  30553. * 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
  30554. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30555. * else in the scene.
  30556. */
  30557. customRenderTargets: RenderTargetTexture[];
  30558. /**
  30559. * When set, the camera will render to this render target instead of the default canvas
  30560. */
  30561. outputRenderTarget: Nullable<RenderTargetTexture>;
  30562. /**
  30563. * Observable triggered when the camera view matrix has changed.
  30564. */
  30565. onViewMatrixChangedObservable: Observable<Camera>;
  30566. /**
  30567. * Observable triggered when the camera Projection matrix has changed.
  30568. */
  30569. onProjectionMatrixChangedObservable: Observable<Camera>;
  30570. /**
  30571. * Observable triggered when the inputs have been processed.
  30572. */
  30573. onAfterCheckInputsObservable: Observable<Camera>;
  30574. /**
  30575. * Observable triggered when reset has been called and applied to the camera.
  30576. */
  30577. onRestoreStateObservable: Observable<Camera>;
  30578. /** @hidden */
  30579. _cameraRigParams: any;
  30580. /** @hidden */
  30581. _rigCameras: Camera[];
  30582. /** @hidden */
  30583. _rigPostProcess: Nullable<PostProcess>;
  30584. protected _webvrViewMatrix: Matrix;
  30585. /** @hidden */
  30586. _skipRendering: boolean;
  30587. /** @hidden */
  30588. _projectionMatrix: Matrix;
  30589. /** @hidden */
  30590. _postProcesses: Nullable<PostProcess>[];
  30591. /** @hidden */
  30592. _activeMeshes: SmartArray<AbstractMesh>;
  30593. protected _globalPosition: Vector3;
  30594. /** @hidden */
  30595. _computedViewMatrix: Matrix;
  30596. private _doNotComputeProjectionMatrix;
  30597. private _transformMatrix;
  30598. private _frustumPlanes;
  30599. private _refreshFrustumPlanes;
  30600. private _storedFov;
  30601. private _stateStored;
  30602. /**
  30603. * Instantiates a new camera object.
  30604. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30605. * @see http://doc.babylonjs.com/features/cameras
  30606. * @param name Defines the name of the camera in the scene
  30607. * @param position Defines the position of the camera
  30608. * @param scene Defines the scene the camera belongs too
  30609. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30610. */
  30611. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30612. /**
  30613. * Store current camera state (fov, position, etc..)
  30614. * @returns the camera
  30615. */
  30616. storeState(): Camera;
  30617. /**
  30618. * Restores the camera state values if it has been stored. You must call storeState() first
  30619. */
  30620. protected _restoreStateValues(): boolean;
  30621. /**
  30622. * Restored camera state. You must call storeState() first.
  30623. * @returns true if restored and false otherwise
  30624. */
  30625. restoreState(): boolean;
  30626. /**
  30627. * Gets the class name of the camera.
  30628. * @returns the class name
  30629. */
  30630. getClassName(): string;
  30631. /** @hidden */
  30632. readonly _isCamera: boolean;
  30633. /**
  30634. * Gets a string representation of the camera useful for debug purpose.
  30635. * @param fullDetails Defines that a more verboe level of logging is required
  30636. * @returns the string representation
  30637. */
  30638. toString(fullDetails?: boolean): string;
  30639. /**
  30640. * Gets the current world space position of the camera.
  30641. */
  30642. readonly globalPosition: Vector3;
  30643. /**
  30644. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30645. * @returns the active meshe list
  30646. */
  30647. getActiveMeshes(): SmartArray<AbstractMesh>;
  30648. /**
  30649. * Check wether a mesh is part of the current active mesh list of the camera
  30650. * @param mesh Defines the mesh to check
  30651. * @returns true if active, false otherwise
  30652. */
  30653. isActiveMesh(mesh: Mesh): boolean;
  30654. /**
  30655. * Is this camera ready to be used/rendered
  30656. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30657. * @return true if the camera is ready
  30658. */
  30659. isReady(completeCheck?: boolean): boolean;
  30660. /** @hidden */
  30661. _initCache(): void;
  30662. /** @hidden */
  30663. _updateCache(ignoreParentClass?: boolean): void;
  30664. /** @hidden */
  30665. _isSynchronized(): boolean;
  30666. /** @hidden */
  30667. _isSynchronizedViewMatrix(): boolean;
  30668. /** @hidden */
  30669. _isSynchronizedProjectionMatrix(): boolean;
  30670. /**
  30671. * Attach the input controls to a specific dom element to get the input from.
  30672. * @param element Defines the element the controls should be listened from
  30673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30674. */
  30675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30676. /**
  30677. * Detach the current controls from the specified dom element.
  30678. * @param element Defines the element to stop listening the inputs from
  30679. */
  30680. detachControl(element: HTMLElement): void;
  30681. /**
  30682. * Update the camera state according to the different inputs gathered during the frame.
  30683. */
  30684. update(): void;
  30685. /** @hidden */
  30686. _checkInputs(): void;
  30687. /** @hidden */
  30688. readonly rigCameras: Camera[];
  30689. /**
  30690. * Gets the post process used by the rig cameras
  30691. */
  30692. readonly rigPostProcess: Nullable<PostProcess>;
  30693. /**
  30694. * Internal, gets the first post proces.
  30695. * @returns the first post process to be run on this camera.
  30696. */
  30697. _getFirstPostProcess(): Nullable<PostProcess>;
  30698. private _cascadePostProcessesToRigCams;
  30699. /**
  30700. * Attach a post process to the camera.
  30701. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30702. * @param postProcess The post process to attach to the camera
  30703. * @param insertAt The position of the post process in case several of them are in use in the scene
  30704. * @returns the position the post process has been inserted at
  30705. */
  30706. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30707. /**
  30708. * Detach a post process to the camera.
  30709. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30710. * @param postProcess The post process to detach from the camera
  30711. */
  30712. detachPostProcess(postProcess: PostProcess): void;
  30713. /**
  30714. * Gets the current world matrix of the camera
  30715. */
  30716. getWorldMatrix(): Matrix;
  30717. /** @hidden */
  30718. _getViewMatrix(): Matrix;
  30719. /**
  30720. * Gets the current view matrix of the camera.
  30721. * @param force forces the camera to recompute the matrix without looking at the cached state
  30722. * @returns the view matrix
  30723. */
  30724. getViewMatrix(force?: boolean): Matrix;
  30725. /**
  30726. * Freeze the projection matrix.
  30727. * It will prevent the cache check of the camera projection compute and can speed up perf
  30728. * if no parameter of the camera are meant to change
  30729. * @param projection Defines manually a projection if necessary
  30730. */
  30731. freezeProjectionMatrix(projection?: Matrix): void;
  30732. /**
  30733. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30734. */
  30735. unfreezeProjectionMatrix(): void;
  30736. /**
  30737. * Gets the current projection matrix of the camera.
  30738. * @param force forces the camera to recompute the matrix without looking at the cached state
  30739. * @returns the projection matrix
  30740. */
  30741. getProjectionMatrix(force?: boolean): Matrix;
  30742. /**
  30743. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30744. * @returns a Matrix
  30745. */
  30746. getTransformationMatrix(): Matrix;
  30747. private _updateFrustumPlanes;
  30748. /**
  30749. * Checks if a cullable object (mesh...) is in the camera frustum
  30750. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30751. * @param target The object to check
  30752. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30753. * @returns true if the object is in frustum otherwise false
  30754. */
  30755. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30756. /**
  30757. * Checks if a cullable object (mesh...) is in the camera frustum
  30758. * Unlike isInFrustum this cheks the full bounding box
  30759. * @param target The object to check
  30760. * @returns true if the object is in frustum otherwise false
  30761. */
  30762. isCompletelyInFrustum(target: ICullable): boolean;
  30763. /**
  30764. * Gets a ray in the forward direction from the camera.
  30765. * @param length Defines the length of the ray to create
  30766. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30767. * @param origin Defines the start point of the ray which defaults to the camera position
  30768. * @returns the forward ray
  30769. */
  30770. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30771. /**
  30772. * Releases resources associated with this node.
  30773. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30774. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30775. */
  30776. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30777. /** @hidden */
  30778. _isLeftCamera: boolean;
  30779. /**
  30780. * Gets the left camera of a rig setup in case of Rigged Camera
  30781. */
  30782. readonly isLeftCamera: boolean;
  30783. /** @hidden */
  30784. _isRightCamera: boolean;
  30785. /**
  30786. * Gets the right camera of a rig setup in case of Rigged Camera
  30787. */
  30788. readonly isRightCamera: boolean;
  30789. /**
  30790. * Gets the left camera of a rig setup in case of Rigged Camera
  30791. */
  30792. readonly leftCamera: Nullable<FreeCamera>;
  30793. /**
  30794. * Gets the right camera of a rig setup in case of Rigged Camera
  30795. */
  30796. readonly rightCamera: Nullable<FreeCamera>;
  30797. /**
  30798. * Gets the left camera target of a rig setup in case of Rigged Camera
  30799. * @returns the target position
  30800. */
  30801. getLeftTarget(): Nullable<Vector3>;
  30802. /**
  30803. * Gets the right camera target of a rig setup in case of Rigged Camera
  30804. * @returns the target position
  30805. */
  30806. getRightTarget(): Nullable<Vector3>;
  30807. /**
  30808. * @hidden
  30809. */
  30810. setCameraRigMode(mode: number, rigParams: any): void;
  30811. /** @hidden */
  30812. static _setStereoscopicRigMode(camera: Camera): void;
  30813. /** @hidden */
  30814. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30815. /** @hidden */
  30816. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30817. /** @hidden */
  30818. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30819. /** @hidden */
  30820. _getVRProjectionMatrix(): Matrix;
  30821. protected _updateCameraRotationMatrix(): void;
  30822. protected _updateWebVRCameraRotationMatrix(): void;
  30823. /**
  30824. * This function MUST be overwritten by the different WebVR cameras available.
  30825. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30826. * @hidden
  30827. */
  30828. _getWebVRProjectionMatrix(): Matrix;
  30829. /**
  30830. * This function MUST be overwritten by the different WebVR cameras available.
  30831. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30832. * @hidden
  30833. */
  30834. _getWebVRViewMatrix(): Matrix;
  30835. /** @hidden */
  30836. setCameraRigParameter(name: string, value: any): void;
  30837. /**
  30838. * needs to be overridden by children so sub has required properties to be copied
  30839. * @hidden
  30840. */
  30841. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30842. /**
  30843. * May need to be overridden by children
  30844. * @hidden
  30845. */
  30846. _updateRigCameras(): void;
  30847. /** @hidden */
  30848. _setupInputs(): void;
  30849. /**
  30850. * Serialiaze the camera setup to a json represention
  30851. * @returns the JSON representation
  30852. */
  30853. serialize(): any;
  30854. /**
  30855. * Clones the current camera.
  30856. * @param name The cloned camera name
  30857. * @returns the cloned camera
  30858. */
  30859. clone(name: string): Camera;
  30860. /**
  30861. * Gets the direction of the camera relative to a given local axis.
  30862. * @param localAxis Defines the reference axis to provide a relative direction.
  30863. * @return the direction
  30864. */
  30865. getDirection(localAxis: Vector3): Vector3;
  30866. /**
  30867. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30868. * @param localAxis Defines the reference axis to provide a relative direction.
  30869. * @param result Defines the vector to store the result in
  30870. */
  30871. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30872. /**
  30873. * Gets a camera constructor for a given camera type
  30874. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30875. * @param name The name of the camera the result will be able to instantiate
  30876. * @param scene The scene the result will construct the camera in
  30877. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30878. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30879. * @returns a factory method to construc the camera
  30880. */
  30881. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30882. /**
  30883. * Compute the world matrix of the camera.
  30884. * @returns the camera workd matrix
  30885. */
  30886. computeWorldMatrix(): Matrix;
  30887. /**
  30888. * Parse a JSON and creates the camera from the parsed information
  30889. * @param parsedCamera The JSON to parse
  30890. * @param scene The scene to instantiate the camera in
  30891. * @returns the newly constructed camera
  30892. */
  30893. static Parse(parsedCamera: any, scene: Scene): Camera;
  30894. }
  30895. }
  30896. declare module BABYLON {
  30897. /**
  30898. * Interface for any object that can request an animation frame
  30899. */
  30900. export interface ICustomAnimationFrameRequester {
  30901. /**
  30902. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30903. */
  30904. renderFunction?: Function;
  30905. /**
  30906. * Called to request the next frame to render to
  30907. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30908. */
  30909. requestAnimationFrame: Function;
  30910. /**
  30911. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30912. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30913. */
  30914. requestID?: number;
  30915. }
  30916. /**
  30917. * Interface containing an array of animations
  30918. */
  30919. export interface IAnimatable {
  30920. /**
  30921. * Array of animations
  30922. */
  30923. animations: Nullable<Array<Animation>>;
  30924. }
  30925. /** Interface used by value gradients (color, factor, ...) */
  30926. export interface IValueGradient {
  30927. /**
  30928. * Gets or sets the gradient value (between 0 and 1)
  30929. */
  30930. gradient: number;
  30931. }
  30932. /** Class used to store color4 gradient */
  30933. export class ColorGradient implements IValueGradient {
  30934. /**
  30935. * Gets or sets the gradient value (between 0 and 1)
  30936. */
  30937. gradient: number;
  30938. /**
  30939. * Gets or sets first associated color
  30940. */
  30941. color1: Color4;
  30942. /**
  30943. * Gets or sets second associated color
  30944. */
  30945. color2?: Color4;
  30946. /**
  30947. * Will get a color picked randomly between color1 and color2.
  30948. * If color2 is undefined then color1 will be used
  30949. * @param result defines the target Color4 to store the result in
  30950. */
  30951. getColorToRef(result: Color4): void;
  30952. }
  30953. /** Class used to store color 3 gradient */
  30954. export class Color3Gradient implements IValueGradient {
  30955. /**
  30956. * Gets or sets the gradient value (between 0 and 1)
  30957. */
  30958. gradient: number;
  30959. /**
  30960. * Gets or sets the associated color
  30961. */
  30962. color: Color3;
  30963. }
  30964. /** Class used to store factor gradient */
  30965. export class FactorGradient implements IValueGradient {
  30966. /**
  30967. * Gets or sets the gradient value (between 0 and 1)
  30968. */
  30969. gradient: number;
  30970. /**
  30971. * Gets or sets first associated factor
  30972. */
  30973. factor1: number;
  30974. /**
  30975. * Gets or sets second associated factor
  30976. */
  30977. factor2?: number;
  30978. /**
  30979. * Will get a number picked randomly between factor1 and factor2.
  30980. * If factor2 is undefined then factor1 will be used
  30981. * @returns the picked number
  30982. */
  30983. getFactor(): number;
  30984. }
  30985. /**
  30986. * @ignore
  30987. * Application error to support additional information when loading a file
  30988. */
  30989. export class LoadFileError extends Error {
  30990. /** defines the optional web request */
  30991. request?: WebRequest | undefined;
  30992. private static _setPrototypeOf;
  30993. /**
  30994. * Creates a new LoadFileError
  30995. * @param message defines the message of the error
  30996. * @param request defines the optional web request
  30997. */
  30998. constructor(message: string,
  30999. /** defines the optional web request */
  31000. request?: WebRequest | undefined);
  31001. }
  31002. /**
  31003. * Class used to define a retry strategy when error happens while loading assets
  31004. */
  31005. export class RetryStrategy {
  31006. /**
  31007. * Function used to defines an exponential back off strategy
  31008. * @param maxRetries defines the maximum number of retries (3 by default)
  31009. * @param baseInterval defines the interval between retries
  31010. * @returns the strategy function to use
  31011. */
  31012. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31013. }
  31014. /**
  31015. * File request interface
  31016. */
  31017. export interface IFileRequest {
  31018. /**
  31019. * Raised when the request is complete (success or error).
  31020. */
  31021. onCompleteObservable: Observable<IFileRequest>;
  31022. /**
  31023. * Aborts the request for a file.
  31024. */
  31025. abort: () => void;
  31026. }
  31027. /**
  31028. * Class containing a set of static utilities functions
  31029. */
  31030. export class Tools {
  31031. /**
  31032. * Gets or sets the base URL to use to load assets
  31033. */
  31034. static BaseUrl: string;
  31035. /**
  31036. * Enable/Disable Custom HTTP Request Headers globally.
  31037. * default = false
  31038. * @see CustomRequestHeaders
  31039. */
  31040. static UseCustomRequestHeaders: boolean;
  31041. /**
  31042. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31043. * i.e. when loading files, where the server/service expects an Authorization header
  31044. */
  31045. static CustomRequestHeaders: {
  31046. [key: string]: string;
  31047. };
  31048. /**
  31049. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31050. */
  31051. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31052. /**
  31053. * Default behaviour for cors in the application.
  31054. * It can be a string if the expected behavior is identical in the entire app.
  31055. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31056. */
  31057. static CorsBehavior: string | ((url: string | string[]) => string);
  31058. /**
  31059. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31060. * @ignorenaming
  31061. */
  31062. static UseFallbackTexture: boolean;
  31063. /**
  31064. * Use this object to register external classes like custom textures or material
  31065. * to allow the laoders to instantiate them
  31066. */
  31067. static RegisteredExternalClasses: {
  31068. [key: string]: Object;
  31069. };
  31070. /**
  31071. * Texture content used if a texture cannot loaded
  31072. * @ignorenaming
  31073. */
  31074. static fallbackTexture: string;
  31075. /**
  31076. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31077. * @param u defines the coordinate on X axis
  31078. * @param v defines the coordinate on Y axis
  31079. * @param width defines the width of the source data
  31080. * @param height defines the height of the source data
  31081. * @param pixels defines the source byte array
  31082. * @param color defines the output color
  31083. */
  31084. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31085. /**
  31086. * Interpolates between a and b via alpha
  31087. * @param a The lower value (returned when alpha = 0)
  31088. * @param b The upper value (returned when alpha = 1)
  31089. * @param alpha The interpolation-factor
  31090. * @return The mixed value
  31091. */
  31092. static Mix(a: number, b: number, alpha: number): number;
  31093. /**
  31094. * Tries to instantiate a new object from a given class name
  31095. * @param className defines the class name to instantiate
  31096. * @returns the new object or null if the system was not able to do the instantiation
  31097. */
  31098. static Instantiate(className: string): any;
  31099. /**
  31100. * Provides a slice function that will work even on IE
  31101. * @param data defines the array to slice
  31102. * @param start defines the start of the data (optional)
  31103. * @param end defines the end of the data (optional)
  31104. * @returns the new sliced array
  31105. */
  31106. static Slice<T>(data: T, start?: number, end?: number): T;
  31107. /**
  31108. * Polyfill for setImmediate
  31109. * @param action defines the action to execute after the current execution block
  31110. */
  31111. static SetImmediate(action: () => void): void;
  31112. /**
  31113. * Function indicating if a number is an exponent of 2
  31114. * @param value defines the value to test
  31115. * @returns true if the value is an exponent of 2
  31116. */
  31117. static IsExponentOfTwo(value: number): boolean;
  31118. private static _tmpFloatArray;
  31119. /**
  31120. * Returns the nearest 32-bit single precision float representation of a Number
  31121. * @param value A Number. If the parameter is of a different type, it will get converted
  31122. * to a number or to NaN if it cannot be converted
  31123. * @returns number
  31124. */
  31125. static FloatRound(value: number): number;
  31126. /**
  31127. * Find the next highest power of two.
  31128. * @param x Number to start search from.
  31129. * @return Next highest power of two.
  31130. */
  31131. static CeilingPOT(x: number): number;
  31132. /**
  31133. * Find the next lowest power of two.
  31134. * @param x Number to start search from.
  31135. * @return Next lowest power of two.
  31136. */
  31137. static FloorPOT(x: number): number;
  31138. /**
  31139. * Find the nearest power of two.
  31140. * @param x Number to start search from.
  31141. * @return Next nearest power of two.
  31142. */
  31143. static NearestPOT(x: number): number;
  31144. /**
  31145. * Get the closest exponent of two
  31146. * @param value defines the value to approximate
  31147. * @param max defines the maximum value to return
  31148. * @param mode defines how to define the closest value
  31149. * @returns closest exponent of two of the given value
  31150. */
  31151. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31152. /**
  31153. * Extracts the filename from a path
  31154. * @param path defines the path to use
  31155. * @returns the filename
  31156. */
  31157. static GetFilename(path: string): string;
  31158. /**
  31159. * Extracts the "folder" part of a path (everything before the filename).
  31160. * @param uri The URI to extract the info from
  31161. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31162. * @returns The "folder" part of the path
  31163. */
  31164. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31165. /**
  31166. * Extracts text content from a DOM element hierarchy
  31167. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31168. */
  31169. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31170. /**
  31171. * Convert an angle in radians to degrees
  31172. * @param angle defines the angle to convert
  31173. * @returns the angle in degrees
  31174. */
  31175. static ToDegrees(angle: number): number;
  31176. /**
  31177. * Convert an angle in degrees to radians
  31178. * @param angle defines the angle to convert
  31179. * @returns the angle in radians
  31180. */
  31181. static ToRadians(angle: number): number;
  31182. /**
  31183. * Encode a buffer to a base64 string
  31184. * @param buffer defines the buffer to encode
  31185. * @returns the encoded string
  31186. */
  31187. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31188. /**
  31189. * Extracts minimum and maximum values from a list of indexed positions
  31190. * @param positions defines the positions to use
  31191. * @param indices defines the indices to the positions
  31192. * @param indexStart defines the start index
  31193. * @param indexCount defines the end index
  31194. * @param bias defines bias value to add to the result
  31195. * @return minimum and maximum values
  31196. */
  31197. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31198. minimum: Vector3;
  31199. maximum: Vector3;
  31200. };
  31201. /**
  31202. * Extracts minimum and maximum values from a list of positions
  31203. * @param positions defines the positions to use
  31204. * @param start defines the start index in the positions array
  31205. * @param count defines the number of positions to handle
  31206. * @param bias defines bias value to add to the result
  31207. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31208. * @return minimum and maximum values
  31209. */
  31210. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31211. minimum: Vector3;
  31212. maximum: Vector3;
  31213. };
  31214. /**
  31215. * Returns an array if obj is not an array
  31216. * @param obj defines the object to evaluate as an array
  31217. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31218. * @returns either obj directly if obj is an array or a new array containing obj
  31219. */
  31220. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31221. /**
  31222. * Gets the pointer prefix to use
  31223. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31224. */
  31225. static GetPointerPrefix(): string;
  31226. /**
  31227. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31228. * @param func - the function to be called
  31229. * @param requester - the object that will request the next frame. Falls back to window.
  31230. * @returns frame number
  31231. */
  31232. static QueueNewFrame(func: () => void, requester?: any): number;
  31233. /**
  31234. * Ask the browser to promote the current element to fullscreen rendering mode
  31235. * @param element defines the DOM element to promote
  31236. */
  31237. static RequestFullscreen(element: HTMLElement): void;
  31238. /**
  31239. * Asks the browser to exit fullscreen mode
  31240. */
  31241. static ExitFullscreen(): void;
  31242. /**
  31243. * Ask the browser to promote the current element to pointerlock mode
  31244. * @param element defines the DOM element to promote
  31245. */
  31246. static RequestPointerlock(element: HTMLElement): void;
  31247. /**
  31248. * Asks the browser to exit pointerlock mode
  31249. */
  31250. static ExitPointerlock(): void;
  31251. /**
  31252. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31253. * @param url define the url we are trying
  31254. * @param element define the dom element where to configure the cors policy
  31255. */
  31256. static SetCorsBehavior(url: string | string[], element: {
  31257. crossOrigin: string | null;
  31258. }): void;
  31259. /**
  31260. * Removes unwanted characters from an url
  31261. * @param url defines the url to clean
  31262. * @returns the cleaned url
  31263. */
  31264. static CleanUrl(url: string): string;
  31265. /**
  31266. * Gets or sets a function used to pre-process url before using them to load assets
  31267. */
  31268. static PreprocessUrl: (url: string) => string;
  31269. /**
  31270. * Loads an image as an HTMLImageElement.
  31271. * @param input url string, ArrayBuffer, or Blob to load
  31272. * @param onLoad callback called when the image successfully loads
  31273. * @param onError callback called when the image fails to load
  31274. * @param offlineProvider offline provider for caching
  31275. * @returns the HTMLImageElement of the loaded image
  31276. */
  31277. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31278. /**
  31279. * Loads a file
  31280. * @param url url string, ArrayBuffer, or Blob to load
  31281. * @param onSuccess callback called when the file successfully loads
  31282. * @param onProgress callback called while file is loading (if the server supports this mode)
  31283. * @param offlineProvider defines the offline provider for caching
  31284. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31285. * @param onError callback called when the file fails to load
  31286. * @returns a file request object
  31287. */
  31288. 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;
  31289. /**
  31290. * Load a script (identified by an url). When the url returns, the
  31291. * content of this file is added into a new script element, attached to the DOM (body element)
  31292. * @param scriptUrl defines the url of the script to laod
  31293. * @param onSuccess defines the callback called when the script is loaded
  31294. * @param onError defines the callback to call if an error occurs
  31295. * @param scriptId defines the id of the script element
  31296. */
  31297. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31298. /**
  31299. * Load an asynchronous script (identified by an url). When the url returns, the
  31300. * content of this file is added into a new script element, attached to the DOM (body element)
  31301. * @param scriptUrl defines the url of the script to laod
  31302. * @param scriptId defines the id of the script element
  31303. * @returns a promise request object
  31304. */
  31305. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31306. /**
  31307. * Loads a file from a blob
  31308. * @param fileToLoad defines the blob to use
  31309. * @param callback defines the callback to call when data is loaded
  31310. * @param progressCallback defines the callback to call during loading process
  31311. * @returns a file request object
  31312. */
  31313. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31314. /**
  31315. * Loads a file
  31316. * @param fileToLoad defines the file to load
  31317. * @param callback defines the callback to call when data is loaded
  31318. * @param progressCallBack defines the callback to call during loading process
  31319. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31320. * @returns a file request object
  31321. */
  31322. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31323. /**
  31324. * Creates a data url from a given string content
  31325. * @param content defines the content to convert
  31326. * @returns the new data url link
  31327. */
  31328. static FileAsURL(content: string): string;
  31329. /**
  31330. * Format the given number to a specific decimal format
  31331. * @param value defines the number to format
  31332. * @param decimals defines the number of decimals to use
  31333. * @returns the formatted string
  31334. */
  31335. static Format(value: number, decimals?: number): string;
  31336. /**
  31337. * Checks if a given vector is inside a specific range
  31338. * @param v defines the vector to test
  31339. * @param min defines the minimum range
  31340. * @param max defines the maximum range
  31341. */
  31342. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31343. /**
  31344. * Tries to copy an object by duplicating every property
  31345. * @param source defines the source object
  31346. * @param destination defines the target object
  31347. * @param doNotCopyList defines a list of properties to avoid
  31348. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31349. */
  31350. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31351. /**
  31352. * Gets a boolean indicating if the given object has no own property
  31353. * @param obj defines the object to test
  31354. * @returns true if object has no own property
  31355. */
  31356. static IsEmpty(obj: any): boolean;
  31357. /**
  31358. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31359. * @param str Source string
  31360. * @param suffix Suffix to search for in the source string
  31361. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31362. */
  31363. static EndsWith(str: string, suffix: string): boolean;
  31364. /**
  31365. * Function used to register events at window level
  31366. * @param events defines the events to register
  31367. */
  31368. static RegisterTopRootEvents(events: {
  31369. name: string;
  31370. handler: Nullable<(e: FocusEvent) => any>;
  31371. }[]): void;
  31372. /**
  31373. * Function used to unregister events from window level
  31374. * @param events defines the events to unregister
  31375. */
  31376. static UnregisterTopRootEvents(events: {
  31377. name: string;
  31378. handler: Nullable<(e: FocusEvent) => any>;
  31379. }[]): void;
  31380. /**
  31381. * @ignore
  31382. */
  31383. static _ScreenshotCanvas: HTMLCanvasElement;
  31384. /**
  31385. * Dumps the current bound framebuffer
  31386. * @param width defines the rendering width
  31387. * @param height defines the rendering height
  31388. * @param engine defines the hosting engine
  31389. * @param successCallback defines the callback triggered once the data are available
  31390. * @param mimeType defines the mime type of the result
  31391. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31392. */
  31393. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31394. /**
  31395. * Converts the canvas data to blob.
  31396. * This acts as a polyfill for browsers not supporting the to blob function.
  31397. * @param canvas Defines the canvas to extract the data from
  31398. * @param successCallback Defines the callback triggered once the data are available
  31399. * @param mimeType Defines the mime type of the result
  31400. */
  31401. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31402. /**
  31403. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31404. * @param successCallback defines the callback triggered once the data are available
  31405. * @param mimeType defines the mime type of the result
  31406. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31407. */
  31408. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31409. /**
  31410. * Downloads a blob in the browser
  31411. * @param blob defines the blob to download
  31412. * @param fileName defines the name of the downloaded file
  31413. */
  31414. static Download(blob: Blob, fileName: string): void;
  31415. /**
  31416. * Captures a screenshot of the current rendering
  31417. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31418. * @param engine defines the rendering engine
  31419. * @param camera defines the source camera
  31420. * @param size This parameter can be set to a single number or to an object with the
  31421. * following (optional) properties: precision, width, height. If a single number is passed,
  31422. * it will be used for both width and height. If an object is passed, the screenshot size
  31423. * will be derived from the parameters. The precision property is a multiplier allowing
  31424. * rendering at a higher or lower resolution
  31425. * @param successCallback defines the callback receives a single parameter which contains the
  31426. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31427. * src parameter of an <img> to display it
  31428. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31429. * Check your browser for supported MIME types
  31430. */
  31431. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31432. /**
  31433. * Generates an image screenshot from the specified camera.
  31434. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31435. * @param engine The engine to use for rendering
  31436. * @param camera The camera to use for rendering
  31437. * @param size This parameter can be set to a single number or to an object with the
  31438. * following (optional) properties: precision, width, height. If a single number is passed,
  31439. * it will be used for both width and height. If an object is passed, the screenshot size
  31440. * will be derived from the parameters. The precision property is a multiplier allowing
  31441. * rendering at a higher or lower resolution
  31442. * @param successCallback The callback receives a single parameter which contains the
  31443. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31444. * src parameter of an <img> to display it
  31445. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31446. * Check your browser for supported MIME types
  31447. * @param samples Texture samples (default: 1)
  31448. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31449. * @param fileName A name for for the downloaded file.
  31450. */
  31451. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31452. /**
  31453. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31454. * Be aware Math.random() could cause collisions, but:
  31455. * "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"
  31456. * @returns a pseudo random id
  31457. */
  31458. static RandomId(): string;
  31459. /**
  31460. * Test if the given uri is a base64 string
  31461. * @param uri The uri to test
  31462. * @return True if the uri is a base64 string or false otherwise
  31463. */
  31464. static IsBase64(uri: string): boolean;
  31465. /**
  31466. * Decode the given base64 uri.
  31467. * @param uri The uri to decode
  31468. * @return The decoded base64 data.
  31469. */
  31470. static DecodeBase64(uri: string): ArrayBuffer;
  31471. /**
  31472. * Gets the absolute url.
  31473. * @param url the input url
  31474. * @return the absolute url
  31475. */
  31476. static GetAbsoluteUrl(url: string): string;
  31477. /**
  31478. * No log
  31479. */
  31480. static readonly NoneLogLevel: number;
  31481. /**
  31482. * Only message logs
  31483. */
  31484. static readonly MessageLogLevel: number;
  31485. /**
  31486. * Only warning logs
  31487. */
  31488. static readonly WarningLogLevel: number;
  31489. /**
  31490. * Only error logs
  31491. */
  31492. static readonly ErrorLogLevel: number;
  31493. /**
  31494. * All logs
  31495. */
  31496. static readonly AllLogLevel: number;
  31497. /**
  31498. * Gets a value indicating the number of loading errors
  31499. * @ignorenaming
  31500. */
  31501. static readonly errorsCount: number;
  31502. /**
  31503. * Callback called when a new log is added
  31504. */
  31505. static OnNewCacheEntry: (entry: string) => void;
  31506. /**
  31507. * Log a message to the console
  31508. * @param message defines the message to log
  31509. */
  31510. static Log(message: string): void;
  31511. /**
  31512. * Write a warning message to the console
  31513. * @param message defines the message to log
  31514. */
  31515. static Warn(message: string): void;
  31516. /**
  31517. * Write an error message to the console
  31518. * @param message defines the message to log
  31519. */
  31520. static Error(message: string): void;
  31521. /**
  31522. * Gets current log cache (list of logs)
  31523. */
  31524. static readonly LogCache: string;
  31525. /**
  31526. * Clears the log cache
  31527. */
  31528. static ClearLogCache(): void;
  31529. /**
  31530. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31531. */
  31532. static LogLevels: number;
  31533. /**
  31534. * Checks if the loaded document was accessed via `file:`-Protocol.
  31535. * @returns boolean
  31536. */
  31537. static IsFileURL(): boolean;
  31538. /**
  31539. * Checks if the window object exists
  31540. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31541. */
  31542. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31543. /**
  31544. * No performance log
  31545. */
  31546. static readonly PerformanceNoneLogLevel: number;
  31547. /**
  31548. * Use user marks to log performance
  31549. */
  31550. static readonly PerformanceUserMarkLogLevel: number;
  31551. /**
  31552. * Log performance to the console
  31553. */
  31554. static readonly PerformanceConsoleLogLevel: number;
  31555. private static _performance;
  31556. /**
  31557. * Sets the current performance log level
  31558. */
  31559. static PerformanceLogLevel: number;
  31560. private static _StartPerformanceCounterDisabled;
  31561. private static _EndPerformanceCounterDisabled;
  31562. private static _StartUserMark;
  31563. private static _EndUserMark;
  31564. private static _StartPerformanceConsole;
  31565. private static _EndPerformanceConsole;
  31566. /**
  31567. * Starts a performance counter
  31568. */
  31569. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31570. /**
  31571. * Ends a specific performance coutner
  31572. */
  31573. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31574. /**
  31575. * Gets either window.performance.now() if supported or Date.now() else
  31576. */
  31577. static readonly Now: number;
  31578. /**
  31579. * This method will return the name of the class used to create the instance of the given object.
  31580. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31581. * @param object the object to get the class name from
  31582. * @param isType defines if the object is actually a type
  31583. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31584. */
  31585. static GetClassName(object: any, isType?: boolean): string;
  31586. /**
  31587. * Gets the first element of an array satisfying a given predicate
  31588. * @param array defines the array to browse
  31589. * @param predicate defines the predicate to use
  31590. * @returns null if not found or the element
  31591. */
  31592. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31593. /**
  31594. * This method will return the name of the full name of the class, including its owning module (if any).
  31595. * 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).
  31596. * @param object the object to get the class name from
  31597. * @param isType defines if the object is actually a type
  31598. * @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.
  31599. * @ignorenaming
  31600. */
  31601. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31602. /**
  31603. * Returns a promise that resolves after the given amount of time.
  31604. * @param delay Number of milliseconds to delay
  31605. * @returns Promise that resolves after the given amount of time
  31606. */
  31607. static DelayAsync(delay: number): Promise<void>;
  31608. /**
  31609. * Gets the current gradient from an array of IValueGradient
  31610. * @param ratio defines the current ratio to get
  31611. * @param gradients defines the array of IValueGradient
  31612. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31613. */
  31614. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31615. }
  31616. /**
  31617. * This class is used to track a performance counter which is number based.
  31618. * The user has access to many properties which give statistics of different nature.
  31619. *
  31620. * The implementer can track two kinds of Performance Counter: time and count.
  31621. * 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.
  31622. * 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.
  31623. */
  31624. export class PerfCounter {
  31625. /**
  31626. * Gets or sets a global boolean to turn on and off all the counters
  31627. */
  31628. static Enabled: boolean;
  31629. /**
  31630. * Returns the smallest value ever
  31631. */
  31632. readonly min: number;
  31633. /**
  31634. * Returns the biggest value ever
  31635. */
  31636. readonly max: number;
  31637. /**
  31638. * Returns the average value since the performance counter is running
  31639. */
  31640. readonly average: number;
  31641. /**
  31642. * Returns the average value of the last second the counter was monitored
  31643. */
  31644. readonly lastSecAverage: number;
  31645. /**
  31646. * Returns the current value
  31647. */
  31648. readonly current: number;
  31649. /**
  31650. * Gets the accumulated total
  31651. */
  31652. readonly total: number;
  31653. /**
  31654. * Gets the total value count
  31655. */
  31656. readonly count: number;
  31657. /**
  31658. * Creates a new counter
  31659. */
  31660. constructor();
  31661. /**
  31662. * Call this method to start monitoring a new frame.
  31663. * 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.
  31664. */
  31665. fetchNewFrame(): void;
  31666. /**
  31667. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31668. * @param newCount the count value to add to the monitored count
  31669. * @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.
  31670. */
  31671. addCount(newCount: number, fetchResult: boolean): void;
  31672. /**
  31673. * Start monitoring this performance counter
  31674. */
  31675. beginMonitoring(): void;
  31676. /**
  31677. * Compute the time lapsed since the previous beginMonitoring() call.
  31678. * @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
  31679. */
  31680. endMonitoring(newFrame?: boolean): void;
  31681. private _fetchResult;
  31682. private _startMonitoringTime;
  31683. private _min;
  31684. private _max;
  31685. private _average;
  31686. private _current;
  31687. private _totalValueCount;
  31688. private _totalAccumulated;
  31689. private _lastSecAverage;
  31690. private _lastSecAccumulated;
  31691. private _lastSecTime;
  31692. private _lastSecValueCount;
  31693. }
  31694. /**
  31695. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31696. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31697. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31698. * @param name The name of the class, case should be preserved
  31699. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31700. */
  31701. export function className(name: string, module?: string): (target: Object) => void;
  31702. /**
  31703. * An implementation of a loop for asynchronous functions.
  31704. */
  31705. export class AsyncLoop {
  31706. /**
  31707. * Defines the number of iterations for the loop
  31708. */
  31709. iterations: number;
  31710. /**
  31711. * Defines the current index of the loop.
  31712. */
  31713. index: number;
  31714. private _done;
  31715. private _fn;
  31716. private _successCallback;
  31717. /**
  31718. * Constructor.
  31719. * @param iterations the number of iterations.
  31720. * @param func the function to run each iteration
  31721. * @param successCallback the callback that will be called upon succesful execution
  31722. * @param offset starting offset.
  31723. */
  31724. constructor(
  31725. /**
  31726. * Defines the number of iterations for the loop
  31727. */
  31728. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31729. /**
  31730. * Execute the next iteration. Must be called after the last iteration was finished.
  31731. */
  31732. executeNext(): void;
  31733. /**
  31734. * Break the loop and run the success callback.
  31735. */
  31736. breakLoop(): void;
  31737. /**
  31738. * Create and run an async loop.
  31739. * @param iterations the number of iterations.
  31740. * @param fn the function to run each iteration
  31741. * @param successCallback the callback that will be called upon succesful execution
  31742. * @param offset starting offset.
  31743. * @returns the created async loop object
  31744. */
  31745. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31746. /**
  31747. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31748. * @param iterations total number of iterations
  31749. * @param syncedIterations number of synchronous iterations in each async iteration.
  31750. * @param fn the function to call each iteration.
  31751. * @param callback a success call back that will be called when iterating stops.
  31752. * @param breakFunction a break condition (optional)
  31753. * @param timeout timeout settings for the setTimeout function. default - 0.
  31754. * @returns the created async loop object
  31755. */
  31756. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31757. }
  31758. }
  31759. declare module BABYLON {
  31760. /** @hidden */
  31761. export interface ICollisionCoordinator {
  31762. createCollider(): Collider;
  31763. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31764. init(scene: Scene): void;
  31765. }
  31766. /** @hidden */
  31767. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31768. private _scene;
  31769. private _scaledPosition;
  31770. private _scaledVelocity;
  31771. private _finalPosition;
  31772. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31773. createCollider(): Collider;
  31774. init(scene: Scene): void;
  31775. private _collideWithWorld;
  31776. }
  31777. }
  31778. declare module BABYLON {
  31779. /**
  31780. * Class used to manage all inputs for the scene.
  31781. */
  31782. export class InputManager {
  31783. /** The distance in pixel that you have to move to prevent some events */
  31784. static DragMovementThreshold: number;
  31785. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31786. static LongPressDelay: number;
  31787. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31788. static DoubleClickDelay: number;
  31789. /** If you need to check double click without raising a single click at first click, enable this flag */
  31790. static ExclusiveDoubleClickMode: boolean;
  31791. private _wheelEventName;
  31792. private _onPointerMove;
  31793. private _onPointerDown;
  31794. private _onPointerUp;
  31795. private _initClickEvent;
  31796. private _initActionManager;
  31797. private _delayedSimpleClick;
  31798. private _delayedSimpleClickTimeout;
  31799. private _previousDelayedSimpleClickTimeout;
  31800. private _meshPickProceed;
  31801. private _previousButtonPressed;
  31802. private _currentPickResult;
  31803. private _previousPickResult;
  31804. private _totalPointersPressed;
  31805. private _doubleClickOccured;
  31806. private _pointerOverMesh;
  31807. private _pickedDownMesh;
  31808. private _pickedUpMesh;
  31809. private _pointerX;
  31810. private _pointerY;
  31811. private _unTranslatedPointerX;
  31812. private _unTranslatedPointerY;
  31813. private _startingPointerPosition;
  31814. private _previousStartingPointerPosition;
  31815. private _startingPointerTime;
  31816. private _previousStartingPointerTime;
  31817. private _pointerCaptures;
  31818. private _onKeyDown;
  31819. private _onKeyUp;
  31820. private _onCanvasFocusObserver;
  31821. private _onCanvasBlurObserver;
  31822. private _scene;
  31823. /**
  31824. * Creates a new InputManager
  31825. * @param scene defines the hosting scene
  31826. */
  31827. constructor(scene: Scene);
  31828. /**
  31829. * Gets the mesh that is currently under the pointer
  31830. */
  31831. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31832. /**
  31833. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31834. */
  31835. readonly unTranslatedPointer: Vector2;
  31836. /**
  31837. * Gets or sets the current on-screen X position of the pointer
  31838. */
  31839. pointerX: number;
  31840. /**
  31841. * Gets or sets the current on-screen Y position of the pointer
  31842. */
  31843. pointerY: number;
  31844. private _updatePointerPosition;
  31845. private _processPointerMove;
  31846. private _setRayOnPointerInfo;
  31847. private _checkPrePointerObservable;
  31848. /**
  31849. * Use this method to simulate a pointer move on a mesh
  31850. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31851. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31852. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31853. */
  31854. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31855. /**
  31856. * Use this method to simulate a pointer down on a mesh
  31857. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31858. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31859. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31860. */
  31861. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31862. private _processPointerDown;
  31863. /** @hidden */
  31864. _isPointerSwiping(): boolean;
  31865. /**
  31866. * Use this method to simulate a pointer up on a mesh
  31867. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31868. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31869. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31870. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31871. */
  31872. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31873. private _processPointerUp;
  31874. /**
  31875. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31876. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31877. * @returns true if the pointer was captured
  31878. */
  31879. isPointerCaptured(pointerId?: number): boolean;
  31880. /**
  31881. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31882. * @param attachUp defines if you want to attach events to pointerup
  31883. * @param attachDown defines if you want to attach events to pointerdown
  31884. * @param attachMove defines if you want to attach events to pointermove
  31885. */
  31886. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31887. /**
  31888. * Detaches all event handlers
  31889. */
  31890. detachControl(): void;
  31891. /**
  31892. * Force the value of meshUnderPointer
  31893. * @param mesh defines the mesh to use
  31894. */
  31895. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31896. /**
  31897. * Gets the mesh under the pointer
  31898. * @returns a Mesh or null if no mesh is under the pointer
  31899. */
  31900. getPointerOverMesh(): Nullable<AbstractMesh>;
  31901. }
  31902. }
  31903. declare module BABYLON {
  31904. /**
  31905. * This class defines the direct association between an animation and a target
  31906. */
  31907. export class TargetedAnimation {
  31908. /**
  31909. * Animation to perform
  31910. */
  31911. animation: Animation;
  31912. /**
  31913. * Target to animate
  31914. */
  31915. target: any;
  31916. /**
  31917. * Serialize the object
  31918. * @returns the JSON object representing the current entity
  31919. */
  31920. serialize(): any;
  31921. }
  31922. /**
  31923. * Use this class to create coordinated animations on multiple targets
  31924. */
  31925. export class AnimationGroup implements IDisposable {
  31926. /** The name of the animation group */
  31927. name: string;
  31928. private _scene;
  31929. private _targetedAnimations;
  31930. private _animatables;
  31931. private _from;
  31932. private _to;
  31933. private _isStarted;
  31934. private _isPaused;
  31935. private _speedRatio;
  31936. private _loopAnimation;
  31937. /**
  31938. * Gets or sets the unique id of the node
  31939. */
  31940. uniqueId: number;
  31941. /**
  31942. * This observable will notify when one animation have ended
  31943. */
  31944. onAnimationEndObservable: Observable<TargetedAnimation>;
  31945. /**
  31946. * Observer raised when one animation loops
  31947. */
  31948. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31949. /**
  31950. * This observable will notify when all animations have ended.
  31951. */
  31952. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31953. /**
  31954. * This observable will notify when all animations have paused.
  31955. */
  31956. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31957. /**
  31958. * This observable will notify when all animations are playing.
  31959. */
  31960. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31961. /**
  31962. * Gets the first frame
  31963. */
  31964. readonly from: number;
  31965. /**
  31966. * Gets the last frame
  31967. */
  31968. readonly to: number;
  31969. /**
  31970. * Define if the animations are started
  31971. */
  31972. readonly isStarted: boolean;
  31973. /**
  31974. * Gets a value indicating that the current group is playing
  31975. */
  31976. readonly isPlaying: boolean;
  31977. /**
  31978. * Gets or sets the speed ratio to use for all animations
  31979. */
  31980. /**
  31981. * Gets or sets the speed ratio to use for all animations
  31982. */
  31983. speedRatio: number;
  31984. /**
  31985. * Gets or sets if all animations should loop or not
  31986. */
  31987. loopAnimation: boolean;
  31988. /**
  31989. * Gets the targeted animations for this animation group
  31990. */
  31991. readonly targetedAnimations: Array<TargetedAnimation>;
  31992. /**
  31993. * returning the list of animatables controlled by this animation group.
  31994. */
  31995. readonly animatables: Array<Animatable>;
  31996. /**
  31997. * Instantiates a new Animation Group.
  31998. * This helps managing several animations at once.
  31999. * @see http://doc.babylonjs.com/how_to/group
  32000. * @param name Defines the name of the group
  32001. * @param scene Defines the scene the group belongs to
  32002. */
  32003. constructor(
  32004. /** The name of the animation group */
  32005. name: string, scene?: Nullable<Scene>);
  32006. /**
  32007. * Add an animation (with its target) in the group
  32008. * @param animation defines the animation we want to add
  32009. * @param target defines the target of the animation
  32010. * @returns the TargetedAnimation object
  32011. */
  32012. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32013. /**
  32014. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32015. * It can add constant keys at begin or end
  32016. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32017. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32018. * @returns the animation group
  32019. */
  32020. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32021. /**
  32022. * Start all animations on given targets
  32023. * @param loop defines if animations must loop
  32024. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32025. * @param from defines the from key (optional)
  32026. * @param to defines the to key (optional)
  32027. * @returns the current animation group
  32028. */
  32029. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32030. /**
  32031. * Pause all animations
  32032. * @returns the animation group
  32033. */
  32034. pause(): AnimationGroup;
  32035. /**
  32036. * Play all animations to initial state
  32037. * This function will start() the animations if they were not started or will restart() them if they were paused
  32038. * @param loop defines if animations must loop
  32039. * @returns the animation group
  32040. */
  32041. play(loop?: boolean): AnimationGroup;
  32042. /**
  32043. * Reset all animations to initial state
  32044. * @returns the animation group
  32045. */
  32046. reset(): AnimationGroup;
  32047. /**
  32048. * Restart animations from key 0
  32049. * @returns the animation group
  32050. */
  32051. restart(): AnimationGroup;
  32052. /**
  32053. * Stop all animations
  32054. * @returns the animation group
  32055. */
  32056. stop(): AnimationGroup;
  32057. /**
  32058. * Set animation weight for all animatables
  32059. * @param weight defines the weight to use
  32060. * @return the animationGroup
  32061. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32062. */
  32063. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32064. /**
  32065. * Synchronize and normalize all animatables with a source animatable
  32066. * @param root defines the root animatable to synchronize with
  32067. * @return the animationGroup
  32068. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32069. */
  32070. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32071. /**
  32072. * Goes to a specific frame in this animation group
  32073. * @param frame the frame number to go to
  32074. * @return the animationGroup
  32075. */
  32076. goToFrame(frame: number): AnimationGroup;
  32077. /**
  32078. * Dispose all associated resources
  32079. */
  32080. dispose(): void;
  32081. private _checkAnimationGroupEnded;
  32082. /**
  32083. * Clone the current animation group and returns a copy
  32084. * @param newName defines the name of the new group
  32085. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32086. * @returns the new aniamtion group
  32087. */
  32088. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32089. /**
  32090. * Serializes the animationGroup to an object
  32091. * @returns Serialized object
  32092. */
  32093. serialize(): any;
  32094. /**
  32095. * Returns a new AnimationGroup object parsed from the source provided.
  32096. * @param parsedAnimationGroup defines the source
  32097. * @param scene defines the scene that will receive the animationGroup
  32098. * @returns a new AnimationGroup
  32099. */
  32100. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32101. /**
  32102. * Returns the string "AnimationGroup"
  32103. * @returns "AnimationGroup"
  32104. */
  32105. getClassName(): string;
  32106. /**
  32107. * Creates a detailled string about the object
  32108. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32109. * @returns a string representing the object
  32110. */
  32111. toString(fullDetails?: boolean): string;
  32112. }
  32113. }
  32114. declare module BABYLON {
  32115. /**
  32116. * Define an interface for all classes that will hold resources
  32117. */
  32118. export interface IDisposable {
  32119. /**
  32120. * Releases all held resources
  32121. */
  32122. dispose(): void;
  32123. }
  32124. /** Interface defining initialization parameters for Scene class */
  32125. export interface SceneOptions {
  32126. /**
  32127. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32128. * It will improve performance when the number of geometries becomes important.
  32129. */
  32130. useGeometryUniqueIdsMap?: boolean;
  32131. /**
  32132. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32133. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32134. */
  32135. useMaterialMeshMap?: boolean;
  32136. /**
  32137. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32138. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32139. */
  32140. useClonedMeshhMap?: boolean;
  32141. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32142. virtual?: boolean;
  32143. }
  32144. /**
  32145. * Represents a scene to be rendered by the engine.
  32146. * @see http://doc.babylonjs.com/features/scene
  32147. */
  32148. export class Scene extends AbstractScene implements IAnimatable {
  32149. private static _uniqueIdCounter;
  32150. /** The fog is deactivated */
  32151. static readonly FOGMODE_NONE: number;
  32152. /** The fog density is following an exponential function */
  32153. static readonly FOGMODE_EXP: number;
  32154. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32155. static readonly FOGMODE_EXP2: number;
  32156. /** The fog density is following a linear function. */
  32157. static readonly FOGMODE_LINEAR: number;
  32158. /**
  32159. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32160. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32161. */
  32162. static MinDeltaTime: number;
  32163. /**
  32164. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32165. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32166. */
  32167. static MaxDeltaTime: number;
  32168. /**
  32169. * Factory used to create the default material.
  32170. * @param name The name of the material to create
  32171. * @param scene The scene to create the material for
  32172. * @returns The default material
  32173. */
  32174. static DefaultMaterialFactory(scene: Scene): Material;
  32175. /**
  32176. * Factory used to create the a collision coordinator.
  32177. * @returns The collision coordinator
  32178. */
  32179. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32180. /** @hidden */
  32181. _inputManager: InputManager;
  32182. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32183. cameraToUseForPointers: Nullable<Camera>;
  32184. /** @hidden */
  32185. readonly _isScene: boolean;
  32186. /**
  32187. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32188. */
  32189. autoClear: boolean;
  32190. /**
  32191. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32192. */
  32193. autoClearDepthAndStencil: boolean;
  32194. /**
  32195. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32196. */
  32197. clearColor: Color4;
  32198. /**
  32199. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32200. */
  32201. ambientColor: Color3;
  32202. /**
  32203. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32204. * It should only be one of the following (if not the default embedded one):
  32205. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32206. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32207. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32208. * The material properties need to be setup according to the type of texture in use.
  32209. */
  32210. environmentBRDFTexture: BaseTexture;
  32211. /** @hidden */
  32212. protected _environmentTexture: Nullable<BaseTexture>;
  32213. /**
  32214. * Texture used in all pbr material as the reflection texture.
  32215. * As in the majority of the scene they are the same (exception for multi room and so on),
  32216. * this is easier to reference from here than from all the materials.
  32217. */
  32218. /**
  32219. * Texture used in all pbr material as the reflection texture.
  32220. * As in the majority of the scene they are the same (exception for multi room and so on),
  32221. * this is easier to set here than in all the materials.
  32222. */
  32223. environmentTexture: Nullable<BaseTexture>;
  32224. /** @hidden */
  32225. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32226. /**
  32227. * Default image processing configuration used either in the rendering
  32228. * Forward main pass or through the imageProcessingPostProcess if present.
  32229. * As in the majority of the scene they are the same (exception for multi camera),
  32230. * this is easier to reference from here than from all the materials and post process.
  32231. *
  32232. * No setter as we it is a shared configuration, you can set the values instead.
  32233. */
  32234. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32235. private _forceWireframe;
  32236. /**
  32237. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32238. */
  32239. forceWireframe: boolean;
  32240. private _forcePointsCloud;
  32241. /**
  32242. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32243. */
  32244. forcePointsCloud: boolean;
  32245. /**
  32246. * Gets or sets the active clipplane 1
  32247. */
  32248. clipPlane: Nullable<Plane>;
  32249. /**
  32250. * Gets or sets the active clipplane 2
  32251. */
  32252. clipPlane2: Nullable<Plane>;
  32253. /**
  32254. * Gets or sets the active clipplane 3
  32255. */
  32256. clipPlane3: Nullable<Plane>;
  32257. /**
  32258. * Gets or sets the active clipplane 4
  32259. */
  32260. clipPlane4: Nullable<Plane>;
  32261. /**
  32262. * Gets or sets a boolean indicating if animations are enabled
  32263. */
  32264. animationsEnabled: boolean;
  32265. private _animationPropertiesOverride;
  32266. /**
  32267. * Gets or sets the animation properties override
  32268. */
  32269. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32270. /**
  32271. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32272. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32273. */
  32274. useConstantAnimationDeltaTime: boolean;
  32275. /**
  32276. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32277. * Please note that it requires to run a ray cast through the scene on every frame
  32278. */
  32279. constantlyUpdateMeshUnderPointer: boolean;
  32280. /**
  32281. * Defines the HTML cursor to use when hovering over interactive elements
  32282. */
  32283. hoverCursor: string;
  32284. /**
  32285. * Defines the HTML default cursor to use (empty by default)
  32286. */
  32287. defaultCursor: string;
  32288. /**
  32289. * This is used to call preventDefault() on pointer down
  32290. * in order to block unwanted artifacts like system double clicks
  32291. */
  32292. preventDefaultOnPointerDown: boolean;
  32293. /**
  32294. * This is used to call preventDefault() on pointer up
  32295. * in order to block unwanted artifacts like system double clicks
  32296. */
  32297. preventDefaultOnPointerUp: boolean;
  32298. /**
  32299. * Gets or sets user defined metadata
  32300. */
  32301. metadata: any;
  32302. /**
  32303. * For internal use only. Please do not use.
  32304. */
  32305. reservedDataStore: any;
  32306. /**
  32307. * Gets the name of the plugin used to load this scene (null by default)
  32308. */
  32309. loadingPluginName: string;
  32310. /**
  32311. * Use this array to add regular expressions used to disable offline support for specific urls
  32312. */
  32313. disableOfflineSupportExceptionRules: RegExp[];
  32314. /**
  32315. * An event triggered when the scene is disposed.
  32316. */
  32317. onDisposeObservable: Observable<Scene>;
  32318. private _onDisposeObserver;
  32319. /** Sets a function to be executed when this scene is disposed. */
  32320. onDispose: () => void;
  32321. /**
  32322. * An event triggered before rendering the scene (right after animations and physics)
  32323. */
  32324. onBeforeRenderObservable: Observable<Scene>;
  32325. private _onBeforeRenderObserver;
  32326. /** Sets a function to be executed before rendering this scene */
  32327. beforeRender: Nullable<() => void>;
  32328. /**
  32329. * An event triggered after rendering the scene
  32330. */
  32331. onAfterRenderObservable: Observable<Scene>;
  32332. private _onAfterRenderObserver;
  32333. /** Sets a function to be executed after rendering this scene */
  32334. afterRender: Nullable<() => void>;
  32335. /**
  32336. * An event triggered before animating the scene
  32337. */
  32338. onBeforeAnimationsObservable: Observable<Scene>;
  32339. /**
  32340. * An event triggered after animations processing
  32341. */
  32342. onAfterAnimationsObservable: Observable<Scene>;
  32343. /**
  32344. * An event triggered before draw calls are ready to be sent
  32345. */
  32346. onBeforeDrawPhaseObservable: Observable<Scene>;
  32347. /**
  32348. * An event triggered after draw calls have been sent
  32349. */
  32350. onAfterDrawPhaseObservable: Observable<Scene>;
  32351. /**
  32352. * An event triggered when the scene is ready
  32353. */
  32354. onReadyObservable: Observable<Scene>;
  32355. /**
  32356. * An event triggered before rendering a camera
  32357. */
  32358. onBeforeCameraRenderObservable: Observable<Camera>;
  32359. private _onBeforeCameraRenderObserver;
  32360. /** Sets a function to be executed before rendering a camera*/
  32361. beforeCameraRender: () => void;
  32362. /**
  32363. * An event triggered after rendering a camera
  32364. */
  32365. onAfterCameraRenderObservable: Observable<Camera>;
  32366. private _onAfterCameraRenderObserver;
  32367. /** Sets a function to be executed after rendering a camera*/
  32368. afterCameraRender: () => void;
  32369. /**
  32370. * An event triggered when active meshes evaluation is about to start
  32371. */
  32372. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32373. /**
  32374. * An event triggered when active meshes evaluation is done
  32375. */
  32376. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32377. /**
  32378. * An event triggered when particles rendering is about to start
  32379. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32380. */
  32381. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32382. /**
  32383. * An event triggered when particles rendering is done
  32384. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32385. */
  32386. onAfterParticlesRenderingObservable: Observable<Scene>;
  32387. /**
  32388. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32389. */
  32390. onDataLoadedObservable: Observable<Scene>;
  32391. /**
  32392. * An event triggered when a camera is created
  32393. */
  32394. onNewCameraAddedObservable: Observable<Camera>;
  32395. /**
  32396. * An event triggered when a camera is removed
  32397. */
  32398. onCameraRemovedObservable: Observable<Camera>;
  32399. /**
  32400. * An event triggered when a light is created
  32401. */
  32402. onNewLightAddedObservable: Observable<Light>;
  32403. /**
  32404. * An event triggered when a light is removed
  32405. */
  32406. onLightRemovedObservable: Observable<Light>;
  32407. /**
  32408. * An event triggered when a geometry is created
  32409. */
  32410. onNewGeometryAddedObservable: Observable<Geometry>;
  32411. /**
  32412. * An event triggered when a geometry is removed
  32413. */
  32414. onGeometryRemovedObservable: Observable<Geometry>;
  32415. /**
  32416. * An event triggered when a transform node is created
  32417. */
  32418. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32419. /**
  32420. * An event triggered when a transform node is removed
  32421. */
  32422. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32423. /**
  32424. * An event triggered when a mesh is created
  32425. */
  32426. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32427. /**
  32428. * An event triggered when a mesh is removed
  32429. */
  32430. onMeshRemovedObservable: Observable<AbstractMesh>;
  32431. /**
  32432. * An event triggered when a skeleton is created
  32433. */
  32434. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32435. /**
  32436. * An event triggered when a skeleton is removed
  32437. */
  32438. onSkeletonRemovedObservable: Observable<Skeleton>;
  32439. /**
  32440. * An event triggered when a material is created
  32441. */
  32442. onNewMaterialAddedObservable: Observable<Material>;
  32443. /**
  32444. * An event triggered when a material is removed
  32445. */
  32446. onMaterialRemovedObservable: Observable<Material>;
  32447. /**
  32448. * An event triggered when a texture is created
  32449. */
  32450. onNewTextureAddedObservable: Observable<BaseTexture>;
  32451. /**
  32452. * An event triggered when a texture is removed
  32453. */
  32454. onTextureRemovedObservable: Observable<BaseTexture>;
  32455. /**
  32456. * An event triggered when render targets are about to be rendered
  32457. * Can happen multiple times per frame.
  32458. */
  32459. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32460. /**
  32461. * An event triggered when render targets were rendered.
  32462. * Can happen multiple times per frame.
  32463. */
  32464. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32465. /**
  32466. * An event triggered before calculating deterministic simulation step
  32467. */
  32468. onBeforeStepObservable: Observable<Scene>;
  32469. /**
  32470. * An event triggered after calculating deterministic simulation step
  32471. */
  32472. onAfterStepObservable: Observable<Scene>;
  32473. /**
  32474. * An event triggered when the activeCamera property is updated
  32475. */
  32476. onActiveCameraChanged: Observable<Scene>;
  32477. /**
  32478. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32479. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32480. * 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)
  32481. */
  32482. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32483. /**
  32484. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32485. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32486. * 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)
  32487. */
  32488. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32489. /**
  32490. * This Observable will when a mesh has been imported into the scene.
  32491. */
  32492. onMeshImportedObservable: Observable<AbstractMesh>;
  32493. /**
  32494. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32495. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32496. */
  32497. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32498. /** @hidden */
  32499. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32500. /**
  32501. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32502. */
  32503. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32504. /**
  32505. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32506. */
  32507. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32508. /**
  32509. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32510. */
  32511. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32512. /** Callback called when a pointer move is detected */
  32513. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32514. /** Callback called when a pointer down is detected */
  32515. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32516. /** Callback called when a pointer up is detected */
  32517. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32518. /** Callback called when a pointer pick is detected */
  32519. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32520. /**
  32521. * 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).
  32522. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32523. */
  32524. onPrePointerObservable: Observable<PointerInfoPre>;
  32525. /**
  32526. * Observable event triggered each time an input event is received from the rendering canvas
  32527. */
  32528. onPointerObservable: Observable<PointerInfo>;
  32529. /**
  32530. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32531. */
  32532. readonly unTranslatedPointer: Vector2;
  32533. /**
  32534. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32535. */
  32536. static DragMovementThreshold: number;
  32537. /**
  32538. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32539. */
  32540. static LongPressDelay: number;
  32541. /**
  32542. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32543. */
  32544. static DoubleClickDelay: number;
  32545. /** If you need to check double click without raising a single click at first click, enable this flag */
  32546. static ExclusiveDoubleClickMode: boolean;
  32547. /** @hidden */
  32548. _mirroredCameraPosition: Nullable<Vector3>;
  32549. /**
  32550. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32551. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32552. */
  32553. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32554. /**
  32555. * Observable event triggered each time an keyboard event is received from the hosting window
  32556. */
  32557. onKeyboardObservable: Observable<KeyboardInfo>;
  32558. private _useRightHandedSystem;
  32559. /**
  32560. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32561. */
  32562. useRightHandedSystem: boolean;
  32563. private _timeAccumulator;
  32564. private _currentStepId;
  32565. private _currentInternalStep;
  32566. /**
  32567. * Sets the step Id used by deterministic lock step
  32568. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32569. * @param newStepId defines the step Id
  32570. */
  32571. setStepId(newStepId: number): void;
  32572. /**
  32573. * Gets the step Id used by deterministic lock step
  32574. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32575. * @returns the step Id
  32576. */
  32577. getStepId(): number;
  32578. /**
  32579. * Gets the internal step used by deterministic lock step
  32580. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32581. * @returns the internal step
  32582. */
  32583. getInternalStep(): number;
  32584. private _fogEnabled;
  32585. /**
  32586. * Gets or sets a boolean indicating if fog is enabled on this scene
  32587. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32588. * (Default is true)
  32589. */
  32590. fogEnabled: boolean;
  32591. private _fogMode;
  32592. /**
  32593. * Gets or sets the fog mode to use
  32594. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32595. * | mode | value |
  32596. * | --- | --- |
  32597. * | FOGMODE_NONE | 0 |
  32598. * | FOGMODE_EXP | 1 |
  32599. * | FOGMODE_EXP2 | 2 |
  32600. * | FOGMODE_LINEAR | 3 |
  32601. */
  32602. fogMode: number;
  32603. /**
  32604. * Gets or sets the fog color to use
  32605. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32606. * (Default is Color3(0.2, 0.2, 0.3))
  32607. */
  32608. fogColor: Color3;
  32609. /**
  32610. * Gets or sets the fog density to use
  32611. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32612. * (Default is 0.1)
  32613. */
  32614. fogDensity: number;
  32615. /**
  32616. * Gets or sets the fog start distance to use
  32617. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32618. * (Default is 0)
  32619. */
  32620. fogStart: number;
  32621. /**
  32622. * Gets or sets the fog end distance to use
  32623. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32624. * (Default is 1000)
  32625. */
  32626. fogEnd: number;
  32627. private _shadowsEnabled;
  32628. /**
  32629. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32630. */
  32631. shadowsEnabled: boolean;
  32632. private _lightsEnabled;
  32633. /**
  32634. * Gets or sets a boolean indicating if lights are enabled on this scene
  32635. */
  32636. lightsEnabled: boolean;
  32637. /** All of the active cameras added to this scene. */
  32638. activeCameras: Camera[];
  32639. /** @hidden */
  32640. _activeCamera: Nullable<Camera>;
  32641. /** Gets or sets the current active camera */
  32642. activeCamera: Nullable<Camera>;
  32643. private _defaultMaterial;
  32644. /** The default material used on meshes when no material is affected */
  32645. /** The default material used on meshes when no material is affected */
  32646. defaultMaterial: Material;
  32647. private _texturesEnabled;
  32648. /**
  32649. * Gets or sets a boolean indicating if textures are enabled on this scene
  32650. */
  32651. texturesEnabled: boolean;
  32652. /**
  32653. * Gets or sets a boolean indicating if particles are enabled on this scene
  32654. */
  32655. particlesEnabled: boolean;
  32656. /**
  32657. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32658. */
  32659. spritesEnabled: boolean;
  32660. private _skeletonsEnabled;
  32661. /**
  32662. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32663. */
  32664. skeletonsEnabled: boolean;
  32665. /**
  32666. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32667. */
  32668. lensFlaresEnabled: boolean;
  32669. /**
  32670. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32671. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32672. */
  32673. collisionsEnabled: boolean;
  32674. private _collisionCoordinator;
  32675. /** @hidden */
  32676. readonly collisionCoordinator: ICollisionCoordinator;
  32677. /**
  32678. * Defines the gravity applied to this scene (used only for collisions)
  32679. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32680. */
  32681. gravity: Vector3;
  32682. /**
  32683. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32684. */
  32685. postProcessesEnabled: boolean;
  32686. /**
  32687. * The list of postprocesses added to the scene
  32688. */
  32689. postProcesses: PostProcess[];
  32690. /**
  32691. * Gets the current postprocess manager
  32692. */
  32693. postProcessManager: PostProcessManager;
  32694. /**
  32695. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32696. */
  32697. renderTargetsEnabled: boolean;
  32698. /**
  32699. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32700. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32701. */
  32702. dumpNextRenderTargets: boolean;
  32703. /**
  32704. * The list of user defined render targets added to the scene
  32705. */
  32706. customRenderTargets: RenderTargetTexture[];
  32707. /**
  32708. * Defines if texture loading must be delayed
  32709. * If true, textures will only be loaded when they need to be rendered
  32710. */
  32711. useDelayedTextureLoading: boolean;
  32712. /**
  32713. * Gets the list of meshes imported to the scene through SceneLoader
  32714. */
  32715. importedMeshesFiles: String[];
  32716. /**
  32717. * Gets or sets a boolean indicating if probes are enabled on this scene
  32718. */
  32719. probesEnabled: boolean;
  32720. /**
  32721. * Gets or sets the current offline provider to use to store scene data
  32722. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32723. */
  32724. offlineProvider: IOfflineProvider;
  32725. /**
  32726. * Gets or sets the action manager associated with the scene
  32727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32728. */
  32729. actionManager: AbstractActionManager;
  32730. private _meshesForIntersections;
  32731. /**
  32732. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32733. */
  32734. proceduralTexturesEnabled: boolean;
  32735. private _engine;
  32736. private _totalVertices;
  32737. /** @hidden */
  32738. _activeIndices: PerfCounter;
  32739. /** @hidden */
  32740. _activeParticles: PerfCounter;
  32741. /** @hidden */
  32742. _activeBones: PerfCounter;
  32743. private _animationRatio;
  32744. /** @hidden */
  32745. _animationTimeLast: number;
  32746. /** @hidden */
  32747. _animationTime: number;
  32748. /**
  32749. * Gets or sets a general scale for animation speed
  32750. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32751. */
  32752. animationTimeScale: number;
  32753. /** @hidden */
  32754. _cachedMaterial: Nullable<Material>;
  32755. /** @hidden */
  32756. _cachedEffect: Nullable<Effect>;
  32757. /** @hidden */
  32758. _cachedVisibility: Nullable<number>;
  32759. private _renderId;
  32760. private _frameId;
  32761. private _executeWhenReadyTimeoutId;
  32762. private _intermediateRendering;
  32763. private _viewUpdateFlag;
  32764. private _projectionUpdateFlag;
  32765. /** @hidden */
  32766. _toBeDisposed: Nullable<IDisposable>[];
  32767. private _activeRequests;
  32768. /** @hidden */
  32769. _pendingData: any[];
  32770. private _isDisposed;
  32771. /**
  32772. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32773. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32774. */
  32775. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32776. private _activeMeshes;
  32777. private _processedMaterials;
  32778. private _renderTargets;
  32779. /** @hidden */
  32780. _activeParticleSystems: SmartArray<IParticleSystem>;
  32781. private _activeSkeletons;
  32782. private _softwareSkinnedMeshes;
  32783. private _renderingManager;
  32784. /** @hidden */
  32785. _activeAnimatables: Animatable[];
  32786. private _transformMatrix;
  32787. private _sceneUbo;
  32788. /** @hidden */
  32789. _viewMatrix: Matrix;
  32790. private _projectionMatrix;
  32791. /** @hidden */
  32792. _forcedViewPosition: Nullable<Vector3>;
  32793. /** @hidden */
  32794. _frustumPlanes: Plane[];
  32795. /**
  32796. * Gets the list of frustum planes (built from the active camera)
  32797. */
  32798. readonly frustumPlanes: Plane[];
  32799. /**
  32800. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32801. * This is useful if there are more lights that the maximum simulteanous authorized
  32802. */
  32803. requireLightSorting: boolean;
  32804. /** @hidden */
  32805. readonly useMaterialMeshMap: boolean;
  32806. /** @hidden */
  32807. readonly useClonedMeshhMap: boolean;
  32808. private _externalData;
  32809. private _uid;
  32810. /**
  32811. * @hidden
  32812. * Backing store of defined scene components.
  32813. */
  32814. _components: ISceneComponent[];
  32815. /**
  32816. * @hidden
  32817. * Backing store of defined scene components.
  32818. */
  32819. _serializableComponents: ISceneSerializableComponent[];
  32820. /**
  32821. * List of components to register on the next registration step.
  32822. */
  32823. private _transientComponents;
  32824. /**
  32825. * Registers the transient components if needed.
  32826. */
  32827. private _registerTransientComponents;
  32828. /**
  32829. * @hidden
  32830. * Add a component to the scene.
  32831. * Note that the ccomponent could be registered on th next frame if this is called after
  32832. * the register component stage.
  32833. * @param component Defines the component to add to the scene
  32834. */
  32835. _addComponent(component: ISceneComponent): void;
  32836. /**
  32837. * @hidden
  32838. * Gets a component from the scene.
  32839. * @param name defines the name of the component to retrieve
  32840. * @returns the component or null if not present
  32841. */
  32842. _getComponent(name: string): Nullable<ISceneComponent>;
  32843. /**
  32844. * @hidden
  32845. * Defines the actions happening before camera updates.
  32846. */
  32847. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32848. /**
  32849. * @hidden
  32850. * Defines the actions happening before clear the canvas.
  32851. */
  32852. _beforeClearStage: Stage<SimpleStageAction>;
  32853. /**
  32854. * @hidden
  32855. * Defines the actions when collecting render targets for the frame.
  32856. */
  32857. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32858. /**
  32859. * @hidden
  32860. * Defines the actions happening for one camera in the frame.
  32861. */
  32862. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32863. /**
  32864. * @hidden
  32865. * Defines the actions happening during the per mesh ready checks.
  32866. */
  32867. _isReadyForMeshStage: Stage<MeshStageAction>;
  32868. /**
  32869. * @hidden
  32870. * Defines the actions happening before evaluate active mesh checks.
  32871. */
  32872. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32873. /**
  32874. * @hidden
  32875. * Defines the actions happening during the evaluate sub mesh checks.
  32876. */
  32877. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32878. /**
  32879. * @hidden
  32880. * Defines the actions happening during the active mesh stage.
  32881. */
  32882. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32883. /**
  32884. * @hidden
  32885. * Defines the actions happening during the per camera render target step.
  32886. */
  32887. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32888. /**
  32889. * @hidden
  32890. * Defines the actions happening just before the active camera is drawing.
  32891. */
  32892. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32893. /**
  32894. * @hidden
  32895. * Defines the actions happening just before a render target is drawing.
  32896. */
  32897. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32898. /**
  32899. * @hidden
  32900. * Defines the actions happening just before a rendering group is drawing.
  32901. */
  32902. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32903. /**
  32904. * @hidden
  32905. * Defines the actions happening just before a mesh is drawing.
  32906. */
  32907. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32908. /**
  32909. * @hidden
  32910. * Defines the actions happening just after a mesh has been drawn.
  32911. */
  32912. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32913. /**
  32914. * @hidden
  32915. * Defines the actions happening just after a rendering group has been drawn.
  32916. */
  32917. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32918. /**
  32919. * @hidden
  32920. * Defines the actions happening just after the active camera has been drawn.
  32921. */
  32922. _afterCameraDrawStage: Stage<CameraStageAction>;
  32923. /**
  32924. * @hidden
  32925. * Defines the actions happening just after a render target has been drawn.
  32926. */
  32927. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32928. /**
  32929. * @hidden
  32930. * Defines the actions happening just after rendering all cameras and computing intersections.
  32931. */
  32932. _afterRenderStage: Stage<SimpleStageAction>;
  32933. /**
  32934. * @hidden
  32935. * Defines the actions happening when a pointer move event happens.
  32936. */
  32937. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32938. /**
  32939. * @hidden
  32940. * Defines the actions happening when a pointer down event happens.
  32941. */
  32942. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32943. /**
  32944. * @hidden
  32945. * Defines the actions happening when a pointer up event happens.
  32946. */
  32947. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32948. /**
  32949. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32950. */
  32951. private geometriesByUniqueId;
  32952. /**
  32953. * Creates a new Scene
  32954. * @param engine defines the engine to use to render this scene
  32955. * @param options defines the scene options
  32956. */
  32957. constructor(engine: Engine, options?: SceneOptions);
  32958. /**
  32959. * Gets a string idenfifying the name of the class
  32960. * @returns "Scene" string
  32961. */
  32962. getClassName(): string;
  32963. private _defaultMeshCandidates;
  32964. /**
  32965. * @hidden
  32966. */
  32967. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32968. private _defaultSubMeshCandidates;
  32969. /**
  32970. * @hidden
  32971. */
  32972. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32973. /**
  32974. * Sets the default candidate providers for the scene.
  32975. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32976. * and getCollidingSubMeshCandidates to their default function
  32977. */
  32978. setDefaultCandidateProviders(): void;
  32979. /**
  32980. * Gets the mesh that is currently under the pointer
  32981. */
  32982. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32983. /**
  32984. * Gets or sets the current on-screen X position of the pointer
  32985. */
  32986. pointerX: number;
  32987. /**
  32988. * Gets or sets the current on-screen Y position of the pointer
  32989. */
  32990. pointerY: number;
  32991. /**
  32992. * Gets the cached material (ie. the latest rendered one)
  32993. * @returns the cached material
  32994. */
  32995. getCachedMaterial(): Nullable<Material>;
  32996. /**
  32997. * Gets the cached effect (ie. the latest rendered one)
  32998. * @returns the cached effect
  32999. */
  33000. getCachedEffect(): Nullable<Effect>;
  33001. /**
  33002. * Gets the cached visibility state (ie. the latest rendered one)
  33003. * @returns the cached visibility state
  33004. */
  33005. getCachedVisibility(): Nullable<number>;
  33006. /**
  33007. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33008. * @param material defines the current material
  33009. * @param effect defines the current effect
  33010. * @param visibility defines the current visibility state
  33011. * @returns true if one parameter is not cached
  33012. */
  33013. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33014. /**
  33015. * Gets the engine associated with the scene
  33016. * @returns an Engine
  33017. */
  33018. getEngine(): Engine;
  33019. /**
  33020. * Gets the total number of vertices rendered per frame
  33021. * @returns the total number of vertices rendered per frame
  33022. */
  33023. getTotalVertices(): number;
  33024. /**
  33025. * Gets the performance counter for total vertices
  33026. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33027. */
  33028. readonly totalVerticesPerfCounter: PerfCounter;
  33029. /**
  33030. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33031. * @returns the total number of active indices rendered per frame
  33032. */
  33033. getActiveIndices(): number;
  33034. /**
  33035. * Gets the performance counter for active indices
  33036. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33037. */
  33038. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33039. /**
  33040. * Gets the total number of active particles rendered per frame
  33041. * @returns the total number of active particles rendered per frame
  33042. */
  33043. getActiveParticles(): number;
  33044. /**
  33045. * Gets the performance counter for active particles
  33046. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33047. */
  33048. readonly activeParticlesPerfCounter: PerfCounter;
  33049. /**
  33050. * Gets the total number of active bones rendered per frame
  33051. * @returns the total number of active bones rendered per frame
  33052. */
  33053. getActiveBones(): number;
  33054. /**
  33055. * Gets the performance counter for active bones
  33056. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33057. */
  33058. readonly activeBonesPerfCounter: PerfCounter;
  33059. /**
  33060. * Gets the array of active meshes
  33061. * @returns an array of AbstractMesh
  33062. */
  33063. getActiveMeshes(): SmartArray<AbstractMesh>;
  33064. /**
  33065. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33066. * @returns a number
  33067. */
  33068. getAnimationRatio(): number;
  33069. /**
  33070. * Gets an unique Id for the current render phase
  33071. * @returns a number
  33072. */
  33073. getRenderId(): number;
  33074. /**
  33075. * Gets an unique Id for the current frame
  33076. * @returns a number
  33077. */
  33078. getFrameId(): number;
  33079. /** Call this function if you want to manually increment the render Id*/
  33080. incrementRenderId(): void;
  33081. private _createUbo;
  33082. /**
  33083. * Use this method to simulate a pointer move on a mesh
  33084. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33085. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33086. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33087. * @returns the current scene
  33088. */
  33089. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33090. /**
  33091. * Use this method to simulate a pointer down on a mesh
  33092. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33093. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33094. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33095. * @returns the current scene
  33096. */
  33097. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33098. /**
  33099. * Use this method to simulate a pointer up on a mesh
  33100. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33101. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33102. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33103. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33104. * @returns the current scene
  33105. */
  33106. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33107. /**
  33108. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33109. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33110. * @returns true if the pointer was captured
  33111. */
  33112. isPointerCaptured(pointerId?: number): boolean;
  33113. /**
  33114. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33115. * @param attachUp defines if you want to attach events to pointerup
  33116. * @param attachDown defines if you want to attach events to pointerdown
  33117. * @param attachMove defines if you want to attach events to pointermove
  33118. */
  33119. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33120. /** Detaches all event handlers*/
  33121. detachControl(): void;
  33122. /**
  33123. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33124. * Delay loaded resources are not taking in account
  33125. * @return true if all required resources are ready
  33126. */
  33127. isReady(): boolean;
  33128. /** Resets all cached information relative to material (including effect and visibility) */
  33129. resetCachedMaterial(): void;
  33130. /**
  33131. * Registers a function to be called before every frame render
  33132. * @param func defines the function to register
  33133. */
  33134. registerBeforeRender(func: () => void): void;
  33135. /**
  33136. * Unregisters a function called before every frame render
  33137. * @param func defines the function to unregister
  33138. */
  33139. unregisterBeforeRender(func: () => void): void;
  33140. /**
  33141. * Registers a function to be called after every frame render
  33142. * @param func defines the function to register
  33143. */
  33144. registerAfterRender(func: () => void): void;
  33145. /**
  33146. * Unregisters a function called after every frame render
  33147. * @param func defines the function to unregister
  33148. */
  33149. unregisterAfterRender(func: () => void): void;
  33150. private _executeOnceBeforeRender;
  33151. /**
  33152. * The provided function will run before render once and will be disposed afterwards.
  33153. * A timeout delay can be provided so that the function will be executed in N ms.
  33154. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33155. * @param func The function to be executed.
  33156. * @param timeout optional delay in ms
  33157. */
  33158. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33159. /** @hidden */
  33160. _addPendingData(data: any): void;
  33161. /** @hidden */
  33162. _removePendingData(data: any): void;
  33163. /**
  33164. * Returns the number of items waiting to be loaded
  33165. * @returns the number of items waiting to be loaded
  33166. */
  33167. getWaitingItemsCount(): number;
  33168. /**
  33169. * Returns a boolean indicating if the scene is still loading data
  33170. */
  33171. readonly isLoading: boolean;
  33172. /**
  33173. * Registers a function to be executed when the scene is ready
  33174. * @param {Function} func - the function to be executed
  33175. */
  33176. executeWhenReady(func: () => void): void;
  33177. /**
  33178. * Returns a promise that resolves when the scene is ready
  33179. * @returns A promise that resolves when the scene is ready
  33180. */
  33181. whenReadyAsync(): Promise<void>;
  33182. /** @hidden */
  33183. _checkIsReady(): void;
  33184. /**
  33185. * Gets all animatable attached to the scene
  33186. */
  33187. readonly animatables: Animatable[];
  33188. /**
  33189. * Resets the last animation time frame.
  33190. * Useful to override when animations start running when loading a scene for the first time.
  33191. */
  33192. resetLastAnimationTimeFrame(): void;
  33193. /**
  33194. * Gets the current view matrix
  33195. * @returns a Matrix
  33196. */
  33197. getViewMatrix(): Matrix;
  33198. /**
  33199. * Gets the current projection matrix
  33200. * @returns a Matrix
  33201. */
  33202. getProjectionMatrix(): Matrix;
  33203. /**
  33204. * Gets the current transform matrix
  33205. * @returns a Matrix made of View * Projection
  33206. */
  33207. getTransformMatrix(): Matrix;
  33208. /**
  33209. * Sets the current transform matrix
  33210. * @param viewL defines the View matrix to use
  33211. * @param projectionL defines the Projection matrix to use
  33212. * @param viewR defines the right View matrix to use (if provided)
  33213. * @param projectionR defines the right Projection matrix to use (if provided)
  33214. */
  33215. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33216. /**
  33217. * Gets the uniform buffer used to store scene data
  33218. * @returns a UniformBuffer
  33219. */
  33220. getSceneUniformBuffer(): UniformBuffer;
  33221. /**
  33222. * Gets an unique (relatively to the current scene) Id
  33223. * @returns an unique number for the scene
  33224. */
  33225. getUniqueId(): number;
  33226. /**
  33227. * Add a mesh to the list of scene's meshes
  33228. * @param newMesh defines the mesh to add
  33229. * @param recursive if all child meshes should also be added to the scene
  33230. */
  33231. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33232. /**
  33233. * Remove a mesh for the list of scene's meshes
  33234. * @param toRemove defines the mesh to remove
  33235. * @param recursive if all child meshes should also be removed from the scene
  33236. * @returns the index where the mesh was in the mesh list
  33237. */
  33238. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33239. /**
  33240. * Add a transform node to the list of scene's transform nodes
  33241. * @param newTransformNode defines the transform node to add
  33242. */
  33243. addTransformNode(newTransformNode: TransformNode): void;
  33244. /**
  33245. * Remove a transform node for the list of scene's transform nodes
  33246. * @param toRemove defines the transform node to remove
  33247. * @returns the index where the transform node was in the transform node list
  33248. */
  33249. removeTransformNode(toRemove: TransformNode): number;
  33250. /**
  33251. * Remove a skeleton for the list of scene's skeletons
  33252. * @param toRemove defines the skeleton to remove
  33253. * @returns the index where the skeleton was in the skeleton list
  33254. */
  33255. removeSkeleton(toRemove: Skeleton): number;
  33256. /**
  33257. * Remove a morph target for the list of scene's morph targets
  33258. * @param toRemove defines the morph target to remove
  33259. * @returns the index where the morph target was in the morph target list
  33260. */
  33261. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33262. /**
  33263. * Remove a light for the list of scene's lights
  33264. * @param toRemove defines the light to remove
  33265. * @returns the index where the light was in the light list
  33266. */
  33267. removeLight(toRemove: Light): number;
  33268. /**
  33269. * Remove a camera for the list of scene's cameras
  33270. * @param toRemove defines the camera to remove
  33271. * @returns the index where the camera was in the camera list
  33272. */
  33273. removeCamera(toRemove: Camera): number;
  33274. /**
  33275. * Remove a particle system for the list of scene's particle systems
  33276. * @param toRemove defines the particle system to remove
  33277. * @returns the index where the particle system was in the particle system list
  33278. */
  33279. removeParticleSystem(toRemove: IParticleSystem): number;
  33280. /**
  33281. * Remove a animation for the list of scene's animations
  33282. * @param toRemove defines the animation to remove
  33283. * @returns the index where the animation was in the animation list
  33284. */
  33285. removeAnimation(toRemove: Animation): number;
  33286. /**
  33287. * Will stop the animation of the given target
  33288. * @param target - the target
  33289. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33290. * @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)
  33291. */
  33292. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33293. /**
  33294. * Removes the given animation group from this scene.
  33295. * @param toRemove The animation group to remove
  33296. * @returns The index of the removed animation group
  33297. */
  33298. removeAnimationGroup(toRemove: AnimationGroup): number;
  33299. /**
  33300. * Removes the given multi-material from this scene.
  33301. * @param toRemove The multi-material to remove
  33302. * @returns The index of the removed multi-material
  33303. */
  33304. removeMultiMaterial(toRemove: MultiMaterial): number;
  33305. /**
  33306. * Removes the given material from this scene.
  33307. * @param toRemove The material to remove
  33308. * @returns The index of the removed material
  33309. */
  33310. removeMaterial(toRemove: Material): number;
  33311. /**
  33312. * Removes the given action manager from this scene.
  33313. * @param toRemove The action manager to remove
  33314. * @returns The index of the removed action manager
  33315. */
  33316. removeActionManager(toRemove: AbstractActionManager): number;
  33317. /**
  33318. * Removes the given texture from this scene.
  33319. * @param toRemove The texture to remove
  33320. * @returns The index of the removed texture
  33321. */
  33322. removeTexture(toRemove: BaseTexture): number;
  33323. /**
  33324. * Adds the given light to this scene
  33325. * @param newLight The light to add
  33326. */
  33327. addLight(newLight: Light): void;
  33328. /**
  33329. * Sorts the list list based on light priorities
  33330. */
  33331. sortLightsByPriority(): void;
  33332. /**
  33333. * Adds the given camera to this scene
  33334. * @param newCamera The camera to add
  33335. */
  33336. addCamera(newCamera: Camera): void;
  33337. /**
  33338. * Adds the given skeleton to this scene
  33339. * @param newSkeleton The skeleton to add
  33340. */
  33341. addSkeleton(newSkeleton: Skeleton): void;
  33342. /**
  33343. * Adds the given particle system to this scene
  33344. * @param newParticleSystem The particle system to add
  33345. */
  33346. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33347. /**
  33348. * Adds the given animation to this scene
  33349. * @param newAnimation The animation to add
  33350. */
  33351. addAnimation(newAnimation: Animation): void;
  33352. /**
  33353. * Adds the given animation group to this scene.
  33354. * @param newAnimationGroup The animation group to add
  33355. */
  33356. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33357. /**
  33358. * Adds the given multi-material to this scene
  33359. * @param newMultiMaterial The multi-material to add
  33360. */
  33361. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33362. /**
  33363. * Adds the given material to this scene
  33364. * @param newMaterial The material to add
  33365. */
  33366. addMaterial(newMaterial: Material): void;
  33367. /**
  33368. * Adds the given morph target to this scene
  33369. * @param newMorphTargetManager The morph target to add
  33370. */
  33371. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33372. /**
  33373. * Adds the given geometry to this scene
  33374. * @param newGeometry The geometry to add
  33375. */
  33376. addGeometry(newGeometry: Geometry): void;
  33377. /**
  33378. * Adds the given action manager to this scene
  33379. * @param newActionManager The action manager to add
  33380. */
  33381. addActionManager(newActionManager: AbstractActionManager): void;
  33382. /**
  33383. * Adds the given texture to this scene.
  33384. * @param newTexture The texture to add
  33385. */
  33386. addTexture(newTexture: BaseTexture): void;
  33387. /**
  33388. * Switch active camera
  33389. * @param newCamera defines the new active camera
  33390. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33391. */
  33392. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33393. /**
  33394. * sets the active camera of the scene using its ID
  33395. * @param id defines the camera's ID
  33396. * @return the new active camera or null if none found.
  33397. */
  33398. setActiveCameraByID(id: string): Nullable<Camera>;
  33399. /**
  33400. * sets the active camera of the scene using its name
  33401. * @param name defines the camera's name
  33402. * @returns the new active camera or null if none found.
  33403. */
  33404. setActiveCameraByName(name: string): Nullable<Camera>;
  33405. /**
  33406. * get an animation group using its name
  33407. * @param name defines the material's name
  33408. * @return the animation group or null if none found.
  33409. */
  33410. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33411. /**
  33412. * Get a material using its unique id
  33413. * @param uniqueId defines the material's unique id
  33414. * @return the material or null if none found.
  33415. */
  33416. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33417. /**
  33418. * get a material using its id
  33419. * @param id defines the material's ID
  33420. * @return the material or null if none found.
  33421. */
  33422. getMaterialByID(id: string): Nullable<Material>;
  33423. /**
  33424. * Gets a material using its name
  33425. * @param name defines the material's name
  33426. * @return the material or null if none found.
  33427. */
  33428. getMaterialByName(name: string): Nullable<Material>;
  33429. /**
  33430. * Gets a camera using its id
  33431. * @param id defines the id to look for
  33432. * @returns the camera or null if not found
  33433. */
  33434. getCameraByID(id: string): Nullable<Camera>;
  33435. /**
  33436. * Gets a camera using its unique id
  33437. * @param uniqueId defines the unique id to look for
  33438. * @returns the camera or null if not found
  33439. */
  33440. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33441. /**
  33442. * Gets a camera using its name
  33443. * @param name defines the camera's name
  33444. * @return the camera or null if none found.
  33445. */
  33446. getCameraByName(name: string): Nullable<Camera>;
  33447. /**
  33448. * Gets a bone using its id
  33449. * @param id defines the bone's id
  33450. * @return the bone or null if not found
  33451. */
  33452. getBoneByID(id: string): Nullable<Bone>;
  33453. /**
  33454. * Gets a bone using its id
  33455. * @param name defines the bone's name
  33456. * @return the bone or null if not found
  33457. */
  33458. getBoneByName(name: string): Nullable<Bone>;
  33459. /**
  33460. * Gets a light node using its name
  33461. * @param name defines the the light's name
  33462. * @return the light or null if none found.
  33463. */
  33464. getLightByName(name: string): Nullable<Light>;
  33465. /**
  33466. * Gets a light node using its id
  33467. * @param id defines the light's id
  33468. * @return the light or null if none found.
  33469. */
  33470. getLightByID(id: string): Nullable<Light>;
  33471. /**
  33472. * Gets a light node using its scene-generated unique ID
  33473. * @param uniqueId defines the light's unique id
  33474. * @return the light or null if none found.
  33475. */
  33476. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33477. /**
  33478. * Gets a particle system by id
  33479. * @param id defines the particle system id
  33480. * @return the corresponding system or null if none found
  33481. */
  33482. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33483. /**
  33484. * Gets a geometry using its ID
  33485. * @param id defines the geometry's id
  33486. * @return the geometry or null if none found.
  33487. */
  33488. getGeometryByID(id: string): Nullable<Geometry>;
  33489. private _getGeometryByUniqueID;
  33490. /**
  33491. * Add a new geometry to this scene
  33492. * @param geometry defines the geometry to be added to the scene.
  33493. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33494. * @return a boolean defining if the geometry was added or not
  33495. */
  33496. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33497. /**
  33498. * Removes an existing geometry
  33499. * @param geometry defines the geometry to be removed from the scene
  33500. * @return a boolean defining if the geometry was removed or not
  33501. */
  33502. removeGeometry(geometry: Geometry): boolean;
  33503. /**
  33504. * Gets the list of geometries attached to the scene
  33505. * @returns an array of Geometry
  33506. */
  33507. getGeometries(): Geometry[];
  33508. /**
  33509. * Gets the first added mesh found of a given ID
  33510. * @param id defines the id to search for
  33511. * @return the mesh found or null if not found at all
  33512. */
  33513. getMeshByID(id: string): Nullable<AbstractMesh>;
  33514. /**
  33515. * Gets a list of meshes using their id
  33516. * @param id defines the id to search for
  33517. * @returns a list of meshes
  33518. */
  33519. getMeshesByID(id: string): Array<AbstractMesh>;
  33520. /**
  33521. * Gets the first added transform node found of a given ID
  33522. * @param id defines the id to search for
  33523. * @return the found transform node or null if not found at all.
  33524. */
  33525. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33526. /**
  33527. * Gets a transform node with its auto-generated unique id
  33528. * @param uniqueId efines the unique id to search for
  33529. * @return the found transform node or null if not found at all.
  33530. */
  33531. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33532. /**
  33533. * Gets a list of transform nodes using their id
  33534. * @param id defines the id to search for
  33535. * @returns a list of transform nodes
  33536. */
  33537. getTransformNodesByID(id: string): Array<TransformNode>;
  33538. /**
  33539. * Gets a mesh with its auto-generated unique id
  33540. * @param uniqueId defines the unique id to search for
  33541. * @return the found mesh or null if not found at all.
  33542. */
  33543. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33544. /**
  33545. * Gets a the last added mesh using a given id
  33546. * @param id defines the id to search for
  33547. * @return the found mesh or null if not found at all.
  33548. */
  33549. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33550. /**
  33551. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33552. * @param id defines the id to search for
  33553. * @return the found node or null if not found at all
  33554. */
  33555. getLastEntryByID(id: string): Nullable<Node>;
  33556. /**
  33557. * Gets a node (Mesh, Camera, Light) using a given id
  33558. * @param id defines the id to search for
  33559. * @return the found node or null if not found at all
  33560. */
  33561. getNodeByID(id: string): Nullable<Node>;
  33562. /**
  33563. * Gets a node (Mesh, Camera, Light) using a given name
  33564. * @param name defines the name to search for
  33565. * @return the found node or null if not found at all.
  33566. */
  33567. getNodeByName(name: string): Nullable<Node>;
  33568. /**
  33569. * Gets a mesh using a given name
  33570. * @param name defines the name to search for
  33571. * @return the found mesh or null if not found at all.
  33572. */
  33573. getMeshByName(name: string): Nullable<AbstractMesh>;
  33574. /**
  33575. * Gets a transform node using a given name
  33576. * @param name defines the name to search for
  33577. * @return the found transform node or null if not found at all.
  33578. */
  33579. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33580. /**
  33581. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33582. * @param id defines the id to search for
  33583. * @return the found skeleton or null if not found at all.
  33584. */
  33585. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33586. /**
  33587. * Gets a skeleton using a given auto generated unique id
  33588. * @param uniqueId defines the unique id to search for
  33589. * @return the found skeleton or null if not found at all.
  33590. */
  33591. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33592. /**
  33593. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33594. * @param id defines the id to search for
  33595. * @return the found skeleton or null if not found at all.
  33596. */
  33597. getSkeletonById(id: string): Nullable<Skeleton>;
  33598. /**
  33599. * Gets a skeleton using a given name
  33600. * @param name defines the name to search for
  33601. * @return the found skeleton or null if not found at all.
  33602. */
  33603. getSkeletonByName(name: string): Nullable<Skeleton>;
  33604. /**
  33605. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33606. * @param id defines the id to search for
  33607. * @return the found morph target manager or null if not found at all.
  33608. */
  33609. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33610. /**
  33611. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33612. * @param id defines the id to search for
  33613. * @return the found morph target or null if not found at all.
  33614. */
  33615. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33616. /**
  33617. * Gets a boolean indicating if the given mesh is active
  33618. * @param mesh defines the mesh to look for
  33619. * @returns true if the mesh is in the active list
  33620. */
  33621. isActiveMesh(mesh: AbstractMesh): boolean;
  33622. /**
  33623. * Return a unique id as a string which can serve as an identifier for the scene
  33624. */
  33625. readonly uid: string;
  33626. /**
  33627. * Add an externaly attached data from its key.
  33628. * This method call will fail and return false, if such key already exists.
  33629. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33630. * @param key the unique key that identifies the data
  33631. * @param data the data object to associate to the key for this Engine instance
  33632. * @return true if no such key were already present and the data was added successfully, false otherwise
  33633. */
  33634. addExternalData<T>(key: string, data: T): boolean;
  33635. /**
  33636. * Get an externaly attached data from its key
  33637. * @param key the unique key that identifies the data
  33638. * @return the associated data, if present (can be null), or undefined if not present
  33639. */
  33640. getExternalData<T>(key: string): Nullable<T>;
  33641. /**
  33642. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33643. * @param key the unique key that identifies the data
  33644. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33645. * @return the associated data, can be null if the factory returned null.
  33646. */
  33647. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33648. /**
  33649. * Remove an externaly attached data from the Engine instance
  33650. * @param key the unique key that identifies the data
  33651. * @return true if the data was successfully removed, false if it doesn't exist
  33652. */
  33653. removeExternalData(key: string): boolean;
  33654. private _evaluateSubMesh;
  33655. /**
  33656. * Clear the processed materials smart array preventing retention point in material dispose.
  33657. */
  33658. freeProcessedMaterials(): void;
  33659. private _preventFreeActiveMeshesAndRenderingGroups;
  33660. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33661. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33662. * when disposing several meshes in a row or a hierarchy of meshes.
  33663. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33664. */
  33665. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33666. /**
  33667. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33668. */
  33669. freeActiveMeshes(): void;
  33670. /**
  33671. * Clear the info related to rendering groups preventing retention points during dispose.
  33672. */
  33673. freeRenderingGroups(): void;
  33674. /** @hidden */
  33675. _isInIntermediateRendering(): boolean;
  33676. /**
  33677. * Lambda returning the list of potentially active meshes.
  33678. */
  33679. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33680. /**
  33681. * Lambda returning the list of potentially active sub meshes.
  33682. */
  33683. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33684. /**
  33685. * Lambda returning the list of potentially intersecting sub meshes.
  33686. */
  33687. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33688. /**
  33689. * Lambda returning the list of potentially colliding sub meshes.
  33690. */
  33691. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33692. private _activeMeshesFrozen;
  33693. /**
  33694. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33695. * @returns the current scene
  33696. */
  33697. freezeActiveMeshes(): Scene;
  33698. /**
  33699. * Use this function to restart evaluating active meshes on every frame
  33700. * @returns the current scene
  33701. */
  33702. unfreezeActiveMeshes(): Scene;
  33703. private _evaluateActiveMeshes;
  33704. private _activeMesh;
  33705. /**
  33706. * Update the transform matrix to update from the current active camera
  33707. * @param force defines a boolean used to force the update even if cache is up to date
  33708. */
  33709. updateTransformMatrix(force?: boolean): void;
  33710. private _bindFrameBuffer;
  33711. /** @hidden */
  33712. _allowPostProcessClearColor: boolean;
  33713. /** @hidden */
  33714. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33715. private _processSubCameras;
  33716. private _checkIntersections;
  33717. /** @hidden */
  33718. _advancePhysicsEngineStep(step: number): void;
  33719. /**
  33720. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33721. */
  33722. getDeterministicFrameTime: () => number;
  33723. /** @hidden */
  33724. _animate(): void;
  33725. /** Execute all animations (for a frame) */
  33726. animate(): void;
  33727. /**
  33728. * Render the scene
  33729. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33730. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33731. */
  33732. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33733. /**
  33734. * Freeze all materials
  33735. * A frozen material will not be updatable but should be faster to render
  33736. */
  33737. freezeMaterials(): void;
  33738. /**
  33739. * Unfreeze all materials
  33740. * A frozen material will not be updatable but should be faster to render
  33741. */
  33742. unfreezeMaterials(): void;
  33743. /**
  33744. * Releases all held ressources
  33745. */
  33746. dispose(): void;
  33747. /**
  33748. * Gets if the scene is already disposed
  33749. */
  33750. readonly isDisposed: boolean;
  33751. /**
  33752. * Call this function to reduce memory footprint of the scene.
  33753. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33754. */
  33755. clearCachedVertexData(): void;
  33756. /**
  33757. * This function will remove the local cached buffer data from texture.
  33758. * It will save memory but will prevent the texture from being rebuilt
  33759. */
  33760. cleanCachedTextureBuffer(): void;
  33761. /**
  33762. * Get the world extend vectors with an optional filter
  33763. *
  33764. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33765. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33766. */
  33767. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33768. min: Vector3;
  33769. max: Vector3;
  33770. };
  33771. /**
  33772. * Creates a ray that can be used to pick in the scene
  33773. * @param x defines the x coordinate of the origin (on-screen)
  33774. * @param y defines the y coordinate of the origin (on-screen)
  33775. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33776. * @param camera defines the camera to use for the picking
  33777. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33778. * @returns a Ray
  33779. */
  33780. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33781. /**
  33782. * Creates a ray that can be used to pick in the scene
  33783. * @param x defines the x coordinate of the origin (on-screen)
  33784. * @param y defines the y coordinate of the origin (on-screen)
  33785. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33786. * @param result defines the ray where to store the picking ray
  33787. * @param camera defines the camera to use for the picking
  33788. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33789. * @returns the current scene
  33790. */
  33791. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33792. /**
  33793. * Creates a ray that can be used to pick in the scene
  33794. * @param x defines the x coordinate of the origin (on-screen)
  33795. * @param y defines the y coordinate of the origin (on-screen)
  33796. * @param camera defines the camera to use for the picking
  33797. * @returns a Ray
  33798. */
  33799. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33800. /**
  33801. * Creates a ray that can be used to pick in the scene
  33802. * @param x defines the x coordinate of the origin (on-screen)
  33803. * @param y defines the y coordinate of the origin (on-screen)
  33804. * @param result defines the ray where to store the picking ray
  33805. * @param camera defines the camera to use for the picking
  33806. * @returns the current scene
  33807. */
  33808. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33809. /** Launch a ray to try to pick a mesh in the scene
  33810. * @param x position on screen
  33811. * @param y position on screen
  33812. * @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
  33813. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33814. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33815. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33816. * @returns a PickingInfo
  33817. */
  33818. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33819. /** Use the given ray to pick a mesh in the scene
  33820. * @param ray The ray to use to pick meshes
  33821. * @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
  33822. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33823. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33824. * @returns a PickingInfo
  33825. */
  33826. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33827. /**
  33828. * Launch a ray to try to pick a mesh in the scene
  33829. * @param x X position on screen
  33830. * @param y Y position on screen
  33831. * @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
  33832. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33833. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33834. * @returns an array of PickingInfo
  33835. */
  33836. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33837. /**
  33838. * Launch a ray to try to pick a mesh in the scene
  33839. * @param ray Ray to use
  33840. * @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
  33841. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33842. * @returns an array of PickingInfo
  33843. */
  33844. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33845. /**
  33846. * Force the value of meshUnderPointer
  33847. * @param mesh defines the mesh to use
  33848. */
  33849. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33850. /**
  33851. * Gets the mesh under the pointer
  33852. * @returns a Mesh or null if no mesh is under the pointer
  33853. */
  33854. getPointerOverMesh(): Nullable<AbstractMesh>;
  33855. /** @hidden */
  33856. _rebuildGeometries(): void;
  33857. /** @hidden */
  33858. _rebuildTextures(): void;
  33859. private _getByTags;
  33860. /**
  33861. * Get a list of meshes by tags
  33862. * @param tagsQuery defines the tags query to use
  33863. * @param forEach defines a predicate used to filter results
  33864. * @returns an array of Mesh
  33865. */
  33866. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33867. /**
  33868. * Get a list of cameras by tags
  33869. * @param tagsQuery defines the tags query to use
  33870. * @param forEach defines a predicate used to filter results
  33871. * @returns an array of Camera
  33872. */
  33873. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33874. /**
  33875. * Get a list of lights by tags
  33876. * @param tagsQuery defines the tags query to use
  33877. * @param forEach defines a predicate used to filter results
  33878. * @returns an array of Light
  33879. */
  33880. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33881. /**
  33882. * Get a list of materials by tags
  33883. * @param tagsQuery defines the tags query to use
  33884. * @param forEach defines a predicate used to filter results
  33885. * @returns an array of Material
  33886. */
  33887. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33888. /**
  33889. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33890. * This allowed control for front to back rendering or reversly depending of the special needs.
  33891. *
  33892. * @param renderingGroupId The rendering group id corresponding to its index
  33893. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33894. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33895. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33896. */
  33897. 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;
  33898. /**
  33899. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33900. *
  33901. * @param renderingGroupId The rendering group id corresponding to its index
  33902. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33903. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33904. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33905. */
  33906. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33907. /**
  33908. * Gets the current auto clear configuration for one rendering group of the rendering
  33909. * manager.
  33910. * @param index the rendering group index to get the information for
  33911. * @returns The auto clear setup for the requested rendering group
  33912. */
  33913. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33914. private _blockMaterialDirtyMechanism;
  33915. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33916. blockMaterialDirtyMechanism: boolean;
  33917. /**
  33918. * Will flag all materials as dirty to trigger new shader compilation
  33919. * @param flag defines the flag used to specify which material part must be marked as dirty
  33920. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33921. */
  33922. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33923. /** @hidden */
  33924. _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;
  33925. /** @hidden */
  33926. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33927. }
  33928. }
  33929. declare module BABYLON {
  33930. /**
  33931. * Set of assets to keep when moving a scene into an asset container.
  33932. */
  33933. export class KeepAssets extends AbstractScene {
  33934. }
  33935. /**
  33936. * Container with a set of assets that can be added or removed from a scene.
  33937. */
  33938. export class AssetContainer extends AbstractScene {
  33939. /**
  33940. * The scene the AssetContainer belongs to.
  33941. */
  33942. scene: Scene;
  33943. /**
  33944. * Instantiates an AssetContainer.
  33945. * @param scene The scene the AssetContainer belongs to.
  33946. */
  33947. constructor(scene: Scene);
  33948. /**
  33949. * Adds all the assets from the container to the scene.
  33950. */
  33951. addAllToScene(): void;
  33952. /**
  33953. * Removes all the assets in the container from the scene
  33954. */
  33955. removeAllFromScene(): void;
  33956. /**
  33957. * Disposes all the assets in the container
  33958. */
  33959. dispose(): void;
  33960. private _moveAssets;
  33961. /**
  33962. * Removes all the assets contained in the scene and adds them to the container.
  33963. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33964. */
  33965. moveAllFromScene(keepAssets?: KeepAssets): void;
  33966. /**
  33967. * 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.
  33968. * @returns the root mesh
  33969. */
  33970. createRootMesh(): Mesh;
  33971. }
  33972. }
  33973. declare module BABYLON {
  33974. /**
  33975. * Defines how the parser contract is defined.
  33976. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33977. */
  33978. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33979. /**
  33980. * Defines how the individual parser contract is defined.
  33981. * These parser can parse an individual asset
  33982. */
  33983. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33984. /**
  33985. * Base class of the scene acting as a container for the different elements composing a scene.
  33986. * This class is dynamically extended by the different components of the scene increasing
  33987. * flexibility and reducing coupling
  33988. */
  33989. export abstract class AbstractScene {
  33990. /**
  33991. * Stores the list of available parsers in the application.
  33992. */
  33993. private static _BabylonFileParsers;
  33994. /**
  33995. * Stores the list of available individual parsers in the application.
  33996. */
  33997. private static _IndividualBabylonFileParsers;
  33998. /**
  33999. * Adds a parser in the list of available ones
  34000. * @param name Defines the name of the parser
  34001. * @param parser Defines the parser to add
  34002. */
  34003. static AddParser(name: string, parser: BabylonFileParser): void;
  34004. /**
  34005. * Gets a general parser from the list of avaialble ones
  34006. * @param name Defines the name of the parser
  34007. * @returns the requested parser or null
  34008. */
  34009. static GetParser(name: string): Nullable<BabylonFileParser>;
  34010. /**
  34011. * Adds n individual parser in the list of available ones
  34012. * @param name Defines the name of the parser
  34013. * @param parser Defines the parser to add
  34014. */
  34015. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34016. /**
  34017. * Gets an individual parser from the list of avaialble ones
  34018. * @param name Defines the name of the parser
  34019. * @returns the requested parser or null
  34020. */
  34021. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34022. /**
  34023. * Parser json data and populate both a scene and its associated container object
  34024. * @param jsonData Defines the data to parse
  34025. * @param scene Defines the scene to parse the data for
  34026. * @param container Defines the container attached to the parsing sequence
  34027. * @param rootUrl Defines the root url of the data
  34028. */
  34029. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34030. /**
  34031. * Gets the list of root nodes (ie. nodes with no parent)
  34032. */
  34033. rootNodes: Node[];
  34034. /** All of the cameras added to this scene
  34035. * @see http://doc.babylonjs.com/babylon101/cameras
  34036. */
  34037. cameras: Camera[];
  34038. /**
  34039. * All of the lights added to this scene
  34040. * @see http://doc.babylonjs.com/babylon101/lights
  34041. */
  34042. lights: Light[];
  34043. /**
  34044. * All of the (abstract) meshes added to this scene
  34045. */
  34046. meshes: AbstractMesh[];
  34047. /**
  34048. * The list of skeletons added to the scene
  34049. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34050. */
  34051. skeletons: Skeleton[];
  34052. /**
  34053. * All of the particle systems added to this scene
  34054. * @see http://doc.babylonjs.com/babylon101/particles
  34055. */
  34056. particleSystems: IParticleSystem[];
  34057. /**
  34058. * Gets a list of Animations associated with the scene
  34059. */
  34060. animations: Animation[];
  34061. /**
  34062. * All of the animation groups added to this scene
  34063. * @see http://doc.babylonjs.com/how_to/group
  34064. */
  34065. animationGroups: AnimationGroup[];
  34066. /**
  34067. * All of the multi-materials added to this scene
  34068. * @see http://doc.babylonjs.com/how_to/multi_materials
  34069. */
  34070. multiMaterials: MultiMaterial[];
  34071. /**
  34072. * All of the materials added to this scene
  34073. * In the context of a Scene, it is not supposed to be modified manually.
  34074. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34075. * Note also that the order of the Material wihin the array is not significant and might change.
  34076. * @see http://doc.babylonjs.com/babylon101/materials
  34077. */
  34078. materials: Material[];
  34079. /**
  34080. * The list of morph target managers added to the scene
  34081. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34082. */
  34083. morphTargetManagers: MorphTargetManager[];
  34084. /**
  34085. * The list of geometries used in the scene.
  34086. */
  34087. geometries: Geometry[];
  34088. /**
  34089. * All of the tranform nodes added to this scene
  34090. * In the context of a Scene, it is not supposed to be modified manually.
  34091. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34092. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34093. * @see http://doc.babylonjs.com/how_to/transformnode
  34094. */
  34095. transformNodes: TransformNode[];
  34096. /**
  34097. * ActionManagers available on the scene.
  34098. */
  34099. actionManagers: AbstractActionManager[];
  34100. /**
  34101. * Textures to keep.
  34102. */
  34103. textures: BaseTexture[];
  34104. /**
  34105. * Environment texture for the scene
  34106. */
  34107. environmentTexture: Nullable<BaseTexture>;
  34108. }
  34109. }
  34110. declare module BABYLON {
  34111. /**
  34112. * Defines a sound that can be played in the application.
  34113. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34114. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34115. */
  34116. export class Sound {
  34117. /**
  34118. * The name of the sound in the scene.
  34119. */
  34120. name: string;
  34121. /**
  34122. * Does the sound autoplay once loaded.
  34123. */
  34124. autoplay: boolean;
  34125. /**
  34126. * Does the sound loop after it finishes playing once.
  34127. */
  34128. loop: boolean;
  34129. /**
  34130. * Does the sound use a custom attenuation curve to simulate the falloff
  34131. * happening when the source gets further away from the camera.
  34132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34133. */
  34134. useCustomAttenuation: boolean;
  34135. /**
  34136. * The sound track id this sound belongs to.
  34137. */
  34138. soundTrackId: number;
  34139. /**
  34140. * Is this sound currently played.
  34141. */
  34142. isPlaying: boolean;
  34143. /**
  34144. * Is this sound currently paused.
  34145. */
  34146. isPaused: boolean;
  34147. /**
  34148. * Does this sound enables spatial sound.
  34149. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34150. */
  34151. spatialSound: boolean;
  34152. /**
  34153. * Define the reference distance the sound should be heard perfectly.
  34154. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34155. */
  34156. refDistance: number;
  34157. /**
  34158. * Define the roll off factor of spatial sounds.
  34159. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34160. */
  34161. rolloffFactor: number;
  34162. /**
  34163. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34164. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34165. */
  34166. maxDistance: number;
  34167. /**
  34168. * Define the distance attenuation model the sound will follow.
  34169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34170. */
  34171. distanceModel: string;
  34172. /**
  34173. * @hidden
  34174. * Back Compat
  34175. **/
  34176. onended: () => any;
  34177. /**
  34178. * Observable event when the current playing sound finishes.
  34179. */
  34180. onEndedObservable: Observable<Sound>;
  34181. private _panningModel;
  34182. private _playbackRate;
  34183. private _streaming;
  34184. private _startTime;
  34185. private _startOffset;
  34186. private _position;
  34187. /** @hidden */
  34188. _positionInEmitterSpace: boolean;
  34189. private _localDirection;
  34190. private _volume;
  34191. private _isReadyToPlay;
  34192. private _isDirectional;
  34193. private _readyToPlayCallback;
  34194. private _audioBuffer;
  34195. private _soundSource;
  34196. private _streamingSource;
  34197. private _soundPanner;
  34198. private _soundGain;
  34199. private _inputAudioNode;
  34200. private _outputAudioNode;
  34201. private _coneInnerAngle;
  34202. private _coneOuterAngle;
  34203. private _coneOuterGain;
  34204. private _scene;
  34205. private _connectedTransformNode;
  34206. private _customAttenuationFunction;
  34207. private _registerFunc;
  34208. private _isOutputConnected;
  34209. private _htmlAudioElement;
  34210. private _urlType;
  34211. /** @hidden */
  34212. static _SceneComponentInitialization: (scene: Scene) => void;
  34213. /**
  34214. * Create a sound and attach it to a scene
  34215. * @param name Name of your sound
  34216. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34217. * @param scene defines the scene the sound belongs to
  34218. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34219. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34220. */
  34221. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34222. /**
  34223. * Release the sound and its associated resources
  34224. */
  34225. dispose(): void;
  34226. /**
  34227. * Gets if the sounds is ready to be played or not.
  34228. * @returns true if ready, otherwise false
  34229. */
  34230. isReady(): boolean;
  34231. private _soundLoaded;
  34232. /**
  34233. * Sets the data of the sound from an audiobuffer
  34234. * @param audioBuffer The audioBuffer containing the data
  34235. */
  34236. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34237. /**
  34238. * Updates the current sounds options such as maxdistance, loop...
  34239. * @param options A JSON object containing values named as the object properties
  34240. */
  34241. updateOptions(options: any): void;
  34242. private _createSpatialParameters;
  34243. private _updateSpatialParameters;
  34244. /**
  34245. * Switch the panning model to HRTF:
  34246. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34248. */
  34249. switchPanningModelToHRTF(): void;
  34250. /**
  34251. * Switch the panning model to Equal Power:
  34252. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34254. */
  34255. switchPanningModelToEqualPower(): void;
  34256. private _switchPanningModel;
  34257. /**
  34258. * Connect this sound to a sound track audio node like gain...
  34259. * @param soundTrackAudioNode the sound track audio node to connect to
  34260. */
  34261. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34262. /**
  34263. * Transform this sound into a directional source
  34264. * @param coneInnerAngle Size of the inner cone in degree
  34265. * @param coneOuterAngle Size of the outer cone in degree
  34266. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34267. */
  34268. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34269. /**
  34270. * Gets or sets the inner angle for the directional cone.
  34271. */
  34272. /**
  34273. * Gets or sets the inner angle for the directional cone.
  34274. */
  34275. directionalConeInnerAngle: number;
  34276. /**
  34277. * Gets or sets the outer angle for the directional cone.
  34278. */
  34279. /**
  34280. * Gets or sets the outer angle for the directional cone.
  34281. */
  34282. directionalConeOuterAngle: number;
  34283. /**
  34284. * Sets the position of the emitter if spatial sound is enabled
  34285. * @param newPosition Defines the new posisiton
  34286. */
  34287. setPosition(newPosition: Vector3): void;
  34288. /**
  34289. * Sets the local direction of the emitter if spatial sound is enabled
  34290. * @param newLocalDirection Defines the new local direction
  34291. */
  34292. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34293. private _updateDirection;
  34294. /** @hidden */
  34295. updateDistanceFromListener(): void;
  34296. /**
  34297. * Sets a new custom attenuation function for the sound.
  34298. * @param callback Defines the function used for the attenuation
  34299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34300. */
  34301. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34302. /**
  34303. * Play the sound
  34304. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34305. * @param offset (optional) Start the sound setting it at a specific time
  34306. */
  34307. play(time?: number, offset?: number): void;
  34308. private _onended;
  34309. /**
  34310. * Stop the sound
  34311. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34312. */
  34313. stop(time?: number): void;
  34314. /**
  34315. * Put the sound in pause
  34316. */
  34317. pause(): void;
  34318. /**
  34319. * Sets a dedicated volume for this sounds
  34320. * @param newVolume Define the new volume of the sound
  34321. * @param time Define in how long the sound should be at this value
  34322. */
  34323. setVolume(newVolume: number, time?: number): void;
  34324. /**
  34325. * Set the sound play back rate
  34326. * @param newPlaybackRate Define the playback rate the sound should be played at
  34327. */
  34328. setPlaybackRate(newPlaybackRate: number): void;
  34329. /**
  34330. * Gets the volume of the sound.
  34331. * @returns the volume of the sound
  34332. */
  34333. getVolume(): number;
  34334. /**
  34335. * Attach the sound to a dedicated mesh
  34336. * @param transformNode The transform node to connect the sound with
  34337. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34338. */
  34339. attachToMesh(transformNode: TransformNode): void;
  34340. /**
  34341. * Detach the sound from the previously attached mesh
  34342. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34343. */
  34344. detachFromMesh(): void;
  34345. private _onRegisterAfterWorldMatrixUpdate;
  34346. /**
  34347. * Clone the current sound in the scene.
  34348. * @returns the new sound clone
  34349. */
  34350. clone(): Nullable<Sound>;
  34351. /**
  34352. * Gets the current underlying audio buffer containing the data
  34353. * @returns the audio buffer
  34354. */
  34355. getAudioBuffer(): Nullable<AudioBuffer>;
  34356. /**
  34357. * Serializes the Sound in a JSON representation
  34358. * @returns the JSON representation of the sound
  34359. */
  34360. serialize(): any;
  34361. /**
  34362. * Parse a JSON representation of a sound to innstantiate in a given scene
  34363. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34364. * @param scene Define the scene the new parsed sound should be created in
  34365. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34366. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34367. * @returns the newly parsed sound
  34368. */
  34369. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34370. }
  34371. }
  34372. declare module BABYLON {
  34373. /**
  34374. * This defines an action helpful to play a defined sound on a triggered action.
  34375. */
  34376. export class PlaySoundAction extends Action {
  34377. private _sound;
  34378. /**
  34379. * Instantiate the action
  34380. * @param triggerOptions defines the trigger options
  34381. * @param sound defines the sound to play
  34382. * @param condition defines the trigger related conditions
  34383. */
  34384. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34385. /** @hidden */
  34386. _prepare(): void;
  34387. /**
  34388. * Execute the action and play the sound.
  34389. */
  34390. execute(): void;
  34391. /**
  34392. * Serializes the actions and its related information.
  34393. * @param parent defines the object to serialize in
  34394. * @returns the serialized object
  34395. */
  34396. serialize(parent: any): any;
  34397. }
  34398. /**
  34399. * This defines an action helpful to stop a defined sound on a triggered action.
  34400. */
  34401. export class StopSoundAction extends Action {
  34402. private _sound;
  34403. /**
  34404. * Instantiate the action
  34405. * @param triggerOptions defines the trigger options
  34406. * @param sound defines the sound to stop
  34407. * @param condition defines the trigger related conditions
  34408. */
  34409. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34410. /** @hidden */
  34411. _prepare(): void;
  34412. /**
  34413. * Execute the action and stop the sound.
  34414. */
  34415. execute(): void;
  34416. /**
  34417. * Serializes the actions and its related information.
  34418. * @param parent defines the object to serialize in
  34419. * @returns the serialized object
  34420. */
  34421. serialize(parent: any): any;
  34422. }
  34423. }
  34424. declare module BABYLON {
  34425. /**
  34426. * This defines an action responsible to change the value of a property
  34427. * by interpolating between its current value and the newly set one once triggered.
  34428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34429. */
  34430. export class InterpolateValueAction extends Action {
  34431. /**
  34432. * Defines the path of the property where the value should be interpolated
  34433. */
  34434. propertyPath: string;
  34435. /**
  34436. * Defines the target value at the end of the interpolation.
  34437. */
  34438. value: any;
  34439. /**
  34440. * Defines the time it will take for the property to interpolate to the value.
  34441. */
  34442. duration: number;
  34443. /**
  34444. * Defines if the other scene animations should be stopped when the action has been triggered
  34445. */
  34446. stopOtherAnimations?: boolean;
  34447. /**
  34448. * Defines a callback raised once the interpolation animation has been done.
  34449. */
  34450. onInterpolationDone?: () => void;
  34451. /**
  34452. * Observable triggered once the interpolation animation has been done.
  34453. */
  34454. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34455. private _target;
  34456. private _effectiveTarget;
  34457. private _property;
  34458. /**
  34459. * Instantiate the action
  34460. * @param triggerOptions defines the trigger options
  34461. * @param target defines the object containing the value to interpolate
  34462. * @param propertyPath defines the path to the property in the target object
  34463. * @param value defines the target value at the end of the interpolation
  34464. * @param duration deines the time it will take for the property to interpolate to the value.
  34465. * @param condition defines the trigger related conditions
  34466. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34467. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34468. */
  34469. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34470. /** @hidden */
  34471. _prepare(): void;
  34472. /**
  34473. * Execute the action starts the value interpolation.
  34474. */
  34475. execute(): void;
  34476. /**
  34477. * Serializes the actions and its related information.
  34478. * @param parent defines the object to serialize in
  34479. * @returns the serialized object
  34480. */
  34481. serialize(parent: any): any;
  34482. }
  34483. }
  34484. declare module BABYLON {
  34485. /**
  34486. * Options allowed during the creation of a sound track.
  34487. */
  34488. export interface ISoundTrackOptions {
  34489. /**
  34490. * The volume the sound track should take during creation
  34491. */
  34492. volume?: number;
  34493. /**
  34494. * Define if the sound track is the main sound track of the scene
  34495. */
  34496. mainTrack?: boolean;
  34497. }
  34498. /**
  34499. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34500. * It will be also used in a future release to apply effects on a specific track.
  34501. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34502. */
  34503. export class SoundTrack {
  34504. /**
  34505. * The unique identifier of the sound track in the scene.
  34506. */
  34507. id: number;
  34508. /**
  34509. * The list of sounds included in the sound track.
  34510. */
  34511. soundCollection: Array<Sound>;
  34512. private _outputAudioNode;
  34513. private _scene;
  34514. private _isMainTrack;
  34515. private _connectedAnalyser;
  34516. private _options;
  34517. private _isInitialized;
  34518. /**
  34519. * Creates a new sound track.
  34520. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34521. * @param scene Define the scene the sound track belongs to
  34522. * @param options
  34523. */
  34524. constructor(scene: Scene, options?: ISoundTrackOptions);
  34525. private _initializeSoundTrackAudioGraph;
  34526. /**
  34527. * Release the sound track and its associated resources
  34528. */
  34529. dispose(): void;
  34530. /**
  34531. * Adds a sound to this sound track
  34532. * @param sound define the cound to add
  34533. * @ignoreNaming
  34534. */
  34535. AddSound(sound: Sound): void;
  34536. /**
  34537. * Removes a sound to this sound track
  34538. * @param sound define the cound to remove
  34539. * @ignoreNaming
  34540. */
  34541. RemoveSound(sound: Sound): void;
  34542. /**
  34543. * Set a global volume for the full sound track.
  34544. * @param newVolume Define the new volume of the sound track
  34545. */
  34546. setVolume(newVolume: number): void;
  34547. /**
  34548. * Switch the panning model to HRTF:
  34549. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34550. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34551. */
  34552. switchPanningModelToHRTF(): void;
  34553. /**
  34554. * Switch the panning model to Equal Power:
  34555. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34557. */
  34558. switchPanningModelToEqualPower(): void;
  34559. /**
  34560. * Connect the sound track to an audio analyser allowing some amazing
  34561. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34562. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34563. * @param analyser The analyser to connect to the engine
  34564. */
  34565. connectToAnalyser(analyser: Analyser): void;
  34566. }
  34567. }
  34568. declare module BABYLON {
  34569. interface AbstractScene {
  34570. /**
  34571. * The list of sounds used in the scene.
  34572. */
  34573. sounds: Nullable<Array<Sound>>;
  34574. }
  34575. interface Scene {
  34576. /**
  34577. * @hidden
  34578. * Backing field
  34579. */
  34580. _mainSoundTrack: SoundTrack;
  34581. /**
  34582. * The main sound track played by the scene.
  34583. * It cotains your primary collection of sounds.
  34584. */
  34585. mainSoundTrack: SoundTrack;
  34586. /**
  34587. * The list of sound tracks added to the scene
  34588. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34589. */
  34590. soundTracks: Nullable<Array<SoundTrack>>;
  34591. /**
  34592. * Gets a sound using a given name
  34593. * @param name defines the name to search for
  34594. * @return the found sound or null if not found at all.
  34595. */
  34596. getSoundByName(name: string): Nullable<Sound>;
  34597. /**
  34598. * Gets or sets if audio support is enabled
  34599. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34600. */
  34601. audioEnabled: boolean;
  34602. /**
  34603. * Gets or sets if audio will be output to headphones
  34604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34605. */
  34606. headphone: boolean;
  34607. }
  34608. /**
  34609. * Defines the sound scene component responsible to manage any sounds
  34610. * in a given scene.
  34611. */
  34612. export class AudioSceneComponent implements ISceneSerializableComponent {
  34613. /**
  34614. * The component name helpfull to identify the component in the list of scene components.
  34615. */
  34616. readonly name: string;
  34617. /**
  34618. * The scene the component belongs to.
  34619. */
  34620. scene: Scene;
  34621. private _audioEnabled;
  34622. /**
  34623. * Gets whether audio is enabled or not.
  34624. * Please use related enable/disable method to switch state.
  34625. */
  34626. readonly audioEnabled: boolean;
  34627. private _headphone;
  34628. /**
  34629. * Gets whether audio is outputing to headphone or not.
  34630. * Please use the according Switch methods to change output.
  34631. */
  34632. readonly headphone: boolean;
  34633. /**
  34634. * Creates a new instance of the component for the given scene
  34635. * @param scene Defines the scene to register the component in
  34636. */
  34637. constructor(scene: Scene);
  34638. /**
  34639. * Registers the component in a given scene
  34640. */
  34641. register(): void;
  34642. /**
  34643. * Rebuilds the elements related to this component in case of
  34644. * context lost for instance.
  34645. */
  34646. rebuild(): void;
  34647. /**
  34648. * Serializes the component data to the specified json object
  34649. * @param serializationObject The object to serialize to
  34650. */
  34651. serialize(serializationObject: any): void;
  34652. /**
  34653. * Adds all the elements from the container to the scene
  34654. * @param container the container holding the elements
  34655. */
  34656. addFromContainer(container: AbstractScene): void;
  34657. /**
  34658. * Removes all the elements in the container from the scene
  34659. * @param container contains the elements to remove
  34660. * @param dispose if the removed element should be disposed (default: false)
  34661. */
  34662. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34663. /**
  34664. * Disposes the component and the associated ressources.
  34665. */
  34666. dispose(): void;
  34667. /**
  34668. * Disables audio in the associated scene.
  34669. */
  34670. disableAudio(): void;
  34671. /**
  34672. * Enables audio in the associated scene.
  34673. */
  34674. enableAudio(): void;
  34675. /**
  34676. * Switch audio to headphone output.
  34677. */
  34678. switchAudioModeForHeadphones(): void;
  34679. /**
  34680. * Switch audio to normal speakers.
  34681. */
  34682. switchAudioModeForNormalSpeakers(): void;
  34683. private _afterRender;
  34684. }
  34685. }
  34686. declare module BABYLON {
  34687. /**
  34688. * Wraps one or more Sound objects and selects one with random weight for playback.
  34689. */
  34690. export class WeightedSound {
  34691. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34692. loop: boolean;
  34693. private _coneInnerAngle;
  34694. private _coneOuterAngle;
  34695. private _volume;
  34696. /** A Sound is currently playing. */
  34697. isPlaying: boolean;
  34698. /** A Sound is currently paused. */
  34699. isPaused: boolean;
  34700. private _sounds;
  34701. private _weights;
  34702. private _currentIndex?;
  34703. /**
  34704. * Creates a new WeightedSound from the list of sounds given.
  34705. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34706. * @param sounds Array of Sounds that will be selected from.
  34707. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34708. */
  34709. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34710. /**
  34711. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34712. */
  34713. /**
  34714. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34715. */
  34716. directionalConeInnerAngle: number;
  34717. /**
  34718. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34719. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34720. */
  34721. /**
  34722. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34723. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34724. */
  34725. directionalConeOuterAngle: number;
  34726. /**
  34727. * Playback volume.
  34728. */
  34729. /**
  34730. * Playback volume.
  34731. */
  34732. volume: number;
  34733. private _onended;
  34734. /**
  34735. * Suspend playback
  34736. */
  34737. pause(): void;
  34738. /**
  34739. * Stop playback
  34740. */
  34741. stop(): void;
  34742. /**
  34743. * Start playback.
  34744. * @param startOffset Position the clip head at a specific time in seconds.
  34745. */
  34746. play(startOffset?: number): void;
  34747. }
  34748. }
  34749. declare module BABYLON {
  34750. /**
  34751. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34752. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34753. */
  34754. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34755. /**
  34756. * Gets the name of the behavior.
  34757. */
  34758. readonly name: string;
  34759. /**
  34760. * The easing function used by animations
  34761. */
  34762. static EasingFunction: BackEase;
  34763. /**
  34764. * The easing mode used by animations
  34765. */
  34766. static EasingMode: number;
  34767. /**
  34768. * The duration of the animation, in milliseconds
  34769. */
  34770. transitionDuration: number;
  34771. /**
  34772. * Length of the distance animated by the transition when lower radius is reached
  34773. */
  34774. lowerRadiusTransitionRange: number;
  34775. /**
  34776. * Length of the distance animated by the transition when upper radius is reached
  34777. */
  34778. upperRadiusTransitionRange: number;
  34779. private _autoTransitionRange;
  34780. /**
  34781. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34782. */
  34783. /**
  34784. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34785. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34786. */
  34787. autoTransitionRange: boolean;
  34788. private _attachedCamera;
  34789. private _onAfterCheckInputsObserver;
  34790. private _onMeshTargetChangedObserver;
  34791. /**
  34792. * Initializes the behavior.
  34793. */
  34794. init(): void;
  34795. /**
  34796. * Attaches the behavior to its arc rotate camera.
  34797. * @param camera Defines the camera to attach the behavior to
  34798. */
  34799. attach(camera: ArcRotateCamera): void;
  34800. /**
  34801. * Detaches the behavior from its current arc rotate camera.
  34802. */
  34803. detach(): void;
  34804. private _radiusIsAnimating;
  34805. private _radiusBounceTransition;
  34806. private _animatables;
  34807. private _cachedWheelPrecision;
  34808. /**
  34809. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34810. * @param radiusLimit The limit to check against.
  34811. * @return Bool to indicate if at limit.
  34812. */
  34813. private _isRadiusAtLimit;
  34814. /**
  34815. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34816. * @param radiusDelta The delta by which to animate to. Can be negative.
  34817. */
  34818. private _applyBoundRadiusAnimation;
  34819. /**
  34820. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34821. */
  34822. protected _clearAnimationLocks(): void;
  34823. /**
  34824. * Stops and removes all animations that have been applied to the camera
  34825. */
  34826. stopAllAnimations(): void;
  34827. }
  34828. }
  34829. declare module BABYLON {
  34830. /**
  34831. * 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.
  34832. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34833. */
  34834. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34835. /**
  34836. * Gets the name of the behavior.
  34837. */
  34838. readonly name: string;
  34839. private _mode;
  34840. private _radiusScale;
  34841. private _positionScale;
  34842. private _defaultElevation;
  34843. private _elevationReturnTime;
  34844. private _elevationReturnWaitTime;
  34845. private _zoomStopsAnimation;
  34846. private _framingTime;
  34847. /**
  34848. * The easing function used by animations
  34849. */
  34850. static EasingFunction: ExponentialEase;
  34851. /**
  34852. * The easing mode used by animations
  34853. */
  34854. static EasingMode: number;
  34855. /**
  34856. * Sets the current mode used by the behavior
  34857. */
  34858. /**
  34859. * Gets current mode used by the behavior.
  34860. */
  34861. mode: number;
  34862. /**
  34863. * Sets the scale applied to the radius (1 by default)
  34864. */
  34865. /**
  34866. * Gets the scale applied to the radius
  34867. */
  34868. radiusScale: number;
  34869. /**
  34870. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34871. */
  34872. /**
  34873. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34874. */
  34875. positionScale: number;
  34876. /**
  34877. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34878. * behaviour is triggered, in radians.
  34879. */
  34880. /**
  34881. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34882. * behaviour is triggered, in radians.
  34883. */
  34884. defaultElevation: number;
  34885. /**
  34886. * Sets the time (in milliseconds) taken to return to the default beta position.
  34887. * Negative value indicates camera should not return to default.
  34888. */
  34889. /**
  34890. * Gets the time (in milliseconds) taken to return to the default beta position.
  34891. * Negative value indicates camera should not return to default.
  34892. */
  34893. elevationReturnTime: number;
  34894. /**
  34895. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34896. */
  34897. /**
  34898. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34899. */
  34900. elevationReturnWaitTime: number;
  34901. /**
  34902. * Sets the flag that indicates if user zooming should stop animation.
  34903. */
  34904. /**
  34905. * Gets the flag that indicates if user zooming should stop animation.
  34906. */
  34907. zoomStopsAnimation: boolean;
  34908. /**
  34909. * Sets the transition time when framing the mesh, in milliseconds
  34910. */
  34911. /**
  34912. * Gets the transition time when framing the mesh, in milliseconds
  34913. */
  34914. framingTime: number;
  34915. /**
  34916. * Define if the behavior should automatically change the configured
  34917. * camera limits and sensibilities.
  34918. */
  34919. autoCorrectCameraLimitsAndSensibility: boolean;
  34920. private _onPrePointerObservableObserver;
  34921. private _onAfterCheckInputsObserver;
  34922. private _onMeshTargetChangedObserver;
  34923. private _attachedCamera;
  34924. private _isPointerDown;
  34925. private _lastInteractionTime;
  34926. /**
  34927. * Initializes the behavior.
  34928. */
  34929. init(): void;
  34930. /**
  34931. * Attaches the behavior to its arc rotate camera.
  34932. * @param camera Defines the camera to attach the behavior to
  34933. */
  34934. attach(camera: ArcRotateCamera): void;
  34935. /**
  34936. * Detaches the behavior from its current arc rotate camera.
  34937. */
  34938. detach(): void;
  34939. private _animatables;
  34940. private _betaIsAnimating;
  34941. private _betaTransition;
  34942. private _radiusTransition;
  34943. private _vectorTransition;
  34944. /**
  34945. * Targets the given mesh and updates zoom level accordingly.
  34946. * @param mesh The mesh to target.
  34947. * @param radius Optional. If a cached radius position already exists, overrides default.
  34948. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34949. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34950. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34951. */
  34952. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34953. /**
  34954. * Targets the given mesh with its children and updates zoom level accordingly.
  34955. * @param mesh The mesh to target.
  34956. * @param radius Optional. If a cached radius position already exists, overrides default.
  34957. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34958. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34959. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34960. */
  34961. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34962. /**
  34963. * Targets the given meshes with their children and updates zoom level accordingly.
  34964. * @param meshes The mesh to target.
  34965. * @param radius Optional. If a cached radius position already exists, overrides default.
  34966. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34967. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34968. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34969. */
  34970. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34971. /**
  34972. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34973. * @param minimumWorld Determines the smaller position of the bounding box extend
  34974. * @param maximumWorld Determines the bigger position of the bounding box extend
  34975. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34976. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34977. */
  34978. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34979. /**
  34980. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34981. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34982. * frustum width.
  34983. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34984. * to fully enclose the mesh in the viewing frustum.
  34985. */
  34986. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34987. /**
  34988. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34989. * is automatically returned to its default position (expected to be above ground plane).
  34990. */
  34991. private _maintainCameraAboveGround;
  34992. /**
  34993. * Returns the frustum slope based on the canvas ratio and camera FOV
  34994. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34995. */
  34996. private _getFrustumSlope;
  34997. /**
  34998. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34999. */
  35000. private _clearAnimationLocks;
  35001. /**
  35002. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35003. */
  35004. private _applyUserInteraction;
  35005. /**
  35006. * Stops and removes all animations that have been applied to the camera
  35007. */
  35008. stopAllAnimations(): void;
  35009. /**
  35010. * Gets a value indicating if the user is moving the camera
  35011. */
  35012. readonly isUserIsMoving: boolean;
  35013. /**
  35014. * The camera can move all the way towards the mesh.
  35015. */
  35016. static IgnoreBoundsSizeMode: number;
  35017. /**
  35018. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35019. */
  35020. static FitFrustumSidesMode: number;
  35021. }
  35022. }
  35023. declare module BABYLON {
  35024. /**
  35025. * Base class for Camera Pointer Inputs.
  35026. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35027. * for example usage.
  35028. */
  35029. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35030. /**
  35031. * Defines the camera the input is attached to.
  35032. */
  35033. abstract camera: Camera;
  35034. /**
  35035. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35036. */
  35037. protected _altKey: boolean;
  35038. protected _ctrlKey: boolean;
  35039. protected _metaKey: boolean;
  35040. protected _shiftKey: boolean;
  35041. /**
  35042. * Which mouse buttons were pressed at time of last mouse event.
  35043. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35044. */
  35045. protected _buttonsPressed: number;
  35046. /**
  35047. * Defines the buttons associated with the input to handle camera move.
  35048. */
  35049. buttons: number[];
  35050. /**
  35051. * Attach the input controls to a specific dom element to get the input from.
  35052. * @param element Defines the element the controls should be listened from
  35053. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35054. */
  35055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35056. /**
  35057. * Detach the current controls from the specified dom element.
  35058. * @param element Defines the element to stop listening the inputs from
  35059. */
  35060. detachControl(element: Nullable<HTMLElement>): void;
  35061. /**
  35062. * Gets the class name of the current input.
  35063. * @returns the class name
  35064. */
  35065. getClassName(): string;
  35066. /**
  35067. * Get the friendly name associated with the input class.
  35068. * @returns the input friendly name
  35069. */
  35070. getSimpleName(): string;
  35071. /**
  35072. * Called on pointer POINTERDOUBLETAP event.
  35073. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35074. */
  35075. protected onDoubleTap(type: string): void;
  35076. /**
  35077. * Called on pointer POINTERMOVE event if only a single touch is active.
  35078. * Override this method to provide functionality.
  35079. */
  35080. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35081. /**
  35082. * Called on pointer POINTERMOVE event if multiple touches are active.
  35083. * Override this method to provide functionality.
  35084. */
  35085. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35086. /**
  35087. * Called on JS contextmenu event.
  35088. * Override this method to provide functionality.
  35089. */
  35090. protected onContextMenu(evt: PointerEvent): void;
  35091. /**
  35092. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35093. * press.
  35094. * Override this method to provide functionality.
  35095. */
  35096. protected onButtonDown(evt: PointerEvent): void;
  35097. /**
  35098. * Called each time a new POINTERUP event occurs. Ie, for each button
  35099. * release.
  35100. * Override this method to provide functionality.
  35101. */
  35102. protected onButtonUp(evt: PointerEvent): void;
  35103. /**
  35104. * Called when window becomes inactive.
  35105. * Override this method to provide functionality.
  35106. */
  35107. protected onLostFocus(): void;
  35108. private _pointerInput;
  35109. private _observer;
  35110. private _onLostFocus;
  35111. private pointA;
  35112. private pointB;
  35113. }
  35114. }
  35115. declare module BABYLON {
  35116. /**
  35117. * Manage the pointers inputs to control an arc rotate camera.
  35118. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35119. */
  35120. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35121. /**
  35122. * Defines the camera the input is attached to.
  35123. */
  35124. camera: ArcRotateCamera;
  35125. /**
  35126. * Gets the class name of the current input.
  35127. * @returns the class name
  35128. */
  35129. getClassName(): string;
  35130. /**
  35131. * Defines the buttons associated with the input to handle camera move.
  35132. */
  35133. buttons: number[];
  35134. /**
  35135. * Defines the pointer angular sensibility along the X axis or how fast is
  35136. * the camera rotating.
  35137. */
  35138. angularSensibilityX: number;
  35139. /**
  35140. * Defines the pointer angular sensibility along the Y axis or how fast is
  35141. * the camera rotating.
  35142. */
  35143. angularSensibilityY: number;
  35144. /**
  35145. * Defines the pointer pinch precision or how fast is the camera zooming.
  35146. */
  35147. pinchPrecision: number;
  35148. /**
  35149. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35150. * from 0.
  35151. * It defines the percentage of current camera.radius to use as delta when
  35152. * pinch zoom is used.
  35153. */
  35154. pinchDeltaPercentage: number;
  35155. /**
  35156. * Defines the pointer panning sensibility or how fast is the camera moving.
  35157. */
  35158. panningSensibility: number;
  35159. /**
  35160. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35161. */
  35162. multiTouchPanning: boolean;
  35163. /**
  35164. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35165. * zoom (pinch) through multitouch.
  35166. */
  35167. multiTouchPanAndZoom: boolean;
  35168. /**
  35169. * Revers pinch action direction.
  35170. */
  35171. pinchInwards: boolean;
  35172. private _isPanClick;
  35173. private _twoFingerActivityCount;
  35174. private _isPinching;
  35175. /**
  35176. * Called on pointer POINTERMOVE event if only a single touch is active.
  35177. */
  35178. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35179. /**
  35180. * Called on pointer POINTERDOUBLETAP event.
  35181. */
  35182. protected onDoubleTap(type: string): void;
  35183. /**
  35184. * Called on pointer POINTERMOVE event if multiple touches are active.
  35185. */
  35186. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35187. /**
  35188. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35189. * press.
  35190. */
  35191. protected onButtonDown(evt: PointerEvent): void;
  35192. /**
  35193. * Called each time a new POINTERUP event occurs. Ie, for each button
  35194. * release.
  35195. */
  35196. protected onButtonUp(evt: PointerEvent): void;
  35197. /**
  35198. * Called when window becomes inactive.
  35199. */
  35200. protected onLostFocus(): void;
  35201. }
  35202. }
  35203. declare module BABYLON {
  35204. /**
  35205. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35206. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35207. */
  35208. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35209. /**
  35210. * Defines the camera the input is attached to.
  35211. */
  35212. camera: ArcRotateCamera;
  35213. /**
  35214. * Defines the list of key codes associated with the up action (increase alpha)
  35215. */
  35216. keysUp: number[];
  35217. /**
  35218. * Defines the list of key codes associated with the down action (decrease alpha)
  35219. */
  35220. keysDown: number[];
  35221. /**
  35222. * Defines the list of key codes associated with the left action (increase beta)
  35223. */
  35224. keysLeft: number[];
  35225. /**
  35226. * Defines the list of key codes associated with the right action (decrease beta)
  35227. */
  35228. keysRight: number[];
  35229. /**
  35230. * Defines the list of key codes associated with the reset action.
  35231. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35232. */
  35233. keysReset: number[];
  35234. /**
  35235. * Defines the panning sensibility of the inputs.
  35236. * (How fast is the camera paning)
  35237. */
  35238. panningSensibility: number;
  35239. /**
  35240. * Defines the zooming sensibility of the inputs.
  35241. * (How fast is the camera zooming)
  35242. */
  35243. zoomingSensibility: number;
  35244. /**
  35245. * Defines wether maintaining the alt key down switch the movement mode from
  35246. * orientation to zoom.
  35247. */
  35248. useAltToZoom: boolean;
  35249. /**
  35250. * Rotation speed of the camera
  35251. */
  35252. angularSpeed: number;
  35253. private _keys;
  35254. private _ctrlPressed;
  35255. private _altPressed;
  35256. private _onCanvasBlurObserver;
  35257. private _onKeyboardObserver;
  35258. private _engine;
  35259. private _scene;
  35260. /**
  35261. * Attach the input controls to a specific dom element to get the input from.
  35262. * @param element Defines the element the controls should be listened from
  35263. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35264. */
  35265. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35266. /**
  35267. * Detach the current controls from the specified dom element.
  35268. * @param element Defines the element to stop listening the inputs from
  35269. */
  35270. detachControl(element: Nullable<HTMLElement>): void;
  35271. /**
  35272. * Update the current camera state depending on the inputs that have been used this frame.
  35273. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35274. */
  35275. checkInputs(): void;
  35276. /**
  35277. * Gets the class name of the current intput.
  35278. * @returns the class name
  35279. */
  35280. getClassName(): string;
  35281. /**
  35282. * Get the friendly name associated with the input class.
  35283. * @returns the input friendly name
  35284. */
  35285. getSimpleName(): string;
  35286. }
  35287. }
  35288. declare module BABYLON {
  35289. /**
  35290. * Manage the mouse wheel inputs to control an arc rotate camera.
  35291. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35292. */
  35293. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35294. /**
  35295. * Defines the camera the input is attached to.
  35296. */
  35297. camera: ArcRotateCamera;
  35298. /**
  35299. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35300. */
  35301. wheelPrecision: number;
  35302. /**
  35303. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35304. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35305. */
  35306. wheelDeltaPercentage: number;
  35307. private _wheel;
  35308. private _observer;
  35309. private computeDeltaFromMouseWheelLegacyEvent;
  35310. /**
  35311. * Attach the input controls to a specific dom element to get the input from.
  35312. * @param element Defines the element the controls should be listened from
  35313. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35314. */
  35315. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35316. /**
  35317. * Detach the current controls from the specified dom element.
  35318. * @param element Defines the element to stop listening the inputs from
  35319. */
  35320. detachControl(element: Nullable<HTMLElement>): void;
  35321. /**
  35322. * Gets the class name of the current intput.
  35323. * @returns the class name
  35324. */
  35325. getClassName(): string;
  35326. /**
  35327. * Get the friendly name associated with the input class.
  35328. * @returns the input friendly name
  35329. */
  35330. getSimpleName(): string;
  35331. }
  35332. }
  35333. declare module BABYLON {
  35334. /**
  35335. * Default Inputs manager for the ArcRotateCamera.
  35336. * It groups all the default supported inputs for ease of use.
  35337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35338. */
  35339. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35340. /**
  35341. * Instantiates a new ArcRotateCameraInputsManager.
  35342. * @param camera Defines the camera the inputs belong to
  35343. */
  35344. constructor(camera: ArcRotateCamera);
  35345. /**
  35346. * Add mouse wheel input support to the input manager.
  35347. * @returns the current input manager
  35348. */
  35349. addMouseWheel(): ArcRotateCameraInputsManager;
  35350. /**
  35351. * Add pointers input support to the input manager.
  35352. * @returns the current input manager
  35353. */
  35354. addPointers(): ArcRotateCameraInputsManager;
  35355. /**
  35356. * Add keyboard input support to the input manager.
  35357. * @returns the current input manager
  35358. */
  35359. addKeyboard(): ArcRotateCameraInputsManager;
  35360. }
  35361. }
  35362. declare module BABYLON {
  35363. /**
  35364. * This represents an orbital type of camera.
  35365. *
  35366. * 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.
  35367. * 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.
  35368. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35369. */
  35370. export class ArcRotateCamera extends TargetCamera {
  35371. /**
  35372. * Defines the rotation angle of the camera along the longitudinal axis.
  35373. */
  35374. alpha: number;
  35375. /**
  35376. * Defines the rotation angle of the camera along the latitudinal axis.
  35377. */
  35378. beta: number;
  35379. /**
  35380. * Defines the radius of the camera from it s target point.
  35381. */
  35382. radius: number;
  35383. protected _target: Vector3;
  35384. protected _targetHost: Nullable<AbstractMesh>;
  35385. /**
  35386. * Defines the target point of the camera.
  35387. * The camera looks towards it form the radius distance.
  35388. */
  35389. target: Vector3;
  35390. /**
  35391. * Define the current local position of the camera in the scene
  35392. */
  35393. position: Vector3;
  35394. protected _upVector: Vector3;
  35395. protected _upToYMatrix: Matrix;
  35396. protected _YToUpMatrix: Matrix;
  35397. /**
  35398. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35399. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35400. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35401. */
  35402. upVector: Vector3;
  35403. /**
  35404. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35405. */
  35406. setMatUp(): void;
  35407. /**
  35408. * Current inertia value on the longitudinal axis.
  35409. * The bigger this number the longer it will take for the camera to stop.
  35410. */
  35411. inertialAlphaOffset: number;
  35412. /**
  35413. * Current inertia value on the latitudinal axis.
  35414. * The bigger this number the longer it will take for the camera to stop.
  35415. */
  35416. inertialBetaOffset: number;
  35417. /**
  35418. * Current inertia value on the radius axis.
  35419. * The bigger this number the longer it will take for the camera to stop.
  35420. */
  35421. inertialRadiusOffset: number;
  35422. /**
  35423. * Minimum allowed angle on the longitudinal axis.
  35424. * This can help limiting how the Camera is able to move in the scene.
  35425. */
  35426. lowerAlphaLimit: Nullable<number>;
  35427. /**
  35428. * Maximum allowed angle on the longitudinal axis.
  35429. * This can help limiting how the Camera is able to move in the scene.
  35430. */
  35431. upperAlphaLimit: Nullable<number>;
  35432. /**
  35433. * Minimum allowed angle on the latitudinal axis.
  35434. * This can help limiting how the Camera is able to move in the scene.
  35435. */
  35436. lowerBetaLimit: number;
  35437. /**
  35438. * Maximum allowed angle on the latitudinal axis.
  35439. * This can help limiting how the Camera is able to move in the scene.
  35440. */
  35441. upperBetaLimit: number;
  35442. /**
  35443. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35444. * This can help limiting how the Camera is able to move in the scene.
  35445. */
  35446. lowerRadiusLimit: Nullable<number>;
  35447. /**
  35448. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35449. * This can help limiting how the Camera is able to move in the scene.
  35450. */
  35451. upperRadiusLimit: Nullable<number>;
  35452. /**
  35453. * Defines the current inertia value used during panning of the camera along the X axis.
  35454. */
  35455. inertialPanningX: number;
  35456. /**
  35457. * Defines the current inertia value used during panning of the camera along the Y axis.
  35458. */
  35459. inertialPanningY: number;
  35460. /**
  35461. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35462. * Basically if your fingers moves away from more than this distance you will be considered
  35463. * in pinch mode.
  35464. */
  35465. pinchToPanMaxDistance: number;
  35466. /**
  35467. * Defines the maximum distance the camera can pan.
  35468. * This could help keeping the cammera always in your scene.
  35469. */
  35470. panningDistanceLimit: Nullable<number>;
  35471. /**
  35472. * Defines the target of the camera before paning.
  35473. */
  35474. panningOriginTarget: Vector3;
  35475. /**
  35476. * Defines the value of the inertia used during panning.
  35477. * 0 would mean stop inertia and one would mean no decelleration at all.
  35478. */
  35479. panningInertia: number;
  35480. /**
  35481. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35482. */
  35483. angularSensibilityX: number;
  35484. /**
  35485. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35486. */
  35487. angularSensibilityY: number;
  35488. /**
  35489. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35490. */
  35491. pinchPrecision: number;
  35492. /**
  35493. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35494. * It will be used instead of pinchDeltaPrecision if different from 0.
  35495. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35496. */
  35497. pinchDeltaPercentage: number;
  35498. /**
  35499. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35500. */
  35501. panningSensibility: number;
  35502. /**
  35503. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35504. */
  35505. keysUp: number[];
  35506. /**
  35507. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35508. */
  35509. keysDown: number[];
  35510. /**
  35511. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35512. */
  35513. keysLeft: number[];
  35514. /**
  35515. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35516. */
  35517. keysRight: number[];
  35518. /**
  35519. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35520. */
  35521. wheelPrecision: number;
  35522. /**
  35523. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35524. * It will be used instead of pinchDeltaPrecision if different from 0.
  35525. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35526. */
  35527. wheelDeltaPercentage: number;
  35528. /**
  35529. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35530. */
  35531. zoomOnFactor: number;
  35532. /**
  35533. * Defines a screen offset for the camera position.
  35534. */
  35535. targetScreenOffset: Vector2;
  35536. /**
  35537. * Allows the camera to be completely reversed.
  35538. * If false the camera can not arrive upside down.
  35539. */
  35540. allowUpsideDown: boolean;
  35541. /**
  35542. * Define if double tap/click is used to restore the previously saved state of the camera.
  35543. */
  35544. useInputToRestoreState: boolean;
  35545. /** @hidden */
  35546. _viewMatrix: Matrix;
  35547. /** @hidden */
  35548. _useCtrlForPanning: boolean;
  35549. /** @hidden */
  35550. _panningMouseButton: number;
  35551. /**
  35552. * Defines the input associated to the camera.
  35553. */
  35554. inputs: ArcRotateCameraInputsManager;
  35555. /** @hidden */
  35556. _reset: () => void;
  35557. /**
  35558. * Defines the allowed panning axis.
  35559. */
  35560. panningAxis: Vector3;
  35561. protected _localDirection: Vector3;
  35562. protected _transformedDirection: Vector3;
  35563. private _bouncingBehavior;
  35564. /**
  35565. * Gets the bouncing behavior of the camera if it has been enabled.
  35566. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35567. */
  35568. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35569. /**
  35570. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35571. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35572. */
  35573. useBouncingBehavior: boolean;
  35574. private _framingBehavior;
  35575. /**
  35576. * Gets the framing behavior of the camera if it has been enabled.
  35577. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35578. */
  35579. readonly framingBehavior: Nullable<FramingBehavior>;
  35580. /**
  35581. * Defines if the framing behavior of the camera is enabled on the camera.
  35582. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35583. */
  35584. useFramingBehavior: boolean;
  35585. private _autoRotationBehavior;
  35586. /**
  35587. * Gets the auto rotation behavior of the camera if it has been enabled.
  35588. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35589. */
  35590. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35591. /**
  35592. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35593. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35594. */
  35595. useAutoRotationBehavior: boolean;
  35596. /**
  35597. * Observable triggered when the mesh target has been changed on the camera.
  35598. */
  35599. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35600. /**
  35601. * Event raised when the camera is colliding with a mesh.
  35602. */
  35603. onCollide: (collidedMesh: AbstractMesh) => void;
  35604. /**
  35605. * Defines whether the camera should check collision with the objects oh the scene.
  35606. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35607. */
  35608. checkCollisions: boolean;
  35609. /**
  35610. * Defines the collision radius of the camera.
  35611. * This simulates a sphere around the camera.
  35612. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35613. */
  35614. collisionRadius: Vector3;
  35615. protected _collider: Collider;
  35616. protected _previousPosition: Vector3;
  35617. protected _collisionVelocity: Vector3;
  35618. protected _newPosition: Vector3;
  35619. protected _previousAlpha: number;
  35620. protected _previousBeta: number;
  35621. protected _previousRadius: number;
  35622. protected _collisionTriggered: boolean;
  35623. protected _targetBoundingCenter: Nullable<Vector3>;
  35624. private _computationVector;
  35625. /**
  35626. * Instantiates a new ArcRotateCamera in a given scene
  35627. * @param name Defines the name of the camera
  35628. * @param alpha Defines the camera rotation along the logitudinal axis
  35629. * @param beta Defines the camera rotation along the latitudinal axis
  35630. * @param radius Defines the camera distance from its target
  35631. * @param target Defines the camera target
  35632. * @param scene Defines the scene the camera belongs to
  35633. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35634. */
  35635. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35636. /** @hidden */
  35637. _initCache(): void;
  35638. /** @hidden */
  35639. _updateCache(ignoreParentClass?: boolean): void;
  35640. protected _getTargetPosition(): Vector3;
  35641. private _storedAlpha;
  35642. private _storedBeta;
  35643. private _storedRadius;
  35644. private _storedTarget;
  35645. /**
  35646. * Stores the current state of the camera (alpha, beta, radius and target)
  35647. * @returns the camera itself
  35648. */
  35649. storeState(): Camera;
  35650. /**
  35651. * @hidden
  35652. * Restored camera state. You must call storeState() first
  35653. */
  35654. _restoreStateValues(): boolean;
  35655. /** @hidden */
  35656. _isSynchronizedViewMatrix(): boolean;
  35657. /**
  35658. * Attached controls to the current camera.
  35659. * @param element Defines the element the controls should be listened from
  35660. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35661. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35662. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35663. */
  35664. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35665. /**
  35666. * Detach the current controls from the camera.
  35667. * The camera will stop reacting to inputs.
  35668. * @param element Defines the element to stop listening the inputs from
  35669. */
  35670. detachControl(element: HTMLElement): void;
  35671. /** @hidden */
  35672. _checkInputs(): void;
  35673. protected _checkLimits(): void;
  35674. /**
  35675. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35676. */
  35677. rebuildAnglesAndRadius(): void;
  35678. /**
  35679. * Use a position to define the current camera related information like aplha, beta and radius
  35680. * @param position Defines the position to set the camera at
  35681. */
  35682. setPosition(position: Vector3): void;
  35683. /**
  35684. * Defines the target the camera should look at.
  35685. * This will automatically adapt alpha beta and radius to fit within the new target.
  35686. * @param target Defines the new target as a Vector or a mesh
  35687. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35688. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35689. */
  35690. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35691. /** @hidden */
  35692. _getViewMatrix(): Matrix;
  35693. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35694. /**
  35695. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35696. * @param meshes Defines the mesh to zoom on
  35697. * @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)
  35698. */
  35699. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35700. /**
  35701. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35702. * The target will be changed but the radius
  35703. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35704. * @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)
  35705. */
  35706. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35707. min: Vector3;
  35708. max: Vector3;
  35709. distance: number;
  35710. }, doNotUpdateMaxZ?: boolean): void;
  35711. /**
  35712. * @override
  35713. * Override Camera.createRigCamera
  35714. */
  35715. createRigCamera(name: string, cameraIndex: number): Camera;
  35716. /**
  35717. * @hidden
  35718. * @override
  35719. * Override Camera._updateRigCameras
  35720. */
  35721. _updateRigCameras(): void;
  35722. /**
  35723. * Destroy the camera and release the current resources hold by it.
  35724. */
  35725. dispose(): void;
  35726. /**
  35727. * Gets the current object class name.
  35728. * @return the class name
  35729. */
  35730. getClassName(): string;
  35731. }
  35732. }
  35733. declare module BABYLON {
  35734. /**
  35735. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35736. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35737. */
  35738. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35739. /**
  35740. * Gets the name of the behavior.
  35741. */
  35742. readonly name: string;
  35743. private _zoomStopsAnimation;
  35744. private _idleRotationSpeed;
  35745. private _idleRotationWaitTime;
  35746. private _idleRotationSpinupTime;
  35747. /**
  35748. * Sets the flag that indicates if user zooming should stop animation.
  35749. */
  35750. /**
  35751. * Gets the flag that indicates if user zooming should stop animation.
  35752. */
  35753. zoomStopsAnimation: boolean;
  35754. /**
  35755. * Sets the default speed at which the camera rotates around the model.
  35756. */
  35757. /**
  35758. * Gets the default speed at which the camera rotates around the model.
  35759. */
  35760. idleRotationSpeed: number;
  35761. /**
  35762. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35763. */
  35764. /**
  35765. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35766. */
  35767. idleRotationWaitTime: number;
  35768. /**
  35769. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35770. */
  35771. /**
  35772. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35773. */
  35774. idleRotationSpinupTime: number;
  35775. /**
  35776. * Gets a value indicating if the camera is currently rotating because of this behavior
  35777. */
  35778. readonly rotationInProgress: boolean;
  35779. private _onPrePointerObservableObserver;
  35780. private _onAfterCheckInputsObserver;
  35781. private _attachedCamera;
  35782. private _isPointerDown;
  35783. private _lastFrameTime;
  35784. private _lastInteractionTime;
  35785. private _cameraRotationSpeed;
  35786. /**
  35787. * Initializes the behavior.
  35788. */
  35789. init(): void;
  35790. /**
  35791. * Attaches the behavior to its arc rotate camera.
  35792. * @param camera Defines the camera to attach the behavior to
  35793. */
  35794. attach(camera: ArcRotateCamera): void;
  35795. /**
  35796. * Detaches the behavior from its current arc rotate camera.
  35797. */
  35798. detach(): void;
  35799. /**
  35800. * Returns true if user is scrolling.
  35801. * @return true if user is scrolling.
  35802. */
  35803. private _userIsZooming;
  35804. private _lastFrameRadius;
  35805. private _shouldAnimationStopForInteraction;
  35806. /**
  35807. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35808. */
  35809. private _applyUserInteraction;
  35810. private _userIsMoving;
  35811. }
  35812. }
  35813. declare module BABYLON {
  35814. /**
  35815. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35816. */
  35817. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35818. private ui;
  35819. /**
  35820. * The name of the behavior
  35821. */
  35822. name: string;
  35823. /**
  35824. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35825. */
  35826. distanceAwayFromFace: number;
  35827. /**
  35828. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35829. */
  35830. distanceAwayFromBottomOfFace: number;
  35831. private _faceVectors;
  35832. private _target;
  35833. private _scene;
  35834. private _onRenderObserver;
  35835. private _tmpMatrix;
  35836. private _tmpVector;
  35837. /**
  35838. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35839. * @param ui The transform node that should be attched to the mesh
  35840. */
  35841. constructor(ui: TransformNode);
  35842. /**
  35843. * Initializes the behavior
  35844. */
  35845. init(): void;
  35846. private _closestFace;
  35847. private _zeroVector;
  35848. private _lookAtTmpMatrix;
  35849. private _lookAtToRef;
  35850. /**
  35851. * Attaches the AttachToBoxBehavior to the passed in mesh
  35852. * @param target The mesh that the specified node will be attached to
  35853. */
  35854. attach(target: Mesh): void;
  35855. /**
  35856. * Detaches the behavior from the mesh
  35857. */
  35858. detach(): void;
  35859. }
  35860. }
  35861. declare module BABYLON {
  35862. /**
  35863. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35864. */
  35865. export class FadeInOutBehavior implements Behavior<Mesh> {
  35866. /**
  35867. * Time in milliseconds to delay before fading in (Default: 0)
  35868. */
  35869. delay: number;
  35870. /**
  35871. * Time in milliseconds for the mesh to fade in (Default: 300)
  35872. */
  35873. fadeInTime: number;
  35874. private _millisecondsPerFrame;
  35875. private _hovered;
  35876. private _hoverValue;
  35877. private _ownerNode;
  35878. /**
  35879. * Instatiates the FadeInOutBehavior
  35880. */
  35881. constructor();
  35882. /**
  35883. * The name of the behavior
  35884. */
  35885. readonly name: string;
  35886. /**
  35887. * Initializes the behavior
  35888. */
  35889. init(): void;
  35890. /**
  35891. * Attaches the fade behavior on the passed in mesh
  35892. * @param ownerNode The mesh that will be faded in/out once attached
  35893. */
  35894. attach(ownerNode: Mesh): void;
  35895. /**
  35896. * Detaches the behavior from the mesh
  35897. */
  35898. detach(): void;
  35899. /**
  35900. * Triggers the mesh to begin fading in or out
  35901. * @param value if the object should fade in or out (true to fade in)
  35902. */
  35903. fadeIn(value: boolean): void;
  35904. private _update;
  35905. private _setAllVisibility;
  35906. }
  35907. }
  35908. declare module BABYLON {
  35909. /**
  35910. * Class containing a set of static utilities functions for managing Pivots
  35911. * @hidden
  35912. */
  35913. export class PivotTools {
  35914. private static _PivotCached;
  35915. private static _OldPivotPoint;
  35916. private static _PivotTranslation;
  35917. private static _PivotTmpVector;
  35918. /** @hidden */
  35919. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35920. /** @hidden */
  35921. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35922. }
  35923. }
  35924. declare module BABYLON {
  35925. /**
  35926. * Class containing static functions to help procedurally build meshes
  35927. */
  35928. export class PlaneBuilder {
  35929. /**
  35930. * Creates a plane mesh
  35931. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35932. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35933. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35935. * * 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
  35936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35937. * @param name defines the name of the mesh
  35938. * @param options defines the options used to create the mesh
  35939. * @param scene defines the hosting scene
  35940. * @returns the plane mesh
  35941. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35942. */
  35943. static CreatePlane(name: string, options: {
  35944. size?: number;
  35945. width?: number;
  35946. height?: number;
  35947. sideOrientation?: number;
  35948. frontUVs?: Vector4;
  35949. backUVs?: Vector4;
  35950. updatable?: boolean;
  35951. sourcePlane?: Plane;
  35952. }, scene?: Nullable<Scene>): Mesh;
  35953. }
  35954. }
  35955. declare module BABYLON {
  35956. /**
  35957. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35958. */
  35959. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35960. private static _AnyMouseID;
  35961. /**
  35962. * Abstract mesh the behavior is set on
  35963. */
  35964. attachedNode: AbstractMesh;
  35965. private _dragPlane;
  35966. private _scene;
  35967. private _pointerObserver;
  35968. private _beforeRenderObserver;
  35969. private static _planeScene;
  35970. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35971. /**
  35972. * 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)
  35973. */
  35974. maxDragAngle: number;
  35975. /**
  35976. * @hidden
  35977. */
  35978. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35979. /**
  35980. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35981. */
  35982. currentDraggingPointerID: number;
  35983. /**
  35984. * The last position where the pointer hit the drag plane in world space
  35985. */
  35986. lastDragPosition: Vector3;
  35987. /**
  35988. * If the behavior is currently in a dragging state
  35989. */
  35990. dragging: boolean;
  35991. /**
  35992. * 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)
  35993. */
  35994. dragDeltaRatio: number;
  35995. /**
  35996. * If the drag plane orientation should be updated during the dragging (Default: true)
  35997. */
  35998. updateDragPlane: boolean;
  35999. private _debugMode;
  36000. private _moving;
  36001. /**
  36002. * Fires each time the attached mesh is dragged with the pointer
  36003. * * delta between last drag position and current drag position in world space
  36004. * * dragDistance along the drag axis
  36005. * * dragPlaneNormal normal of the current drag plane used during the drag
  36006. * * dragPlanePoint in world space where the drag intersects the drag plane
  36007. */
  36008. onDragObservable: Observable<{
  36009. delta: Vector3;
  36010. dragPlanePoint: Vector3;
  36011. dragPlaneNormal: Vector3;
  36012. dragDistance: number;
  36013. pointerId: number;
  36014. }>;
  36015. /**
  36016. * Fires each time a drag begins (eg. mouse down on mesh)
  36017. */
  36018. onDragStartObservable: Observable<{
  36019. dragPlanePoint: Vector3;
  36020. pointerId: number;
  36021. }>;
  36022. /**
  36023. * Fires each time a drag ends (eg. mouse release after drag)
  36024. */
  36025. onDragEndObservable: Observable<{
  36026. dragPlanePoint: Vector3;
  36027. pointerId: number;
  36028. }>;
  36029. /**
  36030. * If the attached mesh should be moved when dragged
  36031. */
  36032. moveAttached: boolean;
  36033. /**
  36034. * If the drag behavior will react to drag events (Default: true)
  36035. */
  36036. enabled: boolean;
  36037. /**
  36038. * If camera controls should be detached during the drag
  36039. */
  36040. detachCameraControls: boolean;
  36041. /**
  36042. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36043. */
  36044. useObjectOrienationForDragging: boolean;
  36045. private _options;
  36046. /**
  36047. * Creates a pointer drag behavior that can be attached to a mesh
  36048. * @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)
  36049. */
  36050. constructor(options?: {
  36051. dragAxis?: Vector3;
  36052. dragPlaneNormal?: Vector3;
  36053. });
  36054. /**
  36055. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36056. */
  36057. validateDrag: (targetPosition: Vector3) => boolean;
  36058. /**
  36059. * The name of the behavior
  36060. */
  36061. readonly name: string;
  36062. /**
  36063. * Initializes the behavior
  36064. */
  36065. init(): void;
  36066. private _tmpVector;
  36067. private _alternatePickedPoint;
  36068. private _worldDragAxis;
  36069. private _targetPosition;
  36070. private _attachedElement;
  36071. /**
  36072. * Attaches the drag behavior the passed in mesh
  36073. * @param ownerNode The mesh that will be dragged around once attached
  36074. */
  36075. attach(ownerNode: AbstractMesh): void;
  36076. /**
  36077. * Force relase the drag action by code.
  36078. */
  36079. releaseDrag(): void;
  36080. private _startDragRay;
  36081. private _lastPointerRay;
  36082. /**
  36083. * Simulates the start of a pointer drag event on the behavior
  36084. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36085. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36086. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36087. */
  36088. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36089. private _startDrag;
  36090. private _dragDelta;
  36091. private _moveDrag;
  36092. private _pickWithRayOnDragPlane;
  36093. private _pointA;
  36094. private _pointB;
  36095. private _pointC;
  36096. private _lineA;
  36097. private _lineB;
  36098. private _localAxis;
  36099. private _lookAt;
  36100. private _updateDragPlanePosition;
  36101. /**
  36102. * Detaches the behavior from the mesh
  36103. */
  36104. detach(): void;
  36105. }
  36106. }
  36107. declare module BABYLON {
  36108. /**
  36109. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36110. */
  36111. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36112. private _dragBehaviorA;
  36113. private _dragBehaviorB;
  36114. private _startDistance;
  36115. private _initialScale;
  36116. private _targetScale;
  36117. private _ownerNode;
  36118. private _sceneRenderObserver;
  36119. /**
  36120. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36121. */
  36122. constructor();
  36123. /**
  36124. * The name of the behavior
  36125. */
  36126. readonly name: string;
  36127. /**
  36128. * Initializes the behavior
  36129. */
  36130. init(): void;
  36131. private _getCurrentDistance;
  36132. /**
  36133. * Attaches the scale behavior the passed in mesh
  36134. * @param ownerNode The mesh that will be scaled around once attached
  36135. */
  36136. attach(ownerNode: Mesh): void;
  36137. /**
  36138. * Detaches the behavior from the mesh
  36139. */
  36140. detach(): void;
  36141. }
  36142. }
  36143. declare module BABYLON {
  36144. /**
  36145. * 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
  36146. */
  36147. export class SixDofDragBehavior implements Behavior<Mesh> {
  36148. private static _virtualScene;
  36149. private _ownerNode;
  36150. private _sceneRenderObserver;
  36151. private _scene;
  36152. private _targetPosition;
  36153. private _virtualOriginMesh;
  36154. private _virtualDragMesh;
  36155. private _pointerObserver;
  36156. private _moving;
  36157. private _startingOrientation;
  36158. /**
  36159. * 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)
  36160. */
  36161. private zDragFactor;
  36162. /**
  36163. * If the object should rotate to face the drag origin
  36164. */
  36165. rotateDraggedObject: boolean;
  36166. /**
  36167. * If the behavior is currently in a dragging state
  36168. */
  36169. dragging: boolean;
  36170. /**
  36171. * 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)
  36172. */
  36173. dragDeltaRatio: number;
  36174. /**
  36175. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36176. */
  36177. currentDraggingPointerID: number;
  36178. /**
  36179. * If camera controls should be detached during the drag
  36180. */
  36181. detachCameraControls: boolean;
  36182. /**
  36183. * Fires each time a drag starts
  36184. */
  36185. onDragStartObservable: Observable<{}>;
  36186. /**
  36187. * Fires each time a drag ends (eg. mouse release after drag)
  36188. */
  36189. onDragEndObservable: Observable<{}>;
  36190. /**
  36191. * 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
  36192. */
  36193. constructor();
  36194. /**
  36195. * The name of the behavior
  36196. */
  36197. readonly name: string;
  36198. /**
  36199. * Initializes the behavior
  36200. */
  36201. init(): void;
  36202. /**
  36203. * Attaches the scale behavior the passed in mesh
  36204. * @param ownerNode The mesh that will be scaled around once attached
  36205. */
  36206. attach(ownerNode: Mesh): void;
  36207. /**
  36208. * Detaches the behavior from the mesh
  36209. */
  36210. detach(): void;
  36211. }
  36212. }
  36213. declare module BABYLON {
  36214. /**
  36215. * Class used to apply inverse kinematics to bones
  36216. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36217. */
  36218. export class BoneIKController {
  36219. private static _tmpVecs;
  36220. private static _tmpQuat;
  36221. private static _tmpMats;
  36222. /**
  36223. * Gets or sets the target mesh
  36224. */
  36225. targetMesh: AbstractMesh;
  36226. /** Gets or sets the mesh used as pole */
  36227. poleTargetMesh: AbstractMesh;
  36228. /**
  36229. * Gets or sets the bone used as pole
  36230. */
  36231. poleTargetBone: Nullable<Bone>;
  36232. /**
  36233. * Gets or sets the target position
  36234. */
  36235. targetPosition: Vector3;
  36236. /**
  36237. * Gets or sets the pole target position
  36238. */
  36239. poleTargetPosition: Vector3;
  36240. /**
  36241. * Gets or sets the pole target local offset
  36242. */
  36243. poleTargetLocalOffset: Vector3;
  36244. /**
  36245. * Gets or sets the pole angle
  36246. */
  36247. poleAngle: number;
  36248. /**
  36249. * Gets or sets the mesh associated with the controller
  36250. */
  36251. mesh: AbstractMesh;
  36252. /**
  36253. * 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)
  36254. */
  36255. slerpAmount: number;
  36256. private _bone1Quat;
  36257. private _bone1Mat;
  36258. private _bone2Ang;
  36259. private _bone1;
  36260. private _bone2;
  36261. private _bone1Length;
  36262. private _bone2Length;
  36263. private _maxAngle;
  36264. private _maxReach;
  36265. private _rightHandedSystem;
  36266. private _bendAxis;
  36267. private _slerping;
  36268. private _adjustRoll;
  36269. /**
  36270. * Gets or sets maximum allowed angle
  36271. */
  36272. maxAngle: number;
  36273. /**
  36274. * Creates a new BoneIKController
  36275. * @param mesh defines the mesh to control
  36276. * @param bone defines the bone to control
  36277. * @param options defines options to set up the controller
  36278. */
  36279. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36280. targetMesh?: AbstractMesh;
  36281. poleTargetMesh?: AbstractMesh;
  36282. poleTargetBone?: Bone;
  36283. poleTargetLocalOffset?: Vector3;
  36284. poleAngle?: number;
  36285. bendAxis?: Vector3;
  36286. maxAngle?: number;
  36287. slerpAmount?: number;
  36288. });
  36289. private _setMaxAngle;
  36290. /**
  36291. * Force the controller to update the bones
  36292. */
  36293. update(): void;
  36294. }
  36295. }
  36296. declare module BABYLON {
  36297. /**
  36298. * Class used to make a bone look toward a point in space
  36299. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36300. */
  36301. export class BoneLookController {
  36302. private static _tmpVecs;
  36303. private static _tmpQuat;
  36304. private static _tmpMats;
  36305. /**
  36306. * The target Vector3 that the bone will look at
  36307. */
  36308. target: Vector3;
  36309. /**
  36310. * The mesh that the bone is attached to
  36311. */
  36312. mesh: AbstractMesh;
  36313. /**
  36314. * The bone that will be looking to the target
  36315. */
  36316. bone: Bone;
  36317. /**
  36318. * The up axis of the coordinate system that is used when the bone is rotated
  36319. */
  36320. upAxis: Vector3;
  36321. /**
  36322. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36323. */
  36324. upAxisSpace: Space;
  36325. /**
  36326. * Used to make an adjustment to the yaw of the bone
  36327. */
  36328. adjustYaw: number;
  36329. /**
  36330. * Used to make an adjustment to the pitch of the bone
  36331. */
  36332. adjustPitch: number;
  36333. /**
  36334. * Used to make an adjustment to the roll of the bone
  36335. */
  36336. adjustRoll: number;
  36337. /**
  36338. * 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)
  36339. */
  36340. slerpAmount: number;
  36341. private _minYaw;
  36342. private _maxYaw;
  36343. private _minPitch;
  36344. private _maxPitch;
  36345. private _minYawSin;
  36346. private _minYawCos;
  36347. private _maxYawSin;
  36348. private _maxYawCos;
  36349. private _midYawConstraint;
  36350. private _minPitchTan;
  36351. private _maxPitchTan;
  36352. private _boneQuat;
  36353. private _slerping;
  36354. private _transformYawPitch;
  36355. private _transformYawPitchInv;
  36356. private _firstFrameSkipped;
  36357. private _yawRange;
  36358. private _fowardAxis;
  36359. /**
  36360. * Gets or sets the minimum yaw angle that the bone can look to
  36361. */
  36362. minYaw: number;
  36363. /**
  36364. * Gets or sets the maximum yaw angle that the bone can look to
  36365. */
  36366. maxYaw: number;
  36367. /**
  36368. * Gets or sets the minimum pitch angle that the bone can look to
  36369. */
  36370. minPitch: number;
  36371. /**
  36372. * Gets or sets the maximum pitch angle that the bone can look to
  36373. */
  36374. maxPitch: number;
  36375. /**
  36376. * Create a BoneLookController
  36377. * @param mesh the mesh that the bone belongs to
  36378. * @param bone the bone that will be looking to the target
  36379. * @param target the target Vector3 to look at
  36380. * @param options optional settings:
  36381. * * maxYaw: the maximum angle the bone will yaw to
  36382. * * minYaw: the minimum angle the bone will yaw to
  36383. * * maxPitch: the maximum angle the bone will pitch to
  36384. * * minPitch: the minimum angle the bone will yaw to
  36385. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36386. * * upAxis: the up axis of the coordinate system
  36387. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36388. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36389. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36390. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36391. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36392. * * adjustRoll: used to make an adjustment to the roll of the bone
  36393. **/
  36394. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36395. maxYaw?: number;
  36396. minYaw?: number;
  36397. maxPitch?: number;
  36398. minPitch?: number;
  36399. slerpAmount?: number;
  36400. upAxis?: Vector3;
  36401. upAxisSpace?: Space;
  36402. yawAxis?: Vector3;
  36403. pitchAxis?: Vector3;
  36404. adjustYaw?: number;
  36405. adjustPitch?: number;
  36406. adjustRoll?: number;
  36407. });
  36408. /**
  36409. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36410. */
  36411. update(): void;
  36412. private _getAngleDiff;
  36413. private _getAngleBetween;
  36414. private _isAngleBetween;
  36415. }
  36416. }
  36417. declare module BABYLON {
  36418. /**
  36419. * Manage the gamepad inputs to control an arc rotate camera.
  36420. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36421. */
  36422. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36423. /**
  36424. * Defines the camera the input is attached to.
  36425. */
  36426. camera: ArcRotateCamera;
  36427. /**
  36428. * Defines the gamepad the input is gathering event from.
  36429. */
  36430. gamepad: Nullable<Gamepad>;
  36431. /**
  36432. * Defines the gamepad rotation sensiblity.
  36433. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36434. */
  36435. gamepadRotationSensibility: number;
  36436. /**
  36437. * Defines the gamepad move sensiblity.
  36438. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36439. */
  36440. gamepadMoveSensibility: number;
  36441. private _onGamepadConnectedObserver;
  36442. private _onGamepadDisconnectedObserver;
  36443. /**
  36444. * Attach the input controls to a specific dom element to get the input from.
  36445. * @param element Defines the element the controls should be listened from
  36446. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36447. */
  36448. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36449. /**
  36450. * Detach the current controls from the specified dom element.
  36451. * @param element Defines the element to stop listening the inputs from
  36452. */
  36453. detachControl(element: Nullable<HTMLElement>): void;
  36454. /**
  36455. * Update the current camera state depending on the inputs that have been used this frame.
  36456. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36457. */
  36458. checkInputs(): void;
  36459. /**
  36460. * Gets the class name of the current intput.
  36461. * @returns the class name
  36462. */
  36463. getClassName(): string;
  36464. /**
  36465. * Get the friendly name associated with the input class.
  36466. * @returns the input friendly name
  36467. */
  36468. getSimpleName(): string;
  36469. }
  36470. }
  36471. declare module BABYLON {
  36472. interface ArcRotateCameraInputsManager {
  36473. /**
  36474. * Add orientation input support to the input manager.
  36475. * @returns the current input manager
  36476. */
  36477. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36478. }
  36479. /**
  36480. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36481. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36482. */
  36483. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36484. /**
  36485. * Defines the camera the input is attached to.
  36486. */
  36487. camera: ArcRotateCamera;
  36488. /**
  36489. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36490. */
  36491. alphaCorrection: number;
  36492. /**
  36493. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36494. */
  36495. gammaCorrection: number;
  36496. private _alpha;
  36497. private _gamma;
  36498. private _dirty;
  36499. private _deviceOrientationHandler;
  36500. /**
  36501. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36502. */
  36503. constructor();
  36504. /**
  36505. * Attach the input controls to a specific dom element to get the input from.
  36506. * @param element Defines the element the controls should be listened from
  36507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36508. */
  36509. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36510. /** @hidden */
  36511. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36512. /**
  36513. * Update the current camera state depending on the inputs that have been used this frame.
  36514. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36515. */
  36516. checkInputs(): void;
  36517. /**
  36518. * Detach the current controls from the specified dom element.
  36519. * @param element Defines the element to stop listening the inputs from
  36520. */
  36521. detachControl(element: Nullable<HTMLElement>): void;
  36522. /**
  36523. * Gets the class name of the current intput.
  36524. * @returns the class name
  36525. */
  36526. getClassName(): string;
  36527. /**
  36528. * Get the friendly name associated with the input class.
  36529. * @returns the input friendly name
  36530. */
  36531. getSimpleName(): string;
  36532. }
  36533. }
  36534. declare module BABYLON {
  36535. /**
  36536. * Listen to mouse events to control the camera.
  36537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36538. */
  36539. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36540. /**
  36541. * Defines the camera the input is attached to.
  36542. */
  36543. camera: FlyCamera;
  36544. /**
  36545. * Defines if touch is enabled. (Default is true.)
  36546. */
  36547. touchEnabled: boolean;
  36548. /**
  36549. * Defines the buttons associated with the input to handle camera rotation.
  36550. */
  36551. buttons: number[];
  36552. /**
  36553. * Assign buttons for Yaw control.
  36554. */
  36555. buttonsYaw: number[];
  36556. /**
  36557. * Assign buttons for Pitch control.
  36558. */
  36559. buttonsPitch: number[];
  36560. /**
  36561. * Assign buttons for Roll control.
  36562. */
  36563. buttonsRoll: number[];
  36564. /**
  36565. * Detect if any button is being pressed while mouse is moved.
  36566. * -1 = Mouse locked.
  36567. * 0 = Left button.
  36568. * 1 = Middle Button.
  36569. * 2 = Right Button.
  36570. */
  36571. activeButton: number;
  36572. /**
  36573. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36574. * Higher values reduce its sensitivity.
  36575. */
  36576. angularSensibility: number;
  36577. private _mousemoveCallback;
  36578. private _observer;
  36579. private _rollObserver;
  36580. private previousPosition;
  36581. private noPreventDefault;
  36582. private element;
  36583. /**
  36584. * Listen to mouse events to control the camera.
  36585. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36586. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36587. */
  36588. constructor(touchEnabled?: boolean);
  36589. /**
  36590. * Attach the mouse control to the HTML DOM element.
  36591. * @param element Defines the element that listens to the input events.
  36592. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36593. */
  36594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36595. /**
  36596. * Detach the current controls from the specified dom element.
  36597. * @param element Defines the element to stop listening the inputs from
  36598. */
  36599. detachControl(element: Nullable<HTMLElement>): void;
  36600. /**
  36601. * Gets the class name of the current input.
  36602. * @returns the class name.
  36603. */
  36604. getClassName(): string;
  36605. /**
  36606. * Get the friendly name associated with the input class.
  36607. * @returns the input's friendly name.
  36608. */
  36609. getSimpleName(): string;
  36610. private _pointerInput;
  36611. private _onMouseMove;
  36612. /**
  36613. * Rotate camera by mouse offset.
  36614. */
  36615. private rotateCamera;
  36616. }
  36617. }
  36618. declare module BABYLON {
  36619. /**
  36620. * Default Inputs manager for the FlyCamera.
  36621. * It groups all the default supported inputs for ease of use.
  36622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36623. */
  36624. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36625. /**
  36626. * Instantiates a new FlyCameraInputsManager.
  36627. * @param camera Defines the camera the inputs belong to.
  36628. */
  36629. constructor(camera: FlyCamera);
  36630. /**
  36631. * Add keyboard input support to the input manager.
  36632. * @returns the new FlyCameraKeyboardMoveInput().
  36633. */
  36634. addKeyboard(): FlyCameraInputsManager;
  36635. /**
  36636. * Add mouse input support to the input manager.
  36637. * @param touchEnabled Enable touch screen support.
  36638. * @returns the new FlyCameraMouseInput().
  36639. */
  36640. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36641. }
  36642. }
  36643. declare module BABYLON {
  36644. /**
  36645. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36646. * such as in a 3D Space Shooter or a Flight Simulator.
  36647. */
  36648. export class FlyCamera extends TargetCamera {
  36649. /**
  36650. * Define the collision ellipsoid of the camera.
  36651. * This is helpful for simulating a camera body, like a player's body.
  36652. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36653. */
  36654. ellipsoid: Vector3;
  36655. /**
  36656. * Define an offset for the position of the ellipsoid around the camera.
  36657. * This can be helpful if the camera is attached away from the player's body center,
  36658. * such as at its head.
  36659. */
  36660. ellipsoidOffset: Vector3;
  36661. /**
  36662. * Enable or disable collisions of the camera with the rest of the scene objects.
  36663. */
  36664. checkCollisions: boolean;
  36665. /**
  36666. * Enable or disable gravity on the camera.
  36667. */
  36668. applyGravity: boolean;
  36669. /**
  36670. * Define the current direction the camera is moving to.
  36671. */
  36672. cameraDirection: Vector3;
  36673. /**
  36674. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36675. * This overrides and empties cameraRotation.
  36676. */
  36677. rotationQuaternion: Quaternion;
  36678. /**
  36679. * Track Roll to maintain the wanted Rolling when looking around.
  36680. */
  36681. _trackRoll: number;
  36682. /**
  36683. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36684. */
  36685. rollCorrect: number;
  36686. /**
  36687. * Mimic a banked turn, Rolling the camera when Yawing.
  36688. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36689. */
  36690. bankedTurn: boolean;
  36691. /**
  36692. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36693. */
  36694. bankedTurnLimit: number;
  36695. /**
  36696. * Value of 0 disables the banked Roll.
  36697. * Value of 1 is equal to the Yaw angle in radians.
  36698. */
  36699. bankedTurnMultiplier: number;
  36700. /**
  36701. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36702. */
  36703. inputs: FlyCameraInputsManager;
  36704. /**
  36705. * Gets the input sensibility for mouse input.
  36706. * Higher values reduce sensitivity.
  36707. */
  36708. /**
  36709. * Sets the input sensibility for a mouse input.
  36710. * Higher values reduce sensitivity.
  36711. */
  36712. angularSensibility: number;
  36713. /**
  36714. * Get the keys for camera movement forward.
  36715. */
  36716. /**
  36717. * Set the keys for camera movement forward.
  36718. */
  36719. keysForward: number[];
  36720. /**
  36721. * Get the keys for camera movement backward.
  36722. */
  36723. keysBackward: number[];
  36724. /**
  36725. * Get the keys for camera movement up.
  36726. */
  36727. /**
  36728. * Set the keys for camera movement up.
  36729. */
  36730. keysUp: number[];
  36731. /**
  36732. * Get the keys for camera movement down.
  36733. */
  36734. /**
  36735. * Set the keys for camera movement down.
  36736. */
  36737. keysDown: number[];
  36738. /**
  36739. * Get the keys for camera movement left.
  36740. */
  36741. /**
  36742. * Set the keys for camera movement left.
  36743. */
  36744. keysLeft: number[];
  36745. /**
  36746. * Set the keys for camera movement right.
  36747. */
  36748. /**
  36749. * Set the keys for camera movement right.
  36750. */
  36751. keysRight: number[];
  36752. /**
  36753. * Event raised when the camera collides with a mesh in the scene.
  36754. */
  36755. onCollide: (collidedMesh: AbstractMesh) => void;
  36756. private _collider;
  36757. private _needMoveForGravity;
  36758. private _oldPosition;
  36759. private _diffPosition;
  36760. private _newPosition;
  36761. /** @hidden */
  36762. _localDirection: Vector3;
  36763. /** @hidden */
  36764. _transformedDirection: Vector3;
  36765. /**
  36766. * Instantiates a FlyCamera.
  36767. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36768. * such as in a 3D Space Shooter or a Flight Simulator.
  36769. * @param name Define the name of the camera in the scene.
  36770. * @param position Define the starting position of the camera in the scene.
  36771. * @param scene Define the scene the camera belongs to.
  36772. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36773. */
  36774. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36775. /**
  36776. * Attach a control to the HTML DOM element.
  36777. * @param element Defines the element that listens to the input events.
  36778. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36779. */
  36780. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36781. /**
  36782. * Detach a control from the HTML DOM element.
  36783. * The camera will stop reacting to that input.
  36784. * @param element Defines the element that listens to the input events.
  36785. */
  36786. detachControl(element: HTMLElement): void;
  36787. private _collisionMask;
  36788. /**
  36789. * Get the mask that the camera ignores in collision events.
  36790. */
  36791. /**
  36792. * Set the mask that the camera ignores in collision events.
  36793. */
  36794. collisionMask: number;
  36795. /** @hidden */
  36796. _collideWithWorld(displacement: Vector3): void;
  36797. /** @hidden */
  36798. private _onCollisionPositionChange;
  36799. /** @hidden */
  36800. _checkInputs(): void;
  36801. /** @hidden */
  36802. _decideIfNeedsToMove(): boolean;
  36803. /** @hidden */
  36804. _updatePosition(): void;
  36805. /**
  36806. * Restore the Roll to its target value at the rate specified.
  36807. * @param rate - Higher means slower restoring.
  36808. * @hidden
  36809. */
  36810. restoreRoll(rate: number): void;
  36811. /**
  36812. * Destroy the camera and release the current resources held by it.
  36813. */
  36814. dispose(): void;
  36815. /**
  36816. * Get the current object class name.
  36817. * @returns the class name.
  36818. */
  36819. getClassName(): string;
  36820. }
  36821. }
  36822. declare module BABYLON {
  36823. /**
  36824. * Listen to keyboard events to control the camera.
  36825. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36826. */
  36827. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36828. /**
  36829. * Defines the camera the input is attached to.
  36830. */
  36831. camera: FlyCamera;
  36832. /**
  36833. * The list of keyboard keys used to control the forward move of the camera.
  36834. */
  36835. keysForward: number[];
  36836. /**
  36837. * The list of keyboard keys used to control the backward move of the camera.
  36838. */
  36839. keysBackward: number[];
  36840. /**
  36841. * The list of keyboard keys used to control the forward move of the camera.
  36842. */
  36843. keysUp: number[];
  36844. /**
  36845. * The list of keyboard keys used to control the backward move of the camera.
  36846. */
  36847. keysDown: number[];
  36848. /**
  36849. * The list of keyboard keys used to control the right strafe move of the camera.
  36850. */
  36851. keysRight: number[];
  36852. /**
  36853. * The list of keyboard keys used to control the left strafe move of the camera.
  36854. */
  36855. keysLeft: number[];
  36856. private _keys;
  36857. private _onCanvasBlurObserver;
  36858. private _onKeyboardObserver;
  36859. private _engine;
  36860. private _scene;
  36861. /**
  36862. * Attach the input controls to a specific dom element to get the input from.
  36863. * @param element Defines the element the controls should be listened from
  36864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36865. */
  36866. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36867. /**
  36868. * Detach the current controls from the specified dom element.
  36869. * @param element Defines the element to stop listening the inputs from
  36870. */
  36871. detachControl(element: Nullable<HTMLElement>): void;
  36872. /**
  36873. * Gets the class name of the current intput.
  36874. * @returns the class name
  36875. */
  36876. getClassName(): string;
  36877. /** @hidden */
  36878. _onLostFocus(e: FocusEvent): void;
  36879. /**
  36880. * Get the friendly name associated with the input class.
  36881. * @returns the input friendly name
  36882. */
  36883. getSimpleName(): string;
  36884. /**
  36885. * Update the current camera state depending on the inputs that have been used this frame.
  36886. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36887. */
  36888. checkInputs(): void;
  36889. }
  36890. }
  36891. declare module BABYLON {
  36892. /**
  36893. * Manage the mouse wheel inputs to control a follow camera.
  36894. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36895. */
  36896. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36897. /**
  36898. * Defines the camera the input is attached to.
  36899. */
  36900. camera: FollowCamera;
  36901. /**
  36902. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36903. */
  36904. axisControlRadius: boolean;
  36905. /**
  36906. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36907. */
  36908. axisControlHeight: boolean;
  36909. /**
  36910. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36911. */
  36912. axisControlRotation: boolean;
  36913. /**
  36914. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36915. * relation to mouseWheel events.
  36916. */
  36917. wheelPrecision: number;
  36918. /**
  36919. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36920. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36921. */
  36922. wheelDeltaPercentage: number;
  36923. private _wheel;
  36924. private _observer;
  36925. /**
  36926. * Attach the input controls to a specific dom element to get the input from.
  36927. * @param element Defines the element the controls should be listened from
  36928. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36929. */
  36930. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36931. /**
  36932. * Detach the current controls from the specified dom element.
  36933. * @param element Defines the element to stop listening the inputs from
  36934. */
  36935. detachControl(element: Nullable<HTMLElement>): void;
  36936. /**
  36937. * Gets the class name of the current intput.
  36938. * @returns the class name
  36939. */
  36940. getClassName(): string;
  36941. /**
  36942. * Get the friendly name associated with the input class.
  36943. * @returns the input friendly name
  36944. */
  36945. getSimpleName(): string;
  36946. }
  36947. }
  36948. declare module BABYLON {
  36949. /**
  36950. * Manage the pointers inputs to control an follow camera.
  36951. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36952. */
  36953. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36954. /**
  36955. * Defines the camera the input is attached to.
  36956. */
  36957. camera: FollowCamera;
  36958. /**
  36959. * Gets the class name of the current input.
  36960. * @returns the class name
  36961. */
  36962. getClassName(): string;
  36963. /**
  36964. * Defines the pointer angular sensibility along the X axis or how fast is
  36965. * the camera rotating.
  36966. * A negative number will reverse the axis direction.
  36967. */
  36968. angularSensibilityX: number;
  36969. /**
  36970. * Defines the pointer angular sensibility along the Y axis or how fast is
  36971. * the camera rotating.
  36972. * A negative number will reverse the axis direction.
  36973. */
  36974. angularSensibilityY: number;
  36975. /**
  36976. * Defines the pointer pinch precision or how fast is the camera zooming.
  36977. * A negative number will reverse the axis direction.
  36978. */
  36979. pinchPrecision: number;
  36980. /**
  36981. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36982. * from 0.
  36983. * It defines the percentage of current camera.radius to use as delta when
  36984. * pinch zoom is used.
  36985. */
  36986. pinchDeltaPercentage: number;
  36987. /**
  36988. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36989. */
  36990. axisXControlRadius: boolean;
  36991. /**
  36992. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36993. */
  36994. axisXControlHeight: boolean;
  36995. /**
  36996. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36997. */
  36998. axisXControlRotation: boolean;
  36999. /**
  37000. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37001. */
  37002. axisYControlRadius: boolean;
  37003. /**
  37004. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37005. */
  37006. axisYControlHeight: boolean;
  37007. /**
  37008. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37009. */
  37010. axisYControlRotation: boolean;
  37011. /**
  37012. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37013. */
  37014. axisPinchControlRadius: boolean;
  37015. /**
  37016. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37017. */
  37018. axisPinchControlHeight: boolean;
  37019. /**
  37020. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37021. */
  37022. axisPinchControlRotation: boolean;
  37023. /**
  37024. * Log error messages if basic misconfiguration has occurred.
  37025. */
  37026. warningEnable: boolean;
  37027. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37028. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37029. private _warningCounter;
  37030. private _warning;
  37031. }
  37032. }
  37033. declare module BABYLON {
  37034. /**
  37035. * Default Inputs manager for the FollowCamera.
  37036. * It groups all the default supported inputs for ease of use.
  37037. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37038. */
  37039. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37040. /**
  37041. * Instantiates a new FollowCameraInputsManager.
  37042. * @param camera Defines the camera the inputs belong to
  37043. */
  37044. constructor(camera: FollowCamera);
  37045. /**
  37046. * Add keyboard input support to the input manager.
  37047. * @returns the current input manager
  37048. */
  37049. addKeyboard(): FollowCameraInputsManager;
  37050. /**
  37051. * Add mouse wheel input support to the input manager.
  37052. * @returns the current input manager
  37053. */
  37054. addMouseWheel(): FollowCameraInputsManager;
  37055. /**
  37056. * Add pointers input support to the input manager.
  37057. * @returns the current input manager
  37058. */
  37059. addPointers(): FollowCameraInputsManager;
  37060. /**
  37061. * Add orientation input support to the input manager.
  37062. * @returns the current input manager
  37063. */
  37064. addVRDeviceOrientation(): FollowCameraInputsManager;
  37065. }
  37066. }
  37067. declare module BABYLON {
  37068. /**
  37069. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37070. * an arc rotate version arcFollowCamera are available.
  37071. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37072. */
  37073. export class FollowCamera extends TargetCamera {
  37074. /**
  37075. * Distance the follow camera should follow an object at
  37076. */
  37077. radius: number;
  37078. /**
  37079. * Minimum allowed distance of the camera to the axis of rotation
  37080. * (The camera can not get closer).
  37081. * This can help limiting how the Camera is able to move in the scene.
  37082. */
  37083. lowerRadiusLimit: Nullable<number>;
  37084. /**
  37085. * Maximum allowed distance of the camera to the axis of rotation
  37086. * (The camera can not get further).
  37087. * This can help limiting how the Camera is able to move in the scene.
  37088. */
  37089. upperRadiusLimit: Nullable<number>;
  37090. /**
  37091. * Define a rotation offset between the camera and the object it follows
  37092. */
  37093. rotationOffset: number;
  37094. /**
  37095. * Minimum allowed angle to camera position relative to target object.
  37096. * This can help limiting how the Camera is able to move in the scene.
  37097. */
  37098. lowerRotationOffsetLimit: Nullable<number>;
  37099. /**
  37100. * Maximum allowed angle to camera position relative to target object.
  37101. * This can help limiting how the Camera is able to move in the scene.
  37102. */
  37103. upperRotationOffsetLimit: Nullable<number>;
  37104. /**
  37105. * Define a height offset between the camera and the object it follows.
  37106. * It can help following an object from the top (like a car chaing a plane)
  37107. */
  37108. heightOffset: number;
  37109. /**
  37110. * Minimum allowed height of camera position relative to target object.
  37111. * This can help limiting how the Camera is able to move in the scene.
  37112. */
  37113. lowerHeightOffsetLimit: Nullable<number>;
  37114. /**
  37115. * Maximum allowed height of camera position relative to target object.
  37116. * This can help limiting how the Camera is able to move in the scene.
  37117. */
  37118. upperHeightOffsetLimit: Nullable<number>;
  37119. /**
  37120. * Define how fast the camera can accelerate to follow it s target.
  37121. */
  37122. cameraAcceleration: number;
  37123. /**
  37124. * Define the speed limit of the camera following an object.
  37125. */
  37126. maxCameraSpeed: number;
  37127. /**
  37128. * Define the target of the camera.
  37129. */
  37130. lockedTarget: Nullable<AbstractMesh>;
  37131. /**
  37132. * Defines the input associated with the camera.
  37133. */
  37134. inputs: FollowCameraInputsManager;
  37135. /**
  37136. * Instantiates the follow camera.
  37137. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37138. * @param name Define the name of the camera in the scene
  37139. * @param position Define the position of the camera
  37140. * @param scene Define the scene the camera belong to
  37141. * @param lockedTarget Define the target of the camera
  37142. */
  37143. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37144. private _follow;
  37145. /**
  37146. * Attached controls to the current camera.
  37147. * @param element Defines the element the controls should be listened from
  37148. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37149. */
  37150. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37151. /**
  37152. * Detach the current controls from the camera.
  37153. * The camera will stop reacting to inputs.
  37154. * @param element Defines the element to stop listening the inputs from
  37155. */
  37156. detachControl(element: HTMLElement): void;
  37157. /** @hidden */
  37158. _checkInputs(): void;
  37159. private _checkLimits;
  37160. /**
  37161. * Gets the camera class name.
  37162. * @returns the class name
  37163. */
  37164. getClassName(): string;
  37165. }
  37166. /**
  37167. * Arc Rotate version of the follow camera.
  37168. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37169. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37170. */
  37171. export class ArcFollowCamera extends TargetCamera {
  37172. /** The longitudinal angle of the camera */
  37173. alpha: number;
  37174. /** The latitudinal angle of the camera */
  37175. beta: number;
  37176. /** The radius of the camera from its target */
  37177. radius: number;
  37178. /** Define the camera target (the messh it should follow) */
  37179. target: Nullable<AbstractMesh>;
  37180. private _cartesianCoordinates;
  37181. /**
  37182. * Instantiates a new ArcFollowCamera
  37183. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37184. * @param name Define the name of the camera
  37185. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37186. * @param beta Define the rotation angle of the camera around the elevation axis
  37187. * @param radius Define the radius of the camera from its target point
  37188. * @param target Define the target of the camera
  37189. * @param scene Define the scene the camera belongs to
  37190. */
  37191. constructor(name: string,
  37192. /** The longitudinal angle of the camera */
  37193. alpha: number,
  37194. /** The latitudinal angle of the camera */
  37195. beta: number,
  37196. /** The radius of the camera from its target */
  37197. radius: number,
  37198. /** Define the camera target (the messh it should follow) */
  37199. target: Nullable<AbstractMesh>, scene: Scene);
  37200. private _follow;
  37201. /** @hidden */
  37202. _checkInputs(): void;
  37203. /**
  37204. * Returns the class name of the object.
  37205. * It is mostly used internally for serialization purposes.
  37206. */
  37207. getClassName(): string;
  37208. }
  37209. }
  37210. declare module BABYLON {
  37211. /**
  37212. * Manage the keyboard inputs to control the movement of a follow camera.
  37213. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37214. */
  37215. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37216. /**
  37217. * Defines the camera the input is attached to.
  37218. */
  37219. camera: FollowCamera;
  37220. /**
  37221. * Defines the list of key codes associated with the up action (increase heightOffset)
  37222. */
  37223. keysHeightOffsetIncr: number[];
  37224. /**
  37225. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37226. */
  37227. keysHeightOffsetDecr: number[];
  37228. /**
  37229. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37230. */
  37231. keysHeightOffsetModifierAlt: boolean;
  37232. /**
  37233. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37234. */
  37235. keysHeightOffsetModifierCtrl: boolean;
  37236. /**
  37237. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37238. */
  37239. keysHeightOffsetModifierShift: boolean;
  37240. /**
  37241. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37242. */
  37243. keysRotationOffsetIncr: number[];
  37244. /**
  37245. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37246. */
  37247. keysRotationOffsetDecr: number[];
  37248. /**
  37249. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37250. */
  37251. keysRotationOffsetModifierAlt: boolean;
  37252. /**
  37253. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37254. */
  37255. keysRotationOffsetModifierCtrl: boolean;
  37256. /**
  37257. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37258. */
  37259. keysRotationOffsetModifierShift: boolean;
  37260. /**
  37261. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37262. */
  37263. keysRadiusIncr: number[];
  37264. /**
  37265. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37266. */
  37267. keysRadiusDecr: number[];
  37268. /**
  37269. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37270. */
  37271. keysRadiusModifierAlt: boolean;
  37272. /**
  37273. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37274. */
  37275. keysRadiusModifierCtrl: boolean;
  37276. /**
  37277. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37278. */
  37279. keysRadiusModifierShift: boolean;
  37280. /**
  37281. * Defines the rate of change of heightOffset.
  37282. */
  37283. heightSensibility: number;
  37284. /**
  37285. * Defines the rate of change of rotationOffset.
  37286. */
  37287. rotationSensibility: number;
  37288. /**
  37289. * Defines the rate of change of radius.
  37290. */
  37291. radiusSensibility: number;
  37292. private _keys;
  37293. private _ctrlPressed;
  37294. private _altPressed;
  37295. private _shiftPressed;
  37296. private _onCanvasBlurObserver;
  37297. private _onKeyboardObserver;
  37298. private _engine;
  37299. private _scene;
  37300. /**
  37301. * Attach the input controls to a specific dom element to get the input from.
  37302. * @param element Defines the element the controls should be listened from
  37303. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37304. */
  37305. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37306. /**
  37307. * Detach the current controls from the specified dom element.
  37308. * @param element Defines the element to stop listening the inputs from
  37309. */
  37310. detachControl(element: Nullable<HTMLElement>): void;
  37311. /**
  37312. * Update the current camera state depending on the inputs that have been used this frame.
  37313. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37314. */
  37315. checkInputs(): void;
  37316. /**
  37317. * Gets the class name of the current input.
  37318. * @returns the class name
  37319. */
  37320. getClassName(): string;
  37321. /**
  37322. * Get the friendly name associated with the input class.
  37323. * @returns the input friendly name
  37324. */
  37325. getSimpleName(): string;
  37326. /**
  37327. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37328. * allow modification of the heightOffset value.
  37329. */
  37330. private _modifierHeightOffset;
  37331. /**
  37332. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37333. * allow modification of the rotationOffset value.
  37334. */
  37335. private _modifierRotationOffset;
  37336. /**
  37337. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37338. * allow modification of the radius value.
  37339. */
  37340. private _modifierRadius;
  37341. }
  37342. }
  37343. declare module BABYLON {
  37344. interface FreeCameraInputsManager {
  37345. /**
  37346. * @hidden
  37347. */
  37348. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37349. /**
  37350. * Add orientation input support to the input manager.
  37351. * @returns the current input manager
  37352. */
  37353. addDeviceOrientation(): FreeCameraInputsManager;
  37354. }
  37355. /**
  37356. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37357. * Screen rotation is taken into account.
  37358. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37359. */
  37360. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37361. private _camera;
  37362. private _screenOrientationAngle;
  37363. private _constantTranform;
  37364. private _screenQuaternion;
  37365. private _alpha;
  37366. private _beta;
  37367. private _gamma;
  37368. /**
  37369. * @hidden
  37370. */
  37371. _onDeviceOrientationChangedObservable: Observable<void>;
  37372. /**
  37373. * Instantiates a new input
  37374. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37375. */
  37376. constructor();
  37377. /**
  37378. * Define the camera controlled by the input.
  37379. */
  37380. camera: FreeCamera;
  37381. /**
  37382. * Attach the input controls to a specific dom element to get the input from.
  37383. * @param element Defines the element the controls should be listened from
  37384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37385. */
  37386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37387. private _orientationChanged;
  37388. private _deviceOrientation;
  37389. /**
  37390. * Detach the current controls from the specified dom element.
  37391. * @param element Defines the element to stop listening the inputs from
  37392. */
  37393. detachControl(element: Nullable<HTMLElement>): void;
  37394. /**
  37395. * Update the current camera state depending on the inputs that have been used this frame.
  37396. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37397. */
  37398. checkInputs(): void;
  37399. /**
  37400. * Gets the class name of the current intput.
  37401. * @returns the class name
  37402. */
  37403. getClassName(): string;
  37404. /**
  37405. * Get the friendly name associated with the input class.
  37406. * @returns the input friendly name
  37407. */
  37408. getSimpleName(): string;
  37409. }
  37410. }
  37411. declare module BABYLON {
  37412. /**
  37413. * Manage the gamepad inputs to control a free camera.
  37414. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37415. */
  37416. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37417. /**
  37418. * Define the camera the input is attached to.
  37419. */
  37420. camera: FreeCamera;
  37421. /**
  37422. * Define the Gamepad controlling the input
  37423. */
  37424. gamepad: Nullable<Gamepad>;
  37425. /**
  37426. * Defines the gamepad rotation sensiblity.
  37427. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37428. */
  37429. gamepadAngularSensibility: number;
  37430. /**
  37431. * Defines the gamepad move sensiblity.
  37432. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37433. */
  37434. gamepadMoveSensibility: number;
  37435. private _onGamepadConnectedObserver;
  37436. private _onGamepadDisconnectedObserver;
  37437. private _cameraTransform;
  37438. private _deltaTransform;
  37439. private _vector3;
  37440. private _vector2;
  37441. /**
  37442. * Attach the input controls to a specific dom element to get the input from.
  37443. * @param element Defines the element the controls should be listened from
  37444. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37445. */
  37446. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37447. /**
  37448. * Detach the current controls from the specified dom element.
  37449. * @param element Defines the element to stop listening the inputs from
  37450. */
  37451. detachControl(element: Nullable<HTMLElement>): void;
  37452. /**
  37453. * Update the current camera state depending on the inputs that have been used this frame.
  37454. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37455. */
  37456. checkInputs(): void;
  37457. /**
  37458. * Gets the class name of the current intput.
  37459. * @returns the class name
  37460. */
  37461. getClassName(): string;
  37462. /**
  37463. * Get the friendly name associated with the input class.
  37464. * @returns the input friendly name
  37465. */
  37466. getSimpleName(): string;
  37467. }
  37468. }
  37469. declare module BABYLON {
  37470. /**
  37471. * Defines the potential axis of a Joystick
  37472. */
  37473. export enum JoystickAxis {
  37474. /** X axis */
  37475. X = 0,
  37476. /** Y axis */
  37477. Y = 1,
  37478. /** Z axis */
  37479. Z = 2
  37480. }
  37481. /**
  37482. * Class used to define virtual joystick (used in touch mode)
  37483. */
  37484. export class VirtualJoystick {
  37485. /**
  37486. * Gets or sets a boolean indicating that left and right values must be inverted
  37487. */
  37488. reverseLeftRight: boolean;
  37489. /**
  37490. * Gets or sets a boolean indicating that up and down values must be inverted
  37491. */
  37492. reverseUpDown: boolean;
  37493. /**
  37494. * Gets the offset value for the position (ie. the change of the position value)
  37495. */
  37496. deltaPosition: Vector3;
  37497. /**
  37498. * Gets a boolean indicating if the virtual joystick was pressed
  37499. */
  37500. pressed: boolean;
  37501. /**
  37502. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37503. */
  37504. static Canvas: Nullable<HTMLCanvasElement>;
  37505. private static _globalJoystickIndex;
  37506. private static vjCanvasContext;
  37507. private static vjCanvasWidth;
  37508. private static vjCanvasHeight;
  37509. private static halfWidth;
  37510. private _action;
  37511. private _axisTargetedByLeftAndRight;
  37512. private _axisTargetedByUpAndDown;
  37513. private _joystickSensibility;
  37514. private _inversedSensibility;
  37515. private _joystickPointerID;
  37516. private _joystickColor;
  37517. private _joystickPointerPos;
  37518. private _joystickPreviousPointerPos;
  37519. private _joystickPointerStartPos;
  37520. private _deltaJoystickVector;
  37521. private _leftJoystick;
  37522. private _touches;
  37523. private _onPointerDownHandlerRef;
  37524. private _onPointerMoveHandlerRef;
  37525. private _onPointerUpHandlerRef;
  37526. private _onResize;
  37527. /**
  37528. * Creates a new virtual joystick
  37529. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37530. */
  37531. constructor(leftJoystick?: boolean);
  37532. /**
  37533. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37534. * @param newJoystickSensibility defines the new sensibility
  37535. */
  37536. setJoystickSensibility(newJoystickSensibility: number): void;
  37537. private _onPointerDown;
  37538. private _onPointerMove;
  37539. private _onPointerUp;
  37540. /**
  37541. * Change the color of the virtual joystick
  37542. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37543. */
  37544. setJoystickColor(newColor: string): void;
  37545. /**
  37546. * Defines a callback to call when the joystick is touched
  37547. * @param action defines the callback
  37548. */
  37549. setActionOnTouch(action: () => any): void;
  37550. /**
  37551. * Defines which axis you'd like to control for left & right
  37552. * @param axis defines the axis to use
  37553. */
  37554. setAxisForLeftRight(axis: JoystickAxis): void;
  37555. /**
  37556. * Defines which axis you'd like to control for up & down
  37557. * @param axis defines the axis to use
  37558. */
  37559. setAxisForUpDown(axis: JoystickAxis): void;
  37560. private _drawVirtualJoystick;
  37561. /**
  37562. * Release internal HTML canvas
  37563. */
  37564. releaseCanvas(): void;
  37565. }
  37566. }
  37567. declare module BABYLON {
  37568. interface FreeCameraInputsManager {
  37569. /**
  37570. * Add virtual joystick input support to the input manager.
  37571. * @returns the current input manager
  37572. */
  37573. addVirtualJoystick(): FreeCameraInputsManager;
  37574. }
  37575. /**
  37576. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37577. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37578. */
  37579. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37580. /**
  37581. * Defines the camera the input is attached to.
  37582. */
  37583. camera: FreeCamera;
  37584. private _leftjoystick;
  37585. private _rightjoystick;
  37586. /**
  37587. * Gets the left stick of the virtual joystick.
  37588. * @returns The virtual Joystick
  37589. */
  37590. getLeftJoystick(): VirtualJoystick;
  37591. /**
  37592. * Gets the right stick of the virtual joystick.
  37593. * @returns The virtual Joystick
  37594. */
  37595. getRightJoystick(): VirtualJoystick;
  37596. /**
  37597. * Update the current camera state depending on the inputs that have been used this frame.
  37598. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37599. */
  37600. checkInputs(): void;
  37601. /**
  37602. * Attach the input controls to a specific dom element to get the input from.
  37603. * @param element Defines the element the controls should be listened from
  37604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37605. */
  37606. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37607. /**
  37608. * Detach the current controls from the specified dom element.
  37609. * @param element Defines the element to stop listening the inputs from
  37610. */
  37611. detachControl(element: Nullable<HTMLElement>): void;
  37612. /**
  37613. * Gets the class name of the current intput.
  37614. * @returns the class name
  37615. */
  37616. getClassName(): string;
  37617. /**
  37618. * Get the friendly name associated with the input class.
  37619. * @returns the input friendly name
  37620. */
  37621. getSimpleName(): string;
  37622. }
  37623. }
  37624. declare module BABYLON {
  37625. /**
  37626. * This represents a FPS type of camera controlled by touch.
  37627. * This is like a universal camera minus the Gamepad controls.
  37628. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37629. */
  37630. export class TouchCamera extends FreeCamera {
  37631. /**
  37632. * Defines the touch sensibility for rotation.
  37633. * The higher the faster.
  37634. */
  37635. touchAngularSensibility: number;
  37636. /**
  37637. * Defines the touch sensibility for move.
  37638. * The higher the faster.
  37639. */
  37640. touchMoveSensibility: number;
  37641. /**
  37642. * Instantiates a new touch camera.
  37643. * This represents a FPS type of camera controlled by touch.
  37644. * This is like a universal camera minus the Gamepad controls.
  37645. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37646. * @param name Define the name of the camera in the scene
  37647. * @param position Define the start position of the camera in the scene
  37648. * @param scene Define the scene the camera belongs to
  37649. */
  37650. constructor(name: string, position: Vector3, scene: Scene);
  37651. /**
  37652. * Gets the current object class name.
  37653. * @return the class name
  37654. */
  37655. getClassName(): string;
  37656. /** @hidden */
  37657. _setupInputs(): void;
  37658. }
  37659. }
  37660. declare module BABYLON {
  37661. /**
  37662. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37663. * being tilted forward or back and left or right.
  37664. */
  37665. export class DeviceOrientationCamera extends FreeCamera {
  37666. private _initialQuaternion;
  37667. private _quaternionCache;
  37668. private _tmpDragQuaternion;
  37669. /**
  37670. * Creates a new device orientation camera
  37671. * @param name The name of the camera
  37672. * @param position The start position camera
  37673. * @param scene The scene the camera belongs to
  37674. */
  37675. constructor(name: string, position: Vector3, scene: Scene);
  37676. /**
  37677. * @hidden
  37678. * Disabled pointer input on first orientation sensor update (Default: true)
  37679. */
  37680. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37681. private _dragFactor;
  37682. /**
  37683. * Enabled turning on the y axis when the orientation sensor is active
  37684. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37685. */
  37686. enableHorizontalDragging(dragFactor?: number): void;
  37687. /**
  37688. * Gets the current instance class name ("DeviceOrientationCamera").
  37689. * This helps avoiding instanceof at run time.
  37690. * @returns the class name
  37691. */
  37692. getClassName(): string;
  37693. /**
  37694. * @hidden
  37695. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37696. */
  37697. _checkInputs(): void;
  37698. /**
  37699. * Reset the camera to its default orientation on the specified axis only.
  37700. * @param axis The axis to reset
  37701. */
  37702. resetToCurrentRotation(axis?: Axis): void;
  37703. }
  37704. }
  37705. declare module BABYLON {
  37706. /**
  37707. * Defines supported buttons for XBox360 compatible gamepads
  37708. */
  37709. export enum Xbox360Button {
  37710. /** A */
  37711. A = 0,
  37712. /** B */
  37713. B = 1,
  37714. /** X */
  37715. X = 2,
  37716. /** Y */
  37717. Y = 3,
  37718. /** Start */
  37719. Start = 4,
  37720. /** Back */
  37721. Back = 5,
  37722. /** Left button */
  37723. LB = 6,
  37724. /** Right button */
  37725. RB = 7,
  37726. /** Left stick */
  37727. LeftStick = 8,
  37728. /** Right stick */
  37729. RightStick = 9
  37730. }
  37731. /** Defines values for XBox360 DPad */
  37732. export enum Xbox360Dpad {
  37733. /** Up */
  37734. Up = 0,
  37735. /** Down */
  37736. Down = 1,
  37737. /** Left */
  37738. Left = 2,
  37739. /** Right */
  37740. Right = 3
  37741. }
  37742. /**
  37743. * Defines a XBox360 gamepad
  37744. */
  37745. export class Xbox360Pad extends Gamepad {
  37746. private _leftTrigger;
  37747. private _rightTrigger;
  37748. private _onlefttriggerchanged;
  37749. private _onrighttriggerchanged;
  37750. private _onbuttondown;
  37751. private _onbuttonup;
  37752. private _ondpaddown;
  37753. private _ondpadup;
  37754. /** Observable raised when a button is pressed */
  37755. onButtonDownObservable: Observable<Xbox360Button>;
  37756. /** Observable raised when a button is released */
  37757. onButtonUpObservable: Observable<Xbox360Button>;
  37758. /** Observable raised when a pad is pressed */
  37759. onPadDownObservable: Observable<Xbox360Dpad>;
  37760. /** Observable raised when a pad is released */
  37761. onPadUpObservable: Observable<Xbox360Dpad>;
  37762. private _buttonA;
  37763. private _buttonB;
  37764. private _buttonX;
  37765. private _buttonY;
  37766. private _buttonBack;
  37767. private _buttonStart;
  37768. private _buttonLB;
  37769. private _buttonRB;
  37770. private _buttonLeftStick;
  37771. private _buttonRightStick;
  37772. private _dPadUp;
  37773. private _dPadDown;
  37774. private _dPadLeft;
  37775. private _dPadRight;
  37776. private _isXboxOnePad;
  37777. /**
  37778. * Creates a new XBox360 gamepad object
  37779. * @param id defines the id of this gamepad
  37780. * @param index defines its index
  37781. * @param gamepad defines the internal HTML gamepad object
  37782. * @param xboxOne defines if it is a XBox One gamepad
  37783. */
  37784. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37785. /**
  37786. * Defines the callback to call when left trigger is pressed
  37787. * @param callback defines the callback to use
  37788. */
  37789. onlefttriggerchanged(callback: (value: number) => void): void;
  37790. /**
  37791. * Defines the callback to call when right trigger is pressed
  37792. * @param callback defines the callback to use
  37793. */
  37794. onrighttriggerchanged(callback: (value: number) => void): void;
  37795. /**
  37796. * Gets the left trigger value
  37797. */
  37798. /**
  37799. * Sets the left trigger value
  37800. */
  37801. leftTrigger: number;
  37802. /**
  37803. * Gets the right trigger value
  37804. */
  37805. /**
  37806. * Sets the right trigger value
  37807. */
  37808. rightTrigger: number;
  37809. /**
  37810. * Defines the callback to call when a button is pressed
  37811. * @param callback defines the callback to use
  37812. */
  37813. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37814. /**
  37815. * Defines the callback to call when a button is released
  37816. * @param callback defines the callback to use
  37817. */
  37818. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37819. /**
  37820. * Defines the callback to call when a pad is pressed
  37821. * @param callback defines the callback to use
  37822. */
  37823. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37824. /**
  37825. * Defines the callback to call when a pad is released
  37826. * @param callback defines the callback to use
  37827. */
  37828. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37829. private _setButtonValue;
  37830. private _setDPadValue;
  37831. /**
  37832. * Gets the value of the `A` button
  37833. */
  37834. /**
  37835. * Sets the value of the `A` button
  37836. */
  37837. buttonA: number;
  37838. /**
  37839. * Gets the value of the `B` button
  37840. */
  37841. /**
  37842. * Sets the value of the `B` button
  37843. */
  37844. buttonB: number;
  37845. /**
  37846. * Gets the value of the `X` button
  37847. */
  37848. /**
  37849. * Sets the value of the `X` button
  37850. */
  37851. buttonX: number;
  37852. /**
  37853. * Gets the value of the `Y` button
  37854. */
  37855. /**
  37856. * Sets the value of the `Y` button
  37857. */
  37858. buttonY: number;
  37859. /**
  37860. * Gets the value of the `Start` button
  37861. */
  37862. /**
  37863. * Sets the value of the `Start` button
  37864. */
  37865. buttonStart: number;
  37866. /**
  37867. * Gets the value of the `Back` button
  37868. */
  37869. /**
  37870. * Sets the value of the `Back` button
  37871. */
  37872. buttonBack: number;
  37873. /**
  37874. * Gets the value of the `Left` button
  37875. */
  37876. /**
  37877. * Sets the value of the `Left` button
  37878. */
  37879. buttonLB: number;
  37880. /**
  37881. * Gets the value of the `Right` button
  37882. */
  37883. /**
  37884. * Sets the value of the `Right` button
  37885. */
  37886. buttonRB: number;
  37887. /**
  37888. * Gets the value of the Left joystick
  37889. */
  37890. /**
  37891. * Sets the value of the Left joystick
  37892. */
  37893. buttonLeftStick: number;
  37894. /**
  37895. * Gets the value of the Right joystick
  37896. */
  37897. /**
  37898. * Sets the value of the Right joystick
  37899. */
  37900. buttonRightStick: number;
  37901. /**
  37902. * Gets the value of D-pad up
  37903. */
  37904. /**
  37905. * Sets the value of D-pad up
  37906. */
  37907. dPadUp: number;
  37908. /**
  37909. * Gets the value of D-pad down
  37910. */
  37911. /**
  37912. * Sets the value of D-pad down
  37913. */
  37914. dPadDown: number;
  37915. /**
  37916. * Gets the value of D-pad left
  37917. */
  37918. /**
  37919. * Sets the value of D-pad left
  37920. */
  37921. dPadLeft: number;
  37922. /**
  37923. * Gets the value of D-pad right
  37924. */
  37925. /**
  37926. * Sets the value of D-pad right
  37927. */
  37928. dPadRight: number;
  37929. /**
  37930. * Force the gamepad to synchronize with device values
  37931. */
  37932. update(): void;
  37933. /**
  37934. * Disposes the gamepad
  37935. */
  37936. dispose(): void;
  37937. }
  37938. }
  37939. declare module BABYLON {
  37940. /**
  37941. * Manager for handling gamepads
  37942. */
  37943. export class GamepadManager {
  37944. private _scene?;
  37945. private _babylonGamepads;
  37946. private _oneGamepadConnected;
  37947. /** @hidden */
  37948. _isMonitoring: boolean;
  37949. private _gamepadEventSupported;
  37950. private _gamepadSupport;
  37951. /**
  37952. * observable to be triggered when the gamepad controller has been connected
  37953. */
  37954. onGamepadConnectedObservable: Observable<Gamepad>;
  37955. /**
  37956. * observable to be triggered when the gamepad controller has been disconnected
  37957. */
  37958. onGamepadDisconnectedObservable: Observable<Gamepad>;
  37959. private _onGamepadConnectedEvent;
  37960. private _onGamepadDisconnectedEvent;
  37961. /**
  37962. * Initializes the gamepad manager
  37963. * @param _scene BabylonJS scene
  37964. */
  37965. constructor(_scene?: Scene | undefined);
  37966. /**
  37967. * The gamepads in the game pad manager
  37968. */
  37969. readonly gamepads: Gamepad[];
  37970. /**
  37971. * Get the gamepad controllers based on type
  37972. * @param type The type of gamepad controller
  37973. * @returns Nullable gamepad
  37974. */
  37975. getGamepadByType(type?: number): Nullable<Gamepad>;
  37976. /**
  37977. * Disposes the gamepad manager
  37978. */
  37979. dispose(): void;
  37980. private _addNewGamepad;
  37981. private _startMonitoringGamepads;
  37982. private _stopMonitoringGamepads;
  37983. /** @hidden */
  37984. _checkGamepadsStatus(): void;
  37985. private _updateGamepadObjects;
  37986. }
  37987. }
  37988. declare module BABYLON {
  37989. interface Scene {
  37990. /** @hidden */
  37991. _gamepadManager: Nullable<GamepadManager>;
  37992. /**
  37993. * Gets the gamepad manager associated with the scene
  37994. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  37995. */
  37996. gamepadManager: GamepadManager;
  37997. }
  37998. /**
  37999. * Interface representing a free camera inputs manager
  38000. */
  38001. interface FreeCameraInputsManager {
  38002. /**
  38003. * Adds gamepad input support to the FreeCameraInputsManager.
  38004. * @returns the FreeCameraInputsManager
  38005. */
  38006. addGamepad(): FreeCameraInputsManager;
  38007. }
  38008. /**
  38009. * Interface representing an arc rotate camera inputs manager
  38010. */
  38011. interface ArcRotateCameraInputsManager {
  38012. /**
  38013. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38014. * @returns the camera inputs manager
  38015. */
  38016. addGamepad(): ArcRotateCameraInputsManager;
  38017. }
  38018. /**
  38019. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38020. */
  38021. export class GamepadSystemSceneComponent implements ISceneComponent {
  38022. /**
  38023. * The component name helpfull to identify the component in the list of scene components.
  38024. */
  38025. readonly name: string;
  38026. /**
  38027. * The scene the component belongs to.
  38028. */
  38029. scene: Scene;
  38030. /**
  38031. * Creates a new instance of the component for the given scene
  38032. * @param scene Defines the scene to register the component in
  38033. */
  38034. constructor(scene: Scene);
  38035. /**
  38036. * Registers the component in a given scene
  38037. */
  38038. register(): void;
  38039. /**
  38040. * Rebuilds the elements related to this component in case of
  38041. * context lost for instance.
  38042. */
  38043. rebuild(): void;
  38044. /**
  38045. * Disposes the component and the associated ressources
  38046. */
  38047. dispose(): void;
  38048. private _beforeCameraUpdate;
  38049. }
  38050. }
  38051. declare module BABYLON {
  38052. /**
  38053. * 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,
  38054. * which still works and will still be found in many Playgrounds.
  38055. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38056. */
  38057. export class UniversalCamera extends TouchCamera {
  38058. /**
  38059. * Defines the gamepad rotation sensiblity.
  38060. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38061. */
  38062. gamepadAngularSensibility: number;
  38063. /**
  38064. * Defines the gamepad move sensiblity.
  38065. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38066. */
  38067. gamepadMoveSensibility: number;
  38068. /**
  38069. * 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,
  38070. * which still works and will still be found in many Playgrounds.
  38071. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38072. * @param name Define the name of the camera in the scene
  38073. * @param position Define the start position of the camera in the scene
  38074. * @param scene Define the scene the camera belongs to
  38075. */
  38076. constructor(name: string, position: Vector3, scene: Scene);
  38077. /**
  38078. * Gets the current object class name.
  38079. * @return the class name
  38080. */
  38081. getClassName(): string;
  38082. }
  38083. }
  38084. declare module BABYLON {
  38085. /**
  38086. * This represents a FPS type of camera. This is only here for back compat purpose.
  38087. * Please use the UniversalCamera instead as both are identical.
  38088. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38089. */
  38090. export class GamepadCamera extends UniversalCamera {
  38091. /**
  38092. * Instantiates a new Gamepad Camera
  38093. * This represents a FPS type of camera. This is only here for back compat purpose.
  38094. * Please use the UniversalCamera instead as both are identical.
  38095. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38096. * @param name Define the name of the camera in the scene
  38097. * @param position Define the start position of the camera in the scene
  38098. * @param scene Define the scene the camera belongs to
  38099. */
  38100. constructor(name: string, position: Vector3, scene: Scene);
  38101. /**
  38102. * Gets the current object class name.
  38103. * @return the class name
  38104. */
  38105. getClassName(): string;
  38106. }
  38107. }
  38108. declare module BABYLON {
  38109. /** @hidden */
  38110. export var passPixelShader: {
  38111. name: string;
  38112. shader: string;
  38113. };
  38114. }
  38115. declare module BABYLON {
  38116. /** @hidden */
  38117. export var passCubePixelShader: {
  38118. name: string;
  38119. shader: string;
  38120. };
  38121. }
  38122. declare module BABYLON {
  38123. /**
  38124. * PassPostProcess which produces an output the same as it's input
  38125. */
  38126. export class PassPostProcess extends PostProcess {
  38127. /**
  38128. * Creates the PassPostProcess
  38129. * @param name The name of the effect.
  38130. * @param options The required width/height ratio to downsize to before computing the render pass.
  38131. * @param camera The camera to apply the render pass to.
  38132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38133. * @param engine The engine which the post process will be applied. (default: current engine)
  38134. * @param reusable If the post process can be reused on the same frame. (default: false)
  38135. * @param textureType The type of texture to be used when performing the post processing.
  38136. * @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)
  38137. */
  38138. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38139. }
  38140. /**
  38141. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38142. */
  38143. export class PassCubePostProcess extends PostProcess {
  38144. private _face;
  38145. /**
  38146. * Gets or sets the cube face to display.
  38147. * * 0 is +X
  38148. * * 1 is -X
  38149. * * 2 is +Y
  38150. * * 3 is -Y
  38151. * * 4 is +Z
  38152. * * 5 is -Z
  38153. */
  38154. face: number;
  38155. /**
  38156. * Creates the PassCubePostProcess
  38157. * @param name The name of the effect.
  38158. * @param options The required width/height ratio to downsize to before computing the render pass.
  38159. * @param camera The camera to apply the render pass to.
  38160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38161. * @param engine The engine which the post process will be applied. (default: current engine)
  38162. * @param reusable If the post process can be reused on the same frame. (default: false)
  38163. * @param textureType The type of texture to be used when performing the post processing.
  38164. * @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)
  38165. */
  38166. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38167. }
  38168. }
  38169. declare module BABYLON {
  38170. /** @hidden */
  38171. export var anaglyphPixelShader: {
  38172. name: string;
  38173. shader: string;
  38174. };
  38175. }
  38176. declare module BABYLON {
  38177. /**
  38178. * Postprocess used to generate anaglyphic rendering
  38179. */
  38180. export class AnaglyphPostProcess extends PostProcess {
  38181. private _passedProcess;
  38182. /**
  38183. * Creates a new AnaglyphPostProcess
  38184. * @param name defines postprocess name
  38185. * @param options defines creation options or target ratio scale
  38186. * @param rigCameras defines cameras using this postprocess
  38187. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38188. * @param engine defines hosting engine
  38189. * @param reusable defines if the postprocess will be reused multiple times per frame
  38190. */
  38191. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38192. }
  38193. }
  38194. declare module BABYLON {
  38195. /**
  38196. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38197. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38198. */
  38199. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38200. /**
  38201. * Creates a new AnaglyphArcRotateCamera
  38202. * @param name defines camera name
  38203. * @param alpha defines alpha angle (in radians)
  38204. * @param beta defines beta angle (in radians)
  38205. * @param radius defines radius
  38206. * @param target defines camera target
  38207. * @param interaxialDistance defines distance between each color axis
  38208. * @param scene defines the hosting scene
  38209. */
  38210. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38211. /**
  38212. * Gets camera class name
  38213. * @returns AnaglyphArcRotateCamera
  38214. */
  38215. getClassName(): string;
  38216. }
  38217. }
  38218. declare module BABYLON {
  38219. /**
  38220. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38221. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38222. */
  38223. export class AnaglyphFreeCamera extends FreeCamera {
  38224. /**
  38225. * Creates a new AnaglyphFreeCamera
  38226. * @param name defines camera name
  38227. * @param position defines initial position
  38228. * @param interaxialDistance defines distance between each color axis
  38229. * @param scene defines the hosting scene
  38230. */
  38231. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38232. /**
  38233. * Gets camera class name
  38234. * @returns AnaglyphFreeCamera
  38235. */
  38236. getClassName(): string;
  38237. }
  38238. }
  38239. declare module BABYLON {
  38240. /**
  38241. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38242. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38243. */
  38244. export class AnaglyphGamepadCamera extends GamepadCamera {
  38245. /**
  38246. * Creates a new AnaglyphGamepadCamera
  38247. * @param name defines camera name
  38248. * @param position defines initial position
  38249. * @param interaxialDistance defines distance between each color axis
  38250. * @param scene defines the hosting scene
  38251. */
  38252. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38253. /**
  38254. * Gets camera class name
  38255. * @returns AnaglyphGamepadCamera
  38256. */
  38257. getClassName(): string;
  38258. }
  38259. }
  38260. declare module BABYLON {
  38261. /**
  38262. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38263. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38264. */
  38265. export class AnaglyphUniversalCamera extends UniversalCamera {
  38266. /**
  38267. * Creates a new AnaglyphUniversalCamera
  38268. * @param name defines camera name
  38269. * @param position defines initial position
  38270. * @param interaxialDistance defines distance between each color axis
  38271. * @param scene defines the hosting scene
  38272. */
  38273. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38274. /**
  38275. * Gets camera class name
  38276. * @returns AnaglyphUniversalCamera
  38277. */
  38278. getClassName(): string;
  38279. }
  38280. }
  38281. declare module BABYLON {
  38282. /** @hidden */
  38283. export var stereoscopicInterlacePixelShader: {
  38284. name: string;
  38285. shader: string;
  38286. };
  38287. }
  38288. declare module BABYLON {
  38289. /**
  38290. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38291. */
  38292. export class StereoscopicInterlacePostProcess extends PostProcess {
  38293. private _stepSize;
  38294. private _passedProcess;
  38295. /**
  38296. * Initializes a StereoscopicInterlacePostProcess
  38297. * @param name The name of the effect.
  38298. * @param rigCameras The rig cameras to be appled to the post process
  38299. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38300. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38301. * @param engine The engine which the post process will be applied. (default: current engine)
  38302. * @param reusable If the post process can be reused on the same frame. (default: false)
  38303. */
  38304. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38305. }
  38306. }
  38307. declare module BABYLON {
  38308. /**
  38309. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38310. * @see http://doc.babylonjs.com/features/cameras
  38311. */
  38312. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38313. /**
  38314. * Creates a new StereoscopicArcRotateCamera
  38315. * @param name defines camera name
  38316. * @param alpha defines alpha angle (in radians)
  38317. * @param beta defines beta angle (in radians)
  38318. * @param radius defines radius
  38319. * @param target defines camera target
  38320. * @param interaxialDistance defines distance between each color axis
  38321. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38322. * @param scene defines the hosting scene
  38323. */
  38324. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38325. /**
  38326. * Gets camera class name
  38327. * @returns StereoscopicArcRotateCamera
  38328. */
  38329. getClassName(): string;
  38330. }
  38331. }
  38332. declare module BABYLON {
  38333. /**
  38334. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38335. * @see http://doc.babylonjs.com/features/cameras
  38336. */
  38337. export class StereoscopicFreeCamera extends FreeCamera {
  38338. /**
  38339. * Creates a new StereoscopicFreeCamera
  38340. * @param name defines camera name
  38341. * @param position defines initial position
  38342. * @param interaxialDistance defines distance between each color axis
  38343. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38344. * @param scene defines the hosting scene
  38345. */
  38346. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38347. /**
  38348. * Gets camera class name
  38349. * @returns StereoscopicFreeCamera
  38350. */
  38351. getClassName(): string;
  38352. }
  38353. }
  38354. declare module BABYLON {
  38355. /**
  38356. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38357. * @see http://doc.babylonjs.com/features/cameras
  38358. */
  38359. export class StereoscopicGamepadCamera extends GamepadCamera {
  38360. /**
  38361. * Creates a new StereoscopicGamepadCamera
  38362. * @param name defines camera name
  38363. * @param position defines initial position
  38364. * @param interaxialDistance defines distance between each color axis
  38365. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38366. * @param scene defines the hosting scene
  38367. */
  38368. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38369. /**
  38370. * Gets camera class name
  38371. * @returns StereoscopicGamepadCamera
  38372. */
  38373. getClassName(): string;
  38374. }
  38375. }
  38376. declare module BABYLON {
  38377. /**
  38378. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38379. * @see http://doc.babylonjs.com/features/cameras
  38380. */
  38381. export class StereoscopicUniversalCamera extends UniversalCamera {
  38382. /**
  38383. * Creates a new StereoscopicUniversalCamera
  38384. * @param name defines camera name
  38385. * @param position defines initial position
  38386. * @param interaxialDistance defines distance between each color axis
  38387. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38388. * @param scene defines the hosting scene
  38389. */
  38390. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38391. /**
  38392. * Gets camera class name
  38393. * @returns StereoscopicUniversalCamera
  38394. */
  38395. getClassName(): string;
  38396. }
  38397. }
  38398. declare module BABYLON {
  38399. /**
  38400. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38401. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38402. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38403. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38404. */
  38405. export class VirtualJoysticksCamera extends FreeCamera {
  38406. /**
  38407. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38408. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38409. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38410. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38411. * @param name Define the name of the camera in the scene
  38412. * @param position Define the start position of the camera in the scene
  38413. * @param scene Define the scene the camera belongs to
  38414. */
  38415. constructor(name: string, position: Vector3, scene: Scene);
  38416. /**
  38417. * Gets the current object class name.
  38418. * @return the class name
  38419. */
  38420. getClassName(): string;
  38421. }
  38422. }
  38423. declare module BABYLON {
  38424. /**
  38425. * This represents all the required metrics to create a VR camera.
  38426. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38427. */
  38428. export class VRCameraMetrics {
  38429. /**
  38430. * Define the horizontal resolution off the screen.
  38431. */
  38432. hResolution: number;
  38433. /**
  38434. * Define the vertical resolution off the screen.
  38435. */
  38436. vResolution: number;
  38437. /**
  38438. * Define the horizontal screen size.
  38439. */
  38440. hScreenSize: number;
  38441. /**
  38442. * Define the vertical screen size.
  38443. */
  38444. vScreenSize: number;
  38445. /**
  38446. * Define the vertical screen center position.
  38447. */
  38448. vScreenCenter: number;
  38449. /**
  38450. * Define the distance of the eyes to the screen.
  38451. */
  38452. eyeToScreenDistance: number;
  38453. /**
  38454. * Define the distance between both lenses
  38455. */
  38456. lensSeparationDistance: number;
  38457. /**
  38458. * Define the distance between both viewer's eyes.
  38459. */
  38460. interpupillaryDistance: number;
  38461. /**
  38462. * Define the distortion factor of the VR postprocess.
  38463. * Please, touch with care.
  38464. */
  38465. distortionK: number[];
  38466. /**
  38467. * Define the chromatic aberration correction factors for the VR post process.
  38468. */
  38469. chromaAbCorrection: number[];
  38470. /**
  38471. * Define the scale factor of the post process.
  38472. * The smaller the better but the slower.
  38473. */
  38474. postProcessScaleFactor: number;
  38475. /**
  38476. * Define an offset for the lens center.
  38477. */
  38478. lensCenterOffset: number;
  38479. /**
  38480. * Define if the current vr camera should compensate the distortion of the lense or not.
  38481. */
  38482. compensateDistortion: boolean;
  38483. /**
  38484. * Defines if multiview should be enabled when rendering (Default: false)
  38485. */
  38486. multiviewEnabled: boolean;
  38487. /**
  38488. * Gets the rendering aspect ratio based on the provided resolutions.
  38489. */
  38490. readonly aspectRatio: number;
  38491. /**
  38492. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38493. */
  38494. readonly aspectRatioFov: number;
  38495. /**
  38496. * @hidden
  38497. */
  38498. readonly leftHMatrix: Matrix;
  38499. /**
  38500. * @hidden
  38501. */
  38502. readonly rightHMatrix: Matrix;
  38503. /**
  38504. * @hidden
  38505. */
  38506. readonly leftPreViewMatrix: Matrix;
  38507. /**
  38508. * @hidden
  38509. */
  38510. readonly rightPreViewMatrix: Matrix;
  38511. /**
  38512. * Get the default VRMetrics based on the most generic setup.
  38513. * @returns the default vr metrics
  38514. */
  38515. static GetDefault(): VRCameraMetrics;
  38516. }
  38517. }
  38518. declare module BABYLON {
  38519. /** @hidden */
  38520. export var vrDistortionCorrectionPixelShader: {
  38521. name: string;
  38522. shader: string;
  38523. };
  38524. }
  38525. declare module BABYLON {
  38526. /**
  38527. * VRDistortionCorrectionPostProcess used for mobile VR
  38528. */
  38529. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38530. private _isRightEye;
  38531. private _distortionFactors;
  38532. private _postProcessScaleFactor;
  38533. private _lensCenterOffset;
  38534. private _scaleIn;
  38535. private _scaleFactor;
  38536. private _lensCenter;
  38537. /**
  38538. * Initializes the VRDistortionCorrectionPostProcess
  38539. * @param name The name of the effect.
  38540. * @param camera The camera to apply the render pass to.
  38541. * @param isRightEye If this is for the right eye distortion
  38542. * @param vrMetrics All the required metrics for the VR camera
  38543. */
  38544. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38545. }
  38546. }
  38547. declare module BABYLON {
  38548. /**
  38549. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38550. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38551. */
  38552. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38553. /**
  38554. * Creates a new VRDeviceOrientationArcRotateCamera
  38555. * @param name defines camera name
  38556. * @param alpha defines the camera rotation along the logitudinal axis
  38557. * @param beta defines the camera rotation along the latitudinal axis
  38558. * @param radius defines the camera distance from its target
  38559. * @param target defines the camera target
  38560. * @param scene defines the scene the camera belongs to
  38561. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38562. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38563. */
  38564. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38565. /**
  38566. * Gets camera class name
  38567. * @returns VRDeviceOrientationArcRotateCamera
  38568. */
  38569. getClassName(): string;
  38570. }
  38571. }
  38572. declare module BABYLON {
  38573. /**
  38574. * Camera used to simulate VR rendering (based on FreeCamera)
  38575. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38576. */
  38577. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38578. /**
  38579. * Creates a new VRDeviceOrientationFreeCamera
  38580. * @param name defines camera name
  38581. * @param position defines the start position of the camera
  38582. * @param scene defines the scene the camera belongs to
  38583. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38584. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38585. */
  38586. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38587. /**
  38588. * Gets camera class name
  38589. * @returns VRDeviceOrientationFreeCamera
  38590. */
  38591. getClassName(): string;
  38592. }
  38593. }
  38594. declare module BABYLON {
  38595. /**
  38596. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38597. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38598. */
  38599. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38600. /**
  38601. * Creates a new VRDeviceOrientationGamepadCamera
  38602. * @param name defines camera name
  38603. * @param position defines the start position of the camera
  38604. * @param scene defines the scene the camera belongs to
  38605. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38606. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38607. */
  38608. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38609. /**
  38610. * Gets camera class name
  38611. * @returns VRDeviceOrientationGamepadCamera
  38612. */
  38613. getClassName(): string;
  38614. }
  38615. }
  38616. declare module BABYLON {
  38617. /**
  38618. * Base class of materials working in push mode in babylon JS
  38619. * @hidden
  38620. */
  38621. export class PushMaterial extends Material {
  38622. protected _activeEffect: Effect;
  38623. protected _normalMatrix: Matrix;
  38624. /**
  38625. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38626. * This means that the material can keep using a previous shader while a new one is being compiled.
  38627. * This is mostly used when shader parallel compilation is supported (true by default)
  38628. */
  38629. allowShaderHotSwapping: boolean;
  38630. constructor(name: string, scene: Scene);
  38631. getEffect(): Effect;
  38632. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38633. /**
  38634. * Binds the given world matrix to the active effect
  38635. *
  38636. * @param world the matrix to bind
  38637. */
  38638. bindOnlyWorldMatrix(world: Matrix): void;
  38639. /**
  38640. * Binds the given normal matrix to the active effect
  38641. *
  38642. * @param normalMatrix the matrix to bind
  38643. */
  38644. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38645. bind(world: Matrix, mesh?: Mesh): void;
  38646. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38647. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38648. }
  38649. }
  38650. declare module BABYLON {
  38651. /**
  38652. * This groups all the flags used to control the materials channel.
  38653. */
  38654. export class MaterialFlags {
  38655. private static _DiffuseTextureEnabled;
  38656. /**
  38657. * Are diffuse textures enabled in the application.
  38658. */
  38659. static DiffuseTextureEnabled: boolean;
  38660. private static _AmbientTextureEnabled;
  38661. /**
  38662. * Are ambient textures enabled in the application.
  38663. */
  38664. static AmbientTextureEnabled: boolean;
  38665. private static _OpacityTextureEnabled;
  38666. /**
  38667. * Are opacity textures enabled in the application.
  38668. */
  38669. static OpacityTextureEnabled: boolean;
  38670. private static _ReflectionTextureEnabled;
  38671. /**
  38672. * Are reflection textures enabled in the application.
  38673. */
  38674. static ReflectionTextureEnabled: boolean;
  38675. private static _EmissiveTextureEnabled;
  38676. /**
  38677. * Are emissive textures enabled in the application.
  38678. */
  38679. static EmissiveTextureEnabled: boolean;
  38680. private static _SpecularTextureEnabled;
  38681. /**
  38682. * Are specular textures enabled in the application.
  38683. */
  38684. static SpecularTextureEnabled: boolean;
  38685. private static _BumpTextureEnabled;
  38686. /**
  38687. * Are bump textures enabled in the application.
  38688. */
  38689. static BumpTextureEnabled: boolean;
  38690. private static _LightmapTextureEnabled;
  38691. /**
  38692. * Are lightmap textures enabled in the application.
  38693. */
  38694. static LightmapTextureEnabled: boolean;
  38695. private static _RefractionTextureEnabled;
  38696. /**
  38697. * Are refraction textures enabled in the application.
  38698. */
  38699. static RefractionTextureEnabled: boolean;
  38700. private static _ColorGradingTextureEnabled;
  38701. /**
  38702. * Are color grading textures enabled in the application.
  38703. */
  38704. static ColorGradingTextureEnabled: boolean;
  38705. private static _FresnelEnabled;
  38706. /**
  38707. * Are fresnels enabled in the application.
  38708. */
  38709. static FresnelEnabled: boolean;
  38710. private static _ClearCoatTextureEnabled;
  38711. /**
  38712. * Are clear coat textures enabled in the application.
  38713. */
  38714. static ClearCoatTextureEnabled: boolean;
  38715. private static _ClearCoatBumpTextureEnabled;
  38716. /**
  38717. * Are clear coat bump textures enabled in the application.
  38718. */
  38719. static ClearCoatBumpTextureEnabled: boolean;
  38720. private static _ClearCoatTintTextureEnabled;
  38721. /**
  38722. * Are clear coat tint textures enabled in the application.
  38723. */
  38724. static ClearCoatTintTextureEnabled: boolean;
  38725. private static _SheenTextureEnabled;
  38726. /**
  38727. * Are sheen textures enabled in the application.
  38728. */
  38729. static SheenTextureEnabled: boolean;
  38730. private static _AnisotropicTextureEnabled;
  38731. /**
  38732. * Are anisotropic textures enabled in the application.
  38733. */
  38734. static AnisotropicTextureEnabled: boolean;
  38735. private static _ThicknessTextureEnabled;
  38736. /**
  38737. * Are thickness textures enabled in the application.
  38738. */
  38739. static ThicknessTextureEnabled: boolean;
  38740. }
  38741. }
  38742. declare module BABYLON {
  38743. /** @hidden */
  38744. export var defaultFragmentDeclaration: {
  38745. name: string;
  38746. shader: string;
  38747. };
  38748. }
  38749. declare module BABYLON {
  38750. /** @hidden */
  38751. export var defaultUboDeclaration: {
  38752. name: string;
  38753. shader: string;
  38754. };
  38755. }
  38756. declare module BABYLON {
  38757. /** @hidden */
  38758. export var lightFragmentDeclaration: {
  38759. name: string;
  38760. shader: string;
  38761. };
  38762. }
  38763. declare module BABYLON {
  38764. /** @hidden */
  38765. export var lightUboDeclaration: {
  38766. name: string;
  38767. shader: string;
  38768. };
  38769. }
  38770. declare module BABYLON {
  38771. /** @hidden */
  38772. export var lightsFragmentFunctions: {
  38773. name: string;
  38774. shader: string;
  38775. };
  38776. }
  38777. declare module BABYLON {
  38778. /** @hidden */
  38779. export var shadowsFragmentFunctions: {
  38780. name: string;
  38781. shader: string;
  38782. };
  38783. }
  38784. declare module BABYLON {
  38785. /** @hidden */
  38786. export var fresnelFunction: {
  38787. name: string;
  38788. shader: string;
  38789. };
  38790. }
  38791. declare module BABYLON {
  38792. /** @hidden */
  38793. export var reflectionFunction: {
  38794. name: string;
  38795. shader: string;
  38796. };
  38797. }
  38798. declare module BABYLON {
  38799. /** @hidden */
  38800. export var bumpFragmentFunctions: {
  38801. name: string;
  38802. shader: string;
  38803. };
  38804. }
  38805. declare module BABYLON {
  38806. /** @hidden */
  38807. export var logDepthDeclaration: {
  38808. name: string;
  38809. shader: string;
  38810. };
  38811. }
  38812. declare module BABYLON {
  38813. /** @hidden */
  38814. export var bumpFragment: {
  38815. name: string;
  38816. shader: string;
  38817. };
  38818. }
  38819. declare module BABYLON {
  38820. /** @hidden */
  38821. export var depthPrePass: {
  38822. name: string;
  38823. shader: string;
  38824. };
  38825. }
  38826. declare module BABYLON {
  38827. /** @hidden */
  38828. export var lightFragment: {
  38829. name: string;
  38830. shader: string;
  38831. };
  38832. }
  38833. declare module BABYLON {
  38834. /** @hidden */
  38835. export var logDepthFragment: {
  38836. name: string;
  38837. shader: string;
  38838. };
  38839. }
  38840. declare module BABYLON {
  38841. /** @hidden */
  38842. export var defaultPixelShader: {
  38843. name: string;
  38844. shader: string;
  38845. };
  38846. }
  38847. declare module BABYLON {
  38848. /** @hidden */
  38849. export var defaultVertexDeclaration: {
  38850. name: string;
  38851. shader: string;
  38852. };
  38853. }
  38854. declare module BABYLON {
  38855. /** @hidden */
  38856. export var bumpVertexDeclaration: {
  38857. name: string;
  38858. shader: string;
  38859. };
  38860. }
  38861. declare module BABYLON {
  38862. /** @hidden */
  38863. export var bumpVertex: {
  38864. name: string;
  38865. shader: string;
  38866. };
  38867. }
  38868. declare module BABYLON {
  38869. /** @hidden */
  38870. export var fogVertex: {
  38871. name: string;
  38872. shader: string;
  38873. };
  38874. }
  38875. declare module BABYLON {
  38876. /** @hidden */
  38877. export var shadowsVertex: {
  38878. name: string;
  38879. shader: string;
  38880. };
  38881. }
  38882. declare module BABYLON {
  38883. /** @hidden */
  38884. export var pointCloudVertex: {
  38885. name: string;
  38886. shader: string;
  38887. };
  38888. }
  38889. declare module BABYLON {
  38890. /** @hidden */
  38891. export var logDepthVertex: {
  38892. name: string;
  38893. shader: string;
  38894. };
  38895. }
  38896. declare module BABYLON {
  38897. /** @hidden */
  38898. export var defaultVertexShader: {
  38899. name: string;
  38900. shader: string;
  38901. };
  38902. }
  38903. declare module BABYLON {
  38904. /** @hidden */
  38905. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38906. MAINUV1: boolean;
  38907. MAINUV2: boolean;
  38908. DIFFUSE: boolean;
  38909. DIFFUSEDIRECTUV: number;
  38910. AMBIENT: boolean;
  38911. AMBIENTDIRECTUV: number;
  38912. OPACITY: boolean;
  38913. OPACITYDIRECTUV: number;
  38914. OPACITYRGB: boolean;
  38915. REFLECTION: boolean;
  38916. EMISSIVE: boolean;
  38917. EMISSIVEDIRECTUV: number;
  38918. SPECULAR: boolean;
  38919. SPECULARDIRECTUV: number;
  38920. BUMP: boolean;
  38921. BUMPDIRECTUV: number;
  38922. PARALLAX: boolean;
  38923. PARALLAXOCCLUSION: boolean;
  38924. SPECULAROVERALPHA: boolean;
  38925. CLIPPLANE: boolean;
  38926. CLIPPLANE2: boolean;
  38927. CLIPPLANE3: boolean;
  38928. CLIPPLANE4: boolean;
  38929. ALPHATEST: boolean;
  38930. DEPTHPREPASS: boolean;
  38931. ALPHAFROMDIFFUSE: boolean;
  38932. POINTSIZE: boolean;
  38933. FOG: boolean;
  38934. SPECULARTERM: boolean;
  38935. DIFFUSEFRESNEL: boolean;
  38936. OPACITYFRESNEL: boolean;
  38937. REFLECTIONFRESNEL: boolean;
  38938. REFRACTIONFRESNEL: boolean;
  38939. EMISSIVEFRESNEL: boolean;
  38940. FRESNEL: boolean;
  38941. NORMAL: boolean;
  38942. UV1: boolean;
  38943. UV2: boolean;
  38944. VERTEXCOLOR: boolean;
  38945. VERTEXALPHA: boolean;
  38946. NUM_BONE_INFLUENCERS: number;
  38947. BonesPerMesh: number;
  38948. BONETEXTURE: boolean;
  38949. INSTANCES: boolean;
  38950. GLOSSINESS: boolean;
  38951. ROUGHNESS: boolean;
  38952. EMISSIVEASILLUMINATION: boolean;
  38953. LINKEMISSIVEWITHDIFFUSE: boolean;
  38954. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38955. LIGHTMAP: boolean;
  38956. LIGHTMAPDIRECTUV: number;
  38957. OBJECTSPACE_NORMALMAP: boolean;
  38958. USELIGHTMAPASSHADOWMAP: boolean;
  38959. REFLECTIONMAP_3D: boolean;
  38960. REFLECTIONMAP_SPHERICAL: boolean;
  38961. REFLECTIONMAP_PLANAR: boolean;
  38962. REFLECTIONMAP_CUBIC: boolean;
  38963. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38964. REFLECTIONMAP_PROJECTION: boolean;
  38965. REFLECTIONMAP_SKYBOX: boolean;
  38966. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38967. REFLECTIONMAP_EXPLICIT: boolean;
  38968. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38969. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38970. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38971. INVERTCUBICMAP: boolean;
  38972. LOGARITHMICDEPTH: boolean;
  38973. REFRACTION: boolean;
  38974. REFRACTIONMAP_3D: boolean;
  38975. REFLECTIONOVERALPHA: boolean;
  38976. TWOSIDEDLIGHTING: boolean;
  38977. SHADOWFLOAT: boolean;
  38978. MORPHTARGETS: boolean;
  38979. MORPHTARGETS_NORMAL: boolean;
  38980. MORPHTARGETS_TANGENT: boolean;
  38981. NUM_MORPH_INFLUENCERS: number;
  38982. NONUNIFORMSCALING: boolean;
  38983. PREMULTIPLYALPHA: boolean;
  38984. IMAGEPROCESSING: boolean;
  38985. VIGNETTE: boolean;
  38986. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38987. VIGNETTEBLENDMODEOPAQUE: boolean;
  38988. TONEMAPPING: boolean;
  38989. TONEMAPPING_ACES: boolean;
  38990. CONTRAST: boolean;
  38991. COLORCURVES: boolean;
  38992. COLORGRADING: boolean;
  38993. COLORGRADING3D: boolean;
  38994. SAMPLER3DGREENDEPTH: boolean;
  38995. SAMPLER3DBGRMAP: boolean;
  38996. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38997. MULTIVIEW: boolean;
  38998. /**
  38999. * If the reflection texture on this material is in linear color space
  39000. * @hidden
  39001. */
  39002. IS_REFLECTION_LINEAR: boolean;
  39003. /**
  39004. * If the refraction texture on this material is in linear color space
  39005. * @hidden
  39006. */
  39007. IS_REFRACTION_LINEAR: boolean;
  39008. EXPOSURE: boolean;
  39009. constructor();
  39010. setReflectionMode(modeToEnable: string): void;
  39011. }
  39012. /**
  39013. * This is the default material used in Babylon. It is the best trade off between quality
  39014. * and performances.
  39015. * @see http://doc.babylonjs.com/babylon101/materials
  39016. */
  39017. export class StandardMaterial extends PushMaterial {
  39018. private _diffuseTexture;
  39019. /**
  39020. * The basic texture of the material as viewed under a light.
  39021. */
  39022. diffuseTexture: Nullable<BaseTexture>;
  39023. private _ambientTexture;
  39024. /**
  39025. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39026. */
  39027. ambientTexture: Nullable<BaseTexture>;
  39028. private _opacityTexture;
  39029. /**
  39030. * Define the transparency of the material from a texture.
  39031. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39032. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39033. */
  39034. opacityTexture: Nullable<BaseTexture>;
  39035. private _reflectionTexture;
  39036. /**
  39037. * Define the texture used to display the reflection.
  39038. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39039. */
  39040. reflectionTexture: Nullable<BaseTexture>;
  39041. private _emissiveTexture;
  39042. /**
  39043. * Define texture of the material as if self lit.
  39044. * This will be mixed in the final result even in the absence of light.
  39045. */
  39046. emissiveTexture: Nullable<BaseTexture>;
  39047. private _specularTexture;
  39048. /**
  39049. * Define how the color and intensity of the highlight given by the light in the material.
  39050. */
  39051. specularTexture: Nullable<BaseTexture>;
  39052. private _bumpTexture;
  39053. /**
  39054. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39055. * 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.
  39056. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39057. */
  39058. bumpTexture: Nullable<BaseTexture>;
  39059. private _lightmapTexture;
  39060. /**
  39061. * Complex lighting can be computationally expensive to compute at runtime.
  39062. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39063. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39064. */
  39065. lightmapTexture: Nullable<BaseTexture>;
  39066. private _refractionTexture;
  39067. /**
  39068. * Define the texture used to display the refraction.
  39069. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39070. */
  39071. refractionTexture: Nullable<BaseTexture>;
  39072. /**
  39073. * The color of the material lit by the environmental background lighting.
  39074. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39075. */
  39076. ambientColor: Color3;
  39077. /**
  39078. * The basic color of the material as viewed under a light.
  39079. */
  39080. diffuseColor: Color3;
  39081. /**
  39082. * Define how the color and intensity of the highlight given by the light in the material.
  39083. */
  39084. specularColor: Color3;
  39085. /**
  39086. * Define the color of the material as if self lit.
  39087. * This will be mixed in the final result even in the absence of light.
  39088. */
  39089. emissiveColor: Color3;
  39090. /**
  39091. * Defines how sharp are the highlights in the material.
  39092. * The bigger the value the sharper giving a more glossy feeling to the result.
  39093. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39094. */
  39095. specularPower: number;
  39096. private _useAlphaFromDiffuseTexture;
  39097. /**
  39098. * Does the transparency come from the diffuse texture alpha channel.
  39099. */
  39100. useAlphaFromDiffuseTexture: boolean;
  39101. private _useEmissiveAsIllumination;
  39102. /**
  39103. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39104. */
  39105. useEmissiveAsIllumination: boolean;
  39106. private _linkEmissiveWithDiffuse;
  39107. /**
  39108. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39109. * the emissive level when the final color is close to one.
  39110. */
  39111. linkEmissiveWithDiffuse: boolean;
  39112. private _useSpecularOverAlpha;
  39113. /**
  39114. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39115. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39116. */
  39117. useSpecularOverAlpha: boolean;
  39118. private _useReflectionOverAlpha;
  39119. /**
  39120. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39121. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39122. */
  39123. useReflectionOverAlpha: boolean;
  39124. private _disableLighting;
  39125. /**
  39126. * Does lights from the scene impacts this material.
  39127. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39128. */
  39129. disableLighting: boolean;
  39130. private _useObjectSpaceNormalMap;
  39131. /**
  39132. * Allows using an object space normal map (instead of tangent space).
  39133. */
  39134. useObjectSpaceNormalMap: boolean;
  39135. private _useParallax;
  39136. /**
  39137. * Is parallax enabled or not.
  39138. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39139. */
  39140. useParallax: boolean;
  39141. private _useParallaxOcclusion;
  39142. /**
  39143. * Is parallax occlusion enabled or not.
  39144. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39145. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39146. */
  39147. useParallaxOcclusion: boolean;
  39148. /**
  39149. * 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.
  39150. */
  39151. parallaxScaleBias: number;
  39152. private _roughness;
  39153. /**
  39154. * Helps to define how blurry the reflections should appears in the material.
  39155. */
  39156. roughness: number;
  39157. /**
  39158. * In case of refraction, define the value of the indice of refraction.
  39159. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39160. */
  39161. indexOfRefraction: number;
  39162. /**
  39163. * Invert the refraction texture alongside the y axis.
  39164. * It can be useful with procedural textures or probe for instance.
  39165. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39166. */
  39167. invertRefractionY: boolean;
  39168. /**
  39169. * Defines the alpha limits in alpha test mode.
  39170. */
  39171. alphaCutOff: number;
  39172. private _useLightmapAsShadowmap;
  39173. /**
  39174. * In case of light mapping, define whether the map contains light or shadow informations.
  39175. */
  39176. useLightmapAsShadowmap: boolean;
  39177. private _diffuseFresnelParameters;
  39178. /**
  39179. * Define the diffuse fresnel parameters of the material.
  39180. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39181. */
  39182. diffuseFresnelParameters: FresnelParameters;
  39183. private _opacityFresnelParameters;
  39184. /**
  39185. * Define the opacity fresnel parameters of the material.
  39186. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39187. */
  39188. opacityFresnelParameters: FresnelParameters;
  39189. private _reflectionFresnelParameters;
  39190. /**
  39191. * Define the reflection fresnel parameters of the material.
  39192. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39193. */
  39194. reflectionFresnelParameters: FresnelParameters;
  39195. private _refractionFresnelParameters;
  39196. /**
  39197. * Define the refraction fresnel parameters of the material.
  39198. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39199. */
  39200. refractionFresnelParameters: FresnelParameters;
  39201. private _emissiveFresnelParameters;
  39202. /**
  39203. * Define the emissive fresnel parameters of the material.
  39204. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39205. */
  39206. emissiveFresnelParameters: FresnelParameters;
  39207. private _useReflectionFresnelFromSpecular;
  39208. /**
  39209. * If true automatically deducts the fresnels values from the material specularity.
  39210. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39211. */
  39212. useReflectionFresnelFromSpecular: boolean;
  39213. private _useGlossinessFromSpecularMapAlpha;
  39214. /**
  39215. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39216. */
  39217. useGlossinessFromSpecularMapAlpha: boolean;
  39218. private _maxSimultaneousLights;
  39219. /**
  39220. * Defines the maximum number of lights that can be used in the material
  39221. */
  39222. maxSimultaneousLights: number;
  39223. private _invertNormalMapX;
  39224. /**
  39225. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39226. */
  39227. invertNormalMapX: boolean;
  39228. private _invertNormalMapY;
  39229. /**
  39230. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39231. */
  39232. invertNormalMapY: boolean;
  39233. private _twoSidedLighting;
  39234. /**
  39235. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39236. */
  39237. twoSidedLighting: boolean;
  39238. /**
  39239. * Default configuration related to image processing available in the standard Material.
  39240. */
  39241. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39242. /**
  39243. * Gets the image processing configuration used either in this material.
  39244. */
  39245. /**
  39246. * Sets the Default image processing configuration used either in the this material.
  39247. *
  39248. * If sets to null, the scene one is in use.
  39249. */
  39250. imageProcessingConfiguration: ImageProcessingConfiguration;
  39251. /**
  39252. * Keep track of the image processing observer to allow dispose and replace.
  39253. */
  39254. private _imageProcessingObserver;
  39255. /**
  39256. * Attaches a new image processing configuration to the Standard Material.
  39257. * @param configuration
  39258. */
  39259. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39260. /**
  39261. * Gets wether the color curves effect is enabled.
  39262. */
  39263. /**
  39264. * Sets wether the color curves effect is enabled.
  39265. */
  39266. cameraColorCurvesEnabled: boolean;
  39267. /**
  39268. * Gets wether the color grading effect is enabled.
  39269. */
  39270. /**
  39271. * Gets wether the color grading effect is enabled.
  39272. */
  39273. cameraColorGradingEnabled: boolean;
  39274. /**
  39275. * Gets wether tonemapping is enabled or not.
  39276. */
  39277. /**
  39278. * Sets wether tonemapping is enabled or not
  39279. */
  39280. cameraToneMappingEnabled: boolean;
  39281. /**
  39282. * The camera exposure used on this material.
  39283. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39284. * This corresponds to a photographic exposure.
  39285. */
  39286. /**
  39287. * The camera exposure used on this material.
  39288. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39289. * This corresponds to a photographic exposure.
  39290. */
  39291. cameraExposure: number;
  39292. /**
  39293. * Gets The camera contrast used on this material.
  39294. */
  39295. /**
  39296. * Sets The camera contrast used on this material.
  39297. */
  39298. cameraContrast: number;
  39299. /**
  39300. * Gets the Color Grading 2D Lookup Texture.
  39301. */
  39302. /**
  39303. * Sets the Color Grading 2D Lookup Texture.
  39304. */
  39305. cameraColorGradingTexture: Nullable<BaseTexture>;
  39306. /**
  39307. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39308. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39309. * 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;
  39310. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39311. */
  39312. /**
  39313. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39314. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39315. * 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;
  39316. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39317. */
  39318. cameraColorCurves: Nullable<ColorCurves>;
  39319. /**
  39320. * Custom callback helping to override the default shader used in the material.
  39321. */
  39322. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39323. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39324. protected _worldViewProjectionMatrix: Matrix;
  39325. protected _globalAmbientColor: Color3;
  39326. protected _useLogarithmicDepth: boolean;
  39327. /**
  39328. * Instantiates a new standard material.
  39329. * This is the default material used in Babylon. It is the best trade off between quality
  39330. * and performances.
  39331. * @see http://doc.babylonjs.com/babylon101/materials
  39332. * @param name Define the name of the material in the scene
  39333. * @param scene Define the scene the material belong to
  39334. */
  39335. constructor(name: string, scene: Scene);
  39336. /**
  39337. * Gets a boolean indicating that current material needs to register RTT
  39338. */
  39339. readonly hasRenderTargetTextures: boolean;
  39340. /**
  39341. * Gets the current class name of the material e.g. "StandardMaterial"
  39342. * Mainly use in serialization.
  39343. * @returns the class name
  39344. */
  39345. getClassName(): string;
  39346. /**
  39347. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39348. * You can try switching to logarithmic depth.
  39349. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39350. */
  39351. useLogarithmicDepth: boolean;
  39352. /**
  39353. * Specifies if the material will require alpha blending
  39354. * @returns a boolean specifying if alpha blending is needed
  39355. */
  39356. needAlphaBlending(): boolean;
  39357. /**
  39358. * Specifies if this material should be rendered in alpha test mode
  39359. * @returns a boolean specifying if an alpha test is needed.
  39360. */
  39361. needAlphaTesting(): boolean;
  39362. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39363. /**
  39364. * Get the texture used for alpha test purpose.
  39365. * @returns the diffuse texture in case of the standard material.
  39366. */
  39367. getAlphaTestTexture(): Nullable<BaseTexture>;
  39368. /**
  39369. * Get if the submesh is ready to be used and all its information available.
  39370. * Child classes can use it to update shaders
  39371. * @param mesh defines the mesh to check
  39372. * @param subMesh defines which submesh to check
  39373. * @param useInstances specifies that instances should be used
  39374. * @returns a boolean indicating that the submesh is ready or not
  39375. */
  39376. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39377. /**
  39378. * Builds the material UBO layouts.
  39379. * Used internally during the effect preparation.
  39380. */
  39381. buildUniformLayout(): void;
  39382. /**
  39383. * Unbinds the material from the mesh
  39384. */
  39385. unbind(): void;
  39386. /**
  39387. * Binds the submesh to this material by preparing the effect and shader to draw
  39388. * @param world defines the world transformation matrix
  39389. * @param mesh defines the mesh containing the submesh
  39390. * @param subMesh defines the submesh to bind the material to
  39391. */
  39392. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39393. /**
  39394. * Get the list of animatables in the material.
  39395. * @returns the list of animatables object used in the material
  39396. */
  39397. getAnimatables(): IAnimatable[];
  39398. /**
  39399. * Gets the active textures from the material
  39400. * @returns an array of textures
  39401. */
  39402. getActiveTextures(): BaseTexture[];
  39403. /**
  39404. * Specifies if the material uses a texture
  39405. * @param texture defines the texture to check against the material
  39406. * @returns a boolean specifying if the material uses the texture
  39407. */
  39408. hasTexture(texture: BaseTexture): boolean;
  39409. /**
  39410. * Disposes the material
  39411. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39412. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39413. */
  39414. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39415. /**
  39416. * Makes a duplicate of the material, and gives it a new name
  39417. * @param name defines the new name for the duplicated material
  39418. * @returns the cloned material
  39419. */
  39420. clone(name: string): StandardMaterial;
  39421. /**
  39422. * Serializes this material in a JSON representation
  39423. * @returns the serialized material object
  39424. */
  39425. serialize(): any;
  39426. /**
  39427. * Creates a standard material from parsed material data
  39428. * @param source defines the JSON representation of the material
  39429. * @param scene defines the hosting scene
  39430. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39431. * @returns a new standard material
  39432. */
  39433. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39434. /**
  39435. * Are diffuse textures enabled in the application.
  39436. */
  39437. static DiffuseTextureEnabled: boolean;
  39438. /**
  39439. * Are ambient textures enabled in the application.
  39440. */
  39441. static AmbientTextureEnabled: boolean;
  39442. /**
  39443. * Are opacity textures enabled in the application.
  39444. */
  39445. static OpacityTextureEnabled: boolean;
  39446. /**
  39447. * Are reflection textures enabled in the application.
  39448. */
  39449. static ReflectionTextureEnabled: boolean;
  39450. /**
  39451. * Are emissive textures enabled in the application.
  39452. */
  39453. static EmissiveTextureEnabled: boolean;
  39454. /**
  39455. * Are specular textures enabled in the application.
  39456. */
  39457. static SpecularTextureEnabled: boolean;
  39458. /**
  39459. * Are bump textures enabled in the application.
  39460. */
  39461. static BumpTextureEnabled: boolean;
  39462. /**
  39463. * Are lightmap textures enabled in the application.
  39464. */
  39465. static LightmapTextureEnabled: boolean;
  39466. /**
  39467. * Are refraction textures enabled in the application.
  39468. */
  39469. static RefractionTextureEnabled: boolean;
  39470. /**
  39471. * Are color grading textures enabled in the application.
  39472. */
  39473. static ColorGradingTextureEnabled: boolean;
  39474. /**
  39475. * Are fresnels enabled in the application.
  39476. */
  39477. static FresnelEnabled: boolean;
  39478. }
  39479. }
  39480. declare module BABYLON {
  39481. /**
  39482. * A class extending Texture allowing drawing on a texture
  39483. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39484. */
  39485. export class DynamicTexture extends Texture {
  39486. private _generateMipMaps;
  39487. private _canvas;
  39488. private _context;
  39489. private _engine;
  39490. /**
  39491. * Creates a DynamicTexture
  39492. * @param name defines the name of the texture
  39493. * @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
  39494. * @param scene defines the scene where you want the texture
  39495. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39496. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39497. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39498. */
  39499. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39500. /**
  39501. * Get the current class name of the texture useful for serialization or dynamic coding.
  39502. * @returns "DynamicTexture"
  39503. */
  39504. getClassName(): string;
  39505. /**
  39506. * Gets the current state of canRescale
  39507. */
  39508. readonly canRescale: boolean;
  39509. private _recreate;
  39510. /**
  39511. * Scales the texture
  39512. * @param ratio the scale factor to apply to both width and height
  39513. */
  39514. scale(ratio: number): void;
  39515. /**
  39516. * Resizes the texture
  39517. * @param width the new width
  39518. * @param height the new height
  39519. */
  39520. scaleTo(width: number, height: number): void;
  39521. /**
  39522. * Gets the context of the canvas used by the texture
  39523. * @returns the canvas context of the dynamic texture
  39524. */
  39525. getContext(): CanvasRenderingContext2D;
  39526. /**
  39527. * Clears the texture
  39528. */
  39529. clear(): void;
  39530. /**
  39531. * Updates the texture
  39532. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39533. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39534. */
  39535. update(invertY?: boolean, premulAlpha?: boolean): void;
  39536. /**
  39537. * Draws text onto the texture
  39538. * @param text defines the text to be drawn
  39539. * @param x defines the placement of the text from the left
  39540. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39541. * @param font defines the font to be used with font-style, font-size, font-name
  39542. * @param color defines the color used for the text
  39543. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39544. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39545. * @param update defines whether texture is immediately update (default is true)
  39546. */
  39547. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39548. /**
  39549. * Clones the texture
  39550. * @returns the clone of the texture.
  39551. */
  39552. clone(): DynamicTexture;
  39553. /**
  39554. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39555. * @returns a serialized dynamic texture object
  39556. */
  39557. serialize(): any;
  39558. /** @hidden */
  39559. _rebuild(): void;
  39560. }
  39561. }
  39562. declare module BABYLON {
  39563. /** @hidden */
  39564. export var imageProcessingPixelShader: {
  39565. name: string;
  39566. shader: string;
  39567. };
  39568. }
  39569. declare module BABYLON {
  39570. /**
  39571. * ImageProcessingPostProcess
  39572. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39573. */
  39574. export class ImageProcessingPostProcess extends PostProcess {
  39575. /**
  39576. * Default configuration related to image processing available in the PBR Material.
  39577. */
  39578. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39579. /**
  39580. * Gets the image processing configuration used either in this material.
  39581. */
  39582. /**
  39583. * Sets the Default image processing configuration used either in the this material.
  39584. *
  39585. * If sets to null, the scene one is in use.
  39586. */
  39587. imageProcessingConfiguration: ImageProcessingConfiguration;
  39588. /**
  39589. * Keep track of the image processing observer to allow dispose and replace.
  39590. */
  39591. private _imageProcessingObserver;
  39592. /**
  39593. * Attaches a new image processing configuration to the PBR Material.
  39594. * @param configuration
  39595. */
  39596. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39597. /**
  39598. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39599. */
  39600. /**
  39601. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39602. */
  39603. colorCurves: Nullable<ColorCurves>;
  39604. /**
  39605. * Gets wether the color curves effect is enabled.
  39606. */
  39607. /**
  39608. * Sets wether the color curves effect is enabled.
  39609. */
  39610. colorCurvesEnabled: boolean;
  39611. /**
  39612. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39613. */
  39614. /**
  39615. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39616. */
  39617. colorGradingTexture: Nullable<BaseTexture>;
  39618. /**
  39619. * Gets wether the color grading effect is enabled.
  39620. */
  39621. /**
  39622. * Gets wether the color grading effect is enabled.
  39623. */
  39624. colorGradingEnabled: boolean;
  39625. /**
  39626. * Gets exposure used in the effect.
  39627. */
  39628. /**
  39629. * Sets exposure used in the effect.
  39630. */
  39631. exposure: number;
  39632. /**
  39633. * Gets wether tonemapping is enabled or not.
  39634. */
  39635. /**
  39636. * Sets wether tonemapping is enabled or not
  39637. */
  39638. toneMappingEnabled: boolean;
  39639. /**
  39640. * Gets the type of tone mapping effect.
  39641. */
  39642. /**
  39643. * Sets the type of tone mapping effect.
  39644. */
  39645. toneMappingType: number;
  39646. /**
  39647. * Gets contrast used in the effect.
  39648. */
  39649. /**
  39650. * Sets contrast used in the effect.
  39651. */
  39652. contrast: number;
  39653. /**
  39654. * Gets Vignette stretch size.
  39655. */
  39656. /**
  39657. * Sets Vignette stretch size.
  39658. */
  39659. vignetteStretch: number;
  39660. /**
  39661. * Gets Vignette centre X Offset.
  39662. */
  39663. /**
  39664. * Sets Vignette centre X Offset.
  39665. */
  39666. vignetteCentreX: number;
  39667. /**
  39668. * Gets Vignette centre Y Offset.
  39669. */
  39670. /**
  39671. * Sets Vignette centre Y Offset.
  39672. */
  39673. vignetteCentreY: number;
  39674. /**
  39675. * Gets Vignette weight or intensity of the vignette effect.
  39676. */
  39677. /**
  39678. * Sets Vignette weight or intensity of the vignette effect.
  39679. */
  39680. vignetteWeight: number;
  39681. /**
  39682. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39683. * if vignetteEnabled is set to true.
  39684. */
  39685. /**
  39686. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39687. * if vignetteEnabled is set to true.
  39688. */
  39689. vignetteColor: Color4;
  39690. /**
  39691. * Gets Camera field of view used by the Vignette effect.
  39692. */
  39693. /**
  39694. * Sets Camera field of view used by the Vignette effect.
  39695. */
  39696. vignetteCameraFov: number;
  39697. /**
  39698. * Gets the vignette blend mode allowing different kind of effect.
  39699. */
  39700. /**
  39701. * Sets the vignette blend mode allowing different kind of effect.
  39702. */
  39703. vignetteBlendMode: number;
  39704. /**
  39705. * Gets wether the vignette effect is enabled.
  39706. */
  39707. /**
  39708. * Sets wether the vignette effect is enabled.
  39709. */
  39710. vignetteEnabled: boolean;
  39711. private _fromLinearSpace;
  39712. /**
  39713. * Gets wether the input of the processing is in Gamma or Linear Space.
  39714. */
  39715. /**
  39716. * Sets wether the input of the processing is in Gamma or Linear Space.
  39717. */
  39718. fromLinearSpace: boolean;
  39719. /**
  39720. * Defines cache preventing GC.
  39721. */
  39722. private _defines;
  39723. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39724. /**
  39725. * "ImageProcessingPostProcess"
  39726. * @returns "ImageProcessingPostProcess"
  39727. */
  39728. getClassName(): string;
  39729. protected _updateParameters(): void;
  39730. dispose(camera?: Camera): void;
  39731. }
  39732. }
  39733. declare module BABYLON {
  39734. /**
  39735. * Class containing static functions to help procedurally build meshes
  39736. */
  39737. export class GroundBuilder {
  39738. /**
  39739. * Creates a ground mesh
  39740. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39741. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39743. * @param name defines the name of the mesh
  39744. * @param options defines the options used to create the mesh
  39745. * @param scene defines the hosting scene
  39746. * @returns the ground mesh
  39747. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39748. */
  39749. static CreateGround(name: string, options: {
  39750. width?: number;
  39751. height?: number;
  39752. subdivisions?: number;
  39753. subdivisionsX?: number;
  39754. subdivisionsY?: number;
  39755. updatable?: boolean;
  39756. }, scene: any): Mesh;
  39757. /**
  39758. * Creates a tiled ground mesh
  39759. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39760. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39761. * * 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
  39762. * * 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
  39763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39764. * @param name defines the name of the mesh
  39765. * @param options defines the options used to create the mesh
  39766. * @param scene defines the hosting scene
  39767. * @returns the tiled ground mesh
  39768. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39769. */
  39770. static CreateTiledGround(name: string, options: {
  39771. xmin: number;
  39772. zmin: number;
  39773. xmax: number;
  39774. zmax: number;
  39775. subdivisions?: {
  39776. w: number;
  39777. h: number;
  39778. };
  39779. precision?: {
  39780. w: number;
  39781. h: number;
  39782. };
  39783. updatable?: boolean;
  39784. }, scene?: Nullable<Scene>): Mesh;
  39785. /**
  39786. * Creates a ground mesh from a height map
  39787. * * The parameter `url` sets the URL of the height map image resource.
  39788. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39789. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39790. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39791. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39792. * * 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.
  39793. * * 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).
  39794. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39796. * @param name defines the name of the mesh
  39797. * @param url defines the url to the height map
  39798. * @param options defines the options used to create the mesh
  39799. * @param scene defines the hosting scene
  39800. * @returns the ground mesh
  39801. * @see https://doc.babylonjs.com/babylon101/height_map
  39802. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39803. */
  39804. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39805. width?: number;
  39806. height?: number;
  39807. subdivisions?: number;
  39808. minHeight?: number;
  39809. maxHeight?: number;
  39810. colorFilter?: Color3;
  39811. alphaFilter?: number;
  39812. updatable?: boolean;
  39813. onReady?: (mesh: GroundMesh) => void;
  39814. }, scene?: Nullable<Scene>): GroundMesh;
  39815. }
  39816. }
  39817. declare module BABYLON {
  39818. /**
  39819. * Class containing static functions to help procedurally build meshes
  39820. */
  39821. export class TorusBuilder {
  39822. /**
  39823. * Creates a torus mesh
  39824. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39825. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39826. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39828. * * 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
  39829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39830. * @param name defines the name of the mesh
  39831. * @param options defines the options used to create the mesh
  39832. * @param scene defines the hosting scene
  39833. * @returns the torus mesh
  39834. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39835. */
  39836. static CreateTorus(name: string, options: {
  39837. diameter?: number;
  39838. thickness?: number;
  39839. tessellation?: number;
  39840. updatable?: boolean;
  39841. sideOrientation?: number;
  39842. frontUVs?: Vector4;
  39843. backUVs?: Vector4;
  39844. }, scene: any): Mesh;
  39845. }
  39846. }
  39847. declare module BABYLON {
  39848. /**
  39849. * Class containing static functions to help procedurally build meshes
  39850. */
  39851. export class CylinderBuilder {
  39852. /**
  39853. * Creates a cylinder or a cone mesh
  39854. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39855. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39856. * * 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.
  39857. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39858. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39859. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39860. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39861. * * 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).
  39862. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39863. * * 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).
  39864. * * 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
  39865. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39866. * * 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
  39867. * * 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.
  39868. * * If `enclose` is false, a ring surface is one element.
  39869. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39870. * * 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
  39871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39872. * * 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
  39873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39874. * @param name defines the name of the mesh
  39875. * @param options defines the options used to create the mesh
  39876. * @param scene defines the hosting scene
  39877. * @returns the cylinder mesh
  39878. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39879. */
  39880. static CreateCylinder(name: string, options: {
  39881. height?: number;
  39882. diameterTop?: number;
  39883. diameterBottom?: number;
  39884. diameter?: number;
  39885. tessellation?: number;
  39886. subdivisions?: number;
  39887. arc?: number;
  39888. faceColors?: Color4[];
  39889. faceUV?: Vector4[];
  39890. updatable?: boolean;
  39891. hasRings?: boolean;
  39892. enclose?: boolean;
  39893. cap?: number;
  39894. sideOrientation?: number;
  39895. frontUVs?: Vector4;
  39896. backUVs?: Vector4;
  39897. }, scene: any): Mesh;
  39898. }
  39899. }
  39900. declare module BABYLON {
  39901. /**
  39902. * Options to modify the vr teleportation behavior.
  39903. */
  39904. export interface VRTeleportationOptions {
  39905. /**
  39906. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39907. */
  39908. floorMeshName?: string;
  39909. /**
  39910. * A list of meshes to be used as the teleportation floor. (default: empty)
  39911. */
  39912. floorMeshes?: Mesh[];
  39913. }
  39914. /**
  39915. * Options to modify the vr experience helper's behavior.
  39916. */
  39917. export interface VRExperienceHelperOptions extends WebVROptions {
  39918. /**
  39919. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39920. */
  39921. createDeviceOrientationCamera?: boolean;
  39922. /**
  39923. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39924. */
  39925. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39926. /**
  39927. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39928. */
  39929. laserToggle?: boolean;
  39930. /**
  39931. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39932. */
  39933. floorMeshes?: Mesh[];
  39934. /**
  39935. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39936. */
  39937. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39938. }
  39939. /**
  39940. * Event containing information after VR has been entered
  39941. */
  39942. export class OnAfterEnteringVRObservableEvent {
  39943. /**
  39944. * If entering vr was successful
  39945. */
  39946. success: boolean;
  39947. }
  39948. /**
  39949. * Helps to quickly add VR support to an existing scene.
  39950. * See http://doc.babylonjs.com/how_to/webvr_helper
  39951. */
  39952. export class VRExperienceHelper {
  39953. /** Options to modify the vr experience helper's behavior. */
  39954. webVROptions: VRExperienceHelperOptions;
  39955. private _scene;
  39956. private _position;
  39957. private _btnVR;
  39958. private _btnVRDisplayed;
  39959. private _webVRsupported;
  39960. private _webVRready;
  39961. private _webVRrequesting;
  39962. private _webVRpresenting;
  39963. private _hasEnteredVR;
  39964. private _fullscreenVRpresenting;
  39965. private _canvas;
  39966. private _webVRCamera;
  39967. private _vrDeviceOrientationCamera;
  39968. private _deviceOrientationCamera;
  39969. private _existingCamera;
  39970. private _onKeyDown;
  39971. private _onVrDisplayPresentChange;
  39972. private _onVRDisplayChanged;
  39973. private _onVRRequestPresentStart;
  39974. private _onVRRequestPresentComplete;
  39975. /**
  39976. * Observable raised right before entering VR.
  39977. */
  39978. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39979. /**
  39980. * Observable raised when entering VR has completed.
  39981. */
  39982. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39983. /**
  39984. * Observable raised when exiting VR.
  39985. */
  39986. onExitingVRObservable: Observable<VRExperienceHelper>;
  39987. /**
  39988. * Observable raised when controller mesh is loaded.
  39989. */
  39990. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39991. /** Return this.onEnteringVRObservable
  39992. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39993. */
  39994. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39995. /** Return this.onExitingVRObservable
  39996. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39997. */
  39998. readonly onExitingVR: Observable<VRExperienceHelper>;
  39999. /** Return this.onControllerMeshLoadedObservable
  40000. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40001. */
  40002. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40003. private _rayLength;
  40004. private _useCustomVRButton;
  40005. private _teleportationRequested;
  40006. private _teleportActive;
  40007. private _floorMeshName;
  40008. private _floorMeshesCollection;
  40009. private _rotationAllowed;
  40010. private _teleportBackwardsVector;
  40011. private _teleportationTarget;
  40012. private _isDefaultTeleportationTarget;
  40013. private _postProcessMove;
  40014. private _teleportationFillColor;
  40015. private _teleportationBorderColor;
  40016. private _rotationAngle;
  40017. private _haloCenter;
  40018. private _cameraGazer;
  40019. private _padSensibilityUp;
  40020. private _padSensibilityDown;
  40021. private _leftController;
  40022. private _rightController;
  40023. /**
  40024. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40025. */
  40026. onNewMeshSelected: Observable<AbstractMesh>;
  40027. /**
  40028. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40029. */
  40030. onNewMeshPicked: Observable<PickingInfo>;
  40031. private _circleEase;
  40032. /**
  40033. * Observable raised before camera teleportation
  40034. */
  40035. onBeforeCameraTeleport: Observable<Vector3>;
  40036. /**
  40037. * Observable raised after camera teleportation
  40038. */
  40039. onAfterCameraTeleport: Observable<Vector3>;
  40040. /**
  40041. * Observable raised when current selected mesh gets unselected
  40042. */
  40043. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40044. private _raySelectionPredicate;
  40045. /**
  40046. * To be optionaly changed by user to define custom ray selection
  40047. */
  40048. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40049. /**
  40050. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40051. */
  40052. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40053. /**
  40054. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40055. */
  40056. teleportationEnabled: boolean;
  40057. private _defaultHeight;
  40058. private _teleportationInitialized;
  40059. private _interactionsEnabled;
  40060. private _interactionsRequested;
  40061. private _displayGaze;
  40062. private _displayLaserPointer;
  40063. /**
  40064. * The mesh used to display where the user is going to teleport.
  40065. */
  40066. /**
  40067. * Sets the mesh to be used to display where the user is going to teleport.
  40068. */
  40069. teleportationTarget: Mesh;
  40070. /**
  40071. * 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
  40072. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40073. * See http://doc.babylonjs.com/resources/baking_transformations
  40074. */
  40075. gazeTrackerMesh: Mesh;
  40076. /**
  40077. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40078. */
  40079. updateGazeTrackerScale: boolean;
  40080. /**
  40081. * If the gaze trackers color should be updated when selecting meshes
  40082. */
  40083. updateGazeTrackerColor: boolean;
  40084. /**
  40085. * The gaze tracking mesh corresponding to the left controller
  40086. */
  40087. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40088. /**
  40089. * The gaze tracking mesh corresponding to the right controller
  40090. */
  40091. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40092. /**
  40093. * If the ray of the gaze should be displayed.
  40094. */
  40095. /**
  40096. * Sets if the ray of the gaze should be displayed.
  40097. */
  40098. displayGaze: boolean;
  40099. /**
  40100. * If the ray of the LaserPointer should be displayed.
  40101. */
  40102. /**
  40103. * Sets if the ray of the LaserPointer should be displayed.
  40104. */
  40105. displayLaserPointer: boolean;
  40106. /**
  40107. * The deviceOrientationCamera used as the camera when not in VR.
  40108. */
  40109. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40110. /**
  40111. * Based on the current WebVR support, returns the current VR camera used.
  40112. */
  40113. readonly currentVRCamera: Nullable<Camera>;
  40114. /**
  40115. * The webVRCamera which is used when in VR.
  40116. */
  40117. readonly webVRCamera: WebVRFreeCamera;
  40118. /**
  40119. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40120. */
  40121. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40122. private readonly _teleportationRequestInitiated;
  40123. /**
  40124. * Defines wether or not Pointer lock should be requested when switching to
  40125. * full screen.
  40126. */
  40127. requestPointerLockOnFullScreen: boolean;
  40128. /**
  40129. * Instantiates a VRExperienceHelper.
  40130. * Helps to quickly add VR support to an existing scene.
  40131. * @param scene The scene the VRExperienceHelper belongs to.
  40132. * @param webVROptions Options to modify the vr experience helper's behavior.
  40133. */
  40134. constructor(scene: Scene,
  40135. /** Options to modify the vr experience helper's behavior. */
  40136. webVROptions?: VRExperienceHelperOptions);
  40137. private _onDefaultMeshLoaded;
  40138. private _onResize;
  40139. private _onFullscreenChange;
  40140. /**
  40141. * Gets a value indicating if we are currently in VR mode.
  40142. */
  40143. readonly isInVRMode: boolean;
  40144. private onVrDisplayPresentChange;
  40145. private onVRDisplayChanged;
  40146. private moveButtonToBottomRight;
  40147. private displayVRButton;
  40148. private updateButtonVisibility;
  40149. private _cachedAngularSensibility;
  40150. /**
  40151. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40152. * Otherwise, will use the fullscreen API.
  40153. */
  40154. enterVR(): void;
  40155. /**
  40156. * Attempt to exit VR, or fullscreen.
  40157. */
  40158. exitVR(): void;
  40159. /**
  40160. * The position of the vr experience helper.
  40161. */
  40162. /**
  40163. * Sets the position of the vr experience helper.
  40164. */
  40165. position: Vector3;
  40166. /**
  40167. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40168. */
  40169. enableInteractions(): void;
  40170. private readonly _noControllerIsActive;
  40171. private beforeRender;
  40172. private _isTeleportationFloor;
  40173. /**
  40174. * Adds a floor mesh to be used for teleportation.
  40175. * @param floorMesh the mesh to be used for teleportation.
  40176. */
  40177. addFloorMesh(floorMesh: Mesh): void;
  40178. /**
  40179. * Removes a floor mesh from being used for teleportation.
  40180. * @param floorMesh the mesh to be removed.
  40181. */
  40182. removeFloorMesh(floorMesh: Mesh): void;
  40183. /**
  40184. * Enables interactions and teleportation using the VR controllers and gaze.
  40185. * @param vrTeleportationOptions options to modify teleportation behavior.
  40186. */
  40187. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40188. private _onNewGamepadConnected;
  40189. private _tryEnableInteractionOnController;
  40190. private _onNewGamepadDisconnected;
  40191. private _enableInteractionOnController;
  40192. private _checkTeleportWithRay;
  40193. private _checkRotate;
  40194. private _checkTeleportBackwards;
  40195. private _enableTeleportationOnController;
  40196. private _createTeleportationCircles;
  40197. private _displayTeleportationTarget;
  40198. private _hideTeleportationTarget;
  40199. private _rotateCamera;
  40200. private _moveTeleportationSelectorTo;
  40201. private _workingVector;
  40202. private _workingQuaternion;
  40203. private _workingMatrix;
  40204. /**
  40205. * Teleports the users feet to the desired location
  40206. * @param location The location where the user's feet should be placed
  40207. */
  40208. teleportCamera(location: Vector3): void;
  40209. private _convertNormalToDirectionOfRay;
  40210. private _castRayAndSelectObject;
  40211. private _notifySelectedMeshUnselected;
  40212. /**
  40213. * Sets the color of the laser ray from the vr controllers.
  40214. * @param color new color for the ray.
  40215. */
  40216. changeLaserColor(color: Color3): void;
  40217. /**
  40218. * Sets the color of the ray from the vr headsets gaze.
  40219. * @param color new color for the ray.
  40220. */
  40221. changeGazeColor(color: Color3): void;
  40222. /**
  40223. * Exits VR and disposes of the vr experience helper
  40224. */
  40225. dispose(): void;
  40226. /**
  40227. * Gets the name of the VRExperienceHelper class
  40228. * @returns "VRExperienceHelper"
  40229. */
  40230. getClassName(): string;
  40231. }
  40232. }
  40233. declare module BABYLON {
  40234. /**
  40235. * Manages an XRSession
  40236. * @see https://doc.babylonjs.com/how_to/webxr
  40237. */
  40238. export class WebXRSessionManager implements IDisposable {
  40239. private scene;
  40240. /**
  40241. * Fires every time a new xrFrame arrives which can be used to update the camera
  40242. */
  40243. onXRFrameObservable: Observable<any>;
  40244. /**
  40245. * Fires when the xr session is ended either by the device or manually done
  40246. */
  40247. onXRSessionEnded: Observable<any>;
  40248. /** @hidden */
  40249. _xrSession: XRSession;
  40250. /** @hidden */
  40251. _frameOfReference: XRFrameOfReference;
  40252. /** @hidden */
  40253. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40254. /** @hidden */
  40255. _currentXRFrame: Nullable<XRFrame>;
  40256. private _xrNavigator;
  40257. private _xrDevice;
  40258. private _tmpMatrix;
  40259. /**
  40260. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40261. * @param scene The scene which the session should be created for
  40262. */
  40263. constructor(scene: Scene);
  40264. /**
  40265. * Initializes the manager
  40266. * After initialization enterXR can be called to start an XR session
  40267. * @returns Promise which resolves after it is initialized
  40268. */
  40269. initializeAsync(): Promise<void>;
  40270. /**
  40271. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40272. * @param sessionCreationOptions xr options to create the session with
  40273. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40274. * @returns Promise which resolves after it enters XR
  40275. */
  40276. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40277. /**
  40278. * Stops the xrSession and restores the renderloop
  40279. * @returns Promise which resolves after it exits XR
  40280. */
  40281. exitXRAsync(): Promise<void>;
  40282. /**
  40283. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40284. * @param ray ray to cast into the environment
  40285. * @returns Promise which resolves with a collision point in the environment if it exists
  40286. */
  40287. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40288. /**
  40289. * Checks if a session would be supported for the creation options specified
  40290. * @param options creation options to check if they are supported
  40291. * @returns true if supported
  40292. */
  40293. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40294. /**
  40295. * @hidden
  40296. * Converts the render layer of xrSession to a render target
  40297. * @param session session to create render target for
  40298. * @param scene scene the new render target should be created for
  40299. */
  40300. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40301. /**
  40302. * Disposes of the session manager
  40303. */
  40304. dispose(): void;
  40305. }
  40306. }
  40307. declare module BABYLON {
  40308. /**
  40309. * WebXR Camera which holds the views for the xrSession
  40310. * @see https://doc.babylonjs.com/how_to/webxr
  40311. */
  40312. export class WebXRCamera extends FreeCamera {
  40313. private static _TmpMatrix;
  40314. /**
  40315. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40316. * @param name the name of the camera
  40317. * @param scene the scene to add the camera to
  40318. */
  40319. constructor(name: string, scene: Scene);
  40320. private _updateNumberOfRigCameras;
  40321. /** @hidden */
  40322. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40323. /**
  40324. * Updates the cameras position from the current pose information of the XR session
  40325. * @param xrSessionManager the session containing pose information
  40326. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40327. */
  40328. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40329. }
  40330. }
  40331. declare module BABYLON {
  40332. /**
  40333. * States of the webXR experience
  40334. */
  40335. export enum WebXRState {
  40336. /**
  40337. * Transitioning to being in XR mode
  40338. */
  40339. ENTERING_XR = 0,
  40340. /**
  40341. * Transitioning to non XR mode
  40342. */
  40343. EXITING_XR = 1,
  40344. /**
  40345. * In XR mode and presenting
  40346. */
  40347. IN_XR = 2,
  40348. /**
  40349. * Not entered XR mode
  40350. */
  40351. NOT_IN_XR = 3
  40352. }
  40353. /**
  40354. * Helper class used to enable XR
  40355. * @see https://doc.babylonjs.com/how_to/webxr
  40356. */
  40357. export class WebXRExperienceHelper implements IDisposable {
  40358. private scene;
  40359. /**
  40360. * 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
  40361. */
  40362. container: AbstractMesh;
  40363. /**
  40364. * Camera used to render xr content
  40365. */
  40366. camera: WebXRCamera;
  40367. /**
  40368. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40369. */
  40370. state: WebXRState;
  40371. private _setState;
  40372. private static _TmpVector;
  40373. /**
  40374. * Fires when the state of the experience helper has changed
  40375. */
  40376. onStateChangedObservable: Observable<WebXRState>;
  40377. /** @hidden */
  40378. _sessionManager: WebXRSessionManager;
  40379. private _nonVRCamera;
  40380. private _originalSceneAutoClear;
  40381. private _supported;
  40382. /**
  40383. * Creates the experience helper
  40384. * @param scene the scene to attach the experience helper to
  40385. * @returns a promise for the experience helper
  40386. */
  40387. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40388. /**
  40389. * Creates a WebXRExperienceHelper
  40390. * @param scene The scene the helper should be created in
  40391. */
  40392. private constructor();
  40393. /**
  40394. * Exits XR mode and returns the scene to its original state
  40395. * @returns promise that resolves after xr mode has exited
  40396. */
  40397. exitXRAsync(): Promise<void>;
  40398. /**
  40399. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40400. * @param sessionCreationOptions options for the XR session
  40401. * @param frameOfReference frame of reference of the XR session
  40402. * @returns promise that resolves after xr mode has entered
  40403. */
  40404. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40405. /**
  40406. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40407. * @param ray ray to cast into the environment
  40408. * @returns Promise which resolves with a collision point in the environment if it exists
  40409. */
  40410. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40411. /**
  40412. * Updates the global position of the camera by moving the camera's container
  40413. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40414. * @param position The desired global position of the camera
  40415. */
  40416. setPositionOfCameraUsingContainer(position: Vector3): void;
  40417. /**
  40418. * Rotates the xr camera by rotating the camera's container around the camera's position
  40419. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40420. * @param rotation the desired quaternion rotation to apply to the camera
  40421. */
  40422. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40423. /**
  40424. * Checks if the creation options are supported by the xr session
  40425. * @param options creation options
  40426. * @returns true if supported
  40427. */
  40428. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40429. /**
  40430. * Disposes of the experience helper
  40431. */
  40432. dispose(): void;
  40433. }
  40434. }
  40435. declare module BABYLON {
  40436. /**
  40437. * Button which can be used to enter a different mode of XR
  40438. */
  40439. export class WebXREnterExitUIButton {
  40440. /** button element */
  40441. element: HTMLElement;
  40442. /** XR initialization options for the button */
  40443. initializationOptions: XRSessionCreationOptions;
  40444. /**
  40445. * Creates a WebXREnterExitUIButton
  40446. * @param element button element
  40447. * @param initializationOptions XR initialization options for the button
  40448. */
  40449. constructor(
  40450. /** button element */
  40451. element: HTMLElement,
  40452. /** XR initialization options for the button */
  40453. initializationOptions: XRSessionCreationOptions);
  40454. /**
  40455. * Overwritable function which can be used to update the button's visuals when the state changes
  40456. * @param activeButton the current active button in the UI
  40457. */
  40458. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40459. }
  40460. /**
  40461. * Options to create the webXR UI
  40462. */
  40463. export class WebXREnterExitUIOptions {
  40464. /**
  40465. * Context to enter xr with
  40466. */
  40467. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40468. /**
  40469. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40470. */
  40471. customButtons?: Array<WebXREnterExitUIButton>;
  40472. }
  40473. /**
  40474. * UI to allow the user to enter/exit XR mode
  40475. */
  40476. export class WebXREnterExitUI implements IDisposable {
  40477. private scene;
  40478. private _overlay;
  40479. private _buttons;
  40480. private _activeButton;
  40481. /**
  40482. * Fired every time the active button is changed.
  40483. *
  40484. * When xr is entered via a button that launches xr that button will be the callback parameter
  40485. *
  40486. * When exiting xr the callback parameter will be null)
  40487. */
  40488. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40489. /**
  40490. * Creates UI to allow the user to enter/exit XR mode
  40491. * @param scene the scene to add the ui to
  40492. * @param helper the xr experience helper to enter/exit xr with
  40493. * @param options options to configure the UI
  40494. * @returns the created ui
  40495. */
  40496. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40497. private constructor();
  40498. private _updateButtons;
  40499. /**
  40500. * Disposes of the object
  40501. */
  40502. dispose(): void;
  40503. }
  40504. }
  40505. declare module BABYLON {
  40506. /**
  40507. * Represents an XR input
  40508. */
  40509. export class WebXRController {
  40510. /**
  40511. * 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
  40512. */
  40513. grip?: AbstractMesh;
  40514. /**
  40515. * Pointer which can be used to select objects or attach a visible laser to
  40516. */
  40517. pointer: AbstractMesh;
  40518. /**
  40519. * Creates the controller
  40520. * @see https://doc.babylonjs.com/how_to/webxr
  40521. * @param scene the scene which the controller should be associated to
  40522. */
  40523. constructor(scene: Scene);
  40524. /**
  40525. * Disposes of the object
  40526. */
  40527. dispose(): void;
  40528. }
  40529. /**
  40530. * XR input used to track XR inputs such as controllers/rays
  40531. */
  40532. export class WebXRInput implements IDisposable {
  40533. private helper;
  40534. /**
  40535. * XR controllers being tracked
  40536. */
  40537. controllers: Array<WebXRController>;
  40538. private _tmpMatrix;
  40539. private _frameObserver;
  40540. /**
  40541. * Initializes the WebXRInput
  40542. * @param helper experience helper which the input should be created for
  40543. */
  40544. constructor(helper: WebXRExperienceHelper);
  40545. /**
  40546. * Disposes of the object
  40547. */
  40548. dispose(): void;
  40549. }
  40550. }
  40551. declare module BABYLON {
  40552. /**
  40553. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40554. */
  40555. export class WebXRManagedOutputCanvas implements IDisposable {
  40556. private _canvas;
  40557. /**
  40558. * xrpresent context of the canvas which can be used to display/mirror xr content
  40559. */
  40560. canvasContext: Nullable<WebGLRenderingContext>;
  40561. /**
  40562. * Initializes the canvas to be added/removed upon entering/exiting xr
  40563. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40564. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40565. */
  40566. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40567. /**
  40568. * Disposes of the object
  40569. */
  40570. dispose(): void;
  40571. private _setManagedOutputCanvas;
  40572. private _addCanvas;
  40573. private _removeCanvas;
  40574. }
  40575. }
  40576. declare module BABYLON {
  40577. /**
  40578. * Contains an array of blocks representing the octree
  40579. */
  40580. export interface IOctreeContainer<T> {
  40581. /**
  40582. * Blocks within the octree
  40583. */
  40584. blocks: Array<OctreeBlock<T>>;
  40585. }
  40586. /**
  40587. * Class used to store a cell in an octree
  40588. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40589. */
  40590. export class OctreeBlock<T> {
  40591. /**
  40592. * Gets the content of the current block
  40593. */
  40594. entries: T[];
  40595. /**
  40596. * Gets the list of block children
  40597. */
  40598. blocks: Array<OctreeBlock<T>>;
  40599. private _depth;
  40600. private _maxDepth;
  40601. private _capacity;
  40602. private _minPoint;
  40603. private _maxPoint;
  40604. private _boundingVectors;
  40605. private _creationFunc;
  40606. /**
  40607. * Creates a new block
  40608. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40609. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40610. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40611. * @param depth defines the current depth of this block in the octree
  40612. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40613. * @param creationFunc defines a callback to call when an element is added to the block
  40614. */
  40615. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40616. /**
  40617. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40618. */
  40619. readonly capacity: number;
  40620. /**
  40621. * Gets the minimum vector (in world space) of the block's bounding box
  40622. */
  40623. readonly minPoint: Vector3;
  40624. /**
  40625. * Gets the maximum vector (in world space) of the block's bounding box
  40626. */
  40627. readonly maxPoint: Vector3;
  40628. /**
  40629. * Add a new element to this block
  40630. * @param entry defines the element to add
  40631. */
  40632. addEntry(entry: T): void;
  40633. /**
  40634. * Remove an element from this block
  40635. * @param entry defines the element to remove
  40636. */
  40637. removeEntry(entry: T): void;
  40638. /**
  40639. * Add an array of elements to this block
  40640. * @param entries defines the array of elements to add
  40641. */
  40642. addEntries(entries: T[]): void;
  40643. /**
  40644. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40645. * @param frustumPlanes defines the frustum planes to test
  40646. * @param selection defines the array to store current content if selection is positive
  40647. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40648. */
  40649. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40650. /**
  40651. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40652. * @param sphereCenter defines the bounding sphere center
  40653. * @param sphereRadius defines the bounding sphere radius
  40654. * @param selection defines the array to store current content if selection is positive
  40655. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40656. */
  40657. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40658. /**
  40659. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40660. * @param ray defines the ray to test with
  40661. * @param selection defines the array to store current content if selection is positive
  40662. */
  40663. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40664. /**
  40665. * Subdivide the content into child blocks (this block will then be empty)
  40666. */
  40667. createInnerBlocks(): void;
  40668. /**
  40669. * @hidden
  40670. */
  40671. 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;
  40672. }
  40673. }
  40674. declare module BABYLON {
  40675. /**
  40676. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40677. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40678. */
  40679. export class Octree<T> {
  40680. /** 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.) */
  40681. maxDepth: number;
  40682. /**
  40683. * Blocks within the octree containing objects
  40684. */
  40685. blocks: Array<OctreeBlock<T>>;
  40686. /**
  40687. * Content stored in the octree
  40688. */
  40689. dynamicContent: T[];
  40690. private _maxBlockCapacity;
  40691. private _selectionContent;
  40692. private _creationFunc;
  40693. /**
  40694. * Creates a octree
  40695. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40696. * @param creationFunc function to be used to instatiate the octree
  40697. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40698. * @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.)
  40699. */
  40700. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40701. /** 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.) */
  40702. maxDepth?: number);
  40703. /**
  40704. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40705. * @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);
  40706. * @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);
  40707. * @param entries meshes to be added to the octree blocks
  40708. */
  40709. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40710. /**
  40711. * Adds a mesh to the octree
  40712. * @param entry Mesh to add to the octree
  40713. */
  40714. addMesh(entry: T): void;
  40715. /**
  40716. * Remove an element from the octree
  40717. * @param entry defines the element to remove
  40718. */
  40719. removeMesh(entry: T): void;
  40720. /**
  40721. * Selects an array of meshes within the frustum
  40722. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40723. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40724. * @returns array of meshes within the frustum
  40725. */
  40726. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40727. /**
  40728. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40729. * @param sphereCenter defines the bounding sphere center
  40730. * @param sphereRadius defines the bounding sphere radius
  40731. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40732. * @returns an array of objects that intersect the sphere
  40733. */
  40734. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40735. /**
  40736. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40737. * @param ray defines the ray to test with
  40738. * @returns array of intersected objects
  40739. */
  40740. intersectsRay(ray: Ray): SmartArray<T>;
  40741. /**
  40742. * Adds a mesh into the octree block if it intersects the block
  40743. */
  40744. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40745. /**
  40746. * Adds a submesh into the octree block if it intersects the block
  40747. */
  40748. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40749. }
  40750. }
  40751. declare module BABYLON {
  40752. interface Scene {
  40753. /**
  40754. * @hidden
  40755. * Backing Filed
  40756. */
  40757. _selectionOctree: Octree<AbstractMesh>;
  40758. /**
  40759. * Gets the octree used to boost mesh selection (picking)
  40760. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40761. */
  40762. selectionOctree: Octree<AbstractMesh>;
  40763. /**
  40764. * Creates or updates the octree used to boost selection (picking)
  40765. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40766. * @param maxCapacity defines the maximum capacity per leaf
  40767. * @param maxDepth defines the maximum depth of the octree
  40768. * @returns an octree of AbstractMesh
  40769. */
  40770. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40771. }
  40772. interface AbstractMesh {
  40773. /**
  40774. * @hidden
  40775. * Backing Field
  40776. */
  40777. _submeshesOctree: Octree<SubMesh>;
  40778. /**
  40779. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40780. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40781. * @param maxCapacity defines the maximum size of each block (64 by default)
  40782. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40783. * @returns the new octree
  40784. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40785. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40786. */
  40787. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40788. }
  40789. /**
  40790. * Defines the octree scene component responsible to manage any octrees
  40791. * in a given scene.
  40792. */
  40793. export class OctreeSceneComponent {
  40794. /**
  40795. * The component name help to identify the component in the list of scene components.
  40796. */
  40797. readonly name: string;
  40798. /**
  40799. * The scene the component belongs to.
  40800. */
  40801. scene: Scene;
  40802. /**
  40803. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40804. */
  40805. readonly checksIsEnabled: boolean;
  40806. /**
  40807. * Creates a new instance of the component for the given scene
  40808. * @param scene Defines the scene to register the component in
  40809. */
  40810. constructor(scene: Scene);
  40811. /**
  40812. * Registers the component in a given scene
  40813. */
  40814. register(): void;
  40815. /**
  40816. * Return the list of active meshes
  40817. * @returns the list of active meshes
  40818. */
  40819. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40820. /**
  40821. * Return the list of active sub meshes
  40822. * @param mesh The mesh to get the candidates sub meshes from
  40823. * @returns the list of active sub meshes
  40824. */
  40825. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40826. private _tempRay;
  40827. /**
  40828. * Return the list of sub meshes intersecting with a given local ray
  40829. * @param mesh defines the mesh to find the submesh for
  40830. * @param localRay defines the ray in local space
  40831. * @returns the list of intersecting sub meshes
  40832. */
  40833. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40834. /**
  40835. * Return the list of sub meshes colliding with a collider
  40836. * @param mesh defines the mesh to find the submesh for
  40837. * @param collider defines the collider to evaluate the collision against
  40838. * @returns the list of colliding sub meshes
  40839. */
  40840. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40841. /**
  40842. * Rebuilds the elements related to this component in case of
  40843. * context lost for instance.
  40844. */
  40845. rebuild(): void;
  40846. /**
  40847. * Disposes the component and the associated ressources.
  40848. */
  40849. dispose(): void;
  40850. }
  40851. }
  40852. declare module BABYLON {
  40853. /**
  40854. * Renders a layer on top of an existing scene
  40855. */
  40856. export class UtilityLayerRenderer implements IDisposable {
  40857. /** the original scene that will be rendered on top of */
  40858. originalScene: Scene;
  40859. private _pointerCaptures;
  40860. private _lastPointerEvents;
  40861. private static _DefaultUtilityLayer;
  40862. private static _DefaultKeepDepthUtilityLayer;
  40863. private _sharedGizmoLight;
  40864. /**
  40865. * @hidden
  40866. * Light which used by gizmos to get light shading
  40867. */
  40868. _getSharedGizmoLight(): HemisphericLight;
  40869. /**
  40870. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40871. */
  40872. pickUtilitySceneFirst: boolean;
  40873. /**
  40874. * 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)
  40875. */
  40876. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40877. /**
  40878. * 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)
  40879. */
  40880. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40881. /**
  40882. * The scene that is rendered on top of the original scene
  40883. */
  40884. utilityLayerScene: Scene;
  40885. /**
  40886. * If the utility layer should automatically be rendered on top of existing scene
  40887. */
  40888. shouldRender: boolean;
  40889. /**
  40890. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40891. */
  40892. onlyCheckPointerDownEvents: boolean;
  40893. /**
  40894. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40895. */
  40896. processAllEvents: boolean;
  40897. /**
  40898. * Observable raised when the pointer move from the utility layer scene to the main scene
  40899. */
  40900. onPointerOutObservable: Observable<number>;
  40901. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40902. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40903. private _afterRenderObserver;
  40904. private _sceneDisposeObserver;
  40905. private _originalPointerObserver;
  40906. /**
  40907. * Instantiates a UtilityLayerRenderer
  40908. * @param originalScene the original scene that will be rendered on top of
  40909. * @param handleEvents boolean indicating if the utility layer should handle events
  40910. */
  40911. constructor(
  40912. /** the original scene that will be rendered on top of */
  40913. originalScene: Scene, handleEvents?: boolean);
  40914. private _notifyObservers;
  40915. /**
  40916. * Renders the utility layers scene on top of the original scene
  40917. */
  40918. render(): void;
  40919. /**
  40920. * Disposes of the renderer
  40921. */
  40922. dispose(): void;
  40923. private _updateCamera;
  40924. }
  40925. }
  40926. declare module BABYLON {
  40927. /**
  40928. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40929. */
  40930. export class Gizmo implements IDisposable {
  40931. /** The utility layer the gizmo will be added to */
  40932. gizmoLayer: UtilityLayerRenderer;
  40933. /**
  40934. * The root mesh of the gizmo
  40935. */
  40936. _rootMesh: Mesh;
  40937. private _attachedMesh;
  40938. /**
  40939. * Ratio for the scale of the gizmo (Default: 1)
  40940. */
  40941. scaleRatio: number;
  40942. /**
  40943. * If a custom mesh has been set (Default: false)
  40944. */
  40945. protected _customMeshSet: boolean;
  40946. /**
  40947. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40948. * * When set, interactions will be enabled
  40949. */
  40950. attachedMesh: Nullable<AbstractMesh>;
  40951. /**
  40952. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40953. * @param mesh The mesh to replace the default mesh of the gizmo
  40954. */
  40955. setCustomMesh(mesh: Mesh): void;
  40956. /**
  40957. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40958. */
  40959. updateGizmoRotationToMatchAttachedMesh: boolean;
  40960. /**
  40961. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40962. */
  40963. updateGizmoPositionToMatchAttachedMesh: boolean;
  40964. /**
  40965. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40966. */
  40967. protected _updateScale: boolean;
  40968. protected _interactionsEnabled: boolean;
  40969. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40970. private _beforeRenderObserver;
  40971. private _tempVector;
  40972. /**
  40973. * Creates a gizmo
  40974. * @param gizmoLayer The utility layer the gizmo will be added to
  40975. */
  40976. constructor(
  40977. /** The utility layer the gizmo will be added to */
  40978. gizmoLayer?: UtilityLayerRenderer);
  40979. /**
  40980. * Updates the gizmo to match the attached mesh's position/rotation
  40981. */
  40982. protected _update(): void;
  40983. /**
  40984. * Disposes of the gizmo
  40985. */
  40986. dispose(): void;
  40987. }
  40988. }
  40989. declare module BABYLON {
  40990. /**
  40991. * Single plane drag gizmo
  40992. */
  40993. export class PlaneDragGizmo extends Gizmo {
  40994. /**
  40995. * Drag behavior responsible for the gizmos dragging interactions
  40996. */
  40997. dragBehavior: PointerDragBehavior;
  40998. private _pointerObserver;
  40999. /**
  41000. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41001. */
  41002. snapDistance: number;
  41003. /**
  41004. * Event that fires each time the gizmo snaps to a new location.
  41005. * * snapDistance is the the change in distance
  41006. */
  41007. onSnapObservable: Observable<{
  41008. snapDistance: number;
  41009. }>;
  41010. private _plane;
  41011. private _coloredMaterial;
  41012. private _hoverMaterial;
  41013. private _isEnabled;
  41014. private _parent;
  41015. /** @hidden */
  41016. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  41017. /** @hidden */
  41018. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41019. /**
  41020. * Creates a PlaneDragGizmo
  41021. * @param gizmoLayer The utility layer the gizmo will be added to
  41022. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  41023. * @param color The color of the gizmo
  41024. */
  41025. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41026. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41027. /**
  41028. * If the gizmo is enabled
  41029. */
  41030. isEnabled: boolean;
  41031. /**
  41032. * Disposes of the gizmo
  41033. */
  41034. dispose(): void;
  41035. }
  41036. }
  41037. declare module BABYLON {
  41038. /**
  41039. * Gizmo that enables dragging a mesh along 3 axis
  41040. */
  41041. export class PositionGizmo extends Gizmo {
  41042. /**
  41043. * Internal gizmo used for interactions on the x axis
  41044. */
  41045. xGizmo: AxisDragGizmo;
  41046. /**
  41047. * Internal gizmo used for interactions on the y axis
  41048. */
  41049. yGizmo: AxisDragGizmo;
  41050. /**
  41051. * Internal gizmo used for interactions on the z axis
  41052. */
  41053. zGizmo: AxisDragGizmo;
  41054. /**
  41055. * Internal gizmo used for interactions on the yz plane
  41056. */
  41057. xPlaneGizmo: PlaneDragGizmo;
  41058. /**
  41059. * Internal gizmo used for interactions on the xz plane
  41060. */
  41061. yPlaneGizmo: PlaneDragGizmo;
  41062. /**
  41063. * Internal gizmo used for interactions on the xy plane
  41064. */
  41065. zPlaneGizmo: PlaneDragGizmo;
  41066. /**
  41067. * private variables
  41068. */
  41069. private _meshAttached;
  41070. private _updateGizmoRotationToMatchAttachedMesh;
  41071. private _snapDistance;
  41072. private _scaleRatio;
  41073. /** Fires an event when any of it's sub gizmos are dragged */
  41074. onDragStartObservable: Observable<{}>;
  41075. /** Fires an event when any of it's sub gizmos are released from dragging */
  41076. onDragEndObservable: Observable<{}>;
  41077. /**
  41078. * If set to true, planar drag is enabled
  41079. */
  41080. private _planarGizmoEnabled;
  41081. attachedMesh: Nullable<AbstractMesh>;
  41082. /**
  41083. * Creates a PositionGizmo
  41084. * @param gizmoLayer The utility layer the gizmo will be added to
  41085. */
  41086. constructor(gizmoLayer?: UtilityLayerRenderer);
  41087. /**
  41088. * If the planar drag gizmo is enabled
  41089. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  41090. */
  41091. planarGizmoEnabled: boolean;
  41092. updateGizmoRotationToMatchAttachedMesh: boolean;
  41093. /**
  41094. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41095. */
  41096. snapDistance: number;
  41097. /**
  41098. * Ratio for the scale of the gizmo (Default: 1)
  41099. */
  41100. scaleRatio: number;
  41101. /**
  41102. * Disposes of the gizmo
  41103. */
  41104. dispose(): void;
  41105. /**
  41106. * CustomMeshes are not supported by this gizmo
  41107. * @param mesh The mesh to replace the default mesh of the gizmo
  41108. */
  41109. setCustomMesh(mesh: Mesh): void;
  41110. }
  41111. }
  41112. declare module BABYLON {
  41113. /**
  41114. * Single axis drag gizmo
  41115. */
  41116. export class AxisDragGizmo extends Gizmo {
  41117. /**
  41118. * Drag behavior responsible for the gizmos dragging interactions
  41119. */
  41120. dragBehavior: PointerDragBehavior;
  41121. private _pointerObserver;
  41122. /**
  41123. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41124. */
  41125. snapDistance: number;
  41126. /**
  41127. * Event that fires each time the gizmo snaps to a new location.
  41128. * * snapDistance is the the change in distance
  41129. */
  41130. onSnapObservable: Observable<{
  41131. snapDistance: number;
  41132. }>;
  41133. private _isEnabled;
  41134. private _parent;
  41135. private _arrow;
  41136. private _coloredMaterial;
  41137. private _hoverMaterial;
  41138. /** @hidden */
  41139. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41140. /** @hidden */
  41141. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41142. /**
  41143. * Creates an AxisDragGizmo
  41144. * @param gizmoLayer The utility layer the gizmo will be added to
  41145. * @param dragAxis The axis which the gizmo will be able to drag on
  41146. * @param color The color of the gizmo
  41147. */
  41148. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41149. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41150. /**
  41151. * If the gizmo is enabled
  41152. */
  41153. isEnabled: boolean;
  41154. /**
  41155. * Disposes of the gizmo
  41156. */
  41157. dispose(): void;
  41158. }
  41159. }
  41160. declare module BABYLON.Debug {
  41161. /**
  41162. * The Axes viewer will show 3 axes in a specific point in space
  41163. */
  41164. export class AxesViewer {
  41165. private _xAxis;
  41166. private _yAxis;
  41167. private _zAxis;
  41168. private _scaleLinesFactor;
  41169. private _instanced;
  41170. /**
  41171. * Gets the hosting scene
  41172. */
  41173. scene: Scene;
  41174. /**
  41175. * Gets or sets a number used to scale line length
  41176. */
  41177. scaleLines: number;
  41178. /** Gets the node hierarchy used to render x-axis */
  41179. readonly xAxis: TransformNode;
  41180. /** Gets the node hierarchy used to render y-axis */
  41181. readonly yAxis: TransformNode;
  41182. /** Gets the node hierarchy used to render z-axis */
  41183. readonly zAxis: TransformNode;
  41184. /**
  41185. * Creates a new AxesViewer
  41186. * @param scene defines the hosting scene
  41187. * @param scaleLines defines a number used to scale line length (1 by default)
  41188. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41189. * @param xAxis defines the node hierarchy used to render the x-axis
  41190. * @param yAxis defines the node hierarchy used to render the y-axis
  41191. * @param zAxis defines the node hierarchy used to render the z-axis
  41192. */
  41193. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41194. /**
  41195. * Force the viewer to update
  41196. * @param position defines the position of the viewer
  41197. * @param xaxis defines the x axis of the viewer
  41198. * @param yaxis defines the y axis of the viewer
  41199. * @param zaxis defines the z axis of the viewer
  41200. */
  41201. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41202. /**
  41203. * Creates an instance of this axes viewer.
  41204. * @returns a new axes viewer with instanced meshes
  41205. */
  41206. createInstance(): AxesViewer;
  41207. /** Releases resources */
  41208. dispose(): void;
  41209. private static _SetRenderingGroupId;
  41210. }
  41211. }
  41212. declare module BABYLON.Debug {
  41213. /**
  41214. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41215. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41216. */
  41217. export class BoneAxesViewer extends AxesViewer {
  41218. /**
  41219. * Gets or sets the target mesh where to display the axes viewer
  41220. */
  41221. mesh: Nullable<Mesh>;
  41222. /**
  41223. * Gets or sets the target bone where to display the axes viewer
  41224. */
  41225. bone: Nullable<Bone>;
  41226. /** Gets current position */
  41227. pos: Vector3;
  41228. /** Gets direction of X axis */
  41229. xaxis: Vector3;
  41230. /** Gets direction of Y axis */
  41231. yaxis: Vector3;
  41232. /** Gets direction of Z axis */
  41233. zaxis: Vector3;
  41234. /**
  41235. * Creates a new BoneAxesViewer
  41236. * @param scene defines the hosting scene
  41237. * @param bone defines the target bone
  41238. * @param mesh defines the target mesh
  41239. * @param scaleLines defines a scaling factor for line length (1 by default)
  41240. */
  41241. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41242. /**
  41243. * Force the viewer to update
  41244. */
  41245. update(): void;
  41246. /** Releases resources */
  41247. dispose(): void;
  41248. }
  41249. }
  41250. declare module BABYLON {
  41251. /**
  41252. * Interface used to define scene explorer extensibility option
  41253. */
  41254. export interface IExplorerExtensibilityOption {
  41255. /**
  41256. * Define the option label
  41257. */
  41258. label: string;
  41259. /**
  41260. * Defines the action to execute on click
  41261. */
  41262. action: (entity: any) => void;
  41263. }
  41264. /**
  41265. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41266. */
  41267. export interface IExplorerExtensibilityGroup {
  41268. /**
  41269. * Defines a predicate to test if a given type mut be extended
  41270. */
  41271. predicate: (entity: any) => boolean;
  41272. /**
  41273. * Gets the list of options added to a type
  41274. */
  41275. entries: IExplorerExtensibilityOption[];
  41276. }
  41277. /**
  41278. * Interface used to define the options to use to create the Inspector
  41279. */
  41280. export interface IInspectorOptions {
  41281. /**
  41282. * Display in overlay mode (default: false)
  41283. */
  41284. overlay?: boolean;
  41285. /**
  41286. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41287. */
  41288. globalRoot?: HTMLElement;
  41289. /**
  41290. * Display the Scene explorer
  41291. */
  41292. showExplorer?: boolean;
  41293. /**
  41294. * Display the property inspector
  41295. */
  41296. showInspector?: boolean;
  41297. /**
  41298. * Display in embed mode (both panes on the right)
  41299. */
  41300. embedMode?: boolean;
  41301. /**
  41302. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41303. */
  41304. handleResize?: boolean;
  41305. /**
  41306. * Allow the panes to popup (default: true)
  41307. */
  41308. enablePopup?: boolean;
  41309. /**
  41310. * Allow the panes to be closed by users (default: true)
  41311. */
  41312. enableClose?: boolean;
  41313. /**
  41314. * Optional list of extensibility entries
  41315. */
  41316. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41317. /**
  41318. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41319. */
  41320. inspectorURL?: string;
  41321. }
  41322. interface Scene {
  41323. /**
  41324. * @hidden
  41325. * Backing field
  41326. */
  41327. _debugLayer: DebugLayer;
  41328. /**
  41329. * Gets the debug layer (aka Inspector) associated with the scene
  41330. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41331. */
  41332. debugLayer: DebugLayer;
  41333. }
  41334. /**
  41335. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41336. * what is happening in your scene
  41337. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41338. */
  41339. export class DebugLayer {
  41340. /**
  41341. * Define the url to get the inspector script from.
  41342. * By default it uses the babylonjs CDN.
  41343. * @ignoreNaming
  41344. */
  41345. static InspectorURL: string;
  41346. private _scene;
  41347. private BJSINSPECTOR;
  41348. /**
  41349. * Observable triggered when a property is changed through the inspector.
  41350. */
  41351. onPropertyChangedObservable: Observable<{
  41352. object: any;
  41353. property: string;
  41354. value: any;
  41355. initialValue: any;
  41356. }>;
  41357. /**
  41358. * Instantiates a new debug layer.
  41359. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41360. * what is happening in your scene
  41361. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41362. * @param scene Defines the scene to inspect
  41363. */
  41364. constructor(scene: Scene);
  41365. /** Creates the inspector window. */
  41366. private _createInspector;
  41367. /**
  41368. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41369. * @param entity defines the entity to select
  41370. * @param lineContainerTitle defines the specific block to highlight
  41371. */
  41372. select(entity: any, lineContainerTitle?: string): void;
  41373. /** Get the inspector from bundle or global */
  41374. private _getGlobalInspector;
  41375. /**
  41376. * Get if the inspector is visible or not.
  41377. * @returns true if visible otherwise, false
  41378. */
  41379. isVisible(): boolean;
  41380. /**
  41381. * Hide the inspector and close its window.
  41382. */
  41383. hide(): void;
  41384. /**
  41385. * Launch the debugLayer.
  41386. * @param config Define the configuration of the inspector
  41387. * @return a promise fulfilled when the debug layer is visible
  41388. */
  41389. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41390. }
  41391. }
  41392. declare module BABYLON {
  41393. /**
  41394. * Class containing static functions to help procedurally build meshes
  41395. */
  41396. export class BoxBuilder {
  41397. /**
  41398. * Creates a box mesh
  41399. * * The parameter `size` sets the size (float) of each box side (default 1)
  41400. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41401. * * 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)
  41402. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41404. * * 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
  41405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41406. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41407. * @param name defines the name of the mesh
  41408. * @param options defines the options used to create the mesh
  41409. * @param scene defines the hosting scene
  41410. * @returns the box mesh
  41411. */
  41412. static CreateBox(name: string, options: {
  41413. size?: number;
  41414. width?: number;
  41415. height?: number;
  41416. depth?: number;
  41417. faceUV?: Vector4[];
  41418. faceColors?: Color4[];
  41419. sideOrientation?: number;
  41420. frontUVs?: Vector4;
  41421. backUVs?: Vector4;
  41422. wrap?: boolean;
  41423. topBaseAt?: number;
  41424. bottomBaseAt?: number;
  41425. updatable?: boolean;
  41426. }, scene?: Nullable<Scene>): Mesh;
  41427. }
  41428. }
  41429. declare module BABYLON {
  41430. /**
  41431. * Class containing static functions to help procedurally build meshes
  41432. */
  41433. export class SphereBuilder {
  41434. /**
  41435. * Creates a sphere mesh
  41436. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41437. * * 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`)
  41438. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41439. * * 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
  41440. * * 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)
  41441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41442. * * 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
  41443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41444. * @param name defines the name of the mesh
  41445. * @param options defines the options used to create the mesh
  41446. * @param scene defines the hosting scene
  41447. * @returns the sphere mesh
  41448. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41449. */
  41450. static CreateSphere(name: string, options: {
  41451. segments?: number;
  41452. diameter?: number;
  41453. diameterX?: number;
  41454. diameterY?: number;
  41455. diameterZ?: number;
  41456. arc?: number;
  41457. slice?: number;
  41458. sideOrientation?: number;
  41459. frontUVs?: Vector4;
  41460. backUVs?: Vector4;
  41461. updatable?: boolean;
  41462. }, scene: any): Mesh;
  41463. }
  41464. }
  41465. declare module BABYLON.Debug {
  41466. /**
  41467. * Used to show the physics impostor around the specific mesh
  41468. */
  41469. export class PhysicsViewer {
  41470. /** @hidden */
  41471. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41472. /** @hidden */
  41473. protected _meshes: Array<Nullable<AbstractMesh>>;
  41474. /** @hidden */
  41475. protected _scene: Nullable<Scene>;
  41476. /** @hidden */
  41477. protected _numMeshes: number;
  41478. /** @hidden */
  41479. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41480. private _renderFunction;
  41481. private _utilityLayer;
  41482. private _debugBoxMesh;
  41483. private _debugSphereMesh;
  41484. private _debugCylinderMesh;
  41485. private _debugMaterial;
  41486. private _debugMeshMeshes;
  41487. /**
  41488. * Creates a new PhysicsViewer
  41489. * @param scene defines the hosting scene
  41490. */
  41491. constructor(scene: Scene);
  41492. /** @hidden */
  41493. protected _updateDebugMeshes(): void;
  41494. /**
  41495. * Renders a specified physic impostor
  41496. * @param impostor defines the impostor to render
  41497. * @param targetMesh defines the mesh represented by the impostor
  41498. * @returns the new debug mesh used to render the impostor
  41499. */
  41500. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  41501. /**
  41502. * Hides a specified physic impostor
  41503. * @param impostor defines the impostor to hide
  41504. */
  41505. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41506. private _getDebugMaterial;
  41507. private _getDebugBoxMesh;
  41508. private _getDebugSphereMesh;
  41509. private _getDebugCylinderMesh;
  41510. private _getDebugMeshMesh;
  41511. private _getDebugMesh;
  41512. /** Releases all resources */
  41513. dispose(): void;
  41514. }
  41515. }
  41516. declare module BABYLON {
  41517. /**
  41518. * Class containing static functions to help procedurally build meshes
  41519. */
  41520. export class LinesBuilder {
  41521. /**
  41522. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41523. * * 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
  41524. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41525. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41526. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41527. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41528. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41529. * * 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
  41530. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41532. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41533. * @param name defines the name of the new line system
  41534. * @param options defines the options used to create the line system
  41535. * @param scene defines the hosting scene
  41536. * @returns a new line system mesh
  41537. */
  41538. static CreateLineSystem(name: string, options: {
  41539. lines: Vector3[][];
  41540. updatable?: boolean;
  41541. instance?: Nullable<LinesMesh>;
  41542. colors?: Nullable<Color4[][]>;
  41543. useVertexAlpha?: boolean;
  41544. }, scene: Nullable<Scene>): LinesMesh;
  41545. /**
  41546. * Creates a line mesh
  41547. * 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
  41548. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41549. * * The parameter `points` is an array successive Vector3
  41550. * * 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
  41551. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41552. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41553. * * When updating an instance, remember that only point positions can change, not the number of points
  41554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41556. * @param name defines the name of the new line system
  41557. * @param options defines the options used to create the line system
  41558. * @param scene defines the hosting scene
  41559. * @returns a new line mesh
  41560. */
  41561. static CreateLines(name: string, options: {
  41562. points: Vector3[];
  41563. updatable?: boolean;
  41564. instance?: Nullable<LinesMesh>;
  41565. colors?: Color4[];
  41566. useVertexAlpha?: boolean;
  41567. }, scene?: Nullable<Scene>): LinesMesh;
  41568. /**
  41569. * Creates a dashed line mesh
  41570. * * 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
  41571. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41572. * * The parameter `points` is an array successive Vector3
  41573. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41574. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41575. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41576. * * 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
  41577. * * When updating an instance, remember that only point positions can change, not the number of points
  41578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41579. * @param name defines the name of the mesh
  41580. * @param options defines the options used to create the mesh
  41581. * @param scene defines the hosting scene
  41582. * @returns the dashed line mesh
  41583. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41584. */
  41585. static CreateDashedLines(name: string, options: {
  41586. points: Vector3[];
  41587. dashSize?: number;
  41588. gapSize?: number;
  41589. dashNb?: number;
  41590. updatable?: boolean;
  41591. instance?: LinesMesh;
  41592. }, scene?: Nullable<Scene>): LinesMesh;
  41593. }
  41594. }
  41595. declare module BABYLON {
  41596. /**
  41597. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41598. * in order to better appreciate the issue one might have.
  41599. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41600. */
  41601. export class RayHelper {
  41602. /**
  41603. * Defines the ray we are currently tryin to visualize.
  41604. */
  41605. ray: Nullable<Ray>;
  41606. private _renderPoints;
  41607. private _renderLine;
  41608. private _renderFunction;
  41609. private _scene;
  41610. private _updateToMeshFunction;
  41611. private _attachedToMesh;
  41612. private _meshSpaceDirection;
  41613. private _meshSpaceOrigin;
  41614. /**
  41615. * Helper function to create a colored helper in a scene in one line.
  41616. * @param ray Defines the ray we are currently tryin to visualize
  41617. * @param scene Defines the scene the ray is used in
  41618. * @param color Defines the color we want to see the ray in
  41619. * @returns The newly created ray helper.
  41620. */
  41621. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41622. /**
  41623. * Instantiate a new ray helper.
  41624. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41625. * in order to better appreciate the issue one might have.
  41626. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41627. * @param ray Defines the ray we are currently tryin to visualize
  41628. */
  41629. constructor(ray: Ray);
  41630. /**
  41631. * Shows the ray we are willing to debug.
  41632. * @param scene Defines the scene the ray needs to be rendered in
  41633. * @param color Defines the color the ray needs to be rendered in
  41634. */
  41635. show(scene: Scene, color?: Color3): void;
  41636. /**
  41637. * Hides the ray we are debugging.
  41638. */
  41639. hide(): void;
  41640. private _render;
  41641. /**
  41642. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41643. * @param mesh Defines the mesh we want the helper attached to
  41644. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41645. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41646. * @param length Defines the length of the ray
  41647. */
  41648. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41649. /**
  41650. * Detach the ray helper from the mesh it has previously been attached to.
  41651. */
  41652. detachFromMesh(): void;
  41653. private _updateToMesh;
  41654. /**
  41655. * Dispose the helper and release its associated resources.
  41656. */
  41657. dispose(): void;
  41658. }
  41659. }
  41660. declare module BABYLON.Debug {
  41661. /**
  41662. * Class used to render a debug view of a given skeleton
  41663. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41664. */
  41665. export class SkeletonViewer {
  41666. /** defines the skeleton to render */
  41667. skeleton: Skeleton;
  41668. /** defines the mesh attached to the skeleton */
  41669. mesh: AbstractMesh;
  41670. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41671. autoUpdateBonesMatrices: boolean;
  41672. /** defines the rendering group id to use with the viewer */
  41673. renderingGroupId: number;
  41674. /** Gets or sets the color used to render the skeleton */
  41675. color: Color3;
  41676. private _scene;
  41677. private _debugLines;
  41678. private _debugMesh;
  41679. private _isEnabled;
  41680. private _renderFunction;
  41681. private _utilityLayer;
  41682. /**
  41683. * Returns the mesh used to render the bones
  41684. */
  41685. readonly debugMesh: Nullable<LinesMesh>;
  41686. /**
  41687. * Creates a new SkeletonViewer
  41688. * @param skeleton defines the skeleton to render
  41689. * @param mesh defines the mesh attached to the skeleton
  41690. * @param scene defines the hosting scene
  41691. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41692. * @param renderingGroupId defines the rendering group id to use with the viewer
  41693. */
  41694. constructor(
  41695. /** defines the skeleton to render */
  41696. skeleton: Skeleton,
  41697. /** defines the mesh attached to the skeleton */
  41698. mesh: AbstractMesh, scene: Scene,
  41699. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41700. autoUpdateBonesMatrices?: boolean,
  41701. /** defines the rendering group id to use with the viewer */
  41702. renderingGroupId?: number);
  41703. /** Gets or sets a boolean indicating if the viewer is enabled */
  41704. isEnabled: boolean;
  41705. private _getBonePosition;
  41706. private _getLinesForBonesWithLength;
  41707. private _getLinesForBonesNoLength;
  41708. /** Update the viewer to sync with current skeleton state */
  41709. update(): void;
  41710. /** Release associated resources */
  41711. dispose(): void;
  41712. }
  41713. }
  41714. declare module BABYLON {
  41715. /**
  41716. * Options to create the null engine
  41717. */
  41718. export class NullEngineOptions {
  41719. /**
  41720. * Render width (Default: 512)
  41721. */
  41722. renderWidth: number;
  41723. /**
  41724. * Render height (Default: 256)
  41725. */
  41726. renderHeight: number;
  41727. /**
  41728. * Texture size (Default: 512)
  41729. */
  41730. textureSize: number;
  41731. /**
  41732. * If delta time between frames should be constant
  41733. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41734. */
  41735. deterministicLockstep: boolean;
  41736. /**
  41737. * Maximum about of steps between frames (Default: 4)
  41738. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41739. */
  41740. lockstepMaxSteps: number;
  41741. }
  41742. /**
  41743. * The null engine class provides support for headless version of babylon.js.
  41744. * This can be used in server side scenario or for testing purposes
  41745. */
  41746. export class NullEngine extends Engine {
  41747. private _options;
  41748. /**
  41749. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41750. */
  41751. isDeterministicLockStep(): boolean;
  41752. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41753. getLockstepMaxSteps(): number;
  41754. /**
  41755. * Sets hardware scaling, used to save performance if needed
  41756. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41757. */
  41758. getHardwareScalingLevel(): number;
  41759. constructor(options?: NullEngineOptions);
  41760. createVertexBuffer(vertices: FloatArray): DataBuffer;
  41761. createIndexBuffer(indices: IndicesArray): DataBuffer;
  41762. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41763. getRenderWidth(useScreen?: boolean): number;
  41764. getRenderHeight(useScreen?: boolean): number;
  41765. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41766. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41767. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41768. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41769. bindSamplers(effect: Effect): void;
  41770. enableEffect(effect: Effect): void;
  41771. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41772. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41773. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41774. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41775. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41776. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41777. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41778. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41779. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41780. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41781. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41782. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41783. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41784. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41785. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41786. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41787. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41788. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41789. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41790. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41791. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41792. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41793. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41794. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41795. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41796. bindBuffers(vertexBuffers: {
  41797. [key: string]: VertexBuffer;
  41798. }, indexBuffer: DataBuffer, effect: Effect): void;
  41799. wipeCaches(bruteForce?: boolean): void;
  41800. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41801. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41802. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41803. /** @hidden */
  41804. _createTexture(): WebGLTexture;
  41805. /** @hidden */
  41806. _releaseTexture(texture: InternalTexture): void;
  41807. 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;
  41808. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41809. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41810. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41811. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41812. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  41813. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41814. areAllEffectsReady(): boolean;
  41815. /**
  41816. * @hidden
  41817. * Get the current error code of the webGL context
  41818. * @returns the error code
  41819. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41820. */
  41821. getError(): number;
  41822. /** @hidden */
  41823. _getUnpackAlignement(): number;
  41824. /** @hidden */
  41825. _unpackFlipY(value: boolean): void;
  41826. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41827. /**
  41828. * Updates a dynamic vertex buffer.
  41829. * @param vertexBuffer the vertex buffer to update
  41830. * @param data the data used to update the vertex buffer
  41831. * @param byteOffset the byte offset of the data (optional)
  41832. * @param byteLength the byte length of the data (optional)
  41833. */
  41834. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41835. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41836. /** @hidden */
  41837. _bindTexture(channel: number, texture: InternalTexture): void;
  41838. /** @hidden */
  41839. _releaseBuffer(buffer: DataBuffer): boolean;
  41840. releaseEffects(): void;
  41841. displayLoadingUI(): void;
  41842. hideLoadingUI(): void;
  41843. /** @hidden */
  41844. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41845. /** @hidden */
  41846. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41847. /** @hidden */
  41848. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41849. /** @hidden */
  41850. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41851. }
  41852. }
  41853. declare module BABYLON {
  41854. /** @hidden */
  41855. export class _OcclusionDataStorage {
  41856. /** @hidden */
  41857. occlusionInternalRetryCounter: number;
  41858. /** @hidden */
  41859. isOcclusionQueryInProgress: boolean;
  41860. /** @hidden */
  41861. isOccluded: boolean;
  41862. /** @hidden */
  41863. occlusionRetryCount: number;
  41864. /** @hidden */
  41865. occlusionType: number;
  41866. /** @hidden */
  41867. occlusionQueryAlgorithmType: number;
  41868. }
  41869. interface Engine {
  41870. /**
  41871. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41872. * @return the new query
  41873. */
  41874. createQuery(): WebGLQuery;
  41875. /**
  41876. * Delete and release a webGL query
  41877. * @param query defines the query to delete
  41878. * @return the current engine
  41879. */
  41880. deleteQuery(query: WebGLQuery): Engine;
  41881. /**
  41882. * Check if a given query has resolved and got its value
  41883. * @param query defines the query to check
  41884. * @returns true if the query got its value
  41885. */
  41886. isQueryResultAvailable(query: WebGLQuery): boolean;
  41887. /**
  41888. * Gets the value of a given query
  41889. * @param query defines the query to check
  41890. * @returns the value of the query
  41891. */
  41892. getQueryResult(query: WebGLQuery): number;
  41893. /**
  41894. * Initiates an occlusion query
  41895. * @param algorithmType defines the algorithm to use
  41896. * @param query defines the query to use
  41897. * @returns the current engine
  41898. * @see http://doc.babylonjs.com/features/occlusionquery
  41899. */
  41900. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41901. /**
  41902. * Ends an occlusion query
  41903. * @see http://doc.babylonjs.com/features/occlusionquery
  41904. * @param algorithmType defines the algorithm to use
  41905. * @returns the current engine
  41906. */
  41907. endOcclusionQuery(algorithmType: number): Engine;
  41908. /**
  41909. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41910. * Please note that only one query can be issued at a time
  41911. * @returns a time token used to track the time span
  41912. */
  41913. startTimeQuery(): Nullable<_TimeToken>;
  41914. /**
  41915. * Ends a time query
  41916. * @param token defines the token used to measure the time span
  41917. * @returns the time spent (in ns)
  41918. */
  41919. endTimeQuery(token: _TimeToken): int;
  41920. /** @hidden */
  41921. _currentNonTimestampToken: Nullable<_TimeToken>;
  41922. /** @hidden */
  41923. _createTimeQuery(): WebGLQuery;
  41924. /** @hidden */
  41925. _deleteTimeQuery(query: WebGLQuery): void;
  41926. /** @hidden */
  41927. _getGlAlgorithmType(algorithmType: number): number;
  41928. /** @hidden */
  41929. _getTimeQueryResult(query: WebGLQuery): any;
  41930. /** @hidden */
  41931. _getTimeQueryAvailability(query: WebGLQuery): any;
  41932. }
  41933. interface AbstractMesh {
  41934. /**
  41935. * Backing filed
  41936. * @hidden
  41937. */
  41938. __occlusionDataStorage: _OcclusionDataStorage;
  41939. /**
  41940. * Access property
  41941. * @hidden
  41942. */
  41943. _occlusionDataStorage: _OcclusionDataStorage;
  41944. /**
  41945. * 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.
  41946. * The default value is -1 which means don't break the query and wait till the result
  41947. * @see http://doc.babylonjs.com/features/occlusionquery
  41948. */
  41949. occlusionRetryCount: number;
  41950. /**
  41951. * 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:
  41952. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41953. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41954. * * 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.
  41955. * @see http://doc.babylonjs.com/features/occlusionquery
  41956. */
  41957. occlusionType: number;
  41958. /**
  41959. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41960. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41961. * * 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.
  41962. * @see http://doc.babylonjs.com/features/occlusionquery
  41963. */
  41964. occlusionQueryAlgorithmType: number;
  41965. /**
  41966. * 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
  41967. * @see http://doc.babylonjs.com/features/occlusionquery
  41968. */
  41969. isOccluded: boolean;
  41970. /**
  41971. * Flag to check the progress status of the query
  41972. * @see http://doc.babylonjs.com/features/occlusionquery
  41973. */
  41974. isOcclusionQueryInProgress: boolean;
  41975. }
  41976. }
  41977. declare module BABYLON {
  41978. /** @hidden */
  41979. export var _forceTransformFeedbackToBundle: boolean;
  41980. interface Engine {
  41981. /**
  41982. * Creates a webGL transform feedback object
  41983. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41984. * @returns the webGL transform feedback object
  41985. */
  41986. createTransformFeedback(): WebGLTransformFeedback;
  41987. /**
  41988. * Delete a webGL transform feedback object
  41989. * @param value defines the webGL transform feedback object to delete
  41990. */
  41991. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41992. /**
  41993. * Bind a webGL transform feedback object to the webgl context
  41994. * @param value defines the webGL transform feedback object to bind
  41995. */
  41996. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41997. /**
  41998. * Begins a transform feedback operation
  41999. * @param usePoints defines if points or triangles must be used
  42000. */
  42001. beginTransformFeedback(usePoints: boolean): void;
  42002. /**
  42003. * Ends a transform feedback operation
  42004. */
  42005. endTransformFeedback(): void;
  42006. /**
  42007. * Specify the varyings to use with transform feedback
  42008. * @param program defines the associated webGL program
  42009. * @param value defines the list of strings representing the varying names
  42010. */
  42011. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42012. /**
  42013. * Bind a webGL buffer for a transform feedback operation
  42014. * @param value defines the webGL buffer to bind
  42015. */
  42016. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  42017. }
  42018. }
  42019. declare module BABYLON {
  42020. /**
  42021. * Creation options of the multi render target texture.
  42022. */
  42023. export interface IMultiRenderTargetOptions {
  42024. /**
  42025. * Define if the texture needs to create mip maps after render.
  42026. */
  42027. generateMipMaps?: boolean;
  42028. /**
  42029. * Define the types of all the draw buffers we want to create
  42030. */
  42031. types?: number[];
  42032. /**
  42033. * Define the sampling modes of all the draw buffers we want to create
  42034. */
  42035. samplingModes?: number[];
  42036. /**
  42037. * Define if a depth buffer is required
  42038. */
  42039. generateDepthBuffer?: boolean;
  42040. /**
  42041. * Define if a stencil buffer is required
  42042. */
  42043. generateStencilBuffer?: boolean;
  42044. /**
  42045. * Define if a depth texture is required instead of a depth buffer
  42046. */
  42047. generateDepthTexture?: boolean;
  42048. /**
  42049. * Define the number of desired draw buffers
  42050. */
  42051. textureCount?: number;
  42052. /**
  42053. * Define if aspect ratio should be adapted to the texture or stay the scene one
  42054. */
  42055. doNotChangeAspectRatio?: boolean;
  42056. /**
  42057. * Define the default type of the buffers we are creating
  42058. */
  42059. defaultType?: number;
  42060. }
  42061. /**
  42062. * A multi render target, like a render target provides the ability to render to a texture.
  42063. * Unlike the render target, it can render to several draw buffers in one draw.
  42064. * This is specially interesting in deferred rendering or for any effects requiring more than
  42065. * just one color from a single pass.
  42066. */
  42067. export class MultiRenderTarget extends RenderTargetTexture {
  42068. private _internalTextures;
  42069. private _textures;
  42070. private _multiRenderTargetOptions;
  42071. /**
  42072. * Get if draw buffers are currently supported by the used hardware and browser.
  42073. */
  42074. readonly isSupported: boolean;
  42075. /**
  42076. * Get the list of textures generated by the multi render target.
  42077. */
  42078. readonly textures: Texture[];
  42079. /**
  42080. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  42081. */
  42082. readonly depthTexture: Texture;
  42083. /**
  42084. * Set the wrapping mode on U of all the textures we are rendering to.
  42085. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42086. */
  42087. wrapU: number;
  42088. /**
  42089. * Set the wrapping mode on V of all the textures we are rendering to.
  42090. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42091. */
  42092. wrapV: number;
  42093. /**
  42094. * Instantiate a new multi render target texture.
  42095. * A multi render target, like a render target provides the ability to render to a texture.
  42096. * Unlike the render target, it can render to several draw buffers in one draw.
  42097. * This is specially interesting in deferred rendering or for any effects requiring more than
  42098. * just one color from a single pass.
  42099. * @param name Define the name of the texture
  42100. * @param size Define the size of the buffers to render to
  42101. * @param count Define the number of target we are rendering into
  42102. * @param scene Define the scene the texture belongs to
  42103. * @param options Define the options used to create the multi render target
  42104. */
  42105. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  42106. /** @hidden */
  42107. _rebuild(): void;
  42108. private _createInternalTextures;
  42109. private _createTextures;
  42110. /**
  42111. * Define the number of samples used if MSAA is enabled.
  42112. */
  42113. samples: number;
  42114. /**
  42115. * Resize all the textures in the multi render target.
  42116. * Be carrefull as it will recreate all the data in the new texture.
  42117. * @param size Define the new size
  42118. */
  42119. resize(size: any): void;
  42120. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  42121. /**
  42122. * Dispose the render targets and their associated resources
  42123. */
  42124. dispose(): void;
  42125. /**
  42126. * Release all the underlying texture used as draw buffers.
  42127. */
  42128. releaseInternalTextures(): void;
  42129. }
  42130. }
  42131. declare module BABYLON {
  42132. interface Engine {
  42133. /**
  42134. * Unbind a list of render target textures from the webGL context
  42135. * This is used only when drawBuffer extension or webGL2 are active
  42136. * @param textures defines the render target textures to unbind
  42137. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  42138. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  42139. */
  42140. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  42141. /**
  42142. * Create a multi render target texture
  42143. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  42144. * @param size defines the size of the texture
  42145. * @param options defines the creation options
  42146. * @returns the cube texture as an InternalTexture
  42147. */
  42148. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  42149. /**
  42150. * Update the sample count for a given multiple render target texture
  42151. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42152. * @param textures defines the textures to update
  42153. * @param samples defines the sample count to set
  42154. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42155. */
  42156. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  42157. }
  42158. }
  42159. declare module BABYLON {
  42160. /**
  42161. * Gather the list of clipboard event types as constants.
  42162. */
  42163. export class ClipboardEventTypes {
  42164. /**
  42165. * The clipboard event is fired when a copy command is active (pressed).
  42166. */
  42167. static readonly COPY: number;
  42168. /**
  42169. * The clipboard event is fired when a cut command is active (pressed).
  42170. */
  42171. static readonly CUT: number;
  42172. /**
  42173. * The clipboard event is fired when a paste command is active (pressed).
  42174. */
  42175. static readonly PASTE: number;
  42176. }
  42177. /**
  42178. * This class is used to store clipboard related info for the onClipboardObservable event.
  42179. */
  42180. export class ClipboardInfo {
  42181. /**
  42182. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42183. */
  42184. type: number;
  42185. /**
  42186. * Defines the related dom event
  42187. */
  42188. event: ClipboardEvent;
  42189. /**
  42190. *Creates an instance of ClipboardInfo.
  42191. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42192. * @param event Defines the related dom event
  42193. */
  42194. constructor(
  42195. /**
  42196. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42197. */
  42198. type: number,
  42199. /**
  42200. * Defines the related dom event
  42201. */
  42202. event: ClipboardEvent);
  42203. /**
  42204. * Get the clipboard event's type from the keycode.
  42205. * @param keyCode Defines the keyCode for the current keyboard event.
  42206. * @return {number}
  42207. */
  42208. static GetTypeFromCharacter(keyCode: number): number;
  42209. }
  42210. }
  42211. declare module BABYLON {
  42212. /**
  42213. * Class used to represent data loading progression
  42214. */
  42215. export class SceneLoaderProgressEvent {
  42216. /** defines if data length to load can be evaluated */
  42217. readonly lengthComputable: boolean;
  42218. /** defines the loaded data length */
  42219. readonly loaded: number;
  42220. /** defines the data length to load */
  42221. readonly total: number;
  42222. /**
  42223. * Create a new progress event
  42224. * @param lengthComputable defines if data length to load can be evaluated
  42225. * @param loaded defines the loaded data length
  42226. * @param total defines the data length to load
  42227. */
  42228. constructor(
  42229. /** defines if data length to load can be evaluated */
  42230. lengthComputable: boolean,
  42231. /** defines the loaded data length */
  42232. loaded: number,
  42233. /** defines the data length to load */
  42234. total: number);
  42235. /**
  42236. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42237. * @param event defines the source event
  42238. * @returns a new SceneLoaderProgressEvent
  42239. */
  42240. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42241. }
  42242. /**
  42243. * Interface used by SceneLoader plugins to define supported file extensions
  42244. */
  42245. export interface ISceneLoaderPluginExtensions {
  42246. /**
  42247. * Defines the list of supported extensions
  42248. */
  42249. [extension: string]: {
  42250. isBinary: boolean;
  42251. };
  42252. }
  42253. /**
  42254. * Interface used by SceneLoader plugin factory
  42255. */
  42256. export interface ISceneLoaderPluginFactory {
  42257. /**
  42258. * Defines the name of the factory
  42259. */
  42260. name: string;
  42261. /**
  42262. * Function called to create a new plugin
  42263. * @return the new plugin
  42264. */
  42265. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42266. /**
  42267. * Boolean indicating if the plugin can direct load specific data
  42268. */
  42269. canDirectLoad?: (data: string) => boolean;
  42270. }
  42271. /**
  42272. * Interface used to define a SceneLoader plugin
  42273. */
  42274. export interface ISceneLoaderPlugin {
  42275. /**
  42276. * The friendly name of this plugin.
  42277. */
  42278. name: string;
  42279. /**
  42280. * The file extensions supported by this plugin.
  42281. */
  42282. extensions: string | ISceneLoaderPluginExtensions;
  42283. /**
  42284. * Import meshes into a scene.
  42285. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42286. * @param scene The scene to import into
  42287. * @param data The data to import
  42288. * @param rootUrl The root url for scene and resources
  42289. * @param meshes The meshes array to import into
  42290. * @param particleSystems The particle systems array to import into
  42291. * @param skeletons The skeletons array to import into
  42292. * @param onError The callback when import fails
  42293. * @returns True if successful or false otherwise
  42294. */
  42295. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42296. /**
  42297. * Load into a scene.
  42298. * @param scene The scene to load into
  42299. * @param data The data to import
  42300. * @param rootUrl The root url for scene and resources
  42301. * @param onError The callback when import fails
  42302. * @returns true if successful or false otherwise
  42303. */
  42304. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42305. /**
  42306. * The callback that returns true if the data can be directly loaded.
  42307. */
  42308. canDirectLoad?: (data: string) => boolean;
  42309. /**
  42310. * The callback that allows custom handling of the root url based on the response url.
  42311. */
  42312. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42313. /**
  42314. * Load into an asset container.
  42315. * @param scene The scene to load into
  42316. * @param data The data to import
  42317. * @param rootUrl The root url for scene and resources
  42318. * @param onError The callback when import fails
  42319. * @returns The loaded asset container
  42320. */
  42321. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42322. }
  42323. /**
  42324. * Interface used to define an async SceneLoader plugin
  42325. */
  42326. export interface ISceneLoaderPluginAsync {
  42327. /**
  42328. * The friendly name of this plugin.
  42329. */
  42330. name: string;
  42331. /**
  42332. * The file extensions supported by this plugin.
  42333. */
  42334. extensions: string | ISceneLoaderPluginExtensions;
  42335. /**
  42336. * Import meshes into a scene.
  42337. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42338. * @param scene The scene to import into
  42339. * @param data The data to import
  42340. * @param rootUrl The root url for scene and resources
  42341. * @param onProgress The callback when the load progresses
  42342. * @param fileName Defines the name of the file to load
  42343. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42344. */
  42345. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42346. meshes: AbstractMesh[];
  42347. particleSystems: IParticleSystem[];
  42348. skeletons: Skeleton[];
  42349. animationGroups: AnimationGroup[];
  42350. }>;
  42351. /**
  42352. * Load into a scene.
  42353. * @param scene The scene to load into
  42354. * @param data The data to import
  42355. * @param rootUrl The root url for scene and resources
  42356. * @param onProgress The callback when the load progresses
  42357. * @param fileName Defines the name of the file to load
  42358. * @returns Nothing
  42359. */
  42360. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42361. /**
  42362. * The callback that returns true if the data can be directly loaded.
  42363. */
  42364. canDirectLoad?: (data: string) => boolean;
  42365. /**
  42366. * The callback that allows custom handling of the root url based on the response url.
  42367. */
  42368. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42369. /**
  42370. * Load into an asset container.
  42371. * @param scene The scene to load into
  42372. * @param data The data to import
  42373. * @param rootUrl The root url for scene and resources
  42374. * @param onProgress The callback when the load progresses
  42375. * @param fileName Defines the name of the file to load
  42376. * @returns The loaded asset container
  42377. */
  42378. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42379. }
  42380. /**
  42381. * Class used to load scene from various file formats using registered plugins
  42382. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42383. */
  42384. export class SceneLoader {
  42385. /**
  42386. * No logging while loading
  42387. */
  42388. static readonly NO_LOGGING: number;
  42389. /**
  42390. * Minimal logging while loading
  42391. */
  42392. static readonly MINIMAL_LOGGING: number;
  42393. /**
  42394. * Summary logging while loading
  42395. */
  42396. static readonly SUMMARY_LOGGING: number;
  42397. /**
  42398. * Detailled logging while loading
  42399. */
  42400. static readonly DETAILED_LOGGING: number;
  42401. /**
  42402. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42403. */
  42404. static ForceFullSceneLoadingForIncremental: boolean;
  42405. /**
  42406. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42407. */
  42408. static ShowLoadingScreen: boolean;
  42409. /**
  42410. * Defines the current logging level (while loading the scene)
  42411. * @ignorenaming
  42412. */
  42413. static loggingLevel: number;
  42414. /**
  42415. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42416. */
  42417. static CleanBoneMatrixWeights: boolean;
  42418. /**
  42419. * Event raised when a plugin is used to load a scene
  42420. */
  42421. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42422. private static _registeredPlugins;
  42423. private static _getDefaultPlugin;
  42424. private static _getPluginForExtension;
  42425. private static _getPluginForDirectLoad;
  42426. private static _getPluginForFilename;
  42427. private static _getDirectLoad;
  42428. private static _loadData;
  42429. private static _getFileInfo;
  42430. /**
  42431. * Gets a plugin that can load the given extension
  42432. * @param extension defines the extension to load
  42433. * @returns a plugin or null if none works
  42434. */
  42435. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42436. /**
  42437. * Gets a boolean indicating that the given extension can be loaded
  42438. * @param extension defines the extension to load
  42439. * @returns true if the extension is supported
  42440. */
  42441. static IsPluginForExtensionAvailable(extension: string): boolean;
  42442. /**
  42443. * Adds a new plugin to the list of registered plugins
  42444. * @param plugin defines the plugin to add
  42445. */
  42446. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42447. /**
  42448. * Import meshes into a scene
  42449. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42450. * @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)
  42451. * @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)
  42452. * @param scene the instance of BABYLON.Scene to append to
  42453. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42454. * @param onProgress a callback with a progress event for each file being loaded
  42455. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42456. * @param pluginExtension the extension used to determine the plugin
  42457. * @returns The loaded plugin
  42458. */
  42459. 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>;
  42460. /**
  42461. * Import meshes into a scene
  42462. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42463. * @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)
  42464. * @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)
  42465. * @param scene the instance of BABYLON.Scene to append to
  42466. * @param onProgress a callback with a progress event for each file being loaded
  42467. * @param pluginExtension the extension used to determine the plugin
  42468. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42469. */
  42470. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42471. meshes: AbstractMesh[];
  42472. particleSystems: IParticleSystem[];
  42473. skeletons: Skeleton[];
  42474. animationGroups: AnimationGroup[];
  42475. }>;
  42476. /**
  42477. * Load a scene
  42478. * @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)
  42479. * @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)
  42480. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42481. * @param onSuccess a callback with the scene when import succeeds
  42482. * @param onProgress a callback with a progress event for each file being loaded
  42483. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42484. * @param pluginExtension the extension used to determine the plugin
  42485. * @returns The loaded plugin
  42486. */
  42487. 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>;
  42488. /**
  42489. * Load a scene
  42490. * @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)
  42491. * @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)
  42492. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42493. * @param onProgress a callback with a progress event for each file being loaded
  42494. * @param pluginExtension the extension used to determine the plugin
  42495. * @returns The loaded scene
  42496. */
  42497. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42498. /**
  42499. * Append a scene
  42500. * @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)
  42501. * @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)
  42502. * @param scene is the instance of BABYLON.Scene to append to
  42503. * @param onSuccess a callback with the scene when import succeeds
  42504. * @param onProgress a callback with a progress event for each file being loaded
  42505. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42506. * @param pluginExtension the extension used to determine the plugin
  42507. * @returns The loaded plugin
  42508. */
  42509. 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>;
  42510. /**
  42511. * Append a scene
  42512. * @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)
  42513. * @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)
  42514. * @param scene is the instance of BABYLON.Scene to append to
  42515. * @param onProgress a callback with a progress event for each file being loaded
  42516. * @param pluginExtension the extension used to determine the plugin
  42517. * @returns The given scene
  42518. */
  42519. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42520. /**
  42521. * Load a scene into an asset container
  42522. * @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)
  42523. * @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)
  42524. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42525. * @param onSuccess a callback with the scene when import succeeds
  42526. * @param onProgress a callback with a progress event for each file being loaded
  42527. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42528. * @param pluginExtension the extension used to determine the plugin
  42529. * @returns The loaded plugin
  42530. */
  42531. 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>;
  42532. /**
  42533. * Load a scene into an asset container
  42534. * @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)
  42535. * @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)
  42536. * @param scene is the instance of Scene to append to
  42537. * @param onProgress a callback with a progress event for each file being loaded
  42538. * @param pluginExtension the extension used to determine the plugin
  42539. * @returns The loaded asset container
  42540. */
  42541. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42542. }
  42543. }
  42544. declare module BABYLON {
  42545. /**
  42546. * Google Daydream controller
  42547. */
  42548. export class DaydreamController extends WebVRController {
  42549. /**
  42550. * Base Url for the controller model.
  42551. */
  42552. static MODEL_BASE_URL: string;
  42553. /**
  42554. * File name for the controller model.
  42555. */
  42556. static MODEL_FILENAME: string;
  42557. /**
  42558. * Gamepad Id prefix used to identify Daydream Controller.
  42559. */
  42560. static readonly GAMEPAD_ID_PREFIX: string;
  42561. /**
  42562. * Creates a new DaydreamController from a gamepad
  42563. * @param vrGamepad the gamepad that the controller should be created from
  42564. */
  42565. constructor(vrGamepad: any);
  42566. /**
  42567. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42568. * @param scene scene in which to add meshes
  42569. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42570. */
  42571. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42572. /**
  42573. * Called once for each button that changed state since the last frame
  42574. * @param buttonIdx Which button index changed
  42575. * @param state New state of the button
  42576. * @param changes Which properties on the state changed since last frame
  42577. */
  42578. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42579. }
  42580. }
  42581. declare module BABYLON {
  42582. /**
  42583. * Gear VR Controller
  42584. */
  42585. export class GearVRController extends WebVRController {
  42586. /**
  42587. * Base Url for the controller model.
  42588. */
  42589. static MODEL_BASE_URL: string;
  42590. /**
  42591. * File name for the controller model.
  42592. */
  42593. static MODEL_FILENAME: string;
  42594. /**
  42595. * Gamepad Id prefix used to identify this controller.
  42596. */
  42597. static readonly GAMEPAD_ID_PREFIX: string;
  42598. private readonly _buttonIndexToObservableNameMap;
  42599. /**
  42600. * Creates a new GearVRController from a gamepad
  42601. * @param vrGamepad the gamepad that the controller should be created from
  42602. */
  42603. constructor(vrGamepad: any);
  42604. /**
  42605. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42606. * @param scene scene in which to add meshes
  42607. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42608. */
  42609. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42610. /**
  42611. * Called once for each button that changed state since the last frame
  42612. * @param buttonIdx Which button index changed
  42613. * @param state New state of the button
  42614. * @param changes Which properties on the state changed since last frame
  42615. */
  42616. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42617. }
  42618. }
  42619. declare module BABYLON {
  42620. /**
  42621. * Generic Controller
  42622. */
  42623. export class GenericController extends WebVRController {
  42624. /**
  42625. * Base Url for the controller model.
  42626. */
  42627. static readonly MODEL_BASE_URL: string;
  42628. /**
  42629. * File name for the controller model.
  42630. */
  42631. static readonly MODEL_FILENAME: string;
  42632. /**
  42633. * Creates a new GenericController from a gamepad
  42634. * @param vrGamepad the gamepad that the controller should be created from
  42635. */
  42636. constructor(vrGamepad: any);
  42637. /**
  42638. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42639. * @param scene scene in which to add meshes
  42640. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42641. */
  42642. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42643. /**
  42644. * Called once for each button that changed state since the last frame
  42645. * @param buttonIdx Which button index changed
  42646. * @param state New state of the button
  42647. * @param changes Which properties on the state changed since last frame
  42648. */
  42649. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42650. }
  42651. }
  42652. declare module BABYLON {
  42653. /**
  42654. * Oculus Touch Controller
  42655. */
  42656. export class OculusTouchController extends WebVRController {
  42657. /**
  42658. * Base Url for the controller model.
  42659. */
  42660. static MODEL_BASE_URL: string;
  42661. /**
  42662. * File name for the left controller model.
  42663. */
  42664. static MODEL_LEFT_FILENAME: string;
  42665. /**
  42666. * File name for the right controller model.
  42667. */
  42668. static MODEL_RIGHT_FILENAME: string;
  42669. /**
  42670. * Fired when the secondary trigger on this controller is modified
  42671. */
  42672. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42673. /**
  42674. * Fired when the thumb rest on this controller is modified
  42675. */
  42676. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42677. /**
  42678. * Creates a new OculusTouchController from a gamepad
  42679. * @param vrGamepad the gamepad that the controller should be created from
  42680. */
  42681. constructor(vrGamepad: any);
  42682. /**
  42683. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42684. * @param scene scene in which to add meshes
  42685. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42686. */
  42687. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42688. /**
  42689. * Fired when the A button on this controller is modified
  42690. */
  42691. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42692. /**
  42693. * Fired when the B button on this controller is modified
  42694. */
  42695. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42696. /**
  42697. * Fired when the X button on this controller is modified
  42698. */
  42699. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42700. /**
  42701. * Fired when the Y button on this controller is modified
  42702. */
  42703. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42704. /**
  42705. * Called once for each button that changed state since the last frame
  42706. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42707. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42708. * 2) secondary trigger (same)
  42709. * 3) A (right) X (left), touch, pressed = value
  42710. * 4) B / Y
  42711. * 5) thumb rest
  42712. * @param buttonIdx Which button index changed
  42713. * @param state New state of the button
  42714. * @param changes Which properties on the state changed since last frame
  42715. */
  42716. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42717. }
  42718. }
  42719. declare module BABYLON {
  42720. /**
  42721. * Vive Controller
  42722. */
  42723. export class ViveController extends WebVRController {
  42724. /**
  42725. * Base Url for the controller model.
  42726. */
  42727. static MODEL_BASE_URL: string;
  42728. /**
  42729. * File name for the controller model.
  42730. */
  42731. static MODEL_FILENAME: string;
  42732. /**
  42733. * Creates a new ViveController from a gamepad
  42734. * @param vrGamepad the gamepad that the controller should be created from
  42735. */
  42736. constructor(vrGamepad: any);
  42737. /**
  42738. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42739. * @param scene scene in which to add meshes
  42740. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42741. */
  42742. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42743. /**
  42744. * Fired when the left button on this controller is modified
  42745. */
  42746. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42747. /**
  42748. * Fired when the right button on this controller is modified
  42749. */
  42750. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42751. /**
  42752. * Fired when the menu button on this controller is modified
  42753. */
  42754. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42755. /**
  42756. * Called once for each button that changed state since the last frame
  42757. * Vive mapping:
  42758. * 0: touchpad
  42759. * 1: trigger
  42760. * 2: left AND right buttons
  42761. * 3: menu button
  42762. * @param buttonIdx Which button index changed
  42763. * @param state New state of the button
  42764. * @param changes Which properties on the state changed since last frame
  42765. */
  42766. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42767. }
  42768. }
  42769. declare module BABYLON {
  42770. /**
  42771. * Defines the WindowsMotionController object that the state of the windows motion controller
  42772. */
  42773. export class WindowsMotionController extends WebVRController {
  42774. /**
  42775. * The base url used to load the left and right controller models
  42776. */
  42777. static MODEL_BASE_URL: string;
  42778. /**
  42779. * The name of the left controller model file
  42780. */
  42781. static MODEL_LEFT_FILENAME: string;
  42782. /**
  42783. * The name of the right controller model file
  42784. */
  42785. static MODEL_RIGHT_FILENAME: string;
  42786. /**
  42787. * The controller name prefix for this controller type
  42788. */
  42789. static readonly GAMEPAD_ID_PREFIX: string;
  42790. /**
  42791. * The controller id pattern for this controller type
  42792. */
  42793. private static readonly GAMEPAD_ID_PATTERN;
  42794. private _loadedMeshInfo;
  42795. private readonly _mapping;
  42796. /**
  42797. * Fired when the trackpad on this controller is clicked
  42798. */
  42799. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42800. /**
  42801. * Fired when the trackpad on this controller is modified
  42802. */
  42803. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42804. /**
  42805. * The current x and y values of this controller's trackpad
  42806. */
  42807. trackpad: StickValues;
  42808. /**
  42809. * Creates a new WindowsMotionController from a gamepad
  42810. * @param vrGamepad the gamepad that the controller should be created from
  42811. */
  42812. constructor(vrGamepad: any);
  42813. /**
  42814. * Fired when the trigger on this controller is modified
  42815. */
  42816. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42817. /**
  42818. * Fired when the menu button on this controller is modified
  42819. */
  42820. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42821. /**
  42822. * Fired when the grip button on this controller is modified
  42823. */
  42824. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42825. /**
  42826. * Fired when the thumbstick button on this controller is modified
  42827. */
  42828. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42829. /**
  42830. * Fired when the touchpad button on this controller is modified
  42831. */
  42832. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42833. /**
  42834. * Fired when the touchpad values on this controller are modified
  42835. */
  42836. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42837. private _updateTrackpad;
  42838. /**
  42839. * Called once per frame by the engine.
  42840. */
  42841. update(): void;
  42842. /**
  42843. * Called once for each button that changed state since the last frame
  42844. * @param buttonIdx Which button index changed
  42845. * @param state New state of the button
  42846. * @param changes Which properties on the state changed since last frame
  42847. */
  42848. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42849. /**
  42850. * Moves the buttons on the controller mesh based on their current state
  42851. * @param buttonName the name of the button to move
  42852. * @param buttonValue the value of the button which determines the buttons new position
  42853. */
  42854. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42855. /**
  42856. * Moves the axis on the controller mesh based on its current state
  42857. * @param axis the index of the axis
  42858. * @param axisValue the value of the axis which determines the meshes new position
  42859. * @hidden
  42860. */
  42861. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42862. /**
  42863. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42864. * @param scene scene in which to add meshes
  42865. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42866. */
  42867. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42868. /**
  42869. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42870. * can be transformed by button presses and axes values, based on this._mapping.
  42871. *
  42872. * @param scene scene in which the meshes exist
  42873. * @param meshes list of meshes that make up the controller model to process
  42874. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42875. */
  42876. private processModel;
  42877. private createMeshInfo;
  42878. /**
  42879. * Gets the ray of the controller in the direction the controller is pointing
  42880. * @param length the length the resulting ray should be
  42881. * @returns a ray in the direction the controller is pointing
  42882. */
  42883. getForwardRay(length?: number): Ray;
  42884. /**
  42885. * Disposes of the controller
  42886. */
  42887. dispose(): void;
  42888. }
  42889. }
  42890. declare module BABYLON {
  42891. /**
  42892. * Class containing static functions to help procedurally build meshes
  42893. */
  42894. export class PolyhedronBuilder {
  42895. /**
  42896. * Creates a polyhedron mesh
  42897. * * 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
  42898. * * The parameter `size` (positive float, default 1) sets the polygon size
  42899. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42900. * * 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`
  42901. * * 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
  42902. * * 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)`)
  42903. * * 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
  42904. * * 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
  42905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42906. * * 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
  42907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42908. * @param name defines the name of the mesh
  42909. * @param options defines the options used to create the mesh
  42910. * @param scene defines the hosting scene
  42911. * @returns the polyhedron mesh
  42912. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42913. */
  42914. static CreatePolyhedron(name: string, options: {
  42915. type?: number;
  42916. size?: number;
  42917. sizeX?: number;
  42918. sizeY?: number;
  42919. sizeZ?: number;
  42920. custom?: any;
  42921. faceUV?: Vector4[];
  42922. faceColors?: Color4[];
  42923. flat?: boolean;
  42924. updatable?: boolean;
  42925. sideOrientation?: number;
  42926. frontUVs?: Vector4;
  42927. backUVs?: Vector4;
  42928. }, scene?: Nullable<Scene>): Mesh;
  42929. }
  42930. }
  42931. declare module BABYLON {
  42932. /**
  42933. * Gizmo that enables scaling a mesh along 3 axis
  42934. */
  42935. export class ScaleGizmo extends Gizmo {
  42936. /**
  42937. * Internal gizmo used for interactions on the x axis
  42938. */
  42939. xGizmo: AxisScaleGizmo;
  42940. /**
  42941. * Internal gizmo used for interactions on the y axis
  42942. */
  42943. yGizmo: AxisScaleGizmo;
  42944. /**
  42945. * Internal gizmo used for interactions on the z axis
  42946. */
  42947. zGizmo: AxisScaleGizmo;
  42948. /**
  42949. * Internal gizmo used to scale all axis equally
  42950. */
  42951. uniformScaleGizmo: AxisScaleGizmo;
  42952. private _meshAttached;
  42953. private _updateGizmoRotationToMatchAttachedMesh;
  42954. private _snapDistance;
  42955. private _scaleRatio;
  42956. private _uniformScalingMesh;
  42957. private _octahedron;
  42958. /** Fires an event when any of it's sub gizmos are dragged */
  42959. onDragStartObservable: Observable<{}>;
  42960. /** Fires an event when any of it's sub gizmos are released from dragging */
  42961. onDragEndObservable: Observable<{}>;
  42962. attachedMesh: Nullable<AbstractMesh>;
  42963. /**
  42964. * Creates a ScaleGizmo
  42965. * @param gizmoLayer The utility layer the gizmo will be added to
  42966. */
  42967. constructor(gizmoLayer?: UtilityLayerRenderer);
  42968. updateGizmoRotationToMatchAttachedMesh: boolean;
  42969. /**
  42970. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42971. */
  42972. snapDistance: number;
  42973. /**
  42974. * Ratio for the scale of the gizmo (Default: 1)
  42975. */
  42976. scaleRatio: number;
  42977. /**
  42978. * Disposes of the gizmo
  42979. */
  42980. dispose(): void;
  42981. }
  42982. }
  42983. declare module BABYLON {
  42984. /**
  42985. * Single axis scale gizmo
  42986. */
  42987. export class AxisScaleGizmo extends Gizmo {
  42988. /**
  42989. * Drag behavior responsible for the gizmos dragging interactions
  42990. */
  42991. dragBehavior: PointerDragBehavior;
  42992. private _pointerObserver;
  42993. /**
  42994. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42995. */
  42996. snapDistance: number;
  42997. /**
  42998. * Event that fires each time the gizmo snaps to a new location.
  42999. * * snapDistance is the the change in distance
  43000. */
  43001. onSnapObservable: Observable<{
  43002. snapDistance: number;
  43003. }>;
  43004. /**
  43005. * If the scaling operation should be done on all axis (default: false)
  43006. */
  43007. uniformScaling: boolean;
  43008. private _isEnabled;
  43009. private _parent;
  43010. private _arrow;
  43011. private _coloredMaterial;
  43012. private _hoverMaterial;
  43013. /**
  43014. * Creates an AxisScaleGizmo
  43015. * @param gizmoLayer The utility layer the gizmo will be added to
  43016. * @param dragAxis The axis which the gizmo will be able to scale on
  43017. * @param color The color of the gizmo
  43018. */
  43019. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43020. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43021. /**
  43022. * If the gizmo is enabled
  43023. */
  43024. isEnabled: boolean;
  43025. /**
  43026. * Disposes of the gizmo
  43027. */
  43028. dispose(): void;
  43029. /**
  43030. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43031. * @param mesh The mesh to replace the default mesh of the gizmo
  43032. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43033. */
  43034. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43035. }
  43036. }
  43037. declare module BABYLON {
  43038. /**
  43039. * Bounding box gizmo
  43040. */
  43041. export class BoundingBoxGizmo extends Gizmo {
  43042. private _lineBoundingBox;
  43043. private _rotateSpheresParent;
  43044. private _scaleBoxesParent;
  43045. private _boundingDimensions;
  43046. private _renderObserver;
  43047. private _pointerObserver;
  43048. private _scaleDragSpeed;
  43049. private _tmpQuaternion;
  43050. private _tmpVector;
  43051. private _tmpRotationMatrix;
  43052. /**
  43053. * 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)
  43054. */
  43055. ignoreChildren: boolean;
  43056. /**
  43057. * 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)
  43058. */
  43059. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43060. /**
  43061. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43062. */
  43063. rotationSphereSize: number;
  43064. /**
  43065. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43066. */
  43067. scaleBoxSize: number;
  43068. /**
  43069. * 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)
  43070. */
  43071. fixedDragMeshScreenSize: boolean;
  43072. /**
  43073. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43074. */
  43075. fixedDragMeshScreenSizeDistanceFactor: number;
  43076. /**
  43077. * Fired when a rotation sphere or scale box is dragged
  43078. */
  43079. onDragStartObservable: Observable<{}>;
  43080. /**
  43081. * Fired when a scale box is dragged
  43082. */
  43083. onScaleBoxDragObservable: Observable<{}>;
  43084. /**
  43085. * Fired when a scale box drag is ended
  43086. */
  43087. onScaleBoxDragEndObservable: Observable<{}>;
  43088. /**
  43089. * Fired when a rotation sphere is dragged
  43090. */
  43091. onRotationSphereDragObservable: Observable<{}>;
  43092. /**
  43093. * Fired when a rotation sphere drag is ended
  43094. */
  43095. onRotationSphereDragEndObservable: Observable<{}>;
  43096. /**
  43097. * 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)
  43098. */
  43099. scalePivot: Nullable<Vector3>;
  43100. /**
  43101. * Mesh used as a pivot to rotate the attached mesh
  43102. */
  43103. private _anchorMesh;
  43104. private _existingMeshScale;
  43105. private _dragMesh;
  43106. private pointerDragBehavior;
  43107. private coloredMaterial;
  43108. private hoverColoredMaterial;
  43109. /**
  43110. * Sets the color of the bounding box gizmo
  43111. * @param color the color to set
  43112. */
  43113. setColor(color: Color3): void;
  43114. /**
  43115. * Creates an BoundingBoxGizmo
  43116. * @param gizmoLayer The utility layer the gizmo will be added to
  43117. * @param color The color of the gizmo
  43118. */
  43119. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43120. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43121. private _selectNode;
  43122. /**
  43123. * Updates the bounding box information for the Gizmo
  43124. */
  43125. updateBoundingBox(): void;
  43126. private _updateRotationSpheres;
  43127. private _updateScaleBoxes;
  43128. /**
  43129. * Enables rotation on the specified axis and disables rotation on the others
  43130. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43131. */
  43132. setEnabledRotationAxis(axis: string): void;
  43133. /**
  43134. * Enables/disables scaling
  43135. * @param enable if scaling should be enabled
  43136. */
  43137. setEnabledScaling(enable: boolean): void;
  43138. private _updateDummy;
  43139. /**
  43140. * Enables a pointer drag behavior on the bounding box of the gizmo
  43141. */
  43142. enableDragBehavior(): void;
  43143. /**
  43144. * Disposes of the gizmo
  43145. */
  43146. dispose(): void;
  43147. /**
  43148. * 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)
  43149. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43150. * @returns the bounding box mesh with the passed in mesh as a child
  43151. */
  43152. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43153. /**
  43154. * CustomMeshes are not supported by this gizmo
  43155. * @param mesh The mesh to replace the default mesh of the gizmo
  43156. */
  43157. setCustomMesh(mesh: Mesh): void;
  43158. }
  43159. }
  43160. declare module BABYLON {
  43161. /**
  43162. * Single plane rotation gizmo
  43163. */
  43164. export class PlaneRotationGizmo extends Gizmo {
  43165. /**
  43166. * Drag behavior responsible for the gizmos dragging interactions
  43167. */
  43168. dragBehavior: PointerDragBehavior;
  43169. private _pointerObserver;
  43170. /**
  43171. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43172. */
  43173. snapDistance: number;
  43174. /**
  43175. * Event that fires each time the gizmo snaps to a new location.
  43176. * * snapDistance is the the change in distance
  43177. */
  43178. onSnapObservable: Observable<{
  43179. snapDistance: number;
  43180. }>;
  43181. private _isEnabled;
  43182. private _parent;
  43183. /**
  43184. * Creates a PlaneRotationGizmo
  43185. * @param gizmoLayer The utility layer the gizmo will be added to
  43186. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43187. * @param color The color of the gizmo
  43188. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43189. */
  43190. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  43191. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43192. /**
  43193. * If the gizmo is enabled
  43194. */
  43195. isEnabled: boolean;
  43196. /**
  43197. * Disposes of the gizmo
  43198. */
  43199. dispose(): void;
  43200. }
  43201. }
  43202. declare module BABYLON {
  43203. /**
  43204. * Gizmo that enables rotating a mesh along 3 axis
  43205. */
  43206. export class RotationGizmo extends Gizmo {
  43207. /**
  43208. * Internal gizmo used for interactions on the x axis
  43209. */
  43210. xGizmo: PlaneRotationGizmo;
  43211. /**
  43212. * Internal gizmo used for interactions on the y axis
  43213. */
  43214. yGizmo: PlaneRotationGizmo;
  43215. /**
  43216. * Internal gizmo used for interactions on the z axis
  43217. */
  43218. zGizmo: PlaneRotationGizmo;
  43219. /** Fires an event when any of it's sub gizmos are dragged */
  43220. onDragStartObservable: Observable<{}>;
  43221. /** Fires an event when any of it's sub gizmos are released from dragging */
  43222. onDragEndObservable: Observable<{}>;
  43223. private _meshAttached;
  43224. attachedMesh: Nullable<AbstractMesh>;
  43225. /**
  43226. * Creates a RotationGizmo
  43227. * @param gizmoLayer The utility layer the gizmo will be added to
  43228. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43229. */
  43230. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43231. updateGizmoRotationToMatchAttachedMesh: boolean;
  43232. /**
  43233. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43234. */
  43235. snapDistance: number;
  43236. /**
  43237. * Ratio for the scale of the gizmo (Default: 1)
  43238. */
  43239. scaleRatio: number;
  43240. /**
  43241. * Disposes of the gizmo
  43242. */
  43243. dispose(): void;
  43244. /**
  43245. * CustomMeshes are not supported by this gizmo
  43246. * @param mesh The mesh to replace the default mesh of the gizmo
  43247. */
  43248. setCustomMesh(mesh: Mesh): void;
  43249. }
  43250. }
  43251. declare module BABYLON {
  43252. /**
  43253. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43254. */
  43255. export class GizmoManager implements IDisposable {
  43256. private scene;
  43257. /**
  43258. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43259. */
  43260. gizmos: {
  43261. positionGizmo: Nullable<PositionGizmo>;
  43262. rotationGizmo: Nullable<RotationGizmo>;
  43263. scaleGizmo: Nullable<ScaleGizmo>;
  43264. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43265. };
  43266. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43267. clearGizmoOnEmptyPointerEvent: boolean;
  43268. /** Fires an event when the manager is attached to a mesh */
  43269. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43270. private _gizmosEnabled;
  43271. private _pointerObserver;
  43272. private _attachedMesh;
  43273. private _boundingBoxColor;
  43274. private _defaultUtilityLayer;
  43275. private _defaultKeepDepthUtilityLayer;
  43276. /**
  43277. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43278. */
  43279. boundingBoxDragBehavior: SixDofDragBehavior;
  43280. /**
  43281. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43282. */
  43283. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43284. /**
  43285. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43286. */
  43287. usePointerToAttachGizmos: boolean;
  43288. /**
  43289. * Instatiates a gizmo manager
  43290. * @param scene the scene to overlay the gizmos on top of
  43291. */
  43292. constructor(scene: Scene);
  43293. /**
  43294. * Attaches a set of gizmos to the specified mesh
  43295. * @param mesh The mesh the gizmo's should be attached to
  43296. */
  43297. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43298. /**
  43299. * If the position gizmo is enabled
  43300. */
  43301. positionGizmoEnabled: boolean;
  43302. /**
  43303. * If the rotation gizmo is enabled
  43304. */
  43305. rotationGizmoEnabled: boolean;
  43306. /**
  43307. * If the scale gizmo is enabled
  43308. */
  43309. scaleGizmoEnabled: boolean;
  43310. /**
  43311. * If the boundingBox gizmo is enabled
  43312. */
  43313. boundingBoxGizmoEnabled: boolean;
  43314. /**
  43315. * Disposes of the gizmo manager
  43316. */
  43317. dispose(): void;
  43318. }
  43319. }
  43320. declare module BABYLON {
  43321. /**
  43322. * A directional light is defined by a direction (what a surprise!).
  43323. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43324. * 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.
  43325. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43326. */
  43327. export class DirectionalLight extends ShadowLight {
  43328. private _shadowFrustumSize;
  43329. /**
  43330. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43331. */
  43332. /**
  43333. * Specifies a fix frustum size for the shadow generation.
  43334. */
  43335. shadowFrustumSize: number;
  43336. private _shadowOrthoScale;
  43337. /**
  43338. * Gets the shadow projection scale against the optimal computed one.
  43339. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43340. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43341. */
  43342. /**
  43343. * Sets the shadow projection scale against the optimal computed one.
  43344. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43345. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43346. */
  43347. shadowOrthoScale: number;
  43348. /**
  43349. * Automatically compute the projection matrix to best fit (including all the casters)
  43350. * on each frame.
  43351. */
  43352. autoUpdateExtends: boolean;
  43353. private _orthoLeft;
  43354. private _orthoRight;
  43355. private _orthoTop;
  43356. private _orthoBottom;
  43357. /**
  43358. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43359. * The directional light is emitted from everywhere in the given direction.
  43360. * It can cast shadows.
  43361. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43362. * @param name The friendly name of the light
  43363. * @param direction The direction of the light
  43364. * @param scene The scene the light belongs to
  43365. */
  43366. constructor(name: string, direction: Vector3, scene: Scene);
  43367. /**
  43368. * Returns the string "DirectionalLight".
  43369. * @return The class name
  43370. */
  43371. getClassName(): string;
  43372. /**
  43373. * Returns the integer 1.
  43374. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43375. */
  43376. getTypeID(): number;
  43377. /**
  43378. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43379. * Returns the DirectionalLight Shadow projection matrix.
  43380. */
  43381. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43382. /**
  43383. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43384. * Returns the DirectionalLight Shadow projection matrix.
  43385. */
  43386. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43387. /**
  43388. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43389. * Returns the DirectionalLight Shadow projection matrix.
  43390. */
  43391. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43392. protected _buildUniformLayout(): void;
  43393. /**
  43394. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43395. * @param effect The effect to update
  43396. * @param lightIndex The index of the light in the effect to update
  43397. * @returns The directional light
  43398. */
  43399. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43400. /**
  43401. * Gets the minZ used for shadow according to both the scene and the light.
  43402. *
  43403. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43404. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43405. * @param activeCamera The camera we are returning the min for
  43406. * @returns the depth min z
  43407. */
  43408. getDepthMinZ(activeCamera: Camera): number;
  43409. /**
  43410. * Gets the maxZ used for shadow according to both the scene and the light.
  43411. *
  43412. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43413. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43414. * @param activeCamera The camera we are returning the max for
  43415. * @returns the depth max z
  43416. */
  43417. getDepthMaxZ(activeCamera: Camera): number;
  43418. /**
  43419. * Prepares the list of defines specific to the light type.
  43420. * @param defines the list of defines
  43421. * @param lightIndex defines the index of the light for the effect
  43422. */
  43423. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43424. }
  43425. }
  43426. declare module BABYLON {
  43427. /**
  43428. * Class containing static functions to help procedurally build meshes
  43429. */
  43430. export class HemisphereBuilder {
  43431. /**
  43432. * Creates a hemisphere mesh
  43433. * @param name defines the name of the mesh
  43434. * @param options defines the options used to create the mesh
  43435. * @param scene defines the hosting scene
  43436. * @returns the hemisphere mesh
  43437. */
  43438. static CreateHemisphere(name: string, options: {
  43439. segments?: number;
  43440. diameter?: number;
  43441. sideOrientation?: number;
  43442. }, scene: any): Mesh;
  43443. }
  43444. }
  43445. declare module BABYLON {
  43446. /**
  43447. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43448. * These values define a cone of light starting from the position, emitting toward the direction.
  43449. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43450. * and the exponent defines the speed of the decay of the light with distance (reach).
  43451. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43452. */
  43453. export class SpotLight extends ShadowLight {
  43454. private _angle;
  43455. private _innerAngle;
  43456. private _cosHalfAngle;
  43457. private _lightAngleScale;
  43458. private _lightAngleOffset;
  43459. /**
  43460. * Gets the cone angle of the spot light in Radians.
  43461. */
  43462. /**
  43463. * Sets the cone angle of the spot light in Radians.
  43464. */
  43465. angle: number;
  43466. /**
  43467. * Only used in gltf falloff mode, this defines the angle where
  43468. * the directional falloff will start before cutting at angle which could be seen
  43469. * as outer angle.
  43470. */
  43471. /**
  43472. * Only used in gltf falloff mode, this defines the angle where
  43473. * the directional falloff will start before cutting at angle which could be seen
  43474. * as outer angle.
  43475. */
  43476. innerAngle: number;
  43477. private _shadowAngleScale;
  43478. /**
  43479. * Allows scaling the angle of the light for shadow generation only.
  43480. */
  43481. /**
  43482. * Allows scaling the angle of the light for shadow generation only.
  43483. */
  43484. shadowAngleScale: number;
  43485. /**
  43486. * The light decay speed with the distance from the emission spot.
  43487. */
  43488. exponent: number;
  43489. private _projectionTextureMatrix;
  43490. /**
  43491. * Allows reading the projecton texture
  43492. */
  43493. readonly projectionTextureMatrix: Matrix;
  43494. protected _projectionTextureLightNear: number;
  43495. /**
  43496. * Gets the near clip of the Spotlight for texture projection.
  43497. */
  43498. /**
  43499. * Sets the near clip of the Spotlight for texture projection.
  43500. */
  43501. projectionTextureLightNear: number;
  43502. protected _projectionTextureLightFar: number;
  43503. /**
  43504. * Gets the far clip of the Spotlight for texture projection.
  43505. */
  43506. /**
  43507. * Sets the far clip of the Spotlight for texture projection.
  43508. */
  43509. projectionTextureLightFar: number;
  43510. protected _projectionTextureUpDirection: Vector3;
  43511. /**
  43512. * Gets the Up vector of the Spotlight for texture projection.
  43513. */
  43514. /**
  43515. * Sets the Up vector of the Spotlight for texture projection.
  43516. */
  43517. projectionTextureUpDirection: Vector3;
  43518. private _projectionTexture;
  43519. /**
  43520. * Gets the projection texture of the light.
  43521. */
  43522. /**
  43523. * Sets the projection texture of the light.
  43524. */
  43525. projectionTexture: Nullable<BaseTexture>;
  43526. private _projectionTextureViewLightDirty;
  43527. private _projectionTextureProjectionLightDirty;
  43528. private _projectionTextureDirty;
  43529. private _projectionTextureViewTargetVector;
  43530. private _projectionTextureViewLightMatrix;
  43531. private _projectionTextureProjectionLightMatrix;
  43532. private _projectionTextureScalingMatrix;
  43533. /**
  43534. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43535. * It can cast shadows.
  43536. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43537. * @param name The light friendly name
  43538. * @param position The position of the spot light in the scene
  43539. * @param direction The direction of the light in the scene
  43540. * @param angle The cone angle of the light in Radians
  43541. * @param exponent The light decay speed with the distance from the emission spot
  43542. * @param scene The scene the lights belongs to
  43543. */
  43544. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43545. /**
  43546. * Returns the string "SpotLight".
  43547. * @returns the class name
  43548. */
  43549. getClassName(): string;
  43550. /**
  43551. * Returns the integer 2.
  43552. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43553. */
  43554. getTypeID(): number;
  43555. /**
  43556. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43557. */
  43558. protected _setDirection(value: Vector3): void;
  43559. /**
  43560. * Overrides the position setter to recompute the projection texture view light Matrix.
  43561. */
  43562. protected _setPosition(value: Vector3): void;
  43563. /**
  43564. * 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.
  43565. * Returns the SpotLight.
  43566. */
  43567. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43568. protected _computeProjectionTextureViewLightMatrix(): void;
  43569. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43570. /**
  43571. * Main function for light texture projection matrix computing.
  43572. */
  43573. protected _computeProjectionTextureMatrix(): void;
  43574. protected _buildUniformLayout(): void;
  43575. private _computeAngleValues;
  43576. /**
  43577. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43578. * @param effect The effect to update
  43579. * @param lightIndex The index of the light in the effect to update
  43580. * @returns The spot light
  43581. */
  43582. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43583. /**
  43584. * Disposes the light and the associated resources.
  43585. */
  43586. dispose(): void;
  43587. /**
  43588. * Prepares the list of defines specific to the light type.
  43589. * @param defines the list of defines
  43590. * @param lightIndex defines the index of the light for the effect
  43591. */
  43592. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43593. }
  43594. }
  43595. declare module BABYLON {
  43596. /**
  43597. * Gizmo that enables viewing a light
  43598. */
  43599. export class LightGizmo extends Gizmo {
  43600. private _lightMesh;
  43601. private _material;
  43602. private cachedPosition;
  43603. private cachedForward;
  43604. /**
  43605. * Creates a LightGizmo
  43606. * @param gizmoLayer The utility layer the gizmo will be added to
  43607. */
  43608. constructor(gizmoLayer?: UtilityLayerRenderer);
  43609. private _light;
  43610. /**
  43611. * The light that the gizmo is attached to
  43612. */
  43613. light: Nullable<Light>;
  43614. /**
  43615. * @hidden
  43616. * Updates the gizmo to match the attached mesh's position/rotation
  43617. */
  43618. protected _update(): void;
  43619. private static _Scale;
  43620. /**
  43621. * Creates the lines for a light mesh
  43622. */
  43623. private static _createLightLines;
  43624. /**
  43625. * Disposes of the light gizmo
  43626. */
  43627. dispose(): void;
  43628. private static _CreateHemisphericLightMesh;
  43629. private static _CreatePointLightMesh;
  43630. private static _CreateSpotLightMesh;
  43631. private static _CreateDirectionalLightMesh;
  43632. }
  43633. }
  43634. declare module BABYLON {
  43635. /** @hidden */
  43636. export var backgroundFragmentDeclaration: {
  43637. name: string;
  43638. shader: string;
  43639. };
  43640. }
  43641. declare module BABYLON {
  43642. /** @hidden */
  43643. export var backgroundUboDeclaration: {
  43644. name: string;
  43645. shader: string;
  43646. };
  43647. }
  43648. declare module BABYLON {
  43649. /** @hidden */
  43650. export var backgroundPixelShader: {
  43651. name: string;
  43652. shader: string;
  43653. };
  43654. }
  43655. declare module BABYLON {
  43656. /** @hidden */
  43657. export var backgroundVertexDeclaration: {
  43658. name: string;
  43659. shader: string;
  43660. };
  43661. }
  43662. declare module BABYLON {
  43663. /** @hidden */
  43664. export var backgroundVertexShader: {
  43665. name: string;
  43666. shader: string;
  43667. };
  43668. }
  43669. declare module BABYLON {
  43670. /**
  43671. * Background material used to create an efficient environement around your scene.
  43672. */
  43673. export class BackgroundMaterial extends PushMaterial {
  43674. /**
  43675. * Standard reflectance value at parallel view angle.
  43676. */
  43677. static StandardReflectance0: number;
  43678. /**
  43679. * Standard reflectance value at grazing angle.
  43680. */
  43681. static StandardReflectance90: number;
  43682. protected _primaryColor: Color3;
  43683. /**
  43684. * Key light Color (multiply against the environement texture)
  43685. */
  43686. primaryColor: Color3;
  43687. protected __perceptualColor: Nullable<Color3>;
  43688. /**
  43689. * Experimental Internal Use Only.
  43690. *
  43691. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43692. * This acts as a helper to set the primary color to a more "human friendly" value.
  43693. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43694. * output color as close as possible from the chosen value.
  43695. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43696. * part of lighting setup.)
  43697. */
  43698. _perceptualColor: Nullable<Color3>;
  43699. protected _primaryColorShadowLevel: float;
  43700. /**
  43701. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43702. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43703. */
  43704. primaryColorShadowLevel: float;
  43705. protected _primaryColorHighlightLevel: float;
  43706. /**
  43707. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43708. * The primary color is used at the level chosen to define what the white area would look.
  43709. */
  43710. primaryColorHighlightLevel: float;
  43711. protected _reflectionTexture: Nullable<BaseTexture>;
  43712. /**
  43713. * Reflection Texture used in the material.
  43714. * Should be author in a specific way for the best result (refer to the documentation).
  43715. */
  43716. reflectionTexture: Nullable<BaseTexture>;
  43717. protected _reflectionBlur: float;
  43718. /**
  43719. * Reflection Texture level of blur.
  43720. *
  43721. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43722. * texture twice.
  43723. */
  43724. reflectionBlur: float;
  43725. protected _diffuseTexture: Nullable<BaseTexture>;
  43726. /**
  43727. * Diffuse Texture used in the material.
  43728. * Should be author in a specific way for the best result (refer to the documentation).
  43729. */
  43730. diffuseTexture: Nullable<BaseTexture>;
  43731. protected _shadowLights: Nullable<IShadowLight[]>;
  43732. /**
  43733. * Specify the list of lights casting shadow on the material.
  43734. * All scene shadow lights will be included if null.
  43735. */
  43736. shadowLights: Nullable<IShadowLight[]>;
  43737. protected _shadowLevel: float;
  43738. /**
  43739. * Helps adjusting the shadow to a softer level if required.
  43740. * 0 means black shadows and 1 means no shadows.
  43741. */
  43742. shadowLevel: float;
  43743. protected _sceneCenter: Vector3;
  43744. /**
  43745. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43746. * It is usually zero but might be interesting to modify according to your setup.
  43747. */
  43748. sceneCenter: Vector3;
  43749. protected _opacityFresnel: boolean;
  43750. /**
  43751. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43752. * This helps ensuring a nice transition when the camera goes under the ground.
  43753. */
  43754. opacityFresnel: boolean;
  43755. protected _reflectionFresnel: boolean;
  43756. /**
  43757. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43758. * This helps adding a mirror texture on the ground.
  43759. */
  43760. reflectionFresnel: boolean;
  43761. protected _reflectionFalloffDistance: number;
  43762. /**
  43763. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43764. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43765. */
  43766. reflectionFalloffDistance: number;
  43767. protected _reflectionAmount: number;
  43768. /**
  43769. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43770. */
  43771. reflectionAmount: number;
  43772. protected _reflectionReflectance0: number;
  43773. /**
  43774. * This specifies the weight of the reflection at grazing angle.
  43775. */
  43776. reflectionReflectance0: number;
  43777. protected _reflectionReflectance90: number;
  43778. /**
  43779. * This specifies the weight of the reflection at a perpendicular point of view.
  43780. */
  43781. reflectionReflectance90: number;
  43782. /**
  43783. * Sets the reflection reflectance fresnel values according to the default standard
  43784. * empirically know to work well :-)
  43785. */
  43786. reflectionStandardFresnelWeight: number;
  43787. protected _useRGBColor: boolean;
  43788. /**
  43789. * Helps to directly use the maps channels instead of their level.
  43790. */
  43791. useRGBColor: boolean;
  43792. protected _enableNoise: boolean;
  43793. /**
  43794. * This helps reducing the banding effect that could occur on the background.
  43795. */
  43796. enableNoise: boolean;
  43797. /**
  43798. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43799. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43800. * Recommended to be keep at 1.0 except for special cases.
  43801. */
  43802. fovMultiplier: number;
  43803. private _fovMultiplier;
  43804. /**
  43805. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43806. */
  43807. useEquirectangularFOV: boolean;
  43808. private _maxSimultaneousLights;
  43809. /**
  43810. * Number of Simultaneous lights allowed on the material.
  43811. */
  43812. maxSimultaneousLights: int;
  43813. /**
  43814. * Default configuration related to image processing available in the Background Material.
  43815. */
  43816. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43817. /**
  43818. * Keep track of the image processing observer to allow dispose and replace.
  43819. */
  43820. private _imageProcessingObserver;
  43821. /**
  43822. * Attaches a new image processing configuration to the PBR Material.
  43823. * @param configuration (if null the scene configuration will be use)
  43824. */
  43825. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43826. /**
  43827. * Gets the image processing configuration used either in this material.
  43828. */
  43829. /**
  43830. * Sets the Default image processing configuration used either in the this material.
  43831. *
  43832. * If sets to null, the scene one is in use.
  43833. */
  43834. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43835. /**
  43836. * Gets wether the color curves effect is enabled.
  43837. */
  43838. /**
  43839. * Sets wether the color curves effect is enabled.
  43840. */
  43841. cameraColorCurvesEnabled: boolean;
  43842. /**
  43843. * Gets wether the color grading effect is enabled.
  43844. */
  43845. /**
  43846. * Gets wether the color grading effect is enabled.
  43847. */
  43848. cameraColorGradingEnabled: boolean;
  43849. /**
  43850. * Gets wether tonemapping is enabled or not.
  43851. */
  43852. /**
  43853. * Sets wether tonemapping is enabled or not
  43854. */
  43855. cameraToneMappingEnabled: boolean;
  43856. /**
  43857. * The camera exposure used on this material.
  43858. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43859. * This corresponds to a photographic exposure.
  43860. */
  43861. /**
  43862. * The camera exposure used on this material.
  43863. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43864. * This corresponds to a photographic exposure.
  43865. */
  43866. cameraExposure: float;
  43867. /**
  43868. * Gets The camera contrast used on this material.
  43869. */
  43870. /**
  43871. * Sets The camera contrast used on this material.
  43872. */
  43873. cameraContrast: float;
  43874. /**
  43875. * Gets the Color Grading 2D Lookup Texture.
  43876. */
  43877. /**
  43878. * Sets the Color Grading 2D Lookup Texture.
  43879. */
  43880. cameraColorGradingTexture: Nullable<BaseTexture>;
  43881. /**
  43882. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43883. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43884. * 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;
  43885. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43886. */
  43887. /**
  43888. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43889. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43890. * 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;
  43891. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43892. */
  43893. cameraColorCurves: Nullable<ColorCurves>;
  43894. /**
  43895. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43896. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43897. */
  43898. switchToBGR: boolean;
  43899. private _renderTargets;
  43900. private _reflectionControls;
  43901. private _white;
  43902. private _primaryShadowColor;
  43903. private _primaryHighlightColor;
  43904. /**
  43905. * Instantiates a Background Material in the given scene
  43906. * @param name The friendly name of the material
  43907. * @param scene The scene to add the material to
  43908. */
  43909. constructor(name: string, scene: Scene);
  43910. /**
  43911. * Gets a boolean indicating that current material needs to register RTT
  43912. */
  43913. readonly hasRenderTargetTextures: boolean;
  43914. /**
  43915. * The entire material has been created in order to prevent overdraw.
  43916. * @returns false
  43917. */
  43918. needAlphaTesting(): boolean;
  43919. /**
  43920. * The entire material has been created in order to prevent overdraw.
  43921. * @returns true if blending is enable
  43922. */
  43923. needAlphaBlending(): boolean;
  43924. /**
  43925. * Checks wether the material is ready to be rendered for a given mesh.
  43926. * @param mesh The mesh to render
  43927. * @param subMesh The submesh to check against
  43928. * @param useInstances Specify wether or not the material is used with instances
  43929. * @returns true if all the dependencies are ready (Textures, Effects...)
  43930. */
  43931. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43932. /**
  43933. * Compute the primary color according to the chosen perceptual color.
  43934. */
  43935. private _computePrimaryColorFromPerceptualColor;
  43936. /**
  43937. * Compute the highlights and shadow colors according to their chosen levels.
  43938. */
  43939. private _computePrimaryColors;
  43940. /**
  43941. * Build the uniform buffer used in the material.
  43942. */
  43943. buildUniformLayout(): void;
  43944. /**
  43945. * Unbind the material.
  43946. */
  43947. unbind(): void;
  43948. /**
  43949. * Bind only the world matrix to the material.
  43950. * @param world The world matrix to bind.
  43951. */
  43952. bindOnlyWorldMatrix(world: Matrix): void;
  43953. /**
  43954. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43955. * @param world The world matrix to bind.
  43956. * @param subMesh The submesh to bind for.
  43957. */
  43958. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43959. /**
  43960. * Dispose the material.
  43961. * @param forceDisposeEffect Force disposal of the associated effect.
  43962. * @param forceDisposeTextures Force disposal of the associated textures.
  43963. */
  43964. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43965. /**
  43966. * Clones the material.
  43967. * @param name The cloned name.
  43968. * @returns The cloned material.
  43969. */
  43970. clone(name: string): BackgroundMaterial;
  43971. /**
  43972. * Serializes the current material to its JSON representation.
  43973. * @returns The JSON representation.
  43974. */
  43975. serialize(): any;
  43976. /**
  43977. * Gets the class name of the material
  43978. * @returns "BackgroundMaterial"
  43979. */
  43980. getClassName(): string;
  43981. /**
  43982. * Parse a JSON input to create back a background material.
  43983. * @param source The JSON data to parse
  43984. * @param scene The scene to create the parsed material in
  43985. * @param rootUrl The root url of the assets the material depends upon
  43986. * @returns the instantiated BackgroundMaterial.
  43987. */
  43988. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43989. }
  43990. }
  43991. declare module BABYLON {
  43992. /**
  43993. * Represents the different options available during the creation of
  43994. * a Environment helper.
  43995. *
  43996. * This can control the default ground, skybox and image processing setup of your scene.
  43997. */
  43998. export interface IEnvironmentHelperOptions {
  43999. /**
  44000. * Specifies wether or not to create a ground.
  44001. * True by default.
  44002. */
  44003. createGround: boolean;
  44004. /**
  44005. * Specifies the ground size.
  44006. * 15 by default.
  44007. */
  44008. groundSize: number;
  44009. /**
  44010. * The texture used on the ground for the main color.
  44011. * Comes from the BabylonJS CDN by default.
  44012. *
  44013. * Remarks: Can be either a texture or a url.
  44014. */
  44015. groundTexture: string | BaseTexture;
  44016. /**
  44017. * The color mixed in the ground texture by default.
  44018. * BabylonJS clearColor by default.
  44019. */
  44020. groundColor: Color3;
  44021. /**
  44022. * Specifies the ground opacity.
  44023. * 1 by default.
  44024. */
  44025. groundOpacity: number;
  44026. /**
  44027. * Enables the ground to receive shadows.
  44028. * True by default.
  44029. */
  44030. enableGroundShadow: boolean;
  44031. /**
  44032. * Helps preventing the shadow to be fully black on the ground.
  44033. * 0.5 by default.
  44034. */
  44035. groundShadowLevel: number;
  44036. /**
  44037. * Creates a mirror texture attach to the ground.
  44038. * false by default.
  44039. */
  44040. enableGroundMirror: boolean;
  44041. /**
  44042. * Specifies the ground mirror size ratio.
  44043. * 0.3 by default as the default kernel is 64.
  44044. */
  44045. groundMirrorSizeRatio: number;
  44046. /**
  44047. * Specifies the ground mirror blur kernel size.
  44048. * 64 by default.
  44049. */
  44050. groundMirrorBlurKernel: number;
  44051. /**
  44052. * Specifies the ground mirror visibility amount.
  44053. * 1 by default
  44054. */
  44055. groundMirrorAmount: number;
  44056. /**
  44057. * Specifies the ground mirror reflectance weight.
  44058. * This uses the standard weight of the background material to setup the fresnel effect
  44059. * of the mirror.
  44060. * 1 by default.
  44061. */
  44062. groundMirrorFresnelWeight: number;
  44063. /**
  44064. * Specifies the ground mirror Falloff distance.
  44065. * This can helps reducing the size of the reflection.
  44066. * 0 by Default.
  44067. */
  44068. groundMirrorFallOffDistance: number;
  44069. /**
  44070. * Specifies the ground mirror texture type.
  44071. * Unsigned Int by Default.
  44072. */
  44073. groundMirrorTextureType: number;
  44074. /**
  44075. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44076. * the shown objects.
  44077. */
  44078. groundYBias: number;
  44079. /**
  44080. * Specifies wether or not to create a skybox.
  44081. * True by default.
  44082. */
  44083. createSkybox: boolean;
  44084. /**
  44085. * Specifies the skybox size.
  44086. * 20 by default.
  44087. */
  44088. skyboxSize: number;
  44089. /**
  44090. * The texture used on the skybox for the main color.
  44091. * Comes from the BabylonJS CDN by default.
  44092. *
  44093. * Remarks: Can be either a texture or a url.
  44094. */
  44095. skyboxTexture: string | BaseTexture;
  44096. /**
  44097. * The color mixed in the skybox texture by default.
  44098. * BabylonJS clearColor by default.
  44099. */
  44100. skyboxColor: Color3;
  44101. /**
  44102. * The background rotation around the Y axis of the scene.
  44103. * This helps aligning the key lights of your scene with the background.
  44104. * 0 by default.
  44105. */
  44106. backgroundYRotation: number;
  44107. /**
  44108. * Compute automatically the size of the elements to best fit with the scene.
  44109. */
  44110. sizeAuto: boolean;
  44111. /**
  44112. * Default position of the rootMesh if autoSize is not true.
  44113. */
  44114. rootPosition: Vector3;
  44115. /**
  44116. * Sets up the image processing in the scene.
  44117. * true by default.
  44118. */
  44119. setupImageProcessing: boolean;
  44120. /**
  44121. * The texture used as your environment texture in the scene.
  44122. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44123. *
  44124. * Remarks: Can be either a texture or a url.
  44125. */
  44126. environmentTexture: string | BaseTexture;
  44127. /**
  44128. * The value of the exposure to apply to the scene.
  44129. * 0.6 by default if setupImageProcessing is true.
  44130. */
  44131. cameraExposure: number;
  44132. /**
  44133. * The value of the contrast to apply to the scene.
  44134. * 1.6 by default if setupImageProcessing is true.
  44135. */
  44136. cameraContrast: number;
  44137. /**
  44138. * Specifies wether or not tonemapping should be enabled in the scene.
  44139. * true by default if setupImageProcessing is true.
  44140. */
  44141. toneMappingEnabled: boolean;
  44142. }
  44143. /**
  44144. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44145. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44146. * It also helps with the default setup of your imageProcessing configuration.
  44147. */
  44148. export class EnvironmentHelper {
  44149. /**
  44150. * Default ground texture URL.
  44151. */
  44152. private static _groundTextureCDNUrl;
  44153. /**
  44154. * Default skybox texture URL.
  44155. */
  44156. private static _skyboxTextureCDNUrl;
  44157. /**
  44158. * Default environment texture URL.
  44159. */
  44160. private static _environmentTextureCDNUrl;
  44161. /**
  44162. * Creates the default options for the helper.
  44163. */
  44164. private static _getDefaultOptions;
  44165. private _rootMesh;
  44166. /**
  44167. * Gets the root mesh created by the helper.
  44168. */
  44169. readonly rootMesh: Mesh;
  44170. private _skybox;
  44171. /**
  44172. * Gets the skybox created by the helper.
  44173. */
  44174. readonly skybox: Nullable<Mesh>;
  44175. private _skyboxTexture;
  44176. /**
  44177. * Gets the skybox texture created by the helper.
  44178. */
  44179. readonly skyboxTexture: Nullable<BaseTexture>;
  44180. private _skyboxMaterial;
  44181. /**
  44182. * Gets the skybox material created by the helper.
  44183. */
  44184. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44185. private _ground;
  44186. /**
  44187. * Gets the ground mesh created by the helper.
  44188. */
  44189. readonly ground: Nullable<Mesh>;
  44190. private _groundTexture;
  44191. /**
  44192. * Gets the ground texture created by the helper.
  44193. */
  44194. readonly groundTexture: Nullable<BaseTexture>;
  44195. private _groundMirror;
  44196. /**
  44197. * Gets the ground mirror created by the helper.
  44198. */
  44199. readonly groundMirror: Nullable<MirrorTexture>;
  44200. /**
  44201. * Gets the ground mirror render list to helps pushing the meshes
  44202. * you wish in the ground reflection.
  44203. */
  44204. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44205. private _groundMaterial;
  44206. /**
  44207. * Gets the ground material created by the helper.
  44208. */
  44209. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44210. /**
  44211. * Stores the creation options.
  44212. */
  44213. private readonly _scene;
  44214. private _options;
  44215. /**
  44216. * This observable will be notified with any error during the creation of the environment,
  44217. * mainly texture creation errors.
  44218. */
  44219. onErrorObservable: Observable<{
  44220. message?: string;
  44221. exception?: any;
  44222. }>;
  44223. /**
  44224. * constructor
  44225. * @param options Defines the options we want to customize the helper
  44226. * @param scene The scene to add the material to
  44227. */
  44228. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44229. /**
  44230. * Updates the background according to the new options
  44231. * @param options
  44232. */
  44233. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44234. /**
  44235. * Sets the primary color of all the available elements.
  44236. * @param color the main color to affect to the ground and the background
  44237. */
  44238. setMainColor(color: Color3): void;
  44239. /**
  44240. * Setup the image processing according to the specified options.
  44241. */
  44242. private _setupImageProcessing;
  44243. /**
  44244. * Setup the environment texture according to the specified options.
  44245. */
  44246. private _setupEnvironmentTexture;
  44247. /**
  44248. * Setup the background according to the specified options.
  44249. */
  44250. private _setupBackground;
  44251. /**
  44252. * Get the scene sizes according to the setup.
  44253. */
  44254. private _getSceneSize;
  44255. /**
  44256. * Setup the ground according to the specified options.
  44257. */
  44258. private _setupGround;
  44259. /**
  44260. * Setup the ground material according to the specified options.
  44261. */
  44262. private _setupGroundMaterial;
  44263. /**
  44264. * Setup the ground diffuse texture according to the specified options.
  44265. */
  44266. private _setupGroundDiffuseTexture;
  44267. /**
  44268. * Setup the ground mirror texture according to the specified options.
  44269. */
  44270. private _setupGroundMirrorTexture;
  44271. /**
  44272. * Setup the ground to receive the mirror texture.
  44273. */
  44274. private _setupMirrorInGroundMaterial;
  44275. /**
  44276. * Setup the skybox according to the specified options.
  44277. */
  44278. private _setupSkybox;
  44279. /**
  44280. * Setup the skybox material according to the specified options.
  44281. */
  44282. private _setupSkyboxMaterial;
  44283. /**
  44284. * Setup the skybox reflection texture according to the specified options.
  44285. */
  44286. private _setupSkyboxReflectionTexture;
  44287. private _errorHandler;
  44288. /**
  44289. * Dispose all the elements created by the Helper.
  44290. */
  44291. dispose(): void;
  44292. }
  44293. }
  44294. declare module BABYLON {
  44295. /**
  44296. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44297. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44298. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44299. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44300. */
  44301. export class PhotoDome extends TransformNode {
  44302. /**
  44303. * Define the image as a Monoscopic panoramic 360 image.
  44304. */
  44305. static readonly MODE_MONOSCOPIC: number;
  44306. /**
  44307. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44308. */
  44309. static readonly MODE_TOPBOTTOM: number;
  44310. /**
  44311. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44312. */
  44313. static readonly MODE_SIDEBYSIDE: number;
  44314. private _useDirectMapping;
  44315. /**
  44316. * The texture being displayed on the sphere
  44317. */
  44318. protected _photoTexture: Texture;
  44319. /**
  44320. * Gets or sets the texture being displayed on the sphere
  44321. */
  44322. photoTexture: Texture;
  44323. /**
  44324. * Observable raised when an error occured while loading the 360 image
  44325. */
  44326. onLoadErrorObservable: Observable<string>;
  44327. /**
  44328. * The skybox material
  44329. */
  44330. protected _material: BackgroundMaterial;
  44331. /**
  44332. * The surface used for the skybox
  44333. */
  44334. protected _mesh: Mesh;
  44335. /**
  44336. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44337. * Also see the options.resolution property.
  44338. */
  44339. fovMultiplier: number;
  44340. private _imageMode;
  44341. /**
  44342. * Gets or set the current video mode for the video. It can be:
  44343. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  44344. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44345. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44346. */
  44347. imageMode: number;
  44348. /**
  44349. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44350. * @param name Element's name, child elements will append suffixes for their own names.
  44351. * @param urlsOfPhoto defines the url of the photo to display
  44352. * @param options defines an object containing optional or exposed sub element properties
  44353. * @param onError defines a callback called when an error occured while loading the texture
  44354. */
  44355. constructor(name: string, urlOfPhoto: string, options: {
  44356. resolution?: number;
  44357. size?: number;
  44358. useDirectMapping?: boolean;
  44359. faceForward?: boolean;
  44360. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44361. private _onBeforeCameraRenderObserver;
  44362. private _changeImageMode;
  44363. /**
  44364. * Releases resources associated with this node.
  44365. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44366. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44367. */
  44368. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44369. }
  44370. }
  44371. declare module BABYLON {
  44372. /** @hidden */
  44373. export var rgbdDecodePixelShader: {
  44374. name: string;
  44375. shader: string;
  44376. };
  44377. }
  44378. declare module BABYLON {
  44379. /**
  44380. * Class used to host texture specific utilities
  44381. */
  44382. export class BRDFTextureTools {
  44383. /**
  44384. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44385. * @param texture the texture to expand.
  44386. */
  44387. private static _ExpandDefaultBRDFTexture;
  44388. /**
  44389. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44390. * @param scene defines the hosting scene
  44391. * @returns the environment BRDF texture
  44392. */
  44393. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44394. private static _environmentBRDFBase64Texture;
  44395. }
  44396. }
  44397. declare module BABYLON {
  44398. /**
  44399. * @hidden
  44400. */
  44401. export interface IMaterialClearCoatDefines {
  44402. CLEARCOAT: boolean;
  44403. CLEARCOAT_DEFAULTIOR: boolean;
  44404. CLEARCOAT_TEXTURE: boolean;
  44405. CLEARCOAT_TEXTUREDIRECTUV: number;
  44406. CLEARCOAT_BUMP: boolean;
  44407. CLEARCOAT_BUMPDIRECTUV: number;
  44408. CLEARCOAT_TINT: boolean;
  44409. CLEARCOAT_TINT_TEXTURE: boolean;
  44410. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44411. /** @hidden */
  44412. _areTexturesDirty: boolean;
  44413. }
  44414. /**
  44415. * Define the code related to the clear coat parameters of the pbr material.
  44416. */
  44417. export class PBRClearCoatConfiguration {
  44418. /**
  44419. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44420. * The default fits with a polyurethane material.
  44421. */
  44422. private static readonly _DefaultIndiceOfRefraction;
  44423. private _isEnabled;
  44424. /**
  44425. * Defines if the clear coat is enabled in the material.
  44426. */
  44427. isEnabled: boolean;
  44428. /**
  44429. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44430. */
  44431. intensity: number;
  44432. /**
  44433. * Defines the clear coat layer roughness.
  44434. */
  44435. roughness: number;
  44436. private _indiceOfRefraction;
  44437. /**
  44438. * Defines the indice of refraction of the clear coat.
  44439. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44440. * The default fits with a polyurethane material.
  44441. * Changing the default value is more performance intensive.
  44442. */
  44443. indiceOfRefraction: number;
  44444. private _texture;
  44445. /**
  44446. * Stores the clear coat values in a texture.
  44447. */
  44448. texture: Nullable<BaseTexture>;
  44449. private _bumpTexture;
  44450. /**
  44451. * Define the clear coat specific bump texture.
  44452. */
  44453. bumpTexture: Nullable<BaseTexture>;
  44454. private _isTintEnabled;
  44455. /**
  44456. * Defines if the clear coat tint is enabled in the material.
  44457. */
  44458. isTintEnabled: boolean;
  44459. /**
  44460. * Defines the clear coat tint of the material.
  44461. * This is only use if tint is enabled
  44462. */
  44463. tintColor: Color3;
  44464. /**
  44465. * Defines the distance at which the tint color should be found in the
  44466. * clear coat media.
  44467. * This is only use if tint is enabled
  44468. */
  44469. tintColorAtDistance: number;
  44470. /**
  44471. * Defines the clear coat layer thickness.
  44472. * This is only use if tint is enabled
  44473. */
  44474. tintThickness: number;
  44475. private _tintTexture;
  44476. /**
  44477. * Stores the clear tint values in a texture.
  44478. * rgb is tint
  44479. * a is a thickness factor
  44480. */
  44481. tintTexture: Nullable<BaseTexture>;
  44482. /** @hidden */
  44483. private _internalMarkAllSubMeshesAsTexturesDirty;
  44484. /** @hidden */
  44485. _markAllSubMeshesAsTexturesDirty(): void;
  44486. /**
  44487. * Instantiate a new istance of clear coat configuration.
  44488. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44489. */
  44490. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44491. /**
  44492. * Gets wehter the submesh is ready to be used or not.
  44493. * @param defines the list of "defines" to update.
  44494. * @param scene defines the scene the material belongs to.
  44495. * @param engine defines the engine the material belongs to.
  44496. * @param disableBumpMap defines wether the material disables bump or not.
  44497. * @returns - boolean indicating that the submesh is ready or not.
  44498. */
  44499. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44500. /**
  44501. * Checks to see if a texture is used in the material.
  44502. * @param defines the list of "defines" to update.
  44503. * @param scene defines the scene to the material belongs to.
  44504. */
  44505. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44506. /**
  44507. * Binds the material data.
  44508. * @param uniformBuffer defines the Uniform buffer to fill in.
  44509. * @param scene defines the scene the material belongs to.
  44510. * @param engine defines the engine the material belongs to.
  44511. * @param disableBumpMap defines wether the material disables bump or not.
  44512. * @param isFrozen defines wether the material is frozen or not.
  44513. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44514. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44515. */
  44516. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44517. /**
  44518. * Checks to see if a texture is used in the material.
  44519. * @param texture - Base texture to use.
  44520. * @returns - Boolean specifying if a texture is used in the material.
  44521. */
  44522. hasTexture(texture: BaseTexture): boolean;
  44523. /**
  44524. * Returns an array of the actively used textures.
  44525. * @param activeTextures Array of BaseTextures
  44526. */
  44527. getActiveTextures(activeTextures: BaseTexture[]): void;
  44528. /**
  44529. * Returns the animatable textures.
  44530. * @param animatables Array of animatable textures.
  44531. */
  44532. getAnimatables(animatables: IAnimatable[]): void;
  44533. /**
  44534. * Disposes the resources of the material.
  44535. * @param forceDisposeTextures - Forces the disposal of all textures.
  44536. */
  44537. dispose(forceDisposeTextures?: boolean): void;
  44538. /**
  44539. * Get the current class name of the texture useful for serialization or dynamic coding.
  44540. * @returns "PBRClearCoatConfiguration"
  44541. */
  44542. getClassName(): string;
  44543. /**
  44544. * Add fallbacks to the effect fallbacks list.
  44545. * @param defines defines the Base texture to use.
  44546. * @param fallbacks defines the current fallback list.
  44547. * @param currentRank defines the current fallback rank.
  44548. * @returns the new fallback rank.
  44549. */
  44550. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44551. /**
  44552. * Add the required uniforms to the current list.
  44553. * @param uniforms defines the current uniform list.
  44554. */
  44555. static AddUniforms(uniforms: string[]): void;
  44556. /**
  44557. * Add the required samplers to the current list.
  44558. * @param samplers defines the current sampler list.
  44559. */
  44560. static AddSamplers(samplers: string[]): void;
  44561. /**
  44562. * Add the required uniforms to the current buffer.
  44563. * @param uniformBuffer defines the current uniform buffer.
  44564. */
  44565. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44566. /**
  44567. * Makes a duplicate of the current configuration into another one.
  44568. * @param clearCoatConfiguration define the config where to copy the info
  44569. */
  44570. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44571. /**
  44572. * Serializes this clear coat configuration.
  44573. * @returns - An object with the serialized config.
  44574. */
  44575. serialize(): any;
  44576. /**
  44577. * Parses a Clear Coat Configuration from a serialized object.
  44578. * @param source - Serialized object.
  44579. */
  44580. parse(source: any): void;
  44581. }
  44582. }
  44583. declare module BABYLON {
  44584. /**
  44585. * @hidden
  44586. */
  44587. export interface IMaterialAnisotropicDefines {
  44588. ANISOTROPIC: boolean;
  44589. ANISOTROPIC_TEXTURE: boolean;
  44590. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44591. MAINUV1: boolean;
  44592. _areTexturesDirty: boolean;
  44593. _needUVs: boolean;
  44594. }
  44595. /**
  44596. * Define the code related to the anisotropic parameters of the pbr material.
  44597. */
  44598. export class PBRAnisotropicConfiguration {
  44599. private _isEnabled;
  44600. /**
  44601. * Defines if the anisotropy is enabled in the material.
  44602. */
  44603. isEnabled: boolean;
  44604. /**
  44605. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44606. */
  44607. intensity: number;
  44608. /**
  44609. * Defines if the effect is along the tangents, bitangents or in between.
  44610. * By default, the effect is "strectching" the highlights along the tangents.
  44611. */
  44612. direction: Vector2;
  44613. private _texture;
  44614. /**
  44615. * Stores the anisotropy values in a texture.
  44616. * rg is direction (like normal from -1 to 1)
  44617. * b is a intensity
  44618. */
  44619. texture: Nullable<BaseTexture>;
  44620. /** @hidden */
  44621. private _internalMarkAllSubMeshesAsTexturesDirty;
  44622. /** @hidden */
  44623. _markAllSubMeshesAsTexturesDirty(): void;
  44624. /**
  44625. * Instantiate a new istance of anisotropy configuration.
  44626. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44627. */
  44628. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44629. /**
  44630. * Specifies that the submesh is ready to be used.
  44631. * @param defines the list of "defines" to update.
  44632. * @param scene defines the scene the material belongs to.
  44633. * @returns - boolean indicating that the submesh is ready or not.
  44634. */
  44635. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44636. /**
  44637. * Checks to see if a texture is used in the material.
  44638. * @param defines the list of "defines" to update.
  44639. * @param mesh the mesh we are preparing the defines for.
  44640. * @param scene defines the scene the material belongs to.
  44641. */
  44642. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44643. /**
  44644. * Binds the material data.
  44645. * @param uniformBuffer defines the Uniform buffer to fill in.
  44646. * @param scene defines the scene the material belongs to.
  44647. * @param isFrozen defines wether the material is frozen or not.
  44648. */
  44649. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44650. /**
  44651. * Checks to see if a texture is used in the material.
  44652. * @param texture - Base texture to use.
  44653. * @returns - Boolean specifying if a texture is used in the material.
  44654. */
  44655. hasTexture(texture: BaseTexture): boolean;
  44656. /**
  44657. * Returns an array of the actively used textures.
  44658. * @param activeTextures Array of BaseTextures
  44659. */
  44660. getActiveTextures(activeTextures: BaseTexture[]): void;
  44661. /**
  44662. * Returns the animatable textures.
  44663. * @param animatables Array of animatable textures.
  44664. */
  44665. getAnimatables(animatables: IAnimatable[]): void;
  44666. /**
  44667. * Disposes the resources of the material.
  44668. * @param forceDisposeTextures - Forces the disposal of all textures.
  44669. */
  44670. dispose(forceDisposeTextures?: boolean): void;
  44671. /**
  44672. * Get the current class name of the texture useful for serialization or dynamic coding.
  44673. * @returns "PBRAnisotropicConfiguration"
  44674. */
  44675. getClassName(): string;
  44676. /**
  44677. * Add fallbacks to the effect fallbacks list.
  44678. * @param defines defines the Base texture to use.
  44679. * @param fallbacks defines the current fallback list.
  44680. * @param currentRank defines the current fallback rank.
  44681. * @returns the new fallback rank.
  44682. */
  44683. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44684. /**
  44685. * Add the required uniforms to the current list.
  44686. * @param uniforms defines the current uniform list.
  44687. */
  44688. static AddUniforms(uniforms: string[]): void;
  44689. /**
  44690. * Add the required uniforms to the current buffer.
  44691. * @param uniformBuffer defines the current uniform buffer.
  44692. */
  44693. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44694. /**
  44695. * Add the required samplers to the current list.
  44696. * @param samplers defines the current sampler list.
  44697. */
  44698. static AddSamplers(samplers: string[]): void;
  44699. /**
  44700. * Makes a duplicate of the current configuration into another one.
  44701. * @param anisotropicConfiguration define the config where to copy the info
  44702. */
  44703. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44704. /**
  44705. * Serializes this anisotropy configuration.
  44706. * @returns - An object with the serialized config.
  44707. */
  44708. serialize(): any;
  44709. /**
  44710. * Parses a anisotropy Configuration from a serialized object.
  44711. * @param source - Serialized object.
  44712. */
  44713. parse(source: any): void;
  44714. }
  44715. }
  44716. declare module BABYLON {
  44717. /**
  44718. * @hidden
  44719. */
  44720. export interface IMaterialBRDFDefines {
  44721. BRDF_V_HEIGHT_CORRELATED: boolean;
  44722. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44723. SPHERICAL_HARMONICS: boolean;
  44724. /** @hidden */
  44725. _areMiscDirty: boolean;
  44726. }
  44727. /**
  44728. * Define the code related to the BRDF parameters of the pbr material.
  44729. */
  44730. export class PBRBRDFConfiguration {
  44731. /**
  44732. * Default value used for the energy conservation.
  44733. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44734. */
  44735. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44736. /**
  44737. * Default value used for the Smith Visibility Height Correlated mode.
  44738. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44739. */
  44740. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44741. /**
  44742. * Default value used for the IBL diffuse part.
  44743. * This can help switching back to the polynomials mode globally which is a tiny bit
  44744. * less GPU intensive at the drawback of a lower quality.
  44745. */
  44746. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44747. private _useEnergyConservation;
  44748. /**
  44749. * Defines if the material uses energy conservation.
  44750. */
  44751. useEnergyConservation: boolean;
  44752. private _useSmithVisibilityHeightCorrelated;
  44753. /**
  44754. * LEGACY Mode set to false
  44755. * Defines if the material uses height smith correlated visibility term.
  44756. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44757. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44758. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44759. * Not relying on height correlated will also disable energy conservation.
  44760. */
  44761. useSmithVisibilityHeightCorrelated: boolean;
  44762. private _useSphericalHarmonics;
  44763. /**
  44764. * LEGACY Mode set to false
  44765. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  44766. * diffuse part of the IBL.
  44767. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  44768. * to the ground truth.
  44769. */
  44770. useSphericalHarmonics: boolean;
  44771. /** @hidden */
  44772. private _internalMarkAllSubMeshesAsMiscDirty;
  44773. /** @hidden */
  44774. _markAllSubMeshesAsMiscDirty(): void;
  44775. /**
  44776. * Instantiate a new istance of clear coat configuration.
  44777. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44778. */
  44779. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44780. /**
  44781. * Checks to see if a texture is used in the material.
  44782. * @param defines the list of "defines" to update.
  44783. */
  44784. prepareDefines(defines: IMaterialBRDFDefines): void;
  44785. /**
  44786. * Get the current class name of the texture useful for serialization or dynamic coding.
  44787. * @returns "PBRClearCoatConfiguration"
  44788. */
  44789. getClassName(): string;
  44790. /**
  44791. * Makes a duplicate of the current configuration into another one.
  44792. * @param brdfConfiguration define the config where to copy the info
  44793. */
  44794. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44795. /**
  44796. * Serializes this BRDF configuration.
  44797. * @returns - An object with the serialized config.
  44798. */
  44799. serialize(): any;
  44800. /**
  44801. * Parses a BRDF Configuration from a serialized object.
  44802. * @param source - Serialized object.
  44803. */
  44804. parse(source: any): void;
  44805. }
  44806. }
  44807. declare module BABYLON {
  44808. /**
  44809. * @hidden
  44810. */
  44811. export interface IMaterialSheenDefines {
  44812. SHEEN: boolean;
  44813. SHEEN_TEXTURE: boolean;
  44814. SHEEN_TEXTUREDIRECTUV: number;
  44815. SHEEN_LINKWITHALBEDO: boolean;
  44816. /** @hidden */
  44817. _areTexturesDirty: boolean;
  44818. }
  44819. /**
  44820. * Define the code related to the Sheen parameters of the pbr material.
  44821. */
  44822. export class PBRSheenConfiguration {
  44823. private _isEnabled;
  44824. /**
  44825. * Defines if the material uses sheen.
  44826. */
  44827. isEnabled: boolean;
  44828. private _linkSheenWithAlbedo;
  44829. /**
  44830. * Defines if the sheen is linked to the sheen color.
  44831. */
  44832. linkSheenWithAlbedo: boolean;
  44833. /**
  44834. * Defines the sheen intensity.
  44835. */
  44836. intensity: number;
  44837. /**
  44838. * Defines the sheen color.
  44839. */
  44840. color: Color3;
  44841. private _texture;
  44842. /**
  44843. * Stores the sheen tint values in a texture.
  44844. * rgb is tint
  44845. * a is a intensity
  44846. */
  44847. texture: Nullable<BaseTexture>;
  44848. /** @hidden */
  44849. private _internalMarkAllSubMeshesAsTexturesDirty;
  44850. /** @hidden */
  44851. _markAllSubMeshesAsTexturesDirty(): void;
  44852. /**
  44853. * Instantiate a new istance of clear coat configuration.
  44854. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44855. */
  44856. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44857. /**
  44858. * Specifies that the submesh is ready to be used.
  44859. * @param defines the list of "defines" to update.
  44860. * @param scene defines the scene the material belongs to.
  44861. * @returns - boolean indicating that the submesh is ready or not.
  44862. */
  44863. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44864. /**
  44865. * Checks to see if a texture is used in the material.
  44866. * @param defines the list of "defines" to update.
  44867. * @param scene defines the scene the material belongs to.
  44868. */
  44869. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44870. /**
  44871. * Binds the material data.
  44872. * @param uniformBuffer defines the Uniform buffer to fill in.
  44873. * @param scene defines the scene the material belongs to.
  44874. * @param isFrozen defines wether the material is frozen or not.
  44875. */
  44876. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44877. /**
  44878. * Checks to see if a texture is used in the material.
  44879. * @param texture - Base texture to use.
  44880. * @returns - Boolean specifying if a texture is used in the material.
  44881. */
  44882. hasTexture(texture: BaseTexture): boolean;
  44883. /**
  44884. * Returns an array of the actively used textures.
  44885. * @param activeTextures Array of BaseTextures
  44886. */
  44887. getActiveTextures(activeTextures: BaseTexture[]): void;
  44888. /**
  44889. * Returns the animatable textures.
  44890. * @param animatables Array of animatable textures.
  44891. */
  44892. getAnimatables(animatables: IAnimatable[]): void;
  44893. /**
  44894. * Disposes the resources of the material.
  44895. * @param forceDisposeTextures - Forces the disposal of all textures.
  44896. */
  44897. dispose(forceDisposeTextures?: boolean): void;
  44898. /**
  44899. * Get the current class name of the texture useful for serialization or dynamic coding.
  44900. * @returns "PBRSheenConfiguration"
  44901. */
  44902. getClassName(): string;
  44903. /**
  44904. * Add fallbacks to the effect fallbacks list.
  44905. * @param defines defines the Base texture to use.
  44906. * @param fallbacks defines the current fallback list.
  44907. * @param currentRank defines the current fallback rank.
  44908. * @returns the new fallback rank.
  44909. */
  44910. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44911. /**
  44912. * Add the required uniforms to the current list.
  44913. * @param uniforms defines the current uniform list.
  44914. */
  44915. static AddUniforms(uniforms: string[]): void;
  44916. /**
  44917. * Add the required uniforms to the current buffer.
  44918. * @param uniformBuffer defines the current uniform buffer.
  44919. */
  44920. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44921. /**
  44922. * Add the required samplers to the current list.
  44923. * @param samplers defines the current sampler list.
  44924. */
  44925. static AddSamplers(samplers: string[]): void;
  44926. /**
  44927. * Makes a duplicate of the current configuration into another one.
  44928. * @param sheenConfiguration define the config where to copy the info
  44929. */
  44930. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44931. /**
  44932. * Serializes this BRDF configuration.
  44933. * @returns - An object with the serialized config.
  44934. */
  44935. serialize(): any;
  44936. /**
  44937. * Parses a Sheen Configuration from a serialized object.
  44938. * @param source - Serialized object.
  44939. */
  44940. parse(source: any): void;
  44941. }
  44942. }
  44943. declare module BABYLON {
  44944. /**
  44945. * @hidden
  44946. */
  44947. export interface IMaterialSubSurfaceDefines {
  44948. SUBSURFACE: boolean;
  44949. SS_REFRACTION: boolean;
  44950. SS_TRANSLUCENCY: boolean;
  44951. SS_SCATERRING: boolean;
  44952. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44953. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44954. SS_REFRACTIONMAP_3D: boolean;
  44955. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44956. SS_LODINREFRACTIONALPHA: boolean;
  44957. SS_GAMMAREFRACTION: boolean;
  44958. SS_RGBDREFRACTION: boolean;
  44959. SS_LINEARSPECULARREFRACTION: boolean;
  44960. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44961. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44962. /** @hidden */
  44963. _areTexturesDirty: boolean;
  44964. }
  44965. /**
  44966. * Define the code related to the sub surface parameters of the pbr material.
  44967. */
  44968. export class PBRSubSurfaceConfiguration {
  44969. private _isRefractionEnabled;
  44970. /**
  44971. * Defines if the refraction is enabled in the material.
  44972. */
  44973. isRefractionEnabled: boolean;
  44974. private _isTranslucencyEnabled;
  44975. /**
  44976. * Defines if the translucency is enabled in the material.
  44977. */
  44978. isTranslucencyEnabled: boolean;
  44979. private _isScatteringEnabled;
  44980. /**
  44981. * Defines the refraction intensity of the material.
  44982. * The refraction when enabled replaces the Diffuse part of the material.
  44983. * The intensity helps transitionning between diffuse and refraction.
  44984. */
  44985. refractionIntensity: number;
  44986. /**
  44987. * Defines the translucency intensity of the material.
  44988. * When translucency has been enabled, this defines how much of the "translucency"
  44989. * is addded to the diffuse part of the material.
  44990. */
  44991. translucencyIntensity: number;
  44992. /**
  44993. * Defines the scattering intensity of the material.
  44994. * When scattering has been enabled, this defines how much of the "scattered light"
  44995. * is addded to the diffuse part of the material.
  44996. */
  44997. scatteringIntensity: number;
  44998. private _thicknessTexture;
  44999. /**
  45000. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45001. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45002. * 0 would mean minimumThickness
  45003. * 1 would mean maximumThickness
  45004. * The other channels might be use as a mask to vary the different effects intensity.
  45005. */
  45006. thicknessTexture: Nullable<BaseTexture>;
  45007. private _refractionTexture;
  45008. /**
  45009. * Defines the texture to use for refraction.
  45010. */
  45011. refractionTexture: Nullable<BaseTexture>;
  45012. private _indexOfRefraction;
  45013. /**
  45014. * Defines the indice of refraction used in the material.
  45015. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45016. */
  45017. indexOfRefraction: number;
  45018. private _invertRefractionY;
  45019. /**
  45020. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45021. */
  45022. invertRefractionY: boolean;
  45023. private _linkRefractionWithTransparency;
  45024. /**
  45025. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45026. * Materials half opaque for instance using refraction could benefit from this control.
  45027. */
  45028. linkRefractionWithTransparency: boolean;
  45029. /**
  45030. * Defines the minimum thickness stored in the thickness map.
  45031. * If no thickness map is defined, this value will be used to simulate thickness.
  45032. */
  45033. minimumThickness: number;
  45034. /**
  45035. * Defines the maximum thickness stored in the thickness map.
  45036. */
  45037. maximumThickness: number;
  45038. /**
  45039. * Defines the volume tint of the material.
  45040. * This is used for both translucency and scattering.
  45041. */
  45042. tintColor: Color3;
  45043. /**
  45044. * Defines the distance at which the tint color should be found in the media.
  45045. * This is used for refraction only.
  45046. */
  45047. tintColorAtDistance: number;
  45048. /**
  45049. * Defines how far each channel transmit through the media.
  45050. * It is defined as a color to simplify it selection.
  45051. */
  45052. diffusionDistance: Color3;
  45053. private _useMaskFromThicknessTexture;
  45054. /**
  45055. * Stores the intensity of the different subsurface effects in the thickness texture.
  45056. * * the green channel is the translucency intensity.
  45057. * * the blue channel is the scattering intensity.
  45058. * * the alpha channel is the refraction intensity.
  45059. */
  45060. useMaskFromThicknessTexture: boolean;
  45061. /** @hidden */
  45062. private _internalMarkAllSubMeshesAsTexturesDirty;
  45063. /** @hidden */
  45064. _markAllSubMeshesAsTexturesDirty(): void;
  45065. /**
  45066. * Instantiate a new istance of sub surface configuration.
  45067. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45068. */
  45069. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45070. /**
  45071. * Gets wehter the submesh is ready to be used or not.
  45072. * @param defines the list of "defines" to update.
  45073. * @param scene defines the scene the material belongs to.
  45074. * @returns - boolean indicating that the submesh is ready or not.
  45075. */
  45076. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45077. /**
  45078. * Checks to see if a texture is used in the material.
  45079. * @param defines the list of "defines" to update.
  45080. * @param scene defines the scene to the material belongs to.
  45081. */
  45082. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45083. /**
  45084. * Binds the material data.
  45085. * @param uniformBuffer defines the Uniform buffer to fill in.
  45086. * @param scene defines the scene the material belongs to.
  45087. * @param engine defines the engine the material belongs to.
  45088. * @param isFrozen defines wether the material is frozen or not.
  45089. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45090. */
  45091. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45092. /**
  45093. * Unbinds the material from the mesh.
  45094. * @param activeEffect defines the effect that should be unbound from.
  45095. * @returns true if unbound, otherwise false
  45096. */
  45097. unbind(activeEffect: Effect): boolean;
  45098. /**
  45099. * Returns the texture used for refraction or null if none is used.
  45100. * @param scene defines the scene the material belongs to.
  45101. * @returns - Refraction texture if present. If no refraction texture and refraction
  45102. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45103. */
  45104. private _getRefractionTexture;
  45105. /**
  45106. * Returns true if alpha blending should be disabled.
  45107. */
  45108. readonly disableAlphaBlending: boolean;
  45109. /**
  45110. * Fills the list of render target textures.
  45111. * @param renderTargets the list of render targets to update
  45112. */
  45113. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  45114. /**
  45115. * Checks to see if a texture is used in the material.
  45116. * @param texture - Base texture to use.
  45117. * @returns - Boolean specifying if a texture is used in the material.
  45118. */
  45119. hasTexture(texture: BaseTexture): boolean;
  45120. /**
  45121. * Gets a boolean indicating that current material needs to register RTT
  45122. * @returns true if this uses a render target otherwise false.
  45123. */
  45124. hasRenderTargetTextures(): boolean;
  45125. /**
  45126. * Returns an array of the actively used textures.
  45127. * @param activeTextures Array of BaseTextures
  45128. */
  45129. getActiveTextures(activeTextures: BaseTexture[]): void;
  45130. /**
  45131. * Returns the animatable textures.
  45132. * @param animatables Array of animatable textures.
  45133. */
  45134. getAnimatables(animatables: IAnimatable[]): void;
  45135. /**
  45136. * Disposes the resources of the material.
  45137. * @param forceDisposeTextures - Forces the disposal of all textures.
  45138. */
  45139. dispose(forceDisposeTextures?: boolean): void;
  45140. /**
  45141. * Get the current class name of the texture useful for serialization or dynamic coding.
  45142. * @returns "PBRSubSurfaceConfiguration"
  45143. */
  45144. getClassName(): string;
  45145. /**
  45146. * Add fallbacks to the effect fallbacks list.
  45147. * @param defines defines the Base texture to use.
  45148. * @param fallbacks defines the current fallback list.
  45149. * @param currentRank defines the current fallback rank.
  45150. * @returns the new fallback rank.
  45151. */
  45152. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45153. /**
  45154. * Add the required uniforms to the current list.
  45155. * @param uniforms defines the current uniform list.
  45156. */
  45157. static AddUniforms(uniforms: string[]): void;
  45158. /**
  45159. * Add the required samplers to the current list.
  45160. * @param samplers defines the current sampler list.
  45161. */
  45162. static AddSamplers(samplers: string[]): void;
  45163. /**
  45164. * Add the required uniforms to the current buffer.
  45165. * @param uniformBuffer defines the current uniform buffer.
  45166. */
  45167. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45168. /**
  45169. * Makes a duplicate of the current configuration into another one.
  45170. * @param configuration define the config where to copy the info
  45171. */
  45172. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  45173. /**
  45174. * Serializes this Sub Surface configuration.
  45175. * @returns - An object with the serialized config.
  45176. */
  45177. serialize(): any;
  45178. /**
  45179. * Parses a Sub Surface Configuration from a serialized object.
  45180. * @param source - Serialized object.
  45181. */
  45182. parse(source: any): void;
  45183. }
  45184. }
  45185. declare module BABYLON {
  45186. /** @hidden */
  45187. export var pbrFragmentDeclaration: {
  45188. name: string;
  45189. shader: string;
  45190. };
  45191. }
  45192. declare module BABYLON {
  45193. /** @hidden */
  45194. export var pbrUboDeclaration: {
  45195. name: string;
  45196. shader: string;
  45197. };
  45198. }
  45199. declare module BABYLON {
  45200. /** @hidden */
  45201. export var pbrFragmentExtraDeclaration: {
  45202. name: string;
  45203. shader: string;
  45204. };
  45205. }
  45206. declare module BABYLON {
  45207. /** @hidden */
  45208. export var pbrFragmentSamplersDeclaration: {
  45209. name: string;
  45210. shader: string;
  45211. };
  45212. }
  45213. declare module BABYLON {
  45214. /** @hidden */
  45215. export var pbrHelperFunctions: {
  45216. name: string;
  45217. shader: string;
  45218. };
  45219. }
  45220. declare module BABYLON {
  45221. /** @hidden */
  45222. export var harmonicsFunctions: {
  45223. name: string;
  45224. shader: string;
  45225. };
  45226. }
  45227. declare module BABYLON {
  45228. /** @hidden */
  45229. export var pbrDirectLightingSetupFunctions: {
  45230. name: string;
  45231. shader: string;
  45232. };
  45233. }
  45234. declare module BABYLON {
  45235. /** @hidden */
  45236. export var pbrDirectLightingFalloffFunctions: {
  45237. name: string;
  45238. shader: string;
  45239. };
  45240. }
  45241. declare module BABYLON {
  45242. /** @hidden */
  45243. export var pbrBRDFFunctions: {
  45244. name: string;
  45245. shader: string;
  45246. };
  45247. }
  45248. declare module BABYLON {
  45249. /** @hidden */
  45250. export var pbrDirectLightingFunctions: {
  45251. name: string;
  45252. shader: string;
  45253. };
  45254. }
  45255. declare module BABYLON {
  45256. /** @hidden */
  45257. export var pbrIBLFunctions: {
  45258. name: string;
  45259. shader: string;
  45260. };
  45261. }
  45262. declare module BABYLON {
  45263. /** @hidden */
  45264. export var pbrDebug: {
  45265. name: string;
  45266. shader: string;
  45267. };
  45268. }
  45269. declare module BABYLON {
  45270. /** @hidden */
  45271. export var pbrPixelShader: {
  45272. name: string;
  45273. shader: string;
  45274. };
  45275. }
  45276. declare module BABYLON {
  45277. /** @hidden */
  45278. export var pbrVertexDeclaration: {
  45279. name: string;
  45280. shader: string;
  45281. };
  45282. }
  45283. declare module BABYLON {
  45284. /** @hidden */
  45285. export var pbrVertexShader: {
  45286. name: string;
  45287. shader: string;
  45288. };
  45289. }
  45290. declare module BABYLON {
  45291. /**
  45292. * Manages the defines for the PBR Material.
  45293. * @hidden
  45294. */
  45295. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  45296. PBR: boolean;
  45297. MAINUV1: boolean;
  45298. MAINUV2: boolean;
  45299. UV1: boolean;
  45300. UV2: boolean;
  45301. ALBEDO: boolean;
  45302. ALBEDODIRECTUV: number;
  45303. VERTEXCOLOR: boolean;
  45304. AMBIENT: boolean;
  45305. AMBIENTDIRECTUV: number;
  45306. AMBIENTINGRAYSCALE: boolean;
  45307. OPACITY: boolean;
  45308. VERTEXALPHA: boolean;
  45309. OPACITYDIRECTUV: number;
  45310. OPACITYRGB: boolean;
  45311. ALPHATEST: boolean;
  45312. DEPTHPREPASS: boolean;
  45313. ALPHABLEND: boolean;
  45314. ALPHAFROMALBEDO: boolean;
  45315. ALPHATESTVALUE: string;
  45316. SPECULAROVERALPHA: boolean;
  45317. RADIANCEOVERALPHA: boolean;
  45318. ALPHAFRESNEL: boolean;
  45319. LINEARALPHAFRESNEL: boolean;
  45320. PREMULTIPLYALPHA: boolean;
  45321. EMISSIVE: boolean;
  45322. EMISSIVEDIRECTUV: number;
  45323. REFLECTIVITY: boolean;
  45324. REFLECTIVITYDIRECTUV: number;
  45325. SPECULARTERM: boolean;
  45326. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  45327. MICROSURFACEAUTOMATIC: boolean;
  45328. LODBASEDMICROSFURACE: boolean;
  45329. MICROSURFACEMAP: boolean;
  45330. MICROSURFACEMAPDIRECTUV: number;
  45331. METALLICWORKFLOW: boolean;
  45332. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  45333. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  45334. METALLNESSSTOREINMETALMAPBLUE: boolean;
  45335. AOSTOREINMETALMAPRED: boolean;
  45336. ENVIRONMENTBRDF: boolean;
  45337. ENVIRONMENTBRDF_RGBD: boolean;
  45338. NORMAL: boolean;
  45339. TANGENT: boolean;
  45340. BUMP: boolean;
  45341. BUMPDIRECTUV: number;
  45342. OBJECTSPACE_NORMALMAP: boolean;
  45343. PARALLAX: boolean;
  45344. PARALLAXOCCLUSION: boolean;
  45345. NORMALXYSCALE: boolean;
  45346. LIGHTMAP: boolean;
  45347. LIGHTMAPDIRECTUV: number;
  45348. USELIGHTMAPASSHADOWMAP: boolean;
  45349. GAMMALIGHTMAP: boolean;
  45350. REFLECTION: boolean;
  45351. REFLECTIONMAP_3D: boolean;
  45352. REFLECTIONMAP_SPHERICAL: boolean;
  45353. REFLECTIONMAP_PLANAR: boolean;
  45354. REFLECTIONMAP_CUBIC: boolean;
  45355. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  45356. REFLECTIONMAP_PROJECTION: boolean;
  45357. REFLECTIONMAP_SKYBOX: boolean;
  45358. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  45359. REFLECTIONMAP_EXPLICIT: boolean;
  45360. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  45361. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  45362. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  45363. INVERTCUBICMAP: boolean;
  45364. USESPHERICALFROMREFLECTIONMAP: boolean;
  45365. USEIRRADIANCEMAP: boolean;
  45366. SPHERICAL_HARMONICS: boolean;
  45367. USESPHERICALINVERTEX: boolean;
  45368. REFLECTIONMAP_OPPOSITEZ: boolean;
  45369. LODINREFLECTIONALPHA: boolean;
  45370. GAMMAREFLECTION: boolean;
  45371. RGBDREFLECTION: boolean;
  45372. LINEARSPECULARREFLECTION: boolean;
  45373. RADIANCEOCCLUSION: boolean;
  45374. HORIZONOCCLUSION: boolean;
  45375. INSTANCES: boolean;
  45376. NUM_BONE_INFLUENCERS: number;
  45377. BonesPerMesh: number;
  45378. BONETEXTURE: boolean;
  45379. NONUNIFORMSCALING: boolean;
  45380. MORPHTARGETS: boolean;
  45381. MORPHTARGETS_NORMAL: boolean;
  45382. MORPHTARGETS_TANGENT: boolean;
  45383. NUM_MORPH_INFLUENCERS: number;
  45384. IMAGEPROCESSING: boolean;
  45385. VIGNETTE: boolean;
  45386. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45387. VIGNETTEBLENDMODEOPAQUE: boolean;
  45388. TONEMAPPING: boolean;
  45389. TONEMAPPING_ACES: boolean;
  45390. CONTRAST: boolean;
  45391. COLORCURVES: boolean;
  45392. COLORGRADING: boolean;
  45393. COLORGRADING3D: boolean;
  45394. SAMPLER3DGREENDEPTH: boolean;
  45395. SAMPLER3DBGRMAP: boolean;
  45396. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45397. EXPOSURE: boolean;
  45398. MULTIVIEW: boolean;
  45399. USEPHYSICALLIGHTFALLOFF: boolean;
  45400. USEGLTFLIGHTFALLOFF: boolean;
  45401. TWOSIDEDLIGHTING: boolean;
  45402. SHADOWFLOAT: boolean;
  45403. CLIPPLANE: boolean;
  45404. CLIPPLANE2: boolean;
  45405. CLIPPLANE3: boolean;
  45406. CLIPPLANE4: boolean;
  45407. POINTSIZE: boolean;
  45408. FOG: boolean;
  45409. LOGARITHMICDEPTH: boolean;
  45410. FORCENORMALFORWARD: boolean;
  45411. SPECULARAA: boolean;
  45412. CLEARCOAT: boolean;
  45413. CLEARCOAT_DEFAULTIOR: boolean;
  45414. CLEARCOAT_TEXTURE: boolean;
  45415. CLEARCOAT_TEXTUREDIRECTUV: number;
  45416. CLEARCOAT_BUMP: boolean;
  45417. CLEARCOAT_BUMPDIRECTUV: number;
  45418. CLEARCOAT_TINT: boolean;
  45419. CLEARCOAT_TINT_TEXTURE: boolean;
  45420. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45421. ANISOTROPIC: boolean;
  45422. ANISOTROPIC_TEXTURE: boolean;
  45423. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45424. BRDF_V_HEIGHT_CORRELATED: boolean;
  45425. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45426. SHEEN: boolean;
  45427. SHEEN_TEXTURE: boolean;
  45428. SHEEN_TEXTUREDIRECTUV: number;
  45429. SHEEN_LINKWITHALBEDO: boolean;
  45430. SUBSURFACE: boolean;
  45431. SS_REFRACTION: boolean;
  45432. SS_TRANSLUCENCY: boolean;
  45433. SS_SCATERRING: boolean;
  45434. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45435. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45436. SS_REFRACTIONMAP_3D: boolean;
  45437. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45438. SS_LODINREFRACTIONALPHA: boolean;
  45439. SS_GAMMAREFRACTION: boolean;
  45440. SS_RGBDREFRACTION: boolean;
  45441. SS_LINEARSPECULARREFRACTION: boolean;
  45442. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45443. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45444. UNLIT: boolean;
  45445. DEBUGMODE: number;
  45446. /**
  45447. * Initializes the PBR Material defines.
  45448. */
  45449. constructor();
  45450. /**
  45451. * Resets the PBR Material defines.
  45452. */
  45453. reset(): void;
  45454. }
  45455. /**
  45456. * The Physically based material base class of BJS.
  45457. *
  45458. * This offers the main features of a standard PBR material.
  45459. * For more information, please refer to the documentation :
  45460. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45461. */
  45462. export abstract class PBRBaseMaterial extends PushMaterial {
  45463. /**
  45464. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45465. */
  45466. static readonly PBRMATERIAL_OPAQUE: number;
  45467. /**
  45468. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45469. */
  45470. static readonly PBRMATERIAL_ALPHATEST: number;
  45471. /**
  45472. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45473. */
  45474. static readonly PBRMATERIAL_ALPHABLEND: number;
  45475. /**
  45476. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45477. * They are also discarded below the alpha cutoff threshold to improve performances.
  45478. */
  45479. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45480. /**
  45481. * Defines the default value of how much AO map is occluding the analytical lights
  45482. * (point spot...).
  45483. */
  45484. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45485. /**
  45486. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45487. */
  45488. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45489. /**
  45490. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45491. * to enhance interoperability with other engines.
  45492. */
  45493. static readonly LIGHTFALLOFF_GLTF: number;
  45494. /**
  45495. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45496. * to enhance interoperability with other materials.
  45497. */
  45498. static readonly LIGHTFALLOFF_STANDARD: number;
  45499. /**
  45500. * Intensity of the direct lights e.g. the four lights available in your scene.
  45501. * This impacts both the direct diffuse and specular highlights.
  45502. */
  45503. protected _directIntensity: number;
  45504. /**
  45505. * Intensity of the emissive part of the material.
  45506. * This helps controlling the emissive effect without modifying the emissive color.
  45507. */
  45508. protected _emissiveIntensity: number;
  45509. /**
  45510. * Intensity of the environment e.g. how much the environment will light the object
  45511. * either through harmonics for rough material or through the refelction for shiny ones.
  45512. */
  45513. protected _environmentIntensity: number;
  45514. /**
  45515. * This is a special control allowing the reduction of the specular highlights coming from the
  45516. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45517. */
  45518. protected _specularIntensity: number;
  45519. /**
  45520. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45521. */
  45522. private _lightingInfos;
  45523. /**
  45524. * Debug Control allowing disabling the bump map on this material.
  45525. */
  45526. protected _disableBumpMap: boolean;
  45527. /**
  45528. * AKA Diffuse Texture in standard nomenclature.
  45529. */
  45530. protected _albedoTexture: Nullable<BaseTexture>;
  45531. /**
  45532. * AKA Occlusion Texture in other nomenclature.
  45533. */
  45534. protected _ambientTexture: Nullable<BaseTexture>;
  45535. /**
  45536. * AKA Occlusion Texture Intensity in other nomenclature.
  45537. */
  45538. protected _ambientTextureStrength: number;
  45539. /**
  45540. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45541. * 1 means it completely occludes it
  45542. * 0 mean it has no impact
  45543. */
  45544. protected _ambientTextureImpactOnAnalyticalLights: number;
  45545. /**
  45546. * Stores the alpha values in a texture.
  45547. */
  45548. protected _opacityTexture: Nullable<BaseTexture>;
  45549. /**
  45550. * Stores the reflection values in a texture.
  45551. */
  45552. protected _reflectionTexture: Nullable<BaseTexture>;
  45553. /**
  45554. * Stores the emissive values in a texture.
  45555. */
  45556. protected _emissiveTexture: Nullable<BaseTexture>;
  45557. /**
  45558. * AKA Specular texture in other nomenclature.
  45559. */
  45560. protected _reflectivityTexture: Nullable<BaseTexture>;
  45561. /**
  45562. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45563. */
  45564. protected _metallicTexture: Nullable<BaseTexture>;
  45565. /**
  45566. * Specifies the metallic scalar of the metallic/roughness workflow.
  45567. * Can also be used to scale the metalness values of the metallic texture.
  45568. */
  45569. protected _metallic: Nullable<number>;
  45570. /**
  45571. * Specifies the roughness scalar of the metallic/roughness workflow.
  45572. * Can also be used to scale the roughness values of the metallic texture.
  45573. */
  45574. protected _roughness: Nullable<number>;
  45575. /**
  45576. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45577. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45578. */
  45579. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45580. /**
  45581. * Stores surface normal data used to displace a mesh in a texture.
  45582. */
  45583. protected _bumpTexture: Nullable<BaseTexture>;
  45584. /**
  45585. * Stores the pre-calculated light information of a mesh in a texture.
  45586. */
  45587. protected _lightmapTexture: Nullable<BaseTexture>;
  45588. /**
  45589. * The color of a material in ambient lighting.
  45590. */
  45591. protected _ambientColor: Color3;
  45592. /**
  45593. * AKA Diffuse Color in other nomenclature.
  45594. */
  45595. protected _albedoColor: Color3;
  45596. /**
  45597. * AKA Specular Color in other nomenclature.
  45598. */
  45599. protected _reflectivityColor: Color3;
  45600. /**
  45601. * The color applied when light is reflected from a material.
  45602. */
  45603. protected _reflectionColor: Color3;
  45604. /**
  45605. * The color applied when light is emitted from a material.
  45606. */
  45607. protected _emissiveColor: Color3;
  45608. /**
  45609. * AKA Glossiness in other nomenclature.
  45610. */
  45611. protected _microSurface: number;
  45612. /**
  45613. * Specifies that the material will use the light map as a show map.
  45614. */
  45615. protected _useLightmapAsShadowmap: boolean;
  45616. /**
  45617. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45618. * makes the reflect vector face the model (under horizon).
  45619. */
  45620. protected _useHorizonOcclusion: boolean;
  45621. /**
  45622. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45623. * too much the area relying on ambient texture to define their ambient occlusion.
  45624. */
  45625. protected _useRadianceOcclusion: boolean;
  45626. /**
  45627. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45628. */
  45629. protected _useAlphaFromAlbedoTexture: boolean;
  45630. /**
  45631. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45632. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45633. */
  45634. protected _useSpecularOverAlpha: boolean;
  45635. /**
  45636. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45637. */
  45638. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45639. /**
  45640. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45641. */
  45642. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45643. /**
  45644. * Specifies if the metallic texture contains the roughness information in its green channel.
  45645. */
  45646. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45647. /**
  45648. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45649. */
  45650. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45651. /**
  45652. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45653. */
  45654. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45655. /**
  45656. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45657. */
  45658. protected _useAmbientInGrayScale: boolean;
  45659. /**
  45660. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45661. * The material will try to infer what glossiness each pixel should be.
  45662. */
  45663. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45664. /**
  45665. * Defines the falloff type used in this material.
  45666. * It by default is Physical.
  45667. */
  45668. protected _lightFalloff: number;
  45669. /**
  45670. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45671. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45672. */
  45673. protected _useRadianceOverAlpha: boolean;
  45674. /**
  45675. * Allows using an object space normal map (instead of tangent space).
  45676. */
  45677. protected _useObjectSpaceNormalMap: boolean;
  45678. /**
  45679. * Allows using the bump map in parallax mode.
  45680. */
  45681. protected _useParallax: boolean;
  45682. /**
  45683. * Allows using the bump map in parallax occlusion mode.
  45684. */
  45685. protected _useParallaxOcclusion: boolean;
  45686. /**
  45687. * Controls the scale bias of the parallax mode.
  45688. */
  45689. protected _parallaxScaleBias: number;
  45690. /**
  45691. * If sets to true, disables all the lights affecting the material.
  45692. */
  45693. protected _disableLighting: boolean;
  45694. /**
  45695. * Number of Simultaneous lights allowed on the material.
  45696. */
  45697. protected _maxSimultaneousLights: number;
  45698. /**
  45699. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45700. */
  45701. protected _invertNormalMapX: boolean;
  45702. /**
  45703. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45704. */
  45705. protected _invertNormalMapY: boolean;
  45706. /**
  45707. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45708. */
  45709. protected _twoSidedLighting: boolean;
  45710. /**
  45711. * Defines the alpha limits in alpha test mode.
  45712. */
  45713. protected _alphaCutOff: number;
  45714. /**
  45715. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45716. */
  45717. protected _forceAlphaTest: boolean;
  45718. /**
  45719. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45720. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45721. */
  45722. protected _useAlphaFresnel: boolean;
  45723. /**
  45724. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45725. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45726. */
  45727. protected _useLinearAlphaFresnel: boolean;
  45728. /**
  45729. * The transparency mode of the material.
  45730. */
  45731. protected _transparencyMode: Nullable<number>;
  45732. /**
  45733. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45734. * from cos thetav and roughness:
  45735. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45736. */
  45737. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45738. /**
  45739. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45740. */
  45741. protected _forceIrradianceInFragment: boolean;
  45742. /**
  45743. * Force normal to face away from face.
  45744. */
  45745. protected _forceNormalForward: boolean;
  45746. /**
  45747. * Enables specular anti aliasing in the PBR shader.
  45748. * It will both interacts on the Geometry for analytical and IBL lighting.
  45749. * It also prefilter the roughness map based on the bump values.
  45750. */
  45751. protected _enableSpecularAntiAliasing: boolean;
  45752. /**
  45753. * Default configuration related to image processing available in the PBR Material.
  45754. */
  45755. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45756. /**
  45757. * Keep track of the image processing observer to allow dispose and replace.
  45758. */
  45759. private _imageProcessingObserver;
  45760. /**
  45761. * Attaches a new image processing configuration to the PBR Material.
  45762. * @param configuration
  45763. */
  45764. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45765. /**
  45766. * Stores the available render targets.
  45767. */
  45768. private _renderTargets;
  45769. /**
  45770. * Sets the global ambient color for the material used in lighting calculations.
  45771. */
  45772. private _globalAmbientColor;
  45773. /**
  45774. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45775. */
  45776. private _useLogarithmicDepth;
  45777. /**
  45778. * If set to true, no lighting calculations will be applied.
  45779. */
  45780. private _unlit;
  45781. private _debugMode;
  45782. /**
  45783. * @hidden
  45784. * This is reserved for the inspector.
  45785. * Defines the material debug mode.
  45786. * It helps seeing only some components of the material while troubleshooting.
  45787. */
  45788. debugMode: number;
  45789. /**
  45790. * @hidden
  45791. * This is reserved for the inspector.
  45792. * Specify from where on screen the debug mode should start.
  45793. * The value goes from -1 (full screen) to 1 (not visible)
  45794. * It helps with side by side comparison against the final render
  45795. * This defaults to -1
  45796. */
  45797. private debugLimit;
  45798. /**
  45799. * @hidden
  45800. * This is reserved for the inspector.
  45801. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45802. * You can use the factor to better multiply the final value.
  45803. */
  45804. private debugFactor;
  45805. /**
  45806. * Defines the clear coat layer parameters for the material.
  45807. */
  45808. readonly clearCoat: PBRClearCoatConfiguration;
  45809. /**
  45810. * Defines the anisotropic parameters for the material.
  45811. */
  45812. readonly anisotropy: PBRAnisotropicConfiguration;
  45813. /**
  45814. * Defines the BRDF parameters for the material.
  45815. */
  45816. readonly brdf: PBRBRDFConfiguration;
  45817. /**
  45818. * Defines the Sheen parameters for the material.
  45819. */
  45820. readonly sheen: PBRSheenConfiguration;
  45821. /**
  45822. * Defines the SubSurface parameters for the material.
  45823. */
  45824. readonly subSurface: PBRSubSurfaceConfiguration;
  45825. /**
  45826. * Custom callback helping to override the default shader used in the material.
  45827. */
  45828. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  45829. /**
  45830. * Instantiates a new PBRMaterial instance.
  45831. *
  45832. * @param name The material name
  45833. * @param scene The scene the material will be use in.
  45834. */
  45835. constructor(name: string, scene: Scene);
  45836. /**
  45837. * Gets a boolean indicating that current material needs to register RTT
  45838. */
  45839. readonly hasRenderTargetTextures: boolean;
  45840. /**
  45841. * Gets the name of the material class.
  45842. */
  45843. getClassName(): string;
  45844. /**
  45845. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45846. */
  45847. /**
  45848. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45849. */
  45850. useLogarithmicDepth: boolean;
  45851. /**
  45852. * Gets the current transparency mode.
  45853. */
  45854. /**
  45855. * Sets the transparency mode of the material.
  45856. *
  45857. * | Value | Type | Description |
  45858. * | ----- | ----------------------------------- | ----------- |
  45859. * | 0 | OPAQUE | |
  45860. * | 1 | ALPHATEST | |
  45861. * | 2 | ALPHABLEND | |
  45862. * | 3 | ALPHATESTANDBLEND | |
  45863. *
  45864. */
  45865. transparencyMode: Nullable<number>;
  45866. /**
  45867. * Returns true if alpha blending should be disabled.
  45868. */
  45869. private readonly _disableAlphaBlending;
  45870. /**
  45871. * Specifies whether or not this material should be rendered in alpha blend mode.
  45872. */
  45873. needAlphaBlending(): boolean;
  45874. /**
  45875. * Specifies if the mesh will require alpha blending.
  45876. * @param mesh - BJS mesh.
  45877. */
  45878. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45879. /**
  45880. * Specifies whether or not this material should be rendered in alpha test mode.
  45881. */
  45882. needAlphaTesting(): boolean;
  45883. /**
  45884. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45885. */
  45886. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45887. /**
  45888. * Gets the texture used for the alpha test.
  45889. */
  45890. getAlphaTestTexture(): Nullable<BaseTexture>;
  45891. /**
  45892. * Specifies that the submesh is ready to be used.
  45893. * @param mesh - BJS mesh.
  45894. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45895. * @param useInstances - Specifies that instances should be used.
  45896. * @returns - boolean indicating that the submesh is ready or not.
  45897. */
  45898. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45899. /**
  45900. * Specifies if the material uses metallic roughness workflow.
  45901. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45902. */
  45903. isMetallicWorkflow(): boolean;
  45904. private _prepareEffect;
  45905. private _prepareDefines;
  45906. /**
  45907. * Force shader compilation
  45908. */
  45909. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45910. clipPlane: boolean;
  45911. }>): void;
  45912. /**
  45913. * Initializes the uniform buffer layout for the shader.
  45914. */
  45915. buildUniformLayout(): void;
  45916. /**
  45917. * Unbinds the material from the mesh
  45918. */
  45919. unbind(): void;
  45920. /**
  45921. * Binds the submesh data.
  45922. * @param world - The world matrix.
  45923. * @param mesh - The BJS mesh.
  45924. * @param subMesh - A submesh of the BJS mesh.
  45925. */
  45926. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45927. /**
  45928. * Returns the animatable textures.
  45929. * @returns - Array of animatable textures.
  45930. */
  45931. getAnimatables(): IAnimatable[];
  45932. /**
  45933. * Returns the texture used for reflections.
  45934. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45935. */
  45936. private _getReflectionTexture;
  45937. /**
  45938. * Returns an array of the actively used textures.
  45939. * @returns - Array of BaseTextures
  45940. */
  45941. getActiveTextures(): BaseTexture[];
  45942. /**
  45943. * Checks to see if a texture is used in the material.
  45944. * @param texture - Base texture to use.
  45945. * @returns - Boolean specifying if a texture is used in the material.
  45946. */
  45947. hasTexture(texture: BaseTexture): boolean;
  45948. /**
  45949. * Disposes the resources of the material.
  45950. * @param forceDisposeEffect - Forces the disposal of effects.
  45951. * @param forceDisposeTextures - Forces the disposal of all textures.
  45952. */
  45953. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45954. }
  45955. }
  45956. declare module BABYLON {
  45957. /**
  45958. * The Physically based material of BJS.
  45959. *
  45960. * This offers the main features of a standard PBR material.
  45961. * For more information, please refer to the documentation :
  45962. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45963. */
  45964. export class PBRMaterial extends PBRBaseMaterial {
  45965. /**
  45966. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45967. */
  45968. static readonly PBRMATERIAL_OPAQUE: number;
  45969. /**
  45970. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45971. */
  45972. static readonly PBRMATERIAL_ALPHATEST: number;
  45973. /**
  45974. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45975. */
  45976. static readonly PBRMATERIAL_ALPHABLEND: number;
  45977. /**
  45978. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45979. * They are also discarded below the alpha cutoff threshold to improve performances.
  45980. */
  45981. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45982. /**
  45983. * Defines the default value of how much AO map is occluding the analytical lights
  45984. * (point spot...).
  45985. */
  45986. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45987. /**
  45988. * Intensity of the direct lights e.g. the four lights available in your scene.
  45989. * This impacts both the direct diffuse and specular highlights.
  45990. */
  45991. directIntensity: number;
  45992. /**
  45993. * Intensity of the emissive part of the material.
  45994. * This helps controlling the emissive effect without modifying the emissive color.
  45995. */
  45996. emissiveIntensity: number;
  45997. /**
  45998. * Intensity of the environment e.g. how much the environment will light the object
  45999. * either through harmonics for rough material or through the refelction for shiny ones.
  46000. */
  46001. environmentIntensity: number;
  46002. /**
  46003. * This is a special control allowing the reduction of the specular highlights coming from the
  46004. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46005. */
  46006. specularIntensity: number;
  46007. /**
  46008. * Debug Control allowing disabling the bump map on this material.
  46009. */
  46010. disableBumpMap: boolean;
  46011. /**
  46012. * AKA Diffuse Texture in standard nomenclature.
  46013. */
  46014. albedoTexture: BaseTexture;
  46015. /**
  46016. * AKA Occlusion Texture in other nomenclature.
  46017. */
  46018. ambientTexture: BaseTexture;
  46019. /**
  46020. * AKA Occlusion Texture Intensity in other nomenclature.
  46021. */
  46022. ambientTextureStrength: number;
  46023. /**
  46024. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46025. * 1 means it completely occludes it
  46026. * 0 mean it has no impact
  46027. */
  46028. ambientTextureImpactOnAnalyticalLights: number;
  46029. /**
  46030. * Stores the alpha values in a texture.
  46031. */
  46032. opacityTexture: BaseTexture;
  46033. /**
  46034. * Stores the reflection values in a texture.
  46035. */
  46036. reflectionTexture: Nullable<BaseTexture>;
  46037. /**
  46038. * Stores the emissive values in a texture.
  46039. */
  46040. emissiveTexture: BaseTexture;
  46041. /**
  46042. * AKA Specular texture in other nomenclature.
  46043. */
  46044. reflectivityTexture: BaseTexture;
  46045. /**
  46046. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46047. */
  46048. metallicTexture: BaseTexture;
  46049. /**
  46050. * Specifies the metallic scalar of the metallic/roughness workflow.
  46051. * Can also be used to scale the metalness values of the metallic texture.
  46052. */
  46053. metallic: Nullable<number>;
  46054. /**
  46055. * Specifies the roughness scalar of the metallic/roughness workflow.
  46056. * Can also be used to scale the roughness values of the metallic texture.
  46057. */
  46058. roughness: Nullable<number>;
  46059. /**
  46060. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46061. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46062. */
  46063. microSurfaceTexture: BaseTexture;
  46064. /**
  46065. * Stores surface normal data used to displace a mesh in a texture.
  46066. */
  46067. bumpTexture: BaseTexture;
  46068. /**
  46069. * Stores the pre-calculated light information of a mesh in a texture.
  46070. */
  46071. lightmapTexture: BaseTexture;
  46072. /**
  46073. * Stores the refracted light information in a texture.
  46074. */
  46075. refractionTexture: Nullable<BaseTexture>;
  46076. /**
  46077. * The color of a material in ambient lighting.
  46078. */
  46079. ambientColor: Color3;
  46080. /**
  46081. * AKA Diffuse Color in other nomenclature.
  46082. */
  46083. albedoColor: Color3;
  46084. /**
  46085. * AKA Specular Color in other nomenclature.
  46086. */
  46087. reflectivityColor: Color3;
  46088. /**
  46089. * The color reflected from the material.
  46090. */
  46091. reflectionColor: Color3;
  46092. /**
  46093. * The color emitted from the material.
  46094. */
  46095. emissiveColor: Color3;
  46096. /**
  46097. * AKA Glossiness in other nomenclature.
  46098. */
  46099. microSurface: number;
  46100. /**
  46101. * source material index of refraction (IOR)' / 'destination material IOR.
  46102. */
  46103. indexOfRefraction: number;
  46104. /**
  46105. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46106. */
  46107. invertRefractionY: boolean;
  46108. /**
  46109. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46110. * Materials half opaque for instance using refraction could benefit from this control.
  46111. */
  46112. linkRefractionWithTransparency: boolean;
  46113. /**
  46114. * If true, the light map contains occlusion information instead of lighting info.
  46115. */
  46116. useLightmapAsShadowmap: boolean;
  46117. /**
  46118. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46119. */
  46120. useAlphaFromAlbedoTexture: boolean;
  46121. /**
  46122. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46123. */
  46124. forceAlphaTest: boolean;
  46125. /**
  46126. * Defines the alpha limits in alpha test mode.
  46127. */
  46128. alphaCutOff: number;
  46129. /**
  46130. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46131. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46132. */
  46133. useSpecularOverAlpha: boolean;
  46134. /**
  46135. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46136. */
  46137. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46138. /**
  46139. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46140. */
  46141. useRoughnessFromMetallicTextureAlpha: boolean;
  46142. /**
  46143. * Specifies if the metallic texture contains the roughness information in its green channel.
  46144. */
  46145. useRoughnessFromMetallicTextureGreen: boolean;
  46146. /**
  46147. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46148. */
  46149. useMetallnessFromMetallicTextureBlue: boolean;
  46150. /**
  46151. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46152. */
  46153. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46154. /**
  46155. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46156. */
  46157. useAmbientInGrayScale: boolean;
  46158. /**
  46159. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46160. * The material will try to infer what glossiness each pixel should be.
  46161. */
  46162. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46163. /**
  46164. * BJS is using an harcoded light falloff based on a manually sets up range.
  46165. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46166. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46167. */
  46168. /**
  46169. * BJS is using an harcoded light falloff based on a manually sets up range.
  46170. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46171. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46172. */
  46173. usePhysicalLightFalloff: boolean;
  46174. /**
  46175. * In order to support the falloff compatibility with gltf, a special mode has been added
  46176. * to reproduce the gltf light falloff.
  46177. */
  46178. /**
  46179. * In order to support the falloff compatibility with gltf, a special mode has been added
  46180. * to reproduce the gltf light falloff.
  46181. */
  46182. useGLTFLightFalloff: boolean;
  46183. /**
  46184. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46185. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46186. */
  46187. useRadianceOverAlpha: boolean;
  46188. /**
  46189. * Allows using an object space normal map (instead of tangent space).
  46190. */
  46191. useObjectSpaceNormalMap: boolean;
  46192. /**
  46193. * Allows using the bump map in parallax mode.
  46194. */
  46195. useParallax: boolean;
  46196. /**
  46197. * Allows using the bump map in parallax occlusion mode.
  46198. */
  46199. useParallaxOcclusion: boolean;
  46200. /**
  46201. * Controls the scale bias of the parallax mode.
  46202. */
  46203. parallaxScaleBias: number;
  46204. /**
  46205. * If sets to true, disables all the lights affecting the material.
  46206. */
  46207. disableLighting: boolean;
  46208. /**
  46209. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46210. */
  46211. forceIrradianceInFragment: boolean;
  46212. /**
  46213. * Number of Simultaneous lights allowed on the material.
  46214. */
  46215. maxSimultaneousLights: number;
  46216. /**
  46217. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46218. */
  46219. invertNormalMapX: boolean;
  46220. /**
  46221. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46222. */
  46223. invertNormalMapY: boolean;
  46224. /**
  46225. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46226. */
  46227. twoSidedLighting: boolean;
  46228. /**
  46229. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46230. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46231. */
  46232. useAlphaFresnel: boolean;
  46233. /**
  46234. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46235. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46236. */
  46237. useLinearAlphaFresnel: boolean;
  46238. /**
  46239. * Let user defines the brdf lookup texture used for IBL.
  46240. * A default 8bit version is embedded but you could point at :
  46241. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  46242. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46243. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46244. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46245. */
  46246. environmentBRDFTexture: Nullable<BaseTexture>;
  46247. /**
  46248. * Force normal to face away from face.
  46249. */
  46250. forceNormalForward: boolean;
  46251. /**
  46252. * Enables specular anti aliasing in the PBR shader.
  46253. * It will both interacts on the Geometry for analytical and IBL lighting.
  46254. * It also prefilter the roughness map based on the bump values.
  46255. */
  46256. enableSpecularAntiAliasing: boolean;
  46257. /**
  46258. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46259. * makes the reflect vector face the model (under horizon).
  46260. */
  46261. useHorizonOcclusion: boolean;
  46262. /**
  46263. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46264. * too much the area relying on ambient texture to define their ambient occlusion.
  46265. */
  46266. useRadianceOcclusion: boolean;
  46267. /**
  46268. * If set to true, no lighting calculations will be applied.
  46269. */
  46270. unlit: boolean;
  46271. /**
  46272. * Gets the image processing configuration used either in this material.
  46273. */
  46274. /**
  46275. * Sets the Default image processing configuration used either in the this material.
  46276. *
  46277. * If sets to null, the scene one is in use.
  46278. */
  46279. imageProcessingConfiguration: ImageProcessingConfiguration;
  46280. /**
  46281. * Gets wether the color curves effect is enabled.
  46282. */
  46283. /**
  46284. * Sets wether the color curves effect is enabled.
  46285. */
  46286. cameraColorCurvesEnabled: boolean;
  46287. /**
  46288. * Gets wether the color grading effect is enabled.
  46289. */
  46290. /**
  46291. * Gets wether the color grading effect is enabled.
  46292. */
  46293. cameraColorGradingEnabled: boolean;
  46294. /**
  46295. * Gets wether tonemapping is enabled or not.
  46296. */
  46297. /**
  46298. * Sets wether tonemapping is enabled or not
  46299. */
  46300. cameraToneMappingEnabled: boolean;
  46301. /**
  46302. * The camera exposure used on this material.
  46303. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46304. * This corresponds to a photographic exposure.
  46305. */
  46306. /**
  46307. * The camera exposure used on this material.
  46308. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46309. * This corresponds to a photographic exposure.
  46310. */
  46311. cameraExposure: number;
  46312. /**
  46313. * Gets The camera contrast used on this material.
  46314. */
  46315. /**
  46316. * Sets The camera contrast used on this material.
  46317. */
  46318. cameraContrast: number;
  46319. /**
  46320. * Gets the Color Grading 2D Lookup Texture.
  46321. */
  46322. /**
  46323. * Sets the Color Grading 2D Lookup Texture.
  46324. */
  46325. cameraColorGradingTexture: Nullable<BaseTexture>;
  46326. /**
  46327. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46328. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46329. * 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;
  46330. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46331. */
  46332. /**
  46333. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46334. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46335. * 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;
  46336. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46337. */
  46338. cameraColorCurves: Nullable<ColorCurves>;
  46339. /**
  46340. * Instantiates a new PBRMaterial instance.
  46341. *
  46342. * @param name The material name
  46343. * @param scene The scene the material will be use in.
  46344. */
  46345. constructor(name: string, scene: Scene);
  46346. /**
  46347. * Returns the name of this material class.
  46348. */
  46349. getClassName(): string;
  46350. /**
  46351. * Makes a duplicate of the current material.
  46352. * @param name - name to use for the new material.
  46353. */
  46354. clone(name: string): PBRMaterial;
  46355. /**
  46356. * Serializes this PBR Material.
  46357. * @returns - An object with the serialized material.
  46358. */
  46359. serialize(): any;
  46360. /**
  46361. * Parses a PBR Material from a serialized object.
  46362. * @param source - Serialized object.
  46363. * @param scene - BJS scene instance.
  46364. * @param rootUrl - url for the scene object
  46365. * @returns - PBRMaterial
  46366. */
  46367. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46368. }
  46369. }
  46370. declare module BABYLON {
  46371. /**
  46372. * Direct draw surface info
  46373. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46374. */
  46375. export interface DDSInfo {
  46376. /**
  46377. * Width of the texture
  46378. */
  46379. width: number;
  46380. /**
  46381. * Width of the texture
  46382. */
  46383. height: number;
  46384. /**
  46385. * Number of Mipmaps for the texture
  46386. * @see https://en.wikipedia.org/wiki/Mipmap
  46387. */
  46388. mipmapCount: number;
  46389. /**
  46390. * If the textures format is a known fourCC format
  46391. * @see https://www.fourcc.org/
  46392. */
  46393. isFourCC: boolean;
  46394. /**
  46395. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46396. */
  46397. isRGB: boolean;
  46398. /**
  46399. * If the texture is a lumincance format
  46400. */
  46401. isLuminance: boolean;
  46402. /**
  46403. * If this is a cube texture
  46404. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46405. */
  46406. isCube: boolean;
  46407. /**
  46408. * If the texture is a compressed format eg. FOURCC_DXT1
  46409. */
  46410. isCompressed: boolean;
  46411. /**
  46412. * The dxgiFormat of the texture
  46413. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46414. */
  46415. dxgiFormat: number;
  46416. /**
  46417. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46418. */
  46419. textureType: number;
  46420. /**
  46421. * Sphericle polynomial created for the dds texture
  46422. */
  46423. sphericalPolynomial?: SphericalPolynomial;
  46424. }
  46425. /**
  46426. * Class used to provide DDS decompression tools
  46427. */
  46428. export class DDSTools {
  46429. /**
  46430. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46431. */
  46432. static StoreLODInAlphaChannel: boolean;
  46433. /**
  46434. * Gets DDS information from an array buffer
  46435. * @param arrayBuffer defines the array buffer to read data from
  46436. * @returns the DDS information
  46437. */
  46438. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46439. private static _FloatView;
  46440. private static _Int32View;
  46441. private static _ToHalfFloat;
  46442. private static _FromHalfFloat;
  46443. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46444. private static _GetHalfFloatRGBAArrayBuffer;
  46445. private static _GetFloatRGBAArrayBuffer;
  46446. private static _GetFloatAsUIntRGBAArrayBuffer;
  46447. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46448. private static _GetRGBAArrayBuffer;
  46449. private static _ExtractLongWordOrder;
  46450. private static _GetRGBArrayBuffer;
  46451. private static _GetLuminanceArrayBuffer;
  46452. /**
  46453. * Uploads DDS Levels to a Babylon Texture
  46454. * @hidden
  46455. */
  46456. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46457. }
  46458. interface Engine {
  46459. /**
  46460. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46461. * @param rootUrl defines the url where the file to load is located
  46462. * @param scene defines the current scene
  46463. * @param lodScale defines scale to apply to the mip map selection
  46464. * @param lodOffset defines offset to apply to the mip map selection
  46465. * @param onLoad defines an optional callback raised when the texture is loaded
  46466. * @param onError defines an optional callback raised if there is an issue to load the texture
  46467. * @param format defines the format of the data
  46468. * @param forcedExtension defines the extension to use to pick the right loader
  46469. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46470. * @returns the cube texture as an InternalTexture
  46471. */
  46472. 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;
  46473. }
  46474. }
  46475. declare module BABYLON {
  46476. /**
  46477. * Implementation of the DDS Texture Loader.
  46478. * @hidden
  46479. */
  46480. export class _DDSTextureLoader implements IInternalTextureLoader {
  46481. /**
  46482. * Defines wether the loader supports cascade loading the different faces.
  46483. */
  46484. readonly supportCascades: boolean;
  46485. /**
  46486. * This returns if the loader support the current file information.
  46487. * @param extension defines the file extension of the file being loaded
  46488. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46489. * @param fallback defines the fallback internal texture if any
  46490. * @param isBase64 defines whether the texture is encoded as a base64
  46491. * @param isBuffer defines whether the texture data are stored as a buffer
  46492. * @returns true if the loader can load the specified file
  46493. */
  46494. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46495. /**
  46496. * Transform the url before loading if required.
  46497. * @param rootUrl the url of the texture
  46498. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46499. * @returns the transformed texture
  46500. */
  46501. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46502. /**
  46503. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46504. * @param rootUrl the url of the texture
  46505. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46506. * @returns the fallback texture
  46507. */
  46508. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46509. /**
  46510. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46511. * @param data contains the texture data
  46512. * @param texture defines the BabylonJS internal texture
  46513. * @param createPolynomials will be true if polynomials have been requested
  46514. * @param onLoad defines the callback to trigger once the texture is ready
  46515. * @param onError defines the callback to trigger in case of error
  46516. */
  46517. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46518. /**
  46519. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46520. * @param data contains the texture data
  46521. * @param texture defines the BabylonJS internal texture
  46522. * @param callback defines the method to call once ready to upload
  46523. */
  46524. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46525. }
  46526. }
  46527. declare module BABYLON {
  46528. /** @hidden */
  46529. export var rgbdEncodePixelShader: {
  46530. name: string;
  46531. shader: string;
  46532. };
  46533. }
  46534. declare module BABYLON {
  46535. /**
  46536. * Raw texture data and descriptor sufficient for WebGL texture upload
  46537. */
  46538. export interface EnvironmentTextureInfo {
  46539. /**
  46540. * Version of the environment map
  46541. */
  46542. version: number;
  46543. /**
  46544. * Width of image
  46545. */
  46546. width: number;
  46547. /**
  46548. * Irradiance information stored in the file.
  46549. */
  46550. irradiance: any;
  46551. /**
  46552. * Specular information stored in the file.
  46553. */
  46554. specular: any;
  46555. }
  46556. /**
  46557. * Sets of helpers addressing the serialization and deserialization of environment texture
  46558. * stored in a BabylonJS env file.
  46559. * Those files are usually stored as .env files.
  46560. */
  46561. export class EnvironmentTextureTools {
  46562. /**
  46563. * Magic number identifying the env file.
  46564. */
  46565. private static _MagicBytes;
  46566. /**
  46567. * Gets the environment info from an env file.
  46568. * @param data The array buffer containing the .env bytes.
  46569. * @returns the environment file info (the json header) if successfully parsed.
  46570. */
  46571. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46572. /**
  46573. * Creates an environment texture from a loaded cube texture.
  46574. * @param texture defines the cube texture to convert in env file
  46575. * @return a promise containing the environment data if succesfull.
  46576. */
  46577. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46578. /**
  46579. * Creates a JSON representation of the spherical data.
  46580. * @param texture defines the texture containing the polynomials
  46581. * @return the JSON representation of the spherical info
  46582. */
  46583. private static _CreateEnvTextureIrradiance;
  46584. /**
  46585. * Uploads the texture info contained in the env file to the GPU.
  46586. * @param texture defines the internal texture to upload to
  46587. * @param arrayBuffer defines the buffer cotaining the data to load
  46588. * @param info defines the texture info retrieved through the GetEnvInfo method
  46589. * @returns a promise
  46590. */
  46591. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46592. /**
  46593. * Uploads the levels of image data to the GPU.
  46594. * @param texture defines the internal texture to upload to
  46595. * @param imageData defines the array buffer views of image data [mipmap][face]
  46596. * @returns a promise
  46597. */
  46598. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46599. /**
  46600. * Uploads spherical polynomials information to the texture.
  46601. * @param texture defines the texture we are trying to upload the information to
  46602. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46603. */
  46604. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46605. /** @hidden */
  46606. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46607. }
  46608. }
  46609. declare module BABYLON {
  46610. /**
  46611. * Implementation of the ENV Texture Loader.
  46612. * @hidden
  46613. */
  46614. export class _ENVTextureLoader implements IInternalTextureLoader {
  46615. /**
  46616. * Defines wether the loader supports cascade loading the different faces.
  46617. */
  46618. readonly supportCascades: boolean;
  46619. /**
  46620. * This returns if the loader support the current file information.
  46621. * @param extension defines the file extension of the file being loaded
  46622. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46623. * @param fallback defines the fallback internal texture if any
  46624. * @param isBase64 defines whether the texture is encoded as a base64
  46625. * @param isBuffer defines whether the texture data are stored as a buffer
  46626. * @returns true if the loader can load the specified file
  46627. */
  46628. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46629. /**
  46630. * Transform the url before loading if required.
  46631. * @param rootUrl the url of the texture
  46632. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46633. * @returns the transformed texture
  46634. */
  46635. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46636. /**
  46637. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46638. * @param rootUrl the url of the texture
  46639. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46640. * @returns the fallback texture
  46641. */
  46642. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46643. /**
  46644. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46645. * @param data contains the texture data
  46646. * @param texture defines the BabylonJS internal texture
  46647. * @param createPolynomials will be true if polynomials have been requested
  46648. * @param onLoad defines the callback to trigger once the texture is ready
  46649. * @param onError defines the callback to trigger in case of error
  46650. */
  46651. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46652. /**
  46653. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46654. * @param data contains the texture data
  46655. * @param texture defines the BabylonJS internal texture
  46656. * @param callback defines the method to call once ready to upload
  46657. */
  46658. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46659. }
  46660. }
  46661. declare module BABYLON {
  46662. /**
  46663. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46664. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46665. */
  46666. export class KhronosTextureContainer {
  46667. /** contents of the KTX container file */
  46668. arrayBuffer: any;
  46669. private static HEADER_LEN;
  46670. private static COMPRESSED_2D;
  46671. private static COMPRESSED_3D;
  46672. private static TEX_2D;
  46673. private static TEX_3D;
  46674. /**
  46675. * Gets the openGL type
  46676. */
  46677. glType: number;
  46678. /**
  46679. * Gets the openGL type size
  46680. */
  46681. glTypeSize: number;
  46682. /**
  46683. * Gets the openGL format
  46684. */
  46685. glFormat: number;
  46686. /**
  46687. * Gets the openGL internal format
  46688. */
  46689. glInternalFormat: number;
  46690. /**
  46691. * Gets the base internal format
  46692. */
  46693. glBaseInternalFormat: number;
  46694. /**
  46695. * Gets image width in pixel
  46696. */
  46697. pixelWidth: number;
  46698. /**
  46699. * Gets image height in pixel
  46700. */
  46701. pixelHeight: number;
  46702. /**
  46703. * Gets image depth in pixels
  46704. */
  46705. pixelDepth: number;
  46706. /**
  46707. * Gets the number of array elements
  46708. */
  46709. numberOfArrayElements: number;
  46710. /**
  46711. * Gets the number of faces
  46712. */
  46713. numberOfFaces: number;
  46714. /**
  46715. * Gets the number of mipmap levels
  46716. */
  46717. numberOfMipmapLevels: number;
  46718. /**
  46719. * Gets the bytes of key value data
  46720. */
  46721. bytesOfKeyValueData: number;
  46722. /**
  46723. * Gets the load type
  46724. */
  46725. loadType: number;
  46726. /**
  46727. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46728. */
  46729. isInvalid: boolean;
  46730. /**
  46731. * Creates a new KhronosTextureContainer
  46732. * @param arrayBuffer contents of the KTX container file
  46733. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46734. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46735. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46736. */
  46737. constructor(
  46738. /** contents of the KTX container file */
  46739. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46740. /**
  46741. * Uploads KTX content to a Babylon Texture.
  46742. * It is assumed that the texture has already been created & is currently bound
  46743. * @hidden
  46744. */
  46745. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46746. private _upload2DCompressedLevels;
  46747. }
  46748. }
  46749. declare module BABYLON {
  46750. /**
  46751. * Implementation of the KTX Texture Loader.
  46752. * @hidden
  46753. */
  46754. export class _KTXTextureLoader implements IInternalTextureLoader {
  46755. /**
  46756. * Defines wether the loader supports cascade loading the different faces.
  46757. */
  46758. readonly supportCascades: boolean;
  46759. /**
  46760. * This returns if the loader support the current file information.
  46761. * @param extension defines the file extension of the file being loaded
  46762. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46763. * @param fallback defines the fallback internal texture if any
  46764. * @param isBase64 defines whether the texture is encoded as a base64
  46765. * @param isBuffer defines whether the texture data are stored as a buffer
  46766. * @returns true if the loader can load the specified file
  46767. */
  46768. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46769. /**
  46770. * Transform the url before loading if required.
  46771. * @param rootUrl the url of the texture
  46772. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46773. * @returns the transformed texture
  46774. */
  46775. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46776. /**
  46777. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46778. * @param rootUrl the url of the texture
  46779. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46780. * @returns the fallback texture
  46781. */
  46782. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46783. /**
  46784. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46785. * @param data contains the texture data
  46786. * @param texture defines the BabylonJS internal texture
  46787. * @param createPolynomials will be true if polynomials have been requested
  46788. * @param onLoad defines the callback to trigger once the texture is ready
  46789. * @param onError defines the callback to trigger in case of error
  46790. */
  46791. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46792. /**
  46793. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46794. * @param data contains the texture data
  46795. * @param texture defines the BabylonJS internal texture
  46796. * @param callback defines the method to call once ready to upload
  46797. */
  46798. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46799. }
  46800. }
  46801. declare module BABYLON {
  46802. /** @hidden */
  46803. export var _forceSceneHelpersToBundle: boolean;
  46804. interface Scene {
  46805. /**
  46806. * Creates a default light for the scene.
  46807. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46808. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46809. */
  46810. createDefaultLight(replace?: boolean): void;
  46811. /**
  46812. * Creates a default camera for the scene.
  46813. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46814. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46815. * @param replace has default false, when true replaces the active camera in the scene
  46816. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46817. */
  46818. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46819. /**
  46820. * Creates a default camera and a default light.
  46821. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46822. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46823. * @param replace has the default false, when true replaces the active camera/light in the scene
  46824. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46825. */
  46826. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46827. /**
  46828. * Creates a new sky box
  46829. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46830. * @param environmentTexture defines the texture to use as environment texture
  46831. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46832. * @param scale defines the overall scale of the skybox
  46833. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46834. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46835. * @returns a new mesh holding the sky box
  46836. */
  46837. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46838. /**
  46839. * Creates a new environment
  46840. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46841. * @param options defines the options you can use to configure the environment
  46842. * @returns the new EnvironmentHelper
  46843. */
  46844. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46845. /**
  46846. * Creates a new VREXperienceHelper
  46847. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46848. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46849. * @returns a new VREXperienceHelper
  46850. */
  46851. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46852. /**
  46853. * Creates a new XREXperienceHelper
  46854. * @see http://doc.babylonjs.com/how_to/webxr
  46855. * @returns a promise for a new XREXperienceHelper
  46856. */
  46857. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46858. }
  46859. }
  46860. declare module BABYLON {
  46861. /**
  46862. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46863. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46864. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46865. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46866. */
  46867. export class VideoDome extends TransformNode {
  46868. /**
  46869. * Define the video source as a Monoscopic panoramic 360 video.
  46870. */
  46871. static readonly MODE_MONOSCOPIC: number;
  46872. /**
  46873. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46874. */
  46875. static readonly MODE_TOPBOTTOM: number;
  46876. /**
  46877. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46878. */
  46879. static readonly MODE_SIDEBYSIDE: number;
  46880. private _useDirectMapping;
  46881. /**
  46882. * The video texture being displayed on the sphere
  46883. */
  46884. protected _videoTexture: VideoTexture;
  46885. /**
  46886. * Gets the video texture being displayed on the sphere
  46887. */
  46888. readonly videoTexture: VideoTexture;
  46889. /**
  46890. * The skybox material
  46891. */
  46892. protected _material: BackgroundMaterial;
  46893. /**
  46894. * The surface used for the skybox
  46895. */
  46896. protected _mesh: Mesh;
  46897. /**
  46898. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46899. * Also see the options.resolution property.
  46900. */
  46901. fovMultiplier: number;
  46902. private _videoMode;
  46903. /**
  46904. * Gets or set the current video mode for the video. It can be:
  46905. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46906. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46907. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46908. */
  46909. videoMode: number;
  46910. /**
  46911. * Oberserver used in Stereoscopic VR Mode.
  46912. */
  46913. private _onBeforeCameraRenderObserver;
  46914. /**
  46915. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46916. * @param name Element's name, child elements will append suffixes for their own names.
  46917. * @param urlsOrVideo defines the url(s) or the video element to use
  46918. * @param options An object containing optional or exposed sub element properties
  46919. */
  46920. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46921. resolution?: number;
  46922. clickToPlay?: boolean;
  46923. autoPlay?: boolean;
  46924. loop?: boolean;
  46925. size?: number;
  46926. poster?: string;
  46927. faceForward?: boolean;
  46928. useDirectMapping?: boolean;
  46929. }, scene: Scene);
  46930. private _changeVideoMode;
  46931. /**
  46932. * Releases resources associated with this node.
  46933. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46934. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46935. */
  46936. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46937. }
  46938. }
  46939. declare module BABYLON {
  46940. /**
  46941. * This class can be used to get instrumentation data from a Babylon engine
  46942. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46943. */
  46944. export class EngineInstrumentation implements IDisposable {
  46945. /**
  46946. * Define the instrumented engine.
  46947. */
  46948. engine: Engine;
  46949. private _captureGPUFrameTime;
  46950. private _gpuFrameTimeToken;
  46951. private _gpuFrameTime;
  46952. private _captureShaderCompilationTime;
  46953. private _shaderCompilationTime;
  46954. private _onBeginFrameObserver;
  46955. private _onEndFrameObserver;
  46956. private _onBeforeShaderCompilationObserver;
  46957. private _onAfterShaderCompilationObserver;
  46958. /**
  46959. * Gets the perf counter used for GPU frame time
  46960. */
  46961. readonly gpuFrameTimeCounter: PerfCounter;
  46962. /**
  46963. * Gets the GPU frame time capture status
  46964. */
  46965. /**
  46966. * Enable or disable the GPU frame time capture
  46967. */
  46968. captureGPUFrameTime: boolean;
  46969. /**
  46970. * Gets the perf counter used for shader compilation time
  46971. */
  46972. readonly shaderCompilationTimeCounter: PerfCounter;
  46973. /**
  46974. * Gets the shader compilation time capture status
  46975. */
  46976. /**
  46977. * Enable or disable the shader compilation time capture
  46978. */
  46979. captureShaderCompilationTime: boolean;
  46980. /**
  46981. * Instantiates a new engine instrumentation.
  46982. * This class can be used to get instrumentation data from a Babylon engine
  46983. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46984. * @param engine Defines the engine to instrument
  46985. */
  46986. constructor(
  46987. /**
  46988. * Define the instrumented engine.
  46989. */
  46990. engine: Engine);
  46991. /**
  46992. * Dispose and release associated resources.
  46993. */
  46994. dispose(): void;
  46995. }
  46996. }
  46997. declare module BABYLON {
  46998. /**
  46999. * This class can be used to get instrumentation data from a Babylon engine
  47000. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47001. */
  47002. export class SceneInstrumentation implements IDisposable {
  47003. /**
  47004. * Defines the scene to instrument
  47005. */
  47006. scene: Scene;
  47007. private _captureActiveMeshesEvaluationTime;
  47008. private _activeMeshesEvaluationTime;
  47009. private _captureRenderTargetsRenderTime;
  47010. private _renderTargetsRenderTime;
  47011. private _captureFrameTime;
  47012. private _frameTime;
  47013. private _captureRenderTime;
  47014. private _renderTime;
  47015. private _captureInterFrameTime;
  47016. private _interFrameTime;
  47017. private _captureParticlesRenderTime;
  47018. private _particlesRenderTime;
  47019. private _captureSpritesRenderTime;
  47020. private _spritesRenderTime;
  47021. private _capturePhysicsTime;
  47022. private _physicsTime;
  47023. private _captureAnimationsTime;
  47024. private _animationsTime;
  47025. private _captureCameraRenderTime;
  47026. private _cameraRenderTime;
  47027. private _onBeforeActiveMeshesEvaluationObserver;
  47028. private _onAfterActiveMeshesEvaluationObserver;
  47029. private _onBeforeRenderTargetsRenderObserver;
  47030. private _onAfterRenderTargetsRenderObserver;
  47031. private _onAfterRenderObserver;
  47032. private _onBeforeDrawPhaseObserver;
  47033. private _onAfterDrawPhaseObserver;
  47034. private _onBeforeAnimationsObserver;
  47035. private _onBeforeParticlesRenderingObserver;
  47036. private _onAfterParticlesRenderingObserver;
  47037. private _onBeforeSpritesRenderingObserver;
  47038. private _onAfterSpritesRenderingObserver;
  47039. private _onBeforePhysicsObserver;
  47040. private _onAfterPhysicsObserver;
  47041. private _onAfterAnimationsObserver;
  47042. private _onBeforeCameraRenderObserver;
  47043. private _onAfterCameraRenderObserver;
  47044. /**
  47045. * Gets the perf counter used for active meshes evaluation time
  47046. */
  47047. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47048. /**
  47049. * Gets the active meshes evaluation time capture status
  47050. */
  47051. /**
  47052. * Enable or disable the active meshes evaluation time capture
  47053. */
  47054. captureActiveMeshesEvaluationTime: boolean;
  47055. /**
  47056. * Gets the perf counter used for render targets render time
  47057. */
  47058. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47059. /**
  47060. * Gets the render targets render time capture status
  47061. */
  47062. /**
  47063. * Enable or disable the render targets render time capture
  47064. */
  47065. captureRenderTargetsRenderTime: boolean;
  47066. /**
  47067. * Gets the perf counter used for particles render time
  47068. */
  47069. readonly particlesRenderTimeCounter: PerfCounter;
  47070. /**
  47071. * Gets the particles render time capture status
  47072. */
  47073. /**
  47074. * Enable or disable the particles render time capture
  47075. */
  47076. captureParticlesRenderTime: boolean;
  47077. /**
  47078. * Gets the perf counter used for sprites render time
  47079. */
  47080. readonly spritesRenderTimeCounter: PerfCounter;
  47081. /**
  47082. * Gets the sprites render time capture status
  47083. */
  47084. /**
  47085. * Enable or disable the sprites render time capture
  47086. */
  47087. captureSpritesRenderTime: boolean;
  47088. /**
  47089. * Gets the perf counter used for physics time
  47090. */
  47091. readonly physicsTimeCounter: PerfCounter;
  47092. /**
  47093. * Gets the physics time capture status
  47094. */
  47095. /**
  47096. * Enable or disable the physics time capture
  47097. */
  47098. capturePhysicsTime: boolean;
  47099. /**
  47100. * Gets the perf counter used for animations time
  47101. */
  47102. readonly animationsTimeCounter: PerfCounter;
  47103. /**
  47104. * Gets the animations time capture status
  47105. */
  47106. /**
  47107. * Enable or disable the animations time capture
  47108. */
  47109. captureAnimationsTime: boolean;
  47110. /**
  47111. * Gets the perf counter used for frame time capture
  47112. */
  47113. readonly frameTimeCounter: PerfCounter;
  47114. /**
  47115. * Gets the frame time capture status
  47116. */
  47117. /**
  47118. * Enable or disable the frame time capture
  47119. */
  47120. captureFrameTime: boolean;
  47121. /**
  47122. * Gets the perf counter used for inter-frames time capture
  47123. */
  47124. readonly interFrameTimeCounter: PerfCounter;
  47125. /**
  47126. * Gets the inter-frames time capture status
  47127. */
  47128. /**
  47129. * Enable or disable the inter-frames time capture
  47130. */
  47131. captureInterFrameTime: boolean;
  47132. /**
  47133. * Gets the perf counter used for render time capture
  47134. */
  47135. readonly renderTimeCounter: PerfCounter;
  47136. /**
  47137. * Gets the render time capture status
  47138. */
  47139. /**
  47140. * Enable or disable the render time capture
  47141. */
  47142. captureRenderTime: boolean;
  47143. /**
  47144. * Gets the perf counter used for camera render time capture
  47145. */
  47146. readonly cameraRenderTimeCounter: PerfCounter;
  47147. /**
  47148. * Gets the camera render time capture status
  47149. */
  47150. /**
  47151. * Enable or disable the camera render time capture
  47152. */
  47153. captureCameraRenderTime: boolean;
  47154. /**
  47155. * Gets the perf counter used for draw calls
  47156. */
  47157. readonly drawCallsCounter: PerfCounter;
  47158. /**
  47159. * Instantiates a new scene instrumentation.
  47160. * This class can be used to get instrumentation data from a Babylon engine
  47161. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47162. * @param scene Defines the scene to instrument
  47163. */
  47164. constructor(
  47165. /**
  47166. * Defines the scene to instrument
  47167. */
  47168. scene: Scene);
  47169. /**
  47170. * Dispose and release associated resources.
  47171. */
  47172. dispose(): void;
  47173. }
  47174. }
  47175. declare module BABYLON {
  47176. /** @hidden */
  47177. export var glowMapGenerationPixelShader: {
  47178. name: string;
  47179. shader: string;
  47180. };
  47181. }
  47182. declare module BABYLON {
  47183. /** @hidden */
  47184. export var glowMapGenerationVertexShader: {
  47185. name: string;
  47186. shader: string;
  47187. };
  47188. }
  47189. declare module BABYLON {
  47190. /**
  47191. * Effect layer options. This helps customizing the behaviour
  47192. * of the effect layer.
  47193. */
  47194. export interface IEffectLayerOptions {
  47195. /**
  47196. * Multiplication factor apply to the canvas size to compute the render target size
  47197. * used to generated the objects (the smaller the faster).
  47198. */
  47199. mainTextureRatio: number;
  47200. /**
  47201. * Enforces a fixed size texture to ensure effect stability across devices.
  47202. */
  47203. mainTextureFixedSize?: number;
  47204. /**
  47205. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47206. */
  47207. alphaBlendingMode: number;
  47208. /**
  47209. * The camera attached to the layer.
  47210. */
  47211. camera: Nullable<Camera>;
  47212. /**
  47213. * The rendering group to draw the layer in.
  47214. */
  47215. renderingGroupId: number;
  47216. }
  47217. /**
  47218. * The effect layer Helps adding post process effect blended with the main pass.
  47219. *
  47220. * This can be for instance use to generate glow or higlight effects on the scene.
  47221. *
  47222. * The effect layer class can not be used directly and is intented to inherited from to be
  47223. * customized per effects.
  47224. */
  47225. export abstract class EffectLayer {
  47226. private _vertexBuffers;
  47227. private _indexBuffer;
  47228. private _cachedDefines;
  47229. private _effectLayerMapGenerationEffect;
  47230. private _effectLayerOptions;
  47231. private _mergeEffect;
  47232. protected _scene: Scene;
  47233. protected _engine: Engine;
  47234. protected _maxSize: number;
  47235. protected _mainTextureDesiredSize: ISize;
  47236. protected _mainTexture: RenderTargetTexture;
  47237. protected _shouldRender: boolean;
  47238. protected _postProcesses: PostProcess[];
  47239. protected _textures: BaseTexture[];
  47240. protected _emissiveTextureAndColor: {
  47241. texture: Nullable<BaseTexture>;
  47242. color: Color4;
  47243. };
  47244. /**
  47245. * The name of the layer
  47246. */
  47247. name: string;
  47248. /**
  47249. * The clear color of the texture used to generate the glow map.
  47250. */
  47251. neutralColor: Color4;
  47252. /**
  47253. * Specifies wether the highlight layer is enabled or not.
  47254. */
  47255. isEnabled: boolean;
  47256. /**
  47257. * Gets the camera attached to the layer.
  47258. */
  47259. readonly camera: Nullable<Camera>;
  47260. /**
  47261. * Gets the rendering group id the layer should render in.
  47262. */
  47263. readonly renderingGroupId: number;
  47264. /**
  47265. * An event triggered when the effect layer has been disposed.
  47266. */
  47267. onDisposeObservable: Observable<EffectLayer>;
  47268. /**
  47269. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47270. */
  47271. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47272. /**
  47273. * An event triggered when the generated texture is being merged in the scene.
  47274. */
  47275. onBeforeComposeObservable: Observable<EffectLayer>;
  47276. /**
  47277. * An event triggered when the generated texture has been merged in the scene.
  47278. */
  47279. onAfterComposeObservable: Observable<EffectLayer>;
  47280. /**
  47281. * An event triggered when the efffect layer changes its size.
  47282. */
  47283. onSizeChangedObservable: Observable<EffectLayer>;
  47284. /** @hidden */
  47285. static _SceneComponentInitialization: (scene: Scene) => void;
  47286. /**
  47287. * Instantiates a new effect Layer and references it in the scene.
  47288. * @param name The name of the layer
  47289. * @param scene The scene to use the layer in
  47290. */
  47291. constructor(
  47292. /** The Friendly of the effect in the scene */
  47293. name: string, scene: Scene);
  47294. /**
  47295. * Get the effect name of the layer.
  47296. * @return The effect name
  47297. */
  47298. abstract getEffectName(): string;
  47299. /**
  47300. * Checks for the readiness of the element composing the layer.
  47301. * @param subMesh the mesh to check for
  47302. * @param useInstances specify wether or not to use instances to render the mesh
  47303. * @return true if ready otherwise, false
  47304. */
  47305. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47306. /**
  47307. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47308. * @returns true if the effect requires stencil during the main canvas render pass.
  47309. */
  47310. abstract needStencil(): boolean;
  47311. /**
  47312. * Create the merge effect. This is the shader use to blit the information back
  47313. * to the main canvas at the end of the scene rendering.
  47314. * @returns The effect containing the shader used to merge the effect on the main canvas
  47315. */
  47316. protected abstract _createMergeEffect(): Effect;
  47317. /**
  47318. * Creates the render target textures and post processes used in the effect layer.
  47319. */
  47320. protected abstract _createTextureAndPostProcesses(): void;
  47321. /**
  47322. * Implementation specific of rendering the generating effect on the main canvas.
  47323. * @param effect The effect used to render through
  47324. */
  47325. protected abstract _internalRender(effect: Effect): void;
  47326. /**
  47327. * Sets the required values for both the emissive texture and and the main color.
  47328. */
  47329. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47330. /**
  47331. * Free any resources and references associated to a mesh.
  47332. * Internal use
  47333. * @param mesh The mesh to free.
  47334. */
  47335. abstract _disposeMesh(mesh: Mesh): void;
  47336. /**
  47337. * Serializes this layer (Glow or Highlight for example)
  47338. * @returns a serialized layer object
  47339. */
  47340. abstract serialize?(): any;
  47341. /**
  47342. * Initializes the effect layer with the required options.
  47343. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47344. */
  47345. protected _init(options: Partial<IEffectLayerOptions>): void;
  47346. /**
  47347. * Generates the index buffer of the full screen quad blending to the main canvas.
  47348. */
  47349. private _generateIndexBuffer;
  47350. /**
  47351. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47352. */
  47353. private _generateVertexBuffer;
  47354. /**
  47355. * Sets the main texture desired size which is the closest power of two
  47356. * of the engine canvas size.
  47357. */
  47358. private _setMainTextureSize;
  47359. /**
  47360. * Creates the main texture for the effect layer.
  47361. */
  47362. protected _createMainTexture(): void;
  47363. /**
  47364. * Adds specific effects defines.
  47365. * @param defines The defines to add specifics to.
  47366. */
  47367. protected _addCustomEffectDefines(defines: string[]): void;
  47368. /**
  47369. * Checks for the readiness of the element composing the layer.
  47370. * @param subMesh the mesh to check for
  47371. * @param useInstances specify wether or not to use instances to render the mesh
  47372. * @param emissiveTexture the associated emissive texture used to generate the glow
  47373. * @return true if ready otherwise, false
  47374. */
  47375. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47376. /**
  47377. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47378. */
  47379. render(): void;
  47380. /**
  47381. * Determine if a given mesh will be used in the current effect.
  47382. * @param mesh mesh to test
  47383. * @returns true if the mesh will be used
  47384. */
  47385. hasMesh(mesh: AbstractMesh): boolean;
  47386. /**
  47387. * Returns true if the layer contains information to display, otherwise false.
  47388. * @returns true if the glow layer should be rendered
  47389. */
  47390. shouldRender(): boolean;
  47391. /**
  47392. * Returns true if the mesh should render, otherwise false.
  47393. * @param mesh The mesh to render
  47394. * @returns true if it should render otherwise false
  47395. */
  47396. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47397. /**
  47398. * Returns true if the mesh can be rendered, otherwise false.
  47399. * @param mesh The mesh to render
  47400. * @param material The material used on the mesh
  47401. * @returns true if it can be rendered otherwise false
  47402. */
  47403. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47404. /**
  47405. * Returns true if the mesh should render, otherwise false.
  47406. * @param mesh The mesh to render
  47407. * @returns true if it should render otherwise false
  47408. */
  47409. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47410. /**
  47411. * Renders the submesh passed in parameter to the generation map.
  47412. */
  47413. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47414. /**
  47415. * Rebuild the required buffers.
  47416. * @hidden Internal use only.
  47417. */
  47418. _rebuild(): void;
  47419. /**
  47420. * Dispose only the render target textures and post process.
  47421. */
  47422. private _disposeTextureAndPostProcesses;
  47423. /**
  47424. * Dispose the highlight layer and free resources.
  47425. */
  47426. dispose(): void;
  47427. /**
  47428. * Gets the class name of the effect layer
  47429. * @returns the string with the class name of the effect layer
  47430. */
  47431. getClassName(): string;
  47432. /**
  47433. * Creates an effect layer from parsed effect layer data
  47434. * @param parsedEffectLayer defines effect layer data
  47435. * @param scene defines the current scene
  47436. * @param rootUrl defines the root URL containing the effect layer information
  47437. * @returns a parsed effect Layer
  47438. */
  47439. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47440. }
  47441. }
  47442. declare module BABYLON {
  47443. interface AbstractScene {
  47444. /**
  47445. * The list of effect layers (highlights/glow) added to the scene
  47446. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47447. * @see http://doc.babylonjs.com/how_to/glow_layer
  47448. */
  47449. effectLayers: Array<EffectLayer>;
  47450. /**
  47451. * Removes the given effect layer from this scene.
  47452. * @param toRemove defines the effect layer to remove
  47453. * @returns the index of the removed effect layer
  47454. */
  47455. removeEffectLayer(toRemove: EffectLayer): number;
  47456. /**
  47457. * Adds the given effect layer to this scene
  47458. * @param newEffectLayer defines the effect layer to add
  47459. */
  47460. addEffectLayer(newEffectLayer: EffectLayer): void;
  47461. }
  47462. /**
  47463. * Defines the layer scene component responsible to manage any effect layers
  47464. * in a given scene.
  47465. */
  47466. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47467. /**
  47468. * The component name helpfull to identify the component in the list of scene components.
  47469. */
  47470. readonly name: string;
  47471. /**
  47472. * The scene the component belongs to.
  47473. */
  47474. scene: Scene;
  47475. private _engine;
  47476. private _renderEffects;
  47477. private _needStencil;
  47478. private _previousStencilState;
  47479. /**
  47480. * Creates a new instance of the component for the given scene
  47481. * @param scene Defines the scene to register the component in
  47482. */
  47483. constructor(scene: Scene);
  47484. /**
  47485. * Registers the component in a given scene
  47486. */
  47487. register(): void;
  47488. /**
  47489. * Rebuilds the elements related to this component in case of
  47490. * context lost for instance.
  47491. */
  47492. rebuild(): void;
  47493. /**
  47494. * Serializes the component data to the specified json object
  47495. * @param serializationObject The object to serialize to
  47496. */
  47497. serialize(serializationObject: any): void;
  47498. /**
  47499. * Adds all the elements from the container to the scene
  47500. * @param container the container holding the elements
  47501. */
  47502. addFromContainer(container: AbstractScene): void;
  47503. /**
  47504. * Removes all the elements in the container from the scene
  47505. * @param container contains the elements to remove
  47506. * @param dispose if the removed element should be disposed (default: false)
  47507. */
  47508. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47509. /**
  47510. * Disposes the component and the associated ressources.
  47511. */
  47512. dispose(): void;
  47513. private _isReadyForMesh;
  47514. private _renderMainTexture;
  47515. private _setStencil;
  47516. private _setStencilBack;
  47517. private _draw;
  47518. private _drawCamera;
  47519. private _drawRenderingGroup;
  47520. }
  47521. }
  47522. declare module BABYLON {
  47523. /** @hidden */
  47524. export var glowMapMergePixelShader: {
  47525. name: string;
  47526. shader: string;
  47527. };
  47528. }
  47529. declare module BABYLON {
  47530. /** @hidden */
  47531. export var glowMapMergeVertexShader: {
  47532. name: string;
  47533. shader: string;
  47534. };
  47535. }
  47536. declare module BABYLON {
  47537. interface AbstractScene {
  47538. /**
  47539. * Return a the first highlight layer of the scene with a given name.
  47540. * @param name The name of the highlight layer to look for.
  47541. * @return The highlight layer if found otherwise null.
  47542. */
  47543. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47544. }
  47545. /**
  47546. * Glow layer options. This helps customizing the behaviour
  47547. * of the glow layer.
  47548. */
  47549. export interface IGlowLayerOptions {
  47550. /**
  47551. * Multiplication factor apply to the canvas size to compute the render target size
  47552. * used to generated the glowing objects (the smaller the faster).
  47553. */
  47554. mainTextureRatio: number;
  47555. /**
  47556. * Enforces a fixed size texture to ensure resize independant blur.
  47557. */
  47558. mainTextureFixedSize?: number;
  47559. /**
  47560. * How big is the kernel of the blur texture.
  47561. */
  47562. blurKernelSize: number;
  47563. /**
  47564. * The camera attached to the layer.
  47565. */
  47566. camera: Nullable<Camera>;
  47567. /**
  47568. * Enable MSAA by chosing the number of samples.
  47569. */
  47570. mainTextureSamples?: number;
  47571. /**
  47572. * The rendering group to draw the layer in.
  47573. */
  47574. renderingGroupId: number;
  47575. }
  47576. /**
  47577. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47578. *
  47579. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47580. * glowy meshes to your scene.
  47581. *
  47582. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47583. */
  47584. export class GlowLayer extends EffectLayer {
  47585. /**
  47586. * Effect Name of the layer.
  47587. */
  47588. static readonly EffectName: string;
  47589. /**
  47590. * The default blur kernel size used for the glow.
  47591. */
  47592. static DefaultBlurKernelSize: number;
  47593. /**
  47594. * The default texture size ratio used for the glow.
  47595. */
  47596. static DefaultTextureRatio: number;
  47597. /**
  47598. * Sets the kernel size of the blur.
  47599. */
  47600. /**
  47601. * Gets the kernel size of the blur.
  47602. */
  47603. blurKernelSize: number;
  47604. /**
  47605. * Sets the glow intensity.
  47606. */
  47607. /**
  47608. * Gets the glow intensity.
  47609. */
  47610. intensity: number;
  47611. private _options;
  47612. private _intensity;
  47613. private _horizontalBlurPostprocess1;
  47614. private _verticalBlurPostprocess1;
  47615. private _horizontalBlurPostprocess2;
  47616. private _verticalBlurPostprocess2;
  47617. private _blurTexture1;
  47618. private _blurTexture2;
  47619. private _postProcesses1;
  47620. private _postProcesses2;
  47621. private _includedOnlyMeshes;
  47622. private _excludedMeshes;
  47623. /**
  47624. * Callback used to let the user override the color selection on a per mesh basis
  47625. */
  47626. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47627. /**
  47628. * Callback used to let the user override the texture selection on a per mesh basis
  47629. */
  47630. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47631. /**
  47632. * Instantiates a new glow Layer and references it to the scene.
  47633. * @param name The name of the layer
  47634. * @param scene The scene to use the layer in
  47635. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47636. */
  47637. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47638. /**
  47639. * Get the effect name of the layer.
  47640. * @return The effect name
  47641. */
  47642. getEffectName(): string;
  47643. /**
  47644. * Create the merge effect. This is the shader use to blit the information back
  47645. * to the main canvas at the end of the scene rendering.
  47646. */
  47647. protected _createMergeEffect(): Effect;
  47648. /**
  47649. * Creates the render target textures and post processes used in the glow layer.
  47650. */
  47651. protected _createTextureAndPostProcesses(): void;
  47652. /**
  47653. * Checks for the readiness of the element composing the layer.
  47654. * @param subMesh the mesh to check for
  47655. * @param useInstances specify wether or not to use instances to render the mesh
  47656. * @param emissiveTexture the associated emissive texture used to generate the glow
  47657. * @return true if ready otherwise, false
  47658. */
  47659. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47660. /**
  47661. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47662. */
  47663. needStencil(): boolean;
  47664. /**
  47665. * Returns true if the mesh can be rendered, otherwise false.
  47666. * @param mesh The mesh to render
  47667. * @param material The material used on the mesh
  47668. * @returns true if it can be rendered otherwise false
  47669. */
  47670. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47671. /**
  47672. * Implementation specific of rendering the generating effect on the main canvas.
  47673. * @param effect The effect used to render through
  47674. */
  47675. protected _internalRender(effect: Effect): void;
  47676. /**
  47677. * Sets the required values for both the emissive texture and and the main color.
  47678. */
  47679. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47680. /**
  47681. * Returns true if the mesh should render, otherwise false.
  47682. * @param mesh The mesh to render
  47683. * @returns true if it should render otherwise false
  47684. */
  47685. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47686. /**
  47687. * Adds specific effects defines.
  47688. * @param defines The defines to add specifics to.
  47689. */
  47690. protected _addCustomEffectDefines(defines: string[]): void;
  47691. /**
  47692. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47693. * @param mesh The mesh to exclude from the glow layer
  47694. */
  47695. addExcludedMesh(mesh: Mesh): void;
  47696. /**
  47697. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47698. * @param mesh The mesh to remove
  47699. */
  47700. removeExcludedMesh(mesh: Mesh): void;
  47701. /**
  47702. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47703. * @param mesh The mesh to include in the glow layer
  47704. */
  47705. addIncludedOnlyMesh(mesh: Mesh): void;
  47706. /**
  47707. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47708. * @param mesh The mesh to remove
  47709. */
  47710. removeIncludedOnlyMesh(mesh: Mesh): void;
  47711. /**
  47712. * Determine if a given mesh will be used in the glow layer
  47713. * @param mesh The mesh to test
  47714. * @returns true if the mesh will be highlighted by the current glow layer
  47715. */
  47716. hasMesh(mesh: AbstractMesh): boolean;
  47717. /**
  47718. * Free any resources and references associated to a mesh.
  47719. * Internal use
  47720. * @param mesh The mesh to free.
  47721. * @hidden
  47722. */
  47723. _disposeMesh(mesh: Mesh): void;
  47724. /**
  47725. * Gets the class name of the effect layer
  47726. * @returns the string with the class name of the effect layer
  47727. */
  47728. getClassName(): string;
  47729. /**
  47730. * Serializes this glow layer
  47731. * @returns a serialized glow layer object
  47732. */
  47733. serialize(): any;
  47734. /**
  47735. * Creates a Glow Layer from parsed glow layer data
  47736. * @param parsedGlowLayer defines glow layer data
  47737. * @param scene defines the current scene
  47738. * @param rootUrl defines the root URL containing the glow layer information
  47739. * @returns a parsed Glow Layer
  47740. */
  47741. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47742. }
  47743. }
  47744. declare module BABYLON {
  47745. /** @hidden */
  47746. export var glowBlurPostProcessPixelShader: {
  47747. name: string;
  47748. shader: string;
  47749. };
  47750. }
  47751. declare module BABYLON {
  47752. interface AbstractScene {
  47753. /**
  47754. * Return a the first highlight layer of the scene with a given name.
  47755. * @param name The name of the highlight layer to look for.
  47756. * @return The highlight layer if found otherwise null.
  47757. */
  47758. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47759. }
  47760. /**
  47761. * Highlight layer options. This helps customizing the behaviour
  47762. * of the highlight layer.
  47763. */
  47764. export interface IHighlightLayerOptions {
  47765. /**
  47766. * Multiplication factor apply to the canvas size to compute the render target size
  47767. * used to generated the glowing objects (the smaller the faster).
  47768. */
  47769. mainTextureRatio: number;
  47770. /**
  47771. * Enforces a fixed size texture to ensure resize independant blur.
  47772. */
  47773. mainTextureFixedSize?: number;
  47774. /**
  47775. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47776. * of the picture to blur (the smaller the faster).
  47777. */
  47778. blurTextureSizeRatio: number;
  47779. /**
  47780. * How big in texel of the blur texture is the vertical blur.
  47781. */
  47782. blurVerticalSize: number;
  47783. /**
  47784. * How big in texel of the blur texture is the horizontal blur.
  47785. */
  47786. blurHorizontalSize: number;
  47787. /**
  47788. * Alpha blending mode used to apply the blur. Default is combine.
  47789. */
  47790. alphaBlendingMode: number;
  47791. /**
  47792. * The camera attached to the layer.
  47793. */
  47794. camera: Nullable<Camera>;
  47795. /**
  47796. * Should we display highlight as a solid stroke?
  47797. */
  47798. isStroke?: boolean;
  47799. /**
  47800. * The rendering group to draw the layer in.
  47801. */
  47802. renderingGroupId: number;
  47803. }
  47804. /**
  47805. * The highlight layer Helps adding a glow effect around a mesh.
  47806. *
  47807. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47808. * glowy meshes to your scene.
  47809. *
  47810. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47811. */
  47812. export class HighlightLayer extends EffectLayer {
  47813. name: string;
  47814. /**
  47815. * Effect Name of the highlight layer.
  47816. */
  47817. static readonly EffectName: string;
  47818. /**
  47819. * The neutral color used during the preparation of the glow effect.
  47820. * This is black by default as the blend operation is a blend operation.
  47821. */
  47822. static NeutralColor: Color4;
  47823. /**
  47824. * Stencil value used for glowing meshes.
  47825. */
  47826. static GlowingMeshStencilReference: number;
  47827. /**
  47828. * Stencil value used for the other meshes in the scene.
  47829. */
  47830. static NormalMeshStencilReference: number;
  47831. /**
  47832. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47833. */
  47834. innerGlow: boolean;
  47835. /**
  47836. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47837. */
  47838. outerGlow: boolean;
  47839. /**
  47840. * Specifies the horizontal size of the blur.
  47841. */
  47842. /**
  47843. * Gets the horizontal size of the blur.
  47844. */
  47845. blurHorizontalSize: number;
  47846. /**
  47847. * Specifies the vertical size of the blur.
  47848. */
  47849. /**
  47850. * Gets the vertical size of the blur.
  47851. */
  47852. blurVerticalSize: number;
  47853. /**
  47854. * An event triggered when the highlight layer is being blurred.
  47855. */
  47856. onBeforeBlurObservable: Observable<HighlightLayer>;
  47857. /**
  47858. * An event triggered when the highlight layer has been blurred.
  47859. */
  47860. onAfterBlurObservable: Observable<HighlightLayer>;
  47861. private _instanceGlowingMeshStencilReference;
  47862. private _options;
  47863. private _downSamplePostprocess;
  47864. private _horizontalBlurPostprocess;
  47865. private _verticalBlurPostprocess;
  47866. private _blurTexture;
  47867. private _meshes;
  47868. private _excludedMeshes;
  47869. /**
  47870. * Instantiates a new highlight Layer and references it to the scene..
  47871. * @param name The name of the layer
  47872. * @param scene The scene to use the layer in
  47873. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47874. */
  47875. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47876. /**
  47877. * Get the effect name of the layer.
  47878. * @return The effect name
  47879. */
  47880. getEffectName(): string;
  47881. /**
  47882. * Create the merge effect. This is the shader use to blit the information back
  47883. * to the main canvas at the end of the scene rendering.
  47884. */
  47885. protected _createMergeEffect(): Effect;
  47886. /**
  47887. * Creates the render target textures and post processes used in the highlight layer.
  47888. */
  47889. protected _createTextureAndPostProcesses(): void;
  47890. /**
  47891. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47892. */
  47893. needStencil(): boolean;
  47894. /**
  47895. * Checks for the readiness of the element composing the layer.
  47896. * @param subMesh the mesh to check for
  47897. * @param useInstances specify wether or not to use instances to render the mesh
  47898. * @param emissiveTexture the associated emissive texture used to generate the glow
  47899. * @return true if ready otherwise, false
  47900. */
  47901. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47902. /**
  47903. * Implementation specific of rendering the generating effect on the main canvas.
  47904. * @param effect The effect used to render through
  47905. */
  47906. protected _internalRender(effect: Effect): void;
  47907. /**
  47908. * Returns true if the layer contains information to display, otherwise false.
  47909. */
  47910. shouldRender(): boolean;
  47911. /**
  47912. * Returns true if the mesh should render, otherwise false.
  47913. * @param mesh The mesh to render
  47914. * @returns true if it should render otherwise false
  47915. */
  47916. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47917. /**
  47918. * Sets the required values for both the emissive texture and and the main color.
  47919. */
  47920. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47921. /**
  47922. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47923. * @param mesh The mesh to exclude from the highlight layer
  47924. */
  47925. addExcludedMesh(mesh: Mesh): void;
  47926. /**
  47927. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47928. * @param mesh The mesh to highlight
  47929. */
  47930. removeExcludedMesh(mesh: Mesh): void;
  47931. /**
  47932. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47933. * @param mesh mesh to test
  47934. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47935. */
  47936. hasMesh(mesh: AbstractMesh): boolean;
  47937. /**
  47938. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47939. * @param mesh The mesh to highlight
  47940. * @param color The color of the highlight
  47941. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47942. */
  47943. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47944. /**
  47945. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47946. * @param mesh The mesh to highlight
  47947. */
  47948. removeMesh(mesh: Mesh): void;
  47949. /**
  47950. * Force the stencil to the normal expected value for none glowing parts
  47951. */
  47952. private _defaultStencilReference;
  47953. /**
  47954. * Free any resources and references associated to a mesh.
  47955. * Internal use
  47956. * @param mesh The mesh to free.
  47957. * @hidden
  47958. */
  47959. _disposeMesh(mesh: Mesh): void;
  47960. /**
  47961. * Dispose the highlight layer and free resources.
  47962. */
  47963. dispose(): void;
  47964. /**
  47965. * Gets the class name of the effect layer
  47966. * @returns the string with the class name of the effect layer
  47967. */
  47968. getClassName(): string;
  47969. /**
  47970. * Serializes this Highlight layer
  47971. * @returns a serialized Highlight layer object
  47972. */
  47973. serialize(): any;
  47974. /**
  47975. * Creates a Highlight layer from parsed Highlight layer data
  47976. * @param parsedHightlightLayer defines the Highlight layer data
  47977. * @param scene defines the current scene
  47978. * @param rootUrl defines the root URL containing the Highlight layer information
  47979. * @returns a parsed Highlight layer
  47980. */
  47981. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47982. }
  47983. }
  47984. declare module BABYLON {
  47985. interface AbstractScene {
  47986. /**
  47987. * The list of layers (background and foreground) of the scene
  47988. */
  47989. layers: Array<Layer>;
  47990. }
  47991. /**
  47992. * Defines the layer scene component responsible to manage any layers
  47993. * in a given scene.
  47994. */
  47995. export class LayerSceneComponent implements ISceneComponent {
  47996. /**
  47997. * The component name helpfull to identify the component in the list of scene components.
  47998. */
  47999. readonly name: string;
  48000. /**
  48001. * The scene the component belongs to.
  48002. */
  48003. scene: Scene;
  48004. private _engine;
  48005. /**
  48006. * Creates a new instance of the component for the given scene
  48007. * @param scene Defines the scene to register the component in
  48008. */
  48009. constructor(scene: Scene);
  48010. /**
  48011. * Registers the component in a given scene
  48012. */
  48013. register(): void;
  48014. /**
  48015. * Rebuilds the elements related to this component in case of
  48016. * context lost for instance.
  48017. */
  48018. rebuild(): void;
  48019. /**
  48020. * Disposes the component and the associated ressources.
  48021. */
  48022. dispose(): void;
  48023. private _draw;
  48024. private _drawCameraPredicate;
  48025. private _drawCameraBackground;
  48026. private _drawCameraForeground;
  48027. private _drawRenderTargetPredicate;
  48028. private _drawRenderTargetBackground;
  48029. private _drawRenderTargetForeground;
  48030. /**
  48031. * Adds all the elements from the container to the scene
  48032. * @param container the container holding the elements
  48033. */
  48034. addFromContainer(container: AbstractScene): void;
  48035. /**
  48036. * Removes all the elements in the container from the scene
  48037. * @param container contains the elements to remove
  48038. * @param dispose if the removed element should be disposed (default: false)
  48039. */
  48040. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48041. }
  48042. }
  48043. declare module BABYLON {
  48044. /** @hidden */
  48045. export var layerPixelShader: {
  48046. name: string;
  48047. shader: string;
  48048. };
  48049. }
  48050. declare module BABYLON {
  48051. /** @hidden */
  48052. export var layerVertexShader: {
  48053. name: string;
  48054. shader: string;
  48055. };
  48056. }
  48057. declare module BABYLON {
  48058. /**
  48059. * This represents a full screen 2d layer.
  48060. * This can be useful to display a picture in the background of your scene for instance.
  48061. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48062. */
  48063. export class Layer {
  48064. /**
  48065. * Define the name of the layer.
  48066. */
  48067. name: string;
  48068. /**
  48069. * Define the texture the layer should display.
  48070. */
  48071. texture: Nullable<Texture>;
  48072. /**
  48073. * Is the layer in background or foreground.
  48074. */
  48075. isBackground: boolean;
  48076. /**
  48077. * Define the color of the layer (instead of texture).
  48078. */
  48079. color: Color4;
  48080. /**
  48081. * Define the scale of the layer in order to zoom in out of the texture.
  48082. */
  48083. scale: Vector2;
  48084. /**
  48085. * Define an offset for the layer in order to shift the texture.
  48086. */
  48087. offset: Vector2;
  48088. /**
  48089. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48090. */
  48091. alphaBlendingMode: number;
  48092. /**
  48093. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48094. * Alpha test will not mix with the background color in case of transparency.
  48095. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48096. */
  48097. alphaTest: boolean;
  48098. /**
  48099. * Define a mask to restrict the layer to only some of the scene cameras.
  48100. */
  48101. layerMask: number;
  48102. /**
  48103. * Define the list of render target the layer is visible into.
  48104. */
  48105. renderTargetTextures: RenderTargetTexture[];
  48106. /**
  48107. * Define if the layer is only used in renderTarget or if it also
  48108. * renders in the main frame buffer of the canvas.
  48109. */
  48110. renderOnlyInRenderTargetTextures: boolean;
  48111. private _scene;
  48112. private _vertexBuffers;
  48113. private _indexBuffer;
  48114. private _effect;
  48115. private _alphaTestEffect;
  48116. /**
  48117. * An event triggered when the layer is disposed.
  48118. */
  48119. onDisposeObservable: Observable<Layer>;
  48120. private _onDisposeObserver;
  48121. /**
  48122. * Back compatibility with callback before the onDisposeObservable existed.
  48123. * The set callback will be triggered when the layer has been disposed.
  48124. */
  48125. onDispose: () => void;
  48126. /**
  48127. * An event triggered before rendering the scene
  48128. */
  48129. onBeforeRenderObservable: Observable<Layer>;
  48130. private _onBeforeRenderObserver;
  48131. /**
  48132. * Back compatibility with callback before the onBeforeRenderObservable existed.
  48133. * The set callback will be triggered just before rendering the layer.
  48134. */
  48135. onBeforeRender: () => void;
  48136. /**
  48137. * An event triggered after rendering the scene
  48138. */
  48139. onAfterRenderObservable: Observable<Layer>;
  48140. private _onAfterRenderObserver;
  48141. /**
  48142. * Back compatibility with callback before the onAfterRenderObservable existed.
  48143. * The set callback will be triggered just after rendering the layer.
  48144. */
  48145. onAfterRender: () => void;
  48146. /**
  48147. * Instantiates a new layer.
  48148. * This represents a full screen 2d layer.
  48149. * This can be useful to display a picture in the background of your scene for instance.
  48150. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48151. * @param name Define the name of the layer in the scene
  48152. * @param imgUrl Define the url of the texture to display in the layer
  48153. * @param scene Define the scene the layer belongs to
  48154. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  48155. * @param color Defines a color for the layer
  48156. */
  48157. constructor(
  48158. /**
  48159. * Define the name of the layer.
  48160. */
  48161. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  48162. private _createIndexBuffer;
  48163. /** @hidden */
  48164. _rebuild(): void;
  48165. /**
  48166. * Renders the layer in the scene.
  48167. */
  48168. render(): void;
  48169. /**
  48170. * Disposes and releases the associated ressources.
  48171. */
  48172. dispose(): void;
  48173. }
  48174. }
  48175. declare module BABYLON {
  48176. /** @hidden */
  48177. export var lensFlarePixelShader: {
  48178. name: string;
  48179. shader: string;
  48180. };
  48181. }
  48182. declare module BABYLON {
  48183. /** @hidden */
  48184. export var lensFlareVertexShader: {
  48185. name: string;
  48186. shader: string;
  48187. };
  48188. }
  48189. declare module BABYLON {
  48190. /**
  48191. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48192. * It is usually composed of several `lensFlare`.
  48193. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48194. */
  48195. export class LensFlareSystem {
  48196. /**
  48197. * Define the name of the lens flare system
  48198. */
  48199. name: string;
  48200. /**
  48201. * List of lens flares used in this system.
  48202. */
  48203. lensFlares: LensFlare[];
  48204. /**
  48205. * Define a limit from the border the lens flare can be visible.
  48206. */
  48207. borderLimit: number;
  48208. /**
  48209. * Define a viewport border we do not want to see the lens flare in.
  48210. */
  48211. viewportBorder: number;
  48212. /**
  48213. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48214. */
  48215. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48216. /**
  48217. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48218. */
  48219. layerMask: number;
  48220. /**
  48221. * Define the id of the lens flare system in the scene.
  48222. * (equal to name by default)
  48223. */
  48224. id: string;
  48225. private _scene;
  48226. private _emitter;
  48227. private _vertexBuffers;
  48228. private _indexBuffer;
  48229. private _effect;
  48230. private _positionX;
  48231. private _positionY;
  48232. private _isEnabled;
  48233. /** @hidden */
  48234. static _SceneComponentInitialization: (scene: Scene) => void;
  48235. /**
  48236. * Instantiates a lens flare system.
  48237. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48238. * It is usually composed of several `lensFlare`.
  48239. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48240. * @param name Define the name of the lens flare system in the scene
  48241. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48242. * @param scene Define the scene the lens flare system belongs to
  48243. */
  48244. constructor(
  48245. /**
  48246. * Define the name of the lens flare system
  48247. */
  48248. name: string, emitter: any, scene: Scene);
  48249. /**
  48250. * Define if the lens flare system is enabled.
  48251. */
  48252. isEnabled: boolean;
  48253. /**
  48254. * Get the scene the effects belongs to.
  48255. * @returns the scene holding the lens flare system
  48256. */
  48257. getScene(): Scene;
  48258. /**
  48259. * Get the emitter of the lens flare system.
  48260. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48261. * @returns the emitter of the lens flare system
  48262. */
  48263. getEmitter(): any;
  48264. /**
  48265. * Set the emitter of the lens flare system.
  48266. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48267. * @param newEmitter Define the new emitter of the system
  48268. */
  48269. setEmitter(newEmitter: any): void;
  48270. /**
  48271. * Get the lens flare system emitter position.
  48272. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48273. * @returns the position
  48274. */
  48275. getEmitterPosition(): Vector3;
  48276. /**
  48277. * @hidden
  48278. */
  48279. computeEffectivePosition(globalViewport: Viewport): boolean;
  48280. /** @hidden */
  48281. _isVisible(): boolean;
  48282. /**
  48283. * @hidden
  48284. */
  48285. render(): boolean;
  48286. /**
  48287. * Dispose and release the lens flare with its associated resources.
  48288. */
  48289. dispose(): void;
  48290. /**
  48291. * Parse a lens flare system from a JSON repressentation
  48292. * @param parsedLensFlareSystem Define the JSON to parse
  48293. * @param scene Define the scene the parsed system should be instantiated in
  48294. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48295. * @returns the parsed system
  48296. */
  48297. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48298. /**
  48299. * Serialize the current Lens Flare System into a JSON representation.
  48300. * @returns the serialized JSON
  48301. */
  48302. serialize(): any;
  48303. }
  48304. }
  48305. declare module BABYLON {
  48306. /**
  48307. * This represents one of the lens effect in a `lensFlareSystem`.
  48308. * It controls one of the indiviual texture used in the effect.
  48309. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48310. */
  48311. export class LensFlare {
  48312. /**
  48313. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48314. */
  48315. size: number;
  48316. /**
  48317. * 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.
  48318. */
  48319. position: number;
  48320. /**
  48321. * Define the lens color.
  48322. */
  48323. color: Color3;
  48324. /**
  48325. * Define the lens texture.
  48326. */
  48327. texture: Nullable<Texture>;
  48328. /**
  48329. * Define the alpha mode to render this particular lens.
  48330. */
  48331. alphaMode: number;
  48332. private _system;
  48333. /**
  48334. * Creates a new Lens Flare.
  48335. * This represents one of the lens effect in a `lensFlareSystem`.
  48336. * It controls one of the indiviual texture used in the effect.
  48337. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48338. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48339. * @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.
  48340. * @param color Define the lens color
  48341. * @param imgUrl Define the lens texture url
  48342. * @param system Define the `lensFlareSystem` this flare is part of
  48343. * @returns The newly created Lens Flare
  48344. */
  48345. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48346. /**
  48347. * Instantiates a new Lens Flare.
  48348. * This represents one of the lens effect in a `lensFlareSystem`.
  48349. * It controls one of the indiviual texture used in the effect.
  48350. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48351. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48352. * @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.
  48353. * @param color Define the lens color
  48354. * @param imgUrl Define the lens texture url
  48355. * @param system Define the `lensFlareSystem` this flare is part of
  48356. */
  48357. constructor(
  48358. /**
  48359. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48360. */
  48361. size: number,
  48362. /**
  48363. * 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.
  48364. */
  48365. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48366. /**
  48367. * Dispose and release the lens flare with its associated resources.
  48368. */
  48369. dispose(): void;
  48370. }
  48371. }
  48372. declare module BABYLON {
  48373. interface AbstractScene {
  48374. /**
  48375. * The list of lens flare system added to the scene
  48376. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48377. */
  48378. lensFlareSystems: Array<LensFlareSystem>;
  48379. /**
  48380. * Removes the given lens flare system from this scene.
  48381. * @param toRemove The lens flare system to remove
  48382. * @returns The index of the removed lens flare system
  48383. */
  48384. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48385. /**
  48386. * Adds the given lens flare system to this scene
  48387. * @param newLensFlareSystem The lens flare system to add
  48388. */
  48389. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48390. /**
  48391. * Gets a lens flare system using its name
  48392. * @param name defines the name to look for
  48393. * @returns the lens flare system or null if not found
  48394. */
  48395. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48396. /**
  48397. * Gets a lens flare system using its id
  48398. * @param id defines the id to look for
  48399. * @returns the lens flare system or null if not found
  48400. */
  48401. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48402. }
  48403. /**
  48404. * Defines the lens flare scene component responsible to manage any lens flares
  48405. * in a given scene.
  48406. */
  48407. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48408. /**
  48409. * The component name helpfull to identify the component in the list of scene components.
  48410. */
  48411. readonly name: string;
  48412. /**
  48413. * The scene the component belongs to.
  48414. */
  48415. scene: Scene;
  48416. /**
  48417. * Creates a new instance of the component for the given scene
  48418. * @param scene Defines the scene to register the component in
  48419. */
  48420. constructor(scene: Scene);
  48421. /**
  48422. * Registers the component in a given scene
  48423. */
  48424. register(): void;
  48425. /**
  48426. * Rebuilds the elements related to this component in case of
  48427. * context lost for instance.
  48428. */
  48429. rebuild(): void;
  48430. /**
  48431. * Adds all the elements from the container to the scene
  48432. * @param container the container holding the elements
  48433. */
  48434. addFromContainer(container: AbstractScene): void;
  48435. /**
  48436. * Removes all the elements in the container from the scene
  48437. * @param container contains the elements to remove
  48438. * @param dispose if the removed element should be disposed (default: false)
  48439. */
  48440. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48441. /**
  48442. * Serializes the component data to the specified json object
  48443. * @param serializationObject The object to serialize to
  48444. */
  48445. serialize(serializationObject: any): void;
  48446. /**
  48447. * Disposes the component and the associated ressources.
  48448. */
  48449. dispose(): void;
  48450. private _draw;
  48451. }
  48452. }
  48453. declare module BABYLON {
  48454. /**
  48455. * Defines the shadow generator component responsible to manage any shadow generators
  48456. * in a given scene.
  48457. */
  48458. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48459. /**
  48460. * The component name helpfull to identify the component in the list of scene components.
  48461. */
  48462. readonly name: string;
  48463. /**
  48464. * The scene the component belongs to.
  48465. */
  48466. scene: Scene;
  48467. /**
  48468. * Creates a new instance of the component for the given scene
  48469. * @param scene Defines the scene to register the component in
  48470. */
  48471. constructor(scene: Scene);
  48472. /**
  48473. * Registers the component in a given scene
  48474. */
  48475. register(): void;
  48476. /**
  48477. * Rebuilds the elements related to this component in case of
  48478. * context lost for instance.
  48479. */
  48480. rebuild(): void;
  48481. /**
  48482. * Serializes the component data to the specified json object
  48483. * @param serializationObject The object to serialize to
  48484. */
  48485. serialize(serializationObject: any): void;
  48486. /**
  48487. * Adds all the elements from the container to the scene
  48488. * @param container the container holding the elements
  48489. */
  48490. addFromContainer(container: AbstractScene): void;
  48491. /**
  48492. * Removes all the elements in the container from the scene
  48493. * @param container contains the elements to remove
  48494. * @param dispose if the removed element should be disposed (default: false)
  48495. */
  48496. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48497. /**
  48498. * Rebuilds the elements related to this component in case of
  48499. * context lost for instance.
  48500. */
  48501. dispose(): void;
  48502. private _gatherRenderTargets;
  48503. }
  48504. }
  48505. declare module BABYLON {
  48506. /**
  48507. * A point light is a light defined by an unique point in world space.
  48508. * The light is emitted in every direction from this point.
  48509. * A good example of a point light is a standard light bulb.
  48510. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48511. */
  48512. export class PointLight extends ShadowLight {
  48513. private _shadowAngle;
  48514. /**
  48515. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48516. * This specifies what angle the shadow will use to be created.
  48517. *
  48518. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48519. */
  48520. /**
  48521. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48522. * This specifies what angle the shadow will use to be created.
  48523. *
  48524. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48525. */
  48526. shadowAngle: number;
  48527. /**
  48528. * Gets the direction if it has been set.
  48529. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48530. */
  48531. /**
  48532. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48533. */
  48534. direction: Vector3;
  48535. /**
  48536. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48537. * A PointLight emits the light in every direction.
  48538. * It can cast shadows.
  48539. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48540. * ```javascript
  48541. * var pointLight = new PointLight("pl", camera.position, scene);
  48542. * ```
  48543. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48544. * @param name The light friendly name
  48545. * @param position The position of the point light in the scene
  48546. * @param scene The scene the lights belongs to
  48547. */
  48548. constructor(name: string, position: Vector3, scene: Scene);
  48549. /**
  48550. * Returns the string "PointLight"
  48551. * @returns the class name
  48552. */
  48553. getClassName(): string;
  48554. /**
  48555. * Returns the integer 0.
  48556. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48557. */
  48558. getTypeID(): number;
  48559. /**
  48560. * Specifies wether or not the shadowmap should be a cube texture.
  48561. * @returns true if the shadowmap needs to be a cube texture.
  48562. */
  48563. needCube(): boolean;
  48564. /**
  48565. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48566. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48567. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48568. */
  48569. getShadowDirection(faceIndex?: number): Vector3;
  48570. /**
  48571. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48572. * - fov = PI / 2
  48573. * - aspect ratio : 1.0
  48574. * - z-near and far equal to the active camera minZ and maxZ.
  48575. * Returns the PointLight.
  48576. */
  48577. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48578. protected _buildUniformLayout(): void;
  48579. /**
  48580. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48581. * @param effect The effect to update
  48582. * @param lightIndex The index of the light in the effect to update
  48583. * @returns The point light
  48584. */
  48585. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48586. /**
  48587. * Prepares the list of defines specific to the light type.
  48588. * @param defines the list of defines
  48589. * @param lightIndex defines the index of the light for the effect
  48590. */
  48591. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48592. }
  48593. }
  48594. declare module BABYLON {
  48595. /**
  48596. * Header information of HDR texture files.
  48597. */
  48598. export interface HDRInfo {
  48599. /**
  48600. * The height of the texture in pixels.
  48601. */
  48602. height: number;
  48603. /**
  48604. * The width of the texture in pixels.
  48605. */
  48606. width: number;
  48607. /**
  48608. * The index of the beginning of the data in the binary file.
  48609. */
  48610. dataPosition: number;
  48611. }
  48612. /**
  48613. * This groups tools to convert HDR texture to native colors array.
  48614. */
  48615. export class HDRTools {
  48616. private static Ldexp;
  48617. private static Rgbe2float;
  48618. private static readStringLine;
  48619. /**
  48620. * Reads header information from an RGBE texture stored in a native array.
  48621. * More information on this format are available here:
  48622. * https://en.wikipedia.org/wiki/RGBE_image_format
  48623. *
  48624. * @param uint8array The binary file stored in native array.
  48625. * @return The header information.
  48626. */
  48627. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48628. /**
  48629. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48630. * This RGBE texture needs to store the information as a panorama.
  48631. *
  48632. * More information on this format are available here:
  48633. * https://en.wikipedia.org/wiki/RGBE_image_format
  48634. *
  48635. * @param buffer The binary file stored in an array buffer.
  48636. * @param size The expected size of the extracted cubemap.
  48637. * @return The Cube Map information.
  48638. */
  48639. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48640. /**
  48641. * Returns the pixels data extracted from an RGBE texture.
  48642. * This pixels will be stored left to right up to down in the R G B order in one array.
  48643. *
  48644. * More information on this format are available here:
  48645. * https://en.wikipedia.org/wiki/RGBE_image_format
  48646. *
  48647. * @param uint8array The binary file stored in an array buffer.
  48648. * @param hdrInfo The header information of the file.
  48649. * @return The pixels data in RGB right to left up to down order.
  48650. */
  48651. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48652. private static RGBE_ReadPixels_RLE;
  48653. }
  48654. }
  48655. declare module BABYLON {
  48656. /**
  48657. * This represents a texture coming from an HDR input.
  48658. *
  48659. * The only supported format is currently panorama picture stored in RGBE format.
  48660. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48661. */
  48662. export class HDRCubeTexture extends BaseTexture {
  48663. private static _facesMapping;
  48664. private _generateHarmonics;
  48665. private _noMipmap;
  48666. private _textureMatrix;
  48667. private _size;
  48668. private _onLoad;
  48669. private _onError;
  48670. /**
  48671. * The texture URL.
  48672. */
  48673. url: string;
  48674. /**
  48675. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48676. */
  48677. coordinatesMode: number;
  48678. protected _isBlocking: boolean;
  48679. /**
  48680. * Sets wether or not the texture is blocking during loading.
  48681. */
  48682. /**
  48683. * Gets wether or not the texture is blocking during loading.
  48684. */
  48685. isBlocking: boolean;
  48686. protected _rotationY: number;
  48687. /**
  48688. * Sets texture matrix rotation angle around Y axis in radians.
  48689. */
  48690. /**
  48691. * Gets texture matrix rotation angle around Y axis radians.
  48692. */
  48693. rotationY: number;
  48694. /**
  48695. * Gets or sets the center of the bounding box associated with the cube texture
  48696. * It must define where the camera used to render the texture was set
  48697. */
  48698. boundingBoxPosition: Vector3;
  48699. private _boundingBoxSize;
  48700. /**
  48701. * Gets or sets the size of the bounding box associated with the cube texture
  48702. * When defined, the cubemap will switch to local mode
  48703. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48704. * @example https://www.babylonjs-playground.com/#RNASML
  48705. */
  48706. boundingBoxSize: Vector3;
  48707. /**
  48708. * Instantiates an HDRTexture from the following parameters.
  48709. *
  48710. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48711. * @param scene The scene the texture will be used in
  48712. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48713. * @param noMipmap Forces to not generate the mipmap if true
  48714. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48715. * @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)
  48716. * @param reserved Reserved flag for internal use.
  48717. */
  48718. 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>);
  48719. /**
  48720. * Get the current class name of the texture useful for serialization or dynamic coding.
  48721. * @returns "HDRCubeTexture"
  48722. */
  48723. getClassName(): string;
  48724. /**
  48725. * Occurs when the file is raw .hdr file.
  48726. */
  48727. private loadTexture;
  48728. clone(): HDRCubeTexture;
  48729. delayLoad(): void;
  48730. /**
  48731. * Get the texture reflection matrix used to rotate/transform the reflection.
  48732. * @returns the reflection matrix
  48733. */
  48734. getReflectionTextureMatrix(): Matrix;
  48735. /**
  48736. * Set the texture reflection matrix used to rotate/transform the reflection.
  48737. * @param value Define the reflection matrix to set
  48738. */
  48739. setReflectionTextureMatrix(value: Matrix): void;
  48740. /**
  48741. * Parses a JSON representation of an HDR Texture in order to create the texture
  48742. * @param parsedTexture Define the JSON representation
  48743. * @param scene Define the scene the texture should be created in
  48744. * @param rootUrl Define the root url in case we need to load relative dependencies
  48745. * @returns the newly created texture after parsing
  48746. */
  48747. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48748. serialize(): any;
  48749. }
  48750. }
  48751. declare module BABYLON {
  48752. /**
  48753. * Class used to control physics engine
  48754. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48755. */
  48756. export class PhysicsEngine implements IPhysicsEngine {
  48757. private _physicsPlugin;
  48758. /**
  48759. * Global value used to control the smallest number supported by the simulation
  48760. */
  48761. static Epsilon: number;
  48762. private _impostors;
  48763. private _joints;
  48764. /**
  48765. * Gets the gravity vector used by the simulation
  48766. */
  48767. gravity: Vector3;
  48768. /**
  48769. * Factory used to create the default physics plugin.
  48770. * @returns The default physics plugin
  48771. */
  48772. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48773. /**
  48774. * Creates a new Physics Engine
  48775. * @param gravity defines the gravity vector used by the simulation
  48776. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48777. */
  48778. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48779. /**
  48780. * Sets the gravity vector used by the simulation
  48781. * @param gravity defines the gravity vector to use
  48782. */
  48783. setGravity(gravity: Vector3): void;
  48784. /**
  48785. * Set the time step of the physics engine.
  48786. * Default is 1/60.
  48787. * To slow it down, enter 1/600 for example.
  48788. * To speed it up, 1/30
  48789. * @param newTimeStep defines the new timestep to apply to this world.
  48790. */
  48791. setTimeStep(newTimeStep?: number): void;
  48792. /**
  48793. * Get the time step of the physics engine.
  48794. * @returns the current time step
  48795. */
  48796. getTimeStep(): number;
  48797. /**
  48798. * Release all resources
  48799. */
  48800. dispose(): void;
  48801. /**
  48802. * Gets the name of the current physics plugin
  48803. * @returns the name of the plugin
  48804. */
  48805. getPhysicsPluginName(): string;
  48806. /**
  48807. * Adding a new impostor for the impostor tracking.
  48808. * This will be done by the impostor itself.
  48809. * @param impostor the impostor to add
  48810. */
  48811. addImpostor(impostor: PhysicsImpostor): void;
  48812. /**
  48813. * Remove an impostor from the engine.
  48814. * This impostor and its mesh will not longer be updated by the physics engine.
  48815. * @param impostor the impostor to remove
  48816. */
  48817. removeImpostor(impostor: PhysicsImpostor): void;
  48818. /**
  48819. * Add a joint to the physics engine
  48820. * @param mainImpostor defines the main impostor to which the joint is added.
  48821. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48822. * @param joint defines the joint that will connect both impostors.
  48823. */
  48824. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48825. /**
  48826. * Removes a joint from the simulation
  48827. * @param mainImpostor defines the impostor used with the joint
  48828. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48829. * @param joint defines the joint to remove
  48830. */
  48831. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48832. /**
  48833. * Called by the scene. No need to call it.
  48834. * @param delta defines the timespam between frames
  48835. */
  48836. _step(delta: number): void;
  48837. /**
  48838. * Gets the current plugin used to run the simulation
  48839. * @returns current plugin
  48840. */
  48841. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48842. /**
  48843. * Gets the list of physic impostors
  48844. * @returns an array of PhysicsImpostor
  48845. */
  48846. getImpostors(): Array<PhysicsImpostor>;
  48847. /**
  48848. * Gets the impostor for a physics enabled object
  48849. * @param object defines the object impersonated by the impostor
  48850. * @returns the PhysicsImpostor or null if not found
  48851. */
  48852. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48853. /**
  48854. * Gets the impostor for a physics body object
  48855. * @param body defines physics body used by the impostor
  48856. * @returns the PhysicsImpostor or null if not found
  48857. */
  48858. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48859. /**
  48860. * Does a raycast in the physics world
  48861. * @param from when should the ray start?
  48862. * @param to when should the ray end?
  48863. * @returns PhysicsRaycastResult
  48864. */
  48865. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48866. }
  48867. }
  48868. declare module BABYLON {
  48869. /** @hidden */
  48870. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48871. private _useDeltaForWorldStep;
  48872. world: any;
  48873. name: string;
  48874. private _physicsMaterials;
  48875. private _fixedTimeStep;
  48876. private _cannonRaycastResult;
  48877. private _raycastResult;
  48878. private _removeAfterStep;
  48879. BJSCANNON: any;
  48880. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48881. setGravity(gravity: Vector3): void;
  48882. setTimeStep(timeStep: number): void;
  48883. getTimeStep(): number;
  48884. executeStep(delta: number): void;
  48885. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48886. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48887. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48888. private _processChildMeshes;
  48889. removePhysicsBody(impostor: PhysicsImpostor): void;
  48890. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48891. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48892. private _addMaterial;
  48893. private _checkWithEpsilon;
  48894. private _createShape;
  48895. private _createHeightmap;
  48896. private _minus90X;
  48897. private _plus90X;
  48898. private _tmpPosition;
  48899. private _tmpDeltaPosition;
  48900. private _tmpUnityRotation;
  48901. private _updatePhysicsBodyTransformation;
  48902. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48903. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48904. isSupported(): boolean;
  48905. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48906. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48907. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48908. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48909. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48910. getBodyMass(impostor: PhysicsImpostor): number;
  48911. getBodyFriction(impostor: PhysicsImpostor): number;
  48912. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48913. getBodyRestitution(impostor: PhysicsImpostor): number;
  48914. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48915. sleepBody(impostor: PhysicsImpostor): void;
  48916. wakeUpBody(impostor: PhysicsImpostor): void;
  48917. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48918. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48919. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48920. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48921. getRadius(impostor: PhysicsImpostor): number;
  48922. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48923. dispose(): void;
  48924. private _extendNamespace;
  48925. /**
  48926. * Does a raycast in the physics world
  48927. * @param from when should the ray start?
  48928. * @param to when should the ray end?
  48929. * @returns PhysicsRaycastResult
  48930. */
  48931. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48932. }
  48933. }
  48934. declare module BABYLON {
  48935. /** @hidden */
  48936. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48937. world: any;
  48938. name: string;
  48939. BJSOIMO: any;
  48940. private _raycastResult;
  48941. constructor(iterations?: number, oimoInjection?: any);
  48942. setGravity(gravity: Vector3): void;
  48943. setTimeStep(timeStep: number): void;
  48944. getTimeStep(): number;
  48945. private _tmpImpostorsArray;
  48946. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48947. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48948. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48949. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48950. private _tmpPositionVector;
  48951. removePhysicsBody(impostor: PhysicsImpostor): void;
  48952. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48953. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48954. isSupported(): boolean;
  48955. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48956. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48957. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48958. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48959. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48960. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48961. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48962. getBodyMass(impostor: PhysicsImpostor): number;
  48963. getBodyFriction(impostor: PhysicsImpostor): number;
  48964. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48965. getBodyRestitution(impostor: PhysicsImpostor): number;
  48966. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48967. sleepBody(impostor: PhysicsImpostor): void;
  48968. wakeUpBody(impostor: PhysicsImpostor): void;
  48969. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48970. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48971. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48972. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48973. getRadius(impostor: PhysicsImpostor): number;
  48974. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48975. dispose(): void;
  48976. /**
  48977. * Does a raycast in the physics world
  48978. * @param from when should the ray start?
  48979. * @param to when should the ray end?
  48980. * @returns PhysicsRaycastResult
  48981. */
  48982. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48983. }
  48984. }
  48985. declare module BABYLON {
  48986. /**
  48987. * Class containing static functions to help procedurally build meshes
  48988. */
  48989. export class RibbonBuilder {
  48990. /**
  48991. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48992. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48993. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48994. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48995. * * 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
  48996. * * 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
  48997. * * 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
  48998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48999. * * 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
  49000. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49001. * * 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
  49002. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49003. * * 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
  49004. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49006. * @param name defines the name of the mesh
  49007. * @param options defines the options used to create the mesh
  49008. * @param scene defines the hosting scene
  49009. * @returns the ribbon mesh
  49010. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49011. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49012. */
  49013. static CreateRibbon(name: string, options: {
  49014. pathArray: Vector3[][];
  49015. closeArray?: boolean;
  49016. closePath?: boolean;
  49017. offset?: number;
  49018. updatable?: boolean;
  49019. sideOrientation?: number;
  49020. frontUVs?: Vector4;
  49021. backUVs?: Vector4;
  49022. instance?: Mesh;
  49023. invertUV?: boolean;
  49024. uvs?: Vector2[];
  49025. colors?: Color4[];
  49026. }, scene?: Nullable<Scene>): Mesh;
  49027. }
  49028. }
  49029. declare module BABYLON {
  49030. /**
  49031. * Class containing static functions to help procedurally build meshes
  49032. */
  49033. export class ShapeBuilder {
  49034. /**
  49035. * 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.
  49036. * * 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.
  49037. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49038. * * 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.
  49039. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49040. * * 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
  49041. * * 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
  49042. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49043. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49044. * * 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
  49045. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49047. * @param name defines the name of the mesh
  49048. * @param options defines the options used to create the mesh
  49049. * @param scene defines the hosting scene
  49050. * @returns the extruded shape mesh
  49051. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49052. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49053. */
  49054. static ExtrudeShape(name: string, options: {
  49055. shape: Vector3[];
  49056. path: Vector3[];
  49057. scale?: number;
  49058. rotation?: number;
  49059. cap?: number;
  49060. updatable?: boolean;
  49061. sideOrientation?: number;
  49062. frontUVs?: Vector4;
  49063. backUVs?: Vector4;
  49064. instance?: Mesh;
  49065. invertUV?: boolean;
  49066. }, scene?: Nullable<Scene>): Mesh;
  49067. /**
  49068. * Creates an custom extruded shape mesh.
  49069. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49070. * * 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.
  49071. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49072. * * 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
  49073. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49074. * * 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
  49075. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49076. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49077. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49078. * * 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
  49079. * * 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
  49080. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49082. * * 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
  49083. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49085. * @param name defines the name of the mesh
  49086. * @param options defines the options used to create the mesh
  49087. * @param scene defines the hosting scene
  49088. * @returns the custom extruded shape mesh
  49089. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49090. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49091. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49092. */
  49093. static ExtrudeShapeCustom(name: string, options: {
  49094. shape: Vector3[];
  49095. path: Vector3[];
  49096. scaleFunction?: any;
  49097. rotationFunction?: any;
  49098. ribbonCloseArray?: boolean;
  49099. ribbonClosePath?: boolean;
  49100. cap?: number;
  49101. updatable?: boolean;
  49102. sideOrientation?: number;
  49103. frontUVs?: Vector4;
  49104. backUVs?: Vector4;
  49105. instance?: Mesh;
  49106. invertUV?: boolean;
  49107. }, scene?: Nullable<Scene>): Mesh;
  49108. private static _ExtrudeShapeGeneric;
  49109. }
  49110. }
  49111. declare module BABYLON {
  49112. /**
  49113. * AmmoJS Physics plugin
  49114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49115. * @see https://github.com/kripken/ammo.js/
  49116. */
  49117. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49118. private _useDeltaForWorldStep;
  49119. /**
  49120. * Reference to the Ammo library
  49121. */
  49122. bjsAMMO: any;
  49123. /**
  49124. * Created ammoJS world which physics bodies are added to
  49125. */
  49126. world: any;
  49127. /**
  49128. * Name of the plugin
  49129. */
  49130. name: string;
  49131. private _timeStep;
  49132. private _fixedTimeStep;
  49133. private _maxSteps;
  49134. private _tmpQuaternion;
  49135. private _tmpAmmoTransform;
  49136. private _tmpAmmoQuaternion;
  49137. private _tmpAmmoConcreteContactResultCallback;
  49138. private _collisionConfiguration;
  49139. private _dispatcher;
  49140. private _overlappingPairCache;
  49141. private _solver;
  49142. private _softBodySolver;
  49143. private _tmpAmmoVectorA;
  49144. private _tmpAmmoVectorB;
  49145. private _tmpAmmoVectorC;
  49146. private _tmpAmmoVectorD;
  49147. private _tmpContactCallbackResult;
  49148. private _tmpAmmoVectorRCA;
  49149. private _tmpAmmoVectorRCB;
  49150. private _raycastResult;
  49151. private static readonly DISABLE_COLLISION_FLAG;
  49152. private static readonly KINEMATIC_FLAG;
  49153. private static readonly DISABLE_DEACTIVATION_FLAG;
  49154. /**
  49155. * Initializes the ammoJS plugin
  49156. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49157. * @param ammoInjection can be used to inject your own ammo reference
  49158. */
  49159. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  49160. /**
  49161. * Sets the gravity of the physics world (m/(s^2))
  49162. * @param gravity Gravity to set
  49163. */
  49164. setGravity(gravity: Vector3): void;
  49165. /**
  49166. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49167. * @param timeStep timestep to use in seconds
  49168. */
  49169. setTimeStep(timeStep: number): void;
  49170. /**
  49171. * 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)
  49172. * @param fixedTimeStep fixedTimeStep to use in seconds
  49173. */
  49174. setFixedTimeStep(fixedTimeStep: number): void;
  49175. /**
  49176. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49177. * @param maxSteps the maximum number of steps by the physics engine per frame
  49178. */
  49179. setMaxSteps(maxSteps: number): void;
  49180. /**
  49181. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49182. * @returns the current timestep in seconds
  49183. */
  49184. getTimeStep(): number;
  49185. private _isImpostorInContact;
  49186. private _isImpostorPairInContact;
  49187. private _stepSimulation;
  49188. /**
  49189. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49190. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49191. * After the step the babylon meshes are set to the position of the physics imposters
  49192. * @param delta amount of time to step forward
  49193. * @param impostors array of imposters to update before/after the step
  49194. */
  49195. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49196. /**
  49197. * Update babylon mesh to match physics world object
  49198. * @param impostor imposter to match
  49199. */
  49200. private _afterSoftStep;
  49201. /**
  49202. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49203. * @param impostor imposter to match
  49204. */
  49205. private _ropeStep;
  49206. /**
  49207. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49208. * @param impostor imposter to match
  49209. */
  49210. private _softbodyOrClothStep;
  49211. private _tmpVector;
  49212. private _tmpMatrix;
  49213. /**
  49214. * Applies an impulse on the imposter
  49215. * @param impostor imposter to apply impulse to
  49216. * @param force amount of force to be applied to the imposter
  49217. * @param contactPoint the location to apply the impulse on the imposter
  49218. */
  49219. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49220. /**
  49221. * Applies a force on the imposter
  49222. * @param impostor imposter to apply force
  49223. * @param force amount of force to be applied to the imposter
  49224. * @param contactPoint the location to apply the force on the imposter
  49225. */
  49226. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49227. /**
  49228. * Creates a physics body using the plugin
  49229. * @param impostor the imposter to create the physics body on
  49230. */
  49231. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49232. /**
  49233. * Removes the physics body from the imposter and disposes of the body's memory
  49234. * @param impostor imposter to remove the physics body from
  49235. */
  49236. removePhysicsBody(impostor: PhysicsImpostor): void;
  49237. /**
  49238. * Generates a joint
  49239. * @param impostorJoint the imposter joint to create the joint with
  49240. */
  49241. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49242. /**
  49243. * Removes a joint
  49244. * @param impostorJoint the imposter joint to remove the joint from
  49245. */
  49246. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49247. private _addMeshVerts;
  49248. /**
  49249. * Initialise the soft body vertices to match its object's (mesh) vertices
  49250. * Softbody vertices (nodes) are in world space and to match this
  49251. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  49252. * @param impostor to create the softbody for
  49253. */
  49254. private _softVertexData;
  49255. /**
  49256. * Create an impostor's soft body
  49257. * @param impostor to create the softbody for
  49258. */
  49259. private _createSoftbody;
  49260. /**
  49261. * Create cloth for an impostor
  49262. * @param impostor to create the softbody for
  49263. */
  49264. private _createCloth;
  49265. /**
  49266. * Create rope for an impostor
  49267. * @param impostor to create the softbody for
  49268. */
  49269. private _createRope;
  49270. private _addHullVerts;
  49271. private _createShape;
  49272. /**
  49273. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49274. * @param impostor imposter containing the physics body and babylon object
  49275. */
  49276. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49277. /**
  49278. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49279. * @param impostor imposter containing the physics body and babylon object
  49280. * @param newPosition new position
  49281. * @param newRotation new rotation
  49282. */
  49283. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49284. /**
  49285. * If this plugin is supported
  49286. * @returns true if its supported
  49287. */
  49288. isSupported(): boolean;
  49289. /**
  49290. * Sets the linear velocity of the physics body
  49291. * @param impostor imposter to set the velocity on
  49292. * @param velocity velocity to set
  49293. */
  49294. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49295. /**
  49296. * Sets the angular velocity of the physics body
  49297. * @param impostor imposter to set the velocity on
  49298. * @param velocity velocity to set
  49299. */
  49300. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49301. /**
  49302. * gets the linear velocity
  49303. * @param impostor imposter to get linear velocity from
  49304. * @returns linear velocity
  49305. */
  49306. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49307. /**
  49308. * gets the angular velocity
  49309. * @param impostor imposter to get angular velocity from
  49310. * @returns angular velocity
  49311. */
  49312. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49313. /**
  49314. * Sets the mass of physics body
  49315. * @param impostor imposter to set the mass on
  49316. * @param mass mass to set
  49317. */
  49318. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49319. /**
  49320. * Gets the mass of the physics body
  49321. * @param impostor imposter to get the mass from
  49322. * @returns mass
  49323. */
  49324. getBodyMass(impostor: PhysicsImpostor): number;
  49325. /**
  49326. * Gets friction of the impostor
  49327. * @param impostor impostor to get friction from
  49328. * @returns friction value
  49329. */
  49330. getBodyFriction(impostor: PhysicsImpostor): number;
  49331. /**
  49332. * Sets friction of the impostor
  49333. * @param impostor impostor to set friction on
  49334. * @param friction friction value
  49335. */
  49336. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49337. /**
  49338. * Gets restitution of the impostor
  49339. * @param impostor impostor to get restitution from
  49340. * @returns restitution value
  49341. */
  49342. getBodyRestitution(impostor: PhysicsImpostor): number;
  49343. /**
  49344. * Sets resitution of the impostor
  49345. * @param impostor impostor to set resitution on
  49346. * @param restitution resitution value
  49347. */
  49348. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49349. /**
  49350. * Gets pressure inside the impostor
  49351. * @param impostor impostor to get pressure from
  49352. * @returns pressure value
  49353. */
  49354. getBodyPressure(impostor: PhysicsImpostor): number;
  49355. /**
  49356. * Sets pressure inside a soft body impostor
  49357. * Cloth and rope must remain 0 pressure
  49358. * @param impostor impostor to set pressure on
  49359. * @param pressure pressure value
  49360. */
  49361. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  49362. /**
  49363. * Gets stiffness of the impostor
  49364. * @param impostor impostor to get stiffness from
  49365. * @returns pressure value
  49366. */
  49367. getBodyStiffness(impostor: PhysicsImpostor): number;
  49368. /**
  49369. * Sets stiffness of the impostor
  49370. * @param impostor impostor to set stiffness on
  49371. * @param stiffness stiffness value from 0 to 1
  49372. */
  49373. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  49374. /**
  49375. * Gets velocityIterations of the impostor
  49376. * @param impostor impostor to get velocity iterations from
  49377. * @returns velocityIterations value
  49378. */
  49379. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  49380. /**
  49381. * Sets velocityIterations of the impostor
  49382. * @param impostor impostor to set velocity iterations on
  49383. * @param velocityIterations velocityIterations value
  49384. */
  49385. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  49386. /**
  49387. * Gets positionIterations of the impostor
  49388. * @param impostor impostor to get position iterations from
  49389. * @returns positionIterations value
  49390. */
  49391. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  49392. /**
  49393. * Sets positionIterations of the impostor
  49394. * @param impostor impostor to set position on
  49395. * @param positionIterations positionIterations value
  49396. */
  49397. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  49398. /**
  49399. * Append an anchor to a cloth object
  49400. * @param impostor is the cloth impostor to add anchor to
  49401. * @param otherImpostor is the rigid impostor to anchor to
  49402. * @param width ratio across width from 0 to 1
  49403. * @param height ratio up height from 0 to 1
  49404. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  49405. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49406. */
  49407. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49408. /**
  49409. * Append an hook to a rope object
  49410. * @param impostor is the rope impostor to add hook to
  49411. * @param otherImpostor is the rigid impostor to hook to
  49412. * @param length ratio along the rope from 0 to 1
  49413. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  49414. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49415. */
  49416. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49417. /**
  49418. * Sleeps the physics body and stops it from being active
  49419. * @param impostor impostor to sleep
  49420. */
  49421. sleepBody(impostor: PhysicsImpostor): void;
  49422. /**
  49423. * Activates the physics body
  49424. * @param impostor impostor to activate
  49425. */
  49426. wakeUpBody(impostor: PhysicsImpostor): void;
  49427. /**
  49428. * Updates the distance parameters of the joint
  49429. * @param joint joint to update
  49430. * @param maxDistance maximum distance of the joint
  49431. * @param minDistance minimum distance of the joint
  49432. */
  49433. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49434. /**
  49435. * Sets a motor on the joint
  49436. * @param joint joint to set motor on
  49437. * @param speed speed of the motor
  49438. * @param maxForce maximum force of the motor
  49439. * @param motorIndex index of the motor
  49440. */
  49441. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49442. /**
  49443. * Sets the motors limit
  49444. * @param joint joint to set limit on
  49445. * @param upperLimit upper limit
  49446. * @param lowerLimit lower limit
  49447. */
  49448. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49449. /**
  49450. * Syncs the position and rotation of a mesh with the impostor
  49451. * @param mesh mesh to sync
  49452. * @param impostor impostor to update the mesh with
  49453. */
  49454. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49455. /**
  49456. * Gets the radius of the impostor
  49457. * @param impostor impostor to get radius from
  49458. * @returns the radius
  49459. */
  49460. getRadius(impostor: PhysicsImpostor): number;
  49461. /**
  49462. * Gets the box size of the impostor
  49463. * @param impostor impostor to get box size from
  49464. * @param result the resulting box size
  49465. */
  49466. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49467. /**
  49468. * Disposes of the impostor
  49469. */
  49470. dispose(): void;
  49471. /**
  49472. * Does a raycast in the physics world
  49473. * @param from when should the ray start?
  49474. * @param to when should the ray end?
  49475. * @returns PhysicsRaycastResult
  49476. */
  49477. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49478. }
  49479. }
  49480. declare module BABYLON {
  49481. interface AbstractScene {
  49482. /**
  49483. * The list of reflection probes added to the scene
  49484. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49485. */
  49486. reflectionProbes: Array<ReflectionProbe>;
  49487. /**
  49488. * Removes the given reflection probe from this scene.
  49489. * @param toRemove The reflection probe to remove
  49490. * @returns The index of the removed reflection probe
  49491. */
  49492. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49493. /**
  49494. * Adds the given reflection probe to this scene.
  49495. * @param newReflectionProbe The reflection probe to add
  49496. */
  49497. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49498. }
  49499. /**
  49500. * Class used to generate realtime reflection / refraction cube textures
  49501. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49502. */
  49503. export class ReflectionProbe {
  49504. /** defines the name of the probe */
  49505. name: string;
  49506. private _scene;
  49507. private _renderTargetTexture;
  49508. private _projectionMatrix;
  49509. private _viewMatrix;
  49510. private _target;
  49511. private _add;
  49512. private _attachedMesh;
  49513. private _invertYAxis;
  49514. /** Gets or sets probe position (center of the cube map) */
  49515. position: Vector3;
  49516. /**
  49517. * Creates a new reflection probe
  49518. * @param name defines the name of the probe
  49519. * @param size defines the texture resolution (for each face)
  49520. * @param scene defines the hosting scene
  49521. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49522. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49523. */
  49524. constructor(
  49525. /** defines the name of the probe */
  49526. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49527. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49528. samples: number;
  49529. /** Gets or sets the refresh rate to use (on every frame by default) */
  49530. refreshRate: number;
  49531. /**
  49532. * Gets the hosting scene
  49533. * @returns a Scene
  49534. */
  49535. getScene(): Scene;
  49536. /** Gets the internal CubeTexture used to render to */
  49537. readonly cubeTexture: RenderTargetTexture;
  49538. /** Gets the list of meshes to render */
  49539. readonly renderList: Nullable<AbstractMesh[]>;
  49540. /**
  49541. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49542. * @param mesh defines the mesh to attach to
  49543. */
  49544. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49545. /**
  49546. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49547. * @param renderingGroupId The rendering group id corresponding to its index
  49548. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49549. */
  49550. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49551. /**
  49552. * Clean all associated resources
  49553. */
  49554. dispose(): void;
  49555. /**
  49556. * Converts the reflection probe information to a readable string for debug purpose.
  49557. * @param fullDetails Supports for multiple levels of logging within scene loading
  49558. * @returns the human readable reflection probe info
  49559. */
  49560. toString(fullDetails?: boolean): string;
  49561. /**
  49562. * Get the class name of the relfection probe.
  49563. * @returns "ReflectionProbe"
  49564. */
  49565. getClassName(): string;
  49566. /**
  49567. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49568. * @returns The JSON representation of the texture
  49569. */
  49570. serialize(): any;
  49571. /**
  49572. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49573. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49574. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49575. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49576. * @returns The parsed reflection probe if successful
  49577. */
  49578. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49579. }
  49580. }
  49581. declare module BABYLON {
  49582. /** @hidden */
  49583. export var _BabylonLoaderRegistered: boolean;
  49584. }
  49585. declare module BABYLON {
  49586. /**
  49587. * The Physically based simple base material of BJS.
  49588. *
  49589. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49590. * It is used as the base class for both the specGloss and metalRough conventions.
  49591. */
  49592. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49593. /**
  49594. * Number of Simultaneous lights allowed on the material.
  49595. */
  49596. maxSimultaneousLights: number;
  49597. /**
  49598. * If sets to true, disables all the lights affecting the material.
  49599. */
  49600. disableLighting: boolean;
  49601. /**
  49602. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49603. */
  49604. environmentTexture: BaseTexture;
  49605. /**
  49606. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49607. */
  49608. invertNormalMapX: boolean;
  49609. /**
  49610. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49611. */
  49612. invertNormalMapY: boolean;
  49613. /**
  49614. * Normal map used in the model.
  49615. */
  49616. normalTexture: BaseTexture;
  49617. /**
  49618. * Emissivie color used to self-illuminate the model.
  49619. */
  49620. emissiveColor: Color3;
  49621. /**
  49622. * Emissivie texture used to self-illuminate the model.
  49623. */
  49624. emissiveTexture: BaseTexture;
  49625. /**
  49626. * Occlusion Channel Strenght.
  49627. */
  49628. occlusionStrength: number;
  49629. /**
  49630. * Occlusion Texture of the material (adding extra occlusion effects).
  49631. */
  49632. occlusionTexture: BaseTexture;
  49633. /**
  49634. * Defines the alpha limits in alpha test mode.
  49635. */
  49636. alphaCutOff: number;
  49637. /**
  49638. * Gets the current double sided mode.
  49639. */
  49640. /**
  49641. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49642. */
  49643. doubleSided: boolean;
  49644. /**
  49645. * Stores the pre-calculated light information of a mesh in a texture.
  49646. */
  49647. lightmapTexture: BaseTexture;
  49648. /**
  49649. * If true, the light map contains occlusion information instead of lighting info.
  49650. */
  49651. useLightmapAsShadowmap: boolean;
  49652. /**
  49653. * Instantiates a new PBRMaterial instance.
  49654. *
  49655. * @param name The material name
  49656. * @param scene The scene the material will be use in.
  49657. */
  49658. constructor(name: string, scene: Scene);
  49659. getClassName(): string;
  49660. }
  49661. }
  49662. declare module BABYLON {
  49663. /**
  49664. * The PBR material of BJS following the metal roughness convention.
  49665. *
  49666. * This fits to the PBR convention in the GLTF definition:
  49667. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49668. */
  49669. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49670. /**
  49671. * The base color has two different interpretations depending on the value of metalness.
  49672. * When the material is a metal, the base color is the specific measured reflectance value
  49673. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49674. * of the material.
  49675. */
  49676. baseColor: Color3;
  49677. /**
  49678. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49679. * well as opacity information in the alpha channel.
  49680. */
  49681. baseTexture: BaseTexture;
  49682. /**
  49683. * Specifies the metallic scalar value of the material.
  49684. * Can also be used to scale the metalness values of the metallic texture.
  49685. */
  49686. metallic: number;
  49687. /**
  49688. * Specifies the roughness scalar value of the material.
  49689. * Can also be used to scale the roughness values of the metallic texture.
  49690. */
  49691. roughness: number;
  49692. /**
  49693. * Texture containing both the metallic value in the B channel and the
  49694. * roughness value in the G channel to keep better precision.
  49695. */
  49696. metallicRoughnessTexture: BaseTexture;
  49697. /**
  49698. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49699. *
  49700. * @param name The material name
  49701. * @param scene The scene the material will be use in.
  49702. */
  49703. constructor(name: string, scene: Scene);
  49704. /**
  49705. * Return the currrent class name of the material.
  49706. */
  49707. getClassName(): string;
  49708. /**
  49709. * Makes a duplicate of the current material.
  49710. * @param name - name to use for the new material.
  49711. */
  49712. clone(name: string): PBRMetallicRoughnessMaterial;
  49713. /**
  49714. * Serialize the material to a parsable JSON object.
  49715. */
  49716. serialize(): any;
  49717. /**
  49718. * Parses a JSON object correponding to the serialize function.
  49719. */
  49720. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49721. }
  49722. }
  49723. declare module BABYLON {
  49724. /**
  49725. * The PBR material of BJS following the specular glossiness convention.
  49726. *
  49727. * This fits to the PBR convention in the GLTF definition:
  49728. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49729. */
  49730. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49731. /**
  49732. * Specifies the diffuse color of the material.
  49733. */
  49734. diffuseColor: Color3;
  49735. /**
  49736. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49737. * channel.
  49738. */
  49739. diffuseTexture: BaseTexture;
  49740. /**
  49741. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49742. */
  49743. specularColor: Color3;
  49744. /**
  49745. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49746. */
  49747. glossiness: number;
  49748. /**
  49749. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49750. */
  49751. specularGlossinessTexture: BaseTexture;
  49752. /**
  49753. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49754. *
  49755. * @param name The material name
  49756. * @param scene The scene the material will be use in.
  49757. */
  49758. constructor(name: string, scene: Scene);
  49759. /**
  49760. * Return the currrent class name of the material.
  49761. */
  49762. getClassName(): string;
  49763. /**
  49764. * Makes a duplicate of the current material.
  49765. * @param name - name to use for the new material.
  49766. */
  49767. clone(name: string): PBRSpecularGlossinessMaterial;
  49768. /**
  49769. * Serialize the material to a parsable JSON object.
  49770. */
  49771. serialize(): any;
  49772. /**
  49773. * Parses a JSON object correponding to the serialize function.
  49774. */
  49775. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49776. }
  49777. }
  49778. declare module BABYLON {
  49779. /**
  49780. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49781. * It can help converting any input color in a desired output one. This can then be used to create effects
  49782. * from sepia, black and white to sixties or futuristic rendering...
  49783. *
  49784. * The only supported format is currently 3dl.
  49785. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49786. */
  49787. export class ColorGradingTexture extends BaseTexture {
  49788. /**
  49789. * The current texture matrix. (will always be identity in color grading texture)
  49790. */
  49791. private _textureMatrix;
  49792. /**
  49793. * The texture URL.
  49794. */
  49795. url: string;
  49796. /**
  49797. * Empty line regex stored for GC.
  49798. */
  49799. private static _noneEmptyLineRegex;
  49800. private _engine;
  49801. /**
  49802. * Instantiates a ColorGradingTexture from the following parameters.
  49803. *
  49804. * @param url The location of the color gradind data (currently only supporting 3dl)
  49805. * @param scene The scene the texture will be used in
  49806. */
  49807. constructor(url: string, scene: Scene);
  49808. /**
  49809. * Returns the texture matrix used in most of the material.
  49810. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49811. */
  49812. getTextureMatrix(): Matrix;
  49813. /**
  49814. * Occurs when the file being loaded is a .3dl LUT file.
  49815. */
  49816. private load3dlTexture;
  49817. /**
  49818. * Starts the loading process of the texture.
  49819. */
  49820. private loadTexture;
  49821. /**
  49822. * Clones the color gradind texture.
  49823. */
  49824. clone(): ColorGradingTexture;
  49825. /**
  49826. * Called during delayed load for textures.
  49827. */
  49828. delayLoad(): void;
  49829. /**
  49830. * Parses a color grading texture serialized by Babylon.
  49831. * @param parsedTexture The texture information being parsedTexture
  49832. * @param scene The scene to load the texture in
  49833. * @param rootUrl The root url of the data assets to load
  49834. * @return A color gradind texture
  49835. */
  49836. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49837. /**
  49838. * Serializes the LUT texture to json format.
  49839. */
  49840. serialize(): any;
  49841. }
  49842. }
  49843. declare module BABYLON {
  49844. /**
  49845. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49846. */
  49847. export class EquiRectangularCubeTexture extends BaseTexture {
  49848. /** The six faces of the cube. */
  49849. private static _FacesMapping;
  49850. private _noMipmap;
  49851. private _onLoad;
  49852. private _onError;
  49853. /** The size of the cubemap. */
  49854. private _size;
  49855. /** The buffer of the image. */
  49856. private _buffer;
  49857. /** The width of the input image. */
  49858. private _width;
  49859. /** The height of the input image. */
  49860. private _height;
  49861. /** The URL to the image. */
  49862. url: string;
  49863. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49864. coordinatesMode: number;
  49865. /**
  49866. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49867. * @param url The location of the image
  49868. * @param scene The scene the texture will be used in
  49869. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49870. * @param noMipmap Forces to not generate the mipmap if true
  49871. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49872. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49873. * @param onLoad — defines a callback called when texture is loaded
  49874. * @param onError — defines a callback called if there is an error
  49875. */
  49876. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49877. /**
  49878. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49879. */
  49880. private loadImage;
  49881. /**
  49882. * Convert the image buffer into a cubemap and create a CubeTexture.
  49883. */
  49884. private loadTexture;
  49885. /**
  49886. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49887. * @param buffer The ArrayBuffer that should be converted.
  49888. * @returns The buffer as Float32Array.
  49889. */
  49890. private getFloat32ArrayFromArrayBuffer;
  49891. /**
  49892. * Get the current class name of the texture useful for serialization or dynamic coding.
  49893. * @returns "EquiRectangularCubeTexture"
  49894. */
  49895. getClassName(): string;
  49896. /**
  49897. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49898. * @returns A clone of the current EquiRectangularCubeTexture.
  49899. */
  49900. clone(): EquiRectangularCubeTexture;
  49901. }
  49902. }
  49903. declare module BABYLON {
  49904. /**
  49905. * Based on jsTGALoader - Javascript loader for TGA file
  49906. * By Vincent Thibault
  49907. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49908. */
  49909. export class TGATools {
  49910. private static _TYPE_INDEXED;
  49911. private static _TYPE_RGB;
  49912. private static _TYPE_GREY;
  49913. private static _TYPE_RLE_INDEXED;
  49914. private static _TYPE_RLE_RGB;
  49915. private static _TYPE_RLE_GREY;
  49916. private static _ORIGIN_MASK;
  49917. private static _ORIGIN_SHIFT;
  49918. private static _ORIGIN_BL;
  49919. private static _ORIGIN_BR;
  49920. private static _ORIGIN_UL;
  49921. private static _ORIGIN_UR;
  49922. /**
  49923. * Gets the header of a TGA file
  49924. * @param data defines the TGA data
  49925. * @returns the header
  49926. */
  49927. static GetTGAHeader(data: Uint8Array): any;
  49928. /**
  49929. * Uploads TGA content to a Babylon Texture
  49930. * @hidden
  49931. */
  49932. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49933. /** @hidden */
  49934. 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;
  49935. /** @hidden */
  49936. 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;
  49937. /** @hidden */
  49938. 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;
  49939. /** @hidden */
  49940. 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;
  49941. /** @hidden */
  49942. 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;
  49943. /** @hidden */
  49944. 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;
  49945. }
  49946. }
  49947. declare module BABYLON {
  49948. /**
  49949. * Implementation of the TGA Texture Loader.
  49950. * @hidden
  49951. */
  49952. export class _TGATextureLoader implements IInternalTextureLoader {
  49953. /**
  49954. * Defines wether the loader supports cascade loading the different faces.
  49955. */
  49956. readonly supportCascades: boolean;
  49957. /**
  49958. * This returns if the loader support the current file information.
  49959. * @param extension defines the file extension of the file being loaded
  49960. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49961. * @param fallback defines the fallback internal texture if any
  49962. * @param isBase64 defines whether the texture is encoded as a base64
  49963. * @param isBuffer defines whether the texture data are stored as a buffer
  49964. * @returns true if the loader can load the specified file
  49965. */
  49966. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49967. /**
  49968. * Transform the url before loading if required.
  49969. * @param rootUrl the url of the texture
  49970. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49971. * @returns the transformed texture
  49972. */
  49973. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49974. /**
  49975. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49976. * @param rootUrl the url of the texture
  49977. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49978. * @returns the fallback texture
  49979. */
  49980. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49981. /**
  49982. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49983. * @param data contains the texture data
  49984. * @param texture defines the BabylonJS internal texture
  49985. * @param createPolynomials will be true if polynomials have been requested
  49986. * @param onLoad defines the callback to trigger once the texture is ready
  49987. * @param onError defines the callback to trigger in case of error
  49988. */
  49989. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49990. /**
  49991. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49992. * @param data contains the texture data
  49993. * @param texture defines the BabylonJS internal texture
  49994. * @param callback defines the method to call once ready to upload
  49995. */
  49996. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49997. }
  49998. }
  49999. declare module BABYLON {
  50000. /**
  50001. * 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.
  50002. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50003. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50004. */
  50005. export class CustomProceduralTexture extends ProceduralTexture {
  50006. private _animate;
  50007. private _time;
  50008. private _config;
  50009. private _texturePath;
  50010. /**
  50011. * Instantiates a new Custom Procedural Texture.
  50012. * 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.
  50013. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50014. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50015. * @param name Define the name of the texture
  50016. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50017. * @param size Define the size of the texture to create
  50018. * @param scene Define the scene the texture belongs to
  50019. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50020. * @param generateMipMaps Define if the texture should creates mip maps or not
  50021. */
  50022. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50023. private _loadJson;
  50024. /**
  50025. * Is the texture ready to be used ? (rendered at least once)
  50026. * @returns true if ready, otherwise, false.
  50027. */
  50028. isReady(): boolean;
  50029. /**
  50030. * Render the texture to its associated render target.
  50031. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50032. */
  50033. render(useCameraPostProcess?: boolean): void;
  50034. /**
  50035. * Update the list of dependant textures samplers in the shader.
  50036. */
  50037. updateTextures(): void;
  50038. /**
  50039. * Update the uniform values of the procedural texture in the shader.
  50040. */
  50041. updateShaderUniforms(): void;
  50042. /**
  50043. * Define if the texture animates or not.
  50044. */
  50045. animate: boolean;
  50046. }
  50047. }
  50048. declare module BABYLON {
  50049. /** @hidden */
  50050. export var noisePixelShader: {
  50051. name: string;
  50052. shader: string;
  50053. };
  50054. }
  50055. declare module BABYLON {
  50056. /**
  50057. * Class used to generate noise procedural textures
  50058. */
  50059. export class NoiseProceduralTexture extends ProceduralTexture {
  50060. private _time;
  50061. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50062. brightness: number;
  50063. /** Defines the number of octaves to process */
  50064. octaves: number;
  50065. /** Defines the level of persistence (0.8 by default) */
  50066. persistence: number;
  50067. /** Gets or sets animation speed factor (default is 1) */
  50068. animationSpeedFactor: number;
  50069. /**
  50070. * Creates a new NoiseProceduralTexture
  50071. * @param name defines the name fo the texture
  50072. * @param size defines the size of the texture (default is 256)
  50073. * @param scene defines the hosting scene
  50074. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50075. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50076. */
  50077. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50078. private _updateShaderUniforms;
  50079. protected _getDefines(): string;
  50080. /** Generate the current state of the procedural texture */
  50081. render(useCameraPostProcess?: boolean): void;
  50082. /**
  50083. * Serializes this noise procedural texture
  50084. * @returns a serialized noise procedural texture object
  50085. */
  50086. serialize(): any;
  50087. /**
  50088. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50089. * @param parsedTexture defines parsed texture data
  50090. * @param scene defines the current scene
  50091. * @param rootUrl defines the root URL containing noise procedural texture information
  50092. * @returns a parsed NoiseProceduralTexture
  50093. */
  50094. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50095. }
  50096. }
  50097. declare module BABYLON {
  50098. /**
  50099. * Raw cube texture where the raw buffers are passed in
  50100. */
  50101. export class RawCubeTexture extends CubeTexture {
  50102. /**
  50103. * Creates a cube texture where the raw buffers are passed in.
  50104. * @param scene defines the scene the texture is attached to
  50105. * @param data defines the array of data to use to create each face
  50106. * @param size defines the size of the textures
  50107. * @param format defines the format of the data
  50108. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50109. * @param generateMipMaps defines if the engine should generate the mip levels
  50110. * @param invertY defines if data must be stored with Y axis inverted
  50111. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50112. * @param compression defines the compression used (null by default)
  50113. */
  50114. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50115. /**
  50116. * Updates the raw cube texture.
  50117. * @param data defines the data to store
  50118. * @param format defines the data format
  50119. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50120. * @param invertY defines if data must be stored with Y axis inverted
  50121. * @param compression defines the compression used (null by default)
  50122. * @param level defines which level of the texture to update
  50123. */
  50124. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50125. /**
  50126. * Updates a raw cube texture with RGBD encoded data.
  50127. * @param data defines the array of data [mipmap][face] to use to create each face
  50128. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50129. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50130. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50131. * @returns a promsie that resolves when the operation is complete
  50132. */
  50133. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50134. /**
  50135. * Clones the raw cube texture.
  50136. * @return a new cube texture
  50137. */
  50138. clone(): CubeTexture;
  50139. /** @hidden */
  50140. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50141. }
  50142. }
  50143. declare module BABYLON {
  50144. /**
  50145. * Class used to store 3D textures containing user data
  50146. */
  50147. export class RawTexture3D extends Texture {
  50148. /** Gets or sets the texture format to use */
  50149. format: number;
  50150. private _engine;
  50151. /**
  50152. * Create a new RawTexture3D
  50153. * @param data defines the data of the texture
  50154. * @param width defines the width of the texture
  50155. * @param height defines the height of the texture
  50156. * @param depth defines the depth of the texture
  50157. * @param format defines the texture format to use
  50158. * @param scene defines the hosting scene
  50159. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  50160. * @param invertY defines if texture must be stored with Y axis inverted
  50161. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  50162. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  50163. */
  50164. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  50165. /** Gets or sets the texture format to use */
  50166. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  50167. /**
  50168. * Update the texture with new data
  50169. * @param data defines the data to store in the texture
  50170. */
  50171. update(data: ArrayBufferView): void;
  50172. }
  50173. }
  50174. declare module BABYLON {
  50175. /**
  50176. * Creates a refraction texture used by refraction channel of the standard material.
  50177. * It is like a mirror but to see through a material.
  50178. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50179. */
  50180. export class RefractionTexture extends RenderTargetTexture {
  50181. /**
  50182. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  50183. * 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.
  50184. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50185. */
  50186. refractionPlane: Plane;
  50187. /**
  50188. * Define how deep under the surface we should see.
  50189. */
  50190. depth: number;
  50191. /**
  50192. * Creates a refraction texture used by refraction channel of the standard material.
  50193. * It is like a mirror but to see through a material.
  50194. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50195. * @param name Define the texture name
  50196. * @param size Define the size of the underlying texture
  50197. * @param scene Define the scene the refraction belongs to
  50198. * @param generateMipMaps Define if we need to generate mips level for the refraction
  50199. */
  50200. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  50201. /**
  50202. * Clone the refraction texture.
  50203. * @returns the cloned texture
  50204. */
  50205. clone(): RefractionTexture;
  50206. /**
  50207. * Serialize the texture to a JSON representation you could use in Parse later on
  50208. * @returns the serialized JSON representation
  50209. */
  50210. serialize(): any;
  50211. }
  50212. }
  50213. declare module BABYLON {
  50214. /**
  50215. * Defines the options related to the creation of an HtmlElementTexture
  50216. */
  50217. export interface IHtmlElementTextureOptions {
  50218. /**
  50219. * Defines wether mip maps should be created or not.
  50220. */
  50221. generateMipMaps?: boolean;
  50222. /**
  50223. * Defines the sampling mode of the texture.
  50224. */
  50225. samplingMode?: number;
  50226. /**
  50227. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  50228. */
  50229. engine: Nullable<Engine>;
  50230. /**
  50231. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  50232. */
  50233. scene: Nullable<Scene>;
  50234. }
  50235. /**
  50236. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  50237. * To be as efficient as possible depending on your constraints nothing aside the first upload
  50238. * is automatically managed.
  50239. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  50240. * in your application.
  50241. *
  50242. * As the update is not automatic, you need to call them manually.
  50243. */
  50244. export class HtmlElementTexture extends BaseTexture {
  50245. /**
  50246. * The texture URL.
  50247. */
  50248. element: HTMLVideoElement | HTMLCanvasElement;
  50249. private static readonly DefaultOptions;
  50250. private _textureMatrix;
  50251. private _engine;
  50252. private _isVideo;
  50253. private _generateMipMaps;
  50254. private _samplingMode;
  50255. /**
  50256. * Instantiates a HtmlElementTexture from the following parameters.
  50257. *
  50258. * @param name Defines the name of the texture
  50259. * @param element Defines the video or canvas the texture is filled with
  50260. * @param options Defines the other none mandatory texture creation options
  50261. */
  50262. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  50263. private _createInternalTexture;
  50264. /**
  50265. * Returns the texture matrix used in most of the material.
  50266. */
  50267. getTextureMatrix(): Matrix;
  50268. /**
  50269. * Updates the content of the texture.
  50270. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  50271. */
  50272. update(invertY?: Nullable<boolean>): void;
  50273. }
  50274. }
  50275. declare module BABYLON {
  50276. /**
  50277. * Enum used to define the target of a block
  50278. */
  50279. export enum NodeMaterialBlockTargets {
  50280. /** Vertex shader */
  50281. Vertex = 1,
  50282. /** Fragment shader */
  50283. Fragment = 2,
  50284. /** Vertex and Fragment */
  50285. VertexAndFragment = 3
  50286. }
  50287. }
  50288. declare module BABYLON {
  50289. /**
  50290. * Defines the kind of connection point for node based material
  50291. */
  50292. export enum NodeMaterialBlockConnectionPointTypes {
  50293. /** Float */
  50294. Float = 1,
  50295. /** Int */
  50296. Int = 2,
  50297. /** Vector2 */
  50298. Vector2 = 4,
  50299. /** Vector3 */
  50300. Vector3 = 8,
  50301. /** Vector4 */
  50302. Vector4 = 16,
  50303. /** Color3 */
  50304. Color3 = 32,
  50305. /** Color4 */
  50306. Color4 = 64,
  50307. /** Matrix */
  50308. Matrix = 128,
  50309. /** Texture */
  50310. Texture = 256,
  50311. /** Texture3D */
  50312. Texture3D = 512,
  50313. /** Vector3 or Color3 */
  50314. Vector3OrColor3 = 40,
  50315. /** Vector3 or Vector4 */
  50316. Vector3OrVector4 = 24,
  50317. /** Vector4 or Color4 */
  50318. Vector4OrColor4 = 80,
  50319. /** Color3 or Color4 */
  50320. Color3OrColor4 = 96,
  50321. /** Vector3 or Color3 */
  50322. Vector3OrColor3OrVector4OrColor4 = 120
  50323. }
  50324. }
  50325. declare module BABYLON {
  50326. /**
  50327. * Enum used to define well known values e.g. values automatically provided by the system
  50328. */
  50329. export enum NodeMaterialWellKnownValues {
  50330. /** World */
  50331. World = 1,
  50332. /** View */
  50333. View = 2,
  50334. /** Projection */
  50335. Projection = 3,
  50336. /** ViewProjection */
  50337. ViewProjection = 4,
  50338. /** WorldView */
  50339. WorldView = 5,
  50340. /** WorldViewProjection */
  50341. WorldViewProjection = 6,
  50342. /** Will be filled by the block itself */
  50343. Automatic = 7
  50344. }
  50345. }
  50346. declare module BABYLON {
  50347. /**
  50348. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  50349. */
  50350. export enum NodeMaterialBlockConnectionPointMode {
  50351. /** Value is an uniform */
  50352. Uniform = 0,
  50353. /** Value is a mesh attribute */
  50354. Attribute = 1,
  50355. /** Value is a varying between vertex and fragment shaders */
  50356. Varying = 2,
  50357. /** Mode is undefined */
  50358. Undefined = 3
  50359. }
  50360. }
  50361. declare module BABYLON {
  50362. /**
  50363. * Class used to store shared data between 2 NodeMaterialBuildState
  50364. */
  50365. export class NodeMaterialBuildStateSharedData {
  50366. /**
  50367. * Gets the list of emitted varyings
  50368. */
  50369. varyings: string[];
  50370. /**
  50371. * Gets the varying declaration string
  50372. */
  50373. varyingDeclaration: string;
  50374. /**
  50375. * Uniform connection points
  50376. */
  50377. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  50378. /**
  50379. * Bindable blocks (Blocks that need to set data to the effect)
  50380. */
  50381. bindableBlocks: NodeMaterialBlock[];
  50382. /**
  50383. * List of blocks that can provide a compilation fallback
  50384. */
  50385. blocksWithFallbacks: NodeMaterialBlock[];
  50386. /**
  50387. * List of blocks that can provide a define update
  50388. */
  50389. blocksWithDefines: NodeMaterialBlock[];
  50390. /**
  50391. * List of blocks that can provide a repeatable content
  50392. */
  50393. repeatableContentBlocks: NodeMaterialBlock[];
  50394. /**
  50395. * List of blocks that can block the isReady function for the material
  50396. */
  50397. blockingBlocks: NodeMaterialBlock[];
  50398. /**
  50399. * Build Id used to avoid multiple recompilations
  50400. */
  50401. buildId: number;
  50402. /** List of emitted variables */
  50403. variableNames: {
  50404. [key: string]: number;
  50405. };
  50406. /** List of emitted defines */
  50407. defineNames: {
  50408. [key: string]: number;
  50409. };
  50410. /** Should emit comments? */
  50411. emitComments: boolean;
  50412. /** Emit build activity */
  50413. verbose: boolean;
  50414. /**
  50415. * Gets the compilation hints emitted at compilation time
  50416. */
  50417. hints: {
  50418. needWorldViewMatrix: boolean;
  50419. needWorldViewProjectionMatrix: boolean;
  50420. needAlphaBlending: boolean;
  50421. needAlphaTesting: boolean;
  50422. };
  50423. /**
  50424. * List of compilation checks
  50425. */
  50426. checks: {
  50427. emitVertex: boolean;
  50428. emitFragment: boolean;
  50429. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  50430. };
  50431. /** Creates a new shared data */
  50432. constructor();
  50433. /**
  50434. * Emits console errors and exceptions if there is a failing check
  50435. */
  50436. emitErrors(): void;
  50437. }
  50438. }
  50439. declare module BABYLON {
  50440. /**
  50441. * Class used to store node based material build state
  50442. */
  50443. export class NodeMaterialBuildState {
  50444. /**
  50445. * Gets the list of emitted attributes
  50446. */
  50447. attributes: string[];
  50448. /**
  50449. * Gets the list of emitted uniforms
  50450. */
  50451. uniforms: string[];
  50452. /**
  50453. * Gets the list of emitted samplers
  50454. */
  50455. samplers: string[];
  50456. /**
  50457. * Gets the list of emitted functions
  50458. */
  50459. functions: {
  50460. [key: string]: string;
  50461. };
  50462. /**
  50463. * Gets the target of the compilation state
  50464. */
  50465. target: NodeMaterialBlockTargets;
  50466. /**
  50467. * Shared data between multiple NodeMaterialBuildState instances
  50468. */
  50469. sharedData: NodeMaterialBuildStateSharedData;
  50470. /** @hidden */
  50471. _vertexState: NodeMaterialBuildState;
  50472. private _attributeDeclaration;
  50473. private _uniformDeclaration;
  50474. private _samplerDeclaration;
  50475. private _varyingTransfer;
  50476. private _repeatableContentAnchorIndex;
  50477. /** @hidden */
  50478. _builtCompilationString: string;
  50479. /**
  50480. * Gets the emitted compilation strings
  50481. */
  50482. compilationString: string;
  50483. /**
  50484. * Finalize the compilation strings
  50485. * @param state defines the current compilation state
  50486. */
  50487. finalize(state: NodeMaterialBuildState): void;
  50488. /** @hidden */
  50489. readonly _repeatableContentAnchor: string;
  50490. /** @hidden */
  50491. _getFreeVariableName(prefix: string): string;
  50492. /** @hidden */
  50493. _getFreeDefineName(prefix: string): string;
  50494. /** @hidden */
  50495. _excludeVariableName(name: string): void;
  50496. /** @hidden */
  50497. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  50498. /** @hidden */
  50499. _emitFunction(name: string, code: string, comments: string): void;
  50500. /** @hidden */
  50501. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  50502. replaceStrings?: {
  50503. search: RegExp;
  50504. replace: string;
  50505. }[];
  50506. }): string;
  50507. /** @hidden */
  50508. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  50509. repeatKey?: string;
  50510. removeAttributes?: boolean;
  50511. removeUniforms?: boolean;
  50512. removeVaryings?: boolean;
  50513. removeIfDef?: boolean;
  50514. replaceStrings?: {
  50515. search: RegExp;
  50516. replace: string;
  50517. }[];
  50518. }): void;
  50519. /** @hidden */
  50520. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  50521. private _emitDefine;
  50522. /** @hidden */
  50523. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  50524. }
  50525. }
  50526. declare module BABYLON {
  50527. /**
  50528. * Root class for all node material optimizers
  50529. */
  50530. export class NodeMaterialOptimizer {
  50531. /**
  50532. * Function used to optimize a NodeMaterial graph
  50533. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  50534. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  50535. */
  50536. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  50537. }
  50538. }
  50539. declare module BABYLON {
  50540. /**
  50541. * Block used to transform a vector4 with a matrix
  50542. */
  50543. export class Vector4TransformBlock extends NodeMaterialBlock {
  50544. /**
  50545. * Defines the value to use to complement Vector3 to transform it to a Vector4
  50546. */
  50547. complementW: number;
  50548. /**
  50549. * Creates a new Vector4TransformBlock
  50550. * @param name defines the block name
  50551. */
  50552. constructor(name: string);
  50553. /**
  50554. * Gets the current class name
  50555. * @returns the class name
  50556. */
  50557. getClassName(): string;
  50558. /**
  50559. * Gets the vector input
  50560. */
  50561. readonly vector: NodeMaterialConnectionPoint;
  50562. /**
  50563. * Gets the matrix transform input
  50564. */
  50565. readonly transform: NodeMaterialConnectionPoint;
  50566. protected _buildBlock(state: NodeMaterialBuildState): this;
  50567. }
  50568. }
  50569. declare module BABYLON {
  50570. /**
  50571. * Block used to output the vertex position
  50572. */
  50573. export class VertexOutputBlock extends NodeMaterialBlock {
  50574. /**
  50575. * Creates a new VertexOutputBlock
  50576. * @param name defines the block name
  50577. */
  50578. constructor(name: string);
  50579. /**
  50580. * Gets the current class name
  50581. * @returns the class name
  50582. */
  50583. getClassName(): string;
  50584. /**
  50585. * Gets the vector input component
  50586. */
  50587. readonly vector: NodeMaterialConnectionPoint;
  50588. protected _buildBlock(state: NodeMaterialBuildState): this;
  50589. }
  50590. }
  50591. declare module BABYLON {
  50592. /**
  50593. * Block used to output the final color
  50594. */
  50595. export class FragmentOutputBlock extends NodeMaterialBlock {
  50596. /**
  50597. * Gets or sets a boolean indicating if this block will output an alpha value
  50598. */
  50599. alphaBlendingEnabled: boolean;
  50600. /**
  50601. * Create a new FragmentOutputBlock
  50602. * @param name defines the block name
  50603. */
  50604. constructor(name: string);
  50605. /**
  50606. * Gets the current class name
  50607. * @returns the class name
  50608. */
  50609. getClassName(): string;
  50610. /**
  50611. * Gets the color input component
  50612. */
  50613. readonly color: NodeMaterialConnectionPoint;
  50614. protected _buildBlock(state: NodeMaterialBuildState): this;
  50615. }
  50616. }
  50617. declare module BABYLON {
  50618. /**
  50619. * Interface used to configure the node material editor
  50620. */
  50621. export interface INodeMaterialEditorOptions {
  50622. /** Define the URl to load node editor script */
  50623. editorURL?: string;
  50624. }
  50625. /** @hidden */
  50626. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  50627. /** BONES */
  50628. NUM_BONE_INFLUENCERS: number;
  50629. BonesPerMesh: number;
  50630. BONETEXTURE: boolean;
  50631. /** MORPH TARGETS */
  50632. MORPHTARGETS: boolean;
  50633. MORPHTARGETS_NORMAL: boolean;
  50634. MORPHTARGETS_TANGENT: boolean;
  50635. NUM_MORPH_INFLUENCERS: number;
  50636. /** IMAGE PROCESSING */
  50637. IMAGEPROCESSING: boolean;
  50638. VIGNETTE: boolean;
  50639. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50640. VIGNETTEBLENDMODEOPAQUE: boolean;
  50641. TONEMAPPING: boolean;
  50642. TONEMAPPING_ACES: boolean;
  50643. CONTRAST: boolean;
  50644. EXPOSURE: boolean;
  50645. COLORCURVES: boolean;
  50646. COLORGRADING: boolean;
  50647. COLORGRADING3D: boolean;
  50648. SAMPLER3DGREENDEPTH: boolean;
  50649. SAMPLER3DBGRMAP: boolean;
  50650. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50651. constructor();
  50652. setValue(name: string, value: boolean): void;
  50653. }
  50654. /**
  50655. * Class used to configure NodeMaterial
  50656. */
  50657. export interface INodeMaterialOptions {
  50658. /**
  50659. * Defines if blocks should emit comments
  50660. */
  50661. emitComments: boolean;
  50662. }
  50663. /**
  50664. * Class used to create a node based material built by assembling shader blocks
  50665. */
  50666. export class NodeMaterial extends PushMaterial {
  50667. private _options;
  50668. private _vertexCompilationState;
  50669. private _fragmentCompilationState;
  50670. private _sharedData;
  50671. private _buildId;
  50672. private _buildWasSuccessful;
  50673. private _cachedWorldViewMatrix;
  50674. private _cachedWorldViewProjectionMatrix;
  50675. private _textureConnectionPoints;
  50676. private _optimizers;
  50677. /** Define the URl to load node editor script */
  50678. static EditorURL: string;
  50679. private BJSNODEMATERIALEDITOR;
  50680. /** Get the inspector from bundle or global */
  50681. private _getGlobalNodeMaterialEditor;
  50682. /**
  50683. * Defines the maximum number of lights that can be used in the material
  50684. */
  50685. maxSimultaneousLights: number;
  50686. /**
  50687. * Observable raised when the material is built
  50688. */
  50689. onBuildObservable: Observable<NodeMaterial>;
  50690. /**
  50691. * Gets or sets the root nodes of the material vertex shader
  50692. */
  50693. _vertexOutputNodes: NodeMaterialBlock[];
  50694. /**
  50695. * Gets or sets the root nodes of the material fragment (pixel) shader
  50696. */
  50697. _fragmentOutputNodes: NodeMaterialBlock[];
  50698. /** Gets or sets options to control the node material overall behavior */
  50699. options: INodeMaterialOptions;
  50700. /**
  50701. * Default configuration related to image processing available in the standard Material.
  50702. */
  50703. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50704. /**
  50705. * Gets the image processing configuration used either in this material.
  50706. */
  50707. /**
  50708. * Sets the Default image processing configuration used either in the this material.
  50709. *
  50710. * If sets to null, the scene one is in use.
  50711. */
  50712. imageProcessingConfiguration: ImageProcessingConfiguration;
  50713. /**
  50714. * Create a new node based material
  50715. * @param name defines the material name
  50716. * @param scene defines the hosting scene
  50717. * @param options defines creation option
  50718. */
  50719. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  50720. /**
  50721. * Gets the current class name of the material e.g. "NodeMaterial"
  50722. * @returns the class name
  50723. */
  50724. getClassName(): string;
  50725. /**
  50726. * Keep track of the image processing observer to allow dispose and replace.
  50727. */
  50728. private _imageProcessingObserver;
  50729. /**
  50730. * Attaches a new image processing configuration to the Standard Material.
  50731. * @param configuration
  50732. */
  50733. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50734. /**
  50735. * Adds a new optimizer to the list of optimizers
  50736. * @param optimizer defines the optimizers to add
  50737. * @returns the current material
  50738. */
  50739. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  50740. /**
  50741. * Remove an optimizer from the list of optimizers
  50742. * @param optimizer defines the optimizers to remove
  50743. * @returns the current material
  50744. */
  50745. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  50746. /**
  50747. * Add a new block to the list of output nodes
  50748. * @param node defines the node to add
  50749. * @returns the current material
  50750. */
  50751. addOutputNode(node: NodeMaterialBlock): this;
  50752. /**
  50753. * Remove a block from the list of root nodes
  50754. * @param node defines the node to remove
  50755. * @returns the current material
  50756. */
  50757. removeOutputNode(node: NodeMaterialBlock): this;
  50758. private _addVertexOutputNode;
  50759. private _removeVertexOutputNode;
  50760. private _addFragmentOutputNode;
  50761. private _removeFragmentOutputNode;
  50762. /**
  50763. * Specifies if the material will require alpha blending
  50764. * @returns a boolean specifying if alpha blending is needed
  50765. */
  50766. needAlphaBlending(): boolean;
  50767. /**
  50768. * Specifies if this material should be rendered in alpha test mode
  50769. * @returns a boolean specifying if an alpha test is needed.
  50770. */
  50771. needAlphaTesting(): boolean;
  50772. private _initializeBlock;
  50773. private _resetDualBlocks;
  50774. /**
  50775. * Build the material and generates the inner effect
  50776. * @param verbose defines if the build should log activity
  50777. */
  50778. build(verbose?: boolean): void;
  50779. /**
  50780. * Runs an otpimization phase to try to improve the shader code
  50781. */
  50782. optimize(): void;
  50783. private _prepareDefinesForAttributes;
  50784. /**
  50785. * Get if the submesh is ready to be used and all its information available.
  50786. * Child classes can use it to update shaders
  50787. * @param mesh defines the mesh to check
  50788. * @param subMesh defines which submesh to check
  50789. * @param useInstances specifies that instances should be used
  50790. * @returns a boolean indicating that the submesh is ready or not
  50791. */
  50792. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50793. /**
  50794. * Binds the world matrix to the material
  50795. * @param world defines the world transformation matrix
  50796. */
  50797. bindOnlyWorldMatrix(world: Matrix): void;
  50798. /**
  50799. * Binds the submesh to this material by preparing the effect and shader to draw
  50800. * @param world defines the world transformation matrix
  50801. * @param mesh defines the mesh containing the submesh
  50802. * @param subMesh defines the submesh to bind the material to
  50803. */
  50804. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50805. /**
  50806. * Gets the active textures from the material
  50807. * @returns an array of textures
  50808. */
  50809. getActiveTextures(): BaseTexture[];
  50810. /**
  50811. * Specifies if the material uses a texture
  50812. * @param texture defines the texture to check against the material
  50813. * @returns a boolean specifying if the material uses the texture
  50814. */
  50815. hasTexture(texture: BaseTexture): boolean;
  50816. /**
  50817. * Disposes the material
  50818. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  50819. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  50820. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  50821. */
  50822. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  50823. /** Creates the node editor window. */
  50824. private _createNodeEditor;
  50825. /**
  50826. * Launch the node material editor
  50827. * @param config Define the configuration of the editor
  50828. * @return a promise fulfilled when the node editor is visible
  50829. */
  50830. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  50831. /**
  50832. * Clear the current material
  50833. */
  50834. clear(): void;
  50835. /**
  50836. * Clear the current material and set it to a default state
  50837. */
  50838. setToDefault(): void;
  50839. }
  50840. }
  50841. declare module BABYLON {
  50842. /**
  50843. * Defines a block that can be used inside a node based material
  50844. */
  50845. export class NodeMaterialBlock {
  50846. private _buildId;
  50847. private _target;
  50848. private _isFinalMerger;
  50849. /** @hidden */
  50850. _inputs: NodeMaterialConnectionPoint[];
  50851. /** @hidden */
  50852. _outputs: NodeMaterialConnectionPoint[];
  50853. /**
  50854. * Gets or sets the name of the block
  50855. */
  50856. name: string;
  50857. /**
  50858. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  50859. */
  50860. readonly isFinalMerger: boolean;
  50861. /**
  50862. * Gets or sets the build Id
  50863. */
  50864. buildId: number;
  50865. /**
  50866. * Gets or sets the target of the block
  50867. */
  50868. target: NodeMaterialBlockTargets;
  50869. /**
  50870. * Gets the list of input points
  50871. */
  50872. readonly inputs: NodeMaterialConnectionPoint[];
  50873. /** Gets the list of output points */
  50874. readonly outputs: NodeMaterialConnectionPoint[];
  50875. /**
  50876. * Find an input by its name
  50877. * @param name defines the name of the input to look for
  50878. * @returns the input or null if not found
  50879. */
  50880. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  50881. /**
  50882. * Find an output by its name
  50883. * @param name defines the name of the outputto look for
  50884. * @returns the output or null if not found
  50885. */
  50886. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  50887. /**
  50888. * Creates a new NodeMaterialBlock
  50889. * @param name defines the block name
  50890. * @param target defines the target of that block (Vertex by default)
  50891. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  50892. */
  50893. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  50894. /**
  50895. * Initialize the block and prepare the context for build
  50896. * @param state defines the state that will be used for the build
  50897. */
  50898. initialize(state: NodeMaterialBuildState): void;
  50899. /**
  50900. * Bind data to effect. Will only be called for blocks with isBindable === true
  50901. * @param effect defines the effect to bind data to
  50902. * @param nodeMaterial defines the hosting NodeMaterial
  50903. * @param mesh defines the mesh that will be rendered
  50904. */
  50905. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50906. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  50907. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  50908. protected _writeFloat(value: number): string;
  50909. /**
  50910. * Gets the current class name e.g. "NodeMaterialBlock"
  50911. * @returns the class name
  50912. */
  50913. getClassName(): string;
  50914. /**
  50915. * Register a new input. Must be called inside a block constructor
  50916. * @param name defines the connection point name
  50917. * @param type defines the connection point type
  50918. * @param isOptional defines a boolean indicating that this input can be omitted
  50919. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  50920. * @returns the current block
  50921. */
  50922. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  50923. /**
  50924. * Register a new output. Must be called inside a block constructor
  50925. * @param name defines the connection point name
  50926. * @param type defines the connection point type
  50927. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  50928. * @returns the current block
  50929. */
  50930. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  50931. /**
  50932. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  50933. * @param forOutput defines an optional connection point to check compatibility with
  50934. * @returns the first available input or null
  50935. */
  50936. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  50937. /**
  50938. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  50939. * @param forBlock defines an optional block to check compatibility with
  50940. * @returns the first available input or null
  50941. */
  50942. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  50943. /**
  50944. * Connect current block with another block
  50945. * @param other defines the block to connect with
  50946. * @param options define the various options to help pick the right connections
  50947. * @returns the current block
  50948. */
  50949. connectTo(other: NodeMaterialBlock, options?: {
  50950. input?: string;
  50951. output?: string;
  50952. outputSwizzle?: string;
  50953. }): this | undefined;
  50954. protected _buildBlock(state: NodeMaterialBuildState): void;
  50955. /**
  50956. * Add potential fallbacks if shader compilation fails
  50957. * @param mesh defines the mesh to be rendered
  50958. * @param fallbacks defines the current prioritized list of fallbacks
  50959. */
  50960. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  50961. /**
  50962. * Update defines for shader compilation
  50963. * @param mesh defines the mesh to be rendered
  50964. * @param nodeMaterial defines the node material requesting the update
  50965. * @param defines defines the material defines to update
  50966. * @param useInstances specifies that instances should be used
  50967. */
  50968. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  50969. /**
  50970. * Lets the block try to connect some inputs automatically
  50971. */
  50972. autoConfigure(): void;
  50973. /**
  50974. * Function called when a block is declared as repeatable content generator
  50975. * @param vertexShaderState defines the current compilation state for the vertex shader
  50976. * @param fragmentShaderState defines the current compilation state for the fragment shader
  50977. * @param mesh defines the mesh to be rendered
  50978. * @param defines defines the material defines to update
  50979. */
  50980. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  50981. /**
  50982. * Checks if the block is ready
  50983. * @param mesh defines the mesh to be rendered
  50984. * @param nodeMaterial defines the node material requesting the update
  50985. * @param defines defines the material defines to update
  50986. * @param useInstances specifies that instances should be used
  50987. * @returns true if the block is ready
  50988. */
  50989. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  50990. /**
  50991. * Compile the current node and generate the shader code
  50992. * @param state defines the current compilation state (uniforms, samplers, current string)
  50993. * @returns the current block
  50994. */
  50995. build(state: NodeMaterialBuildState): this | undefined;
  50996. }
  50997. }
  50998. declare module BABYLON {
  50999. /**
  51000. * Defines a connection point for a block
  51001. */
  51002. export class NodeMaterialConnectionPoint {
  51003. /** @hidden */
  51004. _ownerBlock: NodeMaterialBlock;
  51005. /** @hidden */
  51006. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51007. private _associatedVariableName;
  51008. private _endpoints;
  51009. private _storedValue;
  51010. private _valueCallback;
  51011. private _mode;
  51012. /** @hidden */
  51013. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51014. /** @hidden */
  51015. _needToEmitVarying: boolean;
  51016. /**
  51017. * Gets or sets the connection point type (default is float)
  51018. */
  51019. type: NodeMaterialBlockConnectionPointTypes;
  51020. /**
  51021. * Gets or sets the connection point name
  51022. */
  51023. name: string;
  51024. /**
  51025. * Gets or sets the swizzle to apply to this connection point when reading or writing
  51026. */
  51027. swizzle: string;
  51028. /**
  51029. * Gets or sets a boolean indicating that this connection point can be omitted
  51030. */
  51031. isOptional: boolean;
  51032. /**
  51033. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  51034. */
  51035. define: string;
  51036. /** Gets or sets the target of that connection point */
  51037. target: NodeMaterialBlockTargets;
  51038. /**
  51039. * Gets or sets the value of that point.
  51040. * Please note that this value will be ignored if valueCallback is defined
  51041. */
  51042. value: any;
  51043. /**
  51044. * Gets or sets a callback used to get the value of that point.
  51045. * Please note that setting this value will force the connection point to ignore the value property
  51046. */
  51047. valueCallback: () => any;
  51048. /**
  51049. * Gets or sets the associated variable name in the shader
  51050. */
  51051. associatedVariableName: string;
  51052. /**
  51053. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  51054. * In this case the connection point name must be the name of the uniform to use.
  51055. * Can only be set on inputs
  51056. */
  51057. isUniform: boolean;
  51058. /**
  51059. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  51060. * In this case the connection point name must be the name of the attribute to use
  51061. * Can only be set on inputs
  51062. */
  51063. isAttribute: boolean;
  51064. /**
  51065. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  51066. * Can only be set on exit points
  51067. */
  51068. isVarying: boolean;
  51069. /** Get the other side of the connection (if any) */
  51070. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51071. /** Get the block that owns this connection point */
  51072. readonly ownerBlock: NodeMaterialBlock;
  51073. /** Get the block connected on the other side of this connection (if any) */
  51074. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  51075. /** Get the block connected on the endpoints of this connection (if any) */
  51076. readonly connectedBlocks: Array<NodeMaterialBlock>;
  51077. /**
  51078. * Creates a new connection point
  51079. * @param name defines the connection point name
  51080. * @param ownerBlock defines the block hosting this connection point
  51081. */
  51082. constructor(name: string, ownerBlock: NodeMaterialBlock);
  51083. /**
  51084. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  51085. * @returns the class name
  51086. */
  51087. getClassName(): string;
  51088. /**
  51089. * Set the source of this connection point to a vertex attribute
  51090. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  51091. * @returns the current connection point
  51092. */
  51093. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  51094. /**
  51095. * Set the source of this connection point to a well known value
  51096. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  51097. * @returns the current connection point
  51098. */
  51099. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  51100. /**
  51101. * Gets a boolean indicating that the current connection point is a well known value
  51102. */
  51103. readonly isWellKnownValue: boolean;
  51104. /**
  51105. * Gets or sets the current well known value or null if not defined as well know value
  51106. */
  51107. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51108. private _getTypeLength;
  51109. /**
  51110. * Connect this point to another connection point
  51111. * @param connectionPoint defines the other connection point
  51112. * @returns the current connection point
  51113. */
  51114. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51115. /**
  51116. * Disconnect this point from one of his endpoint
  51117. * @param endpoint defines the other connection point
  51118. * @returns the current connection point
  51119. */
  51120. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51121. /**
  51122. * When connection point is an uniform, this function will send its value to the effect
  51123. * @param effect defines the effect to transmit value to
  51124. * @param world defines the world matrix
  51125. * @param worldView defines the worldxview matrix
  51126. * @param worldViewProjection defines the worldxviewxprojection matrix
  51127. */
  51128. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  51129. /**
  51130. * When connection point is an uniform, this function will send its value to the effect
  51131. * @param effect defines the effect to transmit value to
  51132. * @param scene defines the hosting scene
  51133. */
  51134. transmit(effect: Effect, scene: Scene): void;
  51135. }
  51136. }
  51137. declare module BABYLON {
  51138. /**
  51139. * Block used to add support for vertex skinning (bones)
  51140. */
  51141. export class BonesBlock extends NodeMaterialBlock {
  51142. /**
  51143. * Creates a new BonesBlock
  51144. * @param name defines the block name
  51145. */
  51146. constructor(name: string);
  51147. /**
  51148. * Initialize the block and prepare the context for build
  51149. * @param state defines the state that will be used for the build
  51150. */
  51151. initialize(state: NodeMaterialBuildState): void;
  51152. /**
  51153. * Gets the current class name
  51154. * @returns the class name
  51155. */
  51156. getClassName(): string;
  51157. /**
  51158. * Gets the matrix indices input component
  51159. */
  51160. readonly matricesIndices: NodeMaterialConnectionPoint;
  51161. /**
  51162. * Gets the matrix weights input component
  51163. */
  51164. readonly matricesWeights: NodeMaterialConnectionPoint;
  51165. /**
  51166. * Gets the extra matrix indices input component
  51167. */
  51168. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  51169. /**
  51170. * Gets the extra matrix weights input component
  51171. */
  51172. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  51173. /**
  51174. * Gets the world input component
  51175. */
  51176. readonly world: NodeMaterialConnectionPoint;
  51177. autoConfigure(): void;
  51178. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51179. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51180. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51181. protected _buildBlock(state: NodeMaterialBuildState): this;
  51182. }
  51183. }
  51184. declare module BABYLON {
  51185. /**
  51186. * Block used to add support for instances
  51187. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  51188. */
  51189. export class InstancesBlock extends NodeMaterialBlock {
  51190. /**
  51191. * Creates a new InstancesBlock
  51192. * @param name defines the block name
  51193. */
  51194. constructor(name: string);
  51195. /**
  51196. * Gets the current class name
  51197. * @returns the class name
  51198. */
  51199. getClassName(): string;
  51200. /**
  51201. * Gets the first world row input component
  51202. */
  51203. readonly world0: NodeMaterialConnectionPoint;
  51204. /**
  51205. * Gets the second world row input component
  51206. */
  51207. readonly world1: NodeMaterialConnectionPoint;
  51208. /**
  51209. * Gets the third world row input component
  51210. */
  51211. readonly world2: NodeMaterialConnectionPoint;
  51212. /**
  51213. * Gets the forth world row input component
  51214. */
  51215. readonly world3: NodeMaterialConnectionPoint;
  51216. /**
  51217. * Gets the world input component
  51218. */
  51219. readonly world: NodeMaterialConnectionPoint;
  51220. /**
  51221. * Gets the output component
  51222. */
  51223. readonly output: NodeMaterialConnectionPoint;
  51224. autoConfigure(): void;
  51225. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51226. protected _buildBlock(state: NodeMaterialBuildState): this;
  51227. }
  51228. }
  51229. declare module BABYLON {
  51230. /**
  51231. * Block used to add morph targets support to vertex shader
  51232. */
  51233. export class MorphTargetsBlock extends NodeMaterialBlock {
  51234. private _repeatableContentAnchor;
  51235. private _repeatebleContentGenerated;
  51236. /**
  51237. * Create a new MorphTargetsBlock
  51238. * @param name defines the block name
  51239. */
  51240. constructor(name: string);
  51241. /**
  51242. * Gets the current class name
  51243. * @returns the class name
  51244. */
  51245. getClassName(): string;
  51246. /**
  51247. * Gets the position input component
  51248. */
  51249. readonly position: NodeMaterialConnectionPoint;
  51250. /**
  51251. * Gets the normal input component
  51252. */
  51253. readonly normal: NodeMaterialConnectionPoint;
  51254. /**
  51255. * Gets the tangent input component
  51256. */
  51257. readonly tangent: NodeMaterialConnectionPoint;
  51258. /**
  51259. * Gets the position output component
  51260. */
  51261. readonly positionOutput: NodeMaterialConnectionPoint;
  51262. /**
  51263. * Gets the normal output component
  51264. */
  51265. readonly normalOutput: NodeMaterialConnectionPoint;
  51266. /**
  51267. * Gets the tangent output component
  51268. */
  51269. readonly tangentOutput: NodeMaterialConnectionPoint;
  51270. initialize(state: NodeMaterialBuildState): void;
  51271. autoConfigure(): void;
  51272. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51273. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51274. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51275. protected _buildBlock(state: NodeMaterialBuildState): this;
  51276. }
  51277. }
  51278. declare module BABYLON {
  51279. /**
  51280. * Block used to add an alpha test in the fragment shader
  51281. */
  51282. export class AlphaTestBlock extends NodeMaterialBlock {
  51283. /**
  51284. * Gets or sets the alpha value where alpha testing happens
  51285. */
  51286. alphaCutOff: number;
  51287. /**
  51288. * Create a new AlphaTestBlock
  51289. * @param name defines the block name
  51290. */
  51291. constructor(name: string);
  51292. /**
  51293. * Gets the current class name
  51294. * @returns the class name
  51295. */
  51296. getClassName(): string;
  51297. /**
  51298. * Gets the color input component
  51299. */
  51300. readonly color: NodeMaterialConnectionPoint;
  51301. protected _buildBlock(state: NodeMaterialBuildState): this;
  51302. }
  51303. }
  51304. declare module BABYLON {
  51305. /**
  51306. * Block used to create a Color4 out of 4 inputs (one for each component)
  51307. */
  51308. export class RGBAMergerBlock extends NodeMaterialBlock {
  51309. /**
  51310. * Create a new RGBAMergerBlock
  51311. * @param name defines the block name
  51312. */
  51313. constructor(name: string);
  51314. /**
  51315. * Gets the current class name
  51316. * @returns the class name
  51317. */
  51318. getClassName(): string;
  51319. /**
  51320. * Gets the R input component
  51321. */
  51322. readonly r: NodeMaterialConnectionPoint;
  51323. /**
  51324. * Gets the G input component
  51325. */
  51326. readonly g: NodeMaterialConnectionPoint;
  51327. /**
  51328. * Gets the B input component
  51329. */
  51330. readonly b: NodeMaterialConnectionPoint;
  51331. /**
  51332. * Gets the RGB input component
  51333. */
  51334. readonly rgb: NodeMaterialConnectionPoint;
  51335. /**
  51336. * Gets the R input component
  51337. */
  51338. readonly a: NodeMaterialConnectionPoint;
  51339. protected _buildBlock(state: NodeMaterialBuildState): this;
  51340. }
  51341. }
  51342. declare module BABYLON {
  51343. /**
  51344. * Block used to create a Color3 out of 3 inputs (one for each component)
  51345. */
  51346. export class RGBMergerBlock extends NodeMaterialBlock {
  51347. /**
  51348. * Create a new RGBMergerBlock
  51349. * @param name defines the block name
  51350. */
  51351. constructor(name: string);
  51352. /**
  51353. * Gets the current class name
  51354. * @returns the class name
  51355. */
  51356. getClassName(): string;
  51357. /**
  51358. * Gets the R component input
  51359. */
  51360. readonly r: NodeMaterialConnectionPoint;
  51361. /**
  51362. * Gets the G component input
  51363. */
  51364. readonly g: NodeMaterialConnectionPoint;
  51365. /**
  51366. * Gets the B component input
  51367. */
  51368. readonly b: NodeMaterialConnectionPoint;
  51369. protected _buildBlock(state: NodeMaterialBuildState): this;
  51370. }
  51371. }
  51372. declare module BABYLON {
  51373. /**
  51374. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  51375. */
  51376. export class RGBASplitterBlock extends NodeMaterialBlock {
  51377. /**
  51378. * Create a new RGBASplitterBlock
  51379. * @param name defines the block name
  51380. */
  51381. constructor(name: string);
  51382. /**
  51383. * Gets the current class name
  51384. * @returns the class name
  51385. */
  51386. getClassName(): string;
  51387. /**
  51388. * Gets the input component
  51389. */
  51390. readonly input: NodeMaterialConnectionPoint;
  51391. protected _buildBlock(state: NodeMaterialBuildState): this;
  51392. }
  51393. }
  51394. declare module BABYLON {
  51395. /**
  51396. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  51397. */
  51398. export class RGBSplitterBlock extends NodeMaterialBlock {
  51399. /**
  51400. * Create a new RGBSplitterBlock
  51401. * @param name defines the block name
  51402. */
  51403. constructor(name: string);
  51404. /**
  51405. * Gets the current class name
  51406. * @returns the class name
  51407. */
  51408. getClassName(): string;
  51409. /**
  51410. * Gets the input component
  51411. */
  51412. readonly input: NodeMaterialConnectionPoint;
  51413. protected _buildBlock(state: NodeMaterialBuildState): this;
  51414. }
  51415. }
  51416. declare module BABYLON {
  51417. /**
  51418. * Block used to read a texture from a sampler
  51419. */
  51420. export class TextureBlock extends NodeMaterialBlock {
  51421. private _defineName;
  51422. /**
  51423. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  51424. */
  51425. autoConnectTextureMatrix: boolean;
  51426. /**
  51427. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  51428. */
  51429. autoSelectUV: boolean;
  51430. /**
  51431. * Create a new TextureBlock
  51432. * @param name defines the block name
  51433. */
  51434. constructor(name: string);
  51435. /**
  51436. * Gets the current class name
  51437. * @returns the class name
  51438. */
  51439. getClassName(): string;
  51440. /**
  51441. * Gets the uv input component
  51442. */
  51443. readonly uv: NodeMaterialConnectionPoint;
  51444. /**
  51445. * Gets the texture information input component
  51446. */
  51447. readonly textureInfo: NodeMaterialConnectionPoint;
  51448. /**
  51449. * Gets the transformed uv input component
  51450. */
  51451. readonly transformedUV: NodeMaterialConnectionPoint;
  51452. /**
  51453. * Gets the texture input component
  51454. */
  51455. readonly texture: NodeMaterialConnectionPoint;
  51456. /**
  51457. * Gets the texture transform input component
  51458. */
  51459. readonly textureTransform: NodeMaterialConnectionPoint;
  51460. autoConfigure(): void;
  51461. initialize(state: NodeMaterialBuildState): void;
  51462. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51463. isReady(): boolean;
  51464. private _injectVertexCode;
  51465. protected _buildBlock(state: NodeMaterialBuildState): this;
  51466. }
  51467. }
  51468. declare module BABYLON {
  51469. /**
  51470. * Block used to add image processing support to fragment shader
  51471. */
  51472. export class ImageProcessingBlock extends NodeMaterialBlock {
  51473. /**
  51474. * Create a new ImageProcessingBlock
  51475. * @param name defines the block name
  51476. */
  51477. constructor(name: string);
  51478. /**
  51479. * Gets the current class name
  51480. * @returns the class name
  51481. */
  51482. getClassName(): string;
  51483. /**
  51484. * Gets the color input component
  51485. */
  51486. readonly color: NodeMaterialConnectionPoint;
  51487. /**
  51488. * Initialize the block and prepare the context for build
  51489. * @param state defines the state that will be used for the build
  51490. */
  51491. initialize(state: NodeMaterialBuildState): void;
  51492. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  51493. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51494. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51495. protected _buildBlock(state: NodeMaterialBuildState): this;
  51496. }
  51497. }
  51498. declare module BABYLON {
  51499. /**
  51500. * Block used to add support for scene fog
  51501. */
  51502. export class FogBlock extends NodeMaterialBlock {
  51503. /**
  51504. * Create a new FogBlock
  51505. * @param name defines the block name
  51506. */
  51507. constructor(name: string);
  51508. /**
  51509. * Gets the current class name
  51510. * @returns the class name
  51511. */
  51512. getClassName(): string;
  51513. /**
  51514. * Gets the world position input component
  51515. */
  51516. readonly worldPosition: NodeMaterialConnectionPoint;
  51517. /**
  51518. * Gets the view input component
  51519. */
  51520. readonly view: NodeMaterialConnectionPoint;
  51521. /**
  51522. * Gets the color input component
  51523. */
  51524. readonly color: NodeMaterialConnectionPoint;
  51525. /**
  51526. * Gets the fog color input component
  51527. */
  51528. readonly fogColor: NodeMaterialConnectionPoint;
  51529. /**
  51530. * Gets the for parameter input component
  51531. */
  51532. readonly fogParameters: NodeMaterialConnectionPoint;
  51533. autoConfigure(): void;
  51534. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51535. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51536. protected _buildBlock(state: NodeMaterialBuildState): this;
  51537. }
  51538. }
  51539. declare module BABYLON {
  51540. /**
  51541. * Block used to multiply 2 vector4
  51542. */
  51543. export class MultiplyBlock extends NodeMaterialBlock {
  51544. /**
  51545. * Creates a new MultiplyBlock
  51546. * @param name defines the block name
  51547. */
  51548. constructor(name: string);
  51549. /**
  51550. * Gets the current class name
  51551. * @returns the class name
  51552. */
  51553. getClassName(): string;
  51554. /**
  51555. * Gets the left operand input component
  51556. */
  51557. readonly left: NodeMaterialConnectionPoint;
  51558. /**
  51559. * Gets the right operand input component
  51560. */
  51561. readonly right: NodeMaterialConnectionPoint;
  51562. protected _buildBlock(state: NodeMaterialBuildState): this;
  51563. }
  51564. }
  51565. declare module BABYLON {
  51566. /**
  51567. * Block used to add 2 vector4
  51568. */
  51569. export class AddBlock extends NodeMaterialBlock {
  51570. /**
  51571. * Creates a new AddBlock
  51572. * @param name defines the block name
  51573. */
  51574. constructor(name: string);
  51575. /**
  51576. * Gets the current class name
  51577. * @returns the class name
  51578. */
  51579. getClassName(): string;
  51580. /**
  51581. * Gets the left operand input component
  51582. */
  51583. readonly left: NodeMaterialConnectionPoint;
  51584. /**
  51585. * Gets the right operand input component
  51586. */
  51587. readonly right: NodeMaterialConnectionPoint;
  51588. protected _buildBlock(state: NodeMaterialBuildState): this;
  51589. }
  51590. }
  51591. declare module BABYLON {
  51592. /**
  51593. * Block used to clamp a float
  51594. */
  51595. export class ClampBlock extends NodeMaterialBlock {
  51596. /** Gets or sets the minimum range */
  51597. minimum: number;
  51598. /** Gets or sets the maximum range */
  51599. maximum: number;
  51600. /**
  51601. * Creates a new ClampBlock
  51602. * @param name defines the block name
  51603. */
  51604. constructor(name: string);
  51605. /**
  51606. * Gets the current class name
  51607. * @returns the class name
  51608. */
  51609. getClassName(): string;
  51610. /**
  51611. * Gets the value input component
  51612. */
  51613. readonly value: NodeMaterialConnectionPoint;
  51614. protected _buildBlock(state: NodeMaterialBuildState): this;
  51615. }
  51616. }
  51617. declare module BABYLON {
  51618. /**
  51619. * Block used to transform a vector2 with a matrix
  51620. */
  51621. export class Vector2TransformBlock extends NodeMaterialBlock {
  51622. /**
  51623. * Defines the value to use to complement Vector2 to transform it to a Vector4
  51624. */
  51625. complementZ: number;
  51626. /**
  51627. * Defines the value to use to complement Vector2 to transform it to a Vector4
  51628. */
  51629. complementW: number;
  51630. /**
  51631. * Creates a new Vector2TransformBlock
  51632. * @param name defines the block name
  51633. */
  51634. constructor(name: string);
  51635. /**
  51636. * Gets the vector input
  51637. */
  51638. readonly vector: NodeMaterialConnectionPoint;
  51639. /**
  51640. * Gets the matrix transform input
  51641. */
  51642. readonly transform: NodeMaterialConnectionPoint;
  51643. /**
  51644. * Gets the current class name
  51645. * @returns the class name
  51646. */
  51647. getClassName(): string;
  51648. protected _buildBlock(state: NodeMaterialBuildState): this;
  51649. }
  51650. }
  51651. declare module BABYLON {
  51652. /**
  51653. * Block used to transform a vector3 with a matrix
  51654. */
  51655. export class Vector3TransformBlock extends NodeMaterialBlock {
  51656. /**
  51657. * Defines the value to use to complement Vector3 to transform it to a Vector4
  51658. */
  51659. complement: number;
  51660. /**
  51661. * Creates a new Vector3TransformBlock
  51662. * @param name defines the block name
  51663. */
  51664. constructor(name: string);
  51665. /**
  51666. * Gets the vector input
  51667. */
  51668. readonly vector: NodeMaterialConnectionPoint;
  51669. /**
  51670. * Gets the matrix transform input
  51671. */
  51672. readonly transform: NodeMaterialConnectionPoint;
  51673. /**
  51674. * Gets the current class name
  51675. * @returns the class name
  51676. */
  51677. getClassName(): string;
  51678. protected _buildBlock(state: NodeMaterialBuildState): this;
  51679. }
  51680. }
  51681. declare module BABYLON {
  51682. /**
  51683. * Block used to multiply two matrices
  51684. */
  51685. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  51686. /**
  51687. * Creates a new MatrixMultiplicationBlock
  51688. * @param name defines the block name
  51689. */
  51690. constructor(name: string);
  51691. /**
  51692. * Gets the left operand
  51693. */
  51694. readonly left: NodeMaterialConnectionPoint;
  51695. /**
  51696. * Gets the right operand
  51697. */
  51698. readonly right: NodeMaterialConnectionPoint;
  51699. /**
  51700. * Gets the current class name
  51701. * @returns the class name
  51702. */
  51703. getClassName(): string;
  51704. protected _buildBlock(state: NodeMaterialBuildState): this;
  51705. }
  51706. }
  51707. declare module BABYLON {
  51708. /**
  51709. * Helper class to push actions to a pool of workers.
  51710. */
  51711. export class WorkerPool implements IDisposable {
  51712. private _workerInfos;
  51713. private _pendingActions;
  51714. /**
  51715. * Constructor
  51716. * @param workers Array of workers to use for actions
  51717. */
  51718. constructor(workers: Array<Worker>);
  51719. /**
  51720. * Terminates all workers and clears any pending actions.
  51721. */
  51722. dispose(): void;
  51723. /**
  51724. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51725. * pended until a worker has completed its action.
  51726. * @param action The action to perform. Call onComplete when the action is complete.
  51727. */
  51728. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51729. private _execute;
  51730. }
  51731. }
  51732. declare module BABYLON {
  51733. /**
  51734. * Configuration for Draco compression
  51735. */
  51736. export interface IDracoCompressionConfiguration {
  51737. /**
  51738. * Configuration for the decoder.
  51739. */
  51740. decoder: {
  51741. /**
  51742. * The url to the WebAssembly module.
  51743. */
  51744. wasmUrl?: string;
  51745. /**
  51746. * The url to the WebAssembly binary.
  51747. */
  51748. wasmBinaryUrl?: string;
  51749. /**
  51750. * The url to the fallback JavaScript module.
  51751. */
  51752. fallbackUrl?: string;
  51753. };
  51754. }
  51755. /**
  51756. * Draco compression (https://google.github.io/draco/)
  51757. *
  51758. * This class wraps the Draco module.
  51759. *
  51760. * **Encoder**
  51761. *
  51762. * The encoder is not currently implemented.
  51763. *
  51764. * **Decoder**
  51765. *
  51766. * 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.
  51767. *
  51768. * To update the configuration, use the following code:
  51769. * ```javascript
  51770. * DracoCompression.Configuration = {
  51771. * decoder: {
  51772. * wasmUrl: "<url to the WebAssembly library>",
  51773. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51774. * fallbackUrl: "<url to the fallback JavaScript library>",
  51775. * }
  51776. * };
  51777. * ```
  51778. *
  51779. * 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.
  51780. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51781. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  51782. *
  51783. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  51784. * ```javascript
  51785. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  51786. * ```
  51787. *
  51788. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51789. */
  51790. export class DracoCompression implements IDisposable {
  51791. private _workerPoolPromise?;
  51792. private _decoderModulePromise?;
  51793. /**
  51794. * The configuration. Defaults to the following urls:
  51795. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51796. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51797. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51798. */
  51799. static Configuration: IDracoCompressionConfiguration;
  51800. /**
  51801. * Returns true if the decoder configuration is available.
  51802. */
  51803. static readonly DecoderAvailable: boolean;
  51804. /**
  51805. * Default number of workers to create when creating the draco compression object.
  51806. */
  51807. static DefaultNumWorkers: number;
  51808. private static GetDefaultNumWorkers;
  51809. private static _Default;
  51810. /**
  51811. * Default instance for the draco compression object.
  51812. */
  51813. static readonly Default: DracoCompression;
  51814. /**
  51815. * Constructor
  51816. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  51817. */
  51818. constructor(numWorkers?: number);
  51819. /**
  51820. * Stop all async operations and release resources.
  51821. */
  51822. dispose(): void;
  51823. /**
  51824. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  51825. * @returns a promise that resolves when ready
  51826. */
  51827. whenReadyAsync(): Promise<void>;
  51828. /**
  51829. * Decode Draco compressed mesh data to vertex data.
  51830. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51831. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51832. * @returns A promise that resolves with the decoded vertex data
  51833. */
  51834. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  51835. [kind: string]: number;
  51836. }): Promise<VertexData>;
  51837. }
  51838. }
  51839. declare module BABYLON {
  51840. /**
  51841. * Class for building Constructive Solid Geometry
  51842. */
  51843. export class CSG {
  51844. private polygons;
  51845. /**
  51846. * The world matrix
  51847. */
  51848. matrix: Matrix;
  51849. /**
  51850. * Stores the position
  51851. */
  51852. position: Vector3;
  51853. /**
  51854. * Stores the rotation
  51855. */
  51856. rotation: Vector3;
  51857. /**
  51858. * Stores the rotation quaternion
  51859. */
  51860. rotationQuaternion: Nullable<Quaternion>;
  51861. /**
  51862. * Stores the scaling vector
  51863. */
  51864. scaling: Vector3;
  51865. /**
  51866. * Convert the Mesh to CSG
  51867. * @param mesh The Mesh to convert to CSG
  51868. * @returns A new CSG from the Mesh
  51869. */
  51870. static FromMesh(mesh: Mesh): CSG;
  51871. /**
  51872. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  51873. * @param polygons Polygons used to construct a CSG solid
  51874. */
  51875. private static FromPolygons;
  51876. /**
  51877. * Clones, or makes a deep copy, of the CSG
  51878. * @returns A new CSG
  51879. */
  51880. clone(): CSG;
  51881. /**
  51882. * Unions this CSG with another CSG
  51883. * @param csg The CSG to union against this CSG
  51884. * @returns The unioned CSG
  51885. */
  51886. union(csg: CSG): CSG;
  51887. /**
  51888. * Unions this CSG with another CSG in place
  51889. * @param csg The CSG to union against this CSG
  51890. */
  51891. unionInPlace(csg: CSG): void;
  51892. /**
  51893. * Subtracts this CSG with another CSG
  51894. * @param csg The CSG to subtract against this CSG
  51895. * @returns A new CSG
  51896. */
  51897. subtract(csg: CSG): CSG;
  51898. /**
  51899. * Subtracts this CSG with another CSG in place
  51900. * @param csg The CSG to subtact against this CSG
  51901. */
  51902. subtractInPlace(csg: CSG): void;
  51903. /**
  51904. * Intersect this CSG with another CSG
  51905. * @param csg The CSG to intersect against this CSG
  51906. * @returns A new CSG
  51907. */
  51908. intersect(csg: CSG): CSG;
  51909. /**
  51910. * Intersects this CSG with another CSG in place
  51911. * @param csg The CSG to intersect against this CSG
  51912. */
  51913. intersectInPlace(csg: CSG): void;
  51914. /**
  51915. * Return a new CSG solid with solid and empty space switched. This solid is
  51916. * not modified.
  51917. * @returns A new CSG solid with solid and empty space switched
  51918. */
  51919. inverse(): CSG;
  51920. /**
  51921. * Inverses the CSG in place
  51922. */
  51923. inverseInPlace(): void;
  51924. /**
  51925. * This is used to keep meshes transformations so they can be restored
  51926. * when we build back a Babylon Mesh
  51927. * NB : All CSG operations are performed in world coordinates
  51928. * @param csg The CSG to copy the transform attributes from
  51929. * @returns This CSG
  51930. */
  51931. copyTransformAttributes(csg: CSG): CSG;
  51932. /**
  51933. * Build Raw mesh from CSG
  51934. * Coordinates here are in world space
  51935. * @param name The name of the mesh geometry
  51936. * @param scene The Scene
  51937. * @param keepSubMeshes Specifies if the submeshes should be kept
  51938. * @returns A new Mesh
  51939. */
  51940. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  51941. /**
  51942. * Build Mesh from CSG taking material and transforms into account
  51943. * @param name The name of the Mesh
  51944. * @param material The material of the Mesh
  51945. * @param scene The Scene
  51946. * @param keepSubMeshes Specifies if submeshes should be kept
  51947. * @returns The new Mesh
  51948. */
  51949. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  51950. }
  51951. }
  51952. declare module BABYLON {
  51953. /**
  51954. * Class used to create a trail following a mesh
  51955. */
  51956. export class TrailMesh extends Mesh {
  51957. private _generator;
  51958. private _autoStart;
  51959. private _running;
  51960. private _diameter;
  51961. private _length;
  51962. private _sectionPolygonPointsCount;
  51963. private _sectionVectors;
  51964. private _sectionNormalVectors;
  51965. private _beforeRenderObserver;
  51966. /**
  51967. * @constructor
  51968. * @param name The value used by scene.getMeshByName() to do a lookup.
  51969. * @param generator The mesh to generate a trail.
  51970. * @param scene The scene to add this mesh to.
  51971. * @param diameter Diameter of trailing mesh. Default is 1.
  51972. * @param length Length of trailing mesh. Default is 60.
  51973. * @param autoStart Automatically start trailing mesh. Default true.
  51974. */
  51975. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  51976. /**
  51977. * "TrailMesh"
  51978. * @returns "TrailMesh"
  51979. */
  51980. getClassName(): string;
  51981. private _createMesh;
  51982. /**
  51983. * Start trailing mesh.
  51984. */
  51985. start(): void;
  51986. /**
  51987. * Stop trailing mesh.
  51988. */
  51989. stop(): void;
  51990. /**
  51991. * Update trailing mesh geometry.
  51992. */
  51993. update(): void;
  51994. /**
  51995. * Returns a new TrailMesh object.
  51996. * @param name is a string, the name given to the new mesh
  51997. * @param newGenerator use new generator object for cloned trail mesh
  51998. * @returns a new mesh
  51999. */
  52000. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52001. /**
  52002. * Serializes this trail mesh
  52003. * @param serializationObject object to write serialization to
  52004. */
  52005. serialize(serializationObject: any): void;
  52006. /**
  52007. * Parses a serialized trail mesh
  52008. * @param parsedMesh the serialized mesh
  52009. * @param scene the scene to create the trail mesh in
  52010. * @returns the created trail mesh
  52011. */
  52012. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52013. }
  52014. }
  52015. declare module BABYLON {
  52016. /**
  52017. * Class containing static functions to help procedurally build meshes
  52018. */
  52019. export class TiledBoxBuilder {
  52020. /**
  52021. * Creates a box mesh
  52022. * 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)
  52023. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52025. * * 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
  52026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52027. * @param name defines the name of the mesh
  52028. * @param options defines the options used to create the mesh
  52029. * @param scene defines the hosting scene
  52030. * @returns the box mesh
  52031. */
  52032. static CreateTiledBox(name: string, options: {
  52033. pattern?: number;
  52034. width?: number;
  52035. height?: number;
  52036. depth?: number;
  52037. tileSize?: number;
  52038. tileWidth?: number;
  52039. tileHeight?: number;
  52040. alignHorizontal?: number;
  52041. alignVertical?: number;
  52042. faceUV?: Vector4[];
  52043. faceColors?: Color4[];
  52044. sideOrientation?: number;
  52045. updatable?: boolean;
  52046. }, scene?: Nullable<Scene>): Mesh;
  52047. }
  52048. }
  52049. declare module BABYLON {
  52050. /**
  52051. * Class containing static functions to help procedurally build meshes
  52052. */
  52053. export class TorusKnotBuilder {
  52054. /**
  52055. * Creates a torus knot mesh
  52056. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52057. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52058. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52059. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52061. * * 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
  52062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52063. * @param name defines the name of the mesh
  52064. * @param options defines the options used to create the mesh
  52065. * @param scene defines the hosting scene
  52066. * @returns the torus knot mesh
  52067. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52068. */
  52069. static CreateTorusKnot(name: string, options: {
  52070. radius?: number;
  52071. tube?: number;
  52072. radialSegments?: number;
  52073. tubularSegments?: number;
  52074. p?: number;
  52075. q?: number;
  52076. updatable?: boolean;
  52077. sideOrientation?: number;
  52078. frontUVs?: Vector4;
  52079. backUVs?: Vector4;
  52080. }, scene: any): Mesh;
  52081. }
  52082. }
  52083. declare module BABYLON {
  52084. /**
  52085. * Polygon
  52086. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52087. */
  52088. export class Polygon {
  52089. /**
  52090. * Creates a rectangle
  52091. * @param xmin bottom X coord
  52092. * @param ymin bottom Y coord
  52093. * @param xmax top X coord
  52094. * @param ymax top Y coord
  52095. * @returns points that make the resulting rectation
  52096. */
  52097. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52098. /**
  52099. * Creates a circle
  52100. * @param radius radius of circle
  52101. * @param cx scale in x
  52102. * @param cy scale in y
  52103. * @param numberOfSides number of sides that make up the circle
  52104. * @returns points that make the resulting circle
  52105. */
  52106. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52107. /**
  52108. * Creates a polygon from input string
  52109. * @param input Input polygon data
  52110. * @returns the parsed points
  52111. */
  52112. static Parse(input: string): Vector2[];
  52113. /**
  52114. * Starts building a polygon from x and y coordinates
  52115. * @param x x coordinate
  52116. * @param y y coordinate
  52117. * @returns the started path2
  52118. */
  52119. static StartingAt(x: number, y: number): Path2;
  52120. }
  52121. /**
  52122. * Builds a polygon
  52123. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52124. */
  52125. export class PolygonMeshBuilder {
  52126. private _points;
  52127. private _outlinepoints;
  52128. private _holes;
  52129. private _name;
  52130. private _scene;
  52131. private _epoints;
  52132. private _eholes;
  52133. private _addToepoint;
  52134. /**
  52135. * Babylon reference to the earcut plugin.
  52136. */
  52137. bjsEarcut: any;
  52138. /**
  52139. * Creates a PolygonMeshBuilder
  52140. * @param name name of the builder
  52141. * @param contours Path of the polygon
  52142. * @param scene scene to add to when creating the mesh
  52143. * @param earcutInjection can be used to inject your own earcut reference
  52144. */
  52145. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52146. /**
  52147. * Adds a whole within the polygon
  52148. * @param hole Array of points defining the hole
  52149. * @returns this
  52150. */
  52151. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52152. /**
  52153. * Creates the polygon
  52154. * @param updatable If the mesh should be updatable
  52155. * @param depth The depth of the mesh created
  52156. * @returns the created mesh
  52157. */
  52158. build(updatable?: boolean, depth?: number): Mesh;
  52159. /**
  52160. * Creates the polygon
  52161. * @param depth The depth of the mesh created
  52162. * @returns the created VertexData
  52163. */
  52164. buildVertexData(depth?: number): VertexData;
  52165. /**
  52166. * Adds a side to the polygon
  52167. * @param positions points that make the polygon
  52168. * @param normals normals of the polygon
  52169. * @param uvs uvs of the polygon
  52170. * @param indices indices of the polygon
  52171. * @param bounds bounds of the polygon
  52172. * @param points points of the polygon
  52173. * @param depth depth of the polygon
  52174. * @param flip flip of the polygon
  52175. */
  52176. private addSide;
  52177. }
  52178. }
  52179. declare module BABYLON {
  52180. /**
  52181. * Class containing static functions to help procedurally build meshes
  52182. */
  52183. export class PolygonBuilder {
  52184. /**
  52185. * Creates a polygon mesh
  52186. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52187. * * 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
  52188. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52190. * * 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)
  52191. * * Remember you can only change the shape positions, not their number when updating a polygon
  52192. * @param name defines the name of the mesh
  52193. * @param options defines the options used to create the mesh
  52194. * @param scene defines the hosting scene
  52195. * @param earcutInjection can be used to inject your own earcut reference
  52196. * @returns the polygon mesh
  52197. */
  52198. static CreatePolygon(name: string, options: {
  52199. shape: Vector3[];
  52200. holes?: Vector3[][];
  52201. depth?: number;
  52202. faceUV?: Vector4[];
  52203. faceColors?: Color4[];
  52204. updatable?: boolean;
  52205. sideOrientation?: number;
  52206. frontUVs?: Vector4;
  52207. backUVs?: Vector4;
  52208. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52209. /**
  52210. * Creates an extruded polygon mesh, with depth in the Y direction.
  52211. * * 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)
  52212. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52213. * @param name defines the name of the mesh
  52214. * @param options defines the options used to create the mesh
  52215. * @param scene defines the hosting scene
  52216. * @param earcutInjection can be used to inject your own earcut reference
  52217. * @returns the polygon mesh
  52218. */
  52219. static ExtrudePolygon(name: string, options: {
  52220. shape: Vector3[];
  52221. holes?: Vector3[][];
  52222. depth?: number;
  52223. faceUV?: Vector4[];
  52224. faceColors?: Color4[];
  52225. updatable?: boolean;
  52226. sideOrientation?: number;
  52227. frontUVs?: Vector4;
  52228. backUVs?: Vector4;
  52229. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52230. }
  52231. }
  52232. declare module BABYLON {
  52233. /**
  52234. * Class containing static functions to help procedurally build meshes
  52235. */
  52236. export class LatheBuilder {
  52237. /**
  52238. * Creates lathe mesh.
  52239. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52240. * * 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
  52241. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52242. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52243. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52244. * * 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
  52245. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52246. * * 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
  52247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52248. * * 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
  52249. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52251. * @param name defines the name of the mesh
  52252. * @param options defines the options used to create the mesh
  52253. * @param scene defines the hosting scene
  52254. * @returns the lathe mesh
  52255. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52256. */
  52257. static CreateLathe(name: string, options: {
  52258. shape: Vector3[];
  52259. radius?: number;
  52260. tessellation?: number;
  52261. clip?: number;
  52262. arc?: number;
  52263. closed?: boolean;
  52264. updatable?: boolean;
  52265. sideOrientation?: number;
  52266. frontUVs?: Vector4;
  52267. backUVs?: Vector4;
  52268. cap?: number;
  52269. invertUV?: boolean;
  52270. }, scene?: Nullable<Scene>): Mesh;
  52271. }
  52272. }
  52273. declare module BABYLON {
  52274. /**
  52275. * Class containing static functions to help procedurally build meshes
  52276. */
  52277. export class TiledPlaneBuilder {
  52278. /**
  52279. * Creates a tiled plane mesh
  52280. * * The parameter `pattern` will, depending on value, do nothing or
  52281. * * * flip (reflect about central vertical) alternate tiles across and up
  52282. * * * flip every tile on alternate rows
  52283. * * * rotate (180 degs) alternate tiles across and up
  52284. * * * rotate every tile on alternate rows
  52285. * * * flip and rotate alternate tiles across and up
  52286. * * * flip and rotate every tile on alternate rows
  52287. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  52288. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  52289. * * 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
  52290. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52291. * * 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)
  52292. * * 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)
  52293. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52294. * @param name defines the name of the mesh
  52295. * @param options defines the options used to create the mesh
  52296. * @param scene defines the hosting scene
  52297. * @returns the box mesh
  52298. */
  52299. static CreateTiledPlane(name: string, options: {
  52300. pattern?: number;
  52301. tileSize?: number;
  52302. tileWidth?: number;
  52303. tileHeight?: number;
  52304. size?: number;
  52305. width?: number;
  52306. height?: number;
  52307. alignHorizontal?: number;
  52308. alignVertical?: number;
  52309. sideOrientation?: number;
  52310. frontUVs?: Vector4;
  52311. backUVs?: Vector4;
  52312. updatable?: boolean;
  52313. }, scene?: Nullable<Scene>): Mesh;
  52314. }
  52315. }
  52316. declare module BABYLON {
  52317. /**
  52318. * Class containing static functions to help procedurally build meshes
  52319. */
  52320. export class TubeBuilder {
  52321. /**
  52322. * Creates a tube mesh.
  52323. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52324. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52325. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52326. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52327. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52328. * * 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)
  52329. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52330. * * 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
  52331. * * 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
  52332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52333. * * 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
  52334. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52336. * @param name defines the name of the mesh
  52337. * @param options defines the options used to create the mesh
  52338. * @param scene defines the hosting scene
  52339. * @returns the tube mesh
  52340. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52341. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52342. */
  52343. static CreateTube(name: string, options: {
  52344. path: Vector3[];
  52345. radius?: number;
  52346. tessellation?: number;
  52347. radiusFunction?: {
  52348. (i: number, distance: number): number;
  52349. };
  52350. cap?: number;
  52351. arc?: number;
  52352. updatable?: boolean;
  52353. sideOrientation?: number;
  52354. frontUVs?: Vector4;
  52355. backUVs?: Vector4;
  52356. instance?: Mesh;
  52357. invertUV?: boolean;
  52358. }, scene?: Nullable<Scene>): Mesh;
  52359. }
  52360. }
  52361. declare module BABYLON {
  52362. /**
  52363. * Class containing static functions to help procedurally build meshes
  52364. */
  52365. export class IcoSphereBuilder {
  52366. /**
  52367. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52368. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52369. * * 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`)
  52370. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52371. * * 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
  52372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52373. * * 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
  52374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52375. * @param name defines the name of the mesh
  52376. * @param options defines the options used to create the mesh
  52377. * @param scene defines the hosting scene
  52378. * @returns the icosahedron mesh
  52379. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52380. */
  52381. static CreateIcoSphere(name: string, options: {
  52382. radius?: number;
  52383. radiusX?: number;
  52384. radiusY?: number;
  52385. radiusZ?: number;
  52386. flat?: boolean;
  52387. subdivisions?: number;
  52388. sideOrientation?: number;
  52389. frontUVs?: Vector4;
  52390. backUVs?: Vector4;
  52391. updatable?: boolean;
  52392. }, scene?: Nullable<Scene>): Mesh;
  52393. }
  52394. }
  52395. declare module BABYLON {
  52396. /**
  52397. * Class containing static functions to help procedurally build meshes
  52398. */
  52399. export class DecalBuilder {
  52400. /**
  52401. * Creates a decal mesh.
  52402. * 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
  52403. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52404. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52405. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52406. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52407. * @param name defines the name of the mesh
  52408. * @param sourceMesh defines the mesh where the decal must be applied
  52409. * @param options defines the options used to create the mesh
  52410. * @param scene defines the hosting scene
  52411. * @returns the decal mesh
  52412. * @see https://doc.babylonjs.com/how_to/decals
  52413. */
  52414. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52415. position?: Vector3;
  52416. normal?: Vector3;
  52417. size?: Vector3;
  52418. angle?: number;
  52419. }): Mesh;
  52420. }
  52421. }
  52422. declare module BABYLON {
  52423. /**
  52424. * Class containing static functions to help procedurally build meshes
  52425. */
  52426. export class MeshBuilder {
  52427. /**
  52428. * Creates a box mesh
  52429. * * The parameter `size` sets the size (float) of each box side (default 1)
  52430. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52431. * * 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)
  52432. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52434. * * 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
  52435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52436. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52437. * @param name defines the name of the mesh
  52438. * @param options defines the options used to create the mesh
  52439. * @param scene defines the hosting scene
  52440. * @returns the box mesh
  52441. */
  52442. static CreateBox(name: string, options: {
  52443. size?: number;
  52444. width?: number;
  52445. height?: number;
  52446. depth?: number;
  52447. faceUV?: Vector4[];
  52448. faceColors?: Color4[];
  52449. sideOrientation?: number;
  52450. frontUVs?: Vector4;
  52451. backUVs?: Vector4;
  52452. updatable?: boolean;
  52453. }, scene?: Nullable<Scene>): Mesh;
  52454. /**
  52455. * Creates a tiled box mesh
  52456. * * faceTiles sets the pattern, tile size and number of tiles for a face
  52457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52458. * @param name defines the name of the mesh
  52459. * @param options defines the options used to create the mesh
  52460. * @param scene defines the hosting scene
  52461. * @returns the tiled box mesh
  52462. */
  52463. static CreateTiledBox(name: string, options: {
  52464. pattern?: number;
  52465. size?: number;
  52466. width?: number;
  52467. height?: number;
  52468. depth: number;
  52469. tileSize?: number;
  52470. tileWidth?: number;
  52471. tileHeight?: number;
  52472. faceUV?: Vector4[];
  52473. faceColors?: Color4[];
  52474. alignHorizontal?: number;
  52475. alignVertical?: number;
  52476. sideOrientation?: number;
  52477. updatable?: boolean;
  52478. }, scene?: Nullable<Scene>): Mesh;
  52479. /**
  52480. * Creates a sphere mesh
  52481. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52482. * * 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`)
  52483. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52484. * * 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
  52485. * * 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)
  52486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52487. * * 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
  52488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52489. * @param name defines the name of the mesh
  52490. * @param options defines the options used to create the mesh
  52491. * @param scene defines the hosting scene
  52492. * @returns the sphere mesh
  52493. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52494. */
  52495. static CreateSphere(name: string, options: {
  52496. segments?: number;
  52497. diameter?: number;
  52498. diameterX?: number;
  52499. diameterY?: number;
  52500. diameterZ?: number;
  52501. arc?: number;
  52502. slice?: number;
  52503. sideOrientation?: number;
  52504. frontUVs?: Vector4;
  52505. backUVs?: Vector4;
  52506. updatable?: boolean;
  52507. }, scene?: Nullable<Scene>): Mesh;
  52508. /**
  52509. * Creates a plane polygonal mesh. By default, this is a disc
  52510. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52511. * * 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
  52512. * * 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
  52513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52514. * * 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
  52515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52516. * @param name defines the name of the mesh
  52517. * @param options defines the options used to create the mesh
  52518. * @param scene defines the hosting scene
  52519. * @returns the plane polygonal mesh
  52520. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52521. */
  52522. static CreateDisc(name: string, options: {
  52523. radius?: number;
  52524. tessellation?: number;
  52525. arc?: number;
  52526. updatable?: boolean;
  52527. sideOrientation?: number;
  52528. frontUVs?: Vector4;
  52529. backUVs?: Vector4;
  52530. }, scene?: Nullable<Scene>): Mesh;
  52531. /**
  52532. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52533. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52534. * * 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`)
  52535. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52536. * * 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
  52537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52538. * * 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
  52539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52540. * @param name defines the name of the mesh
  52541. * @param options defines the options used to create the mesh
  52542. * @param scene defines the hosting scene
  52543. * @returns the icosahedron mesh
  52544. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52545. */
  52546. static CreateIcoSphere(name: string, options: {
  52547. radius?: number;
  52548. radiusX?: number;
  52549. radiusY?: number;
  52550. radiusZ?: number;
  52551. flat?: boolean;
  52552. subdivisions?: number;
  52553. sideOrientation?: number;
  52554. frontUVs?: Vector4;
  52555. backUVs?: Vector4;
  52556. updatable?: boolean;
  52557. }, scene?: Nullable<Scene>): Mesh;
  52558. /**
  52559. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52560. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52561. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52562. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52563. * * 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
  52564. * * 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
  52565. * * 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
  52566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52567. * * 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
  52568. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52569. * * 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
  52570. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52571. * * 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
  52572. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52574. * @param name defines the name of the mesh
  52575. * @param options defines the options used to create the mesh
  52576. * @param scene defines the hosting scene
  52577. * @returns the ribbon mesh
  52578. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52579. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52580. */
  52581. static CreateRibbon(name: string, options: {
  52582. pathArray: Vector3[][];
  52583. closeArray?: boolean;
  52584. closePath?: boolean;
  52585. offset?: number;
  52586. updatable?: boolean;
  52587. sideOrientation?: number;
  52588. frontUVs?: Vector4;
  52589. backUVs?: Vector4;
  52590. instance?: Mesh;
  52591. invertUV?: boolean;
  52592. uvs?: Vector2[];
  52593. colors?: Color4[];
  52594. }, scene?: Nullable<Scene>): Mesh;
  52595. /**
  52596. * Creates a cylinder or a cone mesh
  52597. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52598. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52599. * * 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.
  52600. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52601. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52602. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52603. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52604. * * 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).
  52605. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52606. * * 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).
  52607. * * 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
  52608. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52609. * * 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
  52610. * * 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.
  52611. * * If `enclose` is false, a ring surface is one element.
  52612. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52613. * * 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
  52614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52615. * * 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
  52616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52617. * @param name defines the name of the mesh
  52618. * @param options defines the options used to create the mesh
  52619. * @param scene defines the hosting scene
  52620. * @returns the cylinder mesh
  52621. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52622. */
  52623. static CreateCylinder(name: string, options: {
  52624. height?: number;
  52625. diameterTop?: number;
  52626. diameterBottom?: number;
  52627. diameter?: number;
  52628. tessellation?: number;
  52629. subdivisions?: number;
  52630. arc?: number;
  52631. faceColors?: Color4[];
  52632. faceUV?: Vector4[];
  52633. updatable?: boolean;
  52634. hasRings?: boolean;
  52635. enclose?: boolean;
  52636. cap?: number;
  52637. sideOrientation?: number;
  52638. frontUVs?: Vector4;
  52639. backUVs?: Vector4;
  52640. }, scene?: Nullable<Scene>): Mesh;
  52641. /**
  52642. * Creates a torus mesh
  52643. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52644. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52645. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52646. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52647. * * 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
  52648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52649. * @param name defines the name of the mesh
  52650. * @param options defines the options used to create the mesh
  52651. * @param scene defines the hosting scene
  52652. * @returns the torus mesh
  52653. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52654. */
  52655. static CreateTorus(name: string, options: {
  52656. diameter?: number;
  52657. thickness?: number;
  52658. tessellation?: number;
  52659. updatable?: boolean;
  52660. sideOrientation?: number;
  52661. frontUVs?: Vector4;
  52662. backUVs?: Vector4;
  52663. }, scene?: Nullable<Scene>): Mesh;
  52664. /**
  52665. * Creates a torus knot mesh
  52666. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52667. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52668. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52669. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52671. * * 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
  52672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52673. * @param name defines the name of the mesh
  52674. * @param options defines the options used to create the mesh
  52675. * @param scene defines the hosting scene
  52676. * @returns the torus knot mesh
  52677. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52678. */
  52679. static CreateTorusKnot(name: string, options: {
  52680. radius?: number;
  52681. tube?: number;
  52682. radialSegments?: number;
  52683. tubularSegments?: number;
  52684. p?: number;
  52685. q?: number;
  52686. updatable?: boolean;
  52687. sideOrientation?: number;
  52688. frontUVs?: Vector4;
  52689. backUVs?: Vector4;
  52690. }, scene?: Nullable<Scene>): Mesh;
  52691. /**
  52692. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52693. * * 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
  52694. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52695. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52696. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52697. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52698. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52699. * * 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
  52700. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52702. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52703. * @param name defines the name of the new line system
  52704. * @param options defines the options used to create the line system
  52705. * @param scene defines the hosting scene
  52706. * @returns a new line system mesh
  52707. */
  52708. static CreateLineSystem(name: string, options: {
  52709. lines: Vector3[][];
  52710. updatable?: boolean;
  52711. instance?: Nullable<LinesMesh>;
  52712. colors?: Nullable<Color4[][]>;
  52713. useVertexAlpha?: boolean;
  52714. }, scene: Nullable<Scene>): LinesMesh;
  52715. /**
  52716. * Creates a line mesh
  52717. * 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
  52718. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52719. * * The parameter `points` is an array successive Vector3
  52720. * * 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
  52721. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52722. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52723. * * When updating an instance, remember that only point positions can change, not the number of points
  52724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52725. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52726. * @param name defines the name of the new line system
  52727. * @param options defines the options used to create the line system
  52728. * @param scene defines the hosting scene
  52729. * @returns a new line mesh
  52730. */
  52731. static CreateLines(name: string, options: {
  52732. points: Vector3[];
  52733. updatable?: boolean;
  52734. instance?: Nullable<LinesMesh>;
  52735. colors?: Color4[];
  52736. useVertexAlpha?: boolean;
  52737. }, scene?: Nullable<Scene>): LinesMesh;
  52738. /**
  52739. * Creates a dashed line mesh
  52740. * * 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
  52741. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52742. * * The parameter `points` is an array successive Vector3
  52743. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52744. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52745. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52746. * * 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
  52747. * * When updating an instance, remember that only point positions can change, not the number of points
  52748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52749. * @param name defines the name of the mesh
  52750. * @param options defines the options used to create the mesh
  52751. * @param scene defines the hosting scene
  52752. * @returns the dashed line mesh
  52753. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52754. */
  52755. static CreateDashedLines(name: string, options: {
  52756. points: Vector3[];
  52757. dashSize?: number;
  52758. gapSize?: number;
  52759. dashNb?: number;
  52760. updatable?: boolean;
  52761. instance?: LinesMesh;
  52762. }, scene?: Nullable<Scene>): LinesMesh;
  52763. /**
  52764. * 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.
  52765. * * 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.
  52766. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52767. * * 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.
  52768. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52769. * * 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
  52770. * * 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
  52771. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52772. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52773. * * 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
  52774. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52776. * @param name defines the name of the mesh
  52777. * @param options defines the options used to create the mesh
  52778. * @param scene defines the hosting scene
  52779. * @returns the extruded shape mesh
  52780. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52781. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52782. */
  52783. static ExtrudeShape(name: string, options: {
  52784. shape: Vector3[];
  52785. path: Vector3[];
  52786. scale?: number;
  52787. rotation?: number;
  52788. cap?: number;
  52789. updatable?: boolean;
  52790. sideOrientation?: number;
  52791. frontUVs?: Vector4;
  52792. backUVs?: Vector4;
  52793. instance?: Mesh;
  52794. invertUV?: boolean;
  52795. }, scene?: Nullable<Scene>): Mesh;
  52796. /**
  52797. * Creates an custom extruded shape mesh.
  52798. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52799. * * 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.
  52800. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52801. * * 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
  52802. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52803. * * 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
  52804. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52805. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52806. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52807. * * 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
  52808. * * 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
  52809. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52811. * * 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
  52812. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52814. * @param name defines the name of the mesh
  52815. * @param options defines the options used to create the mesh
  52816. * @param scene defines the hosting scene
  52817. * @returns the custom extruded shape mesh
  52818. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52819. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52820. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52821. */
  52822. static ExtrudeShapeCustom(name: string, options: {
  52823. shape: Vector3[];
  52824. path: Vector3[];
  52825. scaleFunction?: any;
  52826. rotationFunction?: any;
  52827. ribbonCloseArray?: boolean;
  52828. ribbonClosePath?: boolean;
  52829. cap?: number;
  52830. updatable?: boolean;
  52831. sideOrientation?: number;
  52832. frontUVs?: Vector4;
  52833. backUVs?: Vector4;
  52834. instance?: Mesh;
  52835. invertUV?: boolean;
  52836. }, scene?: Nullable<Scene>): Mesh;
  52837. /**
  52838. * Creates lathe mesh.
  52839. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52840. * * 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
  52841. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52842. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52843. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52844. * * 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
  52845. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52846. * * 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
  52847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52848. * * 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
  52849. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52851. * @param name defines the name of the mesh
  52852. * @param options defines the options used to create the mesh
  52853. * @param scene defines the hosting scene
  52854. * @returns the lathe mesh
  52855. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52856. */
  52857. static CreateLathe(name: string, options: {
  52858. shape: Vector3[];
  52859. radius?: number;
  52860. tessellation?: number;
  52861. clip?: number;
  52862. arc?: number;
  52863. closed?: boolean;
  52864. updatable?: boolean;
  52865. sideOrientation?: number;
  52866. frontUVs?: Vector4;
  52867. backUVs?: Vector4;
  52868. cap?: number;
  52869. invertUV?: boolean;
  52870. }, scene?: Nullable<Scene>): Mesh;
  52871. /**
  52872. * Creates a tiled plane mesh
  52873. * * You can set a limited pattern arrangement with the tiles
  52874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52875. * * 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
  52876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52877. * @param name defines the name of the mesh
  52878. * @param options defines the options used to create the mesh
  52879. * @param scene defines the hosting scene
  52880. * @returns the plane mesh
  52881. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52882. */
  52883. static CreateTiledPlane(name: string, options: {
  52884. pattern?: number;
  52885. tileSize?: number;
  52886. tileWidth?: number;
  52887. tileHeight?: number;
  52888. size?: number;
  52889. width?: number;
  52890. height?: number;
  52891. alignHorizontal?: number;
  52892. alignVertical?: number;
  52893. sideOrientation?: number;
  52894. frontUVs?: Vector4;
  52895. backUVs?: Vector4;
  52896. updatable?: boolean;
  52897. }, scene?: Nullable<Scene>): Mesh;
  52898. /**
  52899. * Creates a plane mesh
  52900. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52901. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52902. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52904. * * 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
  52905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52906. * @param name defines the name of the mesh
  52907. * @param options defines the options used to create the mesh
  52908. * @param scene defines the hosting scene
  52909. * @returns the plane mesh
  52910. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52911. */
  52912. static CreatePlane(name: string, options: {
  52913. size?: number;
  52914. width?: number;
  52915. height?: number;
  52916. sideOrientation?: number;
  52917. frontUVs?: Vector4;
  52918. backUVs?: Vector4;
  52919. updatable?: boolean;
  52920. sourcePlane?: Plane;
  52921. }, scene?: Nullable<Scene>): Mesh;
  52922. /**
  52923. * Creates a ground mesh
  52924. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52925. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52927. * @param name defines the name of the mesh
  52928. * @param options defines the options used to create the mesh
  52929. * @param scene defines the hosting scene
  52930. * @returns the ground mesh
  52931. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52932. */
  52933. static CreateGround(name: string, options: {
  52934. width?: number;
  52935. height?: number;
  52936. subdivisions?: number;
  52937. subdivisionsX?: number;
  52938. subdivisionsY?: number;
  52939. updatable?: boolean;
  52940. }, scene?: Nullable<Scene>): Mesh;
  52941. /**
  52942. * Creates a tiled ground mesh
  52943. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52944. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52945. * * 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
  52946. * * 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
  52947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52948. * @param name defines the name of the mesh
  52949. * @param options defines the options used to create the mesh
  52950. * @param scene defines the hosting scene
  52951. * @returns the tiled ground mesh
  52952. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52953. */
  52954. static CreateTiledGround(name: string, options: {
  52955. xmin: number;
  52956. zmin: number;
  52957. xmax: number;
  52958. zmax: number;
  52959. subdivisions?: {
  52960. w: number;
  52961. h: number;
  52962. };
  52963. precision?: {
  52964. w: number;
  52965. h: number;
  52966. };
  52967. updatable?: boolean;
  52968. }, scene?: Nullable<Scene>): Mesh;
  52969. /**
  52970. * Creates a ground mesh from a height map
  52971. * * The parameter `url` sets the URL of the height map image resource.
  52972. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52973. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52974. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52975. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52976. * * 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.
  52977. * * 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).
  52978. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52980. * @param name defines the name of the mesh
  52981. * @param url defines the url to the height map
  52982. * @param options defines the options used to create the mesh
  52983. * @param scene defines the hosting scene
  52984. * @returns the ground mesh
  52985. * @see https://doc.babylonjs.com/babylon101/height_map
  52986. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52987. */
  52988. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52989. width?: number;
  52990. height?: number;
  52991. subdivisions?: number;
  52992. minHeight?: number;
  52993. maxHeight?: number;
  52994. colorFilter?: Color3;
  52995. alphaFilter?: number;
  52996. updatable?: boolean;
  52997. onReady?: (mesh: GroundMesh) => void;
  52998. }, scene?: Nullable<Scene>): GroundMesh;
  52999. /**
  53000. * Creates a polygon mesh
  53001. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53002. * * 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
  53003. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53005. * * 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)
  53006. * * Remember you can only change the shape positions, not their number when updating a polygon
  53007. * @param name defines the name of the mesh
  53008. * @param options defines the options used to create the mesh
  53009. * @param scene defines the hosting scene
  53010. * @param earcutInjection can be used to inject your own earcut reference
  53011. * @returns the polygon mesh
  53012. */
  53013. static CreatePolygon(name: string, options: {
  53014. shape: Vector3[];
  53015. holes?: Vector3[][];
  53016. depth?: number;
  53017. faceUV?: Vector4[];
  53018. faceColors?: Color4[];
  53019. updatable?: boolean;
  53020. sideOrientation?: number;
  53021. frontUVs?: Vector4;
  53022. backUVs?: Vector4;
  53023. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53024. /**
  53025. * Creates an extruded polygon mesh, with depth in the Y direction.
  53026. * * 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)
  53027. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53028. * @param name defines the name of the mesh
  53029. * @param options defines the options used to create the mesh
  53030. * @param scene defines the hosting scene
  53031. * @param earcutInjection can be used to inject your own earcut reference
  53032. * @returns the polygon mesh
  53033. */
  53034. static ExtrudePolygon(name: string, options: {
  53035. shape: Vector3[];
  53036. holes?: Vector3[][];
  53037. depth?: number;
  53038. faceUV?: Vector4[];
  53039. faceColors?: Color4[];
  53040. updatable?: boolean;
  53041. sideOrientation?: number;
  53042. frontUVs?: Vector4;
  53043. backUVs?: Vector4;
  53044. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53045. /**
  53046. * Creates a tube mesh.
  53047. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53048. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53049. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53050. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53051. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53052. * * 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)
  53053. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53054. * * 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
  53055. * * 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
  53056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53057. * * 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
  53058. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53060. * @param name defines the name of the mesh
  53061. * @param options defines the options used to create the mesh
  53062. * @param scene defines the hosting scene
  53063. * @returns the tube mesh
  53064. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53065. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53066. */
  53067. static CreateTube(name: string, options: {
  53068. path: Vector3[];
  53069. radius?: number;
  53070. tessellation?: number;
  53071. radiusFunction?: {
  53072. (i: number, distance: number): number;
  53073. };
  53074. cap?: number;
  53075. arc?: number;
  53076. updatable?: boolean;
  53077. sideOrientation?: number;
  53078. frontUVs?: Vector4;
  53079. backUVs?: Vector4;
  53080. instance?: Mesh;
  53081. invertUV?: boolean;
  53082. }, scene?: Nullable<Scene>): Mesh;
  53083. /**
  53084. * Creates a polyhedron mesh
  53085. * * 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
  53086. * * The parameter `size` (positive float, default 1) sets the polygon size
  53087. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53088. * * 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`
  53089. * * 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
  53090. * * 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)`)
  53091. * * 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
  53092. * * 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
  53093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53094. * * 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
  53095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53096. * @param name defines the name of the mesh
  53097. * @param options defines the options used to create the mesh
  53098. * @param scene defines the hosting scene
  53099. * @returns the polyhedron mesh
  53100. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53101. */
  53102. static CreatePolyhedron(name: string, options: {
  53103. type?: number;
  53104. size?: number;
  53105. sizeX?: number;
  53106. sizeY?: number;
  53107. sizeZ?: number;
  53108. custom?: any;
  53109. faceUV?: Vector4[];
  53110. faceColors?: Color4[];
  53111. flat?: boolean;
  53112. updatable?: boolean;
  53113. sideOrientation?: number;
  53114. frontUVs?: Vector4;
  53115. backUVs?: Vector4;
  53116. }, scene?: Nullable<Scene>): Mesh;
  53117. /**
  53118. * Creates a decal mesh.
  53119. * 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
  53120. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53121. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53122. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53123. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53124. * @param name defines the name of the mesh
  53125. * @param sourceMesh defines the mesh where the decal must be applied
  53126. * @param options defines the options used to create the mesh
  53127. * @param scene defines the hosting scene
  53128. * @returns the decal mesh
  53129. * @see https://doc.babylonjs.com/how_to/decals
  53130. */
  53131. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53132. position?: Vector3;
  53133. normal?: Vector3;
  53134. size?: Vector3;
  53135. angle?: number;
  53136. }): Mesh;
  53137. }
  53138. }
  53139. declare module BABYLON {
  53140. /**
  53141. * A simplifier interface for future simplification implementations
  53142. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53143. */
  53144. export interface ISimplifier {
  53145. /**
  53146. * Simplification of a given mesh according to the given settings.
  53147. * Since this requires computation, it is assumed that the function runs async.
  53148. * @param settings The settings of the simplification, including quality and distance
  53149. * @param successCallback A callback that will be called after the mesh was simplified.
  53150. * @param errorCallback in case of an error, this callback will be called. optional.
  53151. */
  53152. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53153. }
  53154. /**
  53155. * Expected simplification settings.
  53156. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53157. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53158. */
  53159. export interface ISimplificationSettings {
  53160. /**
  53161. * Gets or sets the expected quality
  53162. */
  53163. quality: number;
  53164. /**
  53165. * Gets or sets the distance when this optimized version should be used
  53166. */
  53167. distance: number;
  53168. /**
  53169. * Gets an already optimized mesh
  53170. */
  53171. optimizeMesh?: boolean;
  53172. }
  53173. /**
  53174. * Class used to specify simplification options
  53175. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53176. */
  53177. export class SimplificationSettings implements ISimplificationSettings {
  53178. /** expected quality */
  53179. quality: number;
  53180. /** distance when this optimized version should be used */
  53181. distance: number;
  53182. /** already optimized mesh */
  53183. optimizeMesh?: boolean | undefined;
  53184. /**
  53185. * Creates a SimplificationSettings
  53186. * @param quality expected quality
  53187. * @param distance distance when this optimized version should be used
  53188. * @param optimizeMesh already optimized mesh
  53189. */
  53190. constructor(
  53191. /** expected quality */
  53192. quality: number,
  53193. /** distance when this optimized version should be used */
  53194. distance: number,
  53195. /** already optimized mesh */
  53196. optimizeMesh?: boolean | undefined);
  53197. }
  53198. /**
  53199. * Interface used to define a simplification task
  53200. */
  53201. export interface ISimplificationTask {
  53202. /**
  53203. * Array of settings
  53204. */
  53205. settings: Array<ISimplificationSettings>;
  53206. /**
  53207. * Simplification type
  53208. */
  53209. simplificationType: SimplificationType;
  53210. /**
  53211. * Mesh to simplify
  53212. */
  53213. mesh: Mesh;
  53214. /**
  53215. * Callback called on success
  53216. */
  53217. successCallback?: () => void;
  53218. /**
  53219. * Defines if parallel processing can be used
  53220. */
  53221. parallelProcessing: boolean;
  53222. }
  53223. /**
  53224. * Queue used to order the simplification tasks
  53225. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53226. */
  53227. export class SimplificationQueue {
  53228. private _simplificationArray;
  53229. /**
  53230. * Gets a boolean indicating that the process is still running
  53231. */
  53232. running: boolean;
  53233. /**
  53234. * Creates a new queue
  53235. */
  53236. constructor();
  53237. /**
  53238. * Adds a new simplification task
  53239. * @param task defines a task to add
  53240. */
  53241. addTask(task: ISimplificationTask): void;
  53242. /**
  53243. * Execute next task
  53244. */
  53245. executeNext(): void;
  53246. /**
  53247. * Execute a simplification task
  53248. * @param task defines the task to run
  53249. */
  53250. runSimplification(task: ISimplificationTask): void;
  53251. private getSimplifier;
  53252. }
  53253. /**
  53254. * The implemented types of simplification
  53255. * At the moment only Quadratic Error Decimation is implemented
  53256. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53257. */
  53258. export enum SimplificationType {
  53259. /** Quadratic error decimation */
  53260. QUADRATIC = 0
  53261. }
  53262. }
  53263. declare module BABYLON {
  53264. interface Scene {
  53265. /** @hidden (Backing field) */
  53266. _simplificationQueue: SimplificationQueue;
  53267. /**
  53268. * Gets or sets the simplification queue attached to the scene
  53269. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53270. */
  53271. simplificationQueue: SimplificationQueue;
  53272. }
  53273. interface Mesh {
  53274. /**
  53275. * Simplify the mesh according to the given array of settings.
  53276. * Function will return immediately and will simplify async
  53277. * @param settings a collection of simplification settings
  53278. * @param parallelProcessing should all levels calculate parallel or one after the other
  53279. * @param simplificationType the type of simplification to run
  53280. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53281. * @returns the current mesh
  53282. */
  53283. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53284. }
  53285. /**
  53286. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53287. * created in a scene
  53288. */
  53289. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53290. /**
  53291. * The component name helpfull to identify the component in the list of scene components.
  53292. */
  53293. readonly name: string;
  53294. /**
  53295. * The scene the component belongs to.
  53296. */
  53297. scene: Scene;
  53298. /**
  53299. * Creates a new instance of the component for the given scene
  53300. * @param scene Defines the scene to register the component in
  53301. */
  53302. constructor(scene: Scene);
  53303. /**
  53304. * Registers the component in a given scene
  53305. */
  53306. register(): void;
  53307. /**
  53308. * Rebuilds the elements related to this component in case of
  53309. * context lost for instance.
  53310. */
  53311. rebuild(): void;
  53312. /**
  53313. * Disposes the component and the associated ressources
  53314. */
  53315. dispose(): void;
  53316. private _beforeCameraUpdate;
  53317. }
  53318. }
  53319. declare module BABYLON {
  53320. /**
  53321. * Class used to enable access to IndexedDB
  53322. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53323. */
  53324. export class Database implements IOfflineProvider {
  53325. private _callbackManifestChecked;
  53326. private _currentSceneUrl;
  53327. private _db;
  53328. private _enableSceneOffline;
  53329. private _enableTexturesOffline;
  53330. private _manifestVersionFound;
  53331. private _mustUpdateRessources;
  53332. private _hasReachedQuota;
  53333. private _isSupported;
  53334. private _idbFactory;
  53335. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53336. private static IsUASupportingBlobStorage;
  53337. /**
  53338. * Gets a boolean indicating if Database storate is enabled (off by default)
  53339. */
  53340. static IDBStorageEnabled: boolean;
  53341. /**
  53342. * Gets a boolean indicating if scene must be saved in the database
  53343. */
  53344. readonly enableSceneOffline: boolean;
  53345. /**
  53346. * Gets a boolean indicating if textures must be saved in the database
  53347. */
  53348. readonly enableTexturesOffline: boolean;
  53349. /**
  53350. * Creates a new Database
  53351. * @param urlToScene defines the url to load the scene
  53352. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53353. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53354. */
  53355. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53356. private static _ParseURL;
  53357. private static _ReturnFullUrlLocation;
  53358. private _checkManifestFile;
  53359. /**
  53360. * Open the database and make it available
  53361. * @param successCallback defines the callback to call on success
  53362. * @param errorCallback defines the callback to call on error
  53363. */
  53364. open(successCallback: () => void, errorCallback: () => void): void;
  53365. /**
  53366. * Loads an image from the database
  53367. * @param url defines the url to load from
  53368. * @param image defines the target DOM image
  53369. */
  53370. loadImage(url: string, image: HTMLImageElement): void;
  53371. private _loadImageFromDBAsync;
  53372. private _saveImageIntoDBAsync;
  53373. private _checkVersionFromDB;
  53374. private _loadVersionFromDBAsync;
  53375. private _saveVersionIntoDBAsync;
  53376. /**
  53377. * Loads a file from database
  53378. * @param url defines the URL to load from
  53379. * @param sceneLoaded defines a callback to call on success
  53380. * @param progressCallBack defines a callback to call when progress changed
  53381. * @param errorCallback defines a callback to call on error
  53382. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53383. */
  53384. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53385. private _loadFileAsync;
  53386. private _saveFileAsync;
  53387. /**
  53388. * Validates if xhr data is correct
  53389. * @param xhr defines the request to validate
  53390. * @param dataType defines the expected data type
  53391. * @returns true if data is correct
  53392. */
  53393. private static _ValidateXHRData;
  53394. }
  53395. }
  53396. declare module BABYLON {
  53397. /** @hidden */
  53398. export var gpuUpdateParticlesPixelShader: {
  53399. name: string;
  53400. shader: string;
  53401. };
  53402. }
  53403. declare module BABYLON {
  53404. /** @hidden */
  53405. export var gpuUpdateParticlesVertexShader: {
  53406. name: string;
  53407. shader: string;
  53408. };
  53409. }
  53410. declare module BABYLON {
  53411. /** @hidden */
  53412. export var clipPlaneFragmentDeclaration2: {
  53413. name: string;
  53414. shader: string;
  53415. };
  53416. }
  53417. declare module BABYLON {
  53418. /** @hidden */
  53419. export var gpuRenderParticlesPixelShader: {
  53420. name: string;
  53421. shader: string;
  53422. };
  53423. }
  53424. declare module BABYLON {
  53425. /** @hidden */
  53426. export var clipPlaneVertexDeclaration2: {
  53427. name: string;
  53428. shader: string;
  53429. };
  53430. }
  53431. declare module BABYLON {
  53432. /** @hidden */
  53433. export var gpuRenderParticlesVertexShader: {
  53434. name: string;
  53435. shader: string;
  53436. };
  53437. }
  53438. declare module BABYLON {
  53439. /**
  53440. * This represents a GPU particle system in Babylon
  53441. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53442. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53443. */
  53444. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53445. /**
  53446. * The layer mask we are rendering the particles through.
  53447. */
  53448. layerMask: number;
  53449. private _capacity;
  53450. private _activeCount;
  53451. private _currentActiveCount;
  53452. private _accumulatedCount;
  53453. private _renderEffect;
  53454. private _updateEffect;
  53455. private _buffer0;
  53456. private _buffer1;
  53457. private _spriteBuffer;
  53458. private _updateVAO;
  53459. private _renderVAO;
  53460. private _targetIndex;
  53461. private _sourceBuffer;
  53462. private _targetBuffer;
  53463. private _engine;
  53464. private _currentRenderId;
  53465. private _started;
  53466. private _stopped;
  53467. private _timeDelta;
  53468. private _randomTexture;
  53469. private _randomTexture2;
  53470. private _attributesStrideSize;
  53471. private _updateEffectOptions;
  53472. private _randomTextureSize;
  53473. private _actualFrame;
  53474. private readonly _rawTextureWidth;
  53475. /**
  53476. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53477. */
  53478. static readonly IsSupported: boolean;
  53479. /**
  53480. * An event triggered when the system is disposed.
  53481. */
  53482. onDisposeObservable: Observable<GPUParticleSystem>;
  53483. /**
  53484. * Gets the maximum number of particles active at the same time.
  53485. * @returns The max number of active particles.
  53486. */
  53487. getCapacity(): number;
  53488. /**
  53489. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53490. * to override the particles.
  53491. */
  53492. forceDepthWrite: boolean;
  53493. /**
  53494. * Gets or set the number of active particles
  53495. */
  53496. activeParticleCount: number;
  53497. private _preWarmDone;
  53498. /**
  53499. * Is this system ready to be used/rendered
  53500. * @return true if the system is ready
  53501. */
  53502. isReady(): boolean;
  53503. /**
  53504. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53505. * @returns True if it has been started, otherwise false.
  53506. */
  53507. isStarted(): boolean;
  53508. /**
  53509. * Starts the particle system and begins to emit
  53510. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53511. */
  53512. start(delay?: number): void;
  53513. /**
  53514. * Stops the particle system.
  53515. */
  53516. stop(): void;
  53517. /**
  53518. * Remove all active particles
  53519. */
  53520. reset(): void;
  53521. /**
  53522. * Returns the string "GPUParticleSystem"
  53523. * @returns a string containing the class name
  53524. */
  53525. getClassName(): string;
  53526. private _colorGradientsTexture;
  53527. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53528. /**
  53529. * Adds a new color gradient
  53530. * @param gradient defines the gradient to use (between 0 and 1)
  53531. * @param color1 defines the color to affect to the specified gradient
  53532. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53533. * @returns the current particle system
  53534. */
  53535. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53536. /**
  53537. * Remove a specific color gradient
  53538. * @param gradient defines the gradient to remove
  53539. * @returns the current particle system
  53540. */
  53541. removeColorGradient(gradient: number): GPUParticleSystem;
  53542. private _angularSpeedGradientsTexture;
  53543. private _sizeGradientsTexture;
  53544. private _velocityGradientsTexture;
  53545. private _limitVelocityGradientsTexture;
  53546. private _dragGradientsTexture;
  53547. private _addFactorGradient;
  53548. /**
  53549. * Adds a new size gradient
  53550. * @param gradient defines the gradient to use (between 0 and 1)
  53551. * @param factor defines the size factor to affect to the specified gradient
  53552. * @returns the current particle system
  53553. */
  53554. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53555. /**
  53556. * Remove a specific size gradient
  53557. * @param gradient defines the gradient to remove
  53558. * @returns the current particle system
  53559. */
  53560. removeSizeGradient(gradient: number): GPUParticleSystem;
  53561. /**
  53562. * Adds a new angular speed gradient
  53563. * @param gradient defines the gradient to use (between 0 and 1)
  53564. * @param factor defines the angular speed to affect to the specified gradient
  53565. * @returns the current particle system
  53566. */
  53567. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53568. /**
  53569. * Remove a specific angular speed gradient
  53570. * @param gradient defines the gradient to remove
  53571. * @returns the current particle system
  53572. */
  53573. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53574. /**
  53575. * Adds a new velocity gradient
  53576. * @param gradient defines the gradient to use (between 0 and 1)
  53577. * @param factor defines the velocity to affect to the specified gradient
  53578. * @returns the current particle system
  53579. */
  53580. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53581. /**
  53582. * Remove a specific velocity gradient
  53583. * @param gradient defines the gradient to remove
  53584. * @returns the current particle system
  53585. */
  53586. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53587. /**
  53588. * Adds a new limit velocity gradient
  53589. * @param gradient defines the gradient to use (between 0 and 1)
  53590. * @param factor defines the limit velocity value to affect to the specified gradient
  53591. * @returns the current particle system
  53592. */
  53593. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53594. /**
  53595. * Remove a specific limit velocity gradient
  53596. * @param gradient defines the gradient to remove
  53597. * @returns the current particle system
  53598. */
  53599. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53600. /**
  53601. * Adds a new drag gradient
  53602. * @param gradient defines the gradient to use (between 0 and 1)
  53603. * @param factor defines the drag value to affect to the specified gradient
  53604. * @returns the current particle system
  53605. */
  53606. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53607. /**
  53608. * Remove a specific drag gradient
  53609. * @param gradient defines the gradient to remove
  53610. * @returns the current particle system
  53611. */
  53612. removeDragGradient(gradient: number): GPUParticleSystem;
  53613. /**
  53614. * Not supported by GPUParticleSystem
  53615. * @param gradient defines the gradient to use (between 0 and 1)
  53616. * @param factor defines the emit rate value to affect to the specified gradient
  53617. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53618. * @returns the current particle system
  53619. */
  53620. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53621. /**
  53622. * Not supported by GPUParticleSystem
  53623. * @param gradient defines the gradient to remove
  53624. * @returns the current particle system
  53625. */
  53626. removeEmitRateGradient(gradient: number): IParticleSystem;
  53627. /**
  53628. * Not supported by GPUParticleSystem
  53629. * @param gradient defines the gradient to use (between 0 and 1)
  53630. * @param factor defines the start size value to affect to the specified gradient
  53631. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53632. * @returns the current particle system
  53633. */
  53634. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53635. /**
  53636. * Not supported by GPUParticleSystem
  53637. * @param gradient defines the gradient to remove
  53638. * @returns the current particle system
  53639. */
  53640. removeStartSizeGradient(gradient: number): IParticleSystem;
  53641. /**
  53642. * Not supported by GPUParticleSystem
  53643. * @param gradient defines the gradient to use (between 0 and 1)
  53644. * @param min defines the color remap minimal range
  53645. * @param max defines the color remap maximal range
  53646. * @returns the current particle system
  53647. */
  53648. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53649. /**
  53650. * Not supported by GPUParticleSystem
  53651. * @param gradient defines the gradient to remove
  53652. * @returns the current particle system
  53653. */
  53654. removeColorRemapGradient(): IParticleSystem;
  53655. /**
  53656. * Not supported by GPUParticleSystem
  53657. * @param gradient defines the gradient to use (between 0 and 1)
  53658. * @param min defines the alpha remap minimal range
  53659. * @param max defines the alpha remap maximal range
  53660. * @returns the current particle system
  53661. */
  53662. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53663. /**
  53664. * Not supported by GPUParticleSystem
  53665. * @param gradient defines the gradient to remove
  53666. * @returns the current particle system
  53667. */
  53668. removeAlphaRemapGradient(): IParticleSystem;
  53669. /**
  53670. * Not supported by GPUParticleSystem
  53671. * @param gradient defines the gradient to use (between 0 and 1)
  53672. * @param color defines the color to affect to the specified gradient
  53673. * @returns the current particle system
  53674. */
  53675. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53676. /**
  53677. * Not supported by GPUParticleSystem
  53678. * @param gradient defines the gradient to remove
  53679. * @returns the current particle system
  53680. */
  53681. removeRampGradient(): IParticleSystem;
  53682. /**
  53683. * Not supported by GPUParticleSystem
  53684. * @returns the list of ramp gradients
  53685. */
  53686. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53687. /**
  53688. * Not supported by GPUParticleSystem
  53689. * Gets or sets a boolean indicating that ramp gradients must be used
  53690. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53691. */
  53692. useRampGradients: boolean;
  53693. /**
  53694. * Not supported by GPUParticleSystem
  53695. * @param gradient defines the gradient to use (between 0 and 1)
  53696. * @param factor defines the life time factor to affect to the specified gradient
  53697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53698. * @returns the current particle system
  53699. */
  53700. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53701. /**
  53702. * Not supported by GPUParticleSystem
  53703. * @param gradient defines the gradient to remove
  53704. * @returns the current particle system
  53705. */
  53706. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53707. /**
  53708. * Instantiates a GPU particle system.
  53709. * 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.
  53710. * @param name The name of the particle system
  53711. * @param options The options used to create the system
  53712. * @param scene The scene the particle system belongs to
  53713. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53714. */
  53715. constructor(name: string, options: Partial<{
  53716. capacity: number;
  53717. randomTextureSize: number;
  53718. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53719. protected _reset(): void;
  53720. private _createUpdateVAO;
  53721. private _createRenderVAO;
  53722. private _initialize;
  53723. /** @hidden */
  53724. _recreateUpdateEffect(): void;
  53725. /** @hidden */
  53726. _recreateRenderEffect(): void;
  53727. /**
  53728. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53729. * @param preWarm defines if we are in the pre-warmimg phase
  53730. */
  53731. animate(preWarm?: boolean): void;
  53732. private _createFactorGradientTexture;
  53733. private _createSizeGradientTexture;
  53734. private _createAngularSpeedGradientTexture;
  53735. private _createVelocityGradientTexture;
  53736. private _createLimitVelocityGradientTexture;
  53737. private _createDragGradientTexture;
  53738. private _createColorGradientTexture;
  53739. /**
  53740. * Renders the particle system in its current state
  53741. * @param preWarm defines if the system should only update the particles but not render them
  53742. * @returns the current number of particles
  53743. */
  53744. render(preWarm?: boolean): number;
  53745. /**
  53746. * Rebuilds the particle system
  53747. */
  53748. rebuild(): void;
  53749. private _releaseBuffers;
  53750. private _releaseVAOs;
  53751. /**
  53752. * Disposes the particle system and free the associated resources
  53753. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53754. */
  53755. dispose(disposeTexture?: boolean): void;
  53756. /**
  53757. * Clones the particle system.
  53758. * @param name The name of the cloned object
  53759. * @param newEmitter The new emitter to use
  53760. * @returns the cloned particle system
  53761. */
  53762. clone(name: string, newEmitter: any): GPUParticleSystem;
  53763. /**
  53764. * Serializes the particle system to a JSON object.
  53765. * @returns the JSON object
  53766. */
  53767. serialize(): any;
  53768. /**
  53769. * Parses a JSON object to create a GPU particle system.
  53770. * @param parsedParticleSystem The JSON object to parse
  53771. * @param scene The scene to create the particle system in
  53772. * @param rootUrl The root url to use to load external dependencies like texture
  53773. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53774. * @returns the parsed GPU particle system
  53775. */
  53776. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53777. }
  53778. }
  53779. declare module BABYLON {
  53780. /**
  53781. * Represents a set of particle systems working together to create a specific effect
  53782. */
  53783. export class ParticleSystemSet implements IDisposable {
  53784. private _emitterCreationOptions;
  53785. private _emitterNode;
  53786. /**
  53787. * Gets the particle system list
  53788. */
  53789. systems: IParticleSystem[];
  53790. /**
  53791. * Gets the emitter node used with this set
  53792. */
  53793. readonly emitterNode: Nullable<TransformNode>;
  53794. /**
  53795. * Creates a new emitter mesh as a sphere
  53796. * @param options defines the options used to create the sphere
  53797. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53798. * @param scene defines the hosting scene
  53799. */
  53800. setEmitterAsSphere(options: {
  53801. diameter: number;
  53802. segments: number;
  53803. color: Color3;
  53804. }, renderingGroupId: number, scene: Scene): void;
  53805. /**
  53806. * Starts all particle systems of the set
  53807. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53808. */
  53809. start(emitter?: AbstractMesh): void;
  53810. /**
  53811. * Release all associated resources
  53812. */
  53813. dispose(): void;
  53814. /**
  53815. * Serialize the set into a JSON compatible object
  53816. * @returns a JSON compatible representation of the set
  53817. */
  53818. serialize(): any;
  53819. /**
  53820. * Parse a new ParticleSystemSet from a serialized source
  53821. * @param data defines a JSON compatible representation of the set
  53822. * @param scene defines the hosting scene
  53823. * @param gpu defines if we want GPU particles or CPU particles
  53824. * @returns a new ParticleSystemSet
  53825. */
  53826. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53827. }
  53828. }
  53829. declare module BABYLON {
  53830. /**
  53831. * This class is made for on one-liner static method to help creating particle system set.
  53832. */
  53833. export class ParticleHelper {
  53834. /**
  53835. * Gets or sets base Assets URL
  53836. */
  53837. static BaseAssetsUrl: string;
  53838. /**
  53839. * Create a default particle system that you can tweak
  53840. * @param emitter defines the emitter to use
  53841. * @param capacity defines the system capacity (default is 500 particles)
  53842. * @param scene defines the hosting scene
  53843. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  53844. * @returns the new Particle system
  53845. */
  53846. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  53847. /**
  53848. * This is the main static method (one-liner) of this helper to create different particle systems
  53849. * @param type This string represents the type to the particle system to create
  53850. * @param scene The scene where the particle system should live
  53851. * @param gpu If the system will use gpu
  53852. * @returns the ParticleSystemSet created
  53853. */
  53854. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  53855. /**
  53856. * Static function used to export a particle system to a ParticleSystemSet variable.
  53857. * Please note that the emitter shape is not exported
  53858. * @param systems defines the particle systems to export
  53859. * @returns the created particle system set
  53860. */
  53861. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  53862. }
  53863. }
  53864. declare module BABYLON {
  53865. interface Engine {
  53866. /**
  53867. * Create an effect to use with particle systems.
  53868. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  53869. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  53870. * @param uniformsNames defines a list of attribute names
  53871. * @param samplers defines an array of string used to represent textures
  53872. * @param defines defines the string containing the defines to use to compile the shaders
  53873. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  53874. * @param onCompiled defines a function to call when the effect creation is successful
  53875. * @param onError defines a function to call when the effect creation has failed
  53876. * @returns the new Effect
  53877. */
  53878. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  53879. }
  53880. interface Mesh {
  53881. /**
  53882. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  53883. * @returns an array of IParticleSystem
  53884. */
  53885. getEmittedParticleSystems(): IParticleSystem[];
  53886. /**
  53887. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  53888. * @returns an array of IParticleSystem
  53889. */
  53890. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  53891. }
  53892. /**
  53893. * @hidden
  53894. */
  53895. export var _IDoNeedToBeInTheBuild: number;
  53896. }
  53897. declare module BABYLON {
  53898. interface Scene {
  53899. /** @hidden (Backing field) */
  53900. _physicsEngine: Nullable<IPhysicsEngine>;
  53901. /**
  53902. * Gets the current physics engine
  53903. * @returns a IPhysicsEngine or null if none attached
  53904. */
  53905. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  53906. /**
  53907. * Enables physics to the current scene
  53908. * @param gravity defines the scene's gravity for the physics engine
  53909. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  53910. * @return a boolean indicating if the physics engine was initialized
  53911. */
  53912. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  53913. /**
  53914. * Disables and disposes the physics engine associated with the scene
  53915. */
  53916. disablePhysicsEngine(): void;
  53917. /**
  53918. * Gets a boolean indicating if there is an active physics engine
  53919. * @returns a boolean indicating if there is an active physics engine
  53920. */
  53921. isPhysicsEnabled(): boolean;
  53922. /**
  53923. * Deletes a physics compound impostor
  53924. * @param compound defines the compound to delete
  53925. */
  53926. deleteCompoundImpostor(compound: any): void;
  53927. /**
  53928. * An event triggered when physic simulation is about to be run
  53929. */
  53930. onBeforePhysicsObservable: Observable<Scene>;
  53931. /**
  53932. * An event triggered when physic simulation has been done
  53933. */
  53934. onAfterPhysicsObservable: Observable<Scene>;
  53935. }
  53936. interface AbstractMesh {
  53937. /** @hidden */
  53938. _physicsImpostor: Nullable<PhysicsImpostor>;
  53939. /**
  53940. * Gets or sets impostor used for physic simulation
  53941. * @see http://doc.babylonjs.com/features/physics_engine
  53942. */
  53943. physicsImpostor: Nullable<PhysicsImpostor>;
  53944. /**
  53945. * Gets the current physics impostor
  53946. * @see http://doc.babylonjs.com/features/physics_engine
  53947. * @returns a physics impostor or null
  53948. */
  53949. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  53950. /** Apply a physic impulse to the mesh
  53951. * @param force defines the force to apply
  53952. * @param contactPoint defines where to apply the force
  53953. * @returns the current mesh
  53954. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53955. */
  53956. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  53957. /**
  53958. * Creates a physic joint between two meshes
  53959. * @param otherMesh defines the other mesh to use
  53960. * @param pivot1 defines the pivot to use on this mesh
  53961. * @param pivot2 defines the pivot to use on the other mesh
  53962. * @param options defines additional options (can be plugin dependent)
  53963. * @returns the current mesh
  53964. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  53965. */
  53966. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  53967. /** @hidden */
  53968. _disposePhysicsObserver: Nullable<Observer<Node>>;
  53969. }
  53970. /**
  53971. * Defines the physics engine scene component responsible to manage a physics engine
  53972. */
  53973. export class PhysicsEngineSceneComponent implements ISceneComponent {
  53974. /**
  53975. * The component name helpful to identify the component in the list of scene components.
  53976. */
  53977. readonly name: string;
  53978. /**
  53979. * The scene the component belongs to.
  53980. */
  53981. scene: Scene;
  53982. /**
  53983. * Creates a new instance of the component for the given scene
  53984. * @param scene Defines the scene to register the component in
  53985. */
  53986. constructor(scene: Scene);
  53987. /**
  53988. * Registers the component in a given scene
  53989. */
  53990. register(): void;
  53991. /**
  53992. * Rebuilds the elements related to this component in case of
  53993. * context lost for instance.
  53994. */
  53995. rebuild(): void;
  53996. /**
  53997. * Disposes the component and the associated ressources
  53998. */
  53999. dispose(): void;
  54000. }
  54001. }
  54002. declare module BABYLON {
  54003. /**
  54004. * A helper for physics simulations
  54005. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54006. */
  54007. export class PhysicsHelper {
  54008. private _scene;
  54009. private _physicsEngine;
  54010. /**
  54011. * Initializes the Physics helper
  54012. * @param scene Babylon.js scene
  54013. */
  54014. constructor(scene: Scene);
  54015. /**
  54016. * Applies a radial explosion impulse
  54017. * @param origin the origin of the explosion
  54018. * @param radiusOrEventOptions the radius or the options of radial explosion
  54019. * @param strength the explosion strength
  54020. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54021. * @returns A physics radial explosion event, or null
  54022. */
  54023. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54024. /**
  54025. * Applies a radial explosion force
  54026. * @param origin the origin of the explosion
  54027. * @param radiusOrEventOptions the radius or the options of radial explosion
  54028. * @param strength the explosion strength
  54029. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54030. * @returns A physics radial explosion event, or null
  54031. */
  54032. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54033. /**
  54034. * Creates a gravitational field
  54035. * @param origin the origin of the explosion
  54036. * @param radiusOrEventOptions the radius or the options of radial explosion
  54037. * @param strength the explosion strength
  54038. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54039. * @returns A physics gravitational field event, or null
  54040. */
  54041. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54042. /**
  54043. * Creates a physics updraft event
  54044. * @param origin the origin of the updraft
  54045. * @param radiusOrEventOptions the radius or the options of the updraft
  54046. * @param strength the strength of the updraft
  54047. * @param height the height of the updraft
  54048. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54049. * @returns A physics updraft event, or null
  54050. */
  54051. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54052. /**
  54053. * Creates a physics vortex event
  54054. * @param origin the of the vortex
  54055. * @param radiusOrEventOptions the radius or the options of the vortex
  54056. * @param strength the strength of the vortex
  54057. * @param height the height of the vortex
  54058. * @returns a Physics vortex event, or null
  54059. * A physics vortex event or null
  54060. */
  54061. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54062. }
  54063. /**
  54064. * Represents a physics radial explosion event
  54065. */
  54066. class PhysicsRadialExplosionEvent {
  54067. private _scene;
  54068. private _options;
  54069. private _sphere;
  54070. private _dataFetched;
  54071. /**
  54072. * Initializes a radial explosioin event
  54073. * @param _scene BabylonJS scene
  54074. * @param _options The options for the vortex event
  54075. */
  54076. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54077. /**
  54078. * Returns the data related to the radial explosion event (sphere).
  54079. * @returns The radial explosion event data
  54080. */
  54081. getData(): PhysicsRadialExplosionEventData;
  54082. /**
  54083. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54084. * @param impostor A physics imposter
  54085. * @param origin the origin of the explosion
  54086. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54087. */
  54088. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54089. /**
  54090. * Triggers affecterd impostors callbacks
  54091. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54092. */
  54093. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54094. /**
  54095. * Disposes the sphere.
  54096. * @param force Specifies if the sphere should be disposed by force
  54097. */
  54098. dispose(force?: boolean): void;
  54099. /*** Helpers ***/
  54100. private _prepareSphere;
  54101. private _intersectsWithSphere;
  54102. }
  54103. /**
  54104. * Represents a gravitational field event
  54105. */
  54106. class PhysicsGravitationalFieldEvent {
  54107. private _physicsHelper;
  54108. private _scene;
  54109. private _origin;
  54110. private _options;
  54111. private _tickCallback;
  54112. private _sphere;
  54113. private _dataFetched;
  54114. /**
  54115. * Initializes the physics gravitational field event
  54116. * @param _physicsHelper A physics helper
  54117. * @param _scene BabylonJS scene
  54118. * @param _origin The origin position of the gravitational field event
  54119. * @param _options The options for the vortex event
  54120. */
  54121. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54122. /**
  54123. * Returns the data related to the gravitational field event (sphere).
  54124. * @returns A gravitational field event
  54125. */
  54126. getData(): PhysicsGravitationalFieldEventData;
  54127. /**
  54128. * Enables the gravitational field.
  54129. */
  54130. enable(): void;
  54131. /**
  54132. * Disables the gravitational field.
  54133. */
  54134. disable(): void;
  54135. /**
  54136. * Disposes the sphere.
  54137. * @param force The force to dispose from the gravitational field event
  54138. */
  54139. dispose(force?: boolean): void;
  54140. private _tick;
  54141. }
  54142. /**
  54143. * Represents a physics updraft event
  54144. */
  54145. class PhysicsUpdraftEvent {
  54146. private _scene;
  54147. private _origin;
  54148. private _options;
  54149. private _physicsEngine;
  54150. private _originTop;
  54151. private _originDirection;
  54152. private _tickCallback;
  54153. private _cylinder;
  54154. private _cylinderPosition;
  54155. private _dataFetched;
  54156. /**
  54157. * Initializes the physics updraft event
  54158. * @param _scene BabylonJS scene
  54159. * @param _origin The origin position of the updraft
  54160. * @param _options The options for the updraft event
  54161. */
  54162. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54163. /**
  54164. * Returns the data related to the updraft event (cylinder).
  54165. * @returns A physics updraft event
  54166. */
  54167. getData(): PhysicsUpdraftEventData;
  54168. /**
  54169. * Enables the updraft.
  54170. */
  54171. enable(): void;
  54172. /**
  54173. * Disables the updraft.
  54174. */
  54175. disable(): void;
  54176. /**
  54177. * Disposes the cylinder.
  54178. * @param force Specifies if the updraft should be disposed by force
  54179. */
  54180. dispose(force?: boolean): void;
  54181. private getImpostorHitData;
  54182. private _tick;
  54183. /*** Helpers ***/
  54184. private _prepareCylinder;
  54185. private _intersectsWithCylinder;
  54186. }
  54187. /**
  54188. * Represents a physics vortex event
  54189. */
  54190. class PhysicsVortexEvent {
  54191. private _scene;
  54192. private _origin;
  54193. private _options;
  54194. private _physicsEngine;
  54195. private _originTop;
  54196. private _tickCallback;
  54197. private _cylinder;
  54198. private _cylinderPosition;
  54199. private _dataFetched;
  54200. /**
  54201. * Initializes the physics vortex event
  54202. * @param _scene The BabylonJS scene
  54203. * @param _origin The origin position of the vortex
  54204. * @param _options The options for the vortex event
  54205. */
  54206. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54207. /**
  54208. * Returns the data related to the vortex event (cylinder).
  54209. * @returns The physics vortex event data
  54210. */
  54211. getData(): PhysicsVortexEventData;
  54212. /**
  54213. * Enables the vortex.
  54214. */
  54215. enable(): void;
  54216. /**
  54217. * Disables the cortex.
  54218. */
  54219. disable(): void;
  54220. /**
  54221. * Disposes the sphere.
  54222. * @param force
  54223. */
  54224. dispose(force?: boolean): void;
  54225. private getImpostorHitData;
  54226. private _tick;
  54227. /*** Helpers ***/
  54228. private _prepareCylinder;
  54229. private _intersectsWithCylinder;
  54230. }
  54231. /**
  54232. * Options fot the radial explosion event
  54233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54234. */
  54235. export class PhysicsRadialExplosionEventOptions {
  54236. /**
  54237. * The radius of the sphere for the radial explosion.
  54238. */
  54239. radius: number;
  54240. /**
  54241. * The strenth of the explosion.
  54242. */
  54243. strength: number;
  54244. /**
  54245. * The strenght of the force in correspondence to the distance of the affected object
  54246. */
  54247. falloff: PhysicsRadialImpulseFalloff;
  54248. /**
  54249. * Sphere options for the radial explosion.
  54250. */
  54251. sphere: {
  54252. segments: number;
  54253. diameter: number;
  54254. };
  54255. /**
  54256. * Sphere options for the radial explosion.
  54257. */
  54258. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54259. }
  54260. /**
  54261. * Options fot the updraft event
  54262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54263. */
  54264. export class PhysicsUpdraftEventOptions {
  54265. /**
  54266. * The radius of the cylinder for the vortex
  54267. */
  54268. radius: number;
  54269. /**
  54270. * The strenth of the updraft.
  54271. */
  54272. strength: number;
  54273. /**
  54274. * The height of the cylinder for the updraft.
  54275. */
  54276. height: number;
  54277. /**
  54278. * The mode for the the updraft.
  54279. */
  54280. updraftMode: PhysicsUpdraftMode;
  54281. }
  54282. /**
  54283. * Options fot the vortex event
  54284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54285. */
  54286. export class PhysicsVortexEventOptions {
  54287. /**
  54288. * The radius of the cylinder for the vortex
  54289. */
  54290. radius: number;
  54291. /**
  54292. * The strenth of the vortex.
  54293. */
  54294. strength: number;
  54295. /**
  54296. * The height of the cylinder for the vortex.
  54297. */
  54298. height: number;
  54299. /**
  54300. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54301. */
  54302. centripetalForceThreshold: number;
  54303. /**
  54304. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54305. */
  54306. centripetalForceMultiplier: number;
  54307. /**
  54308. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54309. */
  54310. centrifugalForceMultiplier: number;
  54311. /**
  54312. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54313. */
  54314. updraftForceMultiplier: number;
  54315. }
  54316. /**
  54317. * The strenght of the force in correspondence to the distance of the affected object
  54318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54319. */
  54320. export enum PhysicsRadialImpulseFalloff {
  54321. /** Defines that impulse is constant in strength across it's whole radius */
  54322. Constant = 0,
  54323. /** Defines that impulse gets weaker if it's further from the origin */
  54324. Linear = 1
  54325. }
  54326. /**
  54327. * The strength of the force in correspondence to the distance of the affected object
  54328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54329. */
  54330. export enum PhysicsUpdraftMode {
  54331. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54332. Center = 0,
  54333. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54334. Perpendicular = 1
  54335. }
  54336. /**
  54337. * Interface for a physics hit data
  54338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54339. */
  54340. export interface PhysicsHitData {
  54341. /**
  54342. * The force applied at the contact point
  54343. */
  54344. force: Vector3;
  54345. /**
  54346. * The contact point
  54347. */
  54348. contactPoint: Vector3;
  54349. /**
  54350. * The distance from the origin to the contact point
  54351. */
  54352. distanceFromOrigin: number;
  54353. }
  54354. /**
  54355. * Interface for radial explosion event data
  54356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54357. */
  54358. export interface PhysicsRadialExplosionEventData {
  54359. /**
  54360. * A sphere used for the radial explosion event
  54361. */
  54362. sphere: Mesh;
  54363. }
  54364. /**
  54365. * Interface for gravitational field event data
  54366. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54367. */
  54368. export interface PhysicsGravitationalFieldEventData {
  54369. /**
  54370. * A sphere mesh used for the gravitational field event
  54371. */
  54372. sphere: Mesh;
  54373. }
  54374. /**
  54375. * Interface for updraft event data
  54376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54377. */
  54378. export interface PhysicsUpdraftEventData {
  54379. /**
  54380. * A cylinder used for the updraft event
  54381. */
  54382. cylinder: Mesh;
  54383. }
  54384. /**
  54385. * Interface for vortex event data
  54386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54387. */
  54388. export interface PhysicsVortexEventData {
  54389. /**
  54390. * A cylinder used for the vortex event
  54391. */
  54392. cylinder: Mesh;
  54393. }
  54394. /**
  54395. * Interface for an affected physics impostor
  54396. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54397. */
  54398. export interface PhysicsAffectedImpostorWithData {
  54399. /**
  54400. * The impostor affected by the effect
  54401. */
  54402. impostor: PhysicsImpostor;
  54403. /**
  54404. * The data about the hit/horce from the explosion
  54405. */
  54406. hitData: PhysicsHitData;
  54407. }
  54408. }
  54409. declare module BABYLON {
  54410. /** @hidden */
  54411. export var blackAndWhitePixelShader: {
  54412. name: string;
  54413. shader: string;
  54414. };
  54415. }
  54416. declare module BABYLON {
  54417. /**
  54418. * Post process used to render in black and white
  54419. */
  54420. export class BlackAndWhitePostProcess extends PostProcess {
  54421. /**
  54422. * Linear about to convert he result to black and white (default: 1)
  54423. */
  54424. degree: number;
  54425. /**
  54426. * Creates a black and white post process
  54427. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54428. * @param name The name of the effect.
  54429. * @param options The required width/height ratio to downsize to before computing the render pass.
  54430. * @param camera The camera to apply the render pass to.
  54431. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54432. * @param engine The engine which the post process will be applied. (default: current engine)
  54433. * @param reusable If the post process can be reused on the same frame. (default: false)
  54434. */
  54435. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54436. }
  54437. }
  54438. declare module BABYLON {
  54439. /**
  54440. * This represents a set of one or more post processes in Babylon.
  54441. * A post process can be used to apply a shader to a texture after it is rendered.
  54442. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54443. */
  54444. export class PostProcessRenderEffect {
  54445. private _postProcesses;
  54446. private _getPostProcesses;
  54447. private _singleInstance;
  54448. private _cameras;
  54449. private _indicesForCamera;
  54450. /**
  54451. * Name of the effect
  54452. * @hidden
  54453. */
  54454. _name: string;
  54455. /**
  54456. * Instantiates a post process render effect.
  54457. * A post process can be used to apply a shader to a texture after it is rendered.
  54458. * @param engine The engine the effect is tied to
  54459. * @param name The name of the effect
  54460. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54461. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54462. */
  54463. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54464. /**
  54465. * Checks if all the post processes in the effect are supported.
  54466. */
  54467. readonly isSupported: boolean;
  54468. /**
  54469. * Updates the current state of the effect
  54470. * @hidden
  54471. */
  54472. _update(): void;
  54473. /**
  54474. * Attaches the effect on cameras
  54475. * @param cameras The camera to attach to.
  54476. * @hidden
  54477. */
  54478. _attachCameras(cameras: Camera): void;
  54479. /**
  54480. * Attaches the effect on cameras
  54481. * @param cameras The camera to attach to.
  54482. * @hidden
  54483. */
  54484. _attachCameras(cameras: Camera[]): void;
  54485. /**
  54486. * Detaches the effect on cameras
  54487. * @param cameras The camera to detatch from.
  54488. * @hidden
  54489. */
  54490. _detachCameras(cameras: Camera): void;
  54491. /**
  54492. * Detatches the effect on cameras
  54493. * @param cameras The camera to detatch from.
  54494. * @hidden
  54495. */
  54496. _detachCameras(cameras: Camera[]): void;
  54497. /**
  54498. * Enables the effect on given cameras
  54499. * @param cameras The camera to enable.
  54500. * @hidden
  54501. */
  54502. _enable(cameras: Camera): void;
  54503. /**
  54504. * Enables the effect on given cameras
  54505. * @param cameras The camera to enable.
  54506. * @hidden
  54507. */
  54508. _enable(cameras: Nullable<Camera[]>): void;
  54509. /**
  54510. * Disables the effect on the given cameras
  54511. * @param cameras The camera to disable.
  54512. * @hidden
  54513. */
  54514. _disable(cameras: Camera): void;
  54515. /**
  54516. * Disables the effect on the given cameras
  54517. * @param cameras The camera to disable.
  54518. * @hidden
  54519. */
  54520. _disable(cameras: Nullable<Camera[]>): void;
  54521. /**
  54522. * Gets a list of the post processes contained in the effect.
  54523. * @param camera The camera to get the post processes on.
  54524. * @returns The list of the post processes in the effect.
  54525. */
  54526. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54527. }
  54528. }
  54529. declare module BABYLON {
  54530. /** @hidden */
  54531. export var extractHighlightsPixelShader: {
  54532. name: string;
  54533. shader: string;
  54534. };
  54535. }
  54536. declare module BABYLON {
  54537. /**
  54538. * 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.
  54539. */
  54540. export class ExtractHighlightsPostProcess extends PostProcess {
  54541. /**
  54542. * The luminance threshold, pixels below this value will be set to black.
  54543. */
  54544. threshold: number;
  54545. /** @hidden */
  54546. _exposure: number;
  54547. /**
  54548. * Post process which has the input texture to be used when performing highlight extraction
  54549. * @hidden
  54550. */
  54551. _inputPostProcess: Nullable<PostProcess>;
  54552. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54553. }
  54554. }
  54555. declare module BABYLON {
  54556. /** @hidden */
  54557. export var bloomMergePixelShader: {
  54558. name: string;
  54559. shader: string;
  54560. };
  54561. }
  54562. declare module BABYLON {
  54563. /**
  54564. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54565. */
  54566. export class BloomMergePostProcess extends PostProcess {
  54567. /** Weight of the bloom to be added to the original input. */
  54568. weight: number;
  54569. /**
  54570. * Creates a new instance of @see BloomMergePostProcess
  54571. * @param name The name of the effect.
  54572. * @param originalFromInput Post process which's input will be used for the merge.
  54573. * @param blurred Blurred highlights post process which's output will be used.
  54574. * @param weight Weight of the bloom to be added to the original input.
  54575. * @param options The required width/height ratio to downsize to before computing the render pass.
  54576. * @param camera The camera to apply the render pass to.
  54577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54578. * @param engine The engine which the post process will be applied. (default: current engine)
  54579. * @param reusable If the post process can be reused on the same frame. (default: false)
  54580. * @param textureType Type of textures used when performing the post process. (default: 0)
  54581. * @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)
  54582. */
  54583. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54584. /** Weight of the bloom to be added to the original input. */
  54585. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54586. }
  54587. }
  54588. declare module BABYLON {
  54589. /**
  54590. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54591. */
  54592. export class BloomEffect extends PostProcessRenderEffect {
  54593. private bloomScale;
  54594. /**
  54595. * @hidden Internal
  54596. */
  54597. _effects: Array<PostProcess>;
  54598. /**
  54599. * @hidden Internal
  54600. */
  54601. _downscale: ExtractHighlightsPostProcess;
  54602. private _blurX;
  54603. private _blurY;
  54604. private _merge;
  54605. /**
  54606. * The luminance threshold to find bright areas of the image to bloom.
  54607. */
  54608. threshold: number;
  54609. /**
  54610. * The strength of the bloom.
  54611. */
  54612. weight: number;
  54613. /**
  54614. * Specifies the size of the bloom blur kernel, relative to the final output size
  54615. */
  54616. kernel: number;
  54617. /**
  54618. * Creates a new instance of @see BloomEffect
  54619. * @param scene The scene the effect belongs to.
  54620. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54621. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54622. * @param bloomWeight The the strength of bloom.
  54623. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54624. * @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)
  54625. */
  54626. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54627. /**
  54628. * Disposes each of the internal effects for a given camera.
  54629. * @param camera The camera to dispose the effect on.
  54630. */
  54631. disposeEffects(camera: Camera): void;
  54632. /**
  54633. * @hidden Internal
  54634. */
  54635. _updateEffects(): void;
  54636. /**
  54637. * Internal
  54638. * @returns if all the contained post processes are ready.
  54639. * @hidden
  54640. */
  54641. _isReady(): boolean;
  54642. }
  54643. }
  54644. declare module BABYLON {
  54645. /** @hidden */
  54646. export var chromaticAberrationPixelShader: {
  54647. name: string;
  54648. shader: string;
  54649. };
  54650. }
  54651. declare module BABYLON {
  54652. /**
  54653. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54654. */
  54655. export class ChromaticAberrationPostProcess extends PostProcess {
  54656. /**
  54657. * The amount of seperation of rgb channels (default: 30)
  54658. */
  54659. aberrationAmount: number;
  54660. /**
  54661. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54662. */
  54663. radialIntensity: number;
  54664. /**
  54665. * 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))
  54666. */
  54667. direction: Vector2;
  54668. /**
  54669. * 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))
  54670. */
  54671. centerPosition: Vector2;
  54672. /**
  54673. * Creates a new instance ChromaticAberrationPostProcess
  54674. * @param name The name of the effect.
  54675. * @param screenWidth The width of the screen to apply the effect on.
  54676. * @param screenHeight The height of the screen to apply the effect on.
  54677. * @param options The required width/height ratio to downsize to before computing the render pass.
  54678. * @param camera The camera to apply the render pass to.
  54679. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54680. * @param engine The engine which the post process will be applied. (default: current engine)
  54681. * @param reusable If the post process can be reused on the same frame. (default: false)
  54682. * @param textureType Type of textures used when performing the post process. (default: 0)
  54683. * @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)
  54684. */
  54685. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54686. }
  54687. }
  54688. declare module BABYLON {
  54689. /** @hidden */
  54690. export var circleOfConfusionPixelShader: {
  54691. name: string;
  54692. shader: string;
  54693. };
  54694. }
  54695. declare module BABYLON {
  54696. /**
  54697. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54698. */
  54699. export class CircleOfConfusionPostProcess extends PostProcess {
  54700. /**
  54701. * 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.
  54702. */
  54703. lensSize: number;
  54704. /**
  54705. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54706. */
  54707. fStop: number;
  54708. /**
  54709. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54710. */
  54711. focusDistance: number;
  54712. /**
  54713. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54714. */
  54715. focalLength: number;
  54716. private _depthTexture;
  54717. /**
  54718. * Creates a new instance CircleOfConfusionPostProcess
  54719. * @param name The name of the effect.
  54720. * @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.
  54721. * @param options The required width/height ratio to downsize to before computing the render pass.
  54722. * @param camera The camera to apply the render pass to.
  54723. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54724. * @param engine The engine which the post process will be applied. (default: current engine)
  54725. * @param reusable If the post process can be reused on the same frame. (default: false)
  54726. * @param textureType Type of textures used when performing the post process. (default: 0)
  54727. * @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)
  54728. */
  54729. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54730. /**
  54731. * 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.
  54732. */
  54733. depthTexture: RenderTargetTexture;
  54734. }
  54735. }
  54736. declare module BABYLON {
  54737. /** @hidden */
  54738. export var colorCorrectionPixelShader: {
  54739. name: string;
  54740. shader: string;
  54741. };
  54742. }
  54743. declare module BABYLON {
  54744. /**
  54745. *
  54746. * This post-process allows the modification of rendered colors by using
  54747. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54748. *
  54749. * The object needs to be provided an url to a texture containing the color
  54750. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54751. * Use an image editing software to tweak the LUT to match your needs.
  54752. *
  54753. * For an example of a color LUT, see here:
  54754. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54755. * For explanations on color grading, see here:
  54756. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54757. *
  54758. */
  54759. export class ColorCorrectionPostProcess extends PostProcess {
  54760. private _colorTableTexture;
  54761. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54762. }
  54763. }
  54764. declare module BABYLON {
  54765. /** @hidden */
  54766. export var convolutionPixelShader: {
  54767. name: string;
  54768. shader: string;
  54769. };
  54770. }
  54771. declare module BABYLON {
  54772. /**
  54773. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54774. * input texture to perform effects such as edge detection or sharpening
  54775. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54776. */
  54777. export class ConvolutionPostProcess extends PostProcess {
  54778. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54779. kernel: number[];
  54780. /**
  54781. * Creates a new instance ConvolutionPostProcess
  54782. * @param name The name of the effect.
  54783. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  54784. * @param options The required width/height ratio to downsize to before computing the render pass.
  54785. * @param camera The camera to apply the render pass to.
  54786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54787. * @param engine The engine which the post process will be applied. (default: current engine)
  54788. * @param reusable If the post process can be reused on the same frame. (default: false)
  54789. * @param textureType Type of textures used when performing the post process. (default: 0)
  54790. */
  54791. constructor(name: string,
  54792. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54793. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54794. /**
  54795. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54796. */
  54797. static EdgeDetect0Kernel: number[];
  54798. /**
  54799. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54800. */
  54801. static EdgeDetect1Kernel: number[];
  54802. /**
  54803. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54804. */
  54805. static EdgeDetect2Kernel: number[];
  54806. /**
  54807. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54808. */
  54809. static SharpenKernel: number[];
  54810. /**
  54811. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54812. */
  54813. static EmbossKernel: number[];
  54814. /**
  54815. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54816. */
  54817. static GaussianKernel: number[];
  54818. }
  54819. }
  54820. declare module BABYLON {
  54821. /**
  54822. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  54823. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  54824. * based on samples that have a large difference in distance than the center pixel.
  54825. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  54826. */
  54827. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  54828. direction: Vector2;
  54829. /**
  54830. * Creates a new instance CircleOfConfusionPostProcess
  54831. * @param name The name of the effect.
  54832. * @param scene The scene the effect belongs to.
  54833. * @param direction The direction the blur should be applied.
  54834. * @param kernel The size of the kernel used to blur.
  54835. * @param options The required width/height ratio to downsize to before computing the render pass.
  54836. * @param camera The camera to apply the render pass to.
  54837. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  54838. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  54839. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54840. * @param engine The engine which the post process will be applied. (default: current engine)
  54841. * @param reusable If the post process can be reused on the same frame. (default: false)
  54842. * @param textureType Type of textures used when performing the post process. (default: 0)
  54843. * @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)
  54844. */
  54845. 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);
  54846. }
  54847. }
  54848. declare module BABYLON {
  54849. /** @hidden */
  54850. export var depthOfFieldMergePixelShader: {
  54851. name: string;
  54852. shader: string;
  54853. };
  54854. }
  54855. declare module BABYLON {
  54856. /**
  54857. * Options to be set when merging outputs from the default pipeline.
  54858. */
  54859. export class DepthOfFieldMergePostProcessOptions {
  54860. /**
  54861. * The original image to merge on top of
  54862. */
  54863. originalFromInput: PostProcess;
  54864. /**
  54865. * Parameters to perform the merge of the depth of field effect
  54866. */
  54867. depthOfField?: {
  54868. circleOfConfusion: PostProcess;
  54869. blurSteps: Array<PostProcess>;
  54870. };
  54871. /**
  54872. * Parameters to perform the merge of bloom effect
  54873. */
  54874. bloom?: {
  54875. blurred: PostProcess;
  54876. weight: number;
  54877. };
  54878. }
  54879. /**
  54880. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54881. */
  54882. export class DepthOfFieldMergePostProcess extends PostProcess {
  54883. private blurSteps;
  54884. /**
  54885. * Creates a new instance of DepthOfFieldMergePostProcess
  54886. * @param name The name of the effect.
  54887. * @param originalFromInput Post process which's input will be used for the merge.
  54888. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54889. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54890. * @param options The required width/height ratio to downsize to before computing the render pass.
  54891. * @param camera The camera to apply the render pass to.
  54892. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54893. * @param engine The engine which the post process will be applied. (default: current engine)
  54894. * @param reusable If the post process can be reused on the same frame. (default: false)
  54895. * @param textureType Type of textures used when performing the post process. (default: 0)
  54896. * @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)
  54897. */
  54898. 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);
  54899. /**
  54900. * Updates the effect with the current post process compile time values and recompiles the shader.
  54901. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54902. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54903. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54904. * @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
  54905. * @param onCompiled Called when the shader has been compiled.
  54906. * @param onError Called if there is an error when compiling a shader.
  54907. */
  54908. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54909. }
  54910. }
  54911. declare module BABYLON {
  54912. /**
  54913. * Specifies the level of max blur that should be applied when using the depth of field effect
  54914. */
  54915. export enum DepthOfFieldEffectBlurLevel {
  54916. /**
  54917. * Subtle blur
  54918. */
  54919. Low = 0,
  54920. /**
  54921. * Medium blur
  54922. */
  54923. Medium = 1,
  54924. /**
  54925. * Large blur
  54926. */
  54927. High = 2
  54928. }
  54929. /**
  54930. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54931. */
  54932. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54933. private _circleOfConfusion;
  54934. /**
  54935. * @hidden Internal, blurs from high to low
  54936. */
  54937. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54938. private _depthOfFieldBlurY;
  54939. private _dofMerge;
  54940. /**
  54941. * @hidden Internal post processes in depth of field effect
  54942. */
  54943. _effects: Array<PostProcess>;
  54944. /**
  54945. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54946. */
  54947. focalLength: number;
  54948. /**
  54949. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54950. */
  54951. fStop: number;
  54952. /**
  54953. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54954. */
  54955. focusDistance: number;
  54956. /**
  54957. * 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.
  54958. */
  54959. lensSize: number;
  54960. /**
  54961. * Creates a new instance DepthOfFieldEffect
  54962. * @param scene The scene the effect belongs to.
  54963. * @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.
  54964. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54965. * @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)
  54966. */
  54967. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  54968. /**
  54969. * Get the current class name of the current effet
  54970. * @returns "DepthOfFieldEffect"
  54971. */
  54972. getClassName(): string;
  54973. /**
  54974. * 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.
  54975. */
  54976. depthTexture: RenderTargetTexture;
  54977. /**
  54978. * Disposes each of the internal effects for a given camera.
  54979. * @param camera The camera to dispose the effect on.
  54980. */
  54981. disposeEffects(camera: Camera): void;
  54982. /**
  54983. * @hidden Internal
  54984. */
  54985. _updateEffects(): void;
  54986. /**
  54987. * Internal
  54988. * @returns if all the contained post processes are ready.
  54989. * @hidden
  54990. */
  54991. _isReady(): boolean;
  54992. }
  54993. }
  54994. declare module BABYLON {
  54995. /** @hidden */
  54996. export var displayPassPixelShader: {
  54997. name: string;
  54998. shader: string;
  54999. };
  55000. }
  55001. declare module BABYLON {
  55002. /**
  55003. * DisplayPassPostProcess which produces an output the same as it's input
  55004. */
  55005. export class DisplayPassPostProcess extends PostProcess {
  55006. /**
  55007. * Creates the DisplayPassPostProcess
  55008. * @param name The name of the effect.
  55009. * @param options The required width/height ratio to downsize to before computing the render pass.
  55010. * @param camera The camera to apply the render pass to.
  55011. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55012. * @param engine The engine which the post process will be applied. (default: current engine)
  55013. * @param reusable If the post process can be reused on the same frame. (default: false)
  55014. */
  55015. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55016. }
  55017. }
  55018. declare module BABYLON {
  55019. /** @hidden */
  55020. export var filterPixelShader: {
  55021. name: string;
  55022. shader: string;
  55023. };
  55024. }
  55025. declare module BABYLON {
  55026. /**
  55027. * Applies a kernel filter to the image
  55028. */
  55029. export class FilterPostProcess extends PostProcess {
  55030. /** The matrix to be applied to the image */
  55031. kernelMatrix: Matrix;
  55032. /**
  55033. *
  55034. * @param name The name of the effect.
  55035. * @param kernelMatrix The matrix to be applied to the image
  55036. * @param options The required width/height ratio to downsize to before computing the render pass.
  55037. * @param camera The camera to apply the render pass to.
  55038. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55039. * @param engine The engine which the post process will be applied. (default: current engine)
  55040. * @param reusable If the post process can be reused on the same frame. (default: false)
  55041. */
  55042. constructor(name: string,
  55043. /** The matrix to be applied to the image */
  55044. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55045. }
  55046. }
  55047. declare module BABYLON {
  55048. /** @hidden */
  55049. export var fxaaPixelShader: {
  55050. name: string;
  55051. shader: string;
  55052. };
  55053. }
  55054. declare module BABYLON {
  55055. /** @hidden */
  55056. export var fxaaVertexShader: {
  55057. name: string;
  55058. shader: string;
  55059. };
  55060. }
  55061. declare module BABYLON {
  55062. /**
  55063. * Fxaa post process
  55064. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55065. */
  55066. export class FxaaPostProcess extends PostProcess {
  55067. /** @hidden */
  55068. texelWidth: number;
  55069. /** @hidden */
  55070. texelHeight: number;
  55071. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55072. private _getDefines;
  55073. }
  55074. }
  55075. declare module BABYLON {
  55076. /** @hidden */
  55077. export var grainPixelShader: {
  55078. name: string;
  55079. shader: string;
  55080. };
  55081. }
  55082. declare module BABYLON {
  55083. /**
  55084. * The GrainPostProcess adds noise to the image at mid luminance levels
  55085. */
  55086. export class GrainPostProcess extends PostProcess {
  55087. /**
  55088. * The intensity of the grain added (default: 30)
  55089. */
  55090. intensity: number;
  55091. /**
  55092. * If the grain should be randomized on every frame
  55093. */
  55094. animated: boolean;
  55095. /**
  55096. * Creates a new instance of @see GrainPostProcess
  55097. * @param name The name of the effect.
  55098. * @param options The required width/height ratio to downsize to before computing the render pass.
  55099. * @param camera The camera to apply the render pass to.
  55100. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55101. * @param engine The engine which the post process will be applied. (default: current engine)
  55102. * @param reusable If the post process can be reused on the same frame. (default: false)
  55103. * @param textureType Type of textures used when performing the post process. (default: 0)
  55104. * @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)
  55105. */
  55106. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55107. }
  55108. }
  55109. declare module BABYLON {
  55110. /** @hidden */
  55111. export var highlightsPixelShader: {
  55112. name: string;
  55113. shader: string;
  55114. };
  55115. }
  55116. declare module BABYLON {
  55117. /**
  55118. * Extracts highlights from the image
  55119. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55120. */
  55121. export class HighlightsPostProcess extends PostProcess {
  55122. /**
  55123. * Extracts highlights from the image
  55124. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55125. * @param name The name of the effect.
  55126. * @param options The required width/height ratio to downsize to before computing the render pass.
  55127. * @param camera The camera to apply the render pass to.
  55128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55129. * @param engine The engine which the post process will be applied. (default: current engine)
  55130. * @param reusable If the post process can be reused on the same frame. (default: false)
  55131. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55132. */
  55133. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55134. }
  55135. }
  55136. declare module BABYLON {
  55137. /** @hidden */
  55138. export var mrtFragmentDeclaration: {
  55139. name: string;
  55140. shader: string;
  55141. };
  55142. }
  55143. declare module BABYLON {
  55144. /** @hidden */
  55145. export var geometryPixelShader: {
  55146. name: string;
  55147. shader: string;
  55148. };
  55149. }
  55150. declare module BABYLON {
  55151. /** @hidden */
  55152. export var geometryVertexShader: {
  55153. name: string;
  55154. shader: string;
  55155. };
  55156. }
  55157. declare module BABYLON {
  55158. /** @hidden */
  55159. interface ISavedTransformationMatrix {
  55160. world: Matrix;
  55161. viewProjection: Matrix;
  55162. }
  55163. /**
  55164. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55165. */
  55166. export class GeometryBufferRenderer {
  55167. /**
  55168. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55169. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55170. */
  55171. static readonly POSITION_TEXTURE_TYPE: number;
  55172. /**
  55173. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55174. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55175. */
  55176. static readonly VELOCITY_TEXTURE_TYPE: number;
  55177. /**
  55178. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55179. * in order to compute objects velocities when enableVelocity is set to "true"
  55180. * @hidden
  55181. */
  55182. _previousTransformationMatrices: {
  55183. [index: number]: ISavedTransformationMatrix;
  55184. };
  55185. /**
  55186. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  55187. * in order to compute objects velocities when enableVelocity is set to "true"
  55188. * @hidden
  55189. */
  55190. _previousBonesTransformationMatrices: {
  55191. [index: number]: Float32Array;
  55192. };
  55193. /**
  55194. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  55195. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  55196. */
  55197. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  55198. private _scene;
  55199. private _multiRenderTarget;
  55200. private _ratio;
  55201. private _enablePosition;
  55202. private _enableVelocity;
  55203. private _positionIndex;
  55204. private _velocityIndex;
  55205. protected _effect: Effect;
  55206. protected _cachedDefines: string;
  55207. /**
  55208. * Set the render list (meshes to be rendered) used in the G buffer.
  55209. */
  55210. renderList: Mesh[];
  55211. /**
  55212. * Gets wether or not G buffer are supported by the running hardware.
  55213. * This requires draw buffer supports
  55214. */
  55215. readonly isSupported: boolean;
  55216. /**
  55217. * Returns the index of the given texture type in the G-Buffer textures array
  55218. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55219. * @returns the index of the given texture type in the G-Buffer textures array
  55220. */
  55221. getTextureIndex(textureType: number): number;
  55222. /**
  55223. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55224. */
  55225. /**
  55226. * Sets whether or not objects positions are enabled for the G buffer.
  55227. */
  55228. enablePosition: boolean;
  55229. /**
  55230. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55231. */
  55232. /**
  55233. * Sets wether or not objects velocities are enabled for the G buffer.
  55234. */
  55235. enableVelocity: boolean;
  55236. /**
  55237. * Gets the scene associated with the buffer.
  55238. */
  55239. readonly scene: Scene;
  55240. /**
  55241. * Gets the ratio used by the buffer during its creation.
  55242. * How big is the buffer related to the main canvas.
  55243. */
  55244. readonly ratio: number;
  55245. /** @hidden */
  55246. static _SceneComponentInitialization: (scene: Scene) => void;
  55247. /**
  55248. * Creates a new G Buffer for the scene
  55249. * @param scene The scene the buffer belongs to
  55250. * @param ratio How big is the buffer related to the main canvas.
  55251. */
  55252. constructor(scene: Scene, ratio?: number);
  55253. /**
  55254. * Checks wether everything is ready to render a submesh to the G buffer.
  55255. * @param subMesh the submesh to check readiness for
  55256. * @param useInstances is the mesh drawn using instance or not
  55257. * @returns true if ready otherwise false
  55258. */
  55259. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55260. /**
  55261. * Gets the current underlying G Buffer.
  55262. * @returns the buffer
  55263. */
  55264. getGBuffer(): MultiRenderTarget;
  55265. /**
  55266. * Gets the number of samples used to render the buffer (anti aliasing).
  55267. */
  55268. /**
  55269. * Sets the number of samples used to render the buffer (anti aliasing).
  55270. */
  55271. samples: number;
  55272. /**
  55273. * Disposes the renderer and frees up associated resources.
  55274. */
  55275. dispose(): void;
  55276. protected _createRenderTargets(): void;
  55277. private _copyBonesTransformationMatrices;
  55278. }
  55279. }
  55280. declare module BABYLON {
  55281. interface Scene {
  55282. /** @hidden (Backing field) */
  55283. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55284. /**
  55285. * Gets or Sets the current geometry buffer associated to the scene.
  55286. */
  55287. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55288. /**
  55289. * Enables a GeometryBufferRender and associates it with the scene
  55290. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55291. * @returns the GeometryBufferRenderer
  55292. */
  55293. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55294. /**
  55295. * Disables the GeometryBufferRender associated with the scene
  55296. */
  55297. disableGeometryBufferRenderer(): void;
  55298. }
  55299. /**
  55300. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55301. * in several rendering techniques.
  55302. */
  55303. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55304. /**
  55305. * The component name helpful to identify the component in the list of scene components.
  55306. */
  55307. readonly name: string;
  55308. /**
  55309. * The scene the component belongs to.
  55310. */
  55311. scene: Scene;
  55312. /**
  55313. * Creates a new instance of the component for the given scene
  55314. * @param scene Defines the scene to register the component in
  55315. */
  55316. constructor(scene: Scene);
  55317. /**
  55318. * Registers the component in a given scene
  55319. */
  55320. register(): void;
  55321. /**
  55322. * Rebuilds the elements related to this component in case of
  55323. * context lost for instance.
  55324. */
  55325. rebuild(): void;
  55326. /**
  55327. * Disposes the component and the associated ressources
  55328. */
  55329. dispose(): void;
  55330. private _gatherRenderTargets;
  55331. }
  55332. }
  55333. declare module BABYLON {
  55334. /** @hidden */
  55335. export var motionBlurPixelShader: {
  55336. name: string;
  55337. shader: string;
  55338. };
  55339. }
  55340. declare module BABYLON {
  55341. /**
  55342. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55343. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55344. * As an example, all you have to do is to create the post-process:
  55345. * var mb = new BABYLON.MotionBlurPostProcess(
  55346. * 'mb', // The name of the effect.
  55347. * scene, // The scene containing the objects to blur according to their velocity.
  55348. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55349. * camera // The camera to apply the render pass to.
  55350. * );
  55351. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55352. */
  55353. export class MotionBlurPostProcess extends PostProcess {
  55354. /**
  55355. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55356. */
  55357. motionStrength: number;
  55358. /**
  55359. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55360. */
  55361. /**
  55362. * Sets the number of iterations to be used for motion blur quality
  55363. */
  55364. motionBlurSamples: number;
  55365. private _motionBlurSamples;
  55366. private _geometryBufferRenderer;
  55367. /**
  55368. * Creates a new instance MotionBlurPostProcess
  55369. * @param name The name of the effect.
  55370. * @param scene The scene containing the objects to blur according to their velocity.
  55371. * @param options The required width/height ratio to downsize to before computing the render pass.
  55372. * @param camera The camera to apply the render pass to.
  55373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55374. * @param engine The engine which the post process will be applied. (default: current engine)
  55375. * @param reusable If the post process can be reused on the same frame. (default: false)
  55376. * @param textureType Type of textures used when performing the post process. (default: 0)
  55377. * @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)
  55378. */
  55379. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55380. /**
  55381. * Excludes the given skinned mesh from computing bones velocities.
  55382. * 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.
  55383. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  55384. */
  55385. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55386. /**
  55387. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  55388. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  55389. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  55390. */
  55391. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55392. /**
  55393. * Disposes the post process.
  55394. * @param camera The camera to dispose the post process on.
  55395. */
  55396. dispose(camera?: Camera): void;
  55397. }
  55398. }
  55399. declare module BABYLON {
  55400. /** @hidden */
  55401. export var refractionPixelShader: {
  55402. name: string;
  55403. shader: string;
  55404. };
  55405. }
  55406. declare module BABYLON {
  55407. /**
  55408. * Post process which applies a refractin texture
  55409. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55410. */
  55411. export class RefractionPostProcess extends PostProcess {
  55412. /** the base color of the refraction (used to taint the rendering) */
  55413. color: Color3;
  55414. /** simulated refraction depth */
  55415. depth: number;
  55416. /** the coefficient of the base color (0 to remove base color tainting) */
  55417. colorLevel: number;
  55418. private _refTexture;
  55419. private _ownRefractionTexture;
  55420. /**
  55421. * Gets or sets the refraction texture
  55422. * Please note that you are responsible for disposing the texture if you set it manually
  55423. */
  55424. refractionTexture: Texture;
  55425. /**
  55426. * Initializes the RefractionPostProcess
  55427. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55428. * @param name The name of the effect.
  55429. * @param refractionTextureUrl Url of the refraction texture to use
  55430. * @param color the base color of the refraction (used to taint the rendering)
  55431. * @param depth simulated refraction depth
  55432. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55433. * @param camera The camera to apply the render pass to.
  55434. * @param options The required width/height ratio to downsize to before computing the render pass.
  55435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55436. * @param engine The engine which the post process will be applied. (default: current engine)
  55437. * @param reusable If the post process can be reused on the same frame. (default: false)
  55438. */
  55439. constructor(name: string, refractionTextureUrl: string,
  55440. /** the base color of the refraction (used to taint the rendering) */
  55441. color: Color3,
  55442. /** simulated refraction depth */
  55443. depth: number,
  55444. /** the coefficient of the base color (0 to remove base color tainting) */
  55445. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55446. /**
  55447. * Disposes of the post process
  55448. * @param camera Camera to dispose post process on
  55449. */
  55450. dispose(camera: Camera): void;
  55451. }
  55452. }
  55453. declare module BABYLON {
  55454. /** @hidden */
  55455. export var sharpenPixelShader: {
  55456. name: string;
  55457. shader: string;
  55458. };
  55459. }
  55460. declare module BABYLON {
  55461. /**
  55462. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55463. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55464. */
  55465. export class SharpenPostProcess extends PostProcess {
  55466. /**
  55467. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55468. */
  55469. colorAmount: number;
  55470. /**
  55471. * How much sharpness should be applied (default: 0.3)
  55472. */
  55473. edgeAmount: number;
  55474. /**
  55475. * Creates a new instance ConvolutionPostProcess
  55476. * @param name The name of the effect.
  55477. * @param options The required width/height ratio to downsize to before computing the render pass.
  55478. * @param camera The camera to apply the render pass to.
  55479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55480. * @param engine The engine which the post process will be applied. (default: current engine)
  55481. * @param reusable If the post process can be reused on the same frame. (default: false)
  55482. * @param textureType Type of textures used when performing the post process. (default: 0)
  55483. * @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)
  55484. */
  55485. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55486. }
  55487. }
  55488. declare module BABYLON {
  55489. /**
  55490. * PostProcessRenderPipeline
  55491. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55492. */
  55493. export class PostProcessRenderPipeline {
  55494. private engine;
  55495. private _renderEffects;
  55496. private _renderEffectsForIsolatedPass;
  55497. /**
  55498. * List of inspectable custom properties (used by the Inspector)
  55499. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55500. */
  55501. inspectableCustomProperties: IInspectable[];
  55502. /**
  55503. * @hidden
  55504. */
  55505. protected _cameras: Camera[];
  55506. /** @hidden */
  55507. _name: string;
  55508. /**
  55509. * Gets pipeline name
  55510. */
  55511. readonly name: string;
  55512. /**
  55513. * Initializes a PostProcessRenderPipeline
  55514. * @param engine engine to add the pipeline to
  55515. * @param name name of the pipeline
  55516. */
  55517. constructor(engine: Engine, name: string);
  55518. /**
  55519. * Gets the class name
  55520. * @returns "PostProcessRenderPipeline"
  55521. */
  55522. getClassName(): string;
  55523. /**
  55524. * If all the render effects in the pipeline are supported
  55525. */
  55526. readonly isSupported: boolean;
  55527. /**
  55528. * Adds an effect to the pipeline
  55529. * @param renderEffect the effect to add
  55530. */
  55531. addEffect(renderEffect: PostProcessRenderEffect): void;
  55532. /** @hidden */
  55533. _rebuild(): void;
  55534. /** @hidden */
  55535. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55536. /** @hidden */
  55537. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55538. /** @hidden */
  55539. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55540. /** @hidden */
  55541. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55542. /** @hidden */
  55543. _attachCameras(cameras: Camera, unique: boolean): void;
  55544. /** @hidden */
  55545. _attachCameras(cameras: Camera[], unique: boolean): void;
  55546. /** @hidden */
  55547. _detachCameras(cameras: Camera): void;
  55548. /** @hidden */
  55549. _detachCameras(cameras: Nullable<Camera[]>): void;
  55550. /** @hidden */
  55551. _update(): void;
  55552. /** @hidden */
  55553. _reset(): void;
  55554. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55555. /**
  55556. * Disposes of the pipeline
  55557. */
  55558. dispose(): void;
  55559. }
  55560. }
  55561. declare module BABYLON {
  55562. /**
  55563. * PostProcessRenderPipelineManager class
  55564. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55565. */
  55566. export class PostProcessRenderPipelineManager {
  55567. private _renderPipelines;
  55568. /**
  55569. * Initializes a PostProcessRenderPipelineManager
  55570. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55571. */
  55572. constructor();
  55573. /**
  55574. * Gets the list of supported render pipelines
  55575. */
  55576. readonly supportedPipelines: PostProcessRenderPipeline[];
  55577. /**
  55578. * Adds a pipeline to the manager
  55579. * @param renderPipeline The pipeline to add
  55580. */
  55581. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55582. /**
  55583. * Attaches a camera to the pipeline
  55584. * @param renderPipelineName The name of the pipeline to attach to
  55585. * @param cameras the camera to attach
  55586. * @param unique if the camera can be attached multiple times to the pipeline
  55587. */
  55588. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55589. /**
  55590. * Detaches a camera from the pipeline
  55591. * @param renderPipelineName The name of the pipeline to detach from
  55592. * @param cameras the camera to detach
  55593. */
  55594. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55595. /**
  55596. * Enables an effect by name on a pipeline
  55597. * @param renderPipelineName the name of the pipeline to enable the effect in
  55598. * @param renderEffectName the name of the effect to enable
  55599. * @param cameras the cameras that the effect should be enabled on
  55600. */
  55601. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55602. /**
  55603. * Disables an effect by name on a pipeline
  55604. * @param renderPipelineName the name of the pipeline to disable the effect in
  55605. * @param renderEffectName the name of the effect to disable
  55606. * @param cameras the cameras that the effect should be disabled on
  55607. */
  55608. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55609. /**
  55610. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55611. */
  55612. update(): void;
  55613. /** @hidden */
  55614. _rebuild(): void;
  55615. /**
  55616. * Disposes of the manager and pipelines
  55617. */
  55618. dispose(): void;
  55619. }
  55620. }
  55621. declare module BABYLON {
  55622. interface Scene {
  55623. /** @hidden (Backing field) */
  55624. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55625. /**
  55626. * Gets the postprocess render pipeline manager
  55627. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55628. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55629. */
  55630. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55631. }
  55632. /**
  55633. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55634. */
  55635. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55636. /**
  55637. * The component name helpfull to identify the component in the list of scene components.
  55638. */
  55639. readonly name: string;
  55640. /**
  55641. * The scene the component belongs to.
  55642. */
  55643. scene: Scene;
  55644. /**
  55645. * Creates a new instance of the component for the given scene
  55646. * @param scene Defines the scene to register the component in
  55647. */
  55648. constructor(scene: Scene);
  55649. /**
  55650. * Registers the component in a given scene
  55651. */
  55652. register(): void;
  55653. /**
  55654. * Rebuilds the elements related to this component in case of
  55655. * context lost for instance.
  55656. */
  55657. rebuild(): void;
  55658. /**
  55659. * Disposes the component and the associated ressources
  55660. */
  55661. dispose(): void;
  55662. private _gatherRenderTargets;
  55663. }
  55664. }
  55665. declare module BABYLON {
  55666. /**
  55667. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55668. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55669. */
  55670. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55671. private _scene;
  55672. private _camerasToBeAttached;
  55673. /**
  55674. * ID of the sharpen post process,
  55675. */
  55676. private readonly SharpenPostProcessId;
  55677. /**
  55678. * @ignore
  55679. * ID of the image processing post process;
  55680. */
  55681. readonly ImageProcessingPostProcessId: string;
  55682. /**
  55683. * @ignore
  55684. * ID of the Fast Approximate Anti-Aliasing post process;
  55685. */
  55686. readonly FxaaPostProcessId: string;
  55687. /**
  55688. * ID of the chromatic aberration post process,
  55689. */
  55690. private readonly ChromaticAberrationPostProcessId;
  55691. /**
  55692. * ID of the grain post process
  55693. */
  55694. private readonly GrainPostProcessId;
  55695. /**
  55696. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55697. */
  55698. sharpen: SharpenPostProcess;
  55699. private _sharpenEffect;
  55700. private bloom;
  55701. /**
  55702. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55703. */
  55704. depthOfField: DepthOfFieldEffect;
  55705. /**
  55706. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55707. */
  55708. fxaa: FxaaPostProcess;
  55709. /**
  55710. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55711. */
  55712. imageProcessing: ImageProcessingPostProcess;
  55713. /**
  55714. * Chromatic aberration post process which will shift rgb colors in the image
  55715. */
  55716. chromaticAberration: ChromaticAberrationPostProcess;
  55717. private _chromaticAberrationEffect;
  55718. /**
  55719. * Grain post process which add noise to the image
  55720. */
  55721. grain: GrainPostProcess;
  55722. private _grainEffect;
  55723. /**
  55724. * Glow post process which adds a glow to emissive areas of the image
  55725. */
  55726. private _glowLayer;
  55727. /**
  55728. * Animations which can be used to tweak settings over a period of time
  55729. */
  55730. animations: Animation[];
  55731. private _imageProcessingConfigurationObserver;
  55732. private _sharpenEnabled;
  55733. private _bloomEnabled;
  55734. private _depthOfFieldEnabled;
  55735. private _depthOfFieldBlurLevel;
  55736. private _fxaaEnabled;
  55737. private _imageProcessingEnabled;
  55738. private _defaultPipelineTextureType;
  55739. private _bloomScale;
  55740. private _chromaticAberrationEnabled;
  55741. private _grainEnabled;
  55742. private _buildAllowed;
  55743. /**
  55744. * Gets active scene
  55745. */
  55746. readonly scene: Scene;
  55747. /**
  55748. * Enable or disable the sharpen process from the pipeline
  55749. */
  55750. sharpenEnabled: boolean;
  55751. private _resizeObserver;
  55752. private _hardwareScaleLevel;
  55753. private _bloomKernel;
  55754. /**
  55755. * Specifies the size of the bloom blur kernel, relative to the final output size
  55756. */
  55757. bloomKernel: number;
  55758. /**
  55759. * Specifies the weight of the bloom in the final rendering
  55760. */
  55761. private _bloomWeight;
  55762. /**
  55763. * Specifies the luma threshold for the area that will be blurred by the bloom
  55764. */
  55765. private _bloomThreshold;
  55766. private _hdr;
  55767. /**
  55768. * The strength of the bloom.
  55769. */
  55770. bloomWeight: number;
  55771. /**
  55772. * The strength of the bloom.
  55773. */
  55774. bloomThreshold: number;
  55775. /**
  55776. * The scale of the bloom, lower value will provide better performance.
  55777. */
  55778. bloomScale: number;
  55779. /**
  55780. * Enable or disable the bloom from the pipeline
  55781. */
  55782. bloomEnabled: boolean;
  55783. private _rebuildBloom;
  55784. /**
  55785. * If the depth of field is enabled.
  55786. */
  55787. depthOfFieldEnabled: boolean;
  55788. /**
  55789. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55790. */
  55791. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55792. /**
  55793. * If the anti aliasing is enabled.
  55794. */
  55795. fxaaEnabled: boolean;
  55796. private _samples;
  55797. /**
  55798. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55799. */
  55800. samples: number;
  55801. /**
  55802. * If image processing is enabled.
  55803. */
  55804. imageProcessingEnabled: boolean;
  55805. /**
  55806. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  55807. */
  55808. glowLayerEnabled: boolean;
  55809. /**
  55810. * Gets the glow layer (or null if not defined)
  55811. */
  55812. readonly glowLayer: Nullable<GlowLayer>;
  55813. /**
  55814. * Enable or disable the chromaticAberration process from the pipeline
  55815. */
  55816. chromaticAberrationEnabled: boolean;
  55817. /**
  55818. * Enable or disable the grain process from the pipeline
  55819. */
  55820. grainEnabled: boolean;
  55821. /**
  55822. * @constructor
  55823. * @param name - The rendering pipeline name (default: "")
  55824. * @param hdr - If high dynamic range textures should be used (default: true)
  55825. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55826. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55827. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55828. */
  55829. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55830. /**
  55831. * Get the class name
  55832. * @returns "DefaultRenderingPipeline"
  55833. */
  55834. getClassName(): string;
  55835. /**
  55836. * Force the compilation of the entire pipeline.
  55837. */
  55838. prepare(): void;
  55839. private _hasCleared;
  55840. private _prevPostProcess;
  55841. private _prevPrevPostProcess;
  55842. private _setAutoClearAndTextureSharing;
  55843. private _depthOfFieldSceneObserver;
  55844. private _buildPipeline;
  55845. private _disposePostProcesses;
  55846. /**
  55847. * Adds a camera to the pipeline
  55848. * @param camera the camera to be added
  55849. */
  55850. addCamera(camera: Camera): void;
  55851. /**
  55852. * Removes a camera from the pipeline
  55853. * @param camera the camera to remove
  55854. */
  55855. removeCamera(camera: Camera): void;
  55856. /**
  55857. * Dispose of the pipeline and stop all post processes
  55858. */
  55859. dispose(): void;
  55860. /**
  55861. * Serialize the rendering pipeline (Used when exporting)
  55862. * @returns the serialized object
  55863. */
  55864. serialize(): any;
  55865. /**
  55866. * Parse the serialized pipeline
  55867. * @param source Source pipeline.
  55868. * @param scene The scene to load the pipeline to.
  55869. * @param rootUrl The URL of the serialized pipeline.
  55870. * @returns An instantiated pipeline from the serialized object.
  55871. */
  55872. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55873. }
  55874. }
  55875. declare module BABYLON {
  55876. /** @hidden */
  55877. export var lensHighlightsPixelShader: {
  55878. name: string;
  55879. shader: string;
  55880. };
  55881. }
  55882. declare module BABYLON {
  55883. /** @hidden */
  55884. export var depthOfFieldPixelShader: {
  55885. name: string;
  55886. shader: string;
  55887. };
  55888. }
  55889. declare module BABYLON {
  55890. /**
  55891. * BABYLON.JS Chromatic Aberration GLSL Shader
  55892. * Author: Olivier Guyot
  55893. * Separates very slightly R, G and B colors on the edges of the screen
  55894. * Inspired by Francois Tarlier & Martins Upitis
  55895. */
  55896. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  55897. /**
  55898. * @ignore
  55899. * The chromatic aberration PostProcess id in the pipeline
  55900. */
  55901. LensChromaticAberrationEffect: string;
  55902. /**
  55903. * @ignore
  55904. * The highlights enhancing PostProcess id in the pipeline
  55905. */
  55906. HighlightsEnhancingEffect: string;
  55907. /**
  55908. * @ignore
  55909. * The depth-of-field PostProcess id in the pipeline
  55910. */
  55911. LensDepthOfFieldEffect: string;
  55912. private _scene;
  55913. private _depthTexture;
  55914. private _grainTexture;
  55915. private _chromaticAberrationPostProcess;
  55916. private _highlightsPostProcess;
  55917. private _depthOfFieldPostProcess;
  55918. private _edgeBlur;
  55919. private _grainAmount;
  55920. private _chromaticAberration;
  55921. private _distortion;
  55922. private _highlightsGain;
  55923. private _highlightsThreshold;
  55924. private _dofDistance;
  55925. private _dofAperture;
  55926. private _dofDarken;
  55927. private _dofPentagon;
  55928. private _blurNoise;
  55929. /**
  55930. * @constructor
  55931. *
  55932. * Effect parameters are as follow:
  55933. * {
  55934. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55935. * edge_blur: number; // from 0 to x (1 for realism)
  55936. * distortion: number; // from 0 to x (1 for realism)
  55937. * grain_amount: number; // from 0 to 1
  55938. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55939. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55940. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55941. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55942. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55943. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55944. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55945. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55946. * }
  55947. * Note: if an effect parameter is unset, effect is disabled
  55948. *
  55949. * @param name The rendering pipeline name
  55950. * @param parameters - An object containing all parameters (see above)
  55951. * @param scene The scene linked to this pipeline
  55952. * @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)
  55953. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55954. */
  55955. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55956. /**
  55957. * Get the class name
  55958. * @returns "LensRenderingPipeline"
  55959. */
  55960. getClassName(): string;
  55961. /**
  55962. * Gets associated scene
  55963. */
  55964. readonly scene: Scene;
  55965. /**
  55966. * Gets or sets the edge blur
  55967. */
  55968. edgeBlur: number;
  55969. /**
  55970. * Gets or sets the grain amount
  55971. */
  55972. grainAmount: number;
  55973. /**
  55974. * Gets or sets the chromatic aberration amount
  55975. */
  55976. chromaticAberration: number;
  55977. /**
  55978. * Gets or sets the depth of field aperture
  55979. */
  55980. dofAperture: number;
  55981. /**
  55982. * Gets or sets the edge distortion
  55983. */
  55984. edgeDistortion: number;
  55985. /**
  55986. * Gets or sets the depth of field distortion
  55987. */
  55988. dofDistortion: number;
  55989. /**
  55990. * Gets or sets the darken out of focus amount
  55991. */
  55992. darkenOutOfFocus: number;
  55993. /**
  55994. * Gets or sets a boolean indicating if blur noise is enabled
  55995. */
  55996. blurNoise: boolean;
  55997. /**
  55998. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55999. */
  56000. pentagonBokeh: boolean;
  56001. /**
  56002. * Gets or sets the highlight grain amount
  56003. */
  56004. highlightsGain: number;
  56005. /**
  56006. * Gets or sets the highlight threshold
  56007. */
  56008. highlightsThreshold: number;
  56009. /**
  56010. * Sets the amount of blur at the edges
  56011. * @param amount blur amount
  56012. */
  56013. setEdgeBlur(amount: number): void;
  56014. /**
  56015. * Sets edge blur to 0
  56016. */
  56017. disableEdgeBlur(): void;
  56018. /**
  56019. * Sets the amout of grain
  56020. * @param amount Amount of grain
  56021. */
  56022. setGrainAmount(amount: number): void;
  56023. /**
  56024. * Set grain amount to 0
  56025. */
  56026. disableGrain(): void;
  56027. /**
  56028. * Sets the chromatic aberration amount
  56029. * @param amount amount of chromatic aberration
  56030. */
  56031. setChromaticAberration(amount: number): void;
  56032. /**
  56033. * Sets chromatic aberration amount to 0
  56034. */
  56035. disableChromaticAberration(): void;
  56036. /**
  56037. * Sets the EdgeDistortion amount
  56038. * @param amount amount of EdgeDistortion
  56039. */
  56040. setEdgeDistortion(amount: number): void;
  56041. /**
  56042. * Sets edge distortion to 0
  56043. */
  56044. disableEdgeDistortion(): void;
  56045. /**
  56046. * Sets the FocusDistance amount
  56047. * @param amount amount of FocusDistance
  56048. */
  56049. setFocusDistance(amount: number): void;
  56050. /**
  56051. * Disables depth of field
  56052. */
  56053. disableDepthOfField(): void;
  56054. /**
  56055. * Sets the Aperture amount
  56056. * @param amount amount of Aperture
  56057. */
  56058. setAperture(amount: number): void;
  56059. /**
  56060. * Sets the DarkenOutOfFocus amount
  56061. * @param amount amount of DarkenOutOfFocus
  56062. */
  56063. setDarkenOutOfFocus(amount: number): void;
  56064. private _pentagonBokehIsEnabled;
  56065. /**
  56066. * Creates a pentagon bokeh effect
  56067. */
  56068. enablePentagonBokeh(): void;
  56069. /**
  56070. * Disables the pentagon bokeh effect
  56071. */
  56072. disablePentagonBokeh(): void;
  56073. /**
  56074. * Enables noise blur
  56075. */
  56076. enableNoiseBlur(): void;
  56077. /**
  56078. * Disables noise blur
  56079. */
  56080. disableNoiseBlur(): void;
  56081. /**
  56082. * Sets the HighlightsGain amount
  56083. * @param amount amount of HighlightsGain
  56084. */
  56085. setHighlightsGain(amount: number): void;
  56086. /**
  56087. * Sets the HighlightsThreshold amount
  56088. * @param amount amount of HighlightsThreshold
  56089. */
  56090. setHighlightsThreshold(amount: number): void;
  56091. /**
  56092. * Disables highlights
  56093. */
  56094. disableHighlights(): void;
  56095. /**
  56096. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56097. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56098. */
  56099. dispose(disableDepthRender?: boolean): void;
  56100. private _createChromaticAberrationPostProcess;
  56101. private _createHighlightsPostProcess;
  56102. private _createDepthOfFieldPostProcess;
  56103. private _createGrainTexture;
  56104. }
  56105. }
  56106. declare module BABYLON {
  56107. /** @hidden */
  56108. export var ssao2PixelShader: {
  56109. name: string;
  56110. shader: string;
  56111. };
  56112. }
  56113. declare module BABYLON {
  56114. /** @hidden */
  56115. export var ssaoCombinePixelShader: {
  56116. name: string;
  56117. shader: string;
  56118. };
  56119. }
  56120. declare module BABYLON {
  56121. /**
  56122. * Render pipeline to produce ssao effect
  56123. */
  56124. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56125. /**
  56126. * @ignore
  56127. * The PassPostProcess id in the pipeline that contains the original scene color
  56128. */
  56129. SSAOOriginalSceneColorEffect: string;
  56130. /**
  56131. * @ignore
  56132. * The SSAO PostProcess id in the pipeline
  56133. */
  56134. SSAORenderEffect: string;
  56135. /**
  56136. * @ignore
  56137. * The horizontal blur PostProcess id in the pipeline
  56138. */
  56139. SSAOBlurHRenderEffect: string;
  56140. /**
  56141. * @ignore
  56142. * The vertical blur PostProcess id in the pipeline
  56143. */
  56144. SSAOBlurVRenderEffect: string;
  56145. /**
  56146. * @ignore
  56147. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56148. */
  56149. SSAOCombineRenderEffect: string;
  56150. /**
  56151. * The output strength of the SSAO post-process. Default value is 1.0.
  56152. */
  56153. totalStrength: number;
  56154. /**
  56155. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56156. */
  56157. maxZ: number;
  56158. /**
  56159. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56160. */
  56161. minZAspect: number;
  56162. private _samples;
  56163. /**
  56164. * Number of samples used for the SSAO calculations. Default value is 8
  56165. */
  56166. samples: number;
  56167. private _textureSamples;
  56168. /**
  56169. * Number of samples to use for antialiasing
  56170. */
  56171. textureSamples: number;
  56172. /**
  56173. * Ratio object used for SSAO ratio and blur ratio
  56174. */
  56175. private _ratio;
  56176. /**
  56177. * Dynamically generated sphere sampler.
  56178. */
  56179. private _sampleSphere;
  56180. /**
  56181. * Blur filter offsets
  56182. */
  56183. private _samplerOffsets;
  56184. private _expensiveBlur;
  56185. /**
  56186. * If bilateral blur should be used
  56187. */
  56188. expensiveBlur: boolean;
  56189. /**
  56190. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56191. */
  56192. radius: number;
  56193. /**
  56194. * The base color of the SSAO post-process
  56195. * The final result is "base + ssao" between [0, 1]
  56196. */
  56197. base: number;
  56198. /**
  56199. * Support test.
  56200. */
  56201. static readonly IsSupported: boolean;
  56202. private _scene;
  56203. private _depthTexture;
  56204. private _normalTexture;
  56205. private _randomTexture;
  56206. private _originalColorPostProcess;
  56207. private _ssaoPostProcess;
  56208. private _blurHPostProcess;
  56209. private _blurVPostProcess;
  56210. private _ssaoCombinePostProcess;
  56211. private _firstUpdate;
  56212. /**
  56213. * Gets active scene
  56214. */
  56215. readonly scene: Scene;
  56216. /**
  56217. * @constructor
  56218. * @param name The rendering pipeline name
  56219. * @param scene The scene linked to this pipeline
  56220. * @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 }
  56221. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56222. */
  56223. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56224. /**
  56225. * Get the class name
  56226. * @returns "SSAO2RenderingPipeline"
  56227. */
  56228. getClassName(): string;
  56229. /**
  56230. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56231. */
  56232. dispose(disableGeometryBufferRenderer?: boolean): void;
  56233. private _createBlurPostProcess;
  56234. /** @hidden */
  56235. _rebuild(): void;
  56236. private _bits;
  56237. private _radicalInverse_VdC;
  56238. private _hammersley;
  56239. private _hemisphereSample_uniform;
  56240. private _generateHemisphere;
  56241. private _createSSAOPostProcess;
  56242. private _createSSAOCombinePostProcess;
  56243. private _createRandomTexture;
  56244. /**
  56245. * Serialize the rendering pipeline (Used when exporting)
  56246. * @returns the serialized object
  56247. */
  56248. serialize(): any;
  56249. /**
  56250. * Parse the serialized pipeline
  56251. * @param source Source pipeline.
  56252. * @param scene The scene to load the pipeline to.
  56253. * @param rootUrl The URL of the serialized pipeline.
  56254. * @returns An instantiated pipeline from the serialized object.
  56255. */
  56256. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56257. }
  56258. }
  56259. declare module BABYLON {
  56260. /** @hidden */
  56261. export var ssaoPixelShader: {
  56262. name: string;
  56263. shader: string;
  56264. };
  56265. }
  56266. declare module BABYLON {
  56267. /**
  56268. * Render pipeline to produce ssao effect
  56269. */
  56270. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56271. /**
  56272. * @ignore
  56273. * The PassPostProcess id in the pipeline that contains the original scene color
  56274. */
  56275. SSAOOriginalSceneColorEffect: string;
  56276. /**
  56277. * @ignore
  56278. * The SSAO PostProcess id in the pipeline
  56279. */
  56280. SSAORenderEffect: string;
  56281. /**
  56282. * @ignore
  56283. * The horizontal blur PostProcess id in the pipeline
  56284. */
  56285. SSAOBlurHRenderEffect: string;
  56286. /**
  56287. * @ignore
  56288. * The vertical blur PostProcess id in the pipeline
  56289. */
  56290. SSAOBlurVRenderEffect: string;
  56291. /**
  56292. * @ignore
  56293. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56294. */
  56295. SSAOCombineRenderEffect: string;
  56296. /**
  56297. * The output strength of the SSAO post-process. Default value is 1.0.
  56298. */
  56299. totalStrength: number;
  56300. /**
  56301. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56302. */
  56303. radius: number;
  56304. /**
  56305. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56306. * Must not be equal to fallOff and superior to fallOff.
  56307. * Default value is 0.0075
  56308. */
  56309. area: number;
  56310. /**
  56311. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56312. * Must not be equal to area and inferior to area.
  56313. * Default value is 0.000001
  56314. */
  56315. fallOff: number;
  56316. /**
  56317. * The base color of the SSAO post-process
  56318. * The final result is "base + ssao" between [0, 1]
  56319. */
  56320. base: number;
  56321. private _scene;
  56322. private _depthTexture;
  56323. private _randomTexture;
  56324. private _originalColorPostProcess;
  56325. private _ssaoPostProcess;
  56326. private _blurHPostProcess;
  56327. private _blurVPostProcess;
  56328. private _ssaoCombinePostProcess;
  56329. private _firstUpdate;
  56330. /**
  56331. * Gets active scene
  56332. */
  56333. readonly scene: Scene;
  56334. /**
  56335. * @constructor
  56336. * @param name - The rendering pipeline name
  56337. * @param scene - The scene linked to this pipeline
  56338. * @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 }
  56339. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56340. */
  56341. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56342. /**
  56343. * Get the class name
  56344. * @returns "SSAORenderingPipeline"
  56345. */
  56346. getClassName(): string;
  56347. /**
  56348. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56349. */
  56350. dispose(disableDepthRender?: boolean): void;
  56351. private _createBlurPostProcess;
  56352. /** @hidden */
  56353. _rebuild(): void;
  56354. private _createSSAOPostProcess;
  56355. private _createSSAOCombinePostProcess;
  56356. private _createRandomTexture;
  56357. }
  56358. }
  56359. declare module BABYLON {
  56360. /** @hidden */
  56361. export var standardPixelShader: {
  56362. name: string;
  56363. shader: string;
  56364. };
  56365. }
  56366. declare module BABYLON {
  56367. /**
  56368. * Standard rendering pipeline
  56369. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56370. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56371. */
  56372. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56373. /**
  56374. * Public members
  56375. */
  56376. /**
  56377. * Post-process which contains the original scene color before the pipeline applies all the effects
  56378. */
  56379. originalPostProcess: Nullable<PostProcess>;
  56380. /**
  56381. * Post-process used to down scale an image x4
  56382. */
  56383. downSampleX4PostProcess: Nullable<PostProcess>;
  56384. /**
  56385. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56386. */
  56387. brightPassPostProcess: Nullable<PostProcess>;
  56388. /**
  56389. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56390. */
  56391. blurHPostProcesses: PostProcess[];
  56392. /**
  56393. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56394. */
  56395. blurVPostProcesses: PostProcess[];
  56396. /**
  56397. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56398. */
  56399. textureAdderPostProcess: Nullable<PostProcess>;
  56400. /**
  56401. * Post-process used to create volumetric lighting effect
  56402. */
  56403. volumetricLightPostProcess: Nullable<PostProcess>;
  56404. /**
  56405. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56406. */
  56407. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56408. /**
  56409. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56410. */
  56411. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56412. /**
  56413. * Post-process used to merge the volumetric light effect and the real scene color
  56414. */
  56415. volumetricLightMergePostProces: Nullable<PostProcess>;
  56416. /**
  56417. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56418. */
  56419. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56420. /**
  56421. * Base post-process used to calculate the average luminance of the final image for HDR
  56422. */
  56423. luminancePostProcess: Nullable<PostProcess>;
  56424. /**
  56425. * Post-processes used to create down sample post-processes in order to get
  56426. * the average luminance of the final image for HDR
  56427. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56428. */
  56429. luminanceDownSamplePostProcesses: PostProcess[];
  56430. /**
  56431. * Post-process used to create a HDR effect (light adaptation)
  56432. */
  56433. hdrPostProcess: Nullable<PostProcess>;
  56434. /**
  56435. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56436. */
  56437. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56438. /**
  56439. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56440. */
  56441. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56442. /**
  56443. * Post-process used to merge the final HDR post-process and the real scene color
  56444. */
  56445. hdrFinalPostProcess: Nullable<PostProcess>;
  56446. /**
  56447. * Post-process used to create a lens flare effect
  56448. */
  56449. lensFlarePostProcess: Nullable<PostProcess>;
  56450. /**
  56451. * Post-process that merges the result of the lens flare post-process and the real scene color
  56452. */
  56453. lensFlareComposePostProcess: Nullable<PostProcess>;
  56454. /**
  56455. * Post-process used to create a motion blur effect
  56456. */
  56457. motionBlurPostProcess: Nullable<PostProcess>;
  56458. /**
  56459. * Post-process used to create a depth of field effect
  56460. */
  56461. depthOfFieldPostProcess: Nullable<PostProcess>;
  56462. /**
  56463. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56464. */
  56465. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56466. /**
  56467. * Represents the brightness threshold in order to configure the illuminated surfaces
  56468. */
  56469. brightThreshold: number;
  56470. /**
  56471. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56472. */
  56473. blurWidth: number;
  56474. /**
  56475. * Sets if the blur for highlighted surfaces must be only horizontal
  56476. */
  56477. horizontalBlur: boolean;
  56478. /**
  56479. * Gets the overall exposure used by the pipeline
  56480. */
  56481. /**
  56482. * Sets the overall exposure used by the pipeline
  56483. */
  56484. exposure: number;
  56485. /**
  56486. * Texture used typically to simulate "dirty" on camera lens
  56487. */
  56488. lensTexture: Nullable<Texture>;
  56489. /**
  56490. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56491. */
  56492. volumetricLightCoefficient: number;
  56493. /**
  56494. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56495. */
  56496. volumetricLightPower: number;
  56497. /**
  56498. * Used the set the blur intensity to smooth the volumetric lights
  56499. */
  56500. volumetricLightBlurScale: number;
  56501. /**
  56502. * Light (spot or directional) used to generate the volumetric lights rays
  56503. * The source light must have a shadow generate so the pipeline can get its
  56504. * depth map
  56505. */
  56506. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56507. /**
  56508. * For eye adaptation, represents the minimum luminance the eye can see
  56509. */
  56510. hdrMinimumLuminance: number;
  56511. /**
  56512. * For eye adaptation, represents the decrease luminance speed
  56513. */
  56514. hdrDecreaseRate: number;
  56515. /**
  56516. * For eye adaptation, represents the increase luminance speed
  56517. */
  56518. hdrIncreaseRate: number;
  56519. /**
  56520. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56521. */
  56522. /**
  56523. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56524. */
  56525. hdrAutoExposure: boolean;
  56526. /**
  56527. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56528. */
  56529. lensColorTexture: Nullable<Texture>;
  56530. /**
  56531. * The overall strengh for the lens flare effect
  56532. */
  56533. lensFlareStrength: number;
  56534. /**
  56535. * Dispersion coefficient for lens flare ghosts
  56536. */
  56537. lensFlareGhostDispersal: number;
  56538. /**
  56539. * Main lens flare halo width
  56540. */
  56541. lensFlareHaloWidth: number;
  56542. /**
  56543. * Based on the lens distortion effect, defines how much the lens flare result
  56544. * is distorted
  56545. */
  56546. lensFlareDistortionStrength: number;
  56547. /**
  56548. * Lens star texture must be used to simulate rays on the flares and is available
  56549. * in the documentation
  56550. */
  56551. lensStarTexture: Nullable<Texture>;
  56552. /**
  56553. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56554. * flare effect by taking account of the dirt texture
  56555. */
  56556. lensFlareDirtTexture: Nullable<Texture>;
  56557. /**
  56558. * Represents the focal length for the depth of field effect
  56559. */
  56560. depthOfFieldDistance: number;
  56561. /**
  56562. * Represents the blur intensity for the blurred part of the depth of field effect
  56563. */
  56564. depthOfFieldBlurWidth: number;
  56565. /**
  56566. * Gets how much the image is blurred by the movement while using the motion blur post-process
  56567. */
  56568. /**
  56569. * Sets how much the image is blurred by the movement while using the motion blur post-process
  56570. */
  56571. motionStrength: number;
  56572. /**
  56573. * Gets wether or not the motion blur post-process is object based or screen based.
  56574. */
  56575. /**
  56576. * Sets wether or not the motion blur post-process should be object based or screen based
  56577. */
  56578. objectBasedMotionBlur: boolean;
  56579. /**
  56580. * List of animations for the pipeline (IAnimatable implementation)
  56581. */
  56582. animations: Animation[];
  56583. /**
  56584. * Private members
  56585. */
  56586. private _scene;
  56587. private _currentDepthOfFieldSource;
  56588. private _basePostProcess;
  56589. private _fixedExposure;
  56590. private _currentExposure;
  56591. private _hdrAutoExposure;
  56592. private _hdrCurrentLuminance;
  56593. private _motionStrength;
  56594. private _isObjectBasedMotionBlur;
  56595. private _floatTextureType;
  56596. private _ratio;
  56597. private _bloomEnabled;
  56598. private _depthOfFieldEnabled;
  56599. private _vlsEnabled;
  56600. private _lensFlareEnabled;
  56601. private _hdrEnabled;
  56602. private _motionBlurEnabled;
  56603. private _fxaaEnabled;
  56604. private _motionBlurSamples;
  56605. private _volumetricLightStepsCount;
  56606. private _samples;
  56607. /**
  56608. * @ignore
  56609. * Specifies if the bloom pipeline is enabled
  56610. */
  56611. BloomEnabled: boolean;
  56612. /**
  56613. * @ignore
  56614. * Specifies if the depth of field pipeline is enabed
  56615. */
  56616. DepthOfFieldEnabled: boolean;
  56617. /**
  56618. * @ignore
  56619. * Specifies if the lens flare pipeline is enabed
  56620. */
  56621. LensFlareEnabled: boolean;
  56622. /**
  56623. * @ignore
  56624. * Specifies if the HDR pipeline is enabled
  56625. */
  56626. HDREnabled: boolean;
  56627. /**
  56628. * @ignore
  56629. * Specifies if the volumetric lights scattering effect is enabled
  56630. */
  56631. VLSEnabled: boolean;
  56632. /**
  56633. * @ignore
  56634. * Specifies if the motion blur effect is enabled
  56635. */
  56636. MotionBlurEnabled: boolean;
  56637. /**
  56638. * Specifies if anti-aliasing is enabled
  56639. */
  56640. fxaaEnabled: boolean;
  56641. /**
  56642. * Specifies the number of steps used to calculate the volumetric lights
  56643. * Typically in interval [50, 200]
  56644. */
  56645. volumetricLightStepsCount: number;
  56646. /**
  56647. * Specifies the number of samples used for the motion blur effect
  56648. * Typically in interval [16, 64]
  56649. */
  56650. motionBlurSamples: number;
  56651. /**
  56652. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56653. */
  56654. samples: number;
  56655. /**
  56656. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56657. * @constructor
  56658. * @param name The rendering pipeline name
  56659. * @param scene The scene linked to this pipeline
  56660. * @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)
  56661. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56662. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56663. */
  56664. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56665. private _buildPipeline;
  56666. private _createDownSampleX4PostProcess;
  56667. private _createBrightPassPostProcess;
  56668. private _createBlurPostProcesses;
  56669. private _createTextureAdderPostProcess;
  56670. private _createVolumetricLightPostProcess;
  56671. private _createLuminancePostProcesses;
  56672. private _createHdrPostProcess;
  56673. private _createLensFlarePostProcess;
  56674. private _createDepthOfFieldPostProcess;
  56675. private _createMotionBlurPostProcess;
  56676. private _getDepthTexture;
  56677. private _disposePostProcesses;
  56678. /**
  56679. * Dispose of the pipeline and stop all post processes
  56680. */
  56681. dispose(): void;
  56682. /**
  56683. * Serialize the rendering pipeline (Used when exporting)
  56684. * @returns the serialized object
  56685. */
  56686. serialize(): any;
  56687. /**
  56688. * Parse the serialized pipeline
  56689. * @param source Source pipeline.
  56690. * @param scene The scene to load the pipeline to.
  56691. * @param rootUrl The URL of the serialized pipeline.
  56692. * @returns An instantiated pipeline from the serialized object.
  56693. */
  56694. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56695. /**
  56696. * Luminance steps
  56697. */
  56698. static LuminanceSteps: number;
  56699. }
  56700. }
  56701. declare module BABYLON {
  56702. /** @hidden */
  56703. export var tonemapPixelShader: {
  56704. name: string;
  56705. shader: string;
  56706. };
  56707. }
  56708. declare module BABYLON {
  56709. /** Defines operator used for tonemapping */
  56710. export enum TonemappingOperator {
  56711. /** Hable */
  56712. Hable = 0,
  56713. /** Reinhard */
  56714. Reinhard = 1,
  56715. /** HejiDawson */
  56716. HejiDawson = 2,
  56717. /** Photographic */
  56718. Photographic = 3
  56719. }
  56720. /**
  56721. * Defines a post process to apply tone mapping
  56722. */
  56723. export class TonemapPostProcess extends PostProcess {
  56724. private _operator;
  56725. /** Defines the required exposure adjustement */
  56726. exposureAdjustment: number;
  56727. /**
  56728. * Creates a new TonemapPostProcess
  56729. * @param name defines the name of the postprocess
  56730. * @param _operator defines the operator to use
  56731. * @param exposureAdjustment defines the required exposure adjustement
  56732. * @param camera defines the camera to use (can be null)
  56733. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56734. * @param engine defines the hosting engine (can be ignore if camera is set)
  56735. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56736. */
  56737. constructor(name: string, _operator: TonemappingOperator,
  56738. /** Defines the required exposure adjustement */
  56739. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56740. }
  56741. }
  56742. declare module BABYLON {
  56743. /** @hidden */
  56744. export var depthVertexShader: {
  56745. name: string;
  56746. shader: string;
  56747. };
  56748. }
  56749. declare module BABYLON {
  56750. /** @hidden */
  56751. export var volumetricLightScatteringPixelShader: {
  56752. name: string;
  56753. shader: string;
  56754. };
  56755. }
  56756. declare module BABYLON {
  56757. /** @hidden */
  56758. export var volumetricLightScatteringPassPixelShader: {
  56759. name: string;
  56760. shader: string;
  56761. };
  56762. }
  56763. declare module BABYLON {
  56764. /**
  56765. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  56766. */
  56767. export class VolumetricLightScatteringPostProcess extends PostProcess {
  56768. private _volumetricLightScatteringPass;
  56769. private _volumetricLightScatteringRTT;
  56770. private _viewPort;
  56771. private _screenCoordinates;
  56772. private _cachedDefines;
  56773. /**
  56774. * If not undefined, the mesh position is computed from the attached node position
  56775. */
  56776. attachedNode: {
  56777. position: Vector3;
  56778. };
  56779. /**
  56780. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56781. */
  56782. customMeshPosition: Vector3;
  56783. /**
  56784. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56785. */
  56786. useCustomMeshPosition: boolean;
  56787. /**
  56788. * If the post-process should inverse the light scattering direction
  56789. */
  56790. invert: boolean;
  56791. /**
  56792. * The internal mesh used by the post-process
  56793. */
  56794. mesh: Mesh;
  56795. /**
  56796. * @hidden
  56797. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56798. */
  56799. useDiffuseColor: boolean;
  56800. /**
  56801. * Array containing the excluded meshes not rendered in the internal pass
  56802. */
  56803. excludedMeshes: AbstractMesh[];
  56804. /**
  56805. * Controls the overall intensity of the post-process
  56806. */
  56807. exposure: number;
  56808. /**
  56809. * Dissipates each sample's contribution in range [0, 1]
  56810. */
  56811. decay: number;
  56812. /**
  56813. * Controls the overall intensity of each sample
  56814. */
  56815. weight: number;
  56816. /**
  56817. * Controls the density of each sample
  56818. */
  56819. density: number;
  56820. /**
  56821. * @constructor
  56822. * @param name The post-process name
  56823. * @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)
  56824. * @param camera The camera that the post-process will be attached to
  56825. * @param mesh The mesh used to create the light scattering
  56826. * @param samples The post-process quality, default 100
  56827. * @param samplingModeThe post-process filtering mode
  56828. * @param engine The babylon engine
  56829. * @param reusable If the post-process is reusable
  56830. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56831. */
  56832. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56833. /**
  56834. * Returns the string "VolumetricLightScatteringPostProcess"
  56835. * @returns "VolumetricLightScatteringPostProcess"
  56836. */
  56837. getClassName(): string;
  56838. private _isReady;
  56839. /**
  56840. * Sets the new light position for light scattering effect
  56841. * @param position The new custom light position
  56842. */
  56843. setCustomMeshPosition(position: Vector3): void;
  56844. /**
  56845. * Returns the light position for light scattering effect
  56846. * @return Vector3 The custom light position
  56847. */
  56848. getCustomMeshPosition(): Vector3;
  56849. /**
  56850. * Disposes the internal assets and detaches the post-process from the camera
  56851. */
  56852. dispose(camera: Camera): void;
  56853. /**
  56854. * Returns the render target texture used by the post-process
  56855. * @return the render target texture used by the post-process
  56856. */
  56857. getPass(): RenderTargetTexture;
  56858. private _meshExcluded;
  56859. private _createPass;
  56860. private _updateMeshScreenCoordinates;
  56861. /**
  56862. * Creates a default mesh for the Volumeric Light Scattering post-process
  56863. * @param name The mesh name
  56864. * @param scene The scene where to create the mesh
  56865. * @return the default mesh
  56866. */
  56867. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  56868. }
  56869. }
  56870. declare module BABYLON {
  56871. interface Scene {
  56872. /** @hidden (Backing field) */
  56873. _boundingBoxRenderer: BoundingBoxRenderer;
  56874. /** @hidden (Backing field) */
  56875. _forceShowBoundingBoxes: boolean;
  56876. /**
  56877. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56878. */
  56879. forceShowBoundingBoxes: boolean;
  56880. /**
  56881. * Gets the bounding box renderer associated with the scene
  56882. * @returns a BoundingBoxRenderer
  56883. */
  56884. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56885. }
  56886. interface AbstractMesh {
  56887. /** @hidden (Backing field) */
  56888. _showBoundingBox: boolean;
  56889. /**
  56890. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56891. */
  56892. showBoundingBox: boolean;
  56893. }
  56894. /**
  56895. * Component responsible of rendering the bounding box of the meshes in a scene.
  56896. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56897. */
  56898. export class BoundingBoxRenderer implements ISceneComponent {
  56899. /**
  56900. * The component name helpfull to identify the component in the list of scene components.
  56901. */
  56902. readonly name: string;
  56903. /**
  56904. * The scene the component belongs to.
  56905. */
  56906. scene: Scene;
  56907. /**
  56908. * Color of the bounding box lines placed in front of an object
  56909. */
  56910. frontColor: Color3;
  56911. /**
  56912. * Color of the bounding box lines placed behind an object
  56913. */
  56914. backColor: Color3;
  56915. /**
  56916. * Defines if the renderer should show the back lines or not
  56917. */
  56918. showBackLines: boolean;
  56919. /**
  56920. * @hidden
  56921. */
  56922. renderList: SmartArray<BoundingBox>;
  56923. private _colorShader;
  56924. private _vertexBuffers;
  56925. private _indexBuffer;
  56926. private _fillIndexBuffer;
  56927. private _fillIndexData;
  56928. /**
  56929. * Instantiates a new bounding box renderer in a scene.
  56930. * @param scene the scene the renderer renders in
  56931. */
  56932. constructor(scene: Scene);
  56933. /**
  56934. * Registers the component in a given scene
  56935. */
  56936. register(): void;
  56937. private _evaluateSubMesh;
  56938. private _activeMesh;
  56939. private _prepareRessources;
  56940. private _createIndexBuffer;
  56941. /**
  56942. * Rebuilds the elements related to this component in case of
  56943. * context lost for instance.
  56944. */
  56945. rebuild(): void;
  56946. /**
  56947. * @hidden
  56948. */
  56949. reset(): void;
  56950. /**
  56951. * Render the bounding boxes of a specific rendering group
  56952. * @param renderingGroupId defines the rendering group to render
  56953. */
  56954. render(renderingGroupId: number): void;
  56955. /**
  56956. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56957. * @param mesh Define the mesh to render the occlusion bounding box for
  56958. */
  56959. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56960. /**
  56961. * Dispose and release the resources attached to this renderer.
  56962. */
  56963. dispose(): void;
  56964. }
  56965. }
  56966. declare module BABYLON {
  56967. /** @hidden */
  56968. export var depthPixelShader: {
  56969. name: string;
  56970. shader: string;
  56971. };
  56972. }
  56973. declare module BABYLON {
  56974. /**
  56975. * This represents a depth renderer in Babylon.
  56976. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56977. */
  56978. export class DepthRenderer {
  56979. private _scene;
  56980. private _depthMap;
  56981. private _effect;
  56982. private _cachedDefines;
  56983. private _camera;
  56984. /**
  56985. * Specifiess that the depth renderer will only be used within
  56986. * the camera it is created for.
  56987. * This can help forcing its rendering during the camera processing.
  56988. */
  56989. useOnlyInActiveCamera: boolean;
  56990. /** @hidden */
  56991. static _SceneComponentInitialization: (scene: Scene) => void;
  56992. /**
  56993. * Instantiates a depth renderer
  56994. * @param scene The scene the renderer belongs to
  56995. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56996. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56997. */
  56998. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56999. /**
  57000. * Creates the depth rendering effect and checks if the effect is ready.
  57001. * @param subMesh The submesh to be used to render the depth map of
  57002. * @param useInstances If multiple world instances should be used
  57003. * @returns if the depth renderer is ready to render the depth map
  57004. */
  57005. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57006. /**
  57007. * Gets the texture which the depth map will be written to.
  57008. * @returns The depth map texture
  57009. */
  57010. getDepthMap(): RenderTargetTexture;
  57011. /**
  57012. * Disposes of the depth renderer.
  57013. */
  57014. dispose(): void;
  57015. }
  57016. }
  57017. declare module BABYLON {
  57018. interface Scene {
  57019. /** @hidden (Backing field) */
  57020. _depthRenderer: {
  57021. [id: string]: DepthRenderer;
  57022. };
  57023. /**
  57024. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57025. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57026. * @returns the created depth renderer
  57027. */
  57028. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57029. /**
  57030. * Disables a depth renderer for a given camera
  57031. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57032. */
  57033. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57034. }
  57035. /**
  57036. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57037. * in several rendering techniques.
  57038. */
  57039. export class DepthRendererSceneComponent implements ISceneComponent {
  57040. /**
  57041. * The component name helpfull to identify the component in the list of scene components.
  57042. */
  57043. readonly name: string;
  57044. /**
  57045. * The scene the component belongs to.
  57046. */
  57047. scene: Scene;
  57048. /**
  57049. * Creates a new instance of the component for the given scene
  57050. * @param scene Defines the scene to register the component in
  57051. */
  57052. constructor(scene: Scene);
  57053. /**
  57054. * Registers the component in a given scene
  57055. */
  57056. register(): void;
  57057. /**
  57058. * Rebuilds the elements related to this component in case of
  57059. * context lost for instance.
  57060. */
  57061. rebuild(): void;
  57062. /**
  57063. * Disposes the component and the associated ressources
  57064. */
  57065. dispose(): void;
  57066. private _gatherRenderTargets;
  57067. private _gatherActiveCameraRenderTargets;
  57068. }
  57069. }
  57070. declare module BABYLON {
  57071. /** @hidden */
  57072. export var outlinePixelShader: {
  57073. name: string;
  57074. shader: string;
  57075. };
  57076. }
  57077. declare module BABYLON {
  57078. /** @hidden */
  57079. export var outlineVertexShader: {
  57080. name: string;
  57081. shader: string;
  57082. };
  57083. }
  57084. declare module BABYLON {
  57085. interface Scene {
  57086. /** @hidden */
  57087. _outlineRenderer: OutlineRenderer;
  57088. /**
  57089. * Gets the outline renderer associated with the scene
  57090. * @returns a OutlineRenderer
  57091. */
  57092. getOutlineRenderer(): OutlineRenderer;
  57093. }
  57094. interface AbstractMesh {
  57095. /** @hidden (Backing field) */
  57096. _renderOutline: boolean;
  57097. /**
  57098. * Gets or sets a boolean indicating if the outline must be rendered as well
  57099. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57100. */
  57101. renderOutline: boolean;
  57102. /** @hidden (Backing field) */
  57103. _renderOverlay: boolean;
  57104. /**
  57105. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57106. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57107. */
  57108. renderOverlay: boolean;
  57109. }
  57110. /**
  57111. * This class is responsible to draw bothe outline/overlay of meshes.
  57112. * It should not be used directly but through the available method on mesh.
  57113. */
  57114. export class OutlineRenderer implements ISceneComponent {
  57115. /**
  57116. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57117. */
  57118. private static _StencilReference;
  57119. /**
  57120. * The name of the component. Each component must have a unique name.
  57121. */
  57122. name: string;
  57123. /**
  57124. * The scene the component belongs to.
  57125. */
  57126. scene: Scene;
  57127. /**
  57128. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57129. */
  57130. zOffset: number;
  57131. private _engine;
  57132. private _effect;
  57133. private _cachedDefines;
  57134. private _savedDepthWrite;
  57135. /**
  57136. * Instantiates a new outline renderer. (There could be only one per scene).
  57137. * @param scene Defines the scene it belongs to
  57138. */
  57139. constructor(scene: Scene);
  57140. /**
  57141. * Register the component to one instance of a scene.
  57142. */
  57143. register(): void;
  57144. /**
  57145. * Rebuilds the elements related to this component in case of
  57146. * context lost for instance.
  57147. */
  57148. rebuild(): void;
  57149. /**
  57150. * Disposes the component and the associated ressources.
  57151. */
  57152. dispose(): void;
  57153. /**
  57154. * Renders the outline in the canvas.
  57155. * @param subMesh Defines the sumesh to render
  57156. * @param batch Defines the batch of meshes in case of instances
  57157. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57158. */
  57159. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57160. /**
  57161. * Returns whether or not the outline renderer is ready for a given submesh.
  57162. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57163. * @param subMesh Defines the submesh to check readyness for
  57164. * @param useInstances Defines wheter wee are trying to render instances or not
  57165. * @returns true if ready otherwise false
  57166. */
  57167. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57168. private _beforeRenderingMesh;
  57169. private _afterRenderingMesh;
  57170. }
  57171. }
  57172. declare module BABYLON {
  57173. /**
  57174. * Defines the list of states available for a task inside a AssetsManager
  57175. */
  57176. export enum AssetTaskState {
  57177. /**
  57178. * Initialization
  57179. */
  57180. INIT = 0,
  57181. /**
  57182. * Running
  57183. */
  57184. RUNNING = 1,
  57185. /**
  57186. * Done
  57187. */
  57188. DONE = 2,
  57189. /**
  57190. * Error
  57191. */
  57192. ERROR = 3
  57193. }
  57194. /**
  57195. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57196. */
  57197. export abstract class AbstractAssetTask {
  57198. /**
  57199. * Task name
  57200. */ name: string;
  57201. /**
  57202. * Callback called when the task is successful
  57203. */
  57204. onSuccess: (task: any) => void;
  57205. /**
  57206. * Callback called when the task is not successful
  57207. */
  57208. onError: (task: any, message?: string, exception?: any) => void;
  57209. /**
  57210. * Creates a new AssetsManager
  57211. * @param name defines the name of the task
  57212. */
  57213. constructor(
  57214. /**
  57215. * Task name
  57216. */ name: string);
  57217. private _isCompleted;
  57218. private _taskState;
  57219. private _errorObject;
  57220. /**
  57221. * Get if the task is completed
  57222. */
  57223. readonly isCompleted: boolean;
  57224. /**
  57225. * Gets the current state of the task
  57226. */
  57227. readonly taskState: AssetTaskState;
  57228. /**
  57229. * Gets the current error object (if task is in error)
  57230. */
  57231. readonly errorObject: {
  57232. message?: string;
  57233. exception?: any;
  57234. };
  57235. /**
  57236. * Internal only
  57237. * @hidden
  57238. */
  57239. _setErrorObject(message?: string, exception?: any): void;
  57240. /**
  57241. * Execute the current task
  57242. * @param scene defines the scene where you want your assets to be loaded
  57243. * @param onSuccess is a callback called when the task is successfully executed
  57244. * @param onError is a callback called if an error occurs
  57245. */
  57246. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57247. /**
  57248. * Execute the current task
  57249. * @param scene defines the scene where you want your assets to be loaded
  57250. * @param onSuccess is a callback called when the task is successfully executed
  57251. * @param onError is a callback called if an error occurs
  57252. */
  57253. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57254. /**
  57255. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57256. * This can be used with failed tasks that have the reason for failure fixed.
  57257. */
  57258. reset(): void;
  57259. private onErrorCallback;
  57260. private onDoneCallback;
  57261. }
  57262. /**
  57263. * Define the interface used by progress events raised during assets loading
  57264. */
  57265. export interface IAssetsProgressEvent {
  57266. /**
  57267. * Defines the number of remaining tasks to process
  57268. */
  57269. remainingCount: number;
  57270. /**
  57271. * Defines the total number of tasks
  57272. */
  57273. totalCount: number;
  57274. /**
  57275. * Defines the task that was just processed
  57276. */
  57277. task: AbstractAssetTask;
  57278. }
  57279. /**
  57280. * Class used to share progress information about assets loading
  57281. */
  57282. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57283. /**
  57284. * Defines the number of remaining tasks to process
  57285. */
  57286. remainingCount: number;
  57287. /**
  57288. * Defines the total number of tasks
  57289. */
  57290. totalCount: number;
  57291. /**
  57292. * Defines the task that was just processed
  57293. */
  57294. task: AbstractAssetTask;
  57295. /**
  57296. * Creates a AssetsProgressEvent
  57297. * @param remainingCount defines the number of remaining tasks to process
  57298. * @param totalCount defines the total number of tasks
  57299. * @param task defines the task that was just processed
  57300. */
  57301. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57302. }
  57303. /**
  57304. * Define a task used by AssetsManager to load meshes
  57305. */
  57306. export class MeshAssetTask extends AbstractAssetTask {
  57307. /**
  57308. * Defines the name of the task
  57309. */
  57310. name: string;
  57311. /**
  57312. * Defines the list of mesh's names you want to load
  57313. */
  57314. meshesNames: any;
  57315. /**
  57316. * Defines the root url to use as a base to load your meshes and associated resources
  57317. */
  57318. rootUrl: string;
  57319. /**
  57320. * Defines the filename of the scene to load from
  57321. */
  57322. sceneFilename: string;
  57323. /**
  57324. * Gets the list of loaded meshes
  57325. */
  57326. loadedMeshes: Array<AbstractMesh>;
  57327. /**
  57328. * Gets the list of loaded particle systems
  57329. */
  57330. loadedParticleSystems: Array<IParticleSystem>;
  57331. /**
  57332. * Gets the list of loaded skeletons
  57333. */
  57334. loadedSkeletons: Array<Skeleton>;
  57335. /**
  57336. * Gets the list of loaded animation groups
  57337. */
  57338. loadedAnimationGroups: Array<AnimationGroup>;
  57339. /**
  57340. * Callback called when the task is successful
  57341. */
  57342. onSuccess: (task: MeshAssetTask) => void;
  57343. /**
  57344. * Callback called when the task is successful
  57345. */
  57346. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57347. /**
  57348. * Creates a new MeshAssetTask
  57349. * @param name defines the name of the task
  57350. * @param meshesNames defines the list of mesh's names you want to load
  57351. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57352. * @param sceneFilename defines the filename of the scene to load from
  57353. */
  57354. constructor(
  57355. /**
  57356. * Defines the name of the task
  57357. */
  57358. name: string,
  57359. /**
  57360. * Defines the list of mesh's names you want to load
  57361. */
  57362. meshesNames: any,
  57363. /**
  57364. * Defines the root url to use as a base to load your meshes and associated resources
  57365. */
  57366. rootUrl: string,
  57367. /**
  57368. * Defines the filename of the scene to load from
  57369. */
  57370. sceneFilename: string);
  57371. /**
  57372. * Execute the current task
  57373. * @param scene defines the scene where you want your assets to be loaded
  57374. * @param onSuccess is a callback called when the task is successfully executed
  57375. * @param onError is a callback called if an error occurs
  57376. */
  57377. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57378. }
  57379. /**
  57380. * Define a task used by AssetsManager to load text content
  57381. */
  57382. export class TextFileAssetTask extends AbstractAssetTask {
  57383. /**
  57384. * Defines the name of the task
  57385. */
  57386. name: string;
  57387. /**
  57388. * Defines the location of the file to load
  57389. */
  57390. url: string;
  57391. /**
  57392. * Gets the loaded text string
  57393. */
  57394. text: string;
  57395. /**
  57396. * Callback called when the task is successful
  57397. */
  57398. onSuccess: (task: TextFileAssetTask) => void;
  57399. /**
  57400. * Callback called when the task is successful
  57401. */
  57402. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57403. /**
  57404. * Creates a new TextFileAssetTask object
  57405. * @param name defines the name of the task
  57406. * @param url defines the location of the file to load
  57407. */
  57408. constructor(
  57409. /**
  57410. * Defines the name of the task
  57411. */
  57412. name: string,
  57413. /**
  57414. * Defines the location of the file to load
  57415. */
  57416. url: string);
  57417. /**
  57418. * Execute the current task
  57419. * @param scene defines the scene where you want your assets to be loaded
  57420. * @param onSuccess is a callback called when the task is successfully executed
  57421. * @param onError is a callback called if an error occurs
  57422. */
  57423. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57424. }
  57425. /**
  57426. * Define a task used by AssetsManager to load binary data
  57427. */
  57428. export class BinaryFileAssetTask extends AbstractAssetTask {
  57429. /**
  57430. * Defines the name of the task
  57431. */
  57432. name: string;
  57433. /**
  57434. * Defines the location of the file to load
  57435. */
  57436. url: string;
  57437. /**
  57438. * Gets the lodaded data (as an array buffer)
  57439. */
  57440. data: ArrayBuffer;
  57441. /**
  57442. * Callback called when the task is successful
  57443. */
  57444. onSuccess: (task: BinaryFileAssetTask) => void;
  57445. /**
  57446. * Callback called when the task is successful
  57447. */
  57448. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57449. /**
  57450. * Creates a new BinaryFileAssetTask object
  57451. * @param name defines the name of the new task
  57452. * @param url defines the location of the file to load
  57453. */
  57454. constructor(
  57455. /**
  57456. * Defines the name of the task
  57457. */
  57458. name: string,
  57459. /**
  57460. * Defines the location of the file to load
  57461. */
  57462. url: string);
  57463. /**
  57464. * Execute the current task
  57465. * @param scene defines the scene where you want your assets to be loaded
  57466. * @param onSuccess is a callback called when the task is successfully executed
  57467. * @param onError is a callback called if an error occurs
  57468. */
  57469. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57470. }
  57471. /**
  57472. * Define a task used by AssetsManager to load images
  57473. */
  57474. export class ImageAssetTask extends AbstractAssetTask {
  57475. /**
  57476. * Defines the name of the task
  57477. */
  57478. name: string;
  57479. /**
  57480. * Defines the location of the image to load
  57481. */
  57482. url: string;
  57483. /**
  57484. * Gets the loaded images
  57485. */
  57486. image: HTMLImageElement;
  57487. /**
  57488. * Callback called when the task is successful
  57489. */
  57490. onSuccess: (task: ImageAssetTask) => void;
  57491. /**
  57492. * Callback called when the task is successful
  57493. */
  57494. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57495. /**
  57496. * Creates a new ImageAssetTask
  57497. * @param name defines the name of the task
  57498. * @param url defines the location of the image to load
  57499. */
  57500. constructor(
  57501. /**
  57502. * Defines the name of the task
  57503. */
  57504. name: string,
  57505. /**
  57506. * Defines the location of the image to load
  57507. */
  57508. url: string);
  57509. /**
  57510. * Execute the current task
  57511. * @param scene defines the scene where you want your assets to be loaded
  57512. * @param onSuccess is a callback called when the task is successfully executed
  57513. * @param onError is a callback called if an error occurs
  57514. */
  57515. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57516. }
  57517. /**
  57518. * Defines the interface used by texture loading tasks
  57519. */
  57520. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57521. /**
  57522. * Gets the loaded texture
  57523. */
  57524. texture: TEX;
  57525. }
  57526. /**
  57527. * Define a task used by AssetsManager to load 2D textures
  57528. */
  57529. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57530. /**
  57531. * Defines the name of the task
  57532. */
  57533. name: string;
  57534. /**
  57535. * Defines the location of the file to load
  57536. */
  57537. url: string;
  57538. /**
  57539. * Defines if mipmap should not be generated (default is false)
  57540. */
  57541. noMipmap?: boolean | undefined;
  57542. /**
  57543. * Defines if texture must be inverted on Y axis (default is false)
  57544. */
  57545. invertY?: boolean | undefined;
  57546. /**
  57547. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57548. */
  57549. samplingMode: number;
  57550. /**
  57551. * Gets the loaded texture
  57552. */
  57553. texture: Texture;
  57554. /**
  57555. * Callback called when the task is successful
  57556. */
  57557. onSuccess: (task: TextureAssetTask) => void;
  57558. /**
  57559. * Callback called when the task is successful
  57560. */
  57561. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57562. /**
  57563. * Creates a new TextureAssetTask object
  57564. * @param name defines the name of the task
  57565. * @param url defines the location of the file to load
  57566. * @param noMipmap defines if mipmap should not be generated (default is false)
  57567. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57568. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57569. */
  57570. constructor(
  57571. /**
  57572. * Defines the name of the task
  57573. */
  57574. name: string,
  57575. /**
  57576. * Defines the location of the file to load
  57577. */
  57578. url: string,
  57579. /**
  57580. * Defines if mipmap should not be generated (default is false)
  57581. */
  57582. noMipmap?: boolean | undefined,
  57583. /**
  57584. * Defines if texture must be inverted on Y axis (default is false)
  57585. */
  57586. invertY?: boolean | undefined,
  57587. /**
  57588. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57589. */
  57590. samplingMode?: number);
  57591. /**
  57592. * Execute the current task
  57593. * @param scene defines the scene where you want your assets to be loaded
  57594. * @param onSuccess is a callback called when the task is successfully executed
  57595. * @param onError is a callback called if an error occurs
  57596. */
  57597. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57598. }
  57599. /**
  57600. * Define a task used by AssetsManager to load cube textures
  57601. */
  57602. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57603. /**
  57604. * Defines the name of the task
  57605. */
  57606. name: string;
  57607. /**
  57608. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57609. */
  57610. url: string;
  57611. /**
  57612. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57613. */
  57614. extensions?: string[] | undefined;
  57615. /**
  57616. * Defines if mipmaps should not be generated (default is false)
  57617. */
  57618. noMipmap?: boolean | undefined;
  57619. /**
  57620. * Defines the explicit list of files (undefined by default)
  57621. */
  57622. files?: string[] | undefined;
  57623. /**
  57624. * Gets the loaded texture
  57625. */
  57626. texture: CubeTexture;
  57627. /**
  57628. * Callback called when the task is successful
  57629. */
  57630. onSuccess: (task: CubeTextureAssetTask) => void;
  57631. /**
  57632. * Callback called when the task is successful
  57633. */
  57634. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57635. /**
  57636. * Creates a new CubeTextureAssetTask
  57637. * @param name defines the name of the task
  57638. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57639. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57640. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57641. * @param files defines the explicit list of files (undefined by default)
  57642. */
  57643. constructor(
  57644. /**
  57645. * Defines the name of the task
  57646. */
  57647. name: string,
  57648. /**
  57649. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57650. */
  57651. url: string,
  57652. /**
  57653. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57654. */
  57655. extensions?: string[] | undefined,
  57656. /**
  57657. * Defines if mipmaps should not be generated (default is false)
  57658. */
  57659. noMipmap?: boolean | undefined,
  57660. /**
  57661. * Defines the explicit list of files (undefined by default)
  57662. */
  57663. files?: string[] | undefined);
  57664. /**
  57665. * Execute the current task
  57666. * @param scene defines the scene where you want your assets to be loaded
  57667. * @param onSuccess is a callback called when the task is successfully executed
  57668. * @param onError is a callback called if an error occurs
  57669. */
  57670. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57671. }
  57672. /**
  57673. * Define a task used by AssetsManager to load HDR cube textures
  57674. */
  57675. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57676. /**
  57677. * Defines the name of the task
  57678. */
  57679. name: string;
  57680. /**
  57681. * Defines the location of the file to load
  57682. */
  57683. url: string;
  57684. /**
  57685. * Defines the desired size (the more it increases the longer the generation will be)
  57686. */
  57687. size: number;
  57688. /**
  57689. * Defines if mipmaps should not be generated (default is false)
  57690. */
  57691. noMipmap: boolean;
  57692. /**
  57693. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57694. */
  57695. generateHarmonics: boolean;
  57696. /**
  57697. * 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)
  57698. */
  57699. gammaSpace: boolean;
  57700. /**
  57701. * Internal Use Only
  57702. */
  57703. reserved: boolean;
  57704. /**
  57705. * Gets the loaded texture
  57706. */
  57707. texture: HDRCubeTexture;
  57708. /**
  57709. * Callback called when the task is successful
  57710. */
  57711. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57712. /**
  57713. * Callback called when the task is successful
  57714. */
  57715. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57716. /**
  57717. * Creates a new HDRCubeTextureAssetTask object
  57718. * @param name defines the name of the task
  57719. * @param url defines the location of the file to load
  57720. * @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.
  57721. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57722. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57723. * @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)
  57724. * @param reserved Internal use only
  57725. */
  57726. constructor(
  57727. /**
  57728. * Defines the name of the task
  57729. */
  57730. name: string,
  57731. /**
  57732. * Defines the location of the file to load
  57733. */
  57734. url: string,
  57735. /**
  57736. * Defines the desired size (the more it increases the longer the generation will be)
  57737. */
  57738. size: number,
  57739. /**
  57740. * Defines if mipmaps should not be generated (default is false)
  57741. */
  57742. noMipmap?: boolean,
  57743. /**
  57744. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57745. */
  57746. generateHarmonics?: boolean,
  57747. /**
  57748. * 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)
  57749. */
  57750. gammaSpace?: boolean,
  57751. /**
  57752. * Internal Use Only
  57753. */
  57754. reserved?: boolean);
  57755. /**
  57756. * Execute the current task
  57757. * @param scene defines the scene where you want your assets to be loaded
  57758. * @param onSuccess is a callback called when the task is successfully executed
  57759. * @param onError is a callback called if an error occurs
  57760. */
  57761. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57762. }
  57763. /**
  57764. * Define a task used by AssetsManager to load Equirectangular cube textures
  57765. */
  57766. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  57767. /**
  57768. * Defines the name of the task
  57769. */
  57770. name: string;
  57771. /**
  57772. * Defines the location of the file to load
  57773. */
  57774. url: string;
  57775. /**
  57776. * Defines the desired size (the more it increases the longer the generation will be)
  57777. */
  57778. size: number;
  57779. /**
  57780. * Defines if mipmaps should not be generated (default is false)
  57781. */
  57782. noMipmap: boolean;
  57783. /**
  57784. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57785. * but the standard material would require them in Gamma space) (default is true)
  57786. */
  57787. gammaSpace: boolean;
  57788. /**
  57789. * Gets the loaded texture
  57790. */
  57791. texture: EquiRectangularCubeTexture;
  57792. /**
  57793. * Callback called when the task is successful
  57794. */
  57795. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  57796. /**
  57797. * Callback called when the task is successful
  57798. */
  57799. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  57800. /**
  57801. * Creates a new EquiRectangularCubeTextureAssetTask object
  57802. * @param name defines the name of the task
  57803. * @param url defines the location of the file to load
  57804. * @param size defines the desired size (the more it increases the longer the generation will be)
  57805. * If the size is omitted this implies you are using a preprocessed cubemap.
  57806. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57807. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  57808. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  57809. * (default is true)
  57810. */
  57811. constructor(
  57812. /**
  57813. * Defines the name of the task
  57814. */
  57815. name: string,
  57816. /**
  57817. * Defines the location of the file to load
  57818. */
  57819. url: string,
  57820. /**
  57821. * Defines the desired size (the more it increases the longer the generation will be)
  57822. */
  57823. size: number,
  57824. /**
  57825. * Defines if mipmaps should not be generated (default is false)
  57826. */
  57827. noMipmap?: boolean,
  57828. /**
  57829. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57830. * but the standard material would require them in Gamma space) (default is true)
  57831. */
  57832. gammaSpace?: boolean);
  57833. /**
  57834. * Execute the current task
  57835. * @param scene defines the scene where you want your assets to be loaded
  57836. * @param onSuccess is a callback called when the task is successfully executed
  57837. * @param onError is a callback called if an error occurs
  57838. */
  57839. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57840. }
  57841. /**
  57842. * This class can be used to easily import assets into a scene
  57843. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  57844. */
  57845. export class AssetsManager {
  57846. private _scene;
  57847. private _isLoading;
  57848. protected _tasks: AbstractAssetTask[];
  57849. protected _waitingTasksCount: number;
  57850. protected _totalTasksCount: number;
  57851. /**
  57852. * Callback called when all tasks are processed
  57853. */
  57854. onFinish: (tasks: AbstractAssetTask[]) => void;
  57855. /**
  57856. * Callback called when a task is successful
  57857. */
  57858. onTaskSuccess: (task: AbstractAssetTask) => void;
  57859. /**
  57860. * Callback called when a task had an error
  57861. */
  57862. onTaskError: (task: AbstractAssetTask) => void;
  57863. /**
  57864. * Callback called when a task is done (whatever the result is)
  57865. */
  57866. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  57867. /**
  57868. * Observable called when all tasks are processed
  57869. */
  57870. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  57871. /**
  57872. * Observable called when a task had an error
  57873. */
  57874. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57875. /**
  57876. * Observable called when all tasks were executed
  57877. */
  57878. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57879. /**
  57880. * Observable called when a task is done (whatever the result is)
  57881. */
  57882. onProgressObservable: Observable<IAssetsProgressEvent>;
  57883. /**
  57884. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57885. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57886. */
  57887. useDefaultLoadingScreen: boolean;
  57888. /**
  57889. * Creates a new AssetsManager
  57890. * @param scene defines the scene to work on
  57891. */
  57892. constructor(scene: Scene);
  57893. /**
  57894. * Add a MeshAssetTask to the list of active tasks
  57895. * @param taskName defines the name of the new task
  57896. * @param meshesNames defines the name of meshes to load
  57897. * @param rootUrl defines the root url to use to locate files
  57898. * @param sceneFilename defines the filename of the scene file
  57899. * @returns a new MeshAssetTask object
  57900. */
  57901. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57902. /**
  57903. * Add a TextFileAssetTask to the list of active tasks
  57904. * @param taskName defines the name of the new task
  57905. * @param url defines the url of the file to load
  57906. * @returns a new TextFileAssetTask object
  57907. */
  57908. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57909. /**
  57910. * Add a BinaryFileAssetTask to the list of active tasks
  57911. * @param taskName defines the name of the new task
  57912. * @param url defines the url of the file to load
  57913. * @returns a new BinaryFileAssetTask object
  57914. */
  57915. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57916. /**
  57917. * Add a ImageAssetTask to the list of active tasks
  57918. * @param taskName defines the name of the new task
  57919. * @param url defines the url of the file to load
  57920. * @returns a new ImageAssetTask object
  57921. */
  57922. addImageTask(taskName: string, url: string): ImageAssetTask;
  57923. /**
  57924. * Add a TextureAssetTask to the list of active tasks
  57925. * @param taskName defines the name of the new task
  57926. * @param url defines the url of the file to load
  57927. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57928. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57929. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57930. * @returns a new TextureAssetTask object
  57931. */
  57932. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57933. /**
  57934. * Add a CubeTextureAssetTask to the list of active tasks
  57935. * @param taskName defines the name of the new task
  57936. * @param url defines the url of the file to load
  57937. * @param extensions defines the extension to use to load the cube map (can be null)
  57938. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57939. * @param files defines the list of files to load (can be null)
  57940. * @returns a new CubeTextureAssetTask object
  57941. */
  57942. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57943. /**
  57944. *
  57945. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57946. * @param taskName defines the name of the new task
  57947. * @param url defines the url of the file to load
  57948. * @param size defines the size you want for the cubemap (can be null)
  57949. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57950. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57951. * @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)
  57952. * @param reserved Internal use only
  57953. * @returns a new HDRCubeTextureAssetTask object
  57954. */
  57955. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57956. /**
  57957. *
  57958. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  57959. * @param taskName defines the name of the new task
  57960. * @param url defines the url of the file to load
  57961. * @param size defines the size you want for the cubemap (can be null)
  57962. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57963. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  57964. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  57965. * @returns a new EquiRectangularCubeTextureAssetTask object
  57966. */
  57967. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  57968. /**
  57969. * Remove a task from the assets manager.
  57970. * @param task the task to remove
  57971. */
  57972. removeTask(task: AbstractAssetTask): void;
  57973. private _decreaseWaitingTasksCount;
  57974. private _runTask;
  57975. /**
  57976. * Reset the AssetsManager and remove all tasks
  57977. * @return the current instance of the AssetsManager
  57978. */
  57979. reset(): AssetsManager;
  57980. /**
  57981. * Start the loading process
  57982. * @return the current instance of the AssetsManager
  57983. */
  57984. load(): AssetsManager;
  57985. /**
  57986. * Start the loading process as an async operation
  57987. * @return a promise returning the list of failed tasks
  57988. */
  57989. loadAsync(): Promise<void>;
  57990. }
  57991. }
  57992. declare module BABYLON {
  57993. /**
  57994. * Wrapper class for promise with external resolve and reject.
  57995. */
  57996. export class Deferred<T> {
  57997. /**
  57998. * The promise associated with this deferred object.
  57999. */
  58000. readonly promise: Promise<T>;
  58001. private _resolve;
  58002. private _reject;
  58003. /**
  58004. * The resolve method of the promise associated with this deferred object.
  58005. */
  58006. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58007. /**
  58008. * The reject method of the promise associated with this deferred object.
  58009. */
  58010. readonly reject: (reason?: any) => void;
  58011. /**
  58012. * Constructor for this deferred object.
  58013. */
  58014. constructor();
  58015. }
  58016. }
  58017. declare module BABYLON {
  58018. /**
  58019. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58020. */
  58021. export class MeshExploder {
  58022. private _centerMesh;
  58023. private _meshes;
  58024. private _meshesOrigins;
  58025. private _toCenterVectors;
  58026. private _scaledDirection;
  58027. private _newPosition;
  58028. private _centerPosition;
  58029. /**
  58030. * Explodes meshes from a center mesh.
  58031. * @param meshes The meshes to explode.
  58032. * @param centerMesh The mesh to be center of explosion.
  58033. */
  58034. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58035. private _setCenterMesh;
  58036. /**
  58037. * Get class name
  58038. * @returns "MeshExploder"
  58039. */
  58040. getClassName(): string;
  58041. /**
  58042. * "Exploded meshes"
  58043. * @returns Array of meshes with the centerMesh at index 0.
  58044. */
  58045. getMeshes(): Array<Mesh>;
  58046. /**
  58047. * Explodes meshes giving a specific direction
  58048. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58049. */
  58050. explode(direction?: number): void;
  58051. }
  58052. }
  58053. declare module BABYLON {
  58054. /**
  58055. * Class used to help managing file picking and drag'n'drop
  58056. */
  58057. export class FilesInput {
  58058. /**
  58059. * List of files ready to be loaded
  58060. */
  58061. static readonly FilesToLoad: {
  58062. [key: string]: File;
  58063. };
  58064. /**
  58065. * Callback called when a file is processed
  58066. */
  58067. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58068. private _engine;
  58069. private _currentScene;
  58070. private _sceneLoadedCallback;
  58071. private _progressCallback;
  58072. private _additionalRenderLoopLogicCallback;
  58073. private _textureLoadingCallback;
  58074. private _startingProcessingFilesCallback;
  58075. private _onReloadCallback;
  58076. private _errorCallback;
  58077. private _elementToMonitor;
  58078. private _sceneFileToLoad;
  58079. private _filesToLoad;
  58080. /**
  58081. * Creates a new FilesInput
  58082. * @param engine defines the rendering engine
  58083. * @param scene defines the hosting scene
  58084. * @param sceneLoadedCallback callback called when scene is loaded
  58085. * @param progressCallback callback called to track progress
  58086. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58087. * @param textureLoadingCallback callback called when a texture is loading
  58088. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58089. * @param onReloadCallback callback called when a reload is requested
  58090. * @param errorCallback callback call if an error occurs
  58091. */
  58092. 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);
  58093. private _dragEnterHandler;
  58094. private _dragOverHandler;
  58095. private _dropHandler;
  58096. /**
  58097. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58098. * @param elementToMonitor defines the DOM element to track
  58099. */
  58100. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58101. /**
  58102. * Release all associated resources
  58103. */
  58104. dispose(): void;
  58105. private renderFunction;
  58106. private drag;
  58107. private drop;
  58108. private _traverseFolder;
  58109. private _processFiles;
  58110. /**
  58111. * Load files from a drop event
  58112. * @param event defines the drop event to use as source
  58113. */
  58114. loadFiles(event: any): void;
  58115. private _processReload;
  58116. /**
  58117. * Reload the current scene from the loaded files
  58118. */
  58119. reload(): void;
  58120. }
  58121. }
  58122. declare module BABYLON {
  58123. /**
  58124. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58125. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58126. */
  58127. export class SceneOptimization {
  58128. /**
  58129. * Defines the priority of this optimization (0 by default which means first in the list)
  58130. */
  58131. priority: number;
  58132. /**
  58133. * Gets a string describing the action executed by the current optimization
  58134. * @returns description string
  58135. */
  58136. getDescription(): string;
  58137. /**
  58138. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58139. * @param scene defines the current scene where to apply this optimization
  58140. * @param optimizer defines the current optimizer
  58141. * @returns true if everything that can be done was applied
  58142. */
  58143. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58144. /**
  58145. * Creates the SceneOptimization object
  58146. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58147. * @param desc defines the description associated with the optimization
  58148. */
  58149. constructor(
  58150. /**
  58151. * Defines the priority of this optimization (0 by default which means first in the list)
  58152. */
  58153. priority?: number);
  58154. }
  58155. /**
  58156. * Defines an optimization used to reduce the size of render target textures
  58157. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58158. */
  58159. export class TextureOptimization extends SceneOptimization {
  58160. /**
  58161. * Defines the priority of this optimization (0 by default which means first in the list)
  58162. */
  58163. priority: number;
  58164. /**
  58165. * 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
  58166. */
  58167. maximumSize: number;
  58168. /**
  58169. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58170. */
  58171. step: number;
  58172. /**
  58173. * Gets a string describing the action executed by the current optimization
  58174. * @returns description string
  58175. */
  58176. getDescription(): string;
  58177. /**
  58178. * Creates the TextureOptimization object
  58179. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58180. * @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
  58181. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58182. */
  58183. constructor(
  58184. /**
  58185. * Defines the priority of this optimization (0 by default which means first in the list)
  58186. */
  58187. priority?: number,
  58188. /**
  58189. * 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
  58190. */
  58191. maximumSize?: number,
  58192. /**
  58193. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58194. */
  58195. step?: number);
  58196. /**
  58197. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58198. * @param scene defines the current scene where to apply this optimization
  58199. * @param optimizer defines the current optimizer
  58200. * @returns true if everything that can be done was applied
  58201. */
  58202. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58203. }
  58204. /**
  58205. * Defines an optimization used to increase or decrease the rendering resolution
  58206. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58207. */
  58208. export class HardwareScalingOptimization extends SceneOptimization {
  58209. /**
  58210. * Defines the priority of this optimization (0 by default which means first in the list)
  58211. */
  58212. priority: number;
  58213. /**
  58214. * Defines the maximum scale to use (2 by default)
  58215. */
  58216. maximumScale: number;
  58217. /**
  58218. * Defines the step to use between two passes (0.5 by default)
  58219. */
  58220. step: number;
  58221. private _currentScale;
  58222. private _directionOffset;
  58223. /**
  58224. * Gets a string describing the action executed by the current optimization
  58225. * @return description string
  58226. */
  58227. getDescription(): string;
  58228. /**
  58229. * Creates the HardwareScalingOptimization object
  58230. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58231. * @param maximumScale defines the maximum scale to use (2 by default)
  58232. * @param step defines the step to use between two passes (0.5 by default)
  58233. */
  58234. constructor(
  58235. /**
  58236. * Defines the priority of this optimization (0 by default which means first in the list)
  58237. */
  58238. priority?: number,
  58239. /**
  58240. * Defines the maximum scale to use (2 by default)
  58241. */
  58242. maximumScale?: number,
  58243. /**
  58244. * Defines the step to use between two passes (0.5 by default)
  58245. */
  58246. step?: number);
  58247. /**
  58248. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58249. * @param scene defines the current scene where to apply this optimization
  58250. * @param optimizer defines the current optimizer
  58251. * @returns true if everything that can be done was applied
  58252. */
  58253. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58254. }
  58255. /**
  58256. * Defines an optimization used to remove shadows
  58257. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58258. */
  58259. export class ShadowsOptimization extends SceneOptimization {
  58260. /**
  58261. * Gets a string describing the action executed by the current optimization
  58262. * @return description string
  58263. */
  58264. getDescription(): string;
  58265. /**
  58266. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58267. * @param scene defines the current scene where to apply this optimization
  58268. * @param optimizer defines the current optimizer
  58269. * @returns true if everything that can be done was applied
  58270. */
  58271. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58272. }
  58273. /**
  58274. * Defines an optimization used to turn post-processes off
  58275. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58276. */
  58277. export class PostProcessesOptimization extends SceneOptimization {
  58278. /**
  58279. * Gets a string describing the action executed by the current optimization
  58280. * @return description string
  58281. */
  58282. getDescription(): string;
  58283. /**
  58284. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58285. * @param scene defines the current scene where to apply this optimization
  58286. * @param optimizer defines the current optimizer
  58287. * @returns true if everything that can be done was applied
  58288. */
  58289. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58290. }
  58291. /**
  58292. * Defines an optimization used to turn lens flares off
  58293. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58294. */
  58295. export class LensFlaresOptimization extends SceneOptimization {
  58296. /**
  58297. * Gets a string describing the action executed by the current optimization
  58298. * @return description string
  58299. */
  58300. getDescription(): string;
  58301. /**
  58302. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58303. * @param scene defines the current scene where to apply this optimization
  58304. * @param optimizer defines the current optimizer
  58305. * @returns true if everything that can be done was applied
  58306. */
  58307. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58308. }
  58309. /**
  58310. * Defines an optimization based on user defined callback.
  58311. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58312. */
  58313. export class CustomOptimization extends SceneOptimization {
  58314. /**
  58315. * Callback called to apply the custom optimization.
  58316. */
  58317. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58318. /**
  58319. * Callback called to get custom description
  58320. */
  58321. onGetDescription: () => string;
  58322. /**
  58323. * Gets a string describing the action executed by the current optimization
  58324. * @returns description string
  58325. */
  58326. getDescription(): string;
  58327. /**
  58328. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58329. * @param scene defines the current scene where to apply this optimization
  58330. * @param optimizer defines the current optimizer
  58331. * @returns true if everything that can be done was applied
  58332. */
  58333. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58334. }
  58335. /**
  58336. * Defines an optimization used to turn particles off
  58337. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58338. */
  58339. export class ParticlesOptimization extends SceneOptimization {
  58340. /**
  58341. * Gets a string describing the action executed by the current optimization
  58342. * @return description string
  58343. */
  58344. getDescription(): string;
  58345. /**
  58346. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58347. * @param scene defines the current scene where to apply this optimization
  58348. * @param optimizer defines the current optimizer
  58349. * @returns true if everything that can be done was applied
  58350. */
  58351. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58352. }
  58353. /**
  58354. * Defines an optimization used to turn render targets off
  58355. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58356. */
  58357. export class RenderTargetsOptimization extends SceneOptimization {
  58358. /**
  58359. * Gets a string describing the action executed by the current optimization
  58360. * @return description string
  58361. */
  58362. getDescription(): string;
  58363. /**
  58364. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58365. * @param scene defines the current scene where to apply this optimization
  58366. * @param optimizer defines the current optimizer
  58367. * @returns true if everything that can be done was applied
  58368. */
  58369. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58370. }
  58371. /**
  58372. * Defines an optimization used to merge meshes with compatible materials
  58373. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58374. */
  58375. export class MergeMeshesOptimization extends SceneOptimization {
  58376. private static _UpdateSelectionTree;
  58377. /**
  58378. * Gets or sets a boolean which defines if optimization octree has to be updated
  58379. */
  58380. /**
  58381. * Gets or sets a boolean which defines if optimization octree has to be updated
  58382. */
  58383. static UpdateSelectionTree: boolean;
  58384. /**
  58385. * Gets a string describing the action executed by the current optimization
  58386. * @return description string
  58387. */
  58388. getDescription(): string;
  58389. private _canBeMerged;
  58390. /**
  58391. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58392. * @param scene defines the current scene where to apply this optimization
  58393. * @param optimizer defines the current optimizer
  58394. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58395. * @returns true if everything that can be done was applied
  58396. */
  58397. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58398. }
  58399. /**
  58400. * Defines a list of options used by SceneOptimizer
  58401. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58402. */
  58403. export class SceneOptimizerOptions {
  58404. /**
  58405. * Defines the target frame rate to reach (60 by default)
  58406. */
  58407. targetFrameRate: number;
  58408. /**
  58409. * Defines the interval between two checkes (2000ms by default)
  58410. */
  58411. trackerDuration: number;
  58412. /**
  58413. * Gets the list of optimizations to apply
  58414. */
  58415. optimizations: SceneOptimization[];
  58416. /**
  58417. * Creates a new list of options used by SceneOptimizer
  58418. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58419. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58420. */
  58421. constructor(
  58422. /**
  58423. * Defines the target frame rate to reach (60 by default)
  58424. */
  58425. targetFrameRate?: number,
  58426. /**
  58427. * Defines the interval between two checkes (2000ms by default)
  58428. */
  58429. trackerDuration?: number);
  58430. /**
  58431. * Add a new optimization
  58432. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58433. * @returns the current SceneOptimizerOptions
  58434. */
  58435. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58436. /**
  58437. * Add a new custom optimization
  58438. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58439. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58440. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58441. * @returns the current SceneOptimizerOptions
  58442. */
  58443. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58444. /**
  58445. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58446. * @param targetFrameRate defines the target frame rate (60 by default)
  58447. * @returns a SceneOptimizerOptions object
  58448. */
  58449. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58450. /**
  58451. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58452. * @param targetFrameRate defines the target frame rate (60 by default)
  58453. * @returns a SceneOptimizerOptions object
  58454. */
  58455. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58456. /**
  58457. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58458. * @param targetFrameRate defines the target frame rate (60 by default)
  58459. * @returns a SceneOptimizerOptions object
  58460. */
  58461. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58462. }
  58463. /**
  58464. * Class used to run optimizations in order to reach a target frame rate
  58465. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58466. */
  58467. export class SceneOptimizer implements IDisposable {
  58468. private _isRunning;
  58469. private _options;
  58470. private _scene;
  58471. private _currentPriorityLevel;
  58472. private _targetFrameRate;
  58473. private _trackerDuration;
  58474. private _currentFrameRate;
  58475. private _sceneDisposeObserver;
  58476. private _improvementMode;
  58477. /**
  58478. * Defines an observable called when the optimizer reaches the target frame rate
  58479. */
  58480. onSuccessObservable: Observable<SceneOptimizer>;
  58481. /**
  58482. * Defines an observable called when the optimizer enables an optimization
  58483. */
  58484. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58485. /**
  58486. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58487. */
  58488. onFailureObservable: Observable<SceneOptimizer>;
  58489. /**
  58490. * Gets a boolean indicating if the optimizer is in improvement mode
  58491. */
  58492. readonly isInImprovementMode: boolean;
  58493. /**
  58494. * Gets the current priority level (0 at start)
  58495. */
  58496. readonly currentPriorityLevel: number;
  58497. /**
  58498. * Gets the current frame rate checked by the SceneOptimizer
  58499. */
  58500. readonly currentFrameRate: number;
  58501. /**
  58502. * Gets or sets the current target frame rate (60 by default)
  58503. */
  58504. /**
  58505. * Gets or sets the current target frame rate (60 by default)
  58506. */
  58507. targetFrameRate: number;
  58508. /**
  58509. * Gets or sets the current interval between two checks (every 2000ms by default)
  58510. */
  58511. /**
  58512. * Gets or sets the current interval between two checks (every 2000ms by default)
  58513. */
  58514. trackerDuration: number;
  58515. /**
  58516. * Gets the list of active optimizations
  58517. */
  58518. readonly optimizations: SceneOptimization[];
  58519. /**
  58520. * Creates a new SceneOptimizer
  58521. * @param scene defines the scene to work on
  58522. * @param options defines the options to use with the SceneOptimizer
  58523. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58524. * @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)
  58525. */
  58526. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58527. /**
  58528. * Stops the current optimizer
  58529. */
  58530. stop(): void;
  58531. /**
  58532. * Reset the optimizer to initial step (current priority level = 0)
  58533. */
  58534. reset(): void;
  58535. /**
  58536. * Start the optimizer. By default it will try to reach a specific framerate
  58537. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58538. */
  58539. start(): void;
  58540. private _checkCurrentState;
  58541. /**
  58542. * Release all resources
  58543. */
  58544. dispose(): void;
  58545. /**
  58546. * Helper function to create a SceneOptimizer with one single line of code
  58547. * @param scene defines the scene to work on
  58548. * @param options defines the options to use with the SceneOptimizer
  58549. * @param onSuccess defines a callback to call on success
  58550. * @param onFailure defines a callback to call on failure
  58551. * @returns the new SceneOptimizer object
  58552. */
  58553. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58554. }
  58555. }
  58556. declare module BABYLON {
  58557. /**
  58558. * Class used to serialize a scene into a string
  58559. */
  58560. export class SceneSerializer {
  58561. /**
  58562. * Clear cache used by a previous serialization
  58563. */
  58564. static ClearCache(): void;
  58565. /**
  58566. * Serialize a scene into a JSON compatible object
  58567. * @param scene defines the scene to serialize
  58568. * @returns a JSON compatible object
  58569. */
  58570. static Serialize(scene: Scene): any;
  58571. /**
  58572. * Serialize a mesh into a JSON compatible object
  58573. * @param toSerialize defines the mesh to serialize
  58574. * @param withParents defines if parents must be serialized as well
  58575. * @param withChildren defines if children must be serialized as well
  58576. * @returns a JSON compatible object
  58577. */
  58578. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58579. }
  58580. }
  58581. declare module BABYLON {
  58582. /**
  58583. * Class used to host texture specific utilities
  58584. */
  58585. export class TextureTools {
  58586. /**
  58587. * Uses the GPU to create a copy texture rescaled at a given size
  58588. * @param texture Texture to copy from
  58589. * @param width defines the desired width
  58590. * @param height defines the desired height
  58591. * @param useBilinearMode defines if bilinear mode has to be used
  58592. * @return the generated texture
  58593. */
  58594. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58595. }
  58596. }
  58597. declare module BABYLON {
  58598. /**
  58599. * This represents the different options avilable for the video capture.
  58600. */
  58601. export interface VideoRecorderOptions {
  58602. /** Defines the mime type of the video */
  58603. mimeType: string;
  58604. /** Defines the video the video should be recorded at */
  58605. fps: number;
  58606. /** Defines the chunk size for the recording data */
  58607. recordChunckSize: number;
  58608. /** The audio tracks to attach to the record */
  58609. audioTracks?: MediaStreamTrack[];
  58610. }
  58611. /**
  58612. * This can helps recording videos from BabylonJS.
  58613. * This is based on the available WebRTC functionalities of the browser.
  58614. *
  58615. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58616. */
  58617. export class VideoRecorder {
  58618. private static readonly _defaultOptions;
  58619. /**
  58620. * Returns wehther or not the VideoRecorder is available in your browser.
  58621. * @param engine Defines the Babylon Engine to check the support for
  58622. * @returns true if supported otherwise false
  58623. */
  58624. static IsSupported(engine: Engine): boolean;
  58625. private readonly _options;
  58626. private _canvas;
  58627. private _mediaRecorder;
  58628. private _recordedChunks;
  58629. private _fileName;
  58630. private _resolve;
  58631. private _reject;
  58632. /**
  58633. * True wether a recording is already in progress.
  58634. */
  58635. readonly isRecording: boolean;
  58636. /**
  58637. * Create a new VideoCapture object which can help converting what you see in Babylon to
  58638. * a video file.
  58639. * @param engine Defines the BabylonJS Engine you wish to record
  58640. * @param options Defines options that can be used to customized the capture
  58641. */
  58642. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  58643. /**
  58644. * Stops the current recording before the default capture timeout passed in the startRecording
  58645. * functions.
  58646. */
  58647. stopRecording(): void;
  58648. /**
  58649. * Starts recording the canvas for a max duration specified in parameters.
  58650. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  58651. * @param maxDuration Defines the maximum recording time in seconds.
  58652. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  58653. * @return a promise callback at the end of the recording with the video data in Blob.
  58654. */
  58655. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  58656. /**
  58657. * Releases internal resources used during the recording.
  58658. */
  58659. dispose(): void;
  58660. private _handleDataAvailable;
  58661. private _handleError;
  58662. private _handleStop;
  58663. }
  58664. }
  58665. declare module BABYLON {
  58666. /**
  58667. * Class containing a set of static utilities functions for screenshots
  58668. */
  58669. export class ScreenshotTools {
  58670. /**
  58671. * Captures a screenshot of the current rendering
  58672. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58673. * @param engine defines the rendering engine
  58674. * @param camera defines the source camera
  58675. * @param size This parameter can be set to a single number or to an object with the
  58676. * following (optional) properties: precision, width, height. If a single number is passed,
  58677. * it will be used for both width and height. If an object is passed, the screenshot size
  58678. * will be derived from the parameters. The precision property is a multiplier allowing
  58679. * rendering at a higher or lower resolution
  58680. * @param successCallback defines the callback receives a single parameter which contains the
  58681. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58682. * src parameter of an <img> to display it
  58683. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  58684. * Check your browser for supported MIME types
  58685. */
  58686. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  58687. /**
  58688. * Generates an image screenshot from the specified camera.
  58689. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58690. * @param engine The engine to use for rendering
  58691. * @param camera The camera to use for rendering
  58692. * @param size This parameter can be set to a single number or to an object with the
  58693. * following (optional) properties: precision, width, height. If a single number is passed,
  58694. * it will be used for both width and height. If an object is passed, the screenshot size
  58695. * will be derived from the parameters. The precision property is a multiplier allowing
  58696. * rendering at a higher or lower resolution
  58697. * @param successCallback The callback receives a single parameter which contains the
  58698. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58699. * src parameter of an <img> to display it
  58700. * @param mimeType The MIME type of the screenshot image (default: image/png).
  58701. * Check your browser for supported MIME types
  58702. * @param samples Texture samples (default: 1)
  58703. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  58704. * @param fileName A name for for the downloaded file.
  58705. */
  58706. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  58707. }
  58708. }
  58709. declare module BABYLON {
  58710. /**
  58711. * A cursor which tracks a point on a path
  58712. */
  58713. export class PathCursor {
  58714. private path;
  58715. /**
  58716. * Stores path cursor callbacks for when an onchange event is triggered
  58717. */
  58718. private _onchange;
  58719. /**
  58720. * The value of the path cursor
  58721. */
  58722. value: number;
  58723. /**
  58724. * The animation array of the path cursor
  58725. */
  58726. animations: Animation[];
  58727. /**
  58728. * Initializes the path cursor
  58729. * @param path The path to track
  58730. */
  58731. constructor(path: Path2);
  58732. /**
  58733. * Gets the cursor point on the path
  58734. * @returns A point on the path cursor at the cursor location
  58735. */
  58736. getPoint(): Vector3;
  58737. /**
  58738. * Moves the cursor ahead by the step amount
  58739. * @param step The amount to move the cursor forward
  58740. * @returns This path cursor
  58741. */
  58742. moveAhead(step?: number): PathCursor;
  58743. /**
  58744. * Moves the cursor behind by the step amount
  58745. * @param step The amount to move the cursor back
  58746. * @returns This path cursor
  58747. */
  58748. moveBack(step?: number): PathCursor;
  58749. /**
  58750. * Moves the cursor by the step amount
  58751. * If the step amount is greater than one, an exception is thrown
  58752. * @param step The amount to move the cursor
  58753. * @returns This path cursor
  58754. */
  58755. move(step: number): PathCursor;
  58756. /**
  58757. * Ensures that the value is limited between zero and one
  58758. * @returns This path cursor
  58759. */
  58760. private ensureLimits;
  58761. /**
  58762. * Runs onchange callbacks on change (used by the animation engine)
  58763. * @returns This path cursor
  58764. */
  58765. private raiseOnChange;
  58766. /**
  58767. * Executes a function on change
  58768. * @param f A path cursor onchange callback
  58769. * @returns This path cursor
  58770. */
  58771. onchange(f: (cursor: PathCursor) => void): PathCursor;
  58772. }
  58773. }
  58774. declare module BABYLON {
  58775. /** @hidden */
  58776. export var blurPixelShader: {
  58777. name: string;
  58778. shader: string;
  58779. };
  58780. }
  58781. declare module BABYLON {
  58782. /** @hidden */
  58783. export var bones300Declaration: {
  58784. name: string;
  58785. shader: string;
  58786. };
  58787. }
  58788. declare module BABYLON {
  58789. /** @hidden */
  58790. export var instances300Declaration: {
  58791. name: string;
  58792. shader: string;
  58793. };
  58794. }
  58795. declare module BABYLON {
  58796. /** @hidden */
  58797. export var pointCloudVertexDeclaration: {
  58798. name: string;
  58799. shader: string;
  58800. };
  58801. }
  58802. // Mixins
  58803. interface Window {
  58804. mozIndexedDB: IDBFactory;
  58805. webkitIndexedDB: IDBFactory;
  58806. msIndexedDB: IDBFactory;
  58807. webkitURL: typeof URL;
  58808. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58809. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58810. WebGLRenderingContext: WebGLRenderingContext;
  58811. MSGesture: MSGesture;
  58812. CANNON: any;
  58813. AudioContext: AudioContext;
  58814. webkitAudioContext: AudioContext;
  58815. PointerEvent: any;
  58816. Math: Math;
  58817. Uint8Array: Uint8ArrayConstructor;
  58818. Float32Array: Float32ArrayConstructor;
  58819. mozURL: typeof URL;
  58820. msURL: typeof URL;
  58821. VRFrameData: any; // WebVR, from specs 1.1
  58822. DracoDecoderModule: any;
  58823. setImmediate(handler: (...args: any[]) => void): number;
  58824. }
  58825. interface HTMLCanvasElement {
  58826. requestPointerLock(): void;
  58827. msRequestPointerLock?(): void;
  58828. mozRequestPointerLock?(): void;
  58829. webkitRequestPointerLock?(): void;
  58830. /** Track wether a record is in progress */
  58831. isRecording: boolean;
  58832. /** Capture Stream method defined by some browsers */
  58833. captureStream(fps?: number): MediaStream;
  58834. }
  58835. interface CanvasRenderingContext2D {
  58836. msImageSmoothingEnabled: boolean;
  58837. }
  58838. interface MouseEvent {
  58839. mozMovementX: number;
  58840. mozMovementY: number;
  58841. webkitMovementX: number;
  58842. webkitMovementY: number;
  58843. msMovementX: number;
  58844. msMovementY: number;
  58845. }
  58846. interface Navigator {
  58847. mozGetVRDevices: (any: any) => any;
  58848. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58849. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58850. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58851. webkitGetGamepads(): Gamepad[];
  58852. msGetGamepads(): Gamepad[];
  58853. webkitGamepads(): Gamepad[];
  58854. }
  58855. interface HTMLVideoElement {
  58856. mozSrcObject: any;
  58857. }
  58858. interface Math {
  58859. fround(x: number): number;
  58860. imul(a: number, b: number): number;
  58861. }
  58862. interface WebGLRenderingContext {
  58863. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  58864. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  58865. vertexAttribDivisor(index: number, divisor: number): void;
  58866. createVertexArray(): any;
  58867. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  58868. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  58869. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  58870. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  58871. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  58872. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58873. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  58874. // Queries
  58875. createQuery(): WebGLQuery;
  58876. deleteQuery(query: WebGLQuery): void;
  58877. beginQuery(target: number, query: WebGLQuery): void;
  58878. endQuery(target: number): void;
  58879. getQueryParameter(query: WebGLQuery, pname: number): any;
  58880. getQuery(target: number, pname: number): any;
  58881. MAX_SAMPLES: number;
  58882. RGBA8: number;
  58883. READ_FRAMEBUFFER: number;
  58884. DRAW_FRAMEBUFFER: number;
  58885. UNIFORM_BUFFER: number;
  58886. HALF_FLOAT_OES: number;
  58887. RGBA16F: number;
  58888. RGBA32F: number;
  58889. R32F: number;
  58890. RG32F: number;
  58891. RGB32F: number;
  58892. R16F: number;
  58893. RG16F: number;
  58894. RGB16F: number;
  58895. RED: number;
  58896. RG: number;
  58897. R8: number;
  58898. RG8: number;
  58899. UNSIGNED_INT_24_8: number;
  58900. DEPTH24_STENCIL8: number;
  58901. /* Multiple Render Targets */
  58902. drawBuffers(buffers: number[]): void;
  58903. readBuffer(src: number): void;
  58904. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  58905. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  58906. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  58907. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  58908. // Occlusion Query
  58909. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  58910. ANY_SAMPLES_PASSED: number;
  58911. QUERY_RESULT_AVAILABLE: number;
  58912. QUERY_RESULT: number;
  58913. }
  58914. interface WebGLProgram {
  58915. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  58916. }
  58917. interface EXT_disjoint_timer_query {
  58918. QUERY_COUNTER_BITS_EXT: number;
  58919. TIME_ELAPSED_EXT: number;
  58920. TIMESTAMP_EXT: number;
  58921. GPU_DISJOINT_EXT: number;
  58922. QUERY_RESULT_EXT: number;
  58923. QUERY_RESULT_AVAILABLE_EXT: number;
  58924. queryCounterEXT(query: WebGLQuery, target: number): void;
  58925. createQueryEXT(): WebGLQuery;
  58926. beginQueryEXT(target: number, query: WebGLQuery): void;
  58927. endQueryEXT(target: number): void;
  58928. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  58929. deleteQueryEXT(query: WebGLQuery): void;
  58930. }
  58931. interface WebGLUniformLocation {
  58932. _currentState: any;
  58933. }
  58934. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  58935. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  58936. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  58937. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58938. interface WebGLRenderingContext {
  58939. readonly RASTERIZER_DISCARD: number;
  58940. readonly DEPTH_COMPONENT24: number;
  58941. readonly TEXTURE_3D: number;
  58942. readonly TEXTURE_2D_ARRAY: number;
  58943. readonly TEXTURE_COMPARE_FUNC: number;
  58944. readonly TEXTURE_COMPARE_MODE: number;
  58945. readonly COMPARE_REF_TO_TEXTURE: number;
  58946. readonly TEXTURE_WRAP_R: number;
  58947. readonly HALF_FLOAT: number;
  58948. readonly RGB8: number;
  58949. readonly RED_INTEGER: number;
  58950. readonly RG_INTEGER: number;
  58951. readonly RGB_INTEGER: number;
  58952. readonly RGBA_INTEGER: number;
  58953. readonly R8_SNORM: number;
  58954. readonly RG8_SNORM: number;
  58955. readonly RGB8_SNORM: number;
  58956. readonly RGBA8_SNORM: number;
  58957. readonly R8I: number;
  58958. readonly RG8I: number;
  58959. readonly RGB8I: number;
  58960. readonly RGBA8I: number;
  58961. readonly R8UI: number;
  58962. readonly RG8UI: number;
  58963. readonly RGB8UI: number;
  58964. readonly RGBA8UI: number;
  58965. readonly R16I: number;
  58966. readonly RG16I: number;
  58967. readonly RGB16I: number;
  58968. readonly RGBA16I: number;
  58969. readonly R16UI: number;
  58970. readonly RG16UI: number;
  58971. readonly RGB16UI: number;
  58972. readonly RGBA16UI: number;
  58973. readonly R32I: number;
  58974. readonly RG32I: number;
  58975. readonly RGB32I: number;
  58976. readonly RGBA32I: number;
  58977. readonly R32UI: number;
  58978. readonly RG32UI: number;
  58979. readonly RGB32UI: number;
  58980. readonly RGBA32UI: number;
  58981. readonly RGB10_A2UI: number;
  58982. readonly R11F_G11F_B10F: number;
  58983. readonly RGB9_E5: number;
  58984. readonly RGB10_A2: number;
  58985. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  58986. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  58987. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  58988. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  58989. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  58990. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  58991. 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;
  58992. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  58993. readonly TRANSFORM_FEEDBACK: number;
  58994. readonly INTERLEAVED_ATTRIBS: number;
  58995. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  58996. createTransformFeedback(): WebGLTransformFeedback;
  58997. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  58998. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  58999. beginTransformFeedback(primitiveMode: number): void;
  59000. endTransformFeedback(): void;
  59001. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59002. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59003. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59004. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59005. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59006. }
  59007. interface ImageBitmap {
  59008. readonly width: number;
  59009. readonly height: number;
  59010. close(): void;
  59011. }
  59012. interface WebGLQuery extends WebGLObject {
  59013. }
  59014. declare var WebGLQuery: {
  59015. prototype: WebGLQuery;
  59016. new(): WebGLQuery;
  59017. };
  59018. interface WebGLSampler extends WebGLObject {
  59019. }
  59020. declare var WebGLSampler: {
  59021. prototype: WebGLSampler;
  59022. new(): WebGLSampler;
  59023. };
  59024. interface WebGLSync extends WebGLObject {
  59025. }
  59026. declare var WebGLSync: {
  59027. prototype: WebGLSync;
  59028. new(): WebGLSync;
  59029. };
  59030. interface WebGLTransformFeedback extends WebGLObject {
  59031. }
  59032. declare var WebGLTransformFeedback: {
  59033. prototype: WebGLTransformFeedback;
  59034. new(): WebGLTransformFeedback;
  59035. };
  59036. interface WebGLVertexArrayObject extends WebGLObject {
  59037. }
  59038. declare var WebGLVertexArrayObject: {
  59039. prototype: WebGLVertexArrayObject;
  59040. new(): WebGLVertexArrayObject;
  59041. };
  59042. // Type definitions for WebVR API
  59043. // Project: https://w3c.github.io/webvr/
  59044. // Definitions by: six a <https://github.com/lostfictions>
  59045. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59046. interface VRDisplay extends EventTarget {
  59047. /**
  59048. * Dictionary of capabilities describing the VRDisplay.
  59049. */
  59050. readonly capabilities: VRDisplayCapabilities;
  59051. /**
  59052. * z-depth defining the far plane of the eye view frustum
  59053. * enables mapping of values in the render target depth
  59054. * attachment to scene coordinates. Initially set to 10000.0.
  59055. */
  59056. depthFar: number;
  59057. /**
  59058. * z-depth defining the near plane of the eye view frustum
  59059. * enables mapping of values in the render target depth
  59060. * attachment to scene coordinates. Initially set to 0.01.
  59061. */
  59062. depthNear: number;
  59063. /**
  59064. * An identifier for this distinct VRDisplay. Used as an
  59065. * association point in the Gamepad API.
  59066. */
  59067. readonly displayId: number;
  59068. /**
  59069. * A display name, a user-readable name identifying it.
  59070. */
  59071. readonly displayName: string;
  59072. readonly isConnected: boolean;
  59073. readonly isPresenting: boolean;
  59074. /**
  59075. * If this VRDisplay supports room-scale experiences, the optional
  59076. * stage attribute contains details on the room-scale parameters.
  59077. */
  59078. readonly stageParameters: VRStageParameters | null;
  59079. /**
  59080. * Passing the value returned by `requestAnimationFrame` to
  59081. * `cancelAnimationFrame` will unregister the callback.
  59082. * @param handle Define the hanle of the request to cancel
  59083. */
  59084. cancelAnimationFrame(handle: number): void;
  59085. /**
  59086. * Stops presenting to the VRDisplay.
  59087. * @returns a promise to know when it stopped
  59088. */
  59089. exitPresent(): Promise<void>;
  59090. /**
  59091. * Return the current VREyeParameters for the given eye.
  59092. * @param whichEye Define the eye we want the parameter for
  59093. * @returns the eye parameters
  59094. */
  59095. getEyeParameters(whichEye: string): VREyeParameters;
  59096. /**
  59097. * Populates the passed VRFrameData with the information required to render
  59098. * the current frame.
  59099. * @param frameData Define the data structure to populate
  59100. * @returns true if ok otherwise false
  59101. */
  59102. getFrameData(frameData: VRFrameData): boolean;
  59103. /**
  59104. * Get the layers currently being presented.
  59105. * @returns the list of VR layers
  59106. */
  59107. getLayers(): VRLayer[];
  59108. /**
  59109. * Return a VRPose containing the future predicted pose of the VRDisplay
  59110. * when the current frame will be presented. The value returned will not
  59111. * change until JavaScript has returned control to the browser.
  59112. *
  59113. * The VRPose will contain the position, orientation, velocity,
  59114. * and acceleration of each of these properties.
  59115. * @returns the pose object
  59116. */
  59117. getPose(): VRPose;
  59118. /**
  59119. * Return the current instantaneous pose of the VRDisplay, with no
  59120. * prediction applied.
  59121. * @returns the current instantaneous pose
  59122. */
  59123. getImmediatePose(): VRPose;
  59124. /**
  59125. * The callback passed to `requestAnimationFrame` will be called
  59126. * any time a new frame should be rendered. When the VRDisplay is
  59127. * presenting the callback will be called at the native refresh
  59128. * rate of the HMD. When not presenting this function acts
  59129. * identically to how window.requestAnimationFrame acts. Content should
  59130. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59131. * asynchronously from other displays and at differing refresh rates.
  59132. * @param callback Define the eaction to run next frame
  59133. * @returns the request handle it
  59134. */
  59135. requestAnimationFrame(callback: FrameRequestCallback): number;
  59136. /**
  59137. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59138. * Repeat calls while already presenting will update the VRLayers being displayed.
  59139. * @param layers Define the list of layer to present
  59140. * @returns a promise to know when the request has been fulfilled
  59141. */
  59142. requestPresent(layers: VRLayer[]): Promise<void>;
  59143. /**
  59144. * Reset the pose for this display, treating its current position and
  59145. * orientation as the "origin/zero" values. VRPose.position,
  59146. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59147. * updated when calling resetPose(). This should be called in only
  59148. * sitting-space experiences.
  59149. */
  59150. resetPose(): void;
  59151. /**
  59152. * The VRLayer provided to the VRDisplay will be captured and presented
  59153. * in the HMD. Calling this function has the same effect on the source
  59154. * canvas as any other operation that uses its source image, and canvases
  59155. * created without preserveDrawingBuffer set to true will be cleared.
  59156. * @param pose Define the pose to submit
  59157. */
  59158. submitFrame(pose?: VRPose): void;
  59159. }
  59160. declare var VRDisplay: {
  59161. prototype: VRDisplay;
  59162. new(): VRDisplay;
  59163. };
  59164. interface VRLayer {
  59165. leftBounds?: number[] | Float32Array | null;
  59166. rightBounds?: number[] | Float32Array | null;
  59167. source?: HTMLCanvasElement | null;
  59168. }
  59169. interface VRDisplayCapabilities {
  59170. readonly canPresent: boolean;
  59171. readonly hasExternalDisplay: boolean;
  59172. readonly hasOrientation: boolean;
  59173. readonly hasPosition: boolean;
  59174. readonly maxLayers: number;
  59175. }
  59176. interface VREyeParameters {
  59177. /** @deprecated */
  59178. readonly fieldOfView: VRFieldOfView;
  59179. readonly offset: Float32Array;
  59180. readonly renderHeight: number;
  59181. readonly renderWidth: number;
  59182. }
  59183. interface VRFieldOfView {
  59184. readonly downDegrees: number;
  59185. readonly leftDegrees: number;
  59186. readonly rightDegrees: number;
  59187. readonly upDegrees: number;
  59188. }
  59189. interface VRFrameData {
  59190. readonly leftProjectionMatrix: Float32Array;
  59191. readonly leftViewMatrix: Float32Array;
  59192. readonly pose: VRPose;
  59193. readonly rightProjectionMatrix: Float32Array;
  59194. readonly rightViewMatrix: Float32Array;
  59195. readonly timestamp: number;
  59196. }
  59197. interface VRPose {
  59198. readonly angularAcceleration: Float32Array | null;
  59199. readonly angularVelocity: Float32Array | null;
  59200. readonly linearAcceleration: Float32Array | null;
  59201. readonly linearVelocity: Float32Array | null;
  59202. readonly orientation: Float32Array | null;
  59203. readonly position: Float32Array | null;
  59204. readonly timestamp: number;
  59205. }
  59206. interface VRStageParameters {
  59207. sittingToStandingTransform?: Float32Array;
  59208. sizeX?: number;
  59209. sizeY?: number;
  59210. }
  59211. interface Navigator {
  59212. getVRDisplays(): Promise<VRDisplay[]>;
  59213. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59214. }
  59215. interface Window {
  59216. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59217. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59218. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59219. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59220. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59221. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59222. }
  59223. interface Gamepad {
  59224. readonly displayId: number;
  59225. }
  59226. interface XRDevice {
  59227. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59228. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59229. }
  59230. interface XRSession {
  59231. getInputSources(): Array<any>;
  59232. baseLayer: XRWebGLLayer;
  59233. requestFrameOfReference(type: string): Promise<void>;
  59234. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59235. end(): Promise<void>;
  59236. requestAnimationFrame: Function;
  59237. addEventListener: Function;
  59238. }
  59239. interface XRSessionCreationOptions {
  59240. outputContext?: WebGLRenderingContext | null;
  59241. immersive?: boolean;
  59242. environmentIntegration?: boolean;
  59243. }
  59244. interface XRLayer {
  59245. getViewport: Function;
  59246. framebufferWidth: number;
  59247. framebufferHeight: number;
  59248. }
  59249. interface XRView {
  59250. projectionMatrix: Float32Array;
  59251. }
  59252. interface XRFrame {
  59253. getDevicePose: Function;
  59254. getInputPose: Function;
  59255. views: Array<XRView>;
  59256. baseLayer: XRLayer;
  59257. }
  59258. interface XRFrameOfReference {
  59259. }
  59260. interface XRWebGLLayer extends XRLayer {
  59261. framebuffer: WebGLFramebuffer;
  59262. }
  59263. declare var XRWebGLLayer: {
  59264. prototype: XRWebGLLayer;
  59265. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59266. };
  59267. declare module BABYLON.GUI {
  59268. /**
  59269. * Class used to specific a value and its associated unit
  59270. */
  59271. export class ValueAndUnit {
  59272. /** defines the unit to store */
  59273. unit: number;
  59274. /** defines a boolean indicating if the value can be negative */
  59275. negativeValueAllowed: boolean;
  59276. private _value;
  59277. private _originalUnit;
  59278. /**
  59279. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  59280. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59281. */
  59282. ignoreAdaptiveScaling: boolean;
  59283. /**
  59284. * Creates a new ValueAndUnit
  59285. * @param value defines the value to store
  59286. * @param unit defines the unit to store
  59287. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  59288. */
  59289. constructor(value: number,
  59290. /** defines the unit to store */
  59291. unit?: number,
  59292. /** defines a boolean indicating if the value can be negative */
  59293. negativeValueAllowed?: boolean);
  59294. /** Gets a boolean indicating if the value is a percentage */
  59295. readonly isPercentage: boolean;
  59296. /** Gets a boolean indicating if the value is store as pixel */
  59297. readonly isPixel: boolean;
  59298. /** Gets direct internal value */
  59299. readonly internalValue: number;
  59300. /**
  59301. * Gets value as pixel
  59302. * @param host defines the root host
  59303. * @param refValue defines the reference value for percentages
  59304. * @returns the value as pixel
  59305. */
  59306. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  59307. /**
  59308. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  59309. * @param value defines the value to store
  59310. * @param unit defines the unit to store
  59311. * @returns the current ValueAndUnit
  59312. */
  59313. updateInPlace(value: number, unit?: number): ValueAndUnit;
  59314. /**
  59315. * Gets the value accordingly to its unit
  59316. * @param host defines the root host
  59317. * @returns the value
  59318. */
  59319. getValue(host: AdvancedDynamicTexture): number;
  59320. /**
  59321. * Gets a string representation of the value
  59322. * @param host defines the root host
  59323. * @param decimals defines an optional number of decimals to display
  59324. * @returns a string
  59325. */
  59326. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  59327. /**
  59328. * Store a value parsed from a string
  59329. * @param source defines the source string
  59330. * @returns true if the value was successfully parsed
  59331. */
  59332. fromString(source: string | number): boolean;
  59333. private static _Regex;
  59334. private static _UNITMODE_PERCENTAGE;
  59335. private static _UNITMODE_PIXEL;
  59336. /** UNITMODE_PERCENTAGE */
  59337. static readonly UNITMODE_PERCENTAGE: number;
  59338. /** UNITMODE_PIXEL */
  59339. static readonly UNITMODE_PIXEL: number;
  59340. }
  59341. }
  59342. declare module BABYLON.GUI {
  59343. /**
  59344. * Define a style used by control to automatically setup properties based on a template.
  59345. * Only support font related properties so far
  59346. */
  59347. export class Style implements BABYLON.IDisposable {
  59348. private _fontFamily;
  59349. private _fontStyle;
  59350. private _fontWeight;
  59351. /** @hidden */
  59352. _host: AdvancedDynamicTexture;
  59353. /** @hidden */
  59354. _fontSize: ValueAndUnit;
  59355. /**
  59356. * BABYLON.Observable raised when the style values are changed
  59357. */
  59358. onChangedObservable: BABYLON.Observable<Style>;
  59359. /**
  59360. * Creates a new style object
  59361. * @param host defines the AdvancedDynamicTexture which hosts this style
  59362. */
  59363. constructor(host: AdvancedDynamicTexture);
  59364. /**
  59365. * Gets or sets the font size
  59366. */
  59367. fontSize: string | number;
  59368. /**
  59369. * Gets or sets the font family
  59370. */
  59371. fontFamily: string;
  59372. /**
  59373. * Gets or sets the font style
  59374. */
  59375. fontStyle: string;
  59376. /** Gets or sets font weight */
  59377. fontWeight: string;
  59378. /** Dispose all associated resources */
  59379. dispose(): void;
  59380. }
  59381. }
  59382. declare module BABYLON.GUI {
  59383. /**
  59384. * Class used to transport BABYLON.Vector2 information for pointer events
  59385. */
  59386. export class Vector2WithInfo extends BABYLON.Vector2 {
  59387. /** defines the current mouse button index */
  59388. buttonIndex: number;
  59389. /**
  59390. * Creates a new Vector2WithInfo
  59391. * @param source defines the vector2 data to transport
  59392. * @param buttonIndex defines the current mouse button index
  59393. */
  59394. constructor(source: BABYLON.Vector2,
  59395. /** defines the current mouse button index */
  59396. buttonIndex?: number);
  59397. }
  59398. /** Class used to provide 2D matrix features */
  59399. export class Matrix2D {
  59400. /** Gets the internal array of 6 floats used to store matrix data */
  59401. m: Float32Array;
  59402. /**
  59403. * Creates a new matrix
  59404. * @param m00 defines value for (0, 0)
  59405. * @param m01 defines value for (0, 1)
  59406. * @param m10 defines value for (1, 0)
  59407. * @param m11 defines value for (1, 1)
  59408. * @param m20 defines value for (2, 0)
  59409. * @param m21 defines value for (2, 1)
  59410. */
  59411. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  59412. /**
  59413. * Fills the matrix from direct values
  59414. * @param m00 defines value for (0, 0)
  59415. * @param m01 defines value for (0, 1)
  59416. * @param m10 defines value for (1, 0)
  59417. * @param m11 defines value for (1, 1)
  59418. * @param m20 defines value for (2, 0)
  59419. * @param m21 defines value for (2, 1)
  59420. * @returns the current modified matrix
  59421. */
  59422. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  59423. /**
  59424. * Gets matrix determinant
  59425. * @returns the determinant
  59426. */
  59427. determinant(): number;
  59428. /**
  59429. * Inverses the matrix and stores it in a target matrix
  59430. * @param result defines the target matrix
  59431. * @returns the current matrix
  59432. */
  59433. invertToRef(result: Matrix2D): Matrix2D;
  59434. /**
  59435. * Multiplies the current matrix with another one
  59436. * @param other defines the second operand
  59437. * @param result defines the target matrix
  59438. * @returns the current matrix
  59439. */
  59440. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  59441. /**
  59442. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  59443. * @param x defines the x coordinate to transform
  59444. * @param y defines the x coordinate to transform
  59445. * @param result defines the target vector2
  59446. * @returns the current matrix
  59447. */
  59448. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  59449. /**
  59450. * Creates an identity matrix
  59451. * @returns a new matrix
  59452. */
  59453. static Identity(): Matrix2D;
  59454. /**
  59455. * Creates a translation matrix and stores it in a target matrix
  59456. * @param x defines the x coordinate of the translation
  59457. * @param y defines the y coordinate of the translation
  59458. * @param result defines the target matrix
  59459. */
  59460. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  59461. /**
  59462. * Creates a scaling matrix and stores it in a target matrix
  59463. * @param x defines the x coordinate of the scaling
  59464. * @param y defines the y coordinate of the scaling
  59465. * @param result defines the target matrix
  59466. */
  59467. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  59468. /**
  59469. * Creates a rotation matrix and stores it in a target matrix
  59470. * @param angle defines the rotation angle
  59471. * @param result defines the target matrix
  59472. */
  59473. static RotationToRef(angle: number, result: Matrix2D): void;
  59474. private static _TempPreTranslationMatrix;
  59475. private static _TempPostTranslationMatrix;
  59476. private static _TempRotationMatrix;
  59477. private static _TempScalingMatrix;
  59478. private static _TempCompose0;
  59479. private static _TempCompose1;
  59480. private static _TempCompose2;
  59481. /**
  59482. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  59483. * @param tx defines the x coordinate of the translation
  59484. * @param ty defines the y coordinate of the translation
  59485. * @param angle defines the rotation angle
  59486. * @param scaleX defines the x coordinate of the scaling
  59487. * @param scaleY defines the y coordinate of the scaling
  59488. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  59489. * @param result defines the target matrix
  59490. */
  59491. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  59492. }
  59493. }
  59494. declare module BABYLON.GUI {
  59495. /**
  59496. * Class used to store 2D control sizes
  59497. */
  59498. export class Measure {
  59499. /** defines left coordinate */
  59500. left: number;
  59501. /** defines top coordinate */
  59502. top: number;
  59503. /** defines width dimension */
  59504. width: number;
  59505. /** defines height dimension */
  59506. height: number;
  59507. /**
  59508. * Creates a new measure
  59509. * @param left defines left coordinate
  59510. * @param top defines top coordinate
  59511. * @param width defines width dimension
  59512. * @param height defines height dimension
  59513. */
  59514. constructor(
  59515. /** defines left coordinate */
  59516. left: number,
  59517. /** defines top coordinate */
  59518. top: number,
  59519. /** defines width dimension */
  59520. width: number,
  59521. /** defines height dimension */
  59522. height: number);
  59523. /**
  59524. * Copy from another measure
  59525. * @param other defines the other measure to copy from
  59526. */
  59527. copyFrom(other: Measure): void;
  59528. /**
  59529. * Copy from a group of 4 floats
  59530. * @param left defines left coordinate
  59531. * @param top defines top coordinate
  59532. * @param width defines width dimension
  59533. * @param height defines height dimension
  59534. */
  59535. copyFromFloats(left: number, top: number, width: number, height: number): void;
  59536. /**
  59537. * Computes the axis aligned bounding box measure for two given measures
  59538. * @param a Input measure
  59539. * @param b Input measure
  59540. * @param result the resulting bounding measure
  59541. */
  59542. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  59543. /**
  59544. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  59545. * @param transform the matrix to transform the measure before computing the AABB
  59546. * @param result the resulting AABB
  59547. */
  59548. transformToRef(transform: Matrix2D, result: Measure): void;
  59549. /**
  59550. * Check equality between this measure and another one
  59551. * @param other defines the other measures
  59552. * @returns true if both measures are equals
  59553. */
  59554. isEqualsTo(other: Measure): boolean;
  59555. /**
  59556. * Creates an empty measure
  59557. * @returns a new measure
  59558. */
  59559. static Empty(): Measure;
  59560. }
  59561. }
  59562. declare module BABYLON.GUI {
  59563. /**
  59564. * Interface used to define a control that can receive focus
  59565. */
  59566. export interface IFocusableControl {
  59567. /**
  59568. * Function called when the control receives the focus
  59569. */
  59570. onFocus(): void;
  59571. /**
  59572. * Function called when the control loses the focus
  59573. */
  59574. onBlur(): void;
  59575. /**
  59576. * Function called to let the control handle keyboard events
  59577. * @param evt defines the current keyboard event
  59578. */
  59579. processKeyboard(evt: KeyboardEvent): void;
  59580. /**
  59581. * Function called to get the list of controls that should not steal the focus from this control
  59582. * @returns an array of controls
  59583. */
  59584. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  59585. }
  59586. /**
  59587. * Class used to create texture to support 2D GUI elements
  59588. * @see http://doc.babylonjs.com/how_to/gui
  59589. */
  59590. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  59591. private _isDirty;
  59592. private _renderObserver;
  59593. private _resizeObserver;
  59594. private _preKeyboardObserver;
  59595. private _pointerMoveObserver;
  59596. private _pointerObserver;
  59597. private _canvasPointerOutObserver;
  59598. private _background;
  59599. /** @hidden */
  59600. _rootContainer: Container;
  59601. /** @hidden */
  59602. _lastPickedControl: Control;
  59603. /** @hidden */
  59604. _lastControlOver: {
  59605. [pointerId: number]: Control;
  59606. };
  59607. /** @hidden */
  59608. _lastControlDown: {
  59609. [pointerId: number]: Control;
  59610. };
  59611. /** @hidden */
  59612. _capturingControl: {
  59613. [pointerId: number]: Control;
  59614. };
  59615. /** @hidden */
  59616. _shouldBlockPointer: boolean;
  59617. /** @hidden */
  59618. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  59619. /** @hidden */
  59620. _linkedControls: Control[];
  59621. private _isFullscreen;
  59622. private _fullscreenViewport;
  59623. private _idealWidth;
  59624. private _idealHeight;
  59625. private _useSmallestIdeal;
  59626. private _renderAtIdealSize;
  59627. private _focusedControl;
  59628. private _blockNextFocusCheck;
  59629. private _renderScale;
  59630. private _rootCanvas;
  59631. private _cursorChanged;
  59632. /**
  59633. * Define type to string to ensure compatibility across browsers
  59634. * Safari doesn't support DataTransfer constructor
  59635. */
  59636. private _clipboardData;
  59637. /**
  59638. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  59639. */
  59640. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  59641. /**
  59642. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  59643. */
  59644. onControlPickedObservable: BABYLON.Observable<Control>;
  59645. /**
  59646. * BABYLON.Observable event triggered before layout is evaluated
  59647. */
  59648. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59649. /**
  59650. * BABYLON.Observable event triggered after the layout was evaluated
  59651. */
  59652. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59653. /**
  59654. * BABYLON.Observable event triggered before the texture is rendered
  59655. */
  59656. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59657. /**
  59658. * BABYLON.Observable event triggered after the texture was rendered
  59659. */
  59660. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59661. /**
  59662. * Gets or sets a boolean defining if alpha is stored as premultiplied
  59663. */
  59664. premulAlpha: boolean;
  59665. /**
  59666. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  59667. * Useful when you want more antialiasing
  59668. */
  59669. renderScale: number;
  59670. /** Gets or sets the background color */
  59671. background: string;
  59672. /**
  59673. * Gets or sets the ideal width used to design controls.
  59674. * The GUI will then rescale everything accordingly
  59675. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59676. */
  59677. idealWidth: number;
  59678. /**
  59679. * Gets or sets the ideal height used to design controls.
  59680. * The GUI will then rescale everything accordingly
  59681. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59682. */
  59683. idealHeight: number;
  59684. /**
  59685. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  59686. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59687. */
  59688. useSmallestIdeal: boolean;
  59689. /**
  59690. * Gets or sets a boolean indicating if adaptive scaling must be used
  59691. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59692. */
  59693. renderAtIdealSize: boolean;
  59694. /**
  59695. * Gets the underlying layer used to render the texture when in fullscreen mode
  59696. */
  59697. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  59698. /**
  59699. * Gets the root container control
  59700. */
  59701. readonly rootContainer: Container;
  59702. /**
  59703. * Returns an array containing the root container.
  59704. * This is mostly used to let the Inspector introspects the ADT
  59705. * @returns an array containing the rootContainer
  59706. */
  59707. getChildren(): Array<Container>;
  59708. /**
  59709. * Will return all controls that are inside this texture
  59710. * @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
  59711. * @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
  59712. * @return all child controls
  59713. */
  59714. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  59715. /**
  59716. * Gets or sets the current focused control
  59717. */
  59718. focusedControl: BABYLON.Nullable<IFocusableControl>;
  59719. /**
  59720. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  59721. */
  59722. isForeground: boolean;
  59723. /**
  59724. * Gets or set information about clipboardData
  59725. */
  59726. clipboardData: string;
  59727. /**
  59728. * Creates a new AdvancedDynamicTexture
  59729. * @param name defines the name of the texture
  59730. * @param width defines the width of the texture
  59731. * @param height defines the height of the texture
  59732. * @param scene defines the hosting scene
  59733. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  59734. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  59735. */
  59736. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  59737. /**
  59738. * Get the current class name of the texture useful for serialization or dynamic coding.
  59739. * @returns "AdvancedDynamicTexture"
  59740. */
  59741. getClassName(): string;
  59742. /**
  59743. * Function used to execute a function on all controls
  59744. * @param func defines the function to execute
  59745. * @param container defines the container where controls belong. If null the root container will be used
  59746. */
  59747. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  59748. private _useInvalidateRectOptimization;
  59749. /**
  59750. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  59751. */
  59752. useInvalidateRectOptimization: boolean;
  59753. private _invalidatedRectangle;
  59754. /**
  59755. * Invalidates a rectangle area on the gui texture
  59756. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  59757. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  59758. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  59759. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  59760. */
  59761. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  59762. /**
  59763. * Marks the texture as dirty forcing a complete update
  59764. */
  59765. markAsDirty(): void;
  59766. /**
  59767. * Helper function used to create a new style
  59768. * @returns a new style
  59769. * @see http://doc.babylonjs.com/how_to/gui#styles
  59770. */
  59771. createStyle(): Style;
  59772. /**
  59773. * Adds a new control to the root container
  59774. * @param control defines the control to add
  59775. * @returns the current texture
  59776. */
  59777. addControl(control: Control): AdvancedDynamicTexture;
  59778. /**
  59779. * Removes a control from the root container
  59780. * @param control defines the control to remove
  59781. * @returns the current texture
  59782. */
  59783. removeControl(control: Control): AdvancedDynamicTexture;
  59784. /**
  59785. * Release all resources
  59786. */
  59787. dispose(): void;
  59788. private _onResize;
  59789. /** @hidden */
  59790. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  59791. /**
  59792. * Get screen coordinates for a vector3
  59793. * @param position defines the position to project
  59794. * @param worldMatrix defines the world matrix to use
  59795. * @returns the projected position
  59796. */
  59797. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  59798. private _checkUpdate;
  59799. private _clearMeasure;
  59800. private _render;
  59801. /** @hidden */
  59802. _changeCursor(cursor: string): void;
  59803. /** @hidden */
  59804. _registerLastControlDown(control: Control, pointerId: number): void;
  59805. private _doPicking;
  59806. /** @hidden */
  59807. _cleanControlAfterRemovalFromList(list: {
  59808. [pointerId: number]: Control;
  59809. }, control: Control): void;
  59810. /** @hidden */
  59811. _cleanControlAfterRemoval(control: Control): void;
  59812. /** Attach to all scene events required to support pointer events */
  59813. attach(): void;
  59814. /** @hidden */
  59815. private onClipboardCopy;
  59816. /** @hidden */
  59817. private onClipboardCut;
  59818. /** @hidden */
  59819. private onClipboardPaste;
  59820. /**
  59821. * Register the clipboard Events onto the canvas
  59822. */
  59823. registerClipboardEvents(): void;
  59824. /**
  59825. * Unregister the clipboard Events from the canvas
  59826. */
  59827. unRegisterClipboardEvents(): void;
  59828. /**
  59829. * Connect the texture to a hosting mesh to enable interactions
  59830. * @param mesh defines the mesh to attach to
  59831. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  59832. */
  59833. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  59834. /**
  59835. * Move the focus to a specific control
  59836. * @param control defines the control which will receive the focus
  59837. */
  59838. moveFocusToControl(control: IFocusableControl): void;
  59839. private _manageFocus;
  59840. private _attachToOnPointerOut;
  59841. /**
  59842. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  59843. * @param mesh defines the mesh which will receive the texture
  59844. * @param width defines the texture width (1024 by default)
  59845. * @param height defines the texture height (1024 by default)
  59846. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  59847. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  59848. * @returns a new AdvancedDynamicTexture
  59849. */
  59850. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  59851. /**
  59852. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  59853. * In this mode the texture will rely on a layer for its rendering.
  59854. * This allows it to be treated like any other layer.
  59855. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  59856. * LayerMask is set through advancedTexture.layer.layerMask
  59857. * @param name defines name for the texture
  59858. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  59859. * @param scene defines the hsoting scene
  59860. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  59861. * @returns a new AdvancedDynamicTexture
  59862. */
  59863. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  59864. }
  59865. }
  59866. declare module BABYLON.GUI {
  59867. /**
  59868. * Root class used for all 2D controls
  59869. * @see http://doc.babylonjs.com/how_to/gui#controls
  59870. */
  59871. export class Control {
  59872. /** defines the name of the control */
  59873. name?: string | undefined;
  59874. /**
  59875. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  59876. */
  59877. static AllowAlphaInheritance: boolean;
  59878. private _alpha;
  59879. private _alphaSet;
  59880. private _zIndex;
  59881. /** @hidden */
  59882. _host: AdvancedDynamicTexture;
  59883. /** Gets or sets the control parent */
  59884. parent: BABYLON.Nullable<Container>;
  59885. /** @hidden */
  59886. _currentMeasure: Measure;
  59887. private _fontFamily;
  59888. private _fontStyle;
  59889. private _fontWeight;
  59890. private _fontSize;
  59891. private _font;
  59892. /** @hidden */
  59893. _width: ValueAndUnit;
  59894. /** @hidden */
  59895. _height: ValueAndUnit;
  59896. /** @hidden */
  59897. protected _fontOffset: {
  59898. ascent: number;
  59899. height: number;
  59900. descent: number;
  59901. };
  59902. private _color;
  59903. private _style;
  59904. private _styleObserver;
  59905. /** @hidden */
  59906. protected _horizontalAlignment: number;
  59907. /** @hidden */
  59908. protected _verticalAlignment: number;
  59909. /** @hidden */
  59910. protected _isDirty: boolean;
  59911. /** @hidden */
  59912. protected _wasDirty: boolean;
  59913. /** @hidden */
  59914. _tempParentMeasure: Measure;
  59915. /** @hidden */
  59916. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  59917. /** @hidden */
  59918. protected _cachedParentMeasure: Measure;
  59919. private _paddingLeft;
  59920. private _paddingRight;
  59921. private _paddingTop;
  59922. private _paddingBottom;
  59923. /** @hidden */
  59924. _left: ValueAndUnit;
  59925. /** @hidden */
  59926. _top: ValueAndUnit;
  59927. private _scaleX;
  59928. private _scaleY;
  59929. private _rotation;
  59930. private _transformCenterX;
  59931. private _transformCenterY;
  59932. /** @hidden */
  59933. _transformMatrix: Matrix2D;
  59934. /** @hidden */
  59935. protected _invertTransformMatrix: Matrix2D;
  59936. /** @hidden */
  59937. protected _transformedPosition: BABYLON.Vector2;
  59938. private _isMatrixDirty;
  59939. private _cachedOffsetX;
  59940. private _cachedOffsetY;
  59941. private _isVisible;
  59942. private _isHighlighted;
  59943. /** @hidden */
  59944. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  59945. private _fontSet;
  59946. private _dummyVector2;
  59947. private _downCount;
  59948. private _enterCount;
  59949. private _doNotRender;
  59950. private _downPointerIds;
  59951. protected _isEnabled: boolean;
  59952. protected _disabledColor: string;
  59953. /** @hidden */
  59954. protected _rebuildLayout: boolean;
  59955. /** @hidden */
  59956. _isClipped: boolean;
  59957. /** @hidden */
  59958. _tag: any;
  59959. /**
  59960. * 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
  59961. */
  59962. uniqueId: number;
  59963. /**
  59964. * Gets or sets an object used to store user defined information for the node
  59965. */
  59966. metadata: any;
  59967. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  59968. isHitTestVisible: boolean;
  59969. /** Gets or sets a boolean indicating if the control can block pointer events */
  59970. isPointerBlocker: boolean;
  59971. /** Gets or sets a boolean indicating if the control can be focusable */
  59972. isFocusInvisible: boolean;
  59973. /**
  59974. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  59975. * 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
  59976. */
  59977. clipChildren: boolean;
  59978. /**
  59979. * Gets or sets a boolean indicating that control content must be clipped
  59980. * 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
  59981. */
  59982. clipContent: boolean;
  59983. /**
  59984. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  59985. */
  59986. useBitmapCache: boolean;
  59987. private _cacheData;
  59988. private _shadowOffsetX;
  59989. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  59990. shadowOffsetX: number;
  59991. private _shadowOffsetY;
  59992. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  59993. shadowOffsetY: number;
  59994. private _shadowBlur;
  59995. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  59996. shadowBlur: number;
  59997. private _shadowColor;
  59998. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  59999. shadowColor: string;
  60000. /** Gets or sets the cursor to use when the control is hovered */
  60001. hoverCursor: string;
  60002. /** @hidden */
  60003. protected _linkOffsetX: ValueAndUnit;
  60004. /** @hidden */
  60005. protected _linkOffsetY: ValueAndUnit;
  60006. /** Gets the control type name */
  60007. readonly typeName: string;
  60008. /**
  60009. * Get the current class name of the control.
  60010. * @returns current class name
  60011. */
  60012. getClassName(): string;
  60013. /**
  60014. * An event triggered when the pointer move over the control.
  60015. */
  60016. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  60017. /**
  60018. * An event triggered when the pointer move out of the control.
  60019. */
  60020. onPointerOutObservable: BABYLON.Observable<Control>;
  60021. /**
  60022. * An event triggered when the pointer taps the control
  60023. */
  60024. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  60025. /**
  60026. * An event triggered when pointer up
  60027. */
  60028. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  60029. /**
  60030. * An event triggered when a control is clicked on
  60031. */
  60032. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  60033. /**
  60034. * An event triggered when pointer enters the control
  60035. */
  60036. onPointerEnterObservable: BABYLON.Observable<Control>;
  60037. /**
  60038. * An event triggered when the control is marked as dirty
  60039. */
  60040. onDirtyObservable: BABYLON.Observable<Control>;
  60041. /**
  60042. * An event triggered before drawing the control
  60043. */
  60044. onBeforeDrawObservable: BABYLON.Observable<Control>;
  60045. /**
  60046. * An event triggered after the control was drawn
  60047. */
  60048. onAfterDrawObservable: BABYLON.Observable<Control>;
  60049. /**
  60050. * Get the hosting AdvancedDynamicTexture
  60051. */
  60052. readonly host: AdvancedDynamicTexture;
  60053. /** Gets or set information about font offsets (used to render and align text) */
  60054. fontOffset: {
  60055. ascent: number;
  60056. height: number;
  60057. descent: number;
  60058. };
  60059. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  60060. alpha: number;
  60061. /**
  60062. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  60063. */
  60064. isHighlighted: boolean;
  60065. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  60066. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60067. */
  60068. scaleX: number;
  60069. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  60070. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60071. */
  60072. scaleY: number;
  60073. /** Gets or sets the rotation angle (0 by default)
  60074. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60075. */
  60076. rotation: number;
  60077. /** Gets or sets the transformation center on Y axis (0 by default)
  60078. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60079. */
  60080. transformCenterY: number;
  60081. /** Gets or sets the transformation center on X axis (0 by default)
  60082. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60083. */
  60084. transformCenterX: number;
  60085. /**
  60086. * Gets or sets the horizontal alignment
  60087. * @see http://doc.babylonjs.com/how_to/gui#alignments
  60088. */
  60089. horizontalAlignment: number;
  60090. /**
  60091. * Gets or sets the vertical alignment
  60092. * @see http://doc.babylonjs.com/how_to/gui#alignments
  60093. */
  60094. verticalAlignment: number;
  60095. /**
  60096. * Gets or sets control width
  60097. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60098. */
  60099. width: string | number;
  60100. /**
  60101. * Gets or sets the control width in pixel
  60102. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60103. */
  60104. widthInPixels: number;
  60105. /**
  60106. * Gets or sets control height
  60107. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60108. */
  60109. height: string | number;
  60110. /**
  60111. * Gets or sets control height in pixel
  60112. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60113. */
  60114. heightInPixels: number;
  60115. /** Gets or set font family */
  60116. fontFamily: string;
  60117. /** Gets or sets font style */
  60118. fontStyle: string;
  60119. /** Gets or sets font weight */
  60120. fontWeight: string;
  60121. /**
  60122. * Gets or sets style
  60123. * @see http://doc.babylonjs.com/how_to/gui#styles
  60124. */
  60125. style: BABYLON.Nullable<Style>;
  60126. /** @hidden */
  60127. readonly _isFontSizeInPercentage: boolean;
  60128. /** Gets or sets font size in pixels */
  60129. fontSizeInPixels: number;
  60130. /** Gets or sets font size */
  60131. fontSize: string | number;
  60132. /** Gets or sets foreground color */
  60133. color: string;
  60134. /** Gets or sets z index which is used to reorder controls on the z axis */
  60135. zIndex: number;
  60136. /** Gets or sets a boolean indicating if the control can be rendered */
  60137. notRenderable: boolean;
  60138. /** Gets or sets a boolean indicating if the control is visible */
  60139. isVisible: boolean;
  60140. /** Gets a boolean indicating that the control needs to update its rendering */
  60141. readonly isDirty: boolean;
  60142. /**
  60143. * Gets the current linked mesh (or null if none)
  60144. */
  60145. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  60146. /**
  60147. * Gets or sets a value indicating the padding to use on the left of the control
  60148. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60149. */
  60150. paddingLeft: string | number;
  60151. /**
  60152. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  60153. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60154. */
  60155. paddingLeftInPixels: number;
  60156. /**
  60157. * Gets or sets a value indicating the padding to use on the right of the control
  60158. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60159. */
  60160. paddingRight: string | number;
  60161. /**
  60162. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  60163. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60164. */
  60165. paddingRightInPixels: number;
  60166. /**
  60167. * Gets or sets a value indicating the padding to use on the top of the control
  60168. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60169. */
  60170. paddingTop: string | number;
  60171. /**
  60172. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  60173. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60174. */
  60175. paddingTopInPixels: number;
  60176. /**
  60177. * Gets or sets a value indicating the padding to use on the bottom of the control
  60178. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60179. */
  60180. paddingBottom: string | number;
  60181. /**
  60182. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  60183. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60184. */
  60185. paddingBottomInPixels: number;
  60186. /**
  60187. * Gets or sets a value indicating the left coordinate of the control
  60188. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60189. */
  60190. left: string | number;
  60191. /**
  60192. * Gets or sets a value indicating the left coordinate in pixels of the control
  60193. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60194. */
  60195. leftInPixels: number;
  60196. /**
  60197. * Gets or sets a value indicating the top coordinate of the control
  60198. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60199. */
  60200. top: string | number;
  60201. /**
  60202. * Gets or sets a value indicating the top coordinate in pixels of the control
  60203. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60204. */
  60205. topInPixels: number;
  60206. /**
  60207. * Gets or sets a value indicating the offset on X axis to the linked mesh
  60208. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60209. */
  60210. linkOffsetX: string | number;
  60211. /**
  60212. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  60213. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60214. */
  60215. linkOffsetXInPixels: number;
  60216. /**
  60217. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  60218. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60219. */
  60220. linkOffsetY: string | number;
  60221. /**
  60222. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  60223. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60224. */
  60225. linkOffsetYInPixels: number;
  60226. /** Gets the center coordinate on X axis */
  60227. readonly centerX: number;
  60228. /** Gets the center coordinate on Y axis */
  60229. readonly centerY: number;
  60230. /** Gets or sets if control is Enabled*/
  60231. isEnabled: boolean;
  60232. /** Gets or sets background color of control if it's disabled*/
  60233. disabledColor: string;
  60234. /**
  60235. * Creates a new control
  60236. * @param name defines the name of the control
  60237. */
  60238. constructor(
  60239. /** defines the name of the control */
  60240. name?: string | undefined);
  60241. /** @hidden */
  60242. protected _getTypeName(): string;
  60243. /**
  60244. * Gets the first ascendant in the hierarchy of the given type
  60245. * @param className defines the required type
  60246. * @returns the ascendant or null if not found
  60247. */
  60248. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  60249. /** @hidden */
  60250. _resetFontCache(): void;
  60251. /**
  60252. * Determines if a container is an ascendant of the current control
  60253. * @param container defines the container to look for
  60254. * @returns true if the container is one of the ascendant of the control
  60255. */
  60256. isAscendant(container: Control): boolean;
  60257. /**
  60258. * Gets coordinates in local control space
  60259. * @param globalCoordinates defines the coordinates to transform
  60260. * @returns the new coordinates in local space
  60261. */
  60262. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  60263. /**
  60264. * Gets coordinates in local control space
  60265. * @param globalCoordinates defines the coordinates to transform
  60266. * @param result defines the target vector2 where to store the result
  60267. * @returns the current control
  60268. */
  60269. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  60270. /**
  60271. * Gets coordinates in parent local control space
  60272. * @param globalCoordinates defines the coordinates to transform
  60273. * @returns the new coordinates in parent local space
  60274. */
  60275. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  60276. /**
  60277. * Move the current control to a vector3 position projected onto the screen.
  60278. * @param position defines the target position
  60279. * @param scene defines the hosting scene
  60280. */
  60281. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  60282. /** @hidden */
  60283. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  60284. /**
  60285. * Will return all controls that have this control as ascendant
  60286. * @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
  60287. * @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
  60288. * @return all child controls
  60289. */
  60290. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  60291. /**
  60292. * Link current control with a target mesh
  60293. * @param mesh defines the mesh to link with
  60294. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60295. */
  60296. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  60297. /** @hidden */
  60298. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  60299. /** @hidden */
  60300. _offsetLeft(offset: number): void;
  60301. /** @hidden */
  60302. _offsetTop(offset: number): void;
  60303. /** @hidden */
  60304. _markMatrixAsDirty(): void;
  60305. /** @hidden */
  60306. _flagDescendantsAsMatrixDirty(): void;
  60307. /** @hidden */
  60308. _intersectsRect(rect: Measure): boolean;
  60309. /** @hidden */
  60310. protected invalidateRect(): void;
  60311. /** @hidden */
  60312. _markAsDirty(force?: boolean): void;
  60313. /** @hidden */
  60314. _markAllAsDirty(): void;
  60315. /** @hidden */
  60316. _link(host: AdvancedDynamicTexture): void;
  60317. /** @hidden */
  60318. protected _transform(context?: CanvasRenderingContext2D): void;
  60319. /** @hidden */
  60320. _renderHighlight(context: CanvasRenderingContext2D): void;
  60321. /** @hidden */
  60322. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  60323. /** @hidden */
  60324. protected _applyStates(context: CanvasRenderingContext2D): void;
  60325. /** @hidden */
  60326. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  60327. /** @hidden */
  60328. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60329. protected _evaluateClippingState(parentMeasure: Measure): void;
  60330. /** @hidden */
  60331. _measure(): void;
  60332. /** @hidden */
  60333. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60334. /** @hidden */
  60335. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60336. /** @hidden */
  60337. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60338. /** @hidden */
  60339. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60340. private static _ClipMeasure;
  60341. private _tmpMeasureA;
  60342. private _clip;
  60343. /** @hidden */
  60344. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  60345. /** @hidden */
  60346. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  60347. /**
  60348. * Tests if a given coordinates belong to the current control
  60349. * @param x defines x coordinate to test
  60350. * @param y defines y coordinate to test
  60351. * @returns true if the coordinates are inside the control
  60352. */
  60353. contains(x: number, y: number): boolean;
  60354. /** @hidden */
  60355. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60356. /** @hidden */
  60357. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  60358. /** @hidden */
  60359. _onPointerEnter(target: Control): boolean;
  60360. /** @hidden */
  60361. _onPointerOut(target: Control, force?: boolean): void;
  60362. /** @hidden */
  60363. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60364. /** @hidden */
  60365. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60366. /** @hidden */
  60367. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  60368. /** @hidden */
  60369. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  60370. private _prepareFont;
  60371. /** Releases associated resources */
  60372. dispose(): void;
  60373. private static _HORIZONTAL_ALIGNMENT_LEFT;
  60374. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  60375. private static _HORIZONTAL_ALIGNMENT_CENTER;
  60376. private static _VERTICAL_ALIGNMENT_TOP;
  60377. private static _VERTICAL_ALIGNMENT_BOTTOM;
  60378. private static _VERTICAL_ALIGNMENT_CENTER;
  60379. /** HORIZONTAL_ALIGNMENT_LEFT */
  60380. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  60381. /** HORIZONTAL_ALIGNMENT_RIGHT */
  60382. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  60383. /** HORIZONTAL_ALIGNMENT_CENTER */
  60384. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  60385. /** VERTICAL_ALIGNMENT_TOP */
  60386. static readonly VERTICAL_ALIGNMENT_TOP: number;
  60387. /** VERTICAL_ALIGNMENT_BOTTOM */
  60388. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  60389. /** VERTICAL_ALIGNMENT_CENTER */
  60390. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  60391. private static _FontHeightSizes;
  60392. /** @hidden */
  60393. static _GetFontOffset(font: string): {
  60394. ascent: number;
  60395. height: number;
  60396. descent: number;
  60397. };
  60398. /**
  60399. * Creates a stack panel that can be used to render headers
  60400. * @param control defines the control to associate with the header
  60401. * @param text defines the text of the header
  60402. * @param size defines the size of the header
  60403. * @param options defines options used to configure the header
  60404. * @returns a new StackPanel
  60405. * @ignore
  60406. * @hidden
  60407. */
  60408. static AddHeader: (control: Control, text: string, size: string | number, options: {
  60409. isHorizontal: boolean;
  60410. controlFirst: boolean;
  60411. }) => any;
  60412. /** @hidden */
  60413. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  60414. }
  60415. }
  60416. declare module BABYLON.GUI {
  60417. /**
  60418. * Root class for 2D containers
  60419. * @see http://doc.babylonjs.com/how_to/gui#containers
  60420. */
  60421. export class Container extends Control {
  60422. name?: string | undefined;
  60423. /** @hidden */
  60424. protected _children: Control[];
  60425. /** @hidden */
  60426. protected _measureForChildren: Measure;
  60427. /** @hidden */
  60428. protected _background: string;
  60429. /** @hidden */
  60430. protected _adaptWidthToChildren: boolean;
  60431. /** @hidden */
  60432. protected _adaptHeightToChildren: boolean;
  60433. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  60434. adaptHeightToChildren: boolean;
  60435. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  60436. adaptWidthToChildren: boolean;
  60437. /** Gets or sets background color */
  60438. background: string;
  60439. /** Gets the list of children */
  60440. readonly children: Control[];
  60441. /**
  60442. * Creates a new Container
  60443. * @param name defines the name of the container
  60444. */
  60445. constructor(name?: string | undefined);
  60446. protected _getTypeName(): string;
  60447. _flagDescendantsAsMatrixDirty(): void;
  60448. /**
  60449. * Gets a child using its name
  60450. * @param name defines the child name to look for
  60451. * @returns the child control if found
  60452. */
  60453. getChildByName(name: string): BABYLON.Nullable<Control>;
  60454. /**
  60455. * Gets a child using its type and its name
  60456. * @param name defines the child name to look for
  60457. * @param type defines the child type to look for
  60458. * @returns the child control if found
  60459. */
  60460. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  60461. /**
  60462. * Search for a specific control in children
  60463. * @param control defines the control to look for
  60464. * @returns true if the control is in child list
  60465. */
  60466. containsControl(control: Control): boolean;
  60467. /**
  60468. * Adds a new control to the current container
  60469. * @param control defines the control to add
  60470. * @returns the current container
  60471. */
  60472. addControl(control: BABYLON.Nullable<Control>): Container;
  60473. /**
  60474. * Removes all controls from the current container
  60475. * @returns the current container
  60476. */
  60477. clearControls(): Container;
  60478. /**
  60479. * Removes a control from the current container
  60480. * @param control defines the control to remove
  60481. * @returns the current container
  60482. */
  60483. removeControl(control: Control): Container;
  60484. /** @hidden */
  60485. _reOrderControl(control: Control): void;
  60486. /** @hidden */
  60487. _offsetLeft(offset: number): void;
  60488. /** @hidden */
  60489. _offsetTop(offset: number): void;
  60490. /** @hidden */
  60491. _markAllAsDirty(): void;
  60492. /** @hidden */
  60493. protected _localDraw(context: CanvasRenderingContext2D): void;
  60494. /** @hidden */
  60495. _link(host: AdvancedDynamicTexture): void;
  60496. /** @hidden */
  60497. protected _beforeLayout(): void;
  60498. /** @hidden */
  60499. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60500. /** @hidden */
  60501. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  60502. protected _postMeasure(): void;
  60503. /** @hidden */
  60504. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  60505. /** @hidden */
  60506. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  60507. /** @hidden */
  60508. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60509. /** @hidden */
  60510. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60511. /** Releases associated resources */
  60512. dispose(): void;
  60513. }
  60514. }
  60515. declare module BABYLON.GUI {
  60516. /** Class used to create rectangle container */
  60517. export class Rectangle extends Container {
  60518. name?: string | undefined;
  60519. private _thickness;
  60520. private _cornerRadius;
  60521. /** Gets or sets border thickness */
  60522. thickness: number;
  60523. /** Gets or sets the corner radius angle */
  60524. cornerRadius: number;
  60525. /**
  60526. * Creates a new Rectangle
  60527. * @param name defines the control name
  60528. */
  60529. constructor(name?: string | undefined);
  60530. protected _getTypeName(): string;
  60531. protected _localDraw(context: CanvasRenderingContext2D): void;
  60532. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60533. private _drawRoundedRect;
  60534. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60535. }
  60536. }
  60537. declare module BABYLON.GUI {
  60538. /**
  60539. * Enum that determines the text-wrapping mode to use.
  60540. */
  60541. export enum TextWrapping {
  60542. /**
  60543. * Clip the text when it's larger than Control.width; this is the default mode.
  60544. */
  60545. Clip = 0,
  60546. /**
  60547. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  60548. */
  60549. WordWrap = 1,
  60550. /**
  60551. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  60552. */
  60553. Ellipsis = 2
  60554. }
  60555. /**
  60556. * Class used to create text block control
  60557. */
  60558. export class TextBlock extends Control {
  60559. /**
  60560. * Defines the name of the control
  60561. */
  60562. name?: string | undefined;
  60563. private _text;
  60564. private _textWrapping;
  60565. private _textHorizontalAlignment;
  60566. private _textVerticalAlignment;
  60567. private _lines;
  60568. private _resizeToFit;
  60569. private _lineSpacing;
  60570. private _outlineWidth;
  60571. private _outlineColor;
  60572. /**
  60573. * An event triggered after the text is changed
  60574. */
  60575. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  60576. /**
  60577. * An event triggered after the text was broken up into lines
  60578. */
  60579. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  60580. /**
  60581. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  60582. */
  60583. readonly lines: any[];
  60584. /**
  60585. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  60586. */
  60587. /**
  60588. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  60589. */
  60590. resizeToFit: boolean;
  60591. /**
  60592. * Gets or sets a boolean indicating if text must be wrapped
  60593. */
  60594. /**
  60595. * Gets or sets a boolean indicating if text must be wrapped
  60596. */
  60597. textWrapping: TextWrapping | boolean;
  60598. /**
  60599. * Gets or sets text to display
  60600. */
  60601. /**
  60602. * Gets or sets text to display
  60603. */
  60604. text: string;
  60605. /**
  60606. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  60607. */
  60608. /**
  60609. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  60610. */
  60611. textHorizontalAlignment: number;
  60612. /**
  60613. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  60614. */
  60615. /**
  60616. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  60617. */
  60618. textVerticalAlignment: number;
  60619. /**
  60620. * Gets or sets line spacing value
  60621. */
  60622. /**
  60623. * Gets or sets line spacing value
  60624. */
  60625. lineSpacing: string | number;
  60626. /**
  60627. * Gets or sets outlineWidth of the text to display
  60628. */
  60629. /**
  60630. * Gets or sets outlineWidth of the text to display
  60631. */
  60632. outlineWidth: number;
  60633. /**
  60634. * Gets or sets outlineColor of the text to display
  60635. */
  60636. /**
  60637. * Gets or sets outlineColor of the text to display
  60638. */
  60639. outlineColor: string;
  60640. /**
  60641. * Creates a new TextBlock object
  60642. * @param name defines the name of the control
  60643. * @param text defines the text to display (emptry string by default)
  60644. */
  60645. constructor(
  60646. /**
  60647. * Defines the name of the control
  60648. */
  60649. name?: string | undefined, text?: string);
  60650. protected _getTypeName(): string;
  60651. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60652. private _drawText;
  60653. /** @hidden */
  60654. _draw(context: CanvasRenderingContext2D): void;
  60655. protected _applyStates(context: CanvasRenderingContext2D): void;
  60656. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  60657. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  60658. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  60659. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  60660. protected _renderLines(context: CanvasRenderingContext2D): void;
  60661. /**
  60662. * Given a width constraint applied on the text block, find the expected height
  60663. * @returns expected height
  60664. */
  60665. computeExpectedHeight(): number;
  60666. dispose(): void;
  60667. }
  60668. }
  60669. declare module BABYLON.GUI {
  60670. /**
  60671. * Class used to create 2D images
  60672. */
  60673. export class Image extends Control {
  60674. name?: string | undefined;
  60675. private static _WorkingCanvas;
  60676. private _domImage;
  60677. private _imageWidth;
  60678. private _imageHeight;
  60679. private _loaded;
  60680. private _stretch;
  60681. private _source;
  60682. private _autoScale;
  60683. private _sourceLeft;
  60684. private _sourceTop;
  60685. private _sourceWidth;
  60686. private _sourceHeight;
  60687. private _cellWidth;
  60688. private _cellHeight;
  60689. private _cellId;
  60690. private _populateNinePatchSlicesFromImage;
  60691. private _sliceLeft;
  60692. private _sliceRight;
  60693. private _sliceTop;
  60694. private _sliceBottom;
  60695. private _detectPointerOnOpaqueOnly;
  60696. /**
  60697. * BABYLON.Observable notified when the content is loaded
  60698. */
  60699. onImageLoadedObservable: BABYLON.Observable<Image>;
  60700. /**
  60701. * Gets a boolean indicating that the content is loaded
  60702. */
  60703. readonly isLoaded: boolean;
  60704. /**
  60705. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  60706. */
  60707. populateNinePatchSlicesFromImage: boolean;
  60708. /**
  60709. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  60710. * Beware using this as this will comsume more memory as the image has to be stored twice
  60711. */
  60712. detectPointerOnOpaqueOnly: boolean;
  60713. /**
  60714. * Gets or sets the left value for slicing (9-patch)
  60715. */
  60716. sliceLeft: number;
  60717. /**
  60718. * Gets or sets the right value for slicing (9-patch)
  60719. */
  60720. sliceRight: number;
  60721. /**
  60722. * Gets or sets the top value for slicing (9-patch)
  60723. */
  60724. sliceTop: number;
  60725. /**
  60726. * Gets or sets the bottom value for slicing (9-patch)
  60727. */
  60728. sliceBottom: number;
  60729. /**
  60730. * Gets or sets the left coordinate in the source image
  60731. */
  60732. sourceLeft: number;
  60733. /**
  60734. * Gets or sets the top coordinate in the source image
  60735. */
  60736. sourceTop: number;
  60737. /**
  60738. * Gets or sets the width to capture in the source image
  60739. */
  60740. sourceWidth: number;
  60741. /**
  60742. * Gets or sets the height to capture in the source image
  60743. */
  60744. sourceHeight: number;
  60745. /**
  60746. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  60747. * @see http://doc.babylonjs.com/how_to/gui#image
  60748. */
  60749. autoScale: boolean;
  60750. /** Gets or sets the streching mode used by the image */
  60751. stretch: number;
  60752. /**
  60753. * Gets or sets the internal DOM image used to render the control
  60754. */
  60755. domImage: HTMLImageElement;
  60756. private _onImageLoaded;
  60757. private _extractNinePatchSliceDataFromImage;
  60758. /**
  60759. * Gets or sets image source url
  60760. */
  60761. source: BABYLON.Nullable<string>;
  60762. /**
  60763. * Gets or sets the cell width to use when animation sheet is enabled
  60764. * @see http://doc.babylonjs.com/how_to/gui#image
  60765. */
  60766. cellWidth: number;
  60767. /**
  60768. * Gets or sets the cell height to use when animation sheet is enabled
  60769. * @see http://doc.babylonjs.com/how_to/gui#image
  60770. */
  60771. cellHeight: number;
  60772. /**
  60773. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  60774. * @see http://doc.babylonjs.com/how_to/gui#image
  60775. */
  60776. cellId: number;
  60777. /**
  60778. * Creates a new Image
  60779. * @param name defines the control name
  60780. * @param url defines the image url
  60781. */
  60782. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  60783. /**
  60784. * Tests if a given coordinates belong to the current control
  60785. * @param x defines x coordinate to test
  60786. * @param y defines y coordinate to test
  60787. * @returns true if the coordinates are inside the control
  60788. */
  60789. contains(x: number, y: number): boolean;
  60790. protected _getTypeName(): string;
  60791. /** Force the control to synchronize with its content */
  60792. synchronizeSizeWithContent(): void;
  60793. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60794. private _prepareWorkingCanvasForOpaqueDetection;
  60795. private _drawImage;
  60796. _draw(context: CanvasRenderingContext2D): void;
  60797. private _renderCornerPatch;
  60798. private _renderNinePatch;
  60799. dispose(): void;
  60800. /** STRETCH_NONE */
  60801. static readonly STRETCH_NONE: number;
  60802. /** STRETCH_FILL */
  60803. static readonly STRETCH_FILL: number;
  60804. /** STRETCH_UNIFORM */
  60805. static readonly STRETCH_UNIFORM: number;
  60806. /** STRETCH_EXTEND */
  60807. static readonly STRETCH_EXTEND: number;
  60808. /** NINE_PATCH */
  60809. static readonly STRETCH_NINE_PATCH: number;
  60810. }
  60811. }
  60812. declare module BABYLON.GUI {
  60813. /**
  60814. * Class used to create 2D buttons
  60815. */
  60816. export class Button extends Rectangle {
  60817. name?: string | undefined;
  60818. /**
  60819. * Function called to generate a pointer enter animation
  60820. */
  60821. pointerEnterAnimation: () => void;
  60822. /**
  60823. * Function called to generate a pointer out animation
  60824. */
  60825. pointerOutAnimation: () => void;
  60826. /**
  60827. * Function called to generate a pointer down animation
  60828. */
  60829. pointerDownAnimation: () => void;
  60830. /**
  60831. * Function called to generate a pointer up animation
  60832. */
  60833. pointerUpAnimation: () => void;
  60834. private _image;
  60835. /**
  60836. * Returns the image part of the button (if any)
  60837. */
  60838. readonly image: BABYLON.Nullable<Image>;
  60839. private _textBlock;
  60840. /**
  60841. * Returns the image part of the button (if any)
  60842. */
  60843. readonly textBlock: BABYLON.Nullable<TextBlock>;
  60844. /**
  60845. * Creates a new Button
  60846. * @param name defines the name of the button
  60847. */
  60848. constructor(name?: string | undefined);
  60849. protected _getTypeName(): string;
  60850. /** @hidden */
  60851. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60852. /** @hidden */
  60853. _onPointerEnter(target: Control): boolean;
  60854. /** @hidden */
  60855. _onPointerOut(target: Control, force?: boolean): void;
  60856. /** @hidden */
  60857. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60858. /** @hidden */
  60859. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60860. /**
  60861. * Creates a new button made with an image and a text
  60862. * @param name defines the name of the button
  60863. * @param text defines the text of the button
  60864. * @param imageUrl defines the url of the image
  60865. * @returns a new Button
  60866. */
  60867. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  60868. /**
  60869. * Creates a new button made with an image
  60870. * @param name defines the name of the button
  60871. * @param imageUrl defines the url of the image
  60872. * @returns a new Button
  60873. */
  60874. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  60875. /**
  60876. * Creates a new button made with a text
  60877. * @param name defines the name of the button
  60878. * @param text defines the text of the button
  60879. * @returns a new Button
  60880. */
  60881. static CreateSimpleButton(name: string, text: string): Button;
  60882. /**
  60883. * Creates a new button made with an image and a centered text
  60884. * @param name defines the name of the button
  60885. * @param text defines the text of the button
  60886. * @param imageUrl defines the url of the image
  60887. * @returns a new Button
  60888. */
  60889. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  60890. }
  60891. }
  60892. declare module BABYLON.GUI {
  60893. /**
  60894. * Class used to create a 2D stack panel container
  60895. */
  60896. export class StackPanel extends Container {
  60897. name?: string | undefined;
  60898. private _isVertical;
  60899. private _manualWidth;
  60900. private _manualHeight;
  60901. private _doNotTrackManualChanges;
  60902. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  60903. isVertical: boolean;
  60904. /**
  60905. * Gets or sets panel width.
  60906. * This value should not be set when in horizontal mode as it will be computed automatically
  60907. */
  60908. width: string | number;
  60909. /**
  60910. * Gets or sets panel height.
  60911. * This value should not be set when in vertical mode as it will be computed automatically
  60912. */
  60913. height: string | number;
  60914. /**
  60915. * Creates a new StackPanel
  60916. * @param name defines control name
  60917. */
  60918. constructor(name?: string | undefined);
  60919. protected _getTypeName(): string;
  60920. /** @hidden */
  60921. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60922. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60923. protected _postMeasure(): void;
  60924. }
  60925. }
  60926. declare module BABYLON.GUI {
  60927. /**
  60928. * Class used to represent a 2D checkbox
  60929. */
  60930. export class Checkbox extends Control {
  60931. name?: string | undefined;
  60932. private _isChecked;
  60933. private _background;
  60934. private _checkSizeRatio;
  60935. private _thickness;
  60936. /** Gets or sets border thickness */
  60937. thickness: number;
  60938. /**
  60939. * BABYLON.Observable raised when isChecked property changes
  60940. */
  60941. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  60942. /** Gets or sets a value indicating the ratio between overall size and check size */
  60943. checkSizeRatio: number;
  60944. /** Gets or sets background color */
  60945. background: string;
  60946. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  60947. isChecked: boolean;
  60948. /**
  60949. * Creates a new CheckBox
  60950. * @param name defines the control name
  60951. */
  60952. constructor(name?: string | undefined);
  60953. protected _getTypeName(): string;
  60954. /** @hidden */
  60955. _draw(context: CanvasRenderingContext2D): void;
  60956. /** @hidden */
  60957. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60958. /**
  60959. * Utility function to easily create a checkbox with a header
  60960. * @param title defines the label to use for the header
  60961. * @param onValueChanged defines the callback to call when value changes
  60962. * @returns a StackPanel containing the checkbox and a textBlock
  60963. */
  60964. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  60965. }
  60966. }
  60967. declare module BABYLON.GUI {
  60968. /**
  60969. * Class used to store key control properties
  60970. */
  60971. export class KeyPropertySet {
  60972. /** Width */
  60973. width?: string;
  60974. /** Height */
  60975. height?: string;
  60976. /** Left padding */
  60977. paddingLeft?: string;
  60978. /** Right padding */
  60979. paddingRight?: string;
  60980. /** Top padding */
  60981. paddingTop?: string;
  60982. /** Bottom padding */
  60983. paddingBottom?: string;
  60984. /** Foreground color */
  60985. color?: string;
  60986. /** Background color */
  60987. background?: string;
  60988. }
  60989. /**
  60990. * Class used to create virtual keyboard
  60991. */
  60992. export class VirtualKeyboard extends StackPanel {
  60993. /** BABYLON.Observable raised when a key is pressed */
  60994. onKeyPressObservable: BABYLON.Observable<string>;
  60995. /** Gets or sets default key button width */
  60996. defaultButtonWidth: string;
  60997. /** Gets or sets default key button height */
  60998. defaultButtonHeight: string;
  60999. /** Gets or sets default key button left padding */
  61000. defaultButtonPaddingLeft: string;
  61001. /** Gets or sets default key button right padding */
  61002. defaultButtonPaddingRight: string;
  61003. /** Gets or sets default key button top padding */
  61004. defaultButtonPaddingTop: string;
  61005. /** Gets or sets default key button bottom padding */
  61006. defaultButtonPaddingBottom: string;
  61007. /** Gets or sets default key button foreground color */
  61008. defaultButtonColor: string;
  61009. /** Gets or sets default key button background color */
  61010. defaultButtonBackground: string;
  61011. /** Gets or sets shift button foreground color */
  61012. shiftButtonColor: string;
  61013. /** Gets or sets shift button thickness*/
  61014. selectedShiftThickness: number;
  61015. /** Gets shift key state */
  61016. shiftState: number;
  61017. protected _getTypeName(): string;
  61018. private _createKey;
  61019. /**
  61020. * Adds a new row of keys
  61021. * @param keys defines the list of keys to add
  61022. * @param propertySets defines the associated property sets
  61023. */
  61024. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  61025. /**
  61026. * Set the shift key to a specific state
  61027. * @param shiftState defines the new shift state
  61028. */
  61029. applyShiftState(shiftState: number): void;
  61030. private _currentlyConnectedInputText;
  61031. private _connectedInputTexts;
  61032. private _onKeyPressObserver;
  61033. /** Gets the input text control currently attached to the keyboard */
  61034. readonly connectedInputText: BABYLON.Nullable<InputText>;
  61035. /**
  61036. * Connects the keyboard with an input text control
  61037. *
  61038. * @param input defines the target control
  61039. */
  61040. connect(input: InputText): void;
  61041. /**
  61042. * Disconnects the keyboard from connected InputText controls
  61043. *
  61044. * @param input optionally defines a target control, otherwise all are disconnected
  61045. */
  61046. disconnect(input?: InputText): void;
  61047. private _removeConnectedInputObservables;
  61048. /**
  61049. * Release all resources
  61050. */
  61051. dispose(): void;
  61052. /**
  61053. * Creates a new keyboard using a default layout
  61054. *
  61055. * @param name defines control name
  61056. * @returns a new VirtualKeyboard
  61057. */
  61058. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  61059. }
  61060. }
  61061. declare module BABYLON.GUI {
  61062. /**
  61063. * Class used to create input text control
  61064. */
  61065. export class InputText extends Control implements IFocusableControl {
  61066. name?: string | undefined;
  61067. private _text;
  61068. private _placeholderText;
  61069. private _background;
  61070. private _focusedBackground;
  61071. private _focusedColor;
  61072. private _placeholderColor;
  61073. private _thickness;
  61074. private _margin;
  61075. private _autoStretchWidth;
  61076. private _maxWidth;
  61077. private _isFocused;
  61078. private _blinkTimeout;
  61079. private _blinkIsEven;
  61080. private _cursorOffset;
  61081. private _scrollLeft;
  61082. private _textWidth;
  61083. private _clickedCoordinate;
  61084. private _deadKey;
  61085. private _addKey;
  61086. private _currentKey;
  61087. private _isTextHighlightOn;
  61088. private _textHighlightColor;
  61089. private _highligherOpacity;
  61090. private _highlightedText;
  61091. private _startHighlightIndex;
  61092. private _endHighlightIndex;
  61093. private _cursorIndex;
  61094. private _onFocusSelectAll;
  61095. private _isPointerDown;
  61096. private _onClipboardObserver;
  61097. private _onPointerDblTapObserver;
  61098. /** @hidden */
  61099. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  61100. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  61101. promptMessage: string;
  61102. /** BABYLON.Observable raised when the text changes */
  61103. onTextChangedObservable: BABYLON.Observable<InputText>;
  61104. /** BABYLON.Observable raised just before an entered character is to be added */
  61105. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  61106. /** BABYLON.Observable raised when the control gets the focus */
  61107. onFocusObservable: BABYLON.Observable<InputText>;
  61108. /** BABYLON.Observable raised when the control loses the focus */
  61109. onBlurObservable: BABYLON.Observable<InputText>;
  61110. /**Observable raised when the text is highlighted */
  61111. onTextHighlightObservable: BABYLON.Observable<InputText>;
  61112. /**Observable raised when copy event is triggered */
  61113. onTextCopyObservable: BABYLON.Observable<InputText>;
  61114. /** BABYLON.Observable raised when cut event is triggered */
  61115. onTextCutObservable: BABYLON.Observable<InputText>;
  61116. /** BABYLON.Observable raised when paste event is triggered */
  61117. onTextPasteObservable: BABYLON.Observable<InputText>;
  61118. /** BABYLON.Observable raised when a key event was processed */
  61119. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  61120. /** Gets or sets the maximum width allowed by the control */
  61121. maxWidth: string | number;
  61122. /** Gets the maximum width allowed by the control in pixels */
  61123. readonly maxWidthInPixels: number;
  61124. /** Gets or sets the text highlighter transparency; default: 0.4 */
  61125. highligherOpacity: number;
  61126. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  61127. onFocusSelectAll: boolean;
  61128. /** Gets or sets the text hightlight color */
  61129. textHighlightColor: string;
  61130. /** Gets or sets control margin */
  61131. margin: string;
  61132. /** Gets control margin in pixels */
  61133. readonly marginInPixels: number;
  61134. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  61135. autoStretchWidth: boolean;
  61136. /** Gets or sets border thickness */
  61137. thickness: number;
  61138. /** Gets or sets the background color when focused */
  61139. focusedBackground: string;
  61140. /** Gets or sets the background color when focused */
  61141. focusedColor: string;
  61142. /** Gets or sets the background color */
  61143. background: string;
  61144. /** Gets or sets the placeholder color */
  61145. placeholderColor: string;
  61146. /** Gets or sets the text displayed when the control is empty */
  61147. placeholderText: string;
  61148. /** Gets or sets the dead key flag */
  61149. deadKey: boolean;
  61150. /** Gets or sets the highlight text */
  61151. highlightedText: string;
  61152. /** Gets or sets if the current key should be added */
  61153. addKey: boolean;
  61154. /** Gets or sets the value of the current key being entered */
  61155. currentKey: string;
  61156. /** Gets or sets the text displayed in the control */
  61157. text: string;
  61158. /** Gets or sets control width */
  61159. width: string | number;
  61160. /**
  61161. * Creates a new InputText
  61162. * @param name defines the control name
  61163. * @param text defines the text of the control
  61164. */
  61165. constructor(name?: string | undefined, text?: string);
  61166. /** @hidden */
  61167. onBlur(): void;
  61168. /** @hidden */
  61169. onFocus(): void;
  61170. protected _getTypeName(): string;
  61171. /**
  61172. * Function called to get the list of controls that should not steal the focus from this control
  61173. * @returns an array of controls
  61174. */
  61175. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  61176. /** @hidden */
  61177. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  61178. /** @hidden */
  61179. private _updateValueFromCursorIndex;
  61180. /** @hidden */
  61181. private _processDblClick;
  61182. /** @hidden */
  61183. private _selectAllText;
  61184. /**
  61185. * Handles the keyboard event
  61186. * @param evt Defines the KeyboardEvent
  61187. */
  61188. processKeyboard(evt: KeyboardEvent): void;
  61189. /** @hidden */
  61190. private _onCopyText;
  61191. /** @hidden */
  61192. private _onCutText;
  61193. /** @hidden */
  61194. private _onPasteText;
  61195. _draw(context: CanvasRenderingContext2D): void;
  61196. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61197. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61198. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61199. protected _beforeRenderText(text: string): string;
  61200. dispose(): void;
  61201. }
  61202. }
  61203. declare module BABYLON.GUI {
  61204. /**
  61205. * Class used to create a 2D grid container
  61206. */
  61207. export class Grid extends Container {
  61208. name?: string | undefined;
  61209. private _rowDefinitions;
  61210. private _columnDefinitions;
  61211. private _cells;
  61212. private _childControls;
  61213. /**
  61214. * Gets the number of columns
  61215. */
  61216. readonly columnCount: number;
  61217. /**
  61218. * Gets the number of rows
  61219. */
  61220. readonly rowCount: number;
  61221. /** Gets the list of children */
  61222. readonly children: Control[];
  61223. /** Gets the list of cells (e.g. the containers) */
  61224. readonly cells: {
  61225. [key: string]: Container;
  61226. };
  61227. /**
  61228. * Gets the definition of a specific row
  61229. * @param index defines the index of the row
  61230. * @returns the row definition
  61231. */
  61232. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  61233. /**
  61234. * Gets the definition of a specific column
  61235. * @param index defines the index of the column
  61236. * @returns the column definition
  61237. */
  61238. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  61239. /**
  61240. * Adds a new row to the grid
  61241. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  61242. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  61243. * @returns the current grid
  61244. */
  61245. addRowDefinition(height: number, isPixel?: boolean): Grid;
  61246. /**
  61247. * Adds a new column to the grid
  61248. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  61249. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  61250. * @returns the current grid
  61251. */
  61252. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  61253. /**
  61254. * Update a row definition
  61255. * @param index defines the index of the row to update
  61256. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  61257. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  61258. * @returns the current grid
  61259. */
  61260. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  61261. /**
  61262. * Update a column definition
  61263. * @param index defines the index of the column to update
  61264. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  61265. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  61266. * @returns the current grid
  61267. */
  61268. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  61269. /**
  61270. * Gets the list of children stored in a specific cell
  61271. * @param row defines the row to check
  61272. * @param column defines the column to check
  61273. * @returns the list of controls
  61274. */
  61275. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  61276. /**
  61277. * Gets a string representing the child cell info (row x column)
  61278. * @param child defines the control to get info from
  61279. * @returns a string containing the child cell info (row x column)
  61280. */
  61281. getChildCellInfo(child: Control): string;
  61282. private _removeCell;
  61283. private _offsetCell;
  61284. /**
  61285. * Remove a column definition at specified index
  61286. * @param index defines the index of the column to remove
  61287. * @returns the current grid
  61288. */
  61289. removeColumnDefinition(index: number): Grid;
  61290. /**
  61291. * Remove a row definition at specified index
  61292. * @param index defines the index of the row to remove
  61293. * @returns the current grid
  61294. */
  61295. removeRowDefinition(index: number): Grid;
  61296. /**
  61297. * Adds a new control to the current grid
  61298. * @param control defines the control to add
  61299. * @param row defines the row where to add the control (0 by default)
  61300. * @param column defines the column where to add the control (0 by default)
  61301. * @returns the current grid
  61302. */
  61303. addControl(control: Control, row?: number, column?: number): Grid;
  61304. /**
  61305. * Removes a control from the current container
  61306. * @param control defines the control to remove
  61307. * @returns the current container
  61308. */
  61309. removeControl(control: Control): Container;
  61310. /**
  61311. * Creates a new Grid
  61312. * @param name defines control name
  61313. */
  61314. constructor(name?: string | undefined);
  61315. protected _getTypeName(): string;
  61316. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  61317. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61318. _flagDescendantsAsMatrixDirty(): void;
  61319. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61320. /** Releases associated resources */
  61321. dispose(): void;
  61322. }
  61323. }
  61324. declare module BABYLON.GUI {
  61325. /** Class used to create color pickers */
  61326. export class ColorPicker extends Control {
  61327. name?: string | undefined;
  61328. private static _Epsilon;
  61329. private _colorWheelCanvas;
  61330. private _value;
  61331. private _tmpColor;
  61332. private _pointerStartedOnSquare;
  61333. private _pointerStartedOnWheel;
  61334. private _squareLeft;
  61335. private _squareTop;
  61336. private _squareSize;
  61337. private _h;
  61338. private _s;
  61339. private _v;
  61340. private _lastPointerDownID;
  61341. /**
  61342. * BABYLON.Observable raised when the value changes
  61343. */
  61344. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  61345. /** Gets or sets the color of the color picker */
  61346. value: BABYLON.Color3;
  61347. /**
  61348. * Gets or sets control width
  61349. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61350. */
  61351. width: string | number;
  61352. /**
  61353. * Gets or sets control height
  61354. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61355. */
  61356. /** Gets or sets control height */
  61357. height: string | number;
  61358. /** Gets or sets control size */
  61359. size: string | number;
  61360. /**
  61361. * Creates a new ColorPicker
  61362. * @param name defines the control name
  61363. */
  61364. constructor(name?: string | undefined);
  61365. protected _getTypeName(): string;
  61366. /** @hidden */
  61367. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61368. private _updateSquareProps;
  61369. private _drawGradientSquare;
  61370. private _drawCircle;
  61371. private _createColorWheelCanvas;
  61372. /** @hidden */
  61373. _draw(context: CanvasRenderingContext2D): void;
  61374. private _pointerIsDown;
  61375. private _updateValueFromPointer;
  61376. private _isPointOnSquare;
  61377. private _isPointOnWheel;
  61378. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61379. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61380. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61381. /**
  61382. * This function expands the color picker by creating a color picker dialog with manual
  61383. * color value input and the ability to save colors into an array to be used later in
  61384. * subsequent launches of the dialogue.
  61385. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  61386. * @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.
  61387. * @returns picked color as a hex string and the saved colors array as hex strings.
  61388. */
  61389. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  61390. pickerWidth?: string;
  61391. pickerHeight?: string;
  61392. headerHeight?: string;
  61393. lastColor?: string;
  61394. swatchLimit?: number;
  61395. numSwatchesPerLine?: number;
  61396. savedColors?: Array<string>;
  61397. }): Promise<{
  61398. savedColors?: string[];
  61399. pickedColor: string;
  61400. }>;
  61401. }
  61402. }
  61403. declare module BABYLON.GUI {
  61404. /** Class used to create 2D ellipse containers */
  61405. export class Ellipse extends Container {
  61406. name?: string | undefined;
  61407. private _thickness;
  61408. /** Gets or sets border thickness */
  61409. thickness: number;
  61410. /**
  61411. * Creates a new Ellipse
  61412. * @param name defines the control name
  61413. */
  61414. constructor(name?: string | undefined);
  61415. protected _getTypeName(): string;
  61416. protected _localDraw(context: CanvasRenderingContext2D): void;
  61417. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61418. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61419. }
  61420. }
  61421. declare module BABYLON.GUI {
  61422. /**
  61423. * Class used to create a password control
  61424. */
  61425. export class InputPassword extends InputText {
  61426. protected _beforeRenderText(text: string): string;
  61427. }
  61428. }
  61429. declare module BABYLON.GUI {
  61430. /** Class used to render 2D lines */
  61431. export class Line extends Control {
  61432. name?: string | undefined;
  61433. private _lineWidth;
  61434. private _x1;
  61435. private _y1;
  61436. private _x2;
  61437. private _y2;
  61438. private _dash;
  61439. private _connectedControl;
  61440. private _connectedControlDirtyObserver;
  61441. /** Gets or sets the dash pattern */
  61442. dash: Array<number>;
  61443. /** Gets or sets the control connected with the line end */
  61444. connectedControl: Control;
  61445. /** Gets or sets start coordinates on X axis */
  61446. x1: string | number;
  61447. /** Gets or sets start coordinates on Y axis */
  61448. y1: string | number;
  61449. /** Gets or sets end coordinates on X axis */
  61450. x2: string | number;
  61451. /** Gets or sets end coordinates on Y axis */
  61452. y2: string | number;
  61453. /** Gets or sets line width */
  61454. lineWidth: number;
  61455. /** Gets or sets horizontal alignment */
  61456. horizontalAlignment: number;
  61457. /** Gets or sets vertical alignment */
  61458. verticalAlignment: number;
  61459. private readonly _effectiveX2;
  61460. private readonly _effectiveY2;
  61461. /**
  61462. * Creates a new Line
  61463. * @param name defines the control name
  61464. */
  61465. constructor(name?: string | undefined);
  61466. protected _getTypeName(): string;
  61467. _draw(context: CanvasRenderingContext2D): void;
  61468. _measure(): void;
  61469. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61470. /**
  61471. * Move one end of the line given 3D cartesian coordinates.
  61472. * @param position Targeted world position
  61473. * @param scene BABYLON.Scene
  61474. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  61475. */
  61476. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  61477. /**
  61478. * Move one end of the line to a position in screen absolute space.
  61479. * @param projectedPosition Position in screen absolute space (X, Y)
  61480. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  61481. */
  61482. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  61483. }
  61484. }
  61485. declare module BABYLON.GUI {
  61486. /**
  61487. * Class used to store a point for a MultiLine object.
  61488. * The point can be pure 2D coordinates, a mesh or a control
  61489. */
  61490. export class MultiLinePoint {
  61491. private _multiLine;
  61492. private _x;
  61493. private _y;
  61494. private _control;
  61495. private _mesh;
  61496. private _controlObserver;
  61497. private _meshObserver;
  61498. /** @hidden */
  61499. _point: BABYLON.Vector2;
  61500. /**
  61501. * Creates a new MultiLinePoint
  61502. * @param multiLine defines the source MultiLine object
  61503. */
  61504. constructor(multiLine: MultiLine);
  61505. /** Gets or sets x coordinate */
  61506. x: string | number;
  61507. /** Gets or sets y coordinate */
  61508. y: string | number;
  61509. /** Gets or sets the control associated with this point */
  61510. control: BABYLON.Nullable<Control>;
  61511. /** Gets or sets the mesh associated with this point */
  61512. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61513. /** Resets links */
  61514. resetLinks(): void;
  61515. /**
  61516. * Gets a translation vector
  61517. * @returns the translation vector
  61518. */
  61519. translate(): BABYLON.Vector2;
  61520. private _translatePoint;
  61521. /** Release associated resources */
  61522. dispose(): void;
  61523. }
  61524. }
  61525. declare module BABYLON.GUI {
  61526. /**
  61527. * Class used to create multi line control
  61528. */
  61529. export class MultiLine extends Control {
  61530. name?: string | undefined;
  61531. private _lineWidth;
  61532. private _dash;
  61533. private _points;
  61534. private _minX;
  61535. private _minY;
  61536. private _maxX;
  61537. private _maxY;
  61538. /**
  61539. * Creates a new MultiLine
  61540. * @param name defines the control name
  61541. */
  61542. constructor(name?: string | undefined);
  61543. /** Gets or sets dash pattern */
  61544. dash: Array<number>;
  61545. /**
  61546. * Gets point stored at specified index
  61547. * @param index defines the index to look for
  61548. * @returns the requested point if found
  61549. */
  61550. getAt(index: number): MultiLinePoint;
  61551. /** Function called when a point is updated */
  61552. onPointUpdate: () => void;
  61553. /**
  61554. * Adds new points to the point collection
  61555. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  61556. * @returns the list of created MultiLinePoint
  61557. */
  61558. add(...items: (AbstractMesh | Control | {
  61559. x: string | number;
  61560. y: string | number;
  61561. })[]): MultiLinePoint[];
  61562. /**
  61563. * Adds a new point to the point collection
  61564. * @param item defines the item (mesh, control or 2d coordiantes) to add
  61565. * @returns the created MultiLinePoint
  61566. */
  61567. push(item?: (AbstractMesh | Control | {
  61568. x: string | number;
  61569. y: string | number;
  61570. })): MultiLinePoint;
  61571. /**
  61572. * Remove a specific value or point from the active point collection
  61573. * @param value defines the value or point to remove
  61574. */
  61575. remove(value: number | MultiLinePoint): void;
  61576. /**
  61577. * Resets this object to initial state (no point)
  61578. */
  61579. reset(): void;
  61580. /**
  61581. * Resets all links
  61582. */
  61583. resetLinks(): void;
  61584. /** Gets or sets line width */
  61585. lineWidth: number;
  61586. horizontalAlignment: number;
  61587. verticalAlignment: number;
  61588. protected _getTypeName(): string;
  61589. _draw(context: CanvasRenderingContext2D): void;
  61590. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61591. _measure(): void;
  61592. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61593. dispose(): void;
  61594. }
  61595. }
  61596. declare module BABYLON.GUI {
  61597. /**
  61598. * Class used to create radio button controls
  61599. */
  61600. export class RadioButton extends Control {
  61601. name?: string | undefined;
  61602. private _isChecked;
  61603. private _background;
  61604. private _checkSizeRatio;
  61605. private _thickness;
  61606. /** Gets or sets border thickness */
  61607. thickness: number;
  61608. /** Gets or sets group name */
  61609. group: string;
  61610. /** BABYLON.Observable raised when isChecked is changed */
  61611. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  61612. /** Gets or sets a value indicating the ratio between overall size and check size */
  61613. checkSizeRatio: number;
  61614. /** Gets or sets background color */
  61615. background: string;
  61616. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  61617. isChecked: boolean;
  61618. /**
  61619. * Creates a new RadioButton
  61620. * @param name defines the control name
  61621. */
  61622. constructor(name?: string | undefined);
  61623. protected _getTypeName(): string;
  61624. _draw(context: CanvasRenderingContext2D): void;
  61625. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61626. /**
  61627. * Utility function to easily create a radio button with a header
  61628. * @param title defines the label to use for the header
  61629. * @param group defines the group to use for the radio button
  61630. * @param isChecked defines the initial state of the radio button
  61631. * @param onValueChanged defines the callback to call when value changes
  61632. * @returns a StackPanel containing the radio button and a textBlock
  61633. */
  61634. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  61635. }
  61636. }
  61637. declare module BABYLON.GUI {
  61638. /**
  61639. * Class used to create slider controls
  61640. */
  61641. export class BaseSlider extends Control {
  61642. name?: string | undefined;
  61643. protected _thumbWidth: ValueAndUnit;
  61644. private _minimum;
  61645. private _maximum;
  61646. private _value;
  61647. private _isVertical;
  61648. protected _barOffset: ValueAndUnit;
  61649. private _isThumbClamped;
  61650. protected _displayThumb: boolean;
  61651. private _step;
  61652. private _lastPointerDownID;
  61653. protected _effectiveBarOffset: number;
  61654. protected _renderLeft: number;
  61655. protected _renderTop: number;
  61656. protected _renderWidth: number;
  61657. protected _renderHeight: number;
  61658. protected _backgroundBoxLength: number;
  61659. protected _backgroundBoxThickness: number;
  61660. protected _effectiveThumbThickness: number;
  61661. /** BABYLON.Observable raised when the sldier value changes */
  61662. onValueChangedObservable: BABYLON.Observable<number>;
  61663. /** Gets or sets a boolean indicating if the thumb must be rendered */
  61664. displayThumb: boolean;
  61665. /** Gets or sets a step to apply to values (0 by default) */
  61666. step: number;
  61667. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  61668. barOffset: string | number;
  61669. /** Gets main bar offset in pixels*/
  61670. readonly barOffsetInPixels: number;
  61671. /** Gets or sets thumb width */
  61672. thumbWidth: string | number;
  61673. /** Gets thumb width in pixels */
  61674. readonly thumbWidthInPixels: number;
  61675. /** Gets or sets minimum value */
  61676. minimum: number;
  61677. /** Gets or sets maximum value */
  61678. maximum: number;
  61679. /** Gets or sets current value */
  61680. value: number;
  61681. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  61682. isVertical: boolean;
  61683. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  61684. isThumbClamped: boolean;
  61685. /**
  61686. * Creates a new BaseSlider
  61687. * @param name defines the control name
  61688. */
  61689. constructor(name?: string | undefined);
  61690. protected _getTypeName(): string;
  61691. protected _getThumbPosition(): number;
  61692. protected _getThumbThickness(type: string): number;
  61693. protected _prepareRenderingData(type: string): void;
  61694. private _pointerIsDown;
  61695. /** @hidden */
  61696. protected _updateValueFromPointer(x: number, y: number): void;
  61697. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61698. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61699. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61700. }
  61701. }
  61702. declare module BABYLON.GUI {
  61703. /**
  61704. * Class used to create slider controls
  61705. */
  61706. export class Slider extends BaseSlider {
  61707. name?: string | undefined;
  61708. private _background;
  61709. private _borderColor;
  61710. private _isThumbCircle;
  61711. protected _displayValueBar: boolean;
  61712. /** Gets or sets a boolean indicating if the value bar must be rendered */
  61713. displayValueBar: boolean;
  61714. /** Gets or sets border color */
  61715. borderColor: string;
  61716. /** Gets or sets background color */
  61717. background: string;
  61718. /** Gets or sets a boolean indicating if the thumb should be round or square */
  61719. isThumbCircle: boolean;
  61720. /**
  61721. * Creates a new Slider
  61722. * @param name defines the control name
  61723. */
  61724. constructor(name?: string | undefined);
  61725. protected _getTypeName(): string;
  61726. _draw(context: CanvasRenderingContext2D): void;
  61727. }
  61728. }
  61729. declare module BABYLON.GUI {
  61730. /** Class used to create a RadioGroup
  61731. * which contains groups of radio buttons
  61732. */
  61733. export class SelectorGroup {
  61734. /** name of SelectorGroup */
  61735. name: string;
  61736. private _groupPanel;
  61737. private _selectors;
  61738. private _groupHeader;
  61739. /**
  61740. * Creates a new SelectorGroup
  61741. * @param name of group, used as a group heading
  61742. */
  61743. constructor(
  61744. /** name of SelectorGroup */
  61745. name: string);
  61746. /** Gets the groupPanel of the SelectorGroup */
  61747. readonly groupPanel: StackPanel;
  61748. /** Gets the selectors array */
  61749. readonly selectors: StackPanel[];
  61750. /** Gets and sets the group header */
  61751. header: string;
  61752. /** @hidden */
  61753. private _addGroupHeader;
  61754. /** @hidden*/
  61755. _getSelector(selectorNb: number): StackPanel | undefined;
  61756. /** Removes the selector at the given position
  61757. * @param selectorNb the position of the selector within the group
  61758. */
  61759. removeSelector(selectorNb: number): void;
  61760. }
  61761. /** Class used to create a CheckboxGroup
  61762. * which contains groups of checkbox buttons
  61763. */
  61764. export class CheckboxGroup extends SelectorGroup {
  61765. /** Adds a checkbox as a control
  61766. * @param text is the label for the selector
  61767. * @param func is the function called when the Selector is checked
  61768. * @param checked is true when Selector is checked
  61769. */
  61770. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  61771. /** @hidden */
  61772. _setSelectorLabel(selectorNb: number, label: string): void;
  61773. /** @hidden */
  61774. _setSelectorLabelColor(selectorNb: number, color: string): void;
  61775. /** @hidden */
  61776. _setSelectorButtonColor(selectorNb: number, color: string): void;
  61777. /** @hidden */
  61778. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61779. }
  61780. /** Class used to create a RadioGroup
  61781. * which contains groups of radio buttons
  61782. */
  61783. export class RadioGroup extends SelectorGroup {
  61784. private _selectNb;
  61785. /** Adds a radio button as a control
  61786. * @param label is the label for the selector
  61787. * @param func is the function called when the Selector is checked
  61788. * @param checked is true when Selector is checked
  61789. */
  61790. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  61791. /** @hidden */
  61792. _setSelectorLabel(selectorNb: number, label: string): void;
  61793. /** @hidden */
  61794. _setSelectorLabelColor(selectorNb: number, color: string): void;
  61795. /** @hidden */
  61796. _setSelectorButtonColor(selectorNb: number, color: string): void;
  61797. /** @hidden */
  61798. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61799. }
  61800. /** Class used to create a SliderGroup
  61801. * which contains groups of slider buttons
  61802. */
  61803. export class SliderGroup extends SelectorGroup {
  61804. /**
  61805. * Adds a slider to the SelectorGroup
  61806. * @param label is the label for the SliderBar
  61807. * @param func is the function called when the Slider moves
  61808. * @param unit is a string describing the units used, eg degrees or metres
  61809. * @param min is the minimum value for the Slider
  61810. * @param max is the maximum value for the Slider
  61811. * @param value is the start value for the Slider between min and max
  61812. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  61813. */
  61814. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  61815. /** @hidden */
  61816. _setSelectorLabel(selectorNb: number, label: string): void;
  61817. /** @hidden */
  61818. _setSelectorLabelColor(selectorNb: number, color: string): void;
  61819. /** @hidden */
  61820. _setSelectorButtonColor(selectorNb: number, color: string): void;
  61821. /** @hidden */
  61822. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61823. }
  61824. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  61825. * @see http://doc.babylonjs.com/how_to/selector
  61826. */
  61827. export class SelectionPanel extends Rectangle {
  61828. /** name of SelectionPanel */
  61829. name: string;
  61830. /** an array of SelectionGroups */
  61831. groups: SelectorGroup[];
  61832. private _panel;
  61833. private _buttonColor;
  61834. private _buttonBackground;
  61835. private _headerColor;
  61836. private _barColor;
  61837. private _barHeight;
  61838. private _spacerHeight;
  61839. private _labelColor;
  61840. private _groups;
  61841. private _bars;
  61842. /**
  61843. * Creates a new SelectionPanel
  61844. * @param name of SelectionPanel
  61845. * @param groups is an array of SelectionGroups
  61846. */
  61847. constructor(
  61848. /** name of SelectionPanel */
  61849. name: string,
  61850. /** an array of SelectionGroups */
  61851. groups?: SelectorGroup[]);
  61852. protected _getTypeName(): string;
  61853. /** Gets or sets the headerColor */
  61854. headerColor: string;
  61855. private _setHeaderColor;
  61856. /** Gets or sets the button color */
  61857. buttonColor: string;
  61858. private _setbuttonColor;
  61859. /** Gets or sets the label color */
  61860. labelColor: string;
  61861. private _setLabelColor;
  61862. /** Gets or sets the button background */
  61863. buttonBackground: string;
  61864. private _setButtonBackground;
  61865. /** Gets or sets the color of separator bar */
  61866. barColor: string;
  61867. private _setBarColor;
  61868. /** Gets or sets the height of separator bar */
  61869. barHeight: string;
  61870. private _setBarHeight;
  61871. /** Gets or sets the height of spacers*/
  61872. spacerHeight: string;
  61873. private _setSpacerHeight;
  61874. /** Adds a bar between groups */
  61875. private _addSpacer;
  61876. /** Add a group to the selection panel
  61877. * @param group is the selector group to add
  61878. */
  61879. addGroup(group: SelectorGroup): void;
  61880. /** Remove the group from the given position
  61881. * @param groupNb is the position of the group in the list
  61882. */
  61883. removeGroup(groupNb: number): void;
  61884. /** Change a group header label
  61885. * @param label is the new group header label
  61886. * @param groupNb is the number of the group to relabel
  61887. * */
  61888. setHeaderName(label: string, groupNb: number): void;
  61889. /** Change selector label to the one given
  61890. * @param label is the new selector label
  61891. * @param groupNb is the number of the groupcontaining the selector
  61892. * @param selectorNb is the number of the selector within a group to relabel
  61893. * */
  61894. relabel(label: string, groupNb: number, selectorNb: number): void;
  61895. /** For a given group position remove the selector at the given position
  61896. * @param groupNb is the number of the group to remove the selector from
  61897. * @param selectorNb is the number of the selector within the group
  61898. */
  61899. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  61900. /** For a given group position of correct type add a checkbox button
  61901. * @param groupNb is the number of the group to remove the selector from
  61902. * @param label is the label for the selector
  61903. * @param func is the function called when the Selector is checked
  61904. * @param checked is true when Selector is checked
  61905. */
  61906. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  61907. /** For a given group position of correct type add a radio button
  61908. * @param groupNb is the number of the group to remove the selector from
  61909. * @param label is the label for the selector
  61910. * @param func is the function called when the Selector is checked
  61911. * @param checked is true when Selector is checked
  61912. */
  61913. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  61914. /**
  61915. * For a given slider group add a slider
  61916. * @param groupNb is the number of the group to add the slider to
  61917. * @param label is the label for the Slider
  61918. * @param func is the function called when the Slider moves
  61919. * @param unit is a string describing the units used, eg degrees or metres
  61920. * @param min is the minimum value for the Slider
  61921. * @param max is the maximum value for the Slider
  61922. * @param value is the start value for the Slider between min and max
  61923. * @param onVal is the function used to format the value displayed, eg radians to degrees
  61924. */
  61925. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  61926. }
  61927. }
  61928. declare module BABYLON.GUI {
  61929. /**
  61930. * Class used to hold a the container for ScrollViewer
  61931. * @hidden
  61932. */
  61933. export class _ScrollViewerWindow extends Container {
  61934. parentClientWidth: number;
  61935. parentClientHeight: number;
  61936. /**
  61937. * Creates a new ScrollViewerWindow
  61938. * @param name of ScrollViewerWindow
  61939. */
  61940. constructor(name?: string);
  61941. protected _getTypeName(): string;
  61942. /** @hidden */
  61943. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61944. protected _postMeasure(): void;
  61945. }
  61946. }
  61947. declare module BABYLON.GUI {
  61948. /**
  61949. * Class used to create slider controls
  61950. */
  61951. export class ScrollBar extends BaseSlider {
  61952. name?: string | undefined;
  61953. private _background;
  61954. private _borderColor;
  61955. private _thumbMeasure;
  61956. /** Gets or sets border color */
  61957. borderColor: string;
  61958. /** Gets or sets background color */
  61959. background: string;
  61960. /**
  61961. * Creates a new Slider
  61962. * @param name defines the control name
  61963. */
  61964. constructor(name?: string | undefined);
  61965. protected _getTypeName(): string;
  61966. protected _getThumbThickness(): number;
  61967. _draw(context: CanvasRenderingContext2D): void;
  61968. private _first;
  61969. private _originX;
  61970. private _originY;
  61971. /** @hidden */
  61972. protected _updateValueFromPointer(x: number, y: number): void;
  61973. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61974. }
  61975. }
  61976. declare module BABYLON.GUI {
  61977. /**
  61978. * Class used to hold a viewer window and sliders in a grid
  61979. */
  61980. export class ScrollViewer extends Rectangle {
  61981. private _grid;
  61982. private _horizontalBarSpace;
  61983. private _verticalBarSpace;
  61984. private _dragSpace;
  61985. private _horizontalBar;
  61986. private _verticalBar;
  61987. private _barColor;
  61988. private _barBackground;
  61989. private _barSize;
  61990. private _endLeft;
  61991. private _endTop;
  61992. private _window;
  61993. private _pointerIsOver;
  61994. private _wheelPrecision;
  61995. private _onPointerObserver;
  61996. private _clientWidth;
  61997. private _clientHeight;
  61998. /**
  61999. * Gets the horizontal scrollbar
  62000. */
  62001. readonly horizontalBar: ScrollBar;
  62002. /**
  62003. * Gets the vertical scrollbar
  62004. */
  62005. readonly verticalBar: ScrollBar;
  62006. /**
  62007. * Adds a new control to the current container
  62008. * @param control defines the control to add
  62009. * @returns the current container
  62010. */
  62011. addControl(control: BABYLON.Nullable<Control>): Container;
  62012. /**
  62013. * Removes a control from the current container
  62014. * @param control defines the control to remove
  62015. * @returns the current container
  62016. */
  62017. removeControl(control: Control): Container;
  62018. /** Gets the list of children */
  62019. readonly children: Control[];
  62020. _flagDescendantsAsMatrixDirty(): void;
  62021. /**
  62022. * Creates a new ScrollViewer
  62023. * @param name of ScrollViewer
  62024. */
  62025. constructor(name?: string);
  62026. /** Reset the scroll viewer window to initial size */
  62027. resetWindow(): void;
  62028. protected _getTypeName(): string;
  62029. private _buildClientSizes;
  62030. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62031. protected _postMeasure(): void;
  62032. /**
  62033. * Gets or sets the mouse wheel precision
  62034. * from 0 to 1 with a default value of 0.05
  62035. * */
  62036. wheelPrecision: number;
  62037. /** Gets or sets the bar color */
  62038. barColor: string;
  62039. /** Gets or sets the size of the bar */
  62040. barSize: number;
  62041. /** Gets or sets the bar background */
  62042. barBackground: string;
  62043. /** @hidden */
  62044. private _updateScroller;
  62045. _link(host: AdvancedDynamicTexture): void;
  62046. /** @hidden */
  62047. private _attachWheel;
  62048. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62049. /** Releases associated resources */
  62050. dispose(): void;
  62051. }
  62052. }
  62053. declare module BABYLON.GUI {
  62054. /** Class used to render a grid */
  62055. export class DisplayGrid extends Control {
  62056. name?: string | undefined;
  62057. private _cellWidth;
  62058. private _cellHeight;
  62059. private _minorLineTickness;
  62060. private _minorLineColor;
  62061. private _majorLineTickness;
  62062. private _majorLineColor;
  62063. private _majorLineFrequency;
  62064. private _background;
  62065. private _displayMajorLines;
  62066. private _displayMinorLines;
  62067. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  62068. displayMinorLines: boolean;
  62069. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  62070. displayMajorLines: boolean;
  62071. /** Gets or sets background color (Black by default) */
  62072. background: string;
  62073. /** Gets or sets the width of each cell (20 by default) */
  62074. cellWidth: number;
  62075. /** Gets or sets the height of each cell (20 by default) */
  62076. cellHeight: number;
  62077. /** Gets or sets the tickness of minor lines (1 by default) */
  62078. minorLineTickness: number;
  62079. /** Gets or sets the color of minor lines (DarkGray by default) */
  62080. minorLineColor: string;
  62081. /** Gets or sets the tickness of major lines (2 by default) */
  62082. majorLineTickness: number;
  62083. /** Gets or sets the color of major lines (White by default) */
  62084. majorLineColor: string;
  62085. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  62086. majorLineFrequency: number;
  62087. /**
  62088. * Creates a new GridDisplayRectangle
  62089. * @param name defines the control name
  62090. */
  62091. constructor(name?: string | undefined);
  62092. _draw(context: CanvasRenderingContext2D): void;
  62093. protected _getTypeName(): string;
  62094. }
  62095. }
  62096. declare module BABYLON.GUI {
  62097. /**
  62098. * Class used to create slider controls based on images
  62099. */
  62100. export class ImageBasedSlider extends BaseSlider {
  62101. name?: string | undefined;
  62102. private _backgroundImage;
  62103. private _thumbImage;
  62104. private _valueBarImage;
  62105. private _tempMeasure;
  62106. displayThumb: boolean;
  62107. /**
  62108. * Gets or sets the image used to render the background
  62109. */
  62110. backgroundImage: Image;
  62111. /**
  62112. * Gets or sets the image used to render the value bar
  62113. */
  62114. valueBarImage: Image;
  62115. /**
  62116. * Gets or sets the image used to render the thumb
  62117. */
  62118. thumbImage: Image;
  62119. /**
  62120. * Creates a new ImageBasedSlider
  62121. * @param name defines the control name
  62122. */
  62123. constructor(name?: string | undefined);
  62124. protected _getTypeName(): string;
  62125. _draw(context: CanvasRenderingContext2D): void;
  62126. }
  62127. }
  62128. declare module BABYLON.GUI {
  62129. /**
  62130. * Forcing an export so that this code will execute
  62131. * @hidden
  62132. */
  62133. const name = "Statics";
  62134. }
  62135. declare module BABYLON.GUI {
  62136. /**
  62137. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  62138. */
  62139. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  62140. /**
  62141. * Define the instrumented AdvancedDynamicTexture.
  62142. */
  62143. texture: AdvancedDynamicTexture;
  62144. private _captureRenderTime;
  62145. private _renderTime;
  62146. private _captureLayoutTime;
  62147. private _layoutTime;
  62148. private _onBeginRenderObserver;
  62149. private _onEndRenderObserver;
  62150. private _onBeginLayoutObserver;
  62151. private _onEndLayoutObserver;
  62152. /**
  62153. * Gets the perf counter used to capture render time
  62154. */
  62155. readonly renderTimeCounter: BABYLON.PerfCounter;
  62156. /**
  62157. * Gets the perf counter used to capture layout time
  62158. */
  62159. readonly layoutTimeCounter: BABYLON.PerfCounter;
  62160. /**
  62161. * Enable or disable the render time capture
  62162. */
  62163. captureRenderTime: boolean;
  62164. /**
  62165. * Enable or disable the layout time capture
  62166. */
  62167. captureLayoutTime: boolean;
  62168. /**
  62169. * Instantiates a new advanced dynamic texture instrumentation.
  62170. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  62171. * @param texture Defines the AdvancedDynamicTexture to instrument
  62172. */
  62173. constructor(
  62174. /**
  62175. * Define the instrumented AdvancedDynamicTexture.
  62176. */
  62177. texture: AdvancedDynamicTexture);
  62178. /**
  62179. * Dispose and release associated resources.
  62180. */
  62181. dispose(): void;
  62182. }
  62183. }
  62184. declare module BABYLON.GUI {
  62185. /**
  62186. * Class used to create containers for controls
  62187. */
  62188. export class Container3D extends Control3D {
  62189. private _blockLayout;
  62190. /**
  62191. * Gets the list of child controls
  62192. */
  62193. protected _children: Control3D[];
  62194. /**
  62195. * Gets the list of child controls
  62196. */
  62197. readonly children: Array<Control3D>;
  62198. /**
  62199. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  62200. * This is helpful to optimize layout operation when adding multiple children in a row
  62201. */
  62202. blockLayout: boolean;
  62203. /**
  62204. * Creates a new container
  62205. * @param name defines the container name
  62206. */
  62207. constructor(name?: string);
  62208. /**
  62209. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  62210. * @returns the current container
  62211. */
  62212. updateLayout(): Container3D;
  62213. /**
  62214. * Gets a boolean indicating if the given control is in the children of this control
  62215. * @param control defines the control to check
  62216. * @returns true if the control is in the child list
  62217. */
  62218. containsControl(control: Control3D): boolean;
  62219. /**
  62220. * Adds a control to the children of this control
  62221. * @param control defines the control to add
  62222. * @returns the current container
  62223. */
  62224. addControl(control: Control3D): Container3D;
  62225. /**
  62226. * This function will be called everytime a new control is added
  62227. */
  62228. protected _arrangeChildren(): void;
  62229. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  62230. /**
  62231. * Removes a control from the children of this control
  62232. * @param control defines the control to remove
  62233. * @returns the current container
  62234. */
  62235. removeControl(control: Control3D): Container3D;
  62236. protected _getTypeName(): string;
  62237. /**
  62238. * Releases all associated resources
  62239. */
  62240. dispose(): void;
  62241. /** Control rotation will remain unchanged */
  62242. static readonly UNSET_ORIENTATION: number;
  62243. /** Control will rotate to make it look at sphere central axis */
  62244. static readonly FACEORIGIN_ORIENTATION: number;
  62245. /** Control will rotate to make it look back at sphere central axis */
  62246. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  62247. /** Control will rotate to look at z axis (0, 0, 1) */
  62248. static readonly FACEFORWARD_ORIENTATION: number;
  62249. /** Control will rotate to look at negative z axis (0, 0, -1) */
  62250. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  62251. }
  62252. }
  62253. declare module BABYLON.GUI {
  62254. /**
  62255. * Class used to manage 3D user interface
  62256. * @see http://doc.babylonjs.com/how_to/gui3d
  62257. */
  62258. export class GUI3DManager implements BABYLON.IDisposable {
  62259. private _scene;
  62260. private _sceneDisposeObserver;
  62261. private _utilityLayer;
  62262. private _rootContainer;
  62263. private _pointerObserver;
  62264. private _pointerOutObserver;
  62265. /** @hidden */
  62266. _lastPickedControl: Control3D;
  62267. /** @hidden */
  62268. _lastControlOver: {
  62269. [pointerId: number]: Control3D;
  62270. };
  62271. /** @hidden */
  62272. _lastControlDown: {
  62273. [pointerId: number]: Control3D;
  62274. };
  62275. /**
  62276. * BABYLON.Observable raised when the point picked by the pointer events changed
  62277. */
  62278. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  62279. /** @hidden */
  62280. _sharedMaterials: {
  62281. [key: string]: BABYLON.Material;
  62282. };
  62283. /** Gets the hosting scene */
  62284. readonly scene: BABYLON.Scene;
  62285. /** Gets associated utility layer */
  62286. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  62287. /**
  62288. * Creates a new GUI3DManager
  62289. * @param scene
  62290. */
  62291. constructor(scene?: BABYLON.Scene);
  62292. private _handlePointerOut;
  62293. private _doPicking;
  62294. /**
  62295. * Gets the root container
  62296. */
  62297. readonly rootContainer: Container3D;
  62298. /**
  62299. * Gets a boolean indicating if the given control is in the root child list
  62300. * @param control defines the control to check
  62301. * @returns true if the control is in the root child list
  62302. */
  62303. containsControl(control: Control3D): boolean;
  62304. /**
  62305. * Adds a control to the root child list
  62306. * @param control defines the control to add
  62307. * @returns the current manager
  62308. */
  62309. addControl(control: Control3D): GUI3DManager;
  62310. /**
  62311. * Removes a control from the root child list
  62312. * @param control defines the control to remove
  62313. * @returns the current container
  62314. */
  62315. removeControl(control: Control3D): GUI3DManager;
  62316. /**
  62317. * Releases all associated resources
  62318. */
  62319. dispose(): void;
  62320. }
  62321. }
  62322. declare module BABYLON.GUI {
  62323. /**
  62324. * Class used to transport BABYLON.Vector3 information for pointer events
  62325. */
  62326. export class Vector3WithInfo extends BABYLON.Vector3 {
  62327. /** defines the current mouse button index */
  62328. buttonIndex: number;
  62329. /**
  62330. * Creates a new Vector3WithInfo
  62331. * @param source defines the vector3 data to transport
  62332. * @param buttonIndex defines the current mouse button index
  62333. */
  62334. constructor(source: BABYLON.Vector3,
  62335. /** defines the current mouse button index */
  62336. buttonIndex?: number);
  62337. }
  62338. }
  62339. declare module BABYLON.GUI {
  62340. /**
  62341. * Class used as base class for controls
  62342. */
  62343. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  62344. /** Defines the control name */
  62345. name?: string | undefined;
  62346. /** @hidden */
  62347. _host: GUI3DManager;
  62348. private _node;
  62349. private _downCount;
  62350. private _enterCount;
  62351. private _downPointerIds;
  62352. private _isVisible;
  62353. /** Gets or sets the control position in world space */
  62354. position: BABYLON.Vector3;
  62355. /** Gets or sets the control scaling in world space */
  62356. scaling: BABYLON.Vector3;
  62357. /** Callback used to start pointer enter animation */
  62358. pointerEnterAnimation: () => void;
  62359. /** Callback used to start pointer out animation */
  62360. pointerOutAnimation: () => void;
  62361. /** Callback used to start pointer down animation */
  62362. pointerDownAnimation: () => void;
  62363. /** Callback used to start pointer up animation */
  62364. pointerUpAnimation: () => void;
  62365. /**
  62366. * An event triggered when the pointer move over the control
  62367. */
  62368. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  62369. /**
  62370. * An event triggered when the pointer move out of the control
  62371. */
  62372. onPointerOutObservable: BABYLON.Observable<Control3D>;
  62373. /**
  62374. * An event triggered when the pointer taps the control
  62375. */
  62376. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  62377. /**
  62378. * An event triggered when pointer is up
  62379. */
  62380. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  62381. /**
  62382. * An event triggered when a control is clicked on (with a mouse)
  62383. */
  62384. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  62385. /**
  62386. * An event triggered when pointer enters the control
  62387. */
  62388. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  62389. /**
  62390. * Gets or sets the parent container
  62391. */
  62392. parent: BABYLON.Nullable<Container3D>;
  62393. private _behaviors;
  62394. /**
  62395. * Gets the list of attached behaviors
  62396. * @see http://doc.babylonjs.com/features/behaviour
  62397. */
  62398. readonly behaviors: BABYLON.Behavior<Control3D>[];
  62399. /**
  62400. * Attach a behavior to the control
  62401. * @see http://doc.babylonjs.com/features/behaviour
  62402. * @param behavior defines the behavior to attach
  62403. * @returns the current control
  62404. */
  62405. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62406. /**
  62407. * Remove an attached behavior
  62408. * @see http://doc.babylonjs.com/features/behaviour
  62409. * @param behavior defines the behavior to attach
  62410. * @returns the current control
  62411. */
  62412. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62413. /**
  62414. * Gets an attached behavior by name
  62415. * @param name defines the name of the behavior to look for
  62416. * @see http://doc.babylonjs.com/features/behaviour
  62417. * @returns null if behavior was not found else the requested behavior
  62418. */
  62419. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  62420. /** Gets or sets a boolean indicating if the control is visible */
  62421. isVisible: boolean;
  62422. /**
  62423. * Creates a new control
  62424. * @param name defines the control name
  62425. */
  62426. constructor(
  62427. /** Defines the control name */
  62428. name?: string | undefined);
  62429. /**
  62430. * Gets a string representing the class name
  62431. */
  62432. readonly typeName: string;
  62433. /**
  62434. * Get the current class name of the control.
  62435. * @returns current class name
  62436. */
  62437. getClassName(): string;
  62438. protected _getTypeName(): string;
  62439. /**
  62440. * Gets the transform node used by this control
  62441. */
  62442. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  62443. /**
  62444. * Gets the mesh used to render this control
  62445. */
  62446. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62447. /**
  62448. * Link the control as child of the given node
  62449. * @param node defines the node to link to. Use null to unlink the control
  62450. * @returns the current control
  62451. */
  62452. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  62453. /** @hidden **/
  62454. _prepareNode(scene: BABYLON.Scene): void;
  62455. /**
  62456. * Node creation.
  62457. * Can be overriden by children
  62458. * @param scene defines the scene where the node must be attached
  62459. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  62460. */
  62461. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  62462. /**
  62463. * Affect a material to the given mesh
  62464. * @param mesh defines the mesh which will represent the control
  62465. */
  62466. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62467. /** @hidden */
  62468. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  62469. /** @hidden */
  62470. _onPointerEnter(target: Control3D): boolean;
  62471. /** @hidden */
  62472. _onPointerOut(target: Control3D): void;
  62473. /** @hidden */
  62474. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  62475. /** @hidden */
  62476. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62477. /** @hidden */
  62478. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  62479. /** @hidden */
  62480. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  62481. /** @hidden */
  62482. _disposeNode(): void;
  62483. /**
  62484. * Releases all associated resources
  62485. */
  62486. dispose(): void;
  62487. }
  62488. }
  62489. declare module BABYLON.GUI {
  62490. /**
  62491. * Class used as a root to all buttons
  62492. */
  62493. export class AbstractButton3D extends Control3D {
  62494. /**
  62495. * Creates a new button
  62496. * @param name defines the control name
  62497. */
  62498. constructor(name?: string);
  62499. protected _getTypeName(): string;
  62500. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62501. }
  62502. }
  62503. declare module BABYLON.GUI {
  62504. /**
  62505. * Class used to create a button in 3D
  62506. */
  62507. export class Button3D extends AbstractButton3D {
  62508. /** @hidden */
  62509. protected _currentMaterial: BABYLON.Material;
  62510. private _facadeTexture;
  62511. private _content;
  62512. private _contentResolution;
  62513. private _contentScaleRatio;
  62514. /**
  62515. * Gets or sets the texture resolution used to render content (512 by default)
  62516. */
  62517. contentResolution: BABYLON.int;
  62518. /**
  62519. * Gets or sets the texture scale ratio used to render content (2 by default)
  62520. */
  62521. contentScaleRatio: number;
  62522. protected _disposeFacadeTexture(): void;
  62523. protected _resetContent(): void;
  62524. /**
  62525. * Creates a new button
  62526. * @param name defines the control name
  62527. */
  62528. constructor(name?: string);
  62529. /**
  62530. * Gets or sets the GUI 2D content used to display the button's facade
  62531. */
  62532. content: Control;
  62533. /**
  62534. * Apply the facade texture (created from the content property).
  62535. * This function can be overloaded by child classes
  62536. * @param facadeTexture defines the AdvancedDynamicTexture to use
  62537. */
  62538. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  62539. protected _getTypeName(): string;
  62540. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62541. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62542. /**
  62543. * Releases all associated resources
  62544. */
  62545. dispose(): void;
  62546. }
  62547. }
  62548. declare module BABYLON.GUI {
  62549. /**
  62550. * Abstract class used to create a container panel deployed on the surface of a volume
  62551. */
  62552. export abstract class VolumeBasedPanel extends Container3D {
  62553. private _columns;
  62554. private _rows;
  62555. private _rowThenColum;
  62556. private _orientation;
  62557. protected _cellWidth: number;
  62558. protected _cellHeight: number;
  62559. /**
  62560. * Gets or sets the distance between elements
  62561. */
  62562. margin: number;
  62563. /**
  62564. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  62565. * | Value | Type | Description |
  62566. * | ----- | ----------------------------------- | ----------- |
  62567. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  62568. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  62569. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  62570. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  62571. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  62572. */
  62573. orientation: number;
  62574. /**
  62575. * Gets or sets the number of columns requested (10 by default).
  62576. * The panel will automatically compute the number of rows based on number of child controls.
  62577. */
  62578. columns: BABYLON.int;
  62579. /**
  62580. * Gets or sets a the number of rows requested.
  62581. * The panel will automatically compute the number of columns based on number of child controls.
  62582. */
  62583. rows: BABYLON.int;
  62584. /**
  62585. * Creates new VolumeBasedPanel
  62586. */
  62587. constructor();
  62588. protected _arrangeChildren(): void;
  62589. /** Child classes must implement this function to provide correct control positioning */
  62590. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62591. /** Child classes can implement this function to provide additional processing */
  62592. protected _finalProcessing(): void;
  62593. }
  62594. }
  62595. declare module BABYLON.GUI {
  62596. /**
  62597. * Class used to create a container panel deployed on the surface of a cylinder
  62598. */
  62599. export class CylinderPanel extends VolumeBasedPanel {
  62600. private _radius;
  62601. /**
  62602. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  62603. */
  62604. radius: BABYLON.float;
  62605. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62606. private _cylindricalMapping;
  62607. }
  62608. }
  62609. declare module BABYLON.GUI {
  62610. /** @hidden */
  62611. export var fluentVertexShader: {
  62612. name: string;
  62613. shader: string;
  62614. };
  62615. }
  62616. declare module BABYLON.GUI {
  62617. /** @hidden */
  62618. export var fluentPixelShader: {
  62619. name: string;
  62620. shader: string;
  62621. };
  62622. }
  62623. declare module BABYLON.GUI {
  62624. /** @hidden */
  62625. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  62626. INNERGLOW: boolean;
  62627. BORDER: boolean;
  62628. HOVERLIGHT: boolean;
  62629. TEXTURE: boolean;
  62630. constructor();
  62631. }
  62632. /**
  62633. * Class used to render controls with fluent desgin
  62634. */
  62635. export class FluentMaterial extends BABYLON.PushMaterial {
  62636. /**
  62637. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  62638. */
  62639. innerGlowColorIntensity: number;
  62640. /**
  62641. * Gets or sets the inner glow color (white by default)
  62642. */
  62643. innerGlowColor: BABYLON.Color3;
  62644. /**
  62645. * Gets or sets alpha value (default is 1.0)
  62646. */
  62647. alpha: number;
  62648. /**
  62649. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  62650. */
  62651. albedoColor: BABYLON.Color3;
  62652. /**
  62653. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  62654. */
  62655. renderBorders: boolean;
  62656. /**
  62657. * Gets or sets border width (default is 0.5)
  62658. */
  62659. borderWidth: number;
  62660. /**
  62661. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  62662. */
  62663. edgeSmoothingValue: number;
  62664. /**
  62665. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  62666. */
  62667. borderMinValue: number;
  62668. /**
  62669. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  62670. */
  62671. renderHoverLight: boolean;
  62672. /**
  62673. * Gets or sets the radius used to render the hover light (default is 1.0)
  62674. */
  62675. hoverRadius: number;
  62676. /**
  62677. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  62678. */
  62679. hoverColor: BABYLON.Color4;
  62680. /**
  62681. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  62682. */
  62683. hoverPosition: BABYLON.Vector3;
  62684. private _albedoTexture;
  62685. /** Gets or sets the texture to use for albedo color */
  62686. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  62687. /**
  62688. * Creates a new Fluent material
  62689. * @param name defines the name of the material
  62690. * @param scene defines the hosting scene
  62691. */
  62692. constructor(name: string, scene: BABYLON.Scene);
  62693. needAlphaBlending(): boolean;
  62694. needAlphaTesting(): boolean;
  62695. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  62696. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  62697. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  62698. getActiveTextures(): BABYLON.BaseTexture[];
  62699. hasTexture(texture: BABYLON.BaseTexture): boolean;
  62700. dispose(forceDisposeEffect?: boolean): void;
  62701. clone(name: string): FluentMaterial;
  62702. serialize(): any;
  62703. getClassName(): string;
  62704. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  62705. }
  62706. }
  62707. declare module BABYLON.GUI {
  62708. /**
  62709. * Class used to create a holographic button in 3D
  62710. */
  62711. export class HolographicButton extends Button3D {
  62712. private _backPlate;
  62713. private _textPlate;
  62714. private _frontPlate;
  62715. private _text;
  62716. private _imageUrl;
  62717. private _shareMaterials;
  62718. private _frontMaterial;
  62719. private _backMaterial;
  62720. private _plateMaterial;
  62721. private _pickedPointObserver;
  62722. private _tooltipFade;
  62723. private _tooltipTextBlock;
  62724. private _tooltipTexture;
  62725. private _tooltipMesh;
  62726. private _tooltipHoverObserver;
  62727. private _tooltipOutObserver;
  62728. private _disposeTooltip;
  62729. /**
  62730. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  62731. */
  62732. tooltipText: BABYLON.Nullable<string>;
  62733. /**
  62734. * Gets or sets text for the button
  62735. */
  62736. text: string;
  62737. /**
  62738. * Gets or sets the image url for the button
  62739. */
  62740. imageUrl: string;
  62741. /**
  62742. * Gets the back material used by this button
  62743. */
  62744. readonly backMaterial: FluentMaterial;
  62745. /**
  62746. * Gets the front material used by this button
  62747. */
  62748. readonly frontMaterial: FluentMaterial;
  62749. /**
  62750. * Gets the plate material used by this button
  62751. */
  62752. readonly plateMaterial: BABYLON.StandardMaterial;
  62753. /**
  62754. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  62755. */
  62756. readonly shareMaterials: boolean;
  62757. /**
  62758. * Creates a new button
  62759. * @param name defines the control name
  62760. */
  62761. constructor(name?: string, shareMaterials?: boolean);
  62762. protected _getTypeName(): string;
  62763. private _rebuildContent;
  62764. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62765. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  62766. private _createBackMaterial;
  62767. private _createFrontMaterial;
  62768. private _createPlateMaterial;
  62769. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  62770. /**
  62771. * Releases all associated resources
  62772. */
  62773. dispose(): void;
  62774. }
  62775. }
  62776. declare module BABYLON.GUI {
  62777. /**
  62778. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  62779. */
  62780. export class MeshButton3D extends Button3D {
  62781. /** @hidden */
  62782. protected _currentMesh: BABYLON.Mesh;
  62783. /**
  62784. * Creates a new 3D button based on a mesh
  62785. * @param mesh mesh to become a 3D button
  62786. * @param name defines the control name
  62787. */
  62788. constructor(mesh: BABYLON.Mesh, name?: string);
  62789. protected _getTypeName(): string;
  62790. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62791. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62792. }
  62793. }
  62794. declare module BABYLON.GUI {
  62795. /**
  62796. * Class used to create a container panel deployed on the surface of a plane
  62797. */
  62798. export class PlanePanel extends VolumeBasedPanel {
  62799. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62800. }
  62801. }
  62802. declare module BABYLON.GUI {
  62803. /**
  62804. * Class used to create a container panel where items get randomized planar mapping
  62805. */
  62806. export class ScatterPanel extends VolumeBasedPanel {
  62807. private _iteration;
  62808. /**
  62809. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  62810. */
  62811. iteration: BABYLON.float;
  62812. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62813. private _scatterMapping;
  62814. protected _finalProcessing(): void;
  62815. }
  62816. }
  62817. declare module BABYLON.GUI {
  62818. /**
  62819. * Class used to create a container panel deployed on the surface of a sphere
  62820. */
  62821. export class SpherePanel extends VolumeBasedPanel {
  62822. private _radius;
  62823. /**
  62824. * Gets or sets the radius of the sphere where to project controls (5 by default)
  62825. */
  62826. radius: BABYLON.float;
  62827. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62828. private _sphericalMapping;
  62829. }
  62830. }
  62831. declare module BABYLON.GUI {
  62832. /**
  62833. * Class used to create a stack panel in 3D on XY plane
  62834. */
  62835. export class StackPanel3D extends Container3D {
  62836. private _isVertical;
  62837. /**
  62838. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  62839. */
  62840. isVertical: boolean;
  62841. /**
  62842. * Gets or sets the distance between elements
  62843. */
  62844. margin: number;
  62845. /**
  62846. * Creates new StackPanel
  62847. * @param isVertical
  62848. */
  62849. constructor(isVertical?: boolean);
  62850. protected _arrangeChildren(): void;
  62851. }
  62852. }
  62853. declare module BABYLON {
  62854. /**
  62855. * Mode that determines the coordinate system to use.
  62856. */
  62857. export enum GLTFLoaderCoordinateSystemMode {
  62858. /**
  62859. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  62860. */
  62861. AUTO = 0,
  62862. /**
  62863. * Sets the useRightHandedSystem flag on the scene.
  62864. */
  62865. FORCE_RIGHT_HANDED = 1
  62866. }
  62867. /**
  62868. * Mode that determines what animations will start.
  62869. */
  62870. export enum GLTFLoaderAnimationStartMode {
  62871. /**
  62872. * No animation will start.
  62873. */
  62874. NONE = 0,
  62875. /**
  62876. * The first animation will start.
  62877. */
  62878. FIRST = 1,
  62879. /**
  62880. * All animations will start.
  62881. */
  62882. ALL = 2
  62883. }
  62884. /**
  62885. * Interface that contains the data for the glTF asset.
  62886. */
  62887. export interface IGLTFLoaderData {
  62888. /**
  62889. * Object that represents the glTF JSON.
  62890. */
  62891. json: Object;
  62892. /**
  62893. * The BIN chunk of a binary glTF.
  62894. */
  62895. bin: Nullable<ArrayBufferView>;
  62896. }
  62897. /**
  62898. * Interface for extending the loader.
  62899. */
  62900. export interface IGLTFLoaderExtension {
  62901. /**
  62902. * The name of this extension.
  62903. */
  62904. readonly name: string;
  62905. /**
  62906. * Defines whether this extension is enabled.
  62907. */
  62908. enabled: boolean;
  62909. }
  62910. /**
  62911. * Loader state.
  62912. */
  62913. export enum GLTFLoaderState {
  62914. /**
  62915. * The asset is loading.
  62916. */
  62917. LOADING = 0,
  62918. /**
  62919. * The asset is ready for rendering.
  62920. */
  62921. READY = 1,
  62922. /**
  62923. * The asset is completely loaded.
  62924. */
  62925. COMPLETE = 2
  62926. }
  62927. /** @hidden */
  62928. export interface IGLTFLoader extends IDisposable {
  62929. readonly state: Nullable<GLTFLoaderState>;
  62930. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  62931. meshes: AbstractMesh[];
  62932. particleSystems: IParticleSystem[];
  62933. skeletons: Skeleton[];
  62934. animationGroups: AnimationGroup[];
  62935. }>;
  62936. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  62937. }
  62938. /**
  62939. * File loader for loading glTF files into a scene.
  62940. */
  62941. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  62942. /** @hidden */
  62943. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  62944. /** @hidden */
  62945. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  62946. /**
  62947. * Raised when the asset has been parsed
  62948. */
  62949. onParsedObservable: Observable<IGLTFLoaderData>;
  62950. private _onParsedObserver;
  62951. /**
  62952. * Raised when the asset has been parsed
  62953. */
  62954. onParsed: (loaderData: IGLTFLoaderData) => void;
  62955. /**
  62956. * 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.
  62957. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  62958. * Defaults to true.
  62959. * @hidden
  62960. */
  62961. static IncrementalLoading: boolean;
  62962. /**
  62963. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  62964. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  62965. * @hidden
  62966. */
  62967. static HomogeneousCoordinates: boolean;
  62968. /**
  62969. * The coordinate system mode. Defaults to AUTO.
  62970. */
  62971. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  62972. /**
  62973. * The animation start mode. Defaults to FIRST.
  62974. */
  62975. animationStartMode: GLTFLoaderAnimationStartMode;
  62976. /**
  62977. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  62978. */
  62979. compileMaterials: boolean;
  62980. /**
  62981. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  62982. */
  62983. useClipPlane: boolean;
  62984. /**
  62985. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  62986. */
  62987. compileShadowGenerators: boolean;
  62988. /**
  62989. * Defines if the Alpha blended materials are only applied as coverage.
  62990. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  62991. * If true, no extra effects are applied to transparent pixels.
  62992. */
  62993. transparencyAsCoverage: boolean;
  62994. /**
  62995. * Function called before loading a url referenced by the asset.
  62996. */
  62997. preprocessUrlAsync: (url: string) => Promise<string>;
  62998. /**
  62999. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  63000. */
  63001. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  63002. private _onMeshLoadedObserver;
  63003. /**
  63004. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  63005. */
  63006. onMeshLoaded: (mesh: AbstractMesh) => void;
  63007. /**
  63008. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  63009. */
  63010. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  63011. private _onTextureLoadedObserver;
  63012. /**
  63013. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  63014. */
  63015. onTextureLoaded: (texture: BaseTexture) => void;
  63016. /**
  63017. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  63018. */
  63019. readonly onMaterialLoadedObservable: Observable<Material>;
  63020. private _onMaterialLoadedObserver;
  63021. /**
  63022. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  63023. */
  63024. onMaterialLoaded: (material: Material) => void;
  63025. /**
  63026. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  63027. */
  63028. readonly onCameraLoadedObservable: Observable<Camera>;
  63029. private _onCameraLoadedObserver;
  63030. /**
  63031. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  63032. */
  63033. onCameraLoaded: (camera: Camera) => void;
  63034. /**
  63035. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  63036. * For assets with LODs, raised when all of the LODs are complete.
  63037. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63038. */
  63039. readonly onCompleteObservable: Observable<void>;
  63040. private _onCompleteObserver;
  63041. /**
  63042. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  63043. * For assets with LODs, raised when all of the LODs are complete.
  63044. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63045. */
  63046. onComplete: () => void;
  63047. /**
  63048. * Observable raised when an error occurs.
  63049. */
  63050. readonly onErrorObservable: Observable<any>;
  63051. private _onErrorObserver;
  63052. /**
  63053. * Callback raised when an error occurs.
  63054. */
  63055. onError: (reason: any) => void;
  63056. /**
  63057. * Observable raised after the loader is disposed.
  63058. */
  63059. readonly onDisposeObservable: Observable<void>;
  63060. private _onDisposeObserver;
  63061. /**
  63062. * Callback raised after the loader is disposed.
  63063. */
  63064. onDispose: () => void;
  63065. /**
  63066. * Observable raised after a loader extension is created.
  63067. * Set additional options for a loader extension in this event.
  63068. */
  63069. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  63070. private _onExtensionLoadedObserver;
  63071. /**
  63072. * Callback raised after a loader extension is created.
  63073. */
  63074. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  63075. /**
  63076. * Defines if the loader logging is enabled.
  63077. */
  63078. loggingEnabled: boolean;
  63079. /**
  63080. * Defines if the loader should capture performance counters.
  63081. */
  63082. capturePerformanceCounters: boolean;
  63083. /**
  63084. * Defines if the loader should validate the asset.
  63085. */
  63086. validate: boolean;
  63087. /**
  63088. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  63089. */
  63090. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  63091. private _onValidatedObserver;
  63092. /**
  63093. * Callback raised after a loader extension is created.
  63094. */
  63095. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  63096. private _loader;
  63097. /**
  63098. * Name of the loader ("gltf")
  63099. */
  63100. name: string;
  63101. /**
  63102. * Supported file extensions of the loader (.gltf, .glb)
  63103. */
  63104. extensions: ISceneLoaderPluginExtensions;
  63105. /**
  63106. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  63107. */
  63108. dispose(): void;
  63109. /** @hidden */
  63110. _clear(): void;
  63111. /**
  63112. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  63113. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  63114. * @param scene the scene the meshes should be added to
  63115. * @param data the glTF data to load
  63116. * @param rootUrl root url to load from
  63117. * @param onProgress event that fires when loading progress has occured
  63118. * @param fileName Defines the name of the file to load
  63119. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  63120. */
  63121. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  63122. meshes: AbstractMesh[];
  63123. particleSystems: IParticleSystem[];
  63124. skeletons: Skeleton[];
  63125. animationGroups: AnimationGroup[];
  63126. }>;
  63127. /**
  63128. * Imports all objects from the loaded glTF data and adds them to the scene
  63129. * @param scene the scene the objects should be added to
  63130. * @param data the glTF data to load
  63131. * @param rootUrl root url to load from
  63132. * @param onProgress event that fires when loading progress has occured
  63133. * @param fileName Defines the name of the file to load
  63134. * @returns a promise which completes when objects have been loaded to the scene
  63135. */
  63136. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  63137. /**
  63138. * Load into an asset container.
  63139. * @param scene The scene to load into
  63140. * @param data The data to import
  63141. * @param rootUrl The root url for scene and resources
  63142. * @param onProgress The callback when the load progresses
  63143. * @param fileName Defines the name of the file to load
  63144. * @returns The loaded asset container
  63145. */
  63146. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  63147. /**
  63148. * If the data string can be loaded directly.
  63149. * @param data string contianing the file data
  63150. * @returns if the data can be loaded directly
  63151. */
  63152. canDirectLoad(data: string): boolean;
  63153. /**
  63154. * Rewrites a url by combining a root url and response url.
  63155. */
  63156. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  63157. /**
  63158. * Instantiates a glTF file loader plugin.
  63159. * @returns the created plugin
  63160. */
  63161. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  63162. /**
  63163. * The loader state or null if the loader is not active.
  63164. */
  63165. readonly loaderState: Nullable<GLTFLoaderState>;
  63166. /**
  63167. * Returns a promise that resolves when the asset is completely loaded.
  63168. * @returns a promise that resolves when the asset is completely loaded.
  63169. */
  63170. whenCompleteAsync(): Promise<void>;
  63171. private _parseAsync;
  63172. private _validateAsync;
  63173. private _getLoader;
  63174. private _unpackBinary;
  63175. private _unpackBinaryV1;
  63176. private _unpackBinaryV2;
  63177. private static _parseVersion;
  63178. private static _compareVersion;
  63179. private static _decodeBufferToText;
  63180. private static readonly _logSpaces;
  63181. private _logIndentLevel;
  63182. private _loggingEnabled;
  63183. /** @hidden */
  63184. _log: (message: string) => void;
  63185. /** @hidden */
  63186. _logOpen(message: string): void;
  63187. /** @hidden */
  63188. _logClose(): void;
  63189. private _logEnabled;
  63190. private _logDisabled;
  63191. private _capturePerformanceCounters;
  63192. /** @hidden */
  63193. _startPerformanceCounter: (counterName: string) => void;
  63194. /** @hidden */
  63195. _endPerformanceCounter: (counterName: string) => void;
  63196. private _startPerformanceCounterEnabled;
  63197. private _startPerformanceCounterDisabled;
  63198. private _endPerformanceCounterEnabled;
  63199. private _endPerformanceCounterDisabled;
  63200. }
  63201. }
  63202. declare module BABYLON.GLTF1 {
  63203. /**
  63204. * Enums
  63205. * @hidden
  63206. */
  63207. export enum EComponentType {
  63208. BYTE = 5120,
  63209. UNSIGNED_BYTE = 5121,
  63210. SHORT = 5122,
  63211. UNSIGNED_SHORT = 5123,
  63212. FLOAT = 5126
  63213. }
  63214. /** @hidden */
  63215. export enum EShaderType {
  63216. FRAGMENT = 35632,
  63217. VERTEX = 35633
  63218. }
  63219. /** @hidden */
  63220. export enum EParameterType {
  63221. BYTE = 5120,
  63222. UNSIGNED_BYTE = 5121,
  63223. SHORT = 5122,
  63224. UNSIGNED_SHORT = 5123,
  63225. INT = 5124,
  63226. UNSIGNED_INT = 5125,
  63227. FLOAT = 5126,
  63228. FLOAT_VEC2 = 35664,
  63229. FLOAT_VEC3 = 35665,
  63230. FLOAT_VEC4 = 35666,
  63231. INT_VEC2 = 35667,
  63232. INT_VEC3 = 35668,
  63233. INT_VEC4 = 35669,
  63234. BOOL = 35670,
  63235. BOOL_VEC2 = 35671,
  63236. BOOL_VEC3 = 35672,
  63237. BOOL_VEC4 = 35673,
  63238. FLOAT_MAT2 = 35674,
  63239. FLOAT_MAT3 = 35675,
  63240. FLOAT_MAT4 = 35676,
  63241. SAMPLER_2D = 35678
  63242. }
  63243. /** @hidden */
  63244. export enum ETextureWrapMode {
  63245. CLAMP_TO_EDGE = 33071,
  63246. MIRRORED_REPEAT = 33648,
  63247. REPEAT = 10497
  63248. }
  63249. /** @hidden */
  63250. export enum ETextureFilterType {
  63251. NEAREST = 9728,
  63252. LINEAR = 9728,
  63253. NEAREST_MIPMAP_NEAREST = 9984,
  63254. LINEAR_MIPMAP_NEAREST = 9985,
  63255. NEAREST_MIPMAP_LINEAR = 9986,
  63256. LINEAR_MIPMAP_LINEAR = 9987
  63257. }
  63258. /** @hidden */
  63259. export enum ETextureFormat {
  63260. ALPHA = 6406,
  63261. RGB = 6407,
  63262. RGBA = 6408,
  63263. LUMINANCE = 6409,
  63264. LUMINANCE_ALPHA = 6410
  63265. }
  63266. /** @hidden */
  63267. export enum ECullingType {
  63268. FRONT = 1028,
  63269. BACK = 1029,
  63270. FRONT_AND_BACK = 1032
  63271. }
  63272. /** @hidden */
  63273. export enum EBlendingFunction {
  63274. ZERO = 0,
  63275. ONE = 1,
  63276. SRC_COLOR = 768,
  63277. ONE_MINUS_SRC_COLOR = 769,
  63278. DST_COLOR = 774,
  63279. ONE_MINUS_DST_COLOR = 775,
  63280. SRC_ALPHA = 770,
  63281. ONE_MINUS_SRC_ALPHA = 771,
  63282. DST_ALPHA = 772,
  63283. ONE_MINUS_DST_ALPHA = 773,
  63284. CONSTANT_COLOR = 32769,
  63285. ONE_MINUS_CONSTANT_COLOR = 32770,
  63286. CONSTANT_ALPHA = 32771,
  63287. ONE_MINUS_CONSTANT_ALPHA = 32772,
  63288. SRC_ALPHA_SATURATE = 776
  63289. }
  63290. /** @hidden */
  63291. export interface IGLTFProperty {
  63292. extensions?: {
  63293. [key: string]: any;
  63294. };
  63295. extras?: Object;
  63296. }
  63297. /** @hidden */
  63298. export interface IGLTFChildRootProperty extends IGLTFProperty {
  63299. name?: string;
  63300. }
  63301. /** @hidden */
  63302. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  63303. bufferView: string;
  63304. byteOffset: number;
  63305. byteStride: number;
  63306. count: number;
  63307. type: string;
  63308. componentType: EComponentType;
  63309. max?: number[];
  63310. min?: number[];
  63311. name?: string;
  63312. }
  63313. /** @hidden */
  63314. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  63315. buffer: string;
  63316. byteOffset: number;
  63317. byteLength: number;
  63318. byteStride: number;
  63319. target?: number;
  63320. }
  63321. /** @hidden */
  63322. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  63323. uri: string;
  63324. byteLength?: number;
  63325. type?: string;
  63326. }
  63327. /** @hidden */
  63328. export interface IGLTFShader extends IGLTFChildRootProperty {
  63329. uri: string;
  63330. type: EShaderType;
  63331. }
  63332. /** @hidden */
  63333. export interface IGLTFProgram extends IGLTFChildRootProperty {
  63334. attributes: string[];
  63335. fragmentShader: string;
  63336. vertexShader: string;
  63337. }
  63338. /** @hidden */
  63339. export interface IGLTFTechniqueParameter {
  63340. type: number;
  63341. count?: number;
  63342. semantic?: string;
  63343. node?: string;
  63344. value?: number | boolean | string | Array<any>;
  63345. source?: string;
  63346. babylonValue?: any;
  63347. }
  63348. /** @hidden */
  63349. export interface IGLTFTechniqueCommonProfile {
  63350. lightingModel: string;
  63351. texcoordBindings: Object;
  63352. parameters?: Array<any>;
  63353. }
  63354. /** @hidden */
  63355. export interface IGLTFTechniqueStatesFunctions {
  63356. blendColor?: number[];
  63357. blendEquationSeparate?: number[];
  63358. blendFuncSeparate?: number[];
  63359. colorMask: boolean[];
  63360. cullFace: number[];
  63361. }
  63362. /** @hidden */
  63363. export interface IGLTFTechniqueStates {
  63364. enable: number[];
  63365. functions: IGLTFTechniqueStatesFunctions;
  63366. }
  63367. /** @hidden */
  63368. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  63369. parameters: {
  63370. [key: string]: IGLTFTechniqueParameter;
  63371. };
  63372. program: string;
  63373. attributes: {
  63374. [key: string]: string;
  63375. };
  63376. uniforms: {
  63377. [key: string]: string;
  63378. };
  63379. states: IGLTFTechniqueStates;
  63380. }
  63381. /** @hidden */
  63382. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  63383. technique?: string;
  63384. values: string[];
  63385. }
  63386. /** @hidden */
  63387. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  63388. attributes: {
  63389. [key: string]: string;
  63390. };
  63391. indices: string;
  63392. material: string;
  63393. mode?: number;
  63394. }
  63395. /** @hidden */
  63396. export interface IGLTFMesh extends IGLTFChildRootProperty {
  63397. primitives: IGLTFMeshPrimitive[];
  63398. }
  63399. /** @hidden */
  63400. export interface IGLTFImage extends IGLTFChildRootProperty {
  63401. uri: string;
  63402. }
  63403. /** @hidden */
  63404. export interface IGLTFSampler extends IGLTFChildRootProperty {
  63405. magFilter?: number;
  63406. minFilter?: number;
  63407. wrapS?: number;
  63408. wrapT?: number;
  63409. }
  63410. /** @hidden */
  63411. export interface IGLTFTexture extends IGLTFChildRootProperty {
  63412. sampler: string;
  63413. source: string;
  63414. format?: ETextureFormat;
  63415. internalFormat?: ETextureFormat;
  63416. target?: number;
  63417. type?: number;
  63418. babylonTexture?: Texture;
  63419. }
  63420. /** @hidden */
  63421. export interface IGLTFAmbienLight {
  63422. color?: number[];
  63423. }
  63424. /** @hidden */
  63425. export interface IGLTFDirectionalLight {
  63426. color?: number[];
  63427. }
  63428. /** @hidden */
  63429. export interface IGLTFPointLight {
  63430. color?: number[];
  63431. constantAttenuation?: number;
  63432. linearAttenuation?: number;
  63433. quadraticAttenuation?: number;
  63434. }
  63435. /** @hidden */
  63436. export interface IGLTFSpotLight {
  63437. color?: number[];
  63438. constantAttenuation?: number;
  63439. fallOfAngle?: number;
  63440. fallOffExponent?: number;
  63441. linearAttenuation?: number;
  63442. quadraticAttenuation?: number;
  63443. }
  63444. /** @hidden */
  63445. export interface IGLTFLight extends IGLTFChildRootProperty {
  63446. type: string;
  63447. }
  63448. /** @hidden */
  63449. export interface IGLTFCameraOrthographic {
  63450. xmag: number;
  63451. ymag: number;
  63452. zfar: number;
  63453. znear: number;
  63454. }
  63455. /** @hidden */
  63456. export interface IGLTFCameraPerspective {
  63457. aspectRatio: number;
  63458. yfov: number;
  63459. zfar: number;
  63460. znear: number;
  63461. }
  63462. /** @hidden */
  63463. export interface IGLTFCamera extends IGLTFChildRootProperty {
  63464. type: string;
  63465. }
  63466. /** @hidden */
  63467. export interface IGLTFAnimationChannelTarget {
  63468. id: string;
  63469. path: string;
  63470. }
  63471. /** @hidden */
  63472. export interface IGLTFAnimationChannel {
  63473. sampler: string;
  63474. target: IGLTFAnimationChannelTarget;
  63475. }
  63476. /** @hidden */
  63477. export interface IGLTFAnimationSampler {
  63478. input: string;
  63479. output: string;
  63480. interpolation?: string;
  63481. }
  63482. /** @hidden */
  63483. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  63484. channels?: IGLTFAnimationChannel[];
  63485. parameters?: {
  63486. [key: string]: string;
  63487. };
  63488. samplers?: {
  63489. [key: string]: IGLTFAnimationSampler;
  63490. };
  63491. }
  63492. /** @hidden */
  63493. export interface IGLTFNodeInstanceSkin {
  63494. skeletons: string[];
  63495. skin: string;
  63496. meshes: string[];
  63497. }
  63498. /** @hidden */
  63499. export interface IGLTFSkins extends IGLTFChildRootProperty {
  63500. bindShapeMatrix: number[];
  63501. inverseBindMatrices: string;
  63502. jointNames: string[];
  63503. babylonSkeleton?: Skeleton;
  63504. }
  63505. /** @hidden */
  63506. export interface IGLTFNode extends IGLTFChildRootProperty {
  63507. camera?: string;
  63508. children: string[];
  63509. skin?: string;
  63510. jointName?: string;
  63511. light?: string;
  63512. matrix: number[];
  63513. mesh?: string;
  63514. meshes?: string[];
  63515. rotation?: number[];
  63516. scale?: number[];
  63517. translation?: number[];
  63518. babylonNode?: Node;
  63519. }
  63520. /** @hidden */
  63521. export interface IGLTFScene extends IGLTFChildRootProperty {
  63522. nodes: string[];
  63523. }
  63524. /** @hidden */
  63525. export interface IGLTFRuntime {
  63526. extensions: {
  63527. [key: string]: any;
  63528. };
  63529. accessors: {
  63530. [key: string]: IGLTFAccessor;
  63531. };
  63532. buffers: {
  63533. [key: string]: IGLTFBuffer;
  63534. };
  63535. bufferViews: {
  63536. [key: string]: IGLTFBufferView;
  63537. };
  63538. meshes: {
  63539. [key: string]: IGLTFMesh;
  63540. };
  63541. lights: {
  63542. [key: string]: IGLTFLight;
  63543. };
  63544. cameras: {
  63545. [key: string]: IGLTFCamera;
  63546. };
  63547. nodes: {
  63548. [key: string]: IGLTFNode;
  63549. };
  63550. images: {
  63551. [key: string]: IGLTFImage;
  63552. };
  63553. textures: {
  63554. [key: string]: IGLTFTexture;
  63555. };
  63556. shaders: {
  63557. [key: string]: IGLTFShader;
  63558. };
  63559. programs: {
  63560. [key: string]: IGLTFProgram;
  63561. };
  63562. samplers: {
  63563. [key: string]: IGLTFSampler;
  63564. };
  63565. techniques: {
  63566. [key: string]: IGLTFTechnique;
  63567. };
  63568. materials: {
  63569. [key: string]: IGLTFMaterial;
  63570. };
  63571. animations: {
  63572. [key: string]: IGLTFAnimation;
  63573. };
  63574. skins: {
  63575. [key: string]: IGLTFSkins;
  63576. };
  63577. currentScene?: Object;
  63578. scenes: {
  63579. [key: string]: IGLTFScene;
  63580. };
  63581. extensionsUsed: string[];
  63582. extensionsRequired?: string[];
  63583. buffersCount: number;
  63584. shaderscount: number;
  63585. scene: Scene;
  63586. rootUrl: string;
  63587. loadedBufferCount: number;
  63588. loadedBufferViews: {
  63589. [name: string]: ArrayBufferView;
  63590. };
  63591. loadedShaderCount: number;
  63592. importOnlyMeshes: boolean;
  63593. importMeshesNames?: string[];
  63594. dummyNodes: Node[];
  63595. }
  63596. /** @hidden */
  63597. export interface INodeToRoot {
  63598. bone: Bone;
  63599. node: IGLTFNode;
  63600. id: string;
  63601. }
  63602. /** @hidden */
  63603. export interface IJointNode {
  63604. node: IGLTFNode;
  63605. id: string;
  63606. }
  63607. }
  63608. declare module BABYLON.GLTF1 {
  63609. /**
  63610. * Utils functions for GLTF
  63611. * @hidden
  63612. */
  63613. export class GLTFUtils {
  63614. /**
  63615. * Sets the given "parameter" matrix
  63616. * @param scene: the Scene object
  63617. * @param source: the source node where to pick the matrix
  63618. * @param parameter: the GLTF technique parameter
  63619. * @param uniformName: the name of the shader's uniform
  63620. * @param shaderMaterial: the shader material
  63621. */
  63622. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  63623. /**
  63624. * Sets the given "parameter" matrix
  63625. * @param shaderMaterial: the shader material
  63626. * @param uniform: the name of the shader's uniform
  63627. * @param value: the value of the uniform
  63628. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  63629. */
  63630. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  63631. /**
  63632. * Returns the wrap mode of the texture
  63633. * @param mode: the mode value
  63634. */
  63635. static GetWrapMode(mode: number): number;
  63636. /**
  63637. * Returns the byte stride giving an accessor
  63638. * @param accessor: the GLTF accessor objet
  63639. */
  63640. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  63641. /**
  63642. * Returns the texture filter mode giving a mode value
  63643. * @param mode: the filter mode value
  63644. */
  63645. static GetTextureFilterMode(mode: number): ETextureFilterType;
  63646. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  63647. /**
  63648. * Returns a buffer from its accessor
  63649. * @param gltfRuntime: the GLTF runtime
  63650. * @param accessor: the GLTF accessor
  63651. */
  63652. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  63653. /**
  63654. * Decodes a buffer view into a string
  63655. * @param view: the buffer view
  63656. */
  63657. static DecodeBufferToText(view: ArrayBufferView): string;
  63658. /**
  63659. * Returns the default material of gltf. Related to
  63660. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  63661. * @param scene: the Babylon.js scene
  63662. */
  63663. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  63664. private static _DefaultMaterial;
  63665. }
  63666. }
  63667. declare module BABYLON.GLTF1 {
  63668. /**
  63669. * Implementation of the base glTF spec
  63670. * @hidden
  63671. */
  63672. export class GLTFLoaderBase {
  63673. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  63674. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  63675. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  63676. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  63677. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  63678. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  63679. }
  63680. /**
  63681. * glTF V1 Loader
  63682. * @hidden
  63683. */
  63684. export class GLTFLoader implements IGLTFLoader {
  63685. static Extensions: {
  63686. [name: string]: GLTFLoaderExtension;
  63687. };
  63688. static RegisterExtension(extension: GLTFLoaderExtension): void;
  63689. state: Nullable<GLTFLoaderState>;
  63690. dispose(): void;
  63691. private _importMeshAsync;
  63692. /**
  63693. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  63694. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  63695. * @param scene the scene the meshes should be added to
  63696. * @param data gltf data containing information of the meshes in a loaded file
  63697. * @param rootUrl root url to load from
  63698. * @param onProgress event that fires when loading progress has occured
  63699. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  63700. */
  63701. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  63702. meshes: AbstractMesh[];
  63703. particleSystems: IParticleSystem[];
  63704. skeletons: Skeleton[];
  63705. animationGroups: AnimationGroup[];
  63706. }>;
  63707. private _loadAsync;
  63708. /**
  63709. * Imports all objects from a loaded gltf file and adds them to the scene
  63710. * @param scene the scene the objects should be added to
  63711. * @param data gltf data containing information of the meshes in a loaded file
  63712. * @param rootUrl root url to load from
  63713. * @param onProgress event that fires when loading progress has occured
  63714. * @returns a promise which completes when objects have been loaded to the scene
  63715. */
  63716. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  63717. private _loadShadersAsync;
  63718. private _loadBuffersAsync;
  63719. private _createNodes;
  63720. }
  63721. /** @hidden */
  63722. export abstract class GLTFLoaderExtension {
  63723. private _name;
  63724. constructor(name: string);
  63725. readonly name: string;
  63726. /**
  63727. * Defines an override for loading the runtime
  63728. * Return true to stop further extensions from loading the runtime
  63729. */
  63730. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  63731. /**
  63732. * Defines an onverride for creating gltf runtime
  63733. * Return true to stop further extensions from creating the runtime
  63734. */
  63735. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  63736. /**
  63737. * Defines an override for loading buffers
  63738. * Return true to stop further extensions from loading this buffer
  63739. */
  63740. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  63741. /**
  63742. * Defines an override for loading texture buffers
  63743. * Return true to stop further extensions from loading this texture data
  63744. */
  63745. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63746. /**
  63747. * Defines an override for creating textures
  63748. * Return true to stop further extensions from loading this texture
  63749. */
  63750. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  63751. /**
  63752. * Defines an override for loading shader strings
  63753. * Return true to stop further extensions from loading this shader data
  63754. */
  63755. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  63756. /**
  63757. * Defines an override for loading materials
  63758. * Return true to stop further extensions from loading this material
  63759. */
  63760. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  63761. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  63762. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  63763. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  63764. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  63765. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  63766. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  63767. private static LoadTextureBufferAsync;
  63768. private static CreateTextureAsync;
  63769. private static ApplyExtensions;
  63770. }
  63771. }
  63772. declare module BABYLON.GLTF1 {
  63773. /** @hidden */
  63774. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  63775. private _bin;
  63776. constructor();
  63777. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  63778. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63779. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63780. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  63781. }
  63782. }
  63783. declare module BABYLON.GLTF1 {
  63784. /** @hidden */
  63785. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  63786. constructor();
  63787. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  63788. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  63789. private _loadTexture;
  63790. }
  63791. }
  63792. declare module BABYLON.GLTF2.Loader {
  63793. /**
  63794. * Loader interface with an index field.
  63795. */
  63796. export interface IArrayItem {
  63797. /**
  63798. * The index of this item in the array.
  63799. */
  63800. index: number;
  63801. }
  63802. /**
  63803. * Loader interface with additional members.
  63804. */
  63805. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  63806. /** @hidden */
  63807. _data?: Promise<ArrayBufferView>;
  63808. /** @hidden */
  63809. _babylonVertexBuffer?: Promise<VertexBuffer>;
  63810. }
  63811. /**
  63812. * Loader interface with additional members.
  63813. */
  63814. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  63815. }
  63816. /** @hidden */
  63817. export interface _IAnimationSamplerData {
  63818. input: Float32Array;
  63819. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  63820. output: Float32Array;
  63821. }
  63822. /**
  63823. * Loader interface with additional members.
  63824. */
  63825. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  63826. /** @hidden */
  63827. _data?: Promise<_IAnimationSamplerData>;
  63828. }
  63829. /**
  63830. * Loader interface with additional members.
  63831. */
  63832. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  63833. channels: IAnimationChannel[];
  63834. samplers: IAnimationSampler[];
  63835. /** @hidden */
  63836. _babylonAnimationGroup?: AnimationGroup;
  63837. }
  63838. /**
  63839. * Loader interface with additional members.
  63840. */
  63841. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  63842. /** @hidden */
  63843. _data?: Promise<ArrayBufferView>;
  63844. }
  63845. /**
  63846. * Loader interface with additional members.
  63847. */
  63848. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  63849. /** @hidden */
  63850. _data?: Promise<ArrayBufferView>;
  63851. /** @hidden */
  63852. _babylonBuffer?: Promise<Buffer>;
  63853. }
  63854. /**
  63855. * Loader interface with additional members.
  63856. */
  63857. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  63858. }
  63859. /**
  63860. * Loader interface with additional members.
  63861. */
  63862. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  63863. /** @hidden */
  63864. _data?: Promise<ArrayBufferView>;
  63865. }
  63866. /**
  63867. * Loader interface with additional members.
  63868. */
  63869. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  63870. }
  63871. /**
  63872. * Loader interface with additional members.
  63873. */
  63874. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  63875. }
  63876. /**
  63877. * Loader interface with additional members.
  63878. */
  63879. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  63880. baseColorTexture?: ITextureInfo;
  63881. metallicRoughnessTexture?: ITextureInfo;
  63882. }
  63883. /**
  63884. * Loader interface with additional members.
  63885. */
  63886. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  63887. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  63888. normalTexture?: IMaterialNormalTextureInfo;
  63889. occlusionTexture?: IMaterialOcclusionTextureInfo;
  63890. emissiveTexture?: ITextureInfo;
  63891. /** @hidden */
  63892. _data?: {
  63893. [babylonDrawMode: number]: {
  63894. babylonMaterial: Material;
  63895. babylonMeshes: AbstractMesh[];
  63896. promise: Promise<void>;
  63897. };
  63898. };
  63899. }
  63900. /**
  63901. * Loader interface with additional members.
  63902. */
  63903. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  63904. primitives: IMeshPrimitive[];
  63905. }
  63906. /**
  63907. * Loader interface with additional members.
  63908. */
  63909. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  63910. /** @hidden */
  63911. _instanceData?: {
  63912. babylonSourceMesh: Mesh;
  63913. promise: Promise<any>;
  63914. };
  63915. }
  63916. /**
  63917. * Loader interface with additional members.
  63918. */
  63919. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  63920. /**
  63921. * The parent glTF node.
  63922. */
  63923. parent?: INode;
  63924. /** @hidden */
  63925. _babylonTransformNode?: TransformNode;
  63926. /** @hidden */
  63927. _primitiveBabylonMeshes?: AbstractMesh[];
  63928. /** @hidden */
  63929. _babylonBones?: Bone[];
  63930. /** @hidden */
  63931. _numMorphTargets?: number;
  63932. }
  63933. /** @hidden */
  63934. export interface _ISamplerData {
  63935. noMipMaps: boolean;
  63936. samplingMode: number;
  63937. wrapU: number;
  63938. wrapV: number;
  63939. }
  63940. /**
  63941. * Loader interface with additional members.
  63942. */
  63943. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  63944. /** @hidden */
  63945. _data?: _ISamplerData;
  63946. }
  63947. /**
  63948. * Loader interface with additional members.
  63949. */
  63950. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  63951. }
  63952. /**
  63953. * Loader interface with additional members.
  63954. */
  63955. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  63956. /** @hidden */
  63957. _data?: {
  63958. babylonSkeleton: Skeleton;
  63959. promise: Promise<void>;
  63960. };
  63961. }
  63962. /**
  63963. * Loader interface with additional members.
  63964. */
  63965. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  63966. }
  63967. /**
  63968. * Loader interface with additional members.
  63969. */
  63970. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  63971. }
  63972. /**
  63973. * Loader interface with additional members.
  63974. */
  63975. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  63976. accessors?: IAccessor[];
  63977. animations?: IAnimation[];
  63978. buffers?: IBuffer[];
  63979. bufferViews?: IBufferView[];
  63980. cameras?: ICamera[];
  63981. images?: IImage[];
  63982. materials?: IMaterial[];
  63983. meshes?: IMesh[];
  63984. nodes?: INode[];
  63985. samplers?: ISampler[];
  63986. scenes?: IScene[];
  63987. skins?: ISkin[];
  63988. textures?: ITexture[];
  63989. }
  63990. }
  63991. declare module BABYLON.GLTF2 {
  63992. /**
  63993. * Interface for a glTF loader extension.
  63994. */
  63995. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  63996. /**
  63997. * Called after the loader state changes to LOADING.
  63998. */
  63999. onLoading?(): void;
  64000. /**
  64001. * Called after the loader state changes to READY.
  64002. */
  64003. onReady?(): void;
  64004. /**
  64005. * Define this method to modify the default behavior when loading scenes.
  64006. * @param context The context when loading the asset
  64007. * @param scene The glTF scene property
  64008. * @returns A promise that resolves when the load is complete or null if not handled
  64009. */
  64010. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  64011. /**
  64012. * Define this method to modify the default behavior when loading nodes.
  64013. * @param context The context when loading the asset
  64014. * @param node The glTF node property
  64015. * @param assign A function called synchronously after parsing the glTF properties
  64016. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  64017. */
  64018. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64019. /**
  64020. * Define this method to modify the default behavior when loading cameras.
  64021. * @param context The context when loading the asset
  64022. * @param camera The glTF camera property
  64023. * @param assign A function called synchronously after parsing the glTF properties
  64024. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  64025. */
  64026. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  64027. /**
  64028. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  64029. * @param context The context when loading the asset
  64030. * @param primitive The glTF mesh primitive property
  64031. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  64032. */
  64033. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  64034. /**
  64035. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  64036. * @param context The context when loading the asset
  64037. * @param name The mesh name when loading the asset
  64038. * @param node The glTF node when loading the asset
  64039. * @param mesh The glTF mesh when loading the asset
  64040. * @param primitive The glTF mesh primitive property
  64041. * @param assign A function called synchronously after parsing the glTF properties
  64042. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  64043. */
  64044. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  64045. /**
  64046. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  64047. * @param context The context when loading the asset
  64048. * @param material The glTF material property
  64049. * @param assign A function called synchronously after parsing the glTF properties
  64050. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  64051. */
  64052. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  64053. /**
  64054. * Define this method to modify the default behavior when creating materials.
  64055. * @param context The context when loading the asset
  64056. * @param material The glTF material property
  64057. * @param babylonDrawMode The draw mode for the Babylon material
  64058. * @returns The Babylon material or null if not handled
  64059. */
  64060. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  64061. /**
  64062. * Define this method to modify the default behavior when loading material properties.
  64063. * @param context The context when loading the asset
  64064. * @param material The glTF material property
  64065. * @param babylonMaterial The Babylon material
  64066. * @returns A promise that resolves when the load is complete or null if not handled
  64067. */
  64068. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64069. /**
  64070. * Define this method to modify the default behavior when loading texture infos.
  64071. * @param context The context when loading the asset
  64072. * @param textureInfo The glTF texture info property
  64073. * @param assign A function called synchronously after parsing the glTF properties
  64074. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  64075. */
  64076. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  64077. /**
  64078. * Define this method to modify the default behavior when loading animations.
  64079. * @param context The context when loading the asset
  64080. * @param animation The glTF animation property
  64081. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  64082. */
  64083. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  64084. /**
  64085. * @hidden Define this method to modify the default behavior when loading skins.
  64086. * @param context The context when loading the asset
  64087. * @param node The glTF node property
  64088. * @param skin The glTF skin property
  64089. * @returns A promise that resolves when the load is complete or null if not handled
  64090. */
  64091. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  64092. /**
  64093. * @hidden Define this method to modify the default behavior when loading uris.
  64094. * @param context The context when loading the asset
  64095. * @param property The glTF property associated with the uri
  64096. * @param uri The uri to load
  64097. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  64098. */
  64099. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  64100. }
  64101. }
  64102. declare module BABYLON.GLTF2 {
  64103. /**
  64104. * Helper class for working with arrays when loading the glTF asset
  64105. */
  64106. export class ArrayItem {
  64107. /**
  64108. * Gets an item from the given array.
  64109. * @param context The context when loading the asset
  64110. * @param array The array to get the item from
  64111. * @param index The index to the array
  64112. * @returns The array item
  64113. */
  64114. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  64115. /**
  64116. * Assign an `index` field to each item of the given array.
  64117. * @param array The array of items
  64118. */
  64119. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  64120. }
  64121. /**
  64122. * The glTF 2.0 loader
  64123. */
  64124. export class GLTFLoader implements IGLTFLoader {
  64125. /** @hidden */
  64126. _completePromises: Promise<any>[];
  64127. private _disposed;
  64128. private _parent;
  64129. private _state;
  64130. private _extensions;
  64131. private _rootUrl;
  64132. private _fileName;
  64133. private _uniqueRootUrl;
  64134. private _gltf;
  64135. private _babylonScene;
  64136. private _rootBabylonMesh;
  64137. private _defaultBabylonMaterialData;
  64138. private _progressCallback?;
  64139. private _requests;
  64140. private static readonly _DefaultSampler;
  64141. private static _ExtensionNames;
  64142. private static _ExtensionFactories;
  64143. /**
  64144. * Registers a loader extension.
  64145. * @param name The name of the loader extension.
  64146. * @param factory The factory function that creates the loader extension.
  64147. */
  64148. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  64149. /**
  64150. * Unregisters a loader extension.
  64151. * @param name The name of the loader extenion.
  64152. * @returns A boolean indicating whether the extension has been unregistered
  64153. */
  64154. static UnregisterExtension(name: string): boolean;
  64155. /**
  64156. * Gets the loader state.
  64157. */
  64158. readonly state: Nullable<GLTFLoaderState>;
  64159. /**
  64160. * The glTF object parsed from the JSON.
  64161. */
  64162. readonly gltf: IGLTF;
  64163. /**
  64164. * The Babylon scene when loading the asset.
  64165. */
  64166. readonly babylonScene: Scene;
  64167. /**
  64168. * The root Babylon mesh when loading the asset.
  64169. */
  64170. readonly rootBabylonMesh: Mesh;
  64171. /** @hidden */
  64172. constructor(parent: GLTFFileLoader);
  64173. /** @hidden */
  64174. dispose(): void;
  64175. /** @hidden */
  64176. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64177. meshes: AbstractMesh[];
  64178. particleSystems: IParticleSystem[];
  64179. skeletons: Skeleton[];
  64180. animationGroups: AnimationGroup[];
  64181. }>;
  64182. /** @hidden */
  64183. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64184. private _loadAsync;
  64185. private _loadData;
  64186. private _setupData;
  64187. private _loadExtensions;
  64188. private _checkExtensions;
  64189. private _setState;
  64190. private _createRootNode;
  64191. /**
  64192. * Loads a glTF scene.
  64193. * @param context The context when loading the asset
  64194. * @param scene The glTF scene property
  64195. * @returns A promise that resolves when the load is complete
  64196. */
  64197. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  64198. private _forEachPrimitive;
  64199. private _getMeshes;
  64200. private _getSkeletons;
  64201. private _getAnimationGroups;
  64202. private _startAnimations;
  64203. /**
  64204. * Loads a glTF node.
  64205. * @param context The context when loading the asset
  64206. * @param node The glTF node property
  64207. * @param assign A function called synchronously after parsing the glTF properties
  64208. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  64209. */
  64210. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  64211. private _loadMeshAsync;
  64212. /**
  64213. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  64214. * @param context The context when loading the asset
  64215. * @param name The mesh name when loading the asset
  64216. * @param node The glTF node when loading the asset
  64217. * @param mesh The glTF mesh when loading the asset
  64218. * @param primitive The glTF mesh primitive property
  64219. * @param assign A function called synchronously after parsing the glTF properties
  64220. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  64221. */
  64222. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  64223. private _loadVertexDataAsync;
  64224. private _createMorphTargets;
  64225. private _loadMorphTargetsAsync;
  64226. private _loadMorphTargetVertexDataAsync;
  64227. private static _LoadTransform;
  64228. private _loadSkinAsync;
  64229. private _loadBones;
  64230. private _loadBone;
  64231. private _loadSkinInverseBindMatricesDataAsync;
  64232. private _updateBoneMatrices;
  64233. private _getNodeMatrix;
  64234. /**
  64235. * Loads a glTF camera.
  64236. * @param context The context when loading the asset
  64237. * @param camera The glTF camera property
  64238. * @param assign A function called synchronously after parsing the glTF properties
  64239. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  64240. */
  64241. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  64242. private _loadAnimationsAsync;
  64243. /**
  64244. * Loads a glTF animation.
  64245. * @param context The context when loading the asset
  64246. * @param animation The glTF animation property
  64247. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  64248. */
  64249. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  64250. /**
  64251. * @hidden Loads a glTF animation channel.
  64252. * @param context The context when loading the asset
  64253. * @param animationContext The context of the animation when loading the asset
  64254. * @param animation The glTF animation property
  64255. * @param channel The glTF animation channel property
  64256. * @param babylonAnimationGroup The babylon animation group property
  64257. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  64258. * @returns A void promise when the channel load is complete
  64259. */
  64260. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  64261. private _loadAnimationSamplerAsync;
  64262. private _loadBufferAsync;
  64263. /**
  64264. * Loads a glTF buffer view.
  64265. * @param context The context when loading the asset
  64266. * @param bufferView The glTF buffer view property
  64267. * @returns A promise that resolves with the loaded data when the load is complete
  64268. */
  64269. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  64270. private _loadIndicesAccessorAsync;
  64271. private _loadFloatAccessorAsync;
  64272. private _loadVertexBufferViewAsync;
  64273. private _loadVertexAccessorAsync;
  64274. private _loadMaterialMetallicRoughnessPropertiesAsync;
  64275. /** @hidden */
  64276. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  64277. private _createDefaultMaterial;
  64278. /**
  64279. * Creates a Babylon material from a glTF material.
  64280. * @param context The context when loading the asset
  64281. * @param material The glTF material property
  64282. * @param babylonDrawMode The draw mode for the Babylon material
  64283. * @returns The Babylon material
  64284. */
  64285. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  64286. /**
  64287. * Loads properties from a glTF material into a Babylon material.
  64288. * @param context The context when loading the asset
  64289. * @param material The glTF material property
  64290. * @param babylonMaterial The Babylon material
  64291. * @returns A promise that resolves when the load is complete
  64292. */
  64293. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  64294. /**
  64295. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  64296. * @param context The context when loading the asset
  64297. * @param material The glTF material property
  64298. * @param babylonMaterial The Babylon material
  64299. * @returns A promise that resolves when the load is complete
  64300. */
  64301. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  64302. /**
  64303. * Loads the alpha properties from a glTF material into a Babylon material.
  64304. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  64305. * @param context The context when loading the asset
  64306. * @param material The glTF material property
  64307. * @param babylonMaterial The Babylon material
  64308. */
  64309. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  64310. /**
  64311. * Loads a glTF texture info.
  64312. * @param context The context when loading the asset
  64313. * @param textureInfo The glTF texture info property
  64314. * @param assign A function called synchronously after parsing the glTF properties
  64315. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  64316. */
  64317. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  64318. private _loadTextureAsync;
  64319. private _loadSampler;
  64320. /**
  64321. * Loads a glTF image.
  64322. * @param context The context when loading the asset
  64323. * @param image The glTF image property
  64324. * @returns A promise that resolves with the loaded data when the load is complete
  64325. */
  64326. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  64327. /**
  64328. * Loads a glTF uri.
  64329. * @param context The context when loading the asset
  64330. * @param property The glTF property associated with the uri
  64331. * @param uri The base64 or relative uri
  64332. * @returns A promise that resolves with the loaded data when the load is complete
  64333. */
  64334. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  64335. private _onProgress;
  64336. /**
  64337. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  64338. * @param babylonObject the Babylon object with metadata
  64339. * @param pointer the JSON pointer
  64340. */
  64341. static AddPointerMetadata(babylonObject: {
  64342. metadata: any;
  64343. }, pointer: string): void;
  64344. private static _GetTextureWrapMode;
  64345. private static _GetTextureSamplingMode;
  64346. private static _GetTypedArray;
  64347. private static _GetNumComponents;
  64348. private static _ValidateUri;
  64349. private static _GetDrawMode;
  64350. private _compileMaterialsAsync;
  64351. private _compileShadowGeneratorsAsync;
  64352. private _forEachExtensions;
  64353. private _applyExtensions;
  64354. private _extensionsOnLoading;
  64355. private _extensionsOnReady;
  64356. private _extensionsLoadSceneAsync;
  64357. private _extensionsLoadNodeAsync;
  64358. private _extensionsLoadCameraAsync;
  64359. private _extensionsLoadVertexDataAsync;
  64360. private _extensionsLoadMeshPrimitiveAsync;
  64361. private _extensionsLoadMaterialAsync;
  64362. private _extensionsCreateMaterial;
  64363. private _extensionsLoadMaterialPropertiesAsync;
  64364. private _extensionsLoadTextureInfoAsync;
  64365. private _extensionsLoadAnimationAsync;
  64366. private _extensionsLoadSkinAsync;
  64367. private _extensionsLoadUriAsync;
  64368. /**
  64369. * Helper method called by a loader extension to load an glTF extension.
  64370. * @param context The context when loading the asset
  64371. * @param property The glTF property to load the extension from
  64372. * @param extensionName The name of the extension to load
  64373. * @param actionAsync The action to run
  64374. * @returns The promise returned by actionAsync or null if the extension does not exist
  64375. */
  64376. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  64377. /**
  64378. * Helper method called by a loader extension to load a glTF extra.
  64379. * @param context The context when loading the asset
  64380. * @param property The glTF property to load the extra from
  64381. * @param extensionName The name of the extension to load
  64382. * @param actionAsync The action to run
  64383. * @returns The promise returned by actionAsync or null if the extra does not exist
  64384. */
  64385. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  64386. /**
  64387. * Increments the indentation level and logs a message.
  64388. * @param message The message to log
  64389. */
  64390. logOpen(message: string): void;
  64391. /**
  64392. * Decrements the indentation level.
  64393. */
  64394. logClose(): void;
  64395. /**
  64396. * Logs a message
  64397. * @param message The message to log
  64398. */
  64399. log(message: string): void;
  64400. /**
  64401. * Starts a performance counter.
  64402. * @param counterName The name of the performance counter
  64403. */
  64404. startPerformanceCounter(counterName: string): void;
  64405. /**
  64406. * Ends a performance counter.
  64407. * @param counterName The name of the performance counter
  64408. */
  64409. endPerformanceCounter(counterName: string): void;
  64410. }
  64411. }
  64412. declare module BABYLON.GLTF2.Loader.Extensions {
  64413. /**
  64414. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  64415. */
  64416. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  64417. /** The name of this extension. */
  64418. readonly name: string;
  64419. /** Defines whether this extension is enabled. */
  64420. enabled: boolean;
  64421. private _loader;
  64422. private _lights?;
  64423. /** @hidden */
  64424. constructor(loader: GLTFLoader);
  64425. /** @hidden */
  64426. dispose(): void;
  64427. /** @hidden */
  64428. onLoading(): void;
  64429. /** @hidden */
  64430. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  64431. private _loadLightAsync;
  64432. }
  64433. }
  64434. declare module BABYLON.GLTF2.Loader.Extensions {
  64435. /**
  64436. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  64437. */
  64438. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  64439. /** The name of this extension. */
  64440. readonly name: string;
  64441. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  64442. dracoCompression?: DracoCompression;
  64443. /** Defines whether this extension is enabled. */
  64444. enabled: boolean;
  64445. private _loader;
  64446. /** @hidden */
  64447. constructor(loader: GLTFLoader);
  64448. /** @hidden */
  64449. dispose(): void;
  64450. /** @hidden */
  64451. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  64452. }
  64453. }
  64454. declare module BABYLON.GLTF2.Loader.Extensions {
  64455. /**
  64456. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  64457. */
  64458. export class KHR_lights implements IGLTFLoaderExtension {
  64459. /** The name of this extension. */
  64460. readonly name: string;
  64461. /** Defines whether this extension is enabled. */
  64462. enabled: boolean;
  64463. private _loader;
  64464. private _lights?;
  64465. /** @hidden */
  64466. constructor(loader: GLTFLoader);
  64467. /** @hidden */
  64468. dispose(): void;
  64469. /** @hidden */
  64470. onLoading(): void;
  64471. /** @hidden */
  64472. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64473. }
  64474. }
  64475. declare module BABYLON.GLTF2.Loader.Extensions {
  64476. /**
  64477. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  64478. */
  64479. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  64480. /** The name of this extension. */
  64481. readonly name: string;
  64482. /** Defines whether this extension is enabled. */
  64483. enabled: boolean;
  64484. private _loader;
  64485. /** @hidden */
  64486. constructor(loader: GLTFLoader);
  64487. /** @hidden */
  64488. dispose(): void;
  64489. /** @hidden */
  64490. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64491. private _loadSpecularGlossinessPropertiesAsync;
  64492. }
  64493. }
  64494. declare module BABYLON.GLTF2.Loader.Extensions {
  64495. /**
  64496. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  64497. */
  64498. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  64499. /** The name of this extension. */
  64500. readonly name: string;
  64501. /** Defines whether this extension is enabled. */
  64502. enabled: boolean;
  64503. private _loader;
  64504. /** @hidden */
  64505. constructor(loader: GLTFLoader);
  64506. /** @hidden */
  64507. dispose(): void;
  64508. /** @hidden */
  64509. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64510. private _loadUnlitPropertiesAsync;
  64511. }
  64512. }
  64513. declare module BABYLON.GLTF2.Loader.Extensions {
  64514. /**
  64515. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  64516. */
  64517. export class KHR_texture_transform implements IGLTFLoaderExtension {
  64518. /** The name of this extension. */
  64519. readonly name: string;
  64520. /** Defines whether this extension is enabled. */
  64521. enabled: boolean;
  64522. private _loader;
  64523. /** @hidden */
  64524. constructor(loader: GLTFLoader);
  64525. /** @hidden */
  64526. dispose(): void;
  64527. /** @hidden */
  64528. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  64529. }
  64530. }
  64531. declare module BABYLON.GLTF2.Loader.Extensions {
  64532. /**
  64533. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  64534. */
  64535. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  64536. /** The name of this extension. */
  64537. readonly name: string;
  64538. /** Defines whether this extension is enabled. */
  64539. enabled: boolean;
  64540. private _loader;
  64541. private _clips;
  64542. private _emitters;
  64543. /** @hidden */
  64544. constructor(loader: GLTFLoader);
  64545. /** @hidden */
  64546. dispose(): void;
  64547. /** @hidden */
  64548. onLoading(): void;
  64549. /** @hidden */
  64550. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  64551. /** @hidden */
  64552. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64553. /** @hidden */
  64554. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  64555. private _loadClipAsync;
  64556. private _loadEmitterAsync;
  64557. private _getEventAction;
  64558. private _loadAnimationEventAsync;
  64559. }
  64560. }
  64561. declare module BABYLON.GLTF2.Loader.Extensions {
  64562. /**
  64563. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  64564. */
  64565. export class MSFT_lod implements IGLTFLoaderExtension {
  64566. /** The name of this extension. */
  64567. readonly name: string;
  64568. /** Defines whether this extension is enabled. */
  64569. enabled: boolean;
  64570. /**
  64571. * Maximum number of LODs to load, starting from the lowest LOD.
  64572. */
  64573. maxLODsToLoad: number;
  64574. /**
  64575. * Observable raised when all node LODs of one level are loaded.
  64576. * The event data is the index of the loaded LOD starting from zero.
  64577. * Dispose the loader to cancel the loading of the next level of LODs.
  64578. */
  64579. onNodeLODsLoadedObservable: Observable<number>;
  64580. /**
  64581. * Observable raised when all material LODs of one level are loaded.
  64582. * The event data is the index of the loaded LOD starting from zero.
  64583. * Dispose the loader to cancel the loading of the next level of LODs.
  64584. */
  64585. onMaterialLODsLoadedObservable: Observable<number>;
  64586. private _loader;
  64587. private _nodeIndexLOD;
  64588. private _nodeSignalLODs;
  64589. private _nodePromiseLODs;
  64590. private _materialIndexLOD;
  64591. private _materialSignalLODs;
  64592. private _materialPromiseLODs;
  64593. /** @hidden */
  64594. constructor(loader: GLTFLoader);
  64595. /** @hidden */
  64596. dispose(): void;
  64597. /** @hidden */
  64598. onReady(): void;
  64599. /** @hidden */
  64600. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64601. /** @hidden */
  64602. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  64603. /** @hidden */
  64604. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  64605. /**
  64606. * Gets an array of LOD properties from lowest to highest.
  64607. */
  64608. private _getLODs;
  64609. private _disposeUnusedMaterials;
  64610. }
  64611. }
  64612. declare module BABYLON.GLTF2.Loader.Extensions {
  64613. /** @hidden */
  64614. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  64615. readonly name: string;
  64616. enabled: boolean;
  64617. private _loader;
  64618. constructor(loader: GLTFLoader);
  64619. dispose(): void;
  64620. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64621. }
  64622. }
  64623. declare module BABYLON.GLTF2.Loader.Extensions {
  64624. /** @hidden */
  64625. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  64626. readonly name: string;
  64627. enabled: boolean;
  64628. private _loader;
  64629. constructor(loader: GLTFLoader);
  64630. dispose(): void;
  64631. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64632. }
  64633. }
  64634. declare module BABYLON {
  64635. /**
  64636. * Class reading and parsing the MTL file bundled with the obj file.
  64637. */
  64638. export class MTLFileLoader {
  64639. /**
  64640. * All material loaded from the mtl will be set here
  64641. */
  64642. materials: StandardMaterial[];
  64643. /**
  64644. * This function will read the mtl file and create each material described inside
  64645. * This function could be improve by adding :
  64646. * -some component missing (Ni, Tf...)
  64647. * -including the specific options available
  64648. *
  64649. * @param scene defines the scene the material will be created in
  64650. * @param data defines the mtl data to parse
  64651. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  64652. */
  64653. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  64654. /**
  64655. * Gets the texture for the material.
  64656. *
  64657. * If the material is imported from input file,
  64658. * We sanitize the url to ensure it takes the textre from aside the material.
  64659. *
  64660. * @param rootUrl The root url to load from
  64661. * @param value The value stored in the mtl
  64662. * @return The Texture
  64663. */
  64664. private static _getTexture;
  64665. }
  64666. /**
  64667. * Options for loading OBJ/MTL files
  64668. */
  64669. type MeshLoadOptions = {
  64670. /**
  64671. * Defines if UVs are optimized by default during load.
  64672. */
  64673. OptimizeWithUV: boolean;
  64674. /**
  64675. * Defines custom scaling of UV coordinates of loaded meshes.
  64676. */
  64677. UVScaling: Vector2;
  64678. /**
  64679. * Invert model on y-axis (does a model scaling inversion)
  64680. */
  64681. InvertY: boolean;
  64682. /**
  64683. * Invert Y-Axis of referenced textures on load
  64684. */
  64685. InvertTextureY: boolean;
  64686. /**
  64687. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  64688. */
  64689. ImportVertexColors: boolean;
  64690. /**
  64691. * Compute the normals for the model, even if normals are present in the file.
  64692. */
  64693. ComputeNormals: boolean;
  64694. /**
  64695. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  64696. */
  64697. SkipMaterials: boolean;
  64698. /**
  64699. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  64700. */
  64701. MaterialLoadingFailsSilently: boolean;
  64702. };
  64703. /**
  64704. * OBJ file type loader.
  64705. * This is a babylon scene loader plugin.
  64706. */
  64707. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  64708. /**
  64709. * Defines if UVs are optimized by default during load.
  64710. */
  64711. static OPTIMIZE_WITH_UV: boolean;
  64712. /**
  64713. * Invert model on y-axis (does a model scaling inversion)
  64714. */
  64715. static INVERT_Y: boolean;
  64716. /**
  64717. * Invert Y-Axis of referenced textures on load
  64718. */
  64719. static INVERT_TEXTURE_Y: boolean;
  64720. /**
  64721. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  64722. */
  64723. static IMPORT_VERTEX_COLORS: boolean;
  64724. /**
  64725. * Compute the normals for the model, even if normals are present in the file.
  64726. */
  64727. static COMPUTE_NORMALS: boolean;
  64728. /**
  64729. * Defines custom scaling of UV coordinates of loaded meshes.
  64730. */
  64731. static UV_SCALING: Vector2;
  64732. /**
  64733. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  64734. */
  64735. static SKIP_MATERIALS: boolean;
  64736. /**
  64737. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  64738. *
  64739. * Defaults to true for backwards compatibility.
  64740. */
  64741. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  64742. /**
  64743. * Defines the name of the plugin.
  64744. */
  64745. name: string;
  64746. /**
  64747. * Defines the extension the plugin is able to load.
  64748. */
  64749. extensions: string;
  64750. /** @hidden */
  64751. obj: RegExp;
  64752. /** @hidden */
  64753. group: RegExp;
  64754. /** @hidden */
  64755. mtllib: RegExp;
  64756. /** @hidden */
  64757. usemtl: RegExp;
  64758. /** @hidden */
  64759. smooth: RegExp;
  64760. /** @hidden */
  64761. vertexPattern: RegExp;
  64762. /** @hidden */
  64763. normalPattern: RegExp;
  64764. /** @hidden */
  64765. uvPattern: RegExp;
  64766. /** @hidden */
  64767. facePattern1: RegExp;
  64768. /** @hidden */
  64769. facePattern2: RegExp;
  64770. /** @hidden */
  64771. facePattern3: RegExp;
  64772. /** @hidden */
  64773. facePattern4: RegExp;
  64774. /** @hidden */
  64775. facePattern5: RegExp;
  64776. private _meshLoadOptions;
  64777. /**
  64778. * Creates loader for .OBJ files
  64779. *
  64780. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  64781. */
  64782. constructor(meshLoadOptions?: MeshLoadOptions);
  64783. private static readonly currentMeshLoadOptions;
  64784. /**
  64785. * Calls synchronously the MTL file attached to this obj.
  64786. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  64787. * Without this function materials are not displayed in the first frame (but displayed after).
  64788. * In consequence it is impossible to get material information in your HTML file
  64789. *
  64790. * @param url The URL of the MTL file
  64791. * @param rootUrl
  64792. * @param onSuccess Callback function to be called when the MTL file is loaded
  64793. * @private
  64794. */
  64795. private _loadMTL;
  64796. /**
  64797. * Instantiates a OBJ file loader plugin.
  64798. * @returns the created plugin
  64799. */
  64800. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  64801. /**
  64802. * If the data string can be loaded directly.
  64803. *
  64804. * @param data string containing the file data
  64805. * @returns if the data can be loaded directly
  64806. */
  64807. canDirectLoad(data: string): boolean;
  64808. /**
  64809. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  64810. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64811. * @param scene the scene the meshes should be added to
  64812. * @param data the OBJ data to load
  64813. * @param rootUrl root url to load from
  64814. * @param onProgress event that fires when loading progress has occured
  64815. * @param fileName Defines the name of the file to load
  64816. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64817. */
  64818. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64819. meshes: AbstractMesh[];
  64820. particleSystems: IParticleSystem[];
  64821. skeletons: Skeleton[];
  64822. animationGroups: AnimationGroup[];
  64823. }>;
  64824. /**
  64825. * Imports all objects from the loaded OBJ data and adds them to the scene
  64826. * @param scene the scene the objects should be added to
  64827. * @param data the OBJ data to load
  64828. * @param rootUrl root url to load from
  64829. * @param onProgress event that fires when loading progress has occured
  64830. * @param fileName Defines the name of the file to load
  64831. * @returns a promise which completes when objects have been loaded to the scene
  64832. */
  64833. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64834. /**
  64835. * Load into an asset container.
  64836. * @param scene The scene to load into
  64837. * @param data The data to import
  64838. * @param rootUrl The root url for scene and resources
  64839. * @param onProgress The callback when the load progresses
  64840. * @param fileName Defines the name of the file to load
  64841. * @returns The loaded asset container
  64842. */
  64843. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  64844. /**
  64845. * Read the OBJ file and create an Array of meshes.
  64846. * Each mesh contains all information given by the OBJ and the MTL file.
  64847. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  64848. *
  64849. * @param meshesNames
  64850. * @param scene Scene The scene where are displayed the data
  64851. * @param data String The content of the obj file
  64852. * @param rootUrl String The path to the folder
  64853. * @returns Array<AbstractMesh>
  64854. * @private
  64855. */
  64856. private _parseSolid;
  64857. }
  64858. }
  64859. declare module BABYLON {
  64860. /**
  64861. * STL file type loader.
  64862. * This is a babylon scene loader plugin.
  64863. */
  64864. export class STLFileLoader implements ISceneLoaderPlugin {
  64865. /** @hidden */
  64866. solidPattern: RegExp;
  64867. /** @hidden */
  64868. facetsPattern: RegExp;
  64869. /** @hidden */
  64870. normalPattern: RegExp;
  64871. /** @hidden */
  64872. vertexPattern: RegExp;
  64873. /**
  64874. * Defines the name of the plugin.
  64875. */
  64876. name: string;
  64877. /**
  64878. * Defines the extensions the stl loader is able to load.
  64879. * force data to come in as an ArrayBuffer
  64880. * we'll convert to string if it looks like it's an ASCII .stl
  64881. */
  64882. extensions: ISceneLoaderPluginExtensions;
  64883. /**
  64884. * Import meshes into a scene.
  64885. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  64886. * @param scene The scene to import into
  64887. * @param data The data to import
  64888. * @param rootUrl The root url for scene and resources
  64889. * @param meshes The meshes array to import into
  64890. * @param particleSystems The particle systems array to import into
  64891. * @param skeletons The skeletons array to import into
  64892. * @param onError The callback when import fails
  64893. * @returns True if successful or false otherwise
  64894. */
  64895. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  64896. /**
  64897. * Load into a scene.
  64898. * @param scene The scene to load into
  64899. * @param data The data to import
  64900. * @param rootUrl The root url for scene and resources
  64901. * @param onError The callback when import fails
  64902. * @returns true if successful or false otherwise
  64903. */
  64904. load(scene: Scene, data: any, rootUrl: string): boolean;
  64905. /**
  64906. * Load into an asset container.
  64907. * @param scene The scene to load into
  64908. * @param data The data to import
  64909. * @param rootUrl The root url for scene and resources
  64910. * @param onError The callback when import fails
  64911. * @returns The loaded asset container
  64912. */
  64913. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  64914. private _isBinary;
  64915. private _parseBinary;
  64916. private _parseASCII;
  64917. }
  64918. }
  64919. declare module BABYLON {
  64920. /**
  64921. * Class for generating OBJ data from a Babylon scene.
  64922. */
  64923. export class OBJExport {
  64924. /**
  64925. * Exports the geometry of a Mesh array in .OBJ file format (text)
  64926. * @param mesh defines the list of meshes to serialize
  64927. * @param materials defines if materials should be exported
  64928. * @param matlibname defines the name of the associated mtl file
  64929. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  64930. * @returns the OBJ content
  64931. */
  64932. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  64933. /**
  64934. * Exports the material(s) of a mesh in .MTL file format (text)
  64935. * @param mesh defines the mesh to extract the material from
  64936. * @returns the mtl content
  64937. */
  64938. static MTL(mesh: Mesh): string;
  64939. }
  64940. }
  64941. declare module BABYLON {
  64942. /** @hidden */
  64943. export var __IGLTFExporterExtension: number;
  64944. /**
  64945. * Interface for extending the exporter
  64946. * @hidden
  64947. */
  64948. export interface IGLTFExporterExtension {
  64949. /**
  64950. * The name of this extension
  64951. */
  64952. readonly name: string;
  64953. /**
  64954. * Defines whether this extension is enabled
  64955. */
  64956. enabled: boolean;
  64957. /**
  64958. * Defines whether this extension is required
  64959. */
  64960. required: boolean;
  64961. }
  64962. }
  64963. declare module BABYLON.GLTF2.Exporter {
  64964. /** @hidden */
  64965. export var __IGLTFExporterExtensionV2: number;
  64966. /**
  64967. * Interface for a glTF exporter extension
  64968. * @hidden
  64969. */
  64970. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  64971. /**
  64972. * Define this method to modify the default behavior before exporting a texture
  64973. * @param context The context when loading the asset
  64974. * @param babylonTexture The glTF texture info property
  64975. * @param mimeType The mime-type of the generated image
  64976. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  64977. */
  64978. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  64979. /**
  64980. * Define this method to modify the default behavior when exporting texture info
  64981. * @param context The context when loading the asset
  64982. * @param meshPrimitive glTF mesh primitive
  64983. * @param babylonSubMesh Babylon submesh
  64984. * @param binaryWriter glTF serializer binary writer instance
  64985. * @returns nullable IMeshPrimitive promise
  64986. */
  64987. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  64988. /**
  64989. * Define this method to modify the default behavior when exporting a node
  64990. * @param context The context when exporting the node
  64991. * @param node glTF node
  64992. * @param babylonNode BabylonJS node
  64993. * @returns nullable INode promise
  64994. */
  64995. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  64996. /**
  64997. * Called after the exporter state changes to EXPORTING
  64998. */
  64999. onExporting?(): void;
  65000. }
  65001. }
  65002. declare module BABYLON.GLTF2.Exporter {
  65003. /**
  65004. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  65005. * @hidden
  65006. */
  65007. export class _GLTFMaterialExporter {
  65008. /**
  65009. * Represents the dielectric specular values for R, G and B
  65010. */
  65011. private static readonly _DielectricSpecular;
  65012. /**
  65013. * Allows the maximum specular power to be defined for material calculations
  65014. */
  65015. private static readonly _MaxSpecularPower;
  65016. /**
  65017. * Mapping to store textures
  65018. */
  65019. private _textureMap;
  65020. /**
  65021. * Numeric tolerance value
  65022. */
  65023. private static readonly _Epsilon;
  65024. /**
  65025. * Reference to the glTF Exporter
  65026. */
  65027. private _exporter;
  65028. constructor(exporter: _Exporter);
  65029. /**
  65030. * Specifies if two colors are approximately equal in value
  65031. * @param color1 first color to compare to
  65032. * @param color2 second color to compare to
  65033. * @param epsilon threshold value
  65034. */
  65035. private static FuzzyEquals;
  65036. /**
  65037. * Gets the materials from a Babylon scene and converts them to glTF materials
  65038. * @param scene babylonjs scene
  65039. * @param mimeType texture mime type
  65040. * @param images array of images
  65041. * @param textures array of textures
  65042. * @param materials array of materials
  65043. * @param imageData mapping of texture names to base64 textures
  65044. * @param hasTextureCoords specifies if texture coordinates are present on the material
  65045. */
  65046. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65047. /**
  65048. * Makes a copy of the glTF material without the texture parameters
  65049. * @param originalMaterial original glTF material
  65050. * @returns glTF material without texture parameters
  65051. */
  65052. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  65053. /**
  65054. * Specifies if the material has any texture parameters present
  65055. * @param material glTF Material
  65056. * @returns boolean specifying if texture parameters are present
  65057. */
  65058. _hasTexturesPresent(material: IMaterial): boolean;
  65059. /**
  65060. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  65061. * @param babylonStandardMaterial
  65062. * @returns glTF Metallic Roughness Material representation
  65063. */
  65064. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  65065. /**
  65066. * Computes the metallic factor
  65067. * @param diffuse diffused value
  65068. * @param specular specular value
  65069. * @param oneMinusSpecularStrength one minus the specular strength
  65070. * @returns metallic value
  65071. */
  65072. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  65073. /**
  65074. * Gets the glTF alpha mode from the Babylon Material
  65075. * @param babylonMaterial Babylon Material
  65076. * @returns The Babylon alpha mode value
  65077. */
  65078. _getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  65079. /**
  65080. * Converts a Babylon Standard Material to a glTF Material
  65081. * @param babylonStandardMaterial BJS Standard Material
  65082. * @param mimeType mime type to use for the textures
  65083. * @param images array of glTF image interfaces
  65084. * @param textures array of glTF texture interfaces
  65085. * @param materials array of glTF material interfaces
  65086. * @param imageData map of image file name to data
  65087. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65088. */
  65089. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65090. /**
  65091. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  65092. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  65093. * @param mimeType mime type to use for the textures
  65094. * @param images array of glTF image interfaces
  65095. * @param textures array of glTF texture interfaces
  65096. * @param materials array of glTF material interfaces
  65097. * @param imageData map of image file name to data
  65098. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65099. */
  65100. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65101. /**
  65102. * Converts an image typed array buffer to a base64 image
  65103. * @param buffer typed array buffer
  65104. * @param width width of the image
  65105. * @param height height of the image
  65106. * @param mimeType mimetype of the image
  65107. * @returns base64 image string
  65108. */
  65109. private _createBase64FromCanvasAsync;
  65110. /**
  65111. * Generates a white texture based on the specified width and height
  65112. * @param width width of the texture in pixels
  65113. * @param height height of the texture in pixels
  65114. * @param scene babylonjs scene
  65115. * @returns white texture
  65116. */
  65117. private _createWhiteTexture;
  65118. /**
  65119. * 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
  65120. * @param texture1 first texture to resize
  65121. * @param texture2 second texture to resize
  65122. * @param scene babylonjs scene
  65123. * @returns resized textures or null
  65124. */
  65125. private _resizeTexturesToSameDimensions;
  65126. /**
  65127. * Converts an array of pixels to a Float32Array
  65128. * Throws an error if the pixel format is not supported
  65129. * @param pixels - array buffer containing pixel values
  65130. * @returns Float32 of pixels
  65131. */
  65132. private _convertPixelArrayToFloat32;
  65133. /**
  65134. * Convert Specular Glossiness Textures to Metallic Roughness
  65135. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  65136. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  65137. * @param diffuseTexture texture used to store diffuse information
  65138. * @param specularGlossinessTexture texture used to store specular and glossiness information
  65139. * @param factors specular glossiness material factors
  65140. * @param mimeType the mime type to use for the texture
  65141. * @returns pbr metallic roughness interface or null
  65142. */
  65143. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  65144. /**
  65145. * Converts specular glossiness material properties to metallic roughness
  65146. * @param specularGlossiness interface with specular glossiness material properties
  65147. * @returns interface with metallic roughness material properties
  65148. */
  65149. private _convertSpecularGlossinessToMetallicRoughness;
  65150. /**
  65151. * Calculates the surface reflectance, independent of lighting conditions
  65152. * @param color Color source to calculate brightness from
  65153. * @returns number representing the perceived brightness, or zero if color is undefined
  65154. */
  65155. private _getPerceivedBrightness;
  65156. /**
  65157. * Returns the maximum color component value
  65158. * @param color
  65159. * @returns maximum color component value, or zero if color is null or undefined
  65160. */
  65161. private _getMaxComponent;
  65162. /**
  65163. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  65164. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65165. * @param mimeType mime type to use for the textures
  65166. * @param images array of glTF image interfaces
  65167. * @param textures array of glTF texture interfaces
  65168. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  65169. * @param imageData map of image file name to data
  65170. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65171. * @returns glTF PBR Metallic Roughness factors
  65172. */
  65173. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  65174. private _getGLTFTextureSampler;
  65175. private _getGLTFTextureWrapMode;
  65176. private _getGLTFTextureWrapModesSampler;
  65177. /**
  65178. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  65179. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65180. * @param mimeType mime type to use for the textures
  65181. * @param images array of glTF image interfaces
  65182. * @param textures array of glTF texture interfaces
  65183. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  65184. * @param imageData map of image file name to data
  65185. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65186. * @returns glTF PBR Metallic Roughness factors
  65187. */
  65188. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  65189. /**
  65190. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  65191. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65192. * @param mimeType mime type to use for the textures
  65193. * @param images array of glTF image interfaces
  65194. * @param textures array of glTF texture interfaces
  65195. * @param materials array of glTF material interfaces
  65196. * @param imageData map of image file name to data
  65197. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65198. */
  65199. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65200. private setMetallicRoughnessPbrMaterial;
  65201. private getPixelsFromTexture;
  65202. /**
  65203. * Extracts a texture from a Babylon texture into file data and glTF data
  65204. * @param babylonTexture Babylon texture to extract
  65205. * @param mimeType Mime Type of the babylonTexture
  65206. * @return glTF texture info, or null if the texture format is not supported
  65207. */
  65208. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  65209. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  65210. /**
  65211. * Builds a texture from base64 string
  65212. * @param base64Texture base64 texture string
  65213. * @param baseTextureName Name to use for the texture
  65214. * @param mimeType image mime type for the texture
  65215. * @param images array of images
  65216. * @param textures array of textures
  65217. * @param imageData map of image data
  65218. * @returns glTF texture info, or null if the texture format is not supported
  65219. */
  65220. private _getTextureInfoFromBase64;
  65221. }
  65222. }
  65223. declare module BABYLON {
  65224. /**
  65225. * Class for holding and downloading glTF file data
  65226. */
  65227. export class GLTFData {
  65228. /**
  65229. * Object which contains the file name as the key and its data as the value
  65230. */
  65231. glTFFiles: {
  65232. [fileName: string]: string | Blob;
  65233. };
  65234. /**
  65235. * Initializes the glTF file object
  65236. */
  65237. constructor();
  65238. /**
  65239. * Downloads the glTF data as files based on their names and data
  65240. */
  65241. downloadFiles(): void;
  65242. }
  65243. }
  65244. declare module BABYLON {
  65245. /**
  65246. * Holds a collection of exporter options and parameters
  65247. */
  65248. export interface IExportOptions {
  65249. /**
  65250. * Function which indicates whether a babylon node should be exported or not
  65251. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  65252. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  65253. */
  65254. shouldExportNode?(node: Node): boolean;
  65255. /**
  65256. * The sample rate to bake animation curves
  65257. */
  65258. animationSampleRate?: number;
  65259. /**
  65260. * Begin serialization without waiting for the scene to be ready
  65261. */
  65262. exportWithoutWaitingForScene?: boolean;
  65263. }
  65264. /**
  65265. * Class for generating glTF data from a Babylon scene.
  65266. */
  65267. export class GLTF2Export {
  65268. /**
  65269. * Exports the geometry of the scene to .gltf file format asynchronously
  65270. * @param scene Babylon scene with scene hierarchy information
  65271. * @param filePrefix File prefix to use when generating the glTF file
  65272. * @param options Exporter options
  65273. * @returns Returns an object with a .gltf file and associates texture names
  65274. * as keys and their data and paths as values
  65275. */
  65276. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  65277. private static _PreExportAsync;
  65278. private static _PostExportAsync;
  65279. /**
  65280. * Exports the geometry of the scene to .glb file format asychronously
  65281. * @param scene Babylon scene with scene hierarchy information
  65282. * @param filePrefix File prefix to use when generating glb file
  65283. * @param options Exporter options
  65284. * @returns Returns an object with a .glb filename as key and data as value
  65285. */
  65286. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  65287. }
  65288. }
  65289. declare module BABYLON.GLTF2.Exporter {
  65290. /**
  65291. * @hidden
  65292. */
  65293. export class _GLTFUtilities {
  65294. /**
  65295. * Creates a buffer view based on the supplied arguments
  65296. * @param bufferIndex index value of the specified buffer
  65297. * @param byteOffset byte offset value
  65298. * @param byteLength byte length of the bufferView
  65299. * @param byteStride byte distance between conequential elements
  65300. * @param name name of the buffer view
  65301. * @returns bufferView for glTF
  65302. */
  65303. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  65304. /**
  65305. * Creates an accessor based on the supplied arguments
  65306. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  65307. * @param name The name of the accessor
  65308. * @param type The type of the accessor
  65309. * @param componentType The datatype of components in the attribute
  65310. * @param count The number of attributes referenced by this accessor
  65311. * @param byteOffset The offset relative to the start of the bufferView in bytes
  65312. * @param min Minimum value of each component in this attribute
  65313. * @param max Maximum value of each component in this attribute
  65314. * @returns accessor for glTF
  65315. */
  65316. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  65317. /**
  65318. * Calculates the minimum and maximum values of an array of position floats
  65319. * @param positions Positions array of a mesh
  65320. * @param vertexStart Starting vertex offset to calculate min and max values
  65321. * @param vertexCount Number of vertices to check for min and max values
  65322. * @returns min number array and max number array
  65323. */
  65324. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  65325. min: number[];
  65326. max: number[];
  65327. };
  65328. /**
  65329. * Converts a new right-handed Vector3
  65330. * @param vector vector3 array
  65331. * @returns right-handed Vector3
  65332. */
  65333. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  65334. /**
  65335. * Converts a Vector3 to right-handed
  65336. * @param vector Vector3 to convert to right-handed
  65337. */
  65338. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  65339. /**
  65340. * Converts a three element number array to right-handed
  65341. * @param vector number array to convert to right-handed
  65342. */
  65343. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  65344. /**
  65345. * Converts a new right-handed Vector3
  65346. * @param vector vector3 array
  65347. * @returns right-handed Vector3
  65348. */
  65349. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  65350. /**
  65351. * Converts a Vector3 to right-handed
  65352. * @param vector Vector3 to convert to right-handed
  65353. */
  65354. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  65355. /**
  65356. * Converts a three element number array to right-handed
  65357. * @param vector number array to convert to right-handed
  65358. */
  65359. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  65360. /**
  65361. * Converts a Vector4 to right-handed
  65362. * @param vector Vector4 to convert to right-handed
  65363. */
  65364. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  65365. /**
  65366. * Converts a Vector4 to right-handed
  65367. * @param vector Vector4 to convert to right-handed
  65368. */
  65369. static _GetRightHandedArray4FromRef(vector: number[]): void;
  65370. /**
  65371. * Converts a Quaternion to right-handed
  65372. * @param quaternion Source quaternion to convert to right-handed
  65373. */
  65374. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  65375. /**
  65376. * Converts a Quaternion to right-handed
  65377. * @param quaternion Source quaternion to convert to right-handed
  65378. */
  65379. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  65380. static _NormalizeTangentFromRef(tangent: Vector4): void;
  65381. }
  65382. }
  65383. declare module BABYLON.GLTF2.Exporter {
  65384. /**
  65385. * Converts Babylon Scene into glTF 2.0.
  65386. * @hidden
  65387. */
  65388. export class _Exporter {
  65389. /**
  65390. * Stores the glTF to export
  65391. */
  65392. _glTF: IGLTF;
  65393. /**
  65394. * Stores all generated buffer views, which represents views into the main glTF buffer data
  65395. */
  65396. _bufferViews: IBufferView[];
  65397. /**
  65398. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  65399. */
  65400. _accessors: IAccessor[];
  65401. /**
  65402. * Stores all the generated nodes, which contains transform and/or mesh information per node
  65403. */
  65404. private _nodes;
  65405. /**
  65406. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  65407. */
  65408. private _scenes;
  65409. /**
  65410. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  65411. */
  65412. private _meshes;
  65413. /**
  65414. * Stores all the generated material information, which represents the appearance of each primitive
  65415. */
  65416. _materials: IMaterial[];
  65417. _materialMap: {
  65418. [materialID: number]: number;
  65419. };
  65420. /**
  65421. * Stores all the generated texture information, which is referenced by glTF materials
  65422. */
  65423. _textures: ITexture[];
  65424. /**
  65425. * Stores all the generated image information, which is referenced by glTF textures
  65426. */
  65427. _images: IImage[];
  65428. /**
  65429. * Stores all the texture samplers
  65430. */
  65431. _samplers: ISampler[];
  65432. /**
  65433. * Stores all the generated animation samplers, which is referenced by glTF animations
  65434. */
  65435. /**
  65436. * Stores the animations for glTF models
  65437. */
  65438. private _animations;
  65439. /**
  65440. * Stores the total amount of bytes stored in the glTF buffer
  65441. */
  65442. private _totalByteLength;
  65443. /**
  65444. * Stores a reference to the Babylon scene containing the source geometry and material information
  65445. */
  65446. _babylonScene: Scene;
  65447. /**
  65448. * Stores a map of the image data, where the key is the file name and the value
  65449. * is the image data
  65450. */
  65451. _imageData: {
  65452. [fileName: string]: {
  65453. data: Uint8Array;
  65454. mimeType: ImageMimeType;
  65455. };
  65456. };
  65457. /**
  65458. * Stores a map of the unique id of a node to its index in the node array
  65459. */
  65460. private _nodeMap;
  65461. /**
  65462. * Specifies if the Babylon scene should be converted to right-handed on export
  65463. */
  65464. _convertToRightHandedSystem: boolean;
  65465. /**
  65466. * Baked animation sample rate
  65467. */
  65468. private _animationSampleRate;
  65469. /**
  65470. * Callback which specifies if a node should be exported or not
  65471. */
  65472. private _shouldExportNode;
  65473. private _localEngine;
  65474. _glTFMaterialExporter: _GLTFMaterialExporter;
  65475. private _extensions;
  65476. private static _ExtensionNames;
  65477. private static _ExtensionFactories;
  65478. private _applyExtensions;
  65479. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  65480. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  65481. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65482. private _forEachExtensions;
  65483. private _extensionsOnExporting;
  65484. /**
  65485. * Load glTF serializer extensions
  65486. */
  65487. private _loadExtensions;
  65488. /**
  65489. * Creates a glTF Exporter instance, which can accept optional exporter options
  65490. * @param babylonScene Babylon scene object
  65491. * @param options Options to modify the behavior of the exporter
  65492. */
  65493. constructor(babylonScene: Scene, options?: IExportOptions);
  65494. /**
  65495. * Registers a glTF exporter extension
  65496. * @param name Name of the extension to export
  65497. * @param factory The factory function that creates the exporter extension
  65498. */
  65499. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  65500. /**
  65501. * Un-registers an exporter extension
  65502. * @param name The name fo the exporter extension
  65503. * @returns A boolean indicating whether the extension has been un-registered
  65504. */
  65505. static UnregisterExtension(name: string): boolean;
  65506. /**
  65507. * Lazy load a local engine with premultiplied alpha set to false
  65508. */
  65509. _getLocalEngine(): Engine;
  65510. private reorderIndicesBasedOnPrimitiveMode;
  65511. /**
  65512. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  65513. * clock-wise during export to glTF
  65514. * @param submesh BabylonJS submesh
  65515. * @param primitiveMode Primitive mode of the mesh
  65516. * @param sideOrientation the winding order of the submesh
  65517. * @param vertexBufferKind The type of vertex attribute
  65518. * @param meshAttributeArray The vertex attribute data
  65519. * @param byteOffset The offset to the binary data
  65520. * @param binaryWriter The binary data for the glTF file
  65521. */
  65522. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  65523. /**
  65524. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  65525. * clock-wise during export to glTF
  65526. * @param submesh BabylonJS submesh
  65527. * @param primitiveMode Primitive mode of the mesh
  65528. * @param sideOrientation the winding order of the submesh
  65529. * @param vertexBufferKind The type of vertex attribute
  65530. * @param meshAttributeArray The vertex attribute data
  65531. * @param byteOffset The offset to the binary data
  65532. * @param binaryWriter The binary data for the glTF file
  65533. */
  65534. private reorderTriangleFillMode;
  65535. /**
  65536. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  65537. * clock-wise during export to glTF
  65538. * @param submesh BabylonJS submesh
  65539. * @param primitiveMode Primitive mode of the mesh
  65540. * @param sideOrientation the winding order of the submesh
  65541. * @param vertexBufferKind The type of vertex attribute
  65542. * @param meshAttributeArray The vertex attribute data
  65543. * @param byteOffset The offset to the binary data
  65544. * @param binaryWriter The binary data for the glTF file
  65545. */
  65546. private reorderTriangleStripDrawMode;
  65547. /**
  65548. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  65549. * clock-wise during export to glTF
  65550. * @param submesh BabylonJS submesh
  65551. * @param primitiveMode Primitive mode of the mesh
  65552. * @param sideOrientation the winding order of the submesh
  65553. * @param vertexBufferKind The type of vertex attribute
  65554. * @param meshAttributeArray The vertex attribute data
  65555. * @param byteOffset The offset to the binary data
  65556. * @param binaryWriter The binary data for the glTF file
  65557. */
  65558. private reorderTriangleFanMode;
  65559. /**
  65560. * Writes the vertex attribute data to binary
  65561. * @param vertices The vertices to write to the binary writer
  65562. * @param byteOffset The offset into the binary writer to overwrite binary data
  65563. * @param vertexAttributeKind The vertex attribute type
  65564. * @param meshAttributeArray The vertex attribute data
  65565. * @param binaryWriter The writer containing the binary data
  65566. */
  65567. private writeVertexAttributeData;
  65568. /**
  65569. * Writes mesh attribute data to a data buffer
  65570. * Returns the bytelength of the data
  65571. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  65572. * @param meshAttributeArray Array containing the attribute data
  65573. * @param binaryWriter The buffer to write the binary data to
  65574. * @param indices Used to specify the order of the vertex data
  65575. */
  65576. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  65577. /**
  65578. * Generates glTF json data
  65579. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  65580. * @param glTFPrefix Text to use when prefixing a glTF file
  65581. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  65582. * @returns json data as string
  65583. */
  65584. private generateJSON;
  65585. /**
  65586. * Generates data for .gltf and .bin files based on the glTF prefix string
  65587. * @param glTFPrefix Text to use when prefixing a glTF file
  65588. * @returns GLTFData with glTF file data
  65589. */
  65590. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  65591. /**
  65592. * Creates a binary buffer for glTF
  65593. * @returns array buffer for binary data
  65594. */
  65595. private _generateBinaryAsync;
  65596. /**
  65597. * Pads the number to a multiple of 4
  65598. * @param num number to pad
  65599. * @returns padded number
  65600. */
  65601. private _getPadding;
  65602. /**
  65603. * Generates a glb file from the json and binary data
  65604. * Returns an object with the glb file name as the key and data as the value
  65605. * @param glTFPrefix
  65606. * @returns object with glb filename as key and data as value
  65607. */
  65608. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  65609. /**
  65610. * Sets the TRS for each node
  65611. * @param node glTF Node for storing the transformation data
  65612. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  65613. */
  65614. private setNodeTransformation;
  65615. private getVertexBufferFromMesh;
  65616. /**
  65617. * Creates a bufferview based on the vertices type for the Babylon mesh
  65618. * @param kind Indicates the type of vertices data
  65619. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  65620. * @param binaryWriter The buffer to write the bufferview data to
  65621. */
  65622. private createBufferViewKind;
  65623. /**
  65624. * The primitive mode of the Babylon mesh
  65625. * @param babylonMesh The BabylonJS mesh
  65626. */
  65627. private getMeshPrimitiveMode;
  65628. /**
  65629. * Sets the primitive mode of the glTF mesh primitive
  65630. * @param meshPrimitive glTF mesh primitive
  65631. * @param primitiveMode The primitive mode
  65632. */
  65633. private setPrimitiveMode;
  65634. /**
  65635. * Sets the vertex attribute accessor based of the glTF mesh primitive
  65636. * @param meshPrimitive glTF mesh primitive
  65637. * @param attributeKind vertex attribute
  65638. * @returns boolean specifying if uv coordinates are present
  65639. */
  65640. private setAttributeKind;
  65641. /**
  65642. * Sets data for the primitive attributes of each submesh
  65643. * @param mesh glTF Mesh object to store the primitive attribute information
  65644. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  65645. * @param binaryWriter Buffer to write the attribute data to
  65646. */
  65647. private setPrimitiveAttributesAsync;
  65648. /**
  65649. * Creates a glTF scene based on the array of meshes
  65650. * Returns the the total byte offset
  65651. * @param babylonScene Babylon scene to get the mesh data from
  65652. * @param binaryWriter Buffer to write binary data to
  65653. */
  65654. private createSceneAsync;
  65655. /**
  65656. * Creates a mapping of Node unique id to node index and handles animations
  65657. * @param babylonScene Babylon Scene
  65658. * @param nodes Babylon transform nodes
  65659. * @param shouldExportNode Callback specifying if a transform node should be exported
  65660. * @param binaryWriter Buffer to write binary data to
  65661. * @returns Node mapping of unique id to index
  65662. */
  65663. private createNodeMapAndAnimationsAsync;
  65664. /**
  65665. * Creates a glTF node from a Babylon mesh
  65666. * @param babylonMesh Source Babylon mesh
  65667. * @param binaryWriter Buffer for storing geometry data
  65668. * @returns glTF node
  65669. */
  65670. private createNodeAsync;
  65671. }
  65672. /**
  65673. * @hidden
  65674. *
  65675. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  65676. */
  65677. export class _BinaryWriter {
  65678. /**
  65679. * Array buffer which stores all binary data
  65680. */
  65681. private _arrayBuffer;
  65682. /**
  65683. * View of the array buffer
  65684. */
  65685. private _dataView;
  65686. /**
  65687. * byte offset of data in array buffer
  65688. */
  65689. private _byteOffset;
  65690. /**
  65691. * Initialize binary writer with an initial byte length
  65692. * @param byteLength Initial byte length of the array buffer
  65693. */
  65694. constructor(byteLength: number);
  65695. /**
  65696. * Resize the array buffer to the specified byte length
  65697. * @param byteLength
  65698. */
  65699. private resizeBuffer;
  65700. /**
  65701. * Get an array buffer with the length of the byte offset
  65702. * @returns ArrayBuffer resized to the byte offset
  65703. */
  65704. getArrayBuffer(): ArrayBuffer;
  65705. /**
  65706. * Get the byte offset of the array buffer
  65707. * @returns byte offset
  65708. */
  65709. getByteOffset(): number;
  65710. /**
  65711. * Stores an UInt8 in the array buffer
  65712. * @param entry
  65713. * @param byteOffset If defined, specifies where to set the value as an offset.
  65714. */
  65715. setUInt8(entry: number, byteOffset?: number): void;
  65716. /**
  65717. * Gets an UInt32 in the array buffer
  65718. * @param entry
  65719. * @param byteOffset If defined, specifies where to set the value as an offset.
  65720. */
  65721. getUInt32(byteOffset: number): number;
  65722. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  65723. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  65724. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  65725. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  65726. /**
  65727. * Stores a Float32 in the array buffer
  65728. * @param entry
  65729. */
  65730. setFloat32(entry: number, byteOffset?: number): void;
  65731. /**
  65732. * Stores an UInt32 in the array buffer
  65733. * @param entry
  65734. * @param byteOffset If defined, specifies where to set the value as an offset.
  65735. */
  65736. setUInt32(entry: number, byteOffset?: number): void;
  65737. }
  65738. }
  65739. declare module BABYLON.GLTF2.Exporter {
  65740. /**
  65741. * @hidden
  65742. * Interface to store animation data.
  65743. */
  65744. export interface _IAnimationData {
  65745. /**
  65746. * Keyframe data.
  65747. */
  65748. inputs: number[];
  65749. /**
  65750. * Value data.
  65751. */
  65752. outputs: number[][];
  65753. /**
  65754. * Animation interpolation data.
  65755. */
  65756. samplerInterpolation: AnimationSamplerInterpolation;
  65757. /**
  65758. * Minimum keyframe value.
  65759. */
  65760. inputsMin: number;
  65761. /**
  65762. * Maximum keyframe value.
  65763. */
  65764. inputsMax: number;
  65765. }
  65766. /**
  65767. * @hidden
  65768. */
  65769. export interface _IAnimationInfo {
  65770. /**
  65771. * The target channel for the animation
  65772. */
  65773. animationChannelTargetPath: AnimationChannelTargetPath;
  65774. /**
  65775. * The glTF accessor type for the data.
  65776. */
  65777. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  65778. /**
  65779. * Specifies if quaternions should be used.
  65780. */
  65781. useQuaternion: boolean;
  65782. }
  65783. /**
  65784. * @hidden
  65785. * Utility class for generating glTF animation data from BabylonJS.
  65786. */
  65787. export class _GLTFAnimation {
  65788. /**
  65789. * @ignore
  65790. *
  65791. * Creates glTF channel animation from BabylonJS animation.
  65792. * @param babylonTransformNode - BabylonJS mesh.
  65793. * @param animation - animation.
  65794. * @param animationChannelTargetPath - The target animation channel.
  65795. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  65796. * @param useQuaternion - Specifies if quaternions are used.
  65797. * @returns nullable IAnimationData
  65798. */
  65799. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  65800. private static _DeduceAnimationInfo;
  65801. /**
  65802. * @ignore
  65803. * Create node animations from the transform node animations
  65804. * @param babylonNode
  65805. * @param runtimeGLTFAnimation
  65806. * @param idleGLTFAnimations
  65807. * @param nodeMap
  65808. * @param nodes
  65809. * @param binaryWriter
  65810. * @param bufferViews
  65811. * @param accessors
  65812. * @param convertToRightHandedSystem
  65813. */
  65814. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  65815. [key: number]: number;
  65816. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  65817. /**
  65818. * @ignore
  65819. * Create node animations from the animation groups
  65820. * @param babylonScene
  65821. * @param glTFAnimations
  65822. * @param nodeMap
  65823. * @param nodes
  65824. * @param binaryWriter
  65825. * @param bufferViews
  65826. * @param accessors
  65827. * @param convertToRightHandedSystem
  65828. */
  65829. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  65830. [key: number]: number;
  65831. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  65832. private static AddAnimation;
  65833. /**
  65834. * Create a baked animation
  65835. * @param babylonTransformNode BabylonJS mesh
  65836. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  65837. * @param animationChannelTargetPath animation target channel
  65838. * @param minFrame minimum animation frame
  65839. * @param maxFrame maximum animation frame
  65840. * @param fps frames per second of the animation
  65841. * @param inputs input key frames of the animation
  65842. * @param outputs output key frame data of the animation
  65843. * @param convertToRightHandedSystem converts the values to right-handed
  65844. * @param useQuaternion specifies if quaternions should be used
  65845. */
  65846. private static _CreateBakedAnimation;
  65847. private static _ConvertFactorToVector3OrQuaternion;
  65848. private static _SetInterpolatedValue;
  65849. /**
  65850. * Creates linear animation from the animation key frames
  65851. * @param babylonTransformNode BabylonJS mesh
  65852. * @param animation BabylonJS animation
  65853. * @param animationChannelTargetPath The target animation channel
  65854. * @param frameDelta The difference between the last and first frame of the animation
  65855. * @param inputs Array to store the key frame times
  65856. * @param outputs Array to store the key frame data
  65857. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  65858. * @param useQuaternion Specifies if quaternions are used in the animation
  65859. */
  65860. private static _CreateLinearOrStepAnimation;
  65861. /**
  65862. * Creates cubic spline animation from the animation key frames
  65863. * @param babylonTransformNode BabylonJS mesh
  65864. * @param animation BabylonJS animation
  65865. * @param animationChannelTargetPath The target animation channel
  65866. * @param frameDelta The difference between the last and first frame of the animation
  65867. * @param inputs Array to store the key frame times
  65868. * @param outputs Array to store the key frame data
  65869. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  65870. * @param useQuaternion Specifies if quaternions are used in the animation
  65871. */
  65872. private static _CreateCubicSplineAnimation;
  65873. private static _GetBasePositionRotationOrScale;
  65874. /**
  65875. * Adds a key frame value
  65876. * @param keyFrame
  65877. * @param animation
  65878. * @param outputs
  65879. * @param animationChannelTargetPath
  65880. * @param basePositionRotationOrScale
  65881. * @param convertToRightHandedSystem
  65882. * @param useQuaternion
  65883. */
  65884. private static _AddKeyframeValue;
  65885. /**
  65886. * Determine the interpolation based on the key frames
  65887. * @param keyFrames
  65888. * @param animationChannelTargetPath
  65889. * @param useQuaternion
  65890. */
  65891. private static _DeduceInterpolation;
  65892. /**
  65893. * Adds an input tangent or output tangent to the output data
  65894. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  65895. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  65896. * @param outputs The animation data by keyframe
  65897. * @param animationChannelTargetPath The target animation channel
  65898. * @param interpolation The interpolation type
  65899. * @param keyFrame The key frame with the animation data
  65900. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  65901. * @param useQuaternion Specifies if quaternions are used
  65902. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  65903. */
  65904. private static AddSplineTangent;
  65905. /**
  65906. * Get the minimum and maximum key frames' frame values
  65907. * @param keyFrames animation key frames
  65908. * @returns the minimum and maximum key frame value
  65909. */
  65910. private static calculateMinMaxKeyFrames;
  65911. }
  65912. }
  65913. declare module BABYLON.GLTF2.Exporter {
  65914. /** @hidden */
  65915. export var textureTransformPixelShader: {
  65916. name: string;
  65917. shader: string;
  65918. };
  65919. }
  65920. declare module BABYLON.GLTF2.Exporter.Extensions {
  65921. /**
  65922. * @hidden
  65923. */
  65924. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  65925. /** Name of this extension */
  65926. readonly name: string;
  65927. /** Defines whether this extension is enabled */
  65928. enabled: boolean;
  65929. /** Defines whether this extension is required */
  65930. required: boolean;
  65931. /** Reference to the glTF exporter */
  65932. private _exporter;
  65933. constructor(exporter: _Exporter);
  65934. dispose(): void;
  65935. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  65936. /**
  65937. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  65938. * @param babylonTexture
  65939. * @param offset
  65940. * @param rotation
  65941. * @param scale
  65942. * @param scene
  65943. */
  65944. private _textureTransformTextureAsync;
  65945. }
  65946. }
  65947. declare module BABYLON.GLTF2.Exporter.Extensions {
  65948. /**
  65949. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  65950. */
  65951. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  65952. /** The name of this extension. */
  65953. readonly name: string;
  65954. /** Defines whether this extension is enabled. */
  65955. enabled: boolean;
  65956. /** Defines whether this extension is required */
  65957. required: boolean;
  65958. /** Reference to the glTF exporter */
  65959. private _exporter;
  65960. private _lights;
  65961. /** @hidden */
  65962. constructor(exporter: _Exporter);
  65963. /** @hidden */
  65964. dispose(): void;
  65965. /** @hidden */
  65966. onExporting(): void;
  65967. /**
  65968. * Define this method to modify the default behavior when exporting a node
  65969. * @param context The context when exporting the node
  65970. * @param node glTF node
  65971. * @param babylonNode BabylonJS node
  65972. * @returns nullable INode promise
  65973. */
  65974. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65975. }
  65976. }
  65977. declare module BABYLON {
  65978. /**
  65979. * Class for generating STL data from a Babylon scene.
  65980. */
  65981. export class STLExport {
  65982. /**
  65983. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  65984. * @param meshes list defines the mesh to serialize
  65985. * @param download triggers the automatic download of the file.
  65986. * @param fileName changes the downloads fileName.
  65987. * @param binary changes the STL to a binary type.
  65988. * @param isLittleEndian toggle for binary type exporter.
  65989. * @returns the STL as UTF8 string
  65990. */
  65991. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  65992. }
  65993. }
  65994. /**
  65995. * @ignoreChildren
  65996. * @ignore
  65997. */
  65998. declare module "babylonjs-gltf2interface" {
  65999. export = BABYLON.GLTF2;
  66000. }
  66001. /**
  66002. * Module for glTF 2.0 Interface
  66003. * @ignoreChildren
  66004. * @ignore
  66005. */
  66006. declare module BABYLON.GLTF2 {
  66007. /**
  66008. * The datatype of the components in the attribute
  66009. */
  66010. const enum AccessorComponentType {
  66011. /**
  66012. * Byte
  66013. */
  66014. BYTE = 5120,
  66015. /**
  66016. * Unsigned Byte
  66017. */
  66018. UNSIGNED_BYTE = 5121,
  66019. /**
  66020. * Short
  66021. */
  66022. SHORT = 5122,
  66023. /**
  66024. * Unsigned Short
  66025. */
  66026. UNSIGNED_SHORT = 5123,
  66027. /**
  66028. * Unsigned Int
  66029. */
  66030. UNSIGNED_INT = 5125,
  66031. /**
  66032. * Float
  66033. */
  66034. FLOAT = 5126,
  66035. }
  66036. /**
  66037. * Specifies if the attirbute is a scalar, vector, or matrix
  66038. */
  66039. const enum AccessorType {
  66040. /**
  66041. * Scalar
  66042. */
  66043. SCALAR = "SCALAR",
  66044. /**
  66045. * Vector2
  66046. */
  66047. VEC2 = "VEC2",
  66048. /**
  66049. * Vector3
  66050. */
  66051. VEC3 = "VEC3",
  66052. /**
  66053. * Vector4
  66054. */
  66055. VEC4 = "VEC4",
  66056. /**
  66057. * Matrix2x2
  66058. */
  66059. MAT2 = "MAT2",
  66060. /**
  66061. * Matrix3x3
  66062. */
  66063. MAT3 = "MAT3",
  66064. /**
  66065. * Matrix4x4
  66066. */
  66067. MAT4 = "MAT4",
  66068. }
  66069. /**
  66070. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  66071. */
  66072. const enum AnimationChannelTargetPath {
  66073. /**
  66074. * Translation
  66075. */
  66076. TRANSLATION = "translation",
  66077. /**
  66078. * Rotation
  66079. */
  66080. ROTATION = "rotation",
  66081. /**
  66082. * Scale
  66083. */
  66084. SCALE = "scale",
  66085. /**
  66086. * Weights
  66087. */
  66088. WEIGHTS = "weights",
  66089. }
  66090. /**
  66091. * Interpolation algorithm
  66092. */
  66093. const enum AnimationSamplerInterpolation {
  66094. /**
  66095. * The animated values are linearly interpolated between keyframes
  66096. */
  66097. LINEAR = "LINEAR",
  66098. /**
  66099. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  66100. */
  66101. STEP = "STEP",
  66102. /**
  66103. * The animation's interpolation is computed using a cubic spline with specified tangents
  66104. */
  66105. CUBICSPLINE = "CUBICSPLINE",
  66106. }
  66107. /**
  66108. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  66109. */
  66110. const enum CameraType {
  66111. /**
  66112. * A perspective camera containing properties to create a perspective projection matrix
  66113. */
  66114. PERSPECTIVE = "perspective",
  66115. /**
  66116. * An orthographic camera containing properties to create an orthographic projection matrix
  66117. */
  66118. ORTHOGRAPHIC = "orthographic",
  66119. }
  66120. /**
  66121. * The mime-type of the image
  66122. */
  66123. const enum ImageMimeType {
  66124. /**
  66125. * JPEG Mime-type
  66126. */
  66127. JPEG = "image/jpeg",
  66128. /**
  66129. * PNG Mime-type
  66130. */
  66131. PNG = "image/png",
  66132. }
  66133. /**
  66134. * The alpha rendering mode of the material
  66135. */
  66136. const enum MaterialAlphaMode {
  66137. /**
  66138. * The alpha value is ignored and the rendered output is fully opaque
  66139. */
  66140. OPAQUE = "OPAQUE",
  66141. /**
  66142. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  66143. */
  66144. MASK = "MASK",
  66145. /**
  66146. * 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)
  66147. */
  66148. BLEND = "BLEND",
  66149. }
  66150. /**
  66151. * The type of the primitives to render
  66152. */
  66153. const enum MeshPrimitiveMode {
  66154. /**
  66155. * Points
  66156. */
  66157. POINTS = 0,
  66158. /**
  66159. * Lines
  66160. */
  66161. LINES = 1,
  66162. /**
  66163. * Line Loop
  66164. */
  66165. LINE_LOOP = 2,
  66166. /**
  66167. * Line Strip
  66168. */
  66169. LINE_STRIP = 3,
  66170. /**
  66171. * Triangles
  66172. */
  66173. TRIANGLES = 4,
  66174. /**
  66175. * Triangle Strip
  66176. */
  66177. TRIANGLE_STRIP = 5,
  66178. /**
  66179. * Triangle Fan
  66180. */
  66181. TRIANGLE_FAN = 6,
  66182. }
  66183. /**
  66184. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  66185. */
  66186. const enum TextureMagFilter {
  66187. /**
  66188. * Nearest
  66189. */
  66190. NEAREST = 9728,
  66191. /**
  66192. * Linear
  66193. */
  66194. LINEAR = 9729,
  66195. }
  66196. /**
  66197. * Minification filter. All valid values correspond to WebGL enums
  66198. */
  66199. const enum TextureMinFilter {
  66200. /**
  66201. * Nearest
  66202. */
  66203. NEAREST = 9728,
  66204. /**
  66205. * Linear
  66206. */
  66207. LINEAR = 9729,
  66208. /**
  66209. * Nearest Mip-Map Nearest
  66210. */
  66211. NEAREST_MIPMAP_NEAREST = 9984,
  66212. /**
  66213. * Linear Mipmap Nearest
  66214. */
  66215. LINEAR_MIPMAP_NEAREST = 9985,
  66216. /**
  66217. * Nearest Mipmap Linear
  66218. */
  66219. NEAREST_MIPMAP_LINEAR = 9986,
  66220. /**
  66221. * Linear Mipmap Linear
  66222. */
  66223. LINEAR_MIPMAP_LINEAR = 9987,
  66224. }
  66225. /**
  66226. * S (U) wrapping mode. All valid values correspond to WebGL enums
  66227. */
  66228. const enum TextureWrapMode {
  66229. /**
  66230. * Clamp to Edge
  66231. */
  66232. CLAMP_TO_EDGE = 33071,
  66233. /**
  66234. * Mirrored Repeat
  66235. */
  66236. MIRRORED_REPEAT = 33648,
  66237. /**
  66238. * Repeat
  66239. */
  66240. REPEAT = 10497,
  66241. }
  66242. /**
  66243. * glTF Property
  66244. */
  66245. interface IProperty {
  66246. /**
  66247. * Dictionary object with extension-specific objects
  66248. */
  66249. extensions?: {
  66250. [key: string]: any;
  66251. };
  66252. /**
  66253. * Application-Specific data
  66254. */
  66255. extras?: any;
  66256. }
  66257. /**
  66258. * glTF Child of Root Property
  66259. */
  66260. interface IChildRootProperty extends IProperty {
  66261. /**
  66262. * The user-defined name of this object
  66263. */
  66264. name?: string;
  66265. }
  66266. /**
  66267. * Indices of those attributes that deviate from their initialization value
  66268. */
  66269. interface IAccessorSparseIndices extends IProperty {
  66270. /**
  66271. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  66272. */
  66273. bufferView: number;
  66274. /**
  66275. * The offset relative to the start of the bufferView in bytes. Must be aligned
  66276. */
  66277. byteOffset?: number;
  66278. /**
  66279. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  66280. */
  66281. componentType: AccessorComponentType;
  66282. }
  66283. /**
  66284. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  66285. */
  66286. interface IAccessorSparseValues extends IProperty {
  66287. /**
  66288. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  66289. */
  66290. bufferView: number;
  66291. /**
  66292. * The offset relative to the start of the bufferView in bytes. Must be aligned
  66293. */
  66294. byteOffset?: number;
  66295. }
  66296. /**
  66297. * Sparse storage of attributes that deviate from their initialization value
  66298. */
  66299. interface IAccessorSparse extends IProperty {
  66300. /**
  66301. * The number of attributes encoded in this sparse accessor
  66302. */
  66303. count: number;
  66304. /**
  66305. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  66306. */
  66307. indices: IAccessorSparseIndices;
  66308. /**
  66309. * 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
  66310. */
  66311. values: IAccessorSparseValues;
  66312. }
  66313. /**
  66314. * 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
  66315. */
  66316. interface IAccessor extends IChildRootProperty {
  66317. /**
  66318. * The index of the bufferview
  66319. */
  66320. bufferView?: number;
  66321. /**
  66322. * The offset relative to the start of the bufferView in bytes
  66323. */
  66324. byteOffset?: number;
  66325. /**
  66326. * The datatype of components in the attribute
  66327. */
  66328. componentType: AccessorComponentType;
  66329. /**
  66330. * Specifies whether integer data values should be normalized
  66331. */
  66332. normalized?: boolean;
  66333. /**
  66334. * The number of attributes referenced by this accessor
  66335. */
  66336. count: number;
  66337. /**
  66338. * Specifies if the attribute is a scalar, vector, or matrix
  66339. */
  66340. type: AccessorType;
  66341. /**
  66342. * Maximum value of each component in this attribute
  66343. */
  66344. max?: number[];
  66345. /**
  66346. * Minimum value of each component in this attribute
  66347. */
  66348. min?: number[];
  66349. /**
  66350. * Sparse storage of attributes that deviate from their initialization value
  66351. */
  66352. sparse?: IAccessorSparse;
  66353. }
  66354. /**
  66355. * Targets an animation's sampler at a node's property
  66356. */
  66357. interface IAnimationChannel extends IProperty {
  66358. /**
  66359. * The index of a sampler in this animation used to compute the value for the target
  66360. */
  66361. sampler: number;
  66362. /**
  66363. * The index of the node and TRS property to target
  66364. */
  66365. target: IAnimationChannelTarget;
  66366. }
  66367. /**
  66368. * The index of the node and TRS property that an animation channel targets
  66369. */
  66370. interface IAnimationChannelTarget extends IProperty {
  66371. /**
  66372. * The index of the node to target
  66373. */
  66374. node: number;
  66375. /**
  66376. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  66377. */
  66378. path: AnimationChannelTargetPath;
  66379. }
  66380. /**
  66381. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  66382. */
  66383. interface IAnimationSampler extends IProperty {
  66384. /**
  66385. * The index of an accessor containing keyframe input values, e.g., time
  66386. */
  66387. input: number;
  66388. /**
  66389. * Interpolation algorithm
  66390. */
  66391. interpolation?: AnimationSamplerInterpolation;
  66392. /**
  66393. * The index of an accessor, containing keyframe output values
  66394. */
  66395. output: number;
  66396. }
  66397. /**
  66398. * A keyframe animation
  66399. */
  66400. interface IAnimation extends IChildRootProperty {
  66401. /**
  66402. * An array of channels, each of which targets an animation's sampler at a node's property
  66403. */
  66404. channels: IAnimationChannel[];
  66405. /**
  66406. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  66407. */
  66408. samplers: IAnimationSampler[];
  66409. }
  66410. /**
  66411. * Metadata about the glTF asset
  66412. */
  66413. interface IAsset extends IChildRootProperty {
  66414. /**
  66415. * A copyright message suitable for display to credit the content creator
  66416. */
  66417. copyright?: string;
  66418. /**
  66419. * Tool that generated this glTF model. Useful for debugging
  66420. */
  66421. generator?: string;
  66422. /**
  66423. * The glTF version that this asset targets
  66424. */
  66425. version: string;
  66426. /**
  66427. * The minimum glTF version that this asset targets
  66428. */
  66429. minVersion?: string;
  66430. }
  66431. /**
  66432. * A buffer points to binary geometry, animation, or skins
  66433. */
  66434. interface IBuffer extends IChildRootProperty {
  66435. /**
  66436. * 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
  66437. */
  66438. uri?: string;
  66439. /**
  66440. * The length of the buffer in bytes
  66441. */
  66442. byteLength: number;
  66443. }
  66444. /**
  66445. * A view into a buffer generally representing a subset of the buffer
  66446. */
  66447. interface IBufferView extends IChildRootProperty {
  66448. /**
  66449. * The index of the buffer
  66450. */
  66451. buffer: number;
  66452. /**
  66453. * The offset into the buffer in bytes
  66454. */
  66455. byteOffset?: number;
  66456. /**
  66457. * The lenth of the bufferView in bytes
  66458. */
  66459. byteLength: number;
  66460. /**
  66461. * The stride, in bytes
  66462. */
  66463. byteStride?: number;
  66464. }
  66465. /**
  66466. * An orthographic camera containing properties to create an orthographic projection matrix
  66467. */
  66468. interface ICameraOrthographic extends IProperty {
  66469. /**
  66470. * The floating-point horizontal magnification of the view. Must not be zero
  66471. */
  66472. xmag: number;
  66473. /**
  66474. * The floating-point vertical magnification of the view. Must not be zero
  66475. */
  66476. ymag: number;
  66477. /**
  66478. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  66479. */
  66480. zfar: number;
  66481. /**
  66482. * The floating-point distance to the near clipping plane
  66483. */
  66484. znear: number;
  66485. }
  66486. /**
  66487. * A perspective camera containing properties to create a perspective projection matrix
  66488. */
  66489. interface ICameraPerspective extends IProperty {
  66490. /**
  66491. * The floating-point aspect ratio of the field of view
  66492. */
  66493. aspectRatio?: number;
  66494. /**
  66495. * The floating-point vertical field of view in radians
  66496. */
  66497. yfov: number;
  66498. /**
  66499. * The floating-point distance to the far clipping plane
  66500. */
  66501. zfar?: number;
  66502. /**
  66503. * The floating-point distance to the near clipping plane
  66504. */
  66505. znear: number;
  66506. }
  66507. /**
  66508. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  66509. */
  66510. interface ICamera extends IChildRootProperty {
  66511. /**
  66512. * An orthographic camera containing properties to create an orthographic projection matrix
  66513. */
  66514. orthographic?: ICameraOrthographic;
  66515. /**
  66516. * A perspective camera containing properties to create a perspective projection matrix
  66517. */
  66518. perspective?: ICameraPerspective;
  66519. /**
  66520. * Specifies if the camera uses a perspective or orthographic projection
  66521. */
  66522. type: CameraType;
  66523. }
  66524. /**
  66525. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  66526. */
  66527. interface IImage extends IChildRootProperty {
  66528. /**
  66529. * 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
  66530. */
  66531. uri?: string;
  66532. /**
  66533. * The image's MIME type
  66534. */
  66535. mimeType?: ImageMimeType;
  66536. /**
  66537. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  66538. */
  66539. bufferView?: number;
  66540. }
  66541. /**
  66542. * Material Normal Texture Info
  66543. */
  66544. interface IMaterialNormalTextureInfo extends ITextureInfo {
  66545. /**
  66546. * The scalar multiplier applied to each normal vector of the normal texture
  66547. */
  66548. scale?: number;
  66549. }
  66550. /**
  66551. * Material Occlusion Texture Info
  66552. */
  66553. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  66554. /**
  66555. * A scalar multiplier controlling the amount of occlusion applied
  66556. */
  66557. strength?: number;
  66558. }
  66559. /**
  66560. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  66561. */
  66562. interface IMaterialPbrMetallicRoughness {
  66563. /**
  66564. * The material's base color factor
  66565. */
  66566. baseColorFactor?: number[];
  66567. /**
  66568. * The base color texture
  66569. */
  66570. baseColorTexture?: ITextureInfo;
  66571. /**
  66572. * The metalness of the material
  66573. */
  66574. metallicFactor?: number;
  66575. /**
  66576. * The roughness of the material
  66577. */
  66578. roughnessFactor?: number;
  66579. /**
  66580. * The metallic-roughness texture
  66581. */
  66582. metallicRoughnessTexture?: ITextureInfo;
  66583. }
  66584. /**
  66585. * The material appearance of a primitive
  66586. */
  66587. interface IMaterial extends IChildRootProperty {
  66588. /**
  66589. * 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
  66590. */
  66591. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  66592. /**
  66593. * The normal map texture
  66594. */
  66595. normalTexture?: IMaterialNormalTextureInfo;
  66596. /**
  66597. * The occlusion map texture
  66598. */
  66599. occlusionTexture?: IMaterialOcclusionTextureInfo;
  66600. /**
  66601. * The emissive map texture
  66602. */
  66603. emissiveTexture?: ITextureInfo;
  66604. /**
  66605. * 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
  66606. */
  66607. emissiveFactor?: number[];
  66608. /**
  66609. * The alpha rendering mode of the material
  66610. */
  66611. alphaMode?: MaterialAlphaMode;
  66612. /**
  66613. * The alpha cutoff value of the material
  66614. */
  66615. alphaCutoff?: number;
  66616. /**
  66617. * Specifies whether the material is double sided
  66618. */
  66619. doubleSided?: boolean;
  66620. }
  66621. /**
  66622. * Geometry to be rendered with the given material
  66623. */
  66624. interface IMeshPrimitive extends IProperty {
  66625. /**
  66626. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  66627. */
  66628. attributes: {
  66629. [name: string]: number;
  66630. };
  66631. /**
  66632. * The index of the accessor that contains the indices
  66633. */
  66634. indices?: number;
  66635. /**
  66636. * The index of the material to apply to this primitive when rendering
  66637. */
  66638. material?: number;
  66639. /**
  66640. * The type of primitives to render. All valid values correspond to WebGL enums
  66641. */
  66642. mode?: MeshPrimitiveMode;
  66643. /**
  66644. * 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
  66645. */
  66646. targets?: {
  66647. [name: string]: number;
  66648. }[];
  66649. }
  66650. /**
  66651. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  66652. */
  66653. interface IMesh extends IChildRootProperty {
  66654. /**
  66655. * An array of primitives, each defining geometry to be rendered with a material
  66656. */
  66657. primitives: IMeshPrimitive[];
  66658. /**
  66659. * Array of weights to be applied to the Morph Targets
  66660. */
  66661. weights?: number[];
  66662. }
  66663. /**
  66664. * A node in the node hierarchy
  66665. */
  66666. interface INode extends IChildRootProperty {
  66667. /**
  66668. * The index of the camera referenced by this node
  66669. */
  66670. camera?: number;
  66671. /**
  66672. * The indices of this node's children
  66673. */
  66674. children?: number[];
  66675. /**
  66676. * The index of the skin referenced by this node
  66677. */
  66678. skin?: number;
  66679. /**
  66680. * A floating-point 4x4 transformation matrix stored in column-major order
  66681. */
  66682. matrix?: number[];
  66683. /**
  66684. * The index of the mesh in this node
  66685. */
  66686. mesh?: number;
  66687. /**
  66688. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  66689. */
  66690. rotation?: number[];
  66691. /**
  66692. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  66693. */
  66694. scale?: number[];
  66695. /**
  66696. * The node's translation along the x, y, and z axes
  66697. */
  66698. translation?: number[];
  66699. /**
  66700. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  66701. */
  66702. weights?: number[];
  66703. }
  66704. /**
  66705. * Texture sampler properties for filtering and wrapping modes
  66706. */
  66707. interface ISampler extends IChildRootProperty {
  66708. /**
  66709. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  66710. */
  66711. magFilter?: TextureMagFilter;
  66712. /**
  66713. * Minification filter. All valid values correspond to WebGL enums
  66714. */
  66715. minFilter?: TextureMinFilter;
  66716. /**
  66717. * S (U) wrapping mode. All valid values correspond to WebGL enums
  66718. */
  66719. wrapS?: TextureWrapMode;
  66720. /**
  66721. * T (V) wrapping mode. All valid values correspond to WebGL enums
  66722. */
  66723. wrapT?: TextureWrapMode;
  66724. }
  66725. /**
  66726. * The root nodes of a scene
  66727. */
  66728. interface IScene extends IChildRootProperty {
  66729. /**
  66730. * The indices of each root node
  66731. */
  66732. nodes: number[];
  66733. }
  66734. /**
  66735. * Joints and matrices defining a skin
  66736. */
  66737. interface ISkin extends IChildRootProperty {
  66738. /**
  66739. * 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
  66740. */
  66741. inverseBindMatrices?: number;
  66742. /**
  66743. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  66744. */
  66745. skeleton?: number;
  66746. /**
  66747. * 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)
  66748. */
  66749. joints: number[];
  66750. }
  66751. /**
  66752. * A texture and its sampler
  66753. */
  66754. interface ITexture extends IChildRootProperty {
  66755. /**
  66756. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  66757. */
  66758. sampler?: number;
  66759. /**
  66760. * The index of the image used by this texture
  66761. */
  66762. source: number;
  66763. }
  66764. /**
  66765. * Reference to a texture
  66766. */
  66767. interface ITextureInfo extends IProperty {
  66768. /**
  66769. * The index of the texture
  66770. */
  66771. index: number;
  66772. /**
  66773. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  66774. */
  66775. texCoord?: number;
  66776. }
  66777. /**
  66778. * The root object for a glTF asset
  66779. */
  66780. interface IGLTF extends IProperty {
  66781. /**
  66782. * An array of accessors. An accessor is a typed view into a bufferView
  66783. */
  66784. accessors?: IAccessor[];
  66785. /**
  66786. * An array of keyframe animations
  66787. */
  66788. animations?: IAnimation[];
  66789. /**
  66790. * Metadata about the glTF asset
  66791. */
  66792. asset: IAsset;
  66793. /**
  66794. * An array of buffers. A buffer points to binary geometry, animation, or skins
  66795. */
  66796. buffers?: IBuffer[];
  66797. /**
  66798. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  66799. */
  66800. bufferViews?: IBufferView[];
  66801. /**
  66802. * An array of cameras
  66803. */
  66804. cameras?: ICamera[];
  66805. /**
  66806. * Names of glTF extensions used somewhere in this asset
  66807. */
  66808. extensionsUsed?: string[];
  66809. /**
  66810. * Names of glTF extensions required to properly load this asset
  66811. */
  66812. extensionsRequired?: string[];
  66813. /**
  66814. * An array of images. An image defines data used to create a texture
  66815. */
  66816. images?: IImage[];
  66817. /**
  66818. * An array of materials. A material defines the appearance of a primitive
  66819. */
  66820. materials?: IMaterial[];
  66821. /**
  66822. * An array of meshes. A mesh is a set of primitives to be rendered
  66823. */
  66824. meshes?: IMesh[];
  66825. /**
  66826. * An array of nodes
  66827. */
  66828. nodes?: INode[];
  66829. /**
  66830. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  66831. */
  66832. samplers?: ISampler[];
  66833. /**
  66834. * The index of the default scene
  66835. */
  66836. scene?: number;
  66837. /**
  66838. * An array of scenes
  66839. */
  66840. scenes?: IScene[];
  66841. /**
  66842. * An array of skins. A skin is defined by joints and matrices
  66843. */
  66844. skins?: ISkin[];
  66845. /**
  66846. * An array of textures
  66847. */
  66848. textures?: ITexture[];
  66849. }
  66850. /**
  66851. * The glTF validation results
  66852. */
  66853. interface IGLTFValidationResults {
  66854. info: {
  66855. generator: string;
  66856. hasAnimations: boolean;
  66857. hasDefaultScene: boolean;
  66858. hasMaterials: boolean;
  66859. hasMorphTargets: boolean;
  66860. hasSkins: boolean;
  66861. hasTextures: boolean;
  66862. maxAttributesUsed: number;
  66863. primitivesCount: number
  66864. };
  66865. issues: {
  66866. messages: Array<string>;
  66867. numErrors: number;
  66868. numHints: number;
  66869. numInfos: number;
  66870. numWarnings: number;
  66871. truncated: boolean
  66872. };
  66873. mimeType: string;
  66874. uri: string;
  66875. validatedAt: string;
  66876. validatorVersion: string;
  66877. }
  66878. /**
  66879. * The glTF validation options
  66880. */
  66881. interface IGLTFValidationOptions {
  66882. uri?: string;
  66883. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  66884. validateAccessorData?: boolean;
  66885. maxIssues?: number;
  66886. ignoredIssues?: Array<string>;
  66887. severityOverrides?: Object;
  66888. }
  66889. /**
  66890. * The glTF validator object
  66891. */
  66892. interface IGLTFValidator {
  66893. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  66894. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  66895. }
  66896. }
  66897. declare module BABYLON {
  66898. /** @hidden */
  66899. export var cellPixelShader: {
  66900. name: string;
  66901. shader: string;
  66902. };
  66903. }
  66904. declare module BABYLON {
  66905. /** @hidden */
  66906. export var cellVertexShader: {
  66907. name: string;
  66908. shader: string;
  66909. };
  66910. }
  66911. declare module BABYLON {
  66912. export class CellMaterial extends BABYLON.PushMaterial {
  66913. private _diffuseTexture;
  66914. diffuseTexture: BABYLON.BaseTexture;
  66915. diffuseColor: BABYLON.Color3;
  66916. _computeHighLevel: boolean;
  66917. computeHighLevel: boolean;
  66918. private _disableLighting;
  66919. disableLighting: boolean;
  66920. private _maxSimultaneousLights;
  66921. maxSimultaneousLights: number;
  66922. private _renderId;
  66923. constructor(name: string, scene: BABYLON.Scene);
  66924. needAlphaBlending(): boolean;
  66925. needAlphaTesting(): boolean;
  66926. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66927. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66928. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66929. getAnimatables(): BABYLON.IAnimatable[];
  66930. getActiveTextures(): BABYLON.BaseTexture[];
  66931. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66932. dispose(forceDisposeEffect?: boolean): void;
  66933. getClassName(): string;
  66934. clone(name: string): CellMaterial;
  66935. serialize(): any;
  66936. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  66937. }
  66938. }
  66939. declare module BABYLON {
  66940. export class CustomShaderStructure {
  66941. FragmentStore: string;
  66942. VertexStore: string;
  66943. constructor();
  66944. }
  66945. export class ShaderSpecialParts {
  66946. constructor();
  66947. Fragment_Begin: string;
  66948. Fragment_Definitions: string;
  66949. Fragment_MainBegin: string;
  66950. Fragment_Custom_Diffuse: string;
  66951. Fragment_Before_Lights: string;
  66952. Fragment_Before_Fog: string;
  66953. Fragment_Custom_Alpha: string;
  66954. Fragment_Before_FragColor: string;
  66955. Vertex_Begin: string;
  66956. Vertex_Definitions: string;
  66957. Vertex_MainBegin: string;
  66958. Vertex_Before_PositionUpdated: string;
  66959. Vertex_Before_NormalUpdated: string;
  66960. Vertex_MainEnd: string;
  66961. }
  66962. export class CustomMaterial extends BABYLON.StandardMaterial {
  66963. static ShaderIndexer: number;
  66964. CustomParts: ShaderSpecialParts;
  66965. _isCreatedShader: boolean;
  66966. _createdShaderName: string;
  66967. _customUniform: string[];
  66968. _newUniforms: string[];
  66969. _newUniformInstances: any[];
  66970. _newSamplerInstances: BABYLON.Texture[];
  66971. FragmentShader: string;
  66972. VertexShader: string;
  66973. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  66974. ReviewUniform(name: string, arr: string[]): string[];
  66975. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  66976. constructor(name: string, scene: BABYLON.Scene);
  66977. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  66978. Fragment_Begin(shaderPart: string): CustomMaterial;
  66979. Fragment_Definitions(shaderPart: string): CustomMaterial;
  66980. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  66981. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  66982. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  66983. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  66984. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  66985. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  66986. Vertex_Begin(shaderPart: string): CustomMaterial;
  66987. Vertex_Definitions(shaderPart: string): CustomMaterial;
  66988. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  66989. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  66990. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  66991. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  66992. }
  66993. }
  66994. declare module BABYLON {
  66995. export class ShaderAlebdoParts {
  66996. constructor();
  66997. Fragment_Begin: string;
  66998. Fragment_Definitions: string;
  66999. Fragment_MainBegin: string;
  67000. Fragment_Custom_Albedo: string;
  67001. Fragment_Before_Lights: string;
  67002. Fragment_Custom_MetallicRoughness: string;
  67003. Fragment_Custom_MicroSurface: string;
  67004. Fragment_Before_Fog: string;
  67005. Fragment_Custom_Alpha: string;
  67006. Fragment_Before_FragColor: string;
  67007. Vertex_Begin: string;
  67008. Vertex_Definitions: string;
  67009. Vertex_MainBegin: string;
  67010. Vertex_Before_PositionUpdated: string;
  67011. Vertex_Before_NormalUpdated: string;
  67012. Vertex_MainEnd: string;
  67013. }
  67014. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  67015. static ShaderIndexer: number;
  67016. CustomParts: ShaderAlebdoParts;
  67017. _isCreatedShader: boolean;
  67018. _createdShaderName: string;
  67019. _customUniform: string[];
  67020. _newUniforms: string[];
  67021. _newUniformInstances: any[];
  67022. _newSamplerInstances: BABYLON.Texture[];
  67023. FragmentShader: string;
  67024. VertexShader: string;
  67025. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  67026. ReviewUniform(name: string, arr: string[]): string[];
  67027. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  67028. constructor(name: string, scene: BABYLON.Scene);
  67029. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  67030. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  67031. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  67032. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  67033. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  67034. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  67035. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  67036. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  67037. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  67038. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  67039. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  67040. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  67041. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  67042. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  67043. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  67044. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  67045. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  67046. }
  67047. }
  67048. declare module BABYLON {
  67049. /** @hidden */
  67050. export var firePixelShader: {
  67051. name: string;
  67052. shader: string;
  67053. };
  67054. }
  67055. declare module BABYLON {
  67056. /** @hidden */
  67057. export var fireVertexShader: {
  67058. name: string;
  67059. shader: string;
  67060. };
  67061. }
  67062. declare module BABYLON {
  67063. export class FireMaterial extends BABYLON.PushMaterial {
  67064. private _diffuseTexture;
  67065. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67066. private _distortionTexture;
  67067. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67068. private _opacityTexture;
  67069. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67070. diffuseColor: BABYLON.Color3;
  67071. speed: number;
  67072. private _scaledDiffuse;
  67073. private _renderId;
  67074. private _lastTime;
  67075. constructor(name: string, scene: BABYLON.Scene);
  67076. needAlphaBlending(): boolean;
  67077. needAlphaTesting(): boolean;
  67078. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67079. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67080. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67081. getAnimatables(): BABYLON.IAnimatable[];
  67082. getActiveTextures(): BABYLON.BaseTexture[];
  67083. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67084. getClassName(): string;
  67085. dispose(forceDisposeEffect?: boolean): void;
  67086. clone(name: string): FireMaterial;
  67087. serialize(): any;
  67088. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  67089. }
  67090. }
  67091. declare module BABYLON {
  67092. /** @hidden */
  67093. export var furPixelShader: {
  67094. name: string;
  67095. shader: string;
  67096. };
  67097. }
  67098. declare module BABYLON {
  67099. /** @hidden */
  67100. export var furVertexShader: {
  67101. name: string;
  67102. shader: string;
  67103. };
  67104. }
  67105. declare module BABYLON {
  67106. export class FurMaterial extends BABYLON.PushMaterial {
  67107. private _diffuseTexture;
  67108. diffuseTexture: BABYLON.BaseTexture;
  67109. private _heightTexture;
  67110. heightTexture: BABYLON.BaseTexture;
  67111. diffuseColor: BABYLON.Color3;
  67112. furLength: number;
  67113. furAngle: number;
  67114. furColor: BABYLON.Color3;
  67115. furOffset: number;
  67116. furSpacing: number;
  67117. furGravity: BABYLON.Vector3;
  67118. furSpeed: number;
  67119. furDensity: number;
  67120. furOcclusion: number;
  67121. furTexture: BABYLON.DynamicTexture;
  67122. private _disableLighting;
  67123. disableLighting: boolean;
  67124. private _maxSimultaneousLights;
  67125. maxSimultaneousLights: number;
  67126. highLevelFur: boolean;
  67127. _meshes: BABYLON.AbstractMesh[];
  67128. private _renderId;
  67129. private _furTime;
  67130. constructor(name: string, scene: BABYLON.Scene);
  67131. furTime: number;
  67132. needAlphaBlending(): boolean;
  67133. needAlphaTesting(): boolean;
  67134. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67135. updateFur(): void;
  67136. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67137. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67138. getAnimatables(): BABYLON.IAnimatable[];
  67139. getActiveTextures(): BABYLON.BaseTexture[];
  67140. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67141. dispose(forceDisposeEffect?: boolean): void;
  67142. clone(name: string): FurMaterial;
  67143. serialize(): any;
  67144. getClassName(): string;
  67145. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  67146. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  67147. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  67148. }
  67149. }
  67150. declare module BABYLON {
  67151. /** @hidden */
  67152. export var gradientPixelShader: {
  67153. name: string;
  67154. shader: string;
  67155. };
  67156. }
  67157. declare module BABYLON {
  67158. /** @hidden */
  67159. export var gradientVertexShader: {
  67160. name: string;
  67161. shader: string;
  67162. };
  67163. }
  67164. declare module BABYLON {
  67165. export class GradientMaterial extends BABYLON.PushMaterial {
  67166. private _maxSimultaneousLights;
  67167. maxSimultaneousLights: number;
  67168. topColor: BABYLON.Color3;
  67169. topColorAlpha: number;
  67170. bottomColor: BABYLON.Color3;
  67171. bottomColorAlpha: number;
  67172. offset: number;
  67173. scale: number;
  67174. smoothness: number;
  67175. private _disableLighting;
  67176. disableLighting: boolean;
  67177. private _renderId;
  67178. constructor(name: string, scene: BABYLON.Scene);
  67179. needAlphaBlending(): boolean;
  67180. needAlphaTesting(): boolean;
  67181. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67182. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67183. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67184. getAnimatables(): BABYLON.IAnimatable[];
  67185. dispose(forceDisposeEffect?: boolean): void;
  67186. clone(name: string): GradientMaterial;
  67187. serialize(): any;
  67188. getClassName(): string;
  67189. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  67190. }
  67191. }
  67192. declare module BABYLON {
  67193. /** @hidden */
  67194. export var gridPixelShader: {
  67195. name: string;
  67196. shader: string;
  67197. };
  67198. }
  67199. declare module BABYLON {
  67200. /** @hidden */
  67201. export var gridVertexShader: {
  67202. name: string;
  67203. shader: string;
  67204. };
  67205. }
  67206. declare module BABYLON {
  67207. /**
  67208. * The grid materials allows you to wrap any shape with a grid.
  67209. * Colors are customizable.
  67210. */
  67211. export class GridMaterial extends BABYLON.PushMaterial {
  67212. /**
  67213. * Main color of the grid (e.g. between lines)
  67214. */
  67215. mainColor: BABYLON.Color3;
  67216. /**
  67217. * Color of the grid lines.
  67218. */
  67219. lineColor: BABYLON.Color3;
  67220. /**
  67221. * The scale of the grid compared to unit.
  67222. */
  67223. gridRatio: number;
  67224. /**
  67225. * Allows setting an offset for the grid lines.
  67226. */
  67227. gridOffset: BABYLON.Vector3;
  67228. /**
  67229. * The frequency of thicker lines.
  67230. */
  67231. majorUnitFrequency: number;
  67232. /**
  67233. * The visibility of minor units in the grid.
  67234. */
  67235. minorUnitVisibility: number;
  67236. /**
  67237. * The grid opacity outside of the lines.
  67238. */
  67239. opacity: number;
  67240. /**
  67241. * Determine RBG output is premultiplied by alpha value.
  67242. */
  67243. preMultiplyAlpha: boolean;
  67244. private _opacityTexture;
  67245. opacityTexture: BABYLON.BaseTexture;
  67246. private _gridControl;
  67247. private _renderId;
  67248. /**
  67249. * constructor
  67250. * @param name The name given to the material in order to identify it afterwards.
  67251. * @param scene The scene the material is used in.
  67252. */
  67253. constructor(name: string, scene: BABYLON.Scene);
  67254. /**
  67255. * Returns wehter or not the grid requires alpha blending.
  67256. */
  67257. needAlphaBlending(): boolean;
  67258. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  67259. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67260. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67261. /**
  67262. * Dispose the material and its associated resources.
  67263. * @param forceDisposeEffect will also dispose the used effect when true
  67264. */
  67265. dispose(forceDisposeEffect?: boolean): void;
  67266. clone(name: string): GridMaterial;
  67267. serialize(): any;
  67268. getClassName(): string;
  67269. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  67270. }
  67271. }
  67272. declare module BABYLON {
  67273. /** @hidden */
  67274. export var lavaPixelShader: {
  67275. name: string;
  67276. shader: string;
  67277. };
  67278. }
  67279. declare module BABYLON {
  67280. /** @hidden */
  67281. export var lavaVertexShader: {
  67282. name: string;
  67283. shader: string;
  67284. };
  67285. }
  67286. declare module BABYLON {
  67287. export class LavaMaterial extends BABYLON.PushMaterial {
  67288. private _diffuseTexture;
  67289. diffuseTexture: BABYLON.BaseTexture;
  67290. noiseTexture: BABYLON.BaseTexture;
  67291. fogColor: BABYLON.Color3;
  67292. speed: number;
  67293. movingSpeed: number;
  67294. lowFrequencySpeed: number;
  67295. fogDensity: number;
  67296. private _lastTime;
  67297. diffuseColor: BABYLON.Color3;
  67298. private _disableLighting;
  67299. disableLighting: boolean;
  67300. private _unlit;
  67301. unlit: boolean;
  67302. private _maxSimultaneousLights;
  67303. maxSimultaneousLights: number;
  67304. private _scaledDiffuse;
  67305. private _renderId;
  67306. constructor(name: string, scene: BABYLON.Scene);
  67307. needAlphaBlending(): boolean;
  67308. needAlphaTesting(): boolean;
  67309. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67310. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67311. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67312. getAnimatables(): BABYLON.IAnimatable[];
  67313. getActiveTextures(): BABYLON.BaseTexture[];
  67314. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67315. dispose(forceDisposeEffect?: boolean): void;
  67316. clone(name: string): LavaMaterial;
  67317. serialize(): any;
  67318. getClassName(): string;
  67319. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  67320. }
  67321. }
  67322. declare module BABYLON {
  67323. /** @hidden */
  67324. export var mixPixelShader: {
  67325. name: string;
  67326. shader: string;
  67327. };
  67328. }
  67329. declare module BABYLON {
  67330. /** @hidden */
  67331. export var mixVertexShader: {
  67332. name: string;
  67333. shader: string;
  67334. };
  67335. }
  67336. declare module BABYLON {
  67337. export class MixMaterial extends BABYLON.PushMaterial {
  67338. /**
  67339. * Mix textures
  67340. */
  67341. private _mixTexture1;
  67342. mixTexture1: BABYLON.BaseTexture;
  67343. private _mixTexture2;
  67344. mixTexture2: BABYLON.BaseTexture;
  67345. /**
  67346. * Diffuse textures
  67347. */
  67348. private _diffuseTexture1;
  67349. diffuseTexture1: BABYLON.Texture;
  67350. private _diffuseTexture2;
  67351. diffuseTexture2: BABYLON.Texture;
  67352. private _diffuseTexture3;
  67353. diffuseTexture3: BABYLON.Texture;
  67354. private _diffuseTexture4;
  67355. diffuseTexture4: BABYLON.Texture;
  67356. private _diffuseTexture5;
  67357. diffuseTexture5: BABYLON.Texture;
  67358. private _diffuseTexture6;
  67359. diffuseTexture6: BABYLON.Texture;
  67360. private _diffuseTexture7;
  67361. diffuseTexture7: BABYLON.Texture;
  67362. private _diffuseTexture8;
  67363. diffuseTexture8: BABYLON.Texture;
  67364. /**
  67365. * Uniforms
  67366. */
  67367. diffuseColor: BABYLON.Color3;
  67368. specularColor: BABYLON.Color3;
  67369. specularPower: number;
  67370. private _disableLighting;
  67371. disableLighting: boolean;
  67372. private _maxSimultaneousLights;
  67373. maxSimultaneousLights: number;
  67374. private _renderId;
  67375. constructor(name: string, scene: BABYLON.Scene);
  67376. needAlphaBlending(): boolean;
  67377. needAlphaTesting(): boolean;
  67378. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67379. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67380. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67381. getAnimatables(): BABYLON.IAnimatable[];
  67382. getActiveTextures(): BABYLON.BaseTexture[];
  67383. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67384. dispose(forceDisposeEffect?: boolean): void;
  67385. clone(name: string): MixMaterial;
  67386. serialize(): any;
  67387. getClassName(): string;
  67388. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  67389. }
  67390. }
  67391. declare module BABYLON {
  67392. /** @hidden */
  67393. export var normalPixelShader: {
  67394. name: string;
  67395. shader: string;
  67396. };
  67397. }
  67398. declare module BABYLON {
  67399. /** @hidden */
  67400. export var normalVertexShader: {
  67401. name: string;
  67402. shader: string;
  67403. };
  67404. }
  67405. declare module BABYLON {
  67406. export class NormalMaterial extends BABYLON.PushMaterial {
  67407. private _diffuseTexture;
  67408. diffuseTexture: BABYLON.BaseTexture;
  67409. diffuseColor: BABYLON.Color3;
  67410. private _disableLighting;
  67411. disableLighting: boolean;
  67412. private _maxSimultaneousLights;
  67413. maxSimultaneousLights: number;
  67414. private _renderId;
  67415. constructor(name: string, scene: BABYLON.Scene);
  67416. needAlphaBlending(): boolean;
  67417. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  67418. needAlphaTesting(): boolean;
  67419. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67420. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67421. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67422. getAnimatables(): BABYLON.IAnimatable[];
  67423. getActiveTextures(): BABYLON.BaseTexture[];
  67424. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67425. dispose(forceDisposeEffect?: boolean): void;
  67426. clone(name: string): NormalMaterial;
  67427. serialize(): any;
  67428. getClassName(): string;
  67429. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  67430. }
  67431. }
  67432. declare module BABYLON {
  67433. /** @hidden */
  67434. export var shadowOnlyPixelShader: {
  67435. name: string;
  67436. shader: string;
  67437. };
  67438. }
  67439. declare module BABYLON {
  67440. /** @hidden */
  67441. export var shadowOnlyVertexShader: {
  67442. name: string;
  67443. shader: string;
  67444. };
  67445. }
  67446. declare module BABYLON {
  67447. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  67448. private _renderId;
  67449. private _activeLight;
  67450. constructor(name: string, scene: BABYLON.Scene);
  67451. shadowColor: BABYLON.Color3;
  67452. needAlphaBlending(): boolean;
  67453. needAlphaTesting(): boolean;
  67454. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67455. activeLight: BABYLON.IShadowLight;
  67456. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67457. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67458. clone(name: string): ShadowOnlyMaterial;
  67459. serialize(): any;
  67460. getClassName(): string;
  67461. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  67462. }
  67463. }
  67464. declare module BABYLON {
  67465. /** @hidden */
  67466. export var simplePixelShader: {
  67467. name: string;
  67468. shader: string;
  67469. };
  67470. }
  67471. declare module BABYLON {
  67472. /** @hidden */
  67473. export var simpleVertexShader: {
  67474. name: string;
  67475. shader: string;
  67476. };
  67477. }
  67478. declare module BABYLON {
  67479. export class SimpleMaterial extends BABYLON.PushMaterial {
  67480. private _diffuseTexture;
  67481. diffuseTexture: BABYLON.BaseTexture;
  67482. diffuseColor: BABYLON.Color3;
  67483. private _disableLighting;
  67484. disableLighting: boolean;
  67485. private _maxSimultaneousLights;
  67486. maxSimultaneousLights: number;
  67487. private _renderId;
  67488. constructor(name: string, scene: BABYLON.Scene);
  67489. needAlphaBlending(): boolean;
  67490. needAlphaTesting(): boolean;
  67491. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67492. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67493. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67494. getAnimatables(): BABYLON.IAnimatable[];
  67495. getActiveTextures(): BABYLON.BaseTexture[];
  67496. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67497. dispose(forceDisposeEffect?: boolean): void;
  67498. clone(name: string): SimpleMaterial;
  67499. serialize(): any;
  67500. getClassName(): string;
  67501. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  67502. }
  67503. }
  67504. declare module BABYLON {
  67505. /** @hidden */
  67506. export var skyPixelShader: {
  67507. name: string;
  67508. shader: string;
  67509. };
  67510. }
  67511. declare module BABYLON {
  67512. /** @hidden */
  67513. export var skyVertexShader: {
  67514. name: string;
  67515. shader: string;
  67516. };
  67517. }
  67518. declare module BABYLON {
  67519. /**
  67520. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  67521. * @see https://doc.babylonjs.com/extensions/sky
  67522. */
  67523. export class SkyMaterial extends BABYLON.PushMaterial {
  67524. /**
  67525. * Defines the overall luminance of sky in interval ]0, 1[.
  67526. */
  67527. luminance: number;
  67528. /**
  67529. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  67530. */
  67531. turbidity: number;
  67532. /**
  67533. * Defines the sky appearance (light intensity).
  67534. */
  67535. rayleigh: number;
  67536. /**
  67537. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  67538. */
  67539. mieCoefficient: number;
  67540. /**
  67541. * Defines the amount of haze particles following the Mie scattering theory.
  67542. */
  67543. mieDirectionalG: number;
  67544. /**
  67545. * Defines the distance of the sun according to the active scene camera.
  67546. */
  67547. distance: number;
  67548. /**
  67549. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  67550. * "inclined".
  67551. */
  67552. inclination: number;
  67553. /**
  67554. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  67555. * an object direction and a reference direction.
  67556. */
  67557. azimuth: number;
  67558. /**
  67559. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  67560. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  67561. */
  67562. sunPosition: BABYLON.Vector3;
  67563. /**
  67564. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  67565. * .sunPosition property.
  67566. */
  67567. useSunPosition: boolean;
  67568. /**
  67569. * Defines an offset vector used to get a horizon offset.
  67570. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  67571. */
  67572. cameraOffset: BABYLON.Vector3;
  67573. private _cameraPosition;
  67574. private _renderId;
  67575. /**
  67576. * Instantiates a new sky material.
  67577. * This material allows to create dynamic and texture free
  67578. * effects for skyboxes by taking care of the atmosphere state.
  67579. * @see https://doc.babylonjs.com/extensions/sky
  67580. * @param name Define the name of the material in the scene
  67581. * @param scene Define the scene the material belong to
  67582. */
  67583. constructor(name: string, scene: BABYLON.Scene);
  67584. /**
  67585. * Specifies if the material will require alpha blending
  67586. * @returns a boolean specifying if alpha blending is needed
  67587. */
  67588. needAlphaBlending(): boolean;
  67589. /**
  67590. * Specifies if this material should be rendered in alpha test mode
  67591. * @returns false as the sky material doesn't need alpha testing.
  67592. */
  67593. needAlphaTesting(): boolean;
  67594. /**
  67595. * Get the texture used for alpha test purpose.
  67596. * @returns null as the sky material has no texture.
  67597. */
  67598. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67599. /**
  67600. * Get if the submesh is ready to be used and all its information available.
  67601. * Child classes can use it to update shaders
  67602. * @param mesh defines the mesh to check
  67603. * @param subMesh defines which submesh to check
  67604. * @param useInstances specifies that instances should be used
  67605. * @returns a boolean indicating that the submesh is ready or not
  67606. */
  67607. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67608. /**
  67609. * Binds the submesh to this material by preparing the effect and shader to draw
  67610. * @param world defines the world transformation matrix
  67611. * @param mesh defines the mesh containing the submesh
  67612. * @param subMesh defines the submesh to bind the material to
  67613. */
  67614. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67615. /**
  67616. * Get the list of animatables in the material.
  67617. * @returns the list of animatables object used in the material
  67618. */
  67619. getAnimatables(): BABYLON.IAnimatable[];
  67620. /**
  67621. * Disposes the material
  67622. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  67623. */
  67624. dispose(forceDisposeEffect?: boolean): void;
  67625. /**
  67626. * Makes a duplicate of the material, and gives it a new name
  67627. * @param name defines the new name for the duplicated material
  67628. * @returns the cloned material
  67629. */
  67630. clone(name: string): SkyMaterial;
  67631. /**
  67632. * Serializes this material in a JSON representation
  67633. * @returns the serialized material object
  67634. */
  67635. serialize(): any;
  67636. /**
  67637. * Gets the current class name of the material e.g. "SkyMaterial"
  67638. * Mainly use in serialization.
  67639. * @returns the class name
  67640. */
  67641. getClassName(): string;
  67642. /**
  67643. * Creates a sky material from parsed material data
  67644. * @param source defines the JSON representation of the material
  67645. * @param scene defines the hosting scene
  67646. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67647. * @returns a new sky material
  67648. */
  67649. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  67650. }
  67651. }
  67652. declare module BABYLON {
  67653. /** @hidden */
  67654. export var terrainPixelShader: {
  67655. name: string;
  67656. shader: string;
  67657. };
  67658. }
  67659. declare module BABYLON {
  67660. /** @hidden */
  67661. export var terrainVertexShader: {
  67662. name: string;
  67663. shader: string;
  67664. };
  67665. }
  67666. declare module BABYLON {
  67667. export class TerrainMaterial extends BABYLON.PushMaterial {
  67668. private _mixTexture;
  67669. mixTexture: BABYLON.BaseTexture;
  67670. private _diffuseTexture1;
  67671. diffuseTexture1: BABYLON.Texture;
  67672. private _diffuseTexture2;
  67673. diffuseTexture2: BABYLON.Texture;
  67674. private _diffuseTexture3;
  67675. diffuseTexture3: BABYLON.Texture;
  67676. private _bumpTexture1;
  67677. bumpTexture1: BABYLON.Texture;
  67678. private _bumpTexture2;
  67679. bumpTexture2: BABYLON.Texture;
  67680. private _bumpTexture3;
  67681. bumpTexture3: BABYLON.Texture;
  67682. diffuseColor: BABYLON.Color3;
  67683. specularColor: BABYLON.Color3;
  67684. specularPower: number;
  67685. private _disableLighting;
  67686. disableLighting: boolean;
  67687. private _maxSimultaneousLights;
  67688. maxSimultaneousLights: number;
  67689. private _renderId;
  67690. constructor(name: string, scene: BABYLON.Scene);
  67691. needAlphaBlending(): boolean;
  67692. needAlphaTesting(): boolean;
  67693. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67694. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67695. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67696. getAnimatables(): BABYLON.IAnimatable[];
  67697. getActiveTextures(): BABYLON.BaseTexture[];
  67698. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67699. dispose(forceDisposeEffect?: boolean): void;
  67700. clone(name: string): TerrainMaterial;
  67701. serialize(): any;
  67702. getClassName(): string;
  67703. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  67704. }
  67705. }
  67706. declare module BABYLON {
  67707. /** @hidden */
  67708. export var triplanarPixelShader: {
  67709. name: string;
  67710. shader: string;
  67711. };
  67712. }
  67713. declare module BABYLON {
  67714. /** @hidden */
  67715. export var triplanarVertexShader: {
  67716. name: string;
  67717. shader: string;
  67718. };
  67719. }
  67720. declare module BABYLON {
  67721. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  67722. mixTexture: BABYLON.BaseTexture;
  67723. private _diffuseTextureX;
  67724. diffuseTextureX: BABYLON.BaseTexture;
  67725. private _diffuseTextureY;
  67726. diffuseTextureY: BABYLON.BaseTexture;
  67727. private _diffuseTextureZ;
  67728. diffuseTextureZ: BABYLON.BaseTexture;
  67729. private _normalTextureX;
  67730. normalTextureX: BABYLON.BaseTexture;
  67731. private _normalTextureY;
  67732. normalTextureY: BABYLON.BaseTexture;
  67733. private _normalTextureZ;
  67734. normalTextureZ: BABYLON.BaseTexture;
  67735. tileSize: number;
  67736. diffuseColor: BABYLON.Color3;
  67737. specularColor: BABYLON.Color3;
  67738. specularPower: number;
  67739. private _disableLighting;
  67740. disableLighting: boolean;
  67741. private _maxSimultaneousLights;
  67742. maxSimultaneousLights: number;
  67743. private _renderId;
  67744. constructor(name: string, scene: BABYLON.Scene);
  67745. needAlphaBlending(): boolean;
  67746. needAlphaTesting(): boolean;
  67747. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67748. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67749. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67750. getAnimatables(): BABYLON.IAnimatable[];
  67751. getActiveTextures(): BABYLON.BaseTexture[];
  67752. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67753. dispose(forceDisposeEffect?: boolean): void;
  67754. clone(name: string): TriPlanarMaterial;
  67755. serialize(): any;
  67756. getClassName(): string;
  67757. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  67758. }
  67759. }
  67760. declare module BABYLON {
  67761. /** @hidden */
  67762. export var waterPixelShader: {
  67763. name: string;
  67764. shader: string;
  67765. };
  67766. }
  67767. declare module BABYLON {
  67768. /** @hidden */
  67769. export var waterVertexShader: {
  67770. name: string;
  67771. shader: string;
  67772. };
  67773. }
  67774. declare module BABYLON {
  67775. export class WaterMaterial extends BABYLON.PushMaterial {
  67776. renderTargetSize: BABYLON.Vector2;
  67777. private _bumpTexture;
  67778. bumpTexture: BABYLON.BaseTexture;
  67779. diffuseColor: BABYLON.Color3;
  67780. specularColor: BABYLON.Color3;
  67781. specularPower: number;
  67782. private _disableLighting;
  67783. disableLighting: boolean;
  67784. private _maxSimultaneousLights;
  67785. maxSimultaneousLights: number;
  67786. /**
  67787. * @param {number}: Represents the wind force
  67788. */
  67789. windForce: number;
  67790. /**
  67791. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  67792. */
  67793. windDirection: BABYLON.Vector2;
  67794. /**
  67795. * @param {number}: Wave height, represents the height of the waves
  67796. */
  67797. waveHeight: number;
  67798. /**
  67799. * @param {number}: Bump height, represents the bump height related to the bump map
  67800. */
  67801. bumpHeight: number;
  67802. /**
  67803. * @param {boolean}: Add a smaller moving bump to less steady waves.
  67804. */
  67805. private _bumpSuperimpose;
  67806. bumpSuperimpose: boolean;
  67807. /**
  67808. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  67809. */
  67810. private _fresnelSeparate;
  67811. fresnelSeparate: boolean;
  67812. /**
  67813. * @param {boolean}: bump Waves modify the reflection.
  67814. */
  67815. private _bumpAffectsReflection;
  67816. bumpAffectsReflection: boolean;
  67817. /**
  67818. * @param {number}: The water color blended with the refraction (near)
  67819. */
  67820. waterColor: BABYLON.Color3;
  67821. /**
  67822. * @param {number}: The blend factor related to the water color
  67823. */
  67824. colorBlendFactor: number;
  67825. /**
  67826. * @param {number}: The water color blended with the reflection (far)
  67827. */
  67828. waterColor2: BABYLON.Color3;
  67829. /**
  67830. * @param {number}: The blend factor related to the water color (reflection, far)
  67831. */
  67832. colorBlendFactor2: number;
  67833. /**
  67834. * @param {number}: Represents the maximum length of a wave
  67835. */
  67836. waveLength: number;
  67837. /**
  67838. * @param {number}: Defines the waves speed
  67839. */
  67840. waveSpeed: number;
  67841. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  67842. private _mesh;
  67843. private _refractionRTT;
  67844. private _reflectionRTT;
  67845. private _reflectionTransform;
  67846. private _lastTime;
  67847. private _lastDeltaTime;
  67848. private _renderId;
  67849. private _useLogarithmicDepth;
  67850. private _waitingRenderList;
  67851. /**
  67852. * Gets a boolean indicating that current material needs to register RTT
  67853. */
  67854. readonly hasRenderTargetTextures: boolean;
  67855. /**
  67856. * Constructor
  67857. */
  67858. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  67859. useLogarithmicDepth: boolean;
  67860. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  67861. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  67862. addToRenderList(node: any): void;
  67863. enableRenderTargets(enable: boolean): void;
  67864. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  67865. readonly renderTargetsEnabled: boolean;
  67866. needAlphaBlending(): boolean;
  67867. needAlphaTesting(): boolean;
  67868. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67869. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67870. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67871. private _createRenderTargets;
  67872. getAnimatables(): BABYLON.IAnimatable[];
  67873. getActiveTextures(): BABYLON.BaseTexture[];
  67874. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67875. dispose(forceDisposeEffect?: boolean): void;
  67876. clone(name: string): WaterMaterial;
  67877. serialize(): any;
  67878. getClassName(): string;
  67879. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  67880. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  67881. }
  67882. }
  67883. declare module BABYLON {
  67884. /** @hidden */
  67885. export var asciiartPixelShader: {
  67886. name: string;
  67887. shader: string;
  67888. };
  67889. }
  67890. declare module BABYLON {
  67891. /**
  67892. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  67893. *
  67894. * It basically takes care rendering the font front the given font size to a texture.
  67895. * This is used later on in the postprocess.
  67896. */
  67897. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  67898. private _font;
  67899. private _text;
  67900. private _charSize;
  67901. /**
  67902. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  67903. */
  67904. readonly charSize: number;
  67905. /**
  67906. * Create a new instance of the Ascii Art FontTexture class
  67907. * @param name the name of the texture
  67908. * @param font the font to use, use the W3C CSS notation
  67909. * @param text the caracter set to use in the rendering.
  67910. * @param scene the scene that owns the texture
  67911. */
  67912. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  67913. /**
  67914. * Gets the max char width of a font.
  67915. * @param font the font to use, use the W3C CSS notation
  67916. * @return the max char width
  67917. */
  67918. private getFontWidth;
  67919. /**
  67920. * Gets the max char height of a font.
  67921. * @param font the font to use, use the W3C CSS notation
  67922. * @return the max char height
  67923. */
  67924. private getFontHeight;
  67925. /**
  67926. * Clones the current AsciiArtTexture.
  67927. * @return the clone of the texture.
  67928. */
  67929. clone(): AsciiArtFontTexture;
  67930. /**
  67931. * Parses a json object representing the texture and returns an instance of it.
  67932. * @param source the source JSON representation
  67933. * @param scene the scene to create the texture for
  67934. * @return the parsed texture
  67935. */
  67936. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  67937. }
  67938. /**
  67939. * Option available in the Ascii Art Post Process.
  67940. */
  67941. export interface IAsciiArtPostProcessOptions {
  67942. /**
  67943. * The font to use following the w3c font definition.
  67944. */
  67945. font?: string;
  67946. /**
  67947. * The character set to use in the postprocess.
  67948. */
  67949. characterSet?: string;
  67950. /**
  67951. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  67952. * This number is defined between 0 and 1;
  67953. */
  67954. mixToTile?: number;
  67955. /**
  67956. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  67957. * This number is defined between 0 and 1;
  67958. */
  67959. mixToNormal?: number;
  67960. }
  67961. /**
  67962. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  67963. *
  67964. * Simmply add it to your scene and let the nerd that lives in you have fun.
  67965. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  67966. */
  67967. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  67968. /**
  67969. * The font texture used to render the char in the post process.
  67970. */
  67971. private _asciiArtFontTexture;
  67972. /**
  67973. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  67974. * This number is defined between 0 and 1;
  67975. */
  67976. mixToTile: number;
  67977. /**
  67978. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  67979. * This number is defined between 0 and 1;
  67980. */
  67981. mixToNormal: number;
  67982. /**
  67983. * Instantiates a new Ascii Art Post Process.
  67984. * @param name the name to give to the postprocess
  67985. * @camera the camera to apply the post process to.
  67986. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  67987. */
  67988. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  67989. }
  67990. }
  67991. declare module BABYLON {
  67992. /** @hidden */
  67993. export var digitalrainPixelShader: {
  67994. name: string;
  67995. shader: string;
  67996. };
  67997. }
  67998. declare module BABYLON {
  67999. /**
  68000. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  68001. *
  68002. * It basically takes care rendering the font front the given font size to a texture.
  68003. * This is used later on in the postprocess.
  68004. */
  68005. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  68006. private _font;
  68007. private _text;
  68008. private _charSize;
  68009. /**
  68010. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  68011. */
  68012. readonly charSize: number;
  68013. /**
  68014. * Create a new instance of the Digital Rain FontTexture class
  68015. * @param name the name of the texture
  68016. * @param font the font to use, use the W3C CSS notation
  68017. * @param text the caracter set to use in the rendering.
  68018. * @param scene the scene that owns the texture
  68019. */
  68020. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  68021. /**
  68022. * Gets the max char width of a font.
  68023. * @param font the font to use, use the W3C CSS notation
  68024. * @return the max char width
  68025. */
  68026. private getFontWidth;
  68027. /**
  68028. * Gets the max char height of a font.
  68029. * @param font the font to use, use the W3C CSS notation
  68030. * @return the max char height
  68031. */
  68032. private getFontHeight;
  68033. /**
  68034. * Clones the current DigitalRainFontTexture.
  68035. * @return the clone of the texture.
  68036. */
  68037. clone(): DigitalRainFontTexture;
  68038. /**
  68039. * Parses a json object representing the texture and returns an instance of it.
  68040. * @param source the source JSON representation
  68041. * @param scene the scene to create the texture for
  68042. * @return the parsed texture
  68043. */
  68044. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  68045. }
  68046. /**
  68047. * Option available in the Digital Rain Post Process.
  68048. */
  68049. export interface IDigitalRainPostProcessOptions {
  68050. /**
  68051. * The font to use following the w3c font definition.
  68052. */
  68053. font?: string;
  68054. /**
  68055. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  68056. * This number is defined between 0 and 1;
  68057. */
  68058. mixToTile?: number;
  68059. /**
  68060. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  68061. * This number is defined between 0 and 1;
  68062. */
  68063. mixToNormal?: number;
  68064. }
  68065. /**
  68066. * DigitalRainPostProcess helps rendering everithing in digital rain.
  68067. *
  68068. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68069. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  68070. */
  68071. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  68072. /**
  68073. * The font texture used to render the char in the post process.
  68074. */
  68075. private _digitalRainFontTexture;
  68076. /**
  68077. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  68078. * This number is defined between 0 and 1;
  68079. */
  68080. mixToTile: number;
  68081. /**
  68082. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  68083. * This number is defined between 0 and 1;
  68084. */
  68085. mixToNormal: number;
  68086. /**
  68087. * Instantiates a new Digital Rain Post Process.
  68088. * @param name the name to give to the postprocess
  68089. * @camera the camera to apply the post process to.
  68090. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  68091. */
  68092. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  68093. }
  68094. }
  68095. declare module BABYLON {
  68096. /** @hidden */
  68097. export var oceanPostProcessPixelShader: {
  68098. name: string;
  68099. shader: string;
  68100. };
  68101. }
  68102. declare module BABYLON {
  68103. /**
  68104. * Option available in the Ocean Post Process.
  68105. */
  68106. export interface IOceanPostProcessOptions {
  68107. /**
  68108. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  68109. */
  68110. reflectionSize?: number | {
  68111. width: number;
  68112. height: number;
  68113. } | {
  68114. ratio: number;
  68115. };
  68116. /**
  68117. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  68118. */
  68119. refractionSize?: number | {
  68120. width: number;
  68121. height: number;
  68122. } | {
  68123. ratio: number;
  68124. };
  68125. }
  68126. /**
  68127. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  68128. *
  68129. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68130. * Example usage:
  68131. * var pp = new OceanPostProcess("myOcean", camera);
  68132. * pp.reflectionEnabled = true;
  68133. * pp.refractionEnabled = true;
  68134. */
  68135. export class OceanPostProcess extends BABYLON.PostProcess {
  68136. /**
  68137. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  68138. */
  68139. /**
  68140. * Sets weither or not the real-time reflection is enabled on the ocean.
  68141. * Is set to true, the reflection mirror texture will be used as reflection texture.
  68142. */
  68143. reflectionEnabled: boolean;
  68144. /**
  68145. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  68146. */
  68147. /**
  68148. * Sets weither or not the real-time refraction is enabled on the ocean.
  68149. * Is set to true, the refraction render target texture will be used as refraction texture.
  68150. */
  68151. refractionEnabled: boolean;
  68152. /**
  68153. * Gets wether or not the post-processes is supported by the running hardware.
  68154. * This requires draw buffer supports.
  68155. */
  68156. readonly isSupported: boolean;
  68157. /**
  68158. * This is the reflection mirror texture used to display reflections on the ocean.
  68159. * By default, render list is empty.
  68160. */
  68161. reflectionTexture: BABYLON.MirrorTexture;
  68162. /**
  68163. * This is the refraction render target texture used to display refraction on the ocean.
  68164. * By default, render list is empty.
  68165. */
  68166. refractionTexture: BABYLON.RenderTargetTexture;
  68167. private _time;
  68168. private _cameraRotation;
  68169. private _cameraViewMatrix;
  68170. private _reflectionEnabled;
  68171. private _refractionEnabled;
  68172. private _geometryRenderer;
  68173. /**
  68174. * Instantiates a new Ocean Post Process.
  68175. * @param name the name to give to the postprocess.
  68176. * @camera the camera to apply the post process to.
  68177. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  68178. */
  68179. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  68180. /**
  68181. * Returns the appropriate defines according to the current configuration.
  68182. */
  68183. private _getDefines;
  68184. /**
  68185. * Computes the current camera rotation as the shader requires a camera rotation.
  68186. */
  68187. private _computeCameraRotation;
  68188. }
  68189. }
  68190. declare module BABYLON {
  68191. /** @hidden */
  68192. export var brickProceduralTexturePixelShader: {
  68193. name: string;
  68194. shader: string;
  68195. };
  68196. }
  68197. declare module BABYLON {
  68198. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  68199. private _numberOfBricksHeight;
  68200. private _numberOfBricksWidth;
  68201. private _jointColor;
  68202. private _brickColor;
  68203. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68204. updateShaderUniforms(): void;
  68205. numberOfBricksHeight: number;
  68206. numberOfBricksWidth: number;
  68207. jointColor: BABYLON.Color3;
  68208. brickColor: BABYLON.Color3;
  68209. /**
  68210. * Serializes this brick procedural texture
  68211. * @returns a serialized brick procedural texture object
  68212. */
  68213. serialize(): any;
  68214. /**
  68215. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  68216. * @param parsedTexture defines parsed texture data
  68217. * @param scene defines the current scene
  68218. * @param rootUrl defines the root URL containing brick procedural texture information
  68219. * @returns a parsed Brick Procedural BABYLON.Texture
  68220. */
  68221. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  68222. }
  68223. }
  68224. declare module BABYLON {
  68225. /** @hidden */
  68226. export var cloudProceduralTexturePixelShader: {
  68227. name: string;
  68228. shader: string;
  68229. };
  68230. }
  68231. declare module BABYLON {
  68232. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  68233. private _skyColor;
  68234. private _cloudColor;
  68235. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68236. updateShaderUniforms(): void;
  68237. skyColor: BABYLON.Color4;
  68238. cloudColor: BABYLON.Color4;
  68239. /**
  68240. * Serializes this cloud procedural texture
  68241. * @returns a serialized cloud procedural texture object
  68242. */
  68243. serialize(): any;
  68244. /**
  68245. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  68246. * @param parsedTexture defines parsed texture data
  68247. * @param scene defines the current scene
  68248. * @param rootUrl defines the root URL containing cloud procedural texture information
  68249. * @returns a parsed Cloud Procedural BABYLON.Texture
  68250. */
  68251. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  68252. }
  68253. }
  68254. declare module BABYLON {
  68255. /** @hidden */
  68256. export var fireProceduralTexturePixelShader: {
  68257. name: string;
  68258. shader: string;
  68259. };
  68260. }
  68261. declare module BABYLON {
  68262. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  68263. private _time;
  68264. private _speed;
  68265. private _autoGenerateTime;
  68266. private _fireColors;
  68267. private _alphaThreshold;
  68268. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68269. updateShaderUniforms(): void;
  68270. render(useCameraPostProcess?: boolean): void;
  68271. static readonly PurpleFireColors: BABYLON.Color3[];
  68272. static readonly GreenFireColors: BABYLON.Color3[];
  68273. static readonly RedFireColors: BABYLON.Color3[];
  68274. static readonly BlueFireColors: BABYLON.Color3[];
  68275. autoGenerateTime: boolean;
  68276. fireColors: BABYLON.Color3[];
  68277. time: number;
  68278. speed: BABYLON.Vector2;
  68279. alphaThreshold: number;
  68280. /**
  68281. * Serializes this fire procedural texture
  68282. * @returns a serialized fire procedural texture object
  68283. */
  68284. serialize(): any;
  68285. /**
  68286. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  68287. * @param parsedTexture defines parsed texture data
  68288. * @param scene defines the current scene
  68289. * @param rootUrl defines the root URL containing fire procedural texture information
  68290. * @returns a parsed Fire Procedural BABYLON.Texture
  68291. */
  68292. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  68293. }
  68294. }
  68295. declare module BABYLON {
  68296. /** @hidden */
  68297. export var grassProceduralTexturePixelShader: {
  68298. name: string;
  68299. shader: string;
  68300. };
  68301. }
  68302. declare module BABYLON {
  68303. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  68304. private _grassColors;
  68305. private _groundColor;
  68306. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68307. updateShaderUniforms(): void;
  68308. grassColors: BABYLON.Color3[];
  68309. groundColor: BABYLON.Color3;
  68310. /**
  68311. * Serializes this grass procedural texture
  68312. * @returns a serialized grass procedural texture object
  68313. */
  68314. serialize(): any;
  68315. /**
  68316. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  68317. * @param parsedTexture defines parsed texture data
  68318. * @param scene defines the current scene
  68319. * @param rootUrl defines the root URL containing grass procedural texture information
  68320. * @returns a parsed Grass Procedural BABYLON.Texture
  68321. */
  68322. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  68323. }
  68324. }
  68325. declare module BABYLON {
  68326. /** @hidden */
  68327. export var marbleProceduralTexturePixelShader: {
  68328. name: string;
  68329. shader: string;
  68330. };
  68331. }
  68332. declare module BABYLON {
  68333. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  68334. private _numberOfTilesHeight;
  68335. private _numberOfTilesWidth;
  68336. private _amplitude;
  68337. private _jointColor;
  68338. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68339. updateShaderUniforms(): void;
  68340. numberOfTilesHeight: number;
  68341. amplitude: number;
  68342. numberOfTilesWidth: number;
  68343. jointColor: BABYLON.Color3;
  68344. /**
  68345. * Serializes this marble procedural texture
  68346. * @returns a serialized marble procedural texture object
  68347. */
  68348. serialize(): any;
  68349. /**
  68350. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  68351. * @param parsedTexture defines parsed texture data
  68352. * @param scene defines the current scene
  68353. * @param rootUrl defines the root URL containing marble procedural texture information
  68354. * @returns a parsed Marble Procedural BABYLON.Texture
  68355. */
  68356. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  68357. }
  68358. }
  68359. declare module BABYLON {
  68360. /** @hidden */
  68361. export var normalMapProceduralTexturePixelShader: {
  68362. name: string;
  68363. shader: string;
  68364. };
  68365. }
  68366. declare module BABYLON {
  68367. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  68368. private _baseTexture;
  68369. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68370. updateShaderUniforms(): void;
  68371. render(useCameraPostProcess?: boolean): void;
  68372. resize(size: any, generateMipMaps: any): void;
  68373. baseTexture: BABYLON.Texture;
  68374. /**
  68375. * Serializes this normal map procedural texture
  68376. * @returns a serialized normal map procedural texture object
  68377. */
  68378. serialize(): any;
  68379. /**
  68380. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  68381. * @param parsedTexture defines parsed texture data
  68382. * @param scene defines the current scene
  68383. * @param rootUrl defines the root URL containing normal map procedural texture information
  68384. * @returns a parsed Normal Map Procedural BABYLON.Texture
  68385. */
  68386. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  68387. }
  68388. }
  68389. declare module BABYLON {
  68390. /** @hidden */
  68391. export var perlinNoiseProceduralTexturePixelShader: {
  68392. name: string;
  68393. shader: string;
  68394. };
  68395. }
  68396. declare module BABYLON {
  68397. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  68398. time: number;
  68399. timeScale: number;
  68400. translationSpeed: number;
  68401. private _currentTranslation;
  68402. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68403. updateShaderUniforms(): void;
  68404. render(useCameraPostProcess?: boolean): void;
  68405. resize(size: any, generateMipMaps: any): void;
  68406. /**
  68407. * Serializes this perlin noise procedural texture
  68408. * @returns a serialized perlin noise procedural texture object
  68409. */
  68410. serialize(): any;
  68411. /**
  68412. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  68413. * @param parsedTexture defines parsed texture data
  68414. * @param scene defines the current scene
  68415. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  68416. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  68417. */
  68418. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  68419. }
  68420. }
  68421. declare module BABYLON {
  68422. /** @hidden */
  68423. export var roadProceduralTexturePixelShader: {
  68424. name: string;
  68425. shader: string;
  68426. };
  68427. }
  68428. declare module BABYLON {
  68429. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  68430. private _roadColor;
  68431. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68432. updateShaderUniforms(): void;
  68433. roadColor: BABYLON.Color3;
  68434. /**
  68435. * Serializes this road procedural texture
  68436. * @returns a serialized road procedural texture object
  68437. */
  68438. serialize(): any;
  68439. /**
  68440. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  68441. * @param parsedTexture defines parsed texture data
  68442. * @param scene defines the current scene
  68443. * @param rootUrl defines the root URL containing road procedural texture information
  68444. * @returns a parsed Road Procedural BABYLON.Texture
  68445. */
  68446. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  68447. }
  68448. }
  68449. declare module BABYLON {
  68450. /** @hidden */
  68451. export var starfieldProceduralTexturePixelShader: {
  68452. name: string;
  68453. shader: string;
  68454. };
  68455. }
  68456. declare module BABYLON {
  68457. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  68458. private _time;
  68459. private _alpha;
  68460. private _beta;
  68461. private _zoom;
  68462. private _formuparam;
  68463. private _stepsize;
  68464. private _tile;
  68465. private _brightness;
  68466. private _darkmatter;
  68467. private _distfading;
  68468. private _saturation;
  68469. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68470. updateShaderUniforms(): void;
  68471. time: number;
  68472. alpha: number;
  68473. beta: number;
  68474. formuparam: number;
  68475. stepsize: number;
  68476. zoom: number;
  68477. tile: number;
  68478. brightness: number;
  68479. darkmatter: number;
  68480. distfading: number;
  68481. saturation: number;
  68482. /**
  68483. * Serializes this starfield procedural texture
  68484. * @returns a serialized starfield procedural texture object
  68485. */
  68486. serialize(): any;
  68487. /**
  68488. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  68489. * @param parsedTexture defines parsed texture data
  68490. * @param scene defines the current scene
  68491. * @param rootUrl defines the root URL containing startfield procedural texture information
  68492. * @returns a parsed Starfield Procedural BABYLON.Texture
  68493. */
  68494. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  68495. }
  68496. }
  68497. declare module BABYLON {
  68498. /** @hidden */
  68499. export var woodProceduralTexturePixelShader: {
  68500. name: string;
  68501. shader: string;
  68502. };
  68503. }
  68504. declare module BABYLON {
  68505. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  68506. private _ampScale;
  68507. private _woodColor;
  68508. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68509. updateShaderUniforms(): void;
  68510. ampScale: number;
  68511. woodColor: BABYLON.Color3;
  68512. /**
  68513. * Serializes this wood procedural texture
  68514. * @returns a serialized wood procedural texture object
  68515. */
  68516. serialize(): any;
  68517. /**
  68518. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  68519. * @param parsedTexture defines parsed texture data
  68520. * @param scene defines the current scene
  68521. * @param rootUrl defines the root URL containing wood procedural texture information
  68522. * @returns a parsed Wood Procedural BABYLON.Texture
  68523. */
  68524. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  68525. }
  68526. }