documentation.d.ts 2.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499
  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 readonly 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. lines: string[];
  5338. lineIndex: number;
  5339. readonly currentLine: string;
  5340. readonly canRead: boolean;
  5341. }
  5342. }
  5343. declare module BABYLON {
  5344. /** @hidden */
  5345. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5346. process(preprocessors: {
  5347. [key: string]: string;
  5348. }, options: ProcessingOptions): string;
  5349. }
  5350. }
  5351. declare module BABYLON {
  5352. /** @hidden */
  5353. export class ShaderDefineExpression {
  5354. isTrue(preprocessors: {
  5355. [key: string]: string;
  5356. }): boolean;
  5357. }
  5358. }
  5359. declare module BABYLON {
  5360. /** @hidden */
  5361. export class ShaderCodeTestNode extends ShaderCodeNode {
  5362. testExpression: ShaderDefineExpression;
  5363. isValid(preprocessors: {
  5364. [key: string]: string;
  5365. }): boolean;
  5366. }
  5367. }
  5368. declare module BABYLON {
  5369. /** @hidden */
  5370. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5371. define: string;
  5372. not: boolean;
  5373. constructor(define: string, not?: boolean);
  5374. isTrue(preprocessors: {
  5375. [key: string]: string;
  5376. }): boolean;
  5377. }
  5378. }
  5379. declare module BABYLON {
  5380. /** @hidden */
  5381. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5382. leftOperand: ShaderDefineExpression;
  5383. rightOperand: ShaderDefineExpression;
  5384. isTrue(preprocessors: {
  5385. [key: string]: string;
  5386. }): boolean;
  5387. }
  5388. }
  5389. declare module BABYLON {
  5390. /** @hidden */
  5391. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5392. leftOperand: ShaderDefineExpression;
  5393. rightOperand: ShaderDefineExpression;
  5394. isTrue(preprocessors: {
  5395. [key: string]: string;
  5396. }): boolean;
  5397. }
  5398. }
  5399. declare module BABYLON {
  5400. /** @hidden */
  5401. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5402. define: string;
  5403. operand: string;
  5404. testValue: string;
  5405. constructor(define: string, operand: string, testValue: string);
  5406. isTrue(preprocessors: {
  5407. [key: string]: string;
  5408. }): boolean;
  5409. }
  5410. }
  5411. declare module BABYLON {
  5412. /** @hidden */
  5413. export class ShaderProcessor {
  5414. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5415. private static _ProcessPrecision;
  5416. private static _ExtractOperation;
  5417. private static _BuildSubExpression;
  5418. private static _BuildExpression;
  5419. private static _MoveCursorWithinIf;
  5420. private static _MoveCursor;
  5421. private static _EvaluatePreProcessors;
  5422. private static _ProcessShaderConversion;
  5423. private static _ProcessIncludes;
  5424. }
  5425. }
  5426. declare module BABYLON {
  5427. /**
  5428. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5429. */
  5430. export class PerformanceMonitor {
  5431. private _enabled;
  5432. private _rollingFrameTime;
  5433. private _lastFrameTimeMs;
  5434. /**
  5435. * constructor
  5436. * @param frameSampleSize The number of samples required to saturate the sliding window
  5437. */
  5438. constructor(frameSampleSize?: number);
  5439. /**
  5440. * Samples current frame
  5441. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5442. */
  5443. sampleFrame(timeMs?: number): void;
  5444. /**
  5445. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5446. */
  5447. readonly averageFrameTime: number;
  5448. /**
  5449. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5450. */
  5451. readonly averageFrameTimeVariance: number;
  5452. /**
  5453. * Returns the frame time of the most recent frame
  5454. */
  5455. readonly instantaneousFrameTime: number;
  5456. /**
  5457. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5458. */
  5459. readonly averageFPS: number;
  5460. /**
  5461. * Returns the average framerate in frames per second using the most recent frame time
  5462. */
  5463. readonly instantaneousFPS: number;
  5464. /**
  5465. * Returns true if enough samples have been taken to completely fill the sliding window
  5466. */
  5467. readonly isSaturated: boolean;
  5468. /**
  5469. * Enables contributions to the sliding window sample set
  5470. */
  5471. enable(): void;
  5472. /**
  5473. * Disables contributions to the sliding window sample set
  5474. * Samples will not be interpolated over the disabled period
  5475. */
  5476. disable(): void;
  5477. /**
  5478. * Returns true if sampling is enabled
  5479. */
  5480. readonly isEnabled: boolean;
  5481. /**
  5482. * Resets performance monitor
  5483. */
  5484. reset(): void;
  5485. }
  5486. /**
  5487. * RollingAverage
  5488. *
  5489. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5490. */
  5491. export class RollingAverage {
  5492. /**
  5493. * Current average
  5494. */
  5495. average: number;
  5496. /**
  5497. * Current variance
  5498. */
  5499. variance: number;
  5500. protected _samples: Array<number>;
  5501. protected _sampleCount: number;
  5502. protected _pos: number;
  5503. protected _m2: number;
  5504. /**
  5505. * constructor
  5506. * @param length The number of samples required to saturate the sliding window
  5507. */
  5508. constructor(length: number);
  5509. /**
  5510. * Adds a sample to the sample set
  5511. * @param v The sample value
  5512. */
  5513. add(v: number): void;
  5514. /**
  5515. * Returns previously added values or null if outside of history or outside the sliding window domain
  5516. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5517. * @return Value previously recorded with add() or null if outside of range
  5518. */
  5519. history(i: number): number;
  5520. /**
  5521. * Returns true if enough samples have been taken to completely fill the sliding window
  5522. * @return true if sample-set saturated
  5523. */
  5524. isSaturated(): boolean;
  5525. /**
  5526. * Resets the rolling average (equivalent to 0 samples taken so far)
  5527. */
  5528. reset(): void;
  5529. /**
  5530. * Wraps a value around the sample range boundaries
  5531. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5532. * @return Wrapped position in sample range
  5533. */
  5534. protected _wrapPosition(i: number): number;
  5535. }
  5536. }
  5537. declare module BABYLON {
  5538. /**
  5539. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5540. * The underlying implementation relies on an associative array to ensure the best performances.
  5541. * The value can be anything including 'null' but except 'undefined'
  5542. */
  5543. export class StringDictionary<T> {
  5544. /**
  5545. * This will clear this dictionary and copy the content from the 'source' one.
  5546. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5547. * @param source the dictionary to take the content from and copy to this dictionary
  5548. */
  5549. copyFrom(source: StringDictionary<T>): void;
  5550. /**
  5551. * Get a value based from its key
  5552. * @param key the given key to get the matching value from
  5553. * @return the value if found, otherwise undefined is returned
  5554. */
  5555. get(key: string): T | undefined;
  5556. /**
  5557. * Get a value from its key or add it if it doesn't exist.
  5558. * This method will ensure you that a given key/data will be present in the dictionary.
  5559. * @param key the given key to get the matching value from
  5560. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5561. * The factory will only be invoked if there's no data for the given key.
  5562. * @return the value corresponding to the key.
  5563. */
  5564. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5565. /**
  5566. * Get a value from its key if present in the dictionary otherwise add it
  5567. * @param key the key to get the value from
  5568. * @param val if there's no such key/value pair in the dictionary add it with this value
  5569. * @return the value corresponding to the key
  5570. */
  5571. getOrAdd(key: string, val: T): T;
  5572. /**
  5573. * Check if there's a given key in the dictionary
  5574. * @param key the key to check for
  5575. * @return true if the key is present, false otherwise
  5576. */
  5577. contains(key: string): boolean;
  5578. /**
  5579. * Add a new key and its corresponding value
  5580. * @param key the key to add
  5581. * @param value the value corresponding to the key
  5582. * @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
  5583. */
  5584. add(key: string, value: T): boolean;
  5585. /**
  5586. * Update a specific value associated to a key
  5587. * @param key defines the key to use
  5588. * @param value defines the value to store
  5589. * @returns true if the value was updated (or false if the key was not found)
  5590. */
  5591. set(key: string, value: T): boolean;
  5592. /**
  5593. * Get the element of the given key and remove it from the dictionary
  5594. * @param key defines the key to search
  5595. * @returns the value associated with the key or null if not found
  5596. */
  5597. getAndRemove(key: string): Nullable<T>;
  5598. /**
  5599. * Remove a key/value from the dictionary.
  5600. * @param key the key to remove
  5601. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5602. */
  5603. remove(key: string): boolean;
  5604. /**
  5605. * Clear the whole content of the dictionary
  5606. */
  5607. clear(): void;
  5608. /**
  5609. * Gets the current count
  5610. */
  5611. readonly count: number;
  5612. /**
  5613. * Execute a callback on each key/val of the dictionary.
  5614. * Note that you can remove any element in this dictionary in the callback implementation
  5615. * @param callback the callback to execute on a given key/value pair
  5616. */
  5617. forEach(callback: (key: string, val: T) => void): void;
  5618. /**
  5619. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5620. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5621. * Note that you can remove any element in this dictionary in the callback implementation
  5622. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5623. * @returns the first item
  5624. */
  5625. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5626. private _count;
  5627. private _data;
  5628. }
  5629. }
  5630. declare module BABYLON {
  5631. /**
  5632. * Helper class that provides a small promise polyfill
  5633. */
  5634. export class PromisePolyfill {
  5635. /**
  5636. * Static function used to check if the polyfill is required
  5637. * If this is the case then the function will inject the polyfill to window.Promise
  5638. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5639. */
  5640. static Apply(force?: boolean): void;
  5641. }
  5642. }
  5643. declare module BABYLON {
  5644. /**
  5645. * Class used to store data that will be store in GPU memory
  5646. */
  5647. export class Buffer {
  5648. private _engine;
  5649. private _buffer;
  5650. /** @hidden */
  5651. _data: Nullable<DataArray>;
  5652. private _updatable;
  5653. private _instanced;
  5654. /**
  5655. * Gets the byte stride.
  5656. */
  5657. readonly byteStride: number;
  5658. /**
  5659. * Constructor
  5660. * @param engine the engine
  5661. * @param data the data to use for this buffer
  5662. * @param updatable whether the data is updatable
  5663. * @param stride the stride (optional)
  5664. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5665. * @param instanced whether the buffer is instanced (optional)
  5666. * @param useBytes set to true if the stride in in bytes (optional)
  5667. */
  5668. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5669. /**
  5670. * Create a new VertexBuffer based on the current buffer
  5671. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5672. * @param offset defines offset in the buffer (0 by default)
  5673. * @param size defines the size in floats of attributes (position is 3 for instance)
  5674. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5675. * @param instanced defines if the vertex buffer contains indexed data
  5676. * @param useBytes defines if the offset and stride are in bytes
  5677. * @returns the new vertex buffer
  5678. */
  5679. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5680. /**
  5681. * Gets a boolean indicating if the Buffer is updatable?
  5682. * @returns true if the buffer is updatable
  5683. */
  5684. isUpdatable(): boolean;
  5685. /**
  5686. * Gets current buffer's data
  5687. * @returns a DataArray or null
  5688. */
  5689. getData(): Nullable<DataArray>;
  5690. /**
  5691. * Gets underlying native buffer
  5692. * @returns underlying native buffer
  5693. */
  5694. getBuffer(): Nullable<DataBuffer>;
  5695. /**
  5696. * Gets the stride in float32 units (i.e. byte stride / 4).
  5697. * May not be an integer if the byte stride is not divisible by 4.
  5698. * DEPRECATED. Use byteStride instead.
  5699. * @returns the stride in float32 units
  5700. */
  5701. getStrideSize(): number;
  5702. /**
  5703. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5704. * @param data defines the data to store
  5705. */
  5706. create(data?: Nullable<DataArray>): void;
  5707. /** @hidden */
  5708. _rebuild(): void;
  5709. /**
  5710. * Update current buffer data
  5711. * @param data defines the data to store
  5712. */
  5713. update(data: DataArray): void;
  5714. /**
  5715. * Updates the data directly.
  5716. * @param data the new data
  5717. * @param offset the new offset
  5718. * @param vertexCount the vertex count (optional)
  5719. * @param useBytes set to true if the offset is in bytes
  5720. */
  5721. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5722. /**
  5723. * Release all resources
  5724. */
  5725. dispose(): void;
  5726. }
  5727. /**
  5728. * Specialized buffer used to store vertex data
  5729. */
  5730. export class VertexBuffer {
  5731. /** @hidden */
  5732. _buffer: Buffer;
  5733. private _kind;
  5734. private _size;
  5735. private _ownsBuffer;
  5736. private _instanced;
  5737. private _instanceDivisor;
  5738. /**
  5739. * The byte type.
  5740. */
  5741. static readonly BYTE: number;
  5742. /**
  5743. * The unsigned byte type.
  5744. */
  5745. static readonly UNSIGNED_BYTE: number;
  5746. /**
  5747. * The short type.
  5748. */
  5749. static readonly SHORT: number;
  5750. /**
  5751. * The unsigned short type.
  5752. */
  5753. static readonly UNSIGNED_SHORT: number;
  5754. /**
  5755. * The integer type.
  5756. */
  5757. static readonly INT: number;
  5758. /**
  5759. * The unsigned integer type.
  5760. */
  5761. static readonly UNSIGNED_INT: number;
  5762. /**
  5763. * The float type.
  5764. */
  5765. static readonly FLOAT: number;
  5766. /**
  5767. * Gets or sets the instance divisor when in instanced mode
  5768. */
  5769. instanceDivisor: number;
  5770. /**
  5771. * Gets the byte stride.
  5772. */
  5773. readonly byteStride: number;
  5774. /**
  5775. * Gets the byte offset.
  5776. */
  5777. readonly byteOffset: number;
  5778. /**
  5779. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5780. */
  5781. readonly normalized: boolean;
  5782. /**
  5783. * Gets the data type of each component in the array.
  5784. */
  5785. readonly type: number;
  5786. /**
  5787. * Constructor
  5788. * @param engine the engine
  5789. * @param data the data to use for this vertex buffer
  5790. * @param kind the vertex buffer kind
  5791. * @param updatable whether the data is updatable
  5792. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5793. * @param stride the stride (optional)
  5794. * @param instanced whether the buffer is instanced (optional)
  5795. * @param offset the offset of the data (optional)
  5796. * @param size the number of components (optional)
  5797. * @param type the type of the component (optional)
  5798. * @param normalized whether the data contains normalized data (optional)
  5799. * @param useBytes set to true if stride and offset are in bytes (optional)
  5800. */
  5801. 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);
  5802. /** @hidden */
  5803. _rebuild(): void;
  5804. /**
  5805. * Returns the kind of the VertexBuffer (string)
  5806. * @returns a string
  5807. */
  5808. getKind(): string;
  5809. /**
  5810. * Gets a boolean indicating if the VertexBuffer is updatable?
  5811. * @returns true if the buffer is updatable
  5812. */
  5813. isUpdatable(): boolean;
  5814. /**
  5815. * Gets current buffer's data
  5816. * @returns a DataArray or null
  5817. */
  5818. getData(): Nullable<DataArray>;
  5819. /**
  5820. * Gets underlying native buffer
  5821. * @returns underlying native buffer
  5822. */
  5823. getBuffer(): Nullable<DataBuffer>;
  5824. /**
  5825. * Gets the stride in float32 units (i.e. byte stride / 4).
  5826. * May not be an integer if the byte stride is not divisible by 4.
  5827. * DEPRECATED. Use byteStride instead.
  5828. * @returns the stride in float32 units
  5829. */
  5830. getStrideSize(): number;
  5831. /**
  5832. * Returns the offset as a multiple of the type byte length.
  5833. * DEPRECATED. Use byteOffset instead.
  5834. * @returns the offset in bytes
  5835. */
  5836. getOffset(): number;
  5837. /**
  5838. * Returns the number of components per vertex attribute (integer)
  5839. * @returns the size in float
  5840. */
  5841. getSize(): number;
  5842. /**
  5843. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5844. * @returns true if this buffer is instanced
  5845. */
  5846. getIsInstanced(): boolean;
  5847. /**
  5848. * Returns the instancing divisor, zero for non-instanced (integer).
  5849. * @returns a number
  5850. */
  5851. getInstanceDivisor(): number;
  5852. /**
  5853. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5854. * @param data defines the data to store
  5855. */
  5856. create(data?: DataArray): void;
  5857. /**
  5858. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5859. * This function will create a new buffer if the current one is not updatable
  5860. * @param data defines the data to store
  5861. */
  5862. update(data: DataArray): void;
  5863. /**
  5864. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5865. * Returns the directly updated WebGLBuffer.
  5866. * @param data the new data
  5867. * @param offset the new offset
  5868. * @param useBytes set to true if the offset is in bytes
  5869. */
  5870. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5871. /**
  5872. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5873. */
  5874. dispose(): void;
  5875. /**
  5876. * Enumerates each value of this vertex buffer as numbers.
  5877. * @param count the number of values to enumerate
  5878. * @param callback the callback function called for each value
  5879. */
  5880. forEach(count: number, callback: (value: number, index: number) => void): void;
  5881. /**
  5882. * Positions
  5883. */
  5884. static readonly PositionKind: string;
  5885. /**
  5886. * Normals
  5887. */
  5888. static readonly NormalKind: string;
  5889. /**
  5890. * Tangents
  5891. */
  5892. static readonly TangentKind: string;
  5893. /**
  5894. * Texture coordinates
  5895. */
  5896. static readonly UVKind: string;
  5897. /**
  5898. * Texture coordinates 2
  5899. */
  5900. static readonly UV2Kind: string;
  5901. /**
  5902. * Texture coordinates 3
  5903. */
  5904. static readonly UV3Kind: string;
  5905. /**
  5906. * Texture coordinates 4
  5907. */
  5908. static readonly UV4Kind: string;
  5909. /**
  5910. * Texture coordinates 5
  5911. */
  5912. static readonly UV5Kind: string;
  5913. /**
  5914. * Texture coordinates 6
  5915. */
  5916. static readonly UV6Kind: string;
  5917. /**
  5918. * Colors
  5919. */
  5920. static readonly ColorKind: string;
  5921. /**
  5922. * Matrix indices (for bones)
  5923. */
  5924. static readonly MatricesIndicesKind: string;
  5925. /**
  5926. * Matrix weights (for bones)
  5927. */
  5928. static readonly MatricesWeightsKind: string;
  5929. /**
  5930. * Additional matrix indices (for bones)
  5931. */
  5932. static readonly MatricesIndicesExtraKind: string;
  5933. /**
  5934. * Additional matrix weights (for bones)
  5935. */
  5936. static readonly MatricesWeightsExtraKind: string;
  5937. /**
  5938. * Deduces the stride given a kind.
  5939. * @param kind The kind string to deduce
  5940. * @returns The deduced stride
  5941. */
  5942. static DeduceStride(kind: string): number;
  5943. /**
  5944. * Gets the byte length of the given type.
  5945. * @param type the type
  5946. * @returns the number of bytes
  5947. */
  5948. static GetTypeByteLength(type: number): number;
  5949. /**
  5950. * Enumerates each value of the given parameters as numbers.
  5951. * @param data the data to enumerate
  5952. * @param byteOffset the byte offset of the data
  5953. * @param byteStride the byte stride of the data
  5954. * @param componentCount the number of components per element
  5955. * @param componentType the type of the component
  5956. * @param count the total number of components
  5957. * @param normalized whether the data is normalized
  5958. * @param callback the callback function called for each value
  5959. */
  5960. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5961. private static _GetFloatValue;
  5962. }
  5963. }
  5964. declare module BABYLON {
  5965. /**
  5966. * Class representing spherical harmonics coefficients to the 3rd degree
  5967. */
  5968. export class SphericalHarmonics {
  5969. /**
  5970. * Defines whether or not the harmonics have been prescaled for rendering.
  5971. */
  5972. preScaled: boolean;
  5973. /**
  5974. * The l0,0 coefficients of the spherical harmonics
  5975. */
  5976. l00: Vector3;
  5977. /**
  5978. * The l1,-1 coefficients of the spherical harmonics
  5979. */
  5980. l1_1: Vector3;
  5981. /**
  5982. * The l1,0 coefficients of the spherical harmonics
  5983. */
  5984. l10: Vector3;
  5985. /**
  5986. * The l1,1 coefficients of the spherical harmonics
  5987. */
  5988. l11: Vector3;
  5989. /**
  5990. * The l2,-2 coefficients of the spherical harmonics
  5991. */
  5992. l2_2: Vector3;
  5993. /**
  5994. * The l2,-1 coefficients of the spherical harmonics
  5995. */
  5996. l2_1: Vector3;
  5997. /**
  5998. * The l2,0 coefficients of the spherical harmonics
  5999. */
  6000. l20: Vector3;
  6001. /**
  6002. * The l2,1 coefficients of the spherical harmonics
  6003. */
  6004. l21: Vector3;
  6005. /**
  6006. * The l2,2 coefficients of the spherical harmonics
  6007. */
  6008. l22: Vector3;
  6009. /**
  6010. * Adds a light to the spherical harmonics
  6011. * @param direction the direction of the light
  6012. * @param color the color of the light
  6013. * @param deltaSolidAngle the delta solid angle of the light
  6014. */
  6015. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6016. /**
  6017. * Scales the spherical harmonics by the given amount
  6018. * @param scale the amount to scale
  6019. */
  6020. scaleInPlace(scale: number): void;
  6021. /**
  6022. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6023. *
  6024. * ```
  6025. * E_lm = A_l * L_lm
  6026. * ```
  6027. *
  6028. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6029. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6030. * the scaling factors are given in equation 9.
  6031. */
  6032. convertIncidentRadianceToIrradiance(): void;
  6033. /**
  6034. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6035. *
  6036. * ```
  6037. * L = (1/pi) * E * rho
  6038. * ```
  6039. *
  6040. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6041. */
  6042. convertIrradianceToLambertianRadiance(): void;
  6043. /**
  6044. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6045. * required operations at run time.
  6046. *
  6047. * This is simply done by scaling back the SH with Ylm constants parameter.
  6048. * The trigonometric part being applied by the shader at run time.
  6049. */
  6050. preScaleForRendering(): void;
  6051. /**
  6052. * Constructs a spherical harmonics from an array.
  6053. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6054. * @returns the spherical harmonics
  6055. */
  6056. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6057. /**
  6058. * Gets the spherical harmonics from polynomial
  6059. * @param polynomial the spherical polynomial
  6060. * @returns the spherical harmonics
  6061. */
  6062. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6063. }
  6064. /**
  6065. * Class representing spherical polynomial coefficients to the 3rd degree
  6066. */
  6067. export class SphericalPolynomial {
  6068. private _harmonics;
  6069. /**
  6070. * The spherical harmonics used to create the polynomials.
  6071. */
  6072. readonly preScaledHarmonics: SphericalHarmonics;
  6073. /**
  6074. * The x coefficients of the spherical polynomial
  6075. */
  6076. x: Vector3;
  6077. /**
  6078. * The y coefficients of the spherical polynomial
  6079. */
  6080. y: Vector3;
  6081. /**
  6082. * The z coefficients of the spherical polynomial
  6083. */
  6084. z: Vector3;
  6085. /**
  6086. * The xx coefficients of the spherical polynomial
  6087. */
  6088. xx: Vector3;
  6089. /**
  6090. * The yy coefficients of the spherical polynomial
  6091. */
  6092. yy: Vector3;
  6093. /**
  6094. * The zz coefficients of the spherical polynomial
  6095. */
  6096. zz: Vector3;
  6097. /**
  6098. * The xy coefficients of the spherical polynomial
  6099. */
  6100. xy: Vector3;
  6101. /**
  6102. * The yz coefficients of the spherical polynomial
  6103. */
  6104. yz: Vector3;
  6105. /**
  6106. * The zx coefficients of the spherical polynomial
  6107. */
  6108. zx: Vector3;
  6109. /**
  6110. * Adds an ambient color to the spherical polynomial
  6111. * @param color the color to add
  6112. */
  6113. addAmbient(color: Color3): void;
  6114. /**
  6115. * Scales the spherical polynomial by the given amount
  6116. * @param scale the amount to scale
  6117. */
  6118. scaleInPlace(scale: number): void;
  6119. /**
  6120. * Gets the spherical polynomial from harmonics
  6121. * @param harmonics the spherical harmonics
  6122. * @returns the spherical polynomial
  6123. */
  6124. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6125. /**
  6126. * Constructs a spherical polynomial from an array.
  6127. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6128. * @returns the spherical polynomial
  6129. */
  6130. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6131. }
  6132. }
  6133. declare module BABYLON {
  6134. /**
  6135. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6136. */
  6137. export interface CubeMapInfo {
  6138. /**
  6139. * The pixel array for the front face.
  6140. * This is stored in format, left to right, up to down format.
  6141. */
  6142. front: Nullable<ArrayBufferView>;
  6143. /**
  6144. * The pixel array for the back face.
  6145. * This is stored in format, left to right, up to down format.
  6146. */
  6147. back: Nullable<ArrayBufferView>;
  6148. /**
  6149. * The pixel array for the left face.
  6150. * This is stored in format, left to right, up to down format.
  6151. */
  6152. left: Nullable<ArrayBufferView>;
  6153. /**
  6154. * The pixel array for the right face.
  6155. * This is stored in format, left to right, up to down format.
  6156. */
  6157. right: Nullable<ArrayBufferView>;
  6158. /**
  6159. * The pixel array for the up face.
  6160. * This is stored in format, left to right, up to down format.
  6161. */
  6162. up: Nullable<ArrayBufferView>;
  6163. /**
  6164. * The pixel array for the down face.
  6165. * This is stored in format, left to right, up to down format.
  6166. */
  6167. down: Nullable<ArrayBufferView>;
  6168. /**
  6169. * The size of the cubemap stored.
  6170. *
  6171. * Each faces will be size * size pixels.
  6172. */
  6173. size: number;
  6174. /**
  6175. * The format of the texture.
  6176. *
  6177. * RGBA, RGB.
  6178. */
  6179. format: number;
  6180. /**
  6181. * The type of the texture data.
  6182. *
  6183. * UNSIGNED_INT, FLOAT.
  6184. */
  6185. type: number;
  6186. /**
  6187. * Specifies whether the texture is in gamma space.
  6188. */
  6189. gammaSpace: boolean;
  6190. }
  6191. /**
  6192. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6193. */
  6194. export class PanoramaToCubeMapTools {
  6195. private static FACE_FRONT;
  6196. private static FACE_BACK;
  6197. private static FACE_RIGHT;
  6198. private static FACE_LEFT;
  6199. private static FACE_DOWN;
  6200. private static FACE_UP;
  6201. /**
  6202. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6203. *
  6204. * @param float32Array The source data.
  6205. * @param inputWidth The width of the input panorama.
  6206. * @param inputHeight The height of the input panorama.
  6207. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6208. * @return The cubemap data
  6209. */
  6210. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6211. private static CreateCubemapTexture;
  6212. private static CalcProjectionSpherical;
  6213. }
  6214. }
  6215. declare module BABYLON {
  6216. /**
  6217. * Helper class dealing with the extraction of spherical polynomial dataArray
  6218. * from a cube map.
  6219. */
  6220. export class CubeMapToSphericalPolynomialTools {
  6221. private static FileFaces;
  6222. /**
  6223. * Converts a texture to the according Spherical Polynomial data.
  6224. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6225. *
  6226. * @param texture The texture to extract the information from.
  6227. * @return The Spherical Polynomial data.
  6228. */
  6229. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6230. /**
  6231. * Converts a cubemap to the according Spherical Polynomial data.
  6232. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6233. *
  6234. * @param cubeInfo The Cube map to extract the information from.
  6235. * @return The Spherical Polynomial data.
  6236. */
  6237. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6238. }
  6239. }
  6240. declare module BABYLON {
  6241. /**
  6242. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6243. * during the life time of the application.
  6244. */
  6245. export class EngineStore {
  6246. /** Gets the list of created engines */
  6247. static Instances: Engine[];
  6248. /** @hidden */
  6249. static _LastCreatedScene: Nullable<Scene>;
  6250. /**
  6251. * Gets the latest created engine
  6252. */
  6253. static readonly LastCreatedEngine: Nullable<Engine>;
  6254. /**
  6255. * Gets the latest created scene
  6256. */
  6257. static readonly LastCreatedScene: Nullable<Scene>;
  6258. }
  6259. }
  6260. declare module BABYLON {
  6261. /**
  6262. * Define options used to create a render target texture
  6263. */
  6264. export class RenderTargetCreationOptions {
  6265. /**
  6266. * Specifies is mipmaps must be generated
  6267. */
  6268. generateMipMaps?: boolean;
  6269. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6270. generateDepthBuffer?: boolean;
  6271. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6272. generateStencilBuffer?: boolean;
  6273. /** Defines texture type (int by default) */
  6274. type?: number;
  6275. /** Defines sampling mode (trilinear by default) */
  6276. samplingMode?: number;
  6277. /** Defines format (RGBA by default) */
  6278. format?: number;
  6279. }
  6280. }
  6281. declare module BABYLON {
  6282. /**
  6283. * @hidden
  6284. **/
  6285. export class _AlphaState {
  6286. private _isAlphaBlendDirty;
  6287. private _isBlendFunctionParametersDirty;
  6288. private _isBlendEquationParametersDirty;
  6289. private _isBlendConstantsDirty;
  6290. private _alphaBlend;
  6291. private _blendFunctionParameters;
  6292. private _blendEquationParameters;
  6293. private _blendConstants;
  6294. /**
  6295. * Initializes the state.
  6296. */
  6297. constructor();
  6298. readonly isDirty: boolean;
  6299. alphaBlend: boolean;
  6300. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6301. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6302. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6303. reset(): void;
  6304. apply(gl: WebGLRenderingContext): void;
  6305. }
  6306. }
  6307. declare module BABYLON {
  6308. /**
  6309. * @hidden
  6310. **/
  6311. export class _DepthCullingState {
  6312. private _isDepthTestDirty;
  6313. private _isDepthMaskDirty;
  6314. private _isDepthFuncDirty;
  6315. private _isCullFaceDirty;
  6316. private _isCullDirty;
  6317. private _isZOffsetDirty;
  6318. private _isFrontFaceDirty;
  6319. private _depthTest;
  6320. private _depthMask;
  6321. private _depthFunc;
  6322. private _cull;
  6323. private _cullFace;
  6324. private _zOffset;
  6325. private _frontFace;
  6326. /**
  6327. * Initializes the state.
  6328. */
  6329. constructor();
  6330. readonly isDirty: boolean;
  6331. zOffset: number;
  6332. cullFace: Nullable<number>;
  6333. cull: Nullable<boolean>;
  6334. depthFunc: Nullable<number>;
  6335. depthMask: boolean;
  6336. depthTest: boolean;
  6337. frontFace: Nullable<number>;
  6338. reset(): void;
  6339. apply(gl: WebGLRenderingContext): void;
  6340. }
  6341. }
  6342. declare module BABYLON {
  6343. /**
  6344. * @hidden
  6345. **/
  6346. export class _StencilState {
  6347. /** 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 */
  6348. static readonly ALWAYS: number;
  6349. /** Passed to stencilOperation to specify that stencil value must be kept */
  6350. static readonly KEEP: number;
  6351. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6352. static readonly REPLACE: number;
  6353. private _isStencilTestDirty;
  6354. private _isStencilMaskDirty;
  6355. private _isStencilFuncDirty;
  6356. private _isStencilOpDirty;
  6357. private _stencilTest;
  6358. private _stencilMask;
  6359. private _stencilFunc;
  6360. private _stencilFuncRef;
  6361. private _stencilFuncMask;
  6362. private _stencilOpStencilFail;
  6363. private _stencilOpDepthFail;
  6364. private _stencilOpStencilDepthPass;
  6365. readonly isDirty: boolean;
  6366. stencilFunc: number;
  6367. stencilFuncRef: number;
  6368. stencilFuncMask: number;
  6369. stencilOpStencilFail: number;
  6370. stencilOpDepthFail: number;
  6371. stencilOpStencilDepthPass: number;
  6372. stencilMask: number;
  6373. stencilTest: boolean;
  6374. constructor();
  6375. reset(): void;
  6376. apply(gl: WebGLRenderingContext): void;
  6377. }
  6378. }
  6379. declare module BABYLON {
  6380. /**
  6381. * @hidden
  6382. **/
  6383. export class _TimeToken {
  6384. _startTimeQuery: Nullable<WebGLQuery>;
  6385. _endTimeQuery: Nullable<WebGLQuery>;
  6386. _timeElapsedQuery: Nullable<WebGLQuery>;
  6387. _timeElapsedQueryEnded: boolean;
  6388. }
  6389. }
  6390. declare module BABYLON {
  6391. /**
  6392. * Class used to store data associated with WebGL texture data for the engine
  6393. * This class should not be used directly
  6394. */
  6395. export class InternalTexture {
  6396. /** hidden */
  6397. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6398. /**
  6399. * The source of the texture data is unknown
  6400. */
  6401. static DATASOURCE_UNKNOWN: number;
  6402. /**
  6403. * Texture data comes from an URL
  6404. */
  6405. static DATASOURCE_URL: number;
  6406. /**
  6407. * Texture data is only used for temporary storage
  6408. */
  6409. static DATASOURCE_TEMP: number;
  6410. /**
  6411. * Texture data comes from raw data (ArrayBuffer)
  6412. */
  6413. static DATASOURCE_RAW: number;
  6414. /**
  6415. * Texture content is dynamic (video or dynamic texture)
  6416. */
  6417. static DATASOURCE_DYNAMIC: number;
  6418. /**
  6419. * Texture content is generated by rendering to it
  6420. */
  6421. static DATASOURCE_RENDERTARGET: number;
  6422. /**
  6423. * Texture content is part of a multi render target process
  6424. */
  6425. static DATASOURCE_MULTIRENDERTARGET: number;
  6426. /**
  6427. * Texture data comes from a cube data file
  6428. */
  6429. static DATASOURCE_CUBE: number;
  6430. /**
  6431. * Texture data comes from a raw cube data
  6432. */
  6433. static DATASOURCE_CUBERAW: number;
  6434. /**
  6435. * Texture data come from a prefiltered cube data file
  6436. */
  6437. static DATASOURCE_CUBEPREFILTERED: number;
  6438. /**
  6439. * Texture content is raw 3D data
  6440. */
  6441. static DATASOURCE_RAW3D: number;
  6442. /**
  6443. * Texture content is a depth texture
  6444. */
  6445. static DATASOURCE_DEPTHTEXTURE: number;
  6446. /**
  6447. * Texture data comes from a raw cube data encoded with RGBD
  6448. */
  6449. static DATASOURCE_CUBERAW_RGBD: number;
  6450. /**
  6451. * Defines if the texture is ready
  6452. */
  6453. isReady: boolean;
  6454. /**
  6455. * Defines if the texture is a cube texture
  6456. */
  6457. isCube: boolean;
  6458. /**
  6459. * Defines if the texture contains 3D data
  6460. */
  6461. is3D: boolean;
  6462. /**
  6463. * Defines if the texture contains multiview data
  6464. */
  6465. isMultiview: boolean;
  6466. /**
  6467. * Gets the URL used to load this texture
  6468. */
  6469. url: string;
  6470. /**
  6471. * Gets the sampling mode of the texture
  6472. */
  6473. samplingMode: number;
  6474. /**
  6475. * Gets a boolean indicating if the texture needs mipmaps generation
  6476. */
  6477. generateMipMaps: boolean;
  6478. /**
  6479. * Gets the number of samples used by the texture (WebGL2+ only)
  6480. */
  6481. samples: number;
  6482. /**
  6483. * Gets the type of the texture (int, float...)
  6484. */
  6485. type: number;
  6486. /**
  6487. * Gets the format of the texture (RGB, RGBA...)
  6488. */
  6489. format: number;
  6490. /**
  6491. * Observable called when the texture is loaded
  6492. */
  6493. onLoadedObservable: Observable<InternalTexture>;
  6494. /**
  6495. * Gets the width of the texture
  6496. */
  6497. width: number;
  6498. /**
  6499. * Gets the height of the texture
  6500. */
  6501. height: number;
  6502. /**
  6503. * Gets the depth of the texture
  6504. */
  6505. depth: number;
  6506. /**
  6507. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6508. */
  6509. baseWidth: number;
  6510. /**
  6511. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6512. */
  6513. baseHeight: number;
  6514. /**
  6515. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6516. */
  6517. baseDepth: number;
  6518. /**
  6519. * Gets a boolean indicating if the texture is inverted on Y axis
  6520. */
  6521. invertY: boolean;
  6522. /** @hidden */
  6523. _invertVScale: boolean;
  6524. /** @hidden */
  6525. _associatedChannel: number;
  6526. /** @hidden */
  6527. _dataSource: number;
  6528. /** @hidden */
  6529. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6530. /** @hidden */
  6531. _bufferView: Nullable<ArrayBufferView>;
  6532. /** @hidden */
  6533. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6534. /** @hidden */
  6535. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6536. /** @hidden */
  6537. _size: number;
  6538. /** @hidden */
  6539. _extension: string;
  6540. /** @hidden */
  6541. _files: Nullable<string[]>;
  6542. /** @hidden */
  6543. _workingCanvas: Nullable<HTMLCanvasElement>;
  6544. /** @hidden */
  6545. _workingContext: Nullable<CanvasRenderingContext2D>;
  6546. /** @hidden */
  6547. _framebuffer: Nullable<WebGLFramebuffer>;
  6548. /** @hidden */
  6549. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6550. /** @hidden */
  6551. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6552. /** @hidden */
  6553. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6554. /** @hidden */
  6555. _attachments: Nullable<number[]>;
  6556. /** @hidden */
  6557. _cachedCoordinatesMode: Nullable<number>;
  6558. /** @hidden */
  6559. _cachedWrapU: Nullable<number>;
  6560. /** @hidden */
  6561. _cachedWrapV: Nullable<number>;
  6562. /** @hidden */
  6563. _cachedWrapR: Nullable<number>;
  6564. /** @hidden */
  6565. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6566. /** @hidden */
  6567. _isDisabled: boolean;
  6568. /** @hidden */
  6569. _compression: Nullable<string>;
  6570. /** @hidden */
  6571. _generateStencilBuffer: boolean;
  6572. /** @hidden */
  6573. _generateDepthBuffer: boolean;
  6574. /** @hidden */
  6575. _comparisonFunction: number;
  6576. /** @hidden */
  6577. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6578. /** @hidden */
  6579. _lodGenerationScale: number;
  6580. /** @hidden */
  6581. _lodGenerationOffset: number;
  6582. /** @hidden */
  6583. _colorTextureArray: Nullable<WebGLTexture>;
  6584. /** @hidden */
  6585. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6586. /** @hidden */
  6587. _lodTextureHigh: Nullable<BaseTexture>;
  6588. /** @hidden */
  6589. _lodTextureMid: Nullable<BaseTexture>;
  6590. /** @hidden */
  6591. _lodTextureLow: Nullable<BaseTexture>;
  6592. /** @hidden */
  6593. _isRGBD: boolean;
  6594. /** @hidden */
  6595. _linearSpecularLOD: boolean;
  6596. /** @hidden */
  6597. _irradianceTexture: Nullable<BaseTexture>;
  6598. /** @hidden */
  6599. _webGLTexture: Nullable<WebGLTexture>;
  6600. /** @hidden */
  6601. _references: number;
  6602. private _engine;
  6603. /**
  6604. * Gets the Engine the texture belongs to.
  6605. * @returns The babylon engine
  6606. */
  6607. getEngine(): Engine;
  6608. /**
  6609. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6610. */
  6611. readonly dataSource: number;
  6612. /**
  6613. * Creates a new InternalTexture
  6614. * @param engine defines the engine to use
  6615. * @param dataSource defines the type of data that will be used
  6616. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6617. */
  6618. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6619. /**
  6620. * Increments the number of references (ie. the number of Texture that point to it)
  6621. */
  6622. incrementReferences(): void;
  6623. /**
  6624. * Change the size of the texture (not the size of the content)
  6625. * @param width defines the new width
  6626. * @param height defines the new height
  6627. * @param depth defines the new depth (1 by default)
  6628. */
  6629. updateSize(width: int, height: int, depth?: int): void;
  6630. /** @hidden */
  6631. _rebuild(): void;
  6632. /** @hidden */
  6633. _swapAndDie(target: InternalTexture): void;
  6634. /**
  6635. * Dispose the current allocated resources
  6636. */
  6637. dispose(): void;
  6638. }
  6639. }
  6640. declare module BABYLON {
  6641. /**
  6642. * This represents the main contract an easing function should follow.
  6643. * Easing functions are used throughout the animation system.
  6644. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6645. */
  6646. export interface IEasingFunction {
  6647. /**
  6648. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6649. * of the easing function.
  6650. * The link below provides some of the most common examples of easing functions.
  6651. * @see https://easings.net/
  6652. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6653. * @returns the corresponding value on the curve defined by the easing function
  6654. */
  6655. ease(gradient: number): number;
  6656. }
  6657. /**
  6658. * Base class used for every default easing function.
  6659. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6660. */
  6661. export class EasingFunction implements IEasingFunction {
  6662. /**
  6663. * Interpolation follows the mathematical formula associated with the easing function.
  6664. */
  6665. static readonly EASINGMODE_EASEIN: number;
  6666. /**
  6667. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6668. */
  6669. static readonly EASINGMODE_EASEOUT: number;
  6670. /**
  6671. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6672. */
  6673. static readonly EASINGMODE_EASEINOUT: number;
  6674. private _easingMode;
  6675. /**
  6676. * Sets the easing mode of the current function.
  6677. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6678. */
  6679. setEasingMode(easingMode: number): void;
  6680. /**
  6681. * Gets the current easing mode.
  6682. * @returns the easing mode
  6683. */
  6684. getEasingMode(): number;
  6685. /**
  6686. * @hidden
  6687. */
  6688. easeInCore(gradient: number): number;
  6689. /**
  6690. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6691. * of the easing function.
  6692. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6693. * @returns the corresponding value on the curve defined by the easing function
  6694. */
  6695. ease(gradient: number): number;
  6696. }
  6697. /**
  6698. * Easing function with a circle shape (see link below).
  6699. * @see https://easings.net/#easeInCirc
  6700. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6701. */
  6702. export class CircleEase extends EasingFunction implements IEasingFunction {
  6703. /** @hidden */
  6704. easeInCore(gradient: number): number;
  6705. }
  6706. /**
  6707. * Easing function with a ease back shape (see link below).
  6708. * @see https://easings.net/#easeInBack
  6709. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6710. */
  6711. export class BackEase extends EasingFunction implements IEasingFunction {
  6712. /** Defines the amplitude of the function */
  6713. amplitude: number;
  6714. /**
  6715. * Instantiates a back ease easing
  6716. * @see https://easings.net/#easeInBack
  6717. * @param amplitude Defines the amplitude of the function
  6718. */
  6719. constructor(
  6720. /** Defines the amplitude of the function */
  6721. amplitude?: number);
  6722. /** @hidden */
  6723. easeInCore(gradient: number): number;
  6724. }
  6725. /**
  6726. * Easing function with a bouncing shape (see link below).
  6727. * @see https://easings.net/#easeInBounce
  6728. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6729. */
  6730. export class BounceEase extends EasingFunction implements IEasingFunction {
  6731. /** Defines the number of bounces */
  6732. bounces: number;
  6733. /** Defines the amplitude of the bounce */
  6734. bounciness: number;
  6735. /**
  6736. * Instantiates a bounce easing
  6737. * @see https://easings.net/#easeInBounce
  6738. * @param bounces Defines the number of bounces
  6739. * @param bounciness Defines the amplitude of the bounce
  6740. */
  6741. constructor(
  6742. /** Defines the number of bounces */
  6743. bounces?: number,
  6744. /** Defines the amplitude of the bounce */
  6745. bounciness?: number);
  6746. /** @hidden */
  6747. easeInCore(gradient: number): number;
  6748. }
  6749. /**
  6750. * Easing function with a power of 3 shape (see link below).
  6751. * @see https://easings.net/#easeInCubic
  6752. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6753. */
  6754. export class CubicEase extends EasingFunction implements IEasingFunction {
  6755. /** @hidden */
  6756. easeInCore(gradient: number): number;
  6757. }
  6758. /**
  6759. * Easing function with an elastic shape (see link below).
  6760. * @see https://easings.net/#easeInElastic
  6761. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6762. */
  6763. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6764. /** Defines the number of oscillations*/
  6765. oscillations: number;
  6766. /** Defines the amplitude of the oscillations*/
  6767. springiness: number;
  6768. /**
  6769. * Instantiates an elastic easing function
  6770. * @see https://easings.net/#easeInElastic
  6771. * @param oscillations Defines the number of oscillations
  6772. * @param springiness Defines the amplitude of the oscillations
  6773. */
  6774. constructor(
  6775. /** Defines the number of oscillations*/
  6776. oscillations?: number,
  6777. /** Defines the amplitude of the oscillations*/
  6778. springiness?: number);
  6779. /** @hidden */
  6780. easeInCore(gradient: number): number;
  6781. }
  6782. /**
  6783. * Easing function with an exponential shape (see link below).
  6784. * @see https://easings.net/#easeInExpo
  6785. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6786. */
  6787. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6788. /** Defines the exponent of the function */
  6789. exponent: number;
  6790. /**
  6791. * Instantiates an exponential easing function
  6792. * @see https://easings.net/#easeInExpo
  6793. * @param exponent Defines the exponent of the function
  6794. */
  6795. constructor(
  6796. /** Defines the exponent of the function */
  6797. exponent?: number);
  6798. /** @hidden */
  6799. easeInCore(gradient: number): number;
  6800. }
  6801. /**
  6802. * Easing function with a power shape (see link below).
  6803. * @see https://easings.net/#easeInQuad
  6804. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6805. */
  6806. export class PowerEase extends EasingFunction implements IEasingFunction {
  6807. /** Defines the power of the function */
  6808. power: number;
  6809. /**
  6810. * Instantiates an power base easing function
  6811. * @see https://easings.net/#easeInQuad
  6812. * @param power Defines the power of the function
  6813. */
  6814. constructor(
  6815. /** Defines the power of the function */
  6816. power?: number);
  6817. /** @hidden */
  6818. easeInCore(gradient: number): number;
  6819. }
  6820. /**
  6821. * Easing function with a power of 2 shape (see link below).
  6822. * @see https://easings.net/#easeInQuad
  6823. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6824. */
  6825. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6826. /** @hidden */
  6827. easeInCore(gradient: number): number;
  6828. }
  6829. /**
  6830. * Easing function with a power of 4 shape (see link below).
  6831. * @see https://easings.net/#easeInQuart
  6832. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6833. */
  6834. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6835. /** @hidden */
  6836. easeInCore(gradient: number): number;
  6837. }
  6838. /**
  6839. * Easing function with a power of 5 shape (see link below).
  6840. * @see https://easings.net/#easeInQuint
  6841. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6842. */
  6843. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6844. /** @hidden */
  6845. easeInCore(gradient: number): number;
  6846. }
  6847. /**
  6848. * Easing function with a sin shape (see link below).
  6849. * @see https://easings.net/#easeInSine
  6850. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6851. */
  6852. export class SineEase extends EasingFunction implements IEasingFunction {
  6853. /** @hidden */
  6854. easeInCore(gradient: number): number;
  6855. }
  6856. /**
  6857. * Easing function with a bezier shape (see link below).
  6858. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6859. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6860. */
  6861. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6862. /** Defines the x component of the start tangent in the bezier curve */
  6863. x1: number;
  6864. /** Defines the y component of the start tangent in the bezier curve */
  6865. y1: number;
  6866. /** Defines the x component of the end tangent in the bezier curve */
  6867. x2: number;
  6868. /** Defines the y component of the end tangent in the bezier curve */
  6869. y2: number;
  6870. /**
  6871. * Instantiates a bezier function
  6872. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6873. * @param x1 Defines the x component of the start tangent in the bezier curve
  6874. * @param y1 Defines the y component of the start tangent in the bezier curve
  6875. * @param x2 Defines the x component of the end tangent in the bezier curve
  6876. * @param y2 Defines the y component of the end tangent in the bezier curve
  6877. */
  6878. constructor(
  6879. /** Defines the x component of the start tangent in the bezier curve */
  6880. x1?: number,
  6881. /** Defines the y component of the start tangent in the bezier curve */
  6882. y1?: number,
  6883. /** Defines the x component of the end tangent in the bezier curve */
  6884. x2?: number,
  6885. /** Defines the y component of the end tangent in the bezier curve */
  6886. y2?: number);
  6887. /** @hidden */
  6888. easeInCore(gradient: number): number;
  6889. }
  6890. }
  6891. declare module BABYLON {
  6892. /**
  6893. * Defines an interface which represents an animation key frame
  6894. */
  6895. export interface IAnimationKey {
  6896. /**
  6897. * Frame of the key frame
  6898. */
  6899. frame: number;
  6900. /**
  6901. * Value at the specifies key frame
  6902. */
  6903. value: any;
  6904. /**
  6905. * The input tangent for the cubic hermite spline
  6906. */
  6907. inTangent?: any;
  6908. /**
  6909. * The output tangent for the cubic hermite spline
  6910. */
  6911. outTangent?: any;
  6912. /**
  6913. * The animation interpolation type
  6914. */
  6915. interpolation?: AnimationKeyInterpolation;
  6916. }
  6917. /**
  6918. * Enum for the animation key frame interpolation type
  6919. */
  6920. export enum AnimationKeyInterpolation {
  6921. /**
  6922. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6923. */
  6924. STEP = 1
  6925. }
  6926. }
  6927. declare module BABYLON {
  6928. /**
  6929. * Represents the range of an animation
  6930. */
  6931. export class AnimationRange {
  6932. /**The name of the animation range**/
  6933. name: string;
  6934. /**The starting frame of the animation */
  6935. from: number;
  6936. /**The ending frame of the animation*/
  6937. to: number;
  6938. /**
  6939. * Initializes the range of an animation
  6940. * @param name The name of the animation range
  6941. * @param from The starting frame of the animation
  6942. * @param to The ending frame of the animation
  6943. */
  6944. constructor(
  6945. /**The name of the animation range**/
  6946. name: string,
  6947. /**The starting frame of the animation */
  6948. from: number,
  6949. /**The ending frame of the animation*/
  6950. to: number);
  6951. /**
  6952. * Makes a copy of the animation range
  6953. * @returns A copy of the animation range
  6954. */
  6955. clone(): AnimationRange;
  6956. }
  6957. }
  6958. declare module BABYLON {
  6959. /**
  6960. * Composed of a frame, and an action function
  6961. */
  6962. export class AnimationEvent {
  6963. /** The frame for which the event is triggered **/
  6964. frame: number;
  6965. /** The event to perform when triggered **/
  6966. action: (currentFrame: number) => void;
  6967. /** Specifies if the event should be triggered only once**/
  6968. onlyOnce?: boolean | undefined;
  6969. /**
  6970. * Specifies if the animation event is done
  6971. */
  6972. isDone: boolean;
  6973. /**
  6974. * Initializes the animation event
  6975. * @param frame The frame for which the event is triggered
  6976. * @param action The event to perform when triggered
  6977. * @param onlyOnce Specifies if the event should be triggered only once
  6978. */
  6979. constructor(
  6980. /** The frame for which the event is triggered **/
  6981. frame: number,
  6982. /** The event to perform when triggered **/
  6983. action: (currentFrame: number) => void,
  6984. /** Specifies if the event should be triggered only once**/
  6985. onlyOnce?: boolean | undefined);
  6986. /** @hidden */
  6987. _clone(): AnimationEvent;
  6988. }
  6989. }
  6990. declare module BABYLON {
  6991. /**
  6992. * Interface used to define a behavior
  6993. */
  6994. export interface Behavior<T> {
  6995. /** gets or sets behavior's name */
  6996. name: string;
  6997. /**
  6998. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6999. */
  7000. init(): void;
  7001. /**
  7002. * Called when the behavior is attached to a target
  7003. * @param target defines the target where the behavior is attached to
  7004. */
  7005. attach(target: T): void;
  7006. /**
  7007. * Called when the behavior is detached from its target
  7008. */
  7009. detach(): void;
  7010. }
  7011. /**
  7012. * Interface implemented by classes supporting behaviors
  7013. */
  7014. export interface IBehaviorAware<T> {
  7015. /**
  7016. * Attach a behavior
  7017. * @param behavior defines the behavior to attach
  7018. * @returns the current host
  7019. */
  7020. addBehavior(behavior: Behavior<T>): T;
  7021. /**
  7022. * Remove a behavior from the current object
  7023. * @param behavior defines the behavior to detach
  7024. * @returns the current host
  7025. */
  7026. removeBehavior(behavior: Behavior<T>): T;
  7027. /**
  7028. * Gets a behavior using its name to search
  7029. * @param name defines the name to search
  7030. * @returns the behavior or null if not found
  7031. */
  7032. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7033. }
  7034. }
  7035. declare module BABYLON {
  7036. /**
  7037. * @hidden
  7038. */
  7039. export class IntersectionInfo {
  7040. bu: Nullable<number>;
  7041. bv: Nullable<number>;
  7042. distance: number;
  7043. faceId: number;
  7044. subMeshId: number;
  7045. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7046. }
  7047. }
  7048. declare module BABYLON {
  7049. /**
  7050. * Class used to store bounding sphere information
  7051. */
  7052. export class BoundingSphere {
  7053. /**
  7054. * Gets the center of the bounding sphere in local space
  7055. */
  7056. readonly center: Vector3;
  7057. /**
  7058. * Radius of the bounding sphere in local space
  7059. */
  7060. radius: number;
  7061. /**
  7062. * Gets the center of the bounding sphere in world space
  7063. */
  7064. readonly centerWorld: Vector3;
  7065. /**
  7066. * Radius of the bounding sphere in world space
  7067. */
  7068. radiusWorld: number;
  7069. /**
  7070. * Gets the minimum vector in local space
  7071. */
  7072. readonly minimum: Vector3;
  7073. /**
  7074. * Gets the maximum vector in local space
  7075. */
  7076. readonly maximum: Vector3;
  7077. private _worldMatrix;
  7078. private static readonly TmpVector3;
  7079. /**
  7080. * Creates a new bounding sphere
  7081. * @param min defines the minimum vector (in local space)
  7082. * @param max defines the maximum vector (in local space)
  7083. * @param worldMatrix defines the new world matrix
  7084. */
  7085. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7086. /**
  7087. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7088. * @param min defines the new minimum vector (in local space)
  7089. * @param max defines the new maximum vector (in local space)
  7090. * @param worldMatrix defines the new world matrix
  7091. */
  7092. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7093. /**
  7094. * Scale the current bounding sphere by applying a scale factor
  7095. * @param factor defines the scale factor to apply
  7096. * @returns the current bounding box
  7097. */
  7098. scale(factor: number): BoundingSphere;
  7099. /**
  7100. * Gets the world matrix of the bounding box
  7101. * @returns a matrix
  7102. */
  7103. getWorldMatrix(): DeepImmutable<Matrix>;
  7104. /** @hidden */
  7105. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7106. /**
  7107. * Tests if the bounding sphere is intersecting the frustum planes
  7108. * @param frustumPlanes defines the frustum planes to test
  7109. * @returns true if there is an intersection
  7110. */
  7111. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7112. /**
  7113. * Tests if the bounding sphere center is in between the frustum planes.
  7114. * Used for optimistic fast inclusion.
  7115. * @param frustumPlanes defines the frustum planes to test
  7116. * @returns true if the sphere center is in between the frustum planes
  7117. */
  7118. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7119. /**
  7120. * Tests if a point is inside the bounding sphere
  7121. * @param point defines the point to test
  7122. * @returns true if the point is inside the bounding sphere
  7123. */
  7124. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7125. /**
  7126. * Checks if two sphere intersct
  7127. * @param sphere0 sphere 0
  7128. * @param sphere1 sphere 1
  7129. * @returns true if the speres intersect
  7130. */
  7131. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7132. }
  7133. }
  7134. declare module BABYLON {
  7135. /**
  7136. * Class used to store bounding box information
  7137. */
  7138. export class BoundingBox implements ICullable {
  7139. /**
  7140. * Gets the 8 vectors representing the bounding box in local space
  7141. */
  7142. readonly vectors: Vector3[];
  7143. /**
  7144. * Gets the center of the bounding box in local space
  7145. */
  7146. readonly center: Vector3;
  7147. /**
  7148. * Gets the center of the bounding box in world space
  7149. */
  7150. readonly centerWorld: Vector3;
  7151. /**
  7152. * Gets the extend size in local space
  7153. */
  7154. readonly extendSize: Vector3;
  7155. /**
  7156. * Gets the extend size in world space
  7157. */
  7158. readonly extendSizeWorld: Vector3;
  7159. /**
  7160. * Gets the OBB (object bounding box) directions
  7161. */
  7162. readonly directions: Vector3[];
  7163. /**
  7164. * Gets the 8 vectors representing the bounding box in world space
  7165. */
  7166. readonly vectorsWorld: Vector3[];
  7167. /**
  7168. * Gets the minimum vector in world space
  7169. */
  7170. readonly minimumWorld: Vector3;
  7171. /**
  7172. * Gets the maximum vector in world space
  7173. */
  7174. readonly maximumWorld: Vector3;
  7175. /**
  7176. * Gets the minimum vector in local space
  7177. */
  7178. readonly minimum: Vector3;
  7179. /**
  7180. * Gets the maximum vector in local space
  7181. */
  7182. readonly maximum: Vector3;
  7183. private _worldMatrix;
  7184. private static readonly TmpVector3;
  7185. /**
  7186. * @hidden
  7187. */
  7188. _tag: number;
  7189. /**
  7190. * Creates a new bounding box
  7191. * @param min defines the minimum vector (in local space)
  7192. * @param max defines the maximum vector (in local space)
  7193. * @param worldMatrix defines the new world matrix
  7194. */
  7195. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7196. /**
  7197. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7198. * @param min defines the new minimum vector (in local space)
  7199. * @param max defines the new maximum vector (in local space)
  7200. * @param worldMatrix defines the new world matrix
  7201. */
  7202. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7203. /**
  7204. * Scale the current bounding box by applying a scale factor
  7205. * @param factor defines the scale factor to apply
  7206. * @returns the current bounding box
  7207. */
  7208. scale(factor: number): BoundingBox;
  7209. /**
  7210. * Gets the world matrix of the bounding box
  7211. * @returns a matrix
  7212. */
  7213. getWorldMatrix(): DeepImmutable<Matrix>;
  7214. /** @hidden */
  7215. _update(world: DeepImmutable<Matrix>): void;
  7216. /**
  7217. * Tests if the bounding box is intersecting the frustum planes
  7218. * @param frustumPlanes defines the frustum planes to test
  7219. * @returns true if there is an intersection
  7220. */
  7221. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7222. /**
  7223. * Tests if the bounding box is entirely inside the frustum planes
  7224. * @param frustumPlanes defines the frustum planes to test
  7225. * @returns true if there is an inclusion
  7226. */
  7227. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7228. /**
  7229. * Tests if a point is inside the bounding box
  7230. * @param point defines the point to test
  7231. * @returns true if the point is inside the bounding box
  7232. */
  7233. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7234. /**
  7235. * Tests if the bounding box intersects with a bounding sphere
  7236. * @param sphere defines the sphere to test
  7237. * @returns true if there is an intersection
  7238. */
  7239. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7240. /**
  7241. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7242. * @param min defines the min vector to use
  7243. * @param max defines the max vector to use
  7244. * @returns true if there is an intersection
  7245. */
  7246. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7247. /**
  7248. * Tests if two bounding boxes are intersections
  7249. * @param box0 defines the first box to test
  7250. * @param box1 defines the second box to test
  7251. * @returns true if there is an intersection
  7252. */
  7253. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7254. /**
  7255. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7256. * @param minPoint defines the minimum vector of the bounding box
  7257. * @param maxPoint defines the maximum vector of the bounding box
  7258. * @param sphereCenter defines the sphere center
  7259. * @param sphereRadius defines the sphere radius
  7260. * @returns true if there is an intersection
  7261. */
  7262. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7263. /**
  7264. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7265. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7266. * @param frustumPlanes defines the frustum planes to test
  7267. * @return true if there is an inclusion
  7268. */
  7269. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7270. /**
  7271. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7272. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7273. * @param frustumPlanes defines the frustum planes to test
  7274. * @return true if there is an intersection
  7275. */
  7276. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7277. }
  7278. }
  7279. declare module BABYLON {
  7280. /** @hidden */
  7281. export class Collider {
  7282. /** Define if a collision was found */
  7283. collisionFound: boolean;
  7284. /**
  7285. * Define last intersection point in local space
  7286. */
  7287. intersectionPoint: Vector3;
  7288. /**
  7289. * Define last collided mesh
  7290. */
  7291. collidedMesh: Nullable<AbstractMesh>;
  7292. private _collisionPoint;
  7293. private _planeIntersectionPoint;
  7294. private _tempVector;
  7295. private _tempVector2;
  7296. private _tempVector3;
  7297. private _tempVector4;
  7298. private _edge;
  7299. private _baseToVertex;
  7300. private _destinationPoint;
  7301. private _slidePlaneNormal;
  7302. private _displacementVector;
  7303. /** @hidden */
  7304. _radius: Vector3;
  7305. /** @hidden */
  7306. _retry: number;
  7307. private _velocity;
  7308. private _basePoint;
  7309. private _epsilon;
  7310. /** @hidden */
  7311. _velocityWorldLength: number;
  7312. /** @hidden */
  7313. _basePointWorld: Vector3;
  7314. private _velocityWorld;
  7315. private _normalizedVelocity;
  7316. /** @hidden */
  7317. _initialVelocity: Vector3;
  7318. /** @hidden */
  7319. _initialPosition: Vector3;
  7320. private _nearestDistance;
  7321. private _collisionMask;
  7322. collisionMask: number;
  7323. /**
  7324. * Gets the plane normal used to compute the sliding response (in local space)
  7325. */
  7326. readonly slidePlaneNormal: Vector3;
  7327. /** @hidden */
  7328. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7329. /** @hidden */
  7330. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7331. /** @hidden */
  7332. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7333. /** @hidden */
  7334. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7335. /** @hidden */
  7336. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7337. /** @hidden */
  7338. _getResponse(pos: Vector3, vel: Vector3): void;
  7339. }
  7340. }
  7341. declare module BABYLON {
  7342. /**
  7343. * Interface for cullable objects
  7344. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7345. */
  7346. export interface ICullable {
  7347. /**
  7348. * Checks if the object or part of the object is in the frustum
  7349. * @param frustumPlanes Camera near/planes
  7350. * @returns true if the object is in frustum otherwise false
  7351. */
  7352. isInFrustum(frustumPlanes: Plane[]): boolean;
  7353. /**
  7354. * Checks if a cullable object (mesh...) is in the camera frustum
  7355. * Unlike isInFrustum this cheks the full bounding box
  7356. * @param frustumPlanes Camera near/planes
  7357. * @returns true if the object is in frustum otherwise false
  7358. */
  7359. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7360. }
  7361. /**
  7362. * Info for a bounding data of a mesh
  7363. */
  7364. export class BoundingInfo implements ICullable {
  7365. /**
  7366. * Bounding box for the mesh
  7367. */
  7368. readonly boundingBox: BoundingBox;
  7369. /**
  7370. * Bounding sphere for the mesh
  7371. */
  7372. readonly boundingSphere: BoundingSphere;
  7373. private _isLocked;
  7374. private static readonly TmpVector3;
  7375. /**
  7376. * Constructs bounding info
  7377. * @param minimum min vector of the bounding box/sphere
  7378. * @param maximum max vector of the bounding box/sphere
  7379. * @param worldMatrix defines the new world matrix
  7380. */
  7381. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7382. /**
  7383. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7384. * @param min defines the new minimum vector (in local space)
  7385. * @param max defines the new maximum vector (in local space)
  7386. * @param worldMatrix defines the new world matrix
  7387. */
  7388. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7389. /**
  7390. * min vector of the bounding box/sphere
  7391. */
  7392. readonly minimum: Vector3;
  7393. /**
  7394. * max vector of the bounding box/sphere
  7395. */
  7396. readonly maximum: Vector3;
  7397. /**
  7398. * If the info is locked and won't be updated to avoid perf overhead
  7399. */
  7400. isLocked: boolean;
  7401. /**
  7402. * Updates the bounding sphere and box
  7403. * @param world world matrix to be used to update
  7404. */
  7405. update(world: DeepImmutable<Matrix>): void;
  7406. /**
  7407. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7408. * @param center New center of the bounding info
  7409. * @param extend New extend of the bounding info
  7410. * @returns the current bounding info
  7411. */
  7412. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7413. /**
  7414. * Scale the current bounding info by applying a scale factor
  7415. * @param factor defines the scale factor to apply
  7416. * @returns the current bounding info
  7417. */
  7418. scale(factor: number): BoundingInfo;
  7419. /**
  7420. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7421. * @param frustumPlanes defines the frustum to test
  7422. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7423. * @returns true if the bounding info is in the frustum planes
  7424. */
  7425. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7426. /**
  7427. * Gets the world distance between the min and max points of the bounding box
  7428. */
  7429. readonly diagonalLength: number;
  7430. /**
  7431. * Checks if a cullable object (mesh...) is in the camera frustum
  7432. * Unlike isInFrustum this cheks the full bounding box
  7433. * @param frustumPlanes Camera near/planes
  7434. * @returns true if the object is in frustum otherwise false
  7435. */
  7436. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7437. /** @hidden */
  7438. _checkCollision(collider: Collider): boolean;
  7439. /**
  7440. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7441. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7442. * @param point the point to check intersection with
  7443. * @returns if the point intersects
  7444. */
  7445. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7446. /**
  7447. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7448. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7449. * @param boundingInfo the bounding info to check intersection with
  7450. * @param precise if the intersection should be done using OBB
  7451. * @returns if the bounding info intersects
  7452. */
  7453. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7454. }
  7455. }
  7456. declare module BABYLON {
  7457. /**
  7458. * Defines an array and its length.
  7459. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7460. */
  7461. export interface ISmartArrayLike<T> {
  7462. /**
  7463. * The data of the array.
  7464. */
  7465. data: Array<T>;
  7466. /**
  7467. * The active length of the array.
  7468. */
  7469. length: number;
  7470. }
  7471. /**
  7472. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7473. */
  7474. export class SmartArray<T> implements ISmartArrayLike<T> {
  7475. /**
  7476. * The full set of data from the array.
  7477. */
  7478. data: Array<T>;
  7479. /**
  7480. * The active length of the array.
  7481. */
  7482. length: number;
  7483. protected _id: number;
  7484. /**
  7485. * Instantiates a Smart Array.
  7486. * @param capacity defines the default capacity of the array.
  7487. */
  7488. constructor(capacity: number);
  7489. /**
  7490. * Pushes a value at the end of the active data.
  7491. * @param value defines the object to push in the array.
  7492. */
  7493. push(value: T): void;
  7494. /**
  7495. * Iterates over the active data and apply the lambda to them.
  7496. * @param func defines the action to apply on each value.
  7497. */
  7498. forEach(func: (content: T) => void): void;
  7499. /**
  7500. * Sorts the full sets of data.
  7501. * @param compareFn defines the comparison function to apply.
  7502. */
  7503. sort(compareFn: (a: T, b: T) => number): void;
  7504. /**
  7505. * Resets the active data to an empty array.
  7506. */
  7507. reset(): void;
  7508. /**
  7509. * Releases all the data from the array as well as the array.
  7510. */
  7511. dispose(): void;
  7512. /**
  7513. * Concats the active data with a given array.
  7514. * @param array defines the data to concatenate with.
  7515. */
  7516. concat(array: any): void;
  7517. /**
  7518. * Returns the position of a value in the active data.
  7519. * @param value defines the value to find the index for
  7520. * @returns the index if found in the active data otherwise -1
  7521. */
  7522. indexOf(value: T): number;
  7523. /**
  7524. * Returns whether an element is part of the active data.
  7525. * @param value defines the value to look for
  7526. * @returns true if found in the active data otherwise false
  7527. */
  7528. contains(value: T): boolean;
  7529. private static _GlobalId;
  7530. }
  7531. /**
  7532. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7533. * The data in this array can only be present once
  7534. */
  7535. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7536. private _duplicateId;
  7537. /**
  7538. * Pushes a value at the end of the active data.
  7539. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7540. * @param value defines the object to push in the array.
  7541. */
  7542. push(value: T): void;
  7543. /**
  7544. * Pushes a value at the end of the active data.
  7545. * If the data is already present, it won t be added again
  7546. * @param value defines the object to push in the array.
  7547. * @returns true if added false if it was already present
  7548. */
  7549. pushNoDuplicate(value: T): boolean;
  7550. /**
  7551. * Resets the active data to an empty array.
  7552. */
  7553. reset(): void;
  7554. /**
  7555. * Concats the active data with a given array.
  7556. * This ensures no dupplicate will be present in the result.
  7557. * @param array defines the data to concatenate with.
  7558. */
  7559. concatWithNoDuplicate(array: any): void;
  7560. }
  7561. }
  7562. declare module BABYLON {
  7563. /**
  7564. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7565. * separate meshes. This can be use to improve performances.
  7566. * @see http://doc.babylonjs.com/how_to/multi_materials
  7567. */
  7568. export class MultiMaterial extends Material {
  7569. private _subMaterials;
  7570. /**
  7571. * Gets or Sets the list of Materials used within the multi material.
  7572. * They need to be ordered according to the submeshes order in the associated mesh
  7573. */
  7574. subMaterials: Nullable<Material>[];
  7575. /**
  7576. * Function used to align with Node.getChildren()
  7577. * @returns the list of Materials used within the multi material
  7578. */
  7579. getChildren(): Nullable<Material>[];
  7580. /**
  7581. * Instantiates a new Multi Material
  7582. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7583. * separate meshes. This can be use to improve performances.
  7584. * @see http://doc.babylonjs.com/how_to/multi_materials
  7585. * @param name Define the name in the scene
  7586. * @param scene Define the scene the material belongs to
  7587. */
  7588. constructor(name: string, scene: Scene);
  7589. private _hookArray;
  7590. /**
  7591. * Get one of the submaterial by its index in the submaterials array
  7592. * @param index The index to look the sub material at
  7593. * @returns The Material if the index has been defined
  7594. */
  7595. getSubMaterial(index: number): Nullable<Material>;
  7596. /**
  7597. * Get the list of active textures for the whole sub materials list.
  7598. * @returns All the textures that will be used during the rendering
  7599. */
  7600. getActiveTextures(): BaseTexture[];
  7601. /**
  7602. * Gets the current class name of the material e.g. "MultiMaterial"
  7603. * Mainly use in serialization.
  7604. * @returns the class name
  7605. */
  7606. getClassName(): string;
  7607. /**
  7608. * Checks if the material is ready to render the requested sub mesh
  7609. * @param mesh Define the mesh the submesh belongs to
  7610. * @param subMesh Define the sub mesh to look readyness for
  7611. * @param useInstances Define whether or not the material is used with instances
  7612. * @returns true if ready, otherwise false
  7613. */
  7614. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7615. /**
  7616. * Clones the current material and its related sub materials
  7617. * @param name Define the name of the newly cloned material
  7618. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7619. * @returns the cloned material
  7620. */
  7621. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7622. /**
  7623. * Serializes the materials into a JSON representation.
  7624. * @returns the JSON representation
  7625. */
  7626. serialize(): any;
  7627. /**
  7628. * Dispose the material and release its associated resources
  7629. * @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)
  7630. * @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)
  7631. * @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)
  7632. */
  7633. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7634. /**
  7635. * Creates a MultiMaterial from parsed MultiMaterial data.
  7636. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7637. * @param scene defines the hosting scene
  7638. * @returns a new MultiMaterial
  7639. */
  7640. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7641. }
  7642. }
  7643. declare module BABYLON {
  7644. /**
  7645. * Class used to represent data loading progression
  7646. */
  7647. export class SceneLoaderFlags {
  7648. private static _ForceFullSceneLoadingForIncremental;
  7649. private static _ShowLoadingScreen;
  7650. private static _CleanBoneMatrixWeights;
  7651. private static _loggingLevel;
  7652. /**
  7653. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7654. */
  7655. static ForceFullSceneLoadingForIncremental: boolean;
  7656. /**
  7657. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7658. */
  7659. static ShowLoadingScreen: boolean;
  7660. /**
  7661. * Defines the current logging level (while loading the scene)
  7662. * @ignorenaming
  7663. */
  7664. static loggingLevel: number;
  7665. /**
  7666. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7667. */
  7668. static CleanBoneMatrixWeights: boolean;
  7669. }
  7670. }
  7671. declare module BABYLON {
  7672. /**
  7673. * 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.
  7674. * @see https://doc.babylonjs.com/how_to/transformnode
  7675. */
  7676. export class TransformNode extends Node {
  7677. /**
  7678. * Object will not rotate to face the camera
  7679. */
  7680. static BILLBOARDMODE_NONE: number;
  7681. /**
  7682. * Object will rotate to face the camera but only on the x axis
  7683. */
  7684. static BILLBOARDMODE_X: number;
  7685. /**
  7686. * Object will rotate to face the camera but only on the y axis
  7687. */
  7688. static BILLBOARDMODE_Y: number;
  7689. /**
  7690. * Object will rotate to face the camera but only on the z axis
  7691. */
  7692. static BILLBOARDMODE_Z: number;
  7693. /**
  7694. * Object will rotate to face the camera
  7695. */
  7696. static BILLBOARDMODE_ALL: number;
  7697. private _forward;
  7698. private _forwardInverted;
  7699. private _up;
  7700. private _right;
  7701. private _rightInverted;
  7702. private _position;
  7703. private _rotation;
  7704. private _rotationQuaternion;
  7705. protected _scaling: Vector3;
  7706. protected _isDirty: boolean;
  7707. private _transformToBoneReferal;
  7708. private _billboardMode;
  7709. /**
  7710. * Gets or sets the billboard mode. Default is 0.
  7711. *
  7712. * | Value | Type | Description |
  7713. * | --- | --- | --- |
  7714. * | 0 | BILLBOARDMODE_NONE | |
  7715. * | 1 | BILLBOARDMODE_X | |
  7716. * | 2 | BILLBOARDMODE_Y | |
  7717. * | 4 | BILLBOARDMODE_Z | |
  7718. * | 7 | BILLBOARDMODE_ALL | |
  7719. *
  7720. */
  7721. billboardMode: number;
  7722. private _preserveParentRotationForBillboard;
  7723. /**
  7724. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7725. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7726. */
  7727. preserveParentRotationForBillboard: boolean;
  7728. /**
  7729. * 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
  7730. */
  7731. scalingDeterminant: number;
  7732. private _infiniteDistance;
  7733. /**
  7734. * Gets or sets the distance of the object to max, often used by skybox
  7735. */
  7736. infiniteDistance: boolean;
  7737. /**
  7738. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7739. * By default the system will update normals to compensate
  7740. */
  7741. ignoreNonUniformScaling: boolean;
  7742. /**
  7743. * 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
  7744. */
  7745. reIntegrateRotationIntoRotationQuaternion: boolean;
  7746. /** @hidden */
  7747. _poseMatrix: Nullable<Matrix>;
  7748. /** @hidden */
  7749. _localMatrix: Matrix;
  7750. private _usePivotMatrix;
  7751. private _absolutePosition;
  7752. private _pivotMatrix;
  7753. private _pivotMatrixInverse;
  7754. protected _postMultiplyPivotMatrix: boolean;
  7755. protected _isWorldMatrixFrozen: boolean;
  7756. /** @hidden */
  7757. _indexInSceneTransformNodesArray: number;
  7758. /**
  7759. * An event triggered after the world matrix is updated
  7760. */
  7761. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7762. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7763. /**
  7764. * Gets a string identifying the name of the class
  7765. * @returns "TransformNode" string
  7766. */
  7767. getClassName(): string;
  7768. /**
  7769. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7770. */
  7771. position: Vector3;
  7772. /**
  7773. * 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)).
  7774. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7775. */
  7776. rotation: Vector3;
  7777. /**
  7778. * 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)).
  7779. */
  7780. scaling: Vector3;
  7781. /**
  7782. * 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).
  7783. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7784. */
  7785. rotationQuaternion: Nullable<Quaternion>;
  7786. /**
  7787. * The forward direction of that transform in world space.
  7788. */
  7789. readonly forward: Vector3;
  7790. /**
  7791. * The up direction of that transform in world space.
  7792. */
  7793. readonly up: Vector3;
  7794. /**
  7795. * The right direction of that transform in world space.
  7796. */
  7797. readonly right: Vector3;
  7798. /**
  7799. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7800. * @param matrix the matrix to copy the pose from
  7801. * @returns this TransformNode.
  7802. */
  7803. updatePoseMatrix(matrix: Matrix): TransformNode;
  7804. /**
  7805. * Returns the mesh Pose matrix.
  7806. * @returns the pose matrix
  7807. */
  7808. getPoseMatrix(): Matrix;
  7809. /** @hidden */
  7810. _isSynchronized(): boolean;
  7811. /** @hidden */
  7812. _initCache(): void;
  7813. /**
  7814. * Flag the transform node as dirty (Forcing it to update everything)
  7815. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7816. * @returns this transform node
  7817. */
  7818. markAsDirty(property: string): TransformNode;
  7819. /**
  7820. * Returns the current mesh absolute position.
  7821. * Returns a Vector3.
  7822. */
  7823. readonly absolutePosition: Vector3;
  7824. /**
  7825. * Sets a new matrix to apply before all other transformation
  7826. * @param matrix defines the transform matrix
  7827. * @returns the current TransformNode
  7828. */
  7829. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7830. /**
  7831. * Sets a new pivot matrix to the current node
  7832. * @param matrix defines the new pivot matrix to use
  7833. * @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
  7834. * @returns the current TransformNode
  7835. */
  7836. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7837. /**
  7838. * Returns the mesh pivot matrix.
  7839. * Default : Identity.
  7840. * @returns the matrix
  7841. */
  7842. getPivotMatrix(): Matrix;
  7843. /**
  7844. * Prevents the World matrix to be computed any longer.
  7845. * @returns the TransformNode.
  7846. */
  7847. freezeWorldMatrix(): TransformNode;
  7848. /**
  7849. * Allows back the World matrix computation.
  7850. * @returns the TransformNode.
  7851. */
  7852. unfreezeWorldMatrix(): this;
  7853. /**
  7854. * True if the World matrix has been frozen.
  7855. */
  7856. readonly isWorldMatrixFrozen: boolean;
  7857. /**
  7858. * Retuns the mesh absolute position in the World.
  7859. * @returns a Vector3.
  7860. */
  7861. getAbsolutePosition(): Vector3;
  7862. /**
  7863. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7864. * @param absolutePosition the absolute position to set
  7865. * @returns the TransformNode.
  7866. */
  7867. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7868. /**
  7869. * Sets the mesh position in its local space.
  7870. * @param vector3 the position to set in localspace
  7871. * @returns the TransformNode.
  7872. */
  7873. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7874. /**
  7875. * Returns the mesh position in the local space from the current World matrix values.
  7876. * @returns a new Vector3.
  7877. */
  7878. getPositionExpressedInLocalSpace(): Vector3;
  7879. /**
  7880. * Translates the mesh along the passed Vector3 in its local space.
  7881. * @param vector3 the distance to translate in localspace
  7882. * @returns the TransformNode.
  7883. */
  7884. locallyTranslate(vector3: Vector3): TransformNode;
  7885. private static _lookAtVectorCache;
  7886. /**
  7887. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7888. * @param targetPoint the position (must be in same space as current mesh) to look at
  7889. * @param yawCor optional yaw (y-axis) correction in radians
  7890. * @param pitchCor optional pitch (x-axis) correction in radians
  7891. * @param rollCor optional roll (z-axis) correction in radians
  7892. * @param space the choosen space of the target
  7893. * @returns the TransformNode.
  7894. */
  7895. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7896. /**
  7897. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7898. * This Vector3 is expressed in the World space.
  7899. * @param localAxis axis to rotate
  7900. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7901. */
  7902. getDirection(localAxis: Vector3): Vector3;
  7903. /**
  7904. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7905. * localAxis is expressed in the mesh local space.
  7906. * result is computed in the Wordl space from the mesh World matrix.
  7907. * @param localAxis axis to rotate
  7908. * @param result the resulting transformnode
  7909. * @returns this TransformNode.
  7910. */
  7911. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7912. /**
  7913. * Sets this transform node rotation to the given local axis.
  7914. * @param localAxis the axis in local space
  7915. * @param yawCor optional yaw (y-axis) correction in radians
  7916. * @param pitchCor optional pitch (x-axis) correction in radians
  7917. * @param rollCor optional roll (z-axis) correction in radians
  7918. * @returns this TransformNode
  7919. */
  7920. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7921. /**
  7922. * Sets a new pivot point to the current node
  7923. * @param point defines the new pivot point to use
  7924. * @param space defines if the point is in world or local space (local by default)
  7925. * @returns the current TransformNode
  7926. */
  7927. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7928. /**
  7929. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7930. * @returns the pivot point
  7931. */
  7932. getPivotPoint(): Vector3;
  7933. /**
  7934. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7935. * @param result the vector3 to store the result
  7936. * @returns this TransformNode.
  7937. */
  7938. getPivotPointToRef(result: Vector3): TransformNode;
  7939. /**
  7940. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7941. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7942. */
  7943. getAbsolutePivotPoint(): Vector3;
  7944. /**
  7945. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7946. * @param result vector3 to store the result
  7947. * @returns this TransformNode.
  7948. */
  7949. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7950. /**
  7951. * Defines the passed node as the parent of the current node.
  7952. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7953. * @see https://doc.babylonjs.com/how_to/parenting
  7954. * @param node the node ot set as the parent
  7955. * @returns this TransformNode.
  7956. */
  7957. setParent(node: Nullable<Node>): TransformNode;
  7958. private _nonUniformScaling;
  7959. /**
  7960. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7961. */
  7962. readonly nonUniformScaling: boolean;
  7963. /** @hidden */
  7964. _updateNonUniformScalingState(value: boolean): boolean;
  7965. /**
  7966. * Attach the current TransformNode to another TransformNode associated with a bone
  7967. * @param bone Bone affecting the TransformNode
  7968. * @param affectedTransformNode TransformNode associated with the bone
  7969. * @returns this object
  7970. */
  7971. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7972. /**
  7973. * Detach the transform node if its associated with a bone
  7974. * @returns this object
  7975. */
  7976. detachFromBone(): TransformNode;
  7977. private static _rotationAxisCache;
  7978. /**
  7979. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7980. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7981. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7982. * The passed axis is also normalized.
  7983. * @param axis the axis to rotate around
  7984. * @param amount the amount to rotate in radians
  7985. * @param space Space to rotate in (Default: local)
  7986. * @returns the TransformNode.
  7987. */
  7988. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7989. /**
  7990. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7991. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7992. * The passed axis is also normalized. .
  7993. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7994. * @param point the point to rotate around
  7995. * @param axis the axis to rotate around
  7996. * @param amount the amount to rotate in radians
  7997. * @returns the TransformNode
  7998. */
  7999. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8000. /**
  8001. * Translates the mesh along the axis vector for the passed distance in the given space.
  8002. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8003. * @param axis the axis to translate in
  8004. * @param distance the distance to translate
  8005. * @param space Space to rotate in (Default: local)
  8006. * @returns the TransformNode.
  8007. */
  8008. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8009. /**
  8010. * Adds a rotation step to the mesh current rotation.
  8011. * x, y, z are Euler angles expressed in radians.
  8012. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8013. * This means this rotation is made in the mesh local space only.
  8014. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8015. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8016. * ```javascript
  8017. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8018. * ```
  8019. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8020. * 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.
  8021. * @param x Rotation to add
  8022. * @param y Rotation to add
  8023. * @param z Rotation to add
  8024. * @returns the TransformNode.
  8025. */
  8026. addRotation(x: number, y: number, z: number): TransformNode;
  8027. /**
  8028. * @hidden
  8029. */
  8030. protected _getEffectiveParent(): Nullable<Node>;
  8031. /**
  8032. * Computes the world matrix of the node
  8033. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8034. * @returns the world matrix
  8035. */
  8036. computeWorldMatrix(force?: boolean): Matrix;
  8037. protected _afterComputeWorldMatrix(): void;
  8038. /**
  8039. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8040. * @param func callback function to add
  8041. *
  8042. * @returns the TransformNode.
  8043. */
  8044. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8045. /**
  8046. * Removes a registered callback function.
  8047. * @param func callback function to remove
  8048. * @returns the TransformNode.
  8049. */
  8050. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8051. /**
  8052. * Gets the position of the current mesh in camera space
  8053. * @param camera defines the camera to use
  8054. * @returns a position
  8055. */
  8056. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8057. /**
  8058. * Returns the distance from the mesh to the active camera
  8059. * @param camera defines the camera to use
  8060. * @returns the distance
  8061. */
  8062. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8063. /**
  8064. * Clone the current transform node
  8065. * @param name Name of the new clone
  8066. * @param newParent New parent for the clone
  8067. * @param doNotCloneChildren Do not clone children hierarchy
  8068. * @returns the new transform node
  8069. */
  8070. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8071. /**
  8072. * Serializes the objects information.
  8073. * @param currentSerializationObject defines the object to serialize in
  8074. * @returns the serialized object
  8075. */
  8076. serialize(currentSerializationObject?: any): any;
  8077. /**
  8078. * Returns a new TransformNode object parsed from the source provided.
  8079. * @param parsedTransformNode is the source.
  8080. * @param scene the scne the object belongs to
  8081. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8082. * @returns a new TransformNode object parsed from the source provided.
  8083. */
  8084. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8085. /**
  8086. * Get all child-transformNodes of this node
  8087. * @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
  8088. * @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
  8089. * @returns an array of TransformNode
  8090. */
  8091. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8092. /**
  8093. * Releases resources associated with this transform node.
  8094. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8095. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8096. */
  8097. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8098. }
  8099. }
  8100. declare module BABYLON {
  8101. /**
  8102. * Class used to override all child animations of a given target
  8103. */
  8104. export class AnimationPropertiesOverride {
  8105. /**
  8106. * Gets or sets a value indicating if animation blending must be used
  8107. */
  8108. enableBlending: boolean;
  8109. /**
  8110. * Gets or sets the blending speed to use when enableBlending is true
  8111. */
  8112. blendingSpeed: number;
  8113. /**
  8114. * Gets or sets the default loop mode to use
  8115. */
  8116. loopMode: number;
  8117. }
  8118. }
  8119. declare module BABYLON {
  8120. /**
  8121. * Class used to store bone information
  8122. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8123. */
  8124. export class Bone extends Node {
  8125. /**
  8126. * defines the bone name
  8127. */
  8128. name: string;
  8129. private static _tmpVecs;
  8130. private static _tmpQuat;
  8131. private static _tmpMats;
  8132. /**
  8133. * Gets the list of child bones
  8134. */
  8135. children: Bone[];
  8136. /** Gets the animations associated with this bone */
  8137. animations: Animation[];
  8138. /**
  8139. * Gets or sets bone length
  8140. */
  8141. length: number;
  8142. /**
  8143. * @hidden Internal only
  8144. * Set this value to map this bone to a different index in the transform matrices
  8145. * Set this value to -1 to exclude the bone from the transform matrices
  8146. */
  8147. _index: Nullable<number>;
  8148. private _skeleton;
  8149. private _localMatrix;
  8150. private _restPose;
  8151. private _baseMatrix;
  8152. private _absoluteTransform;
  8153. private _invertedAbsoluteTransform;
  8154. private _parent;
  8155. private _scalingDeterminant;
  8156. private _worldTransform;
  8157. private _localScaling;
  8158. private _localRotation;
  8159. private _localPosition;
  8160. private _needToDecompose;
  8161. private _needToCompose;
  8162. /** @hidden */
  8163. _linkedTransformNode: Nullable<TransformNode>;
  8164. /** @hidden */
  8165. _waitingTransformNodeId: Nullable<string>;
  8166. /** @hidden */
  8167. /** @hidden */
  8168. _matrix: Matrix;
  8169. /**
  8170. * Create a new bone
  8171. * @param name defines the bone name
  8172. * @param skeleton defines the parent skeleton
  8173. * @param parentBone defines the parent (can be null if the bone is the root)
  8174. * @param localMatrix defines the local matrix
  8175. * @param restPose defines the rest pose matrix
  8176. * @param baseMatrix defines the base matrix
  8177. * @param index defines index of the bone in the hiearchy
  8178. */
  8179. constructor(
  8180. /**
  8181. * defines the bone name
  8182. */
  8183. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8184. /**
  8185. * Gets the current object class name.
  8186. * @return the class name
  8187. */
  8188. getClassName(): string;
  8189. /**
  8190. * Gets the parent skeleton
  8191. * @returns a skeleton
  8192. */
  8193. getSkeleton(): Skeleton;
  8194. /**
  8195. * Gets parent bone
  8196. * @returns a bone or null if the bone is the root of the bone hierarchy
  8197. */
  8198. getParent(): Nullable<Bone>;
  8199. /**
  8200. * Returns an array containing the root bones
  8201. * @returns an array containing the root bones
  8202. */
  8203. getChildren(): Array<Bone>;
  8204. /**
  8205. * Sets the parent bone
  8206. * @param parent defines the parent (can be null if the bone is the root)
  8207. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8208. */
  8209. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8210. /**
  8211. * Gets the local matrix
  8212. * @returns a matrix
  8213. */
  8214. getLocalMatrix(): Matrix;
  8215. /**
  8216. * Gets the base matrix (initial matrix which remains unchanged)
  8217. * @returns a matrix
  8218. */
  8219. getBaseMatrix(): Matrix;
  8220. /**
  8221. * Gets the rest pose matrix
  8222. * @returns a matrix
  8223. */
  8224. getRestPose(): Matrix;
  8225. /**
  8226. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8227. */
  8228. getWorldMatrix(): Matrix;
  8229. /**
  8230. * Sets the local matrix to rest pose matrix
  8231. */
  8232. returnToRest(): void;
  8233. /**
  8234. * Gets the inverse of the absolute transform matrix.
  8235. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8236. * @returns a matrix
  8237. */
  8238. getInvertedAbsoluteTransform(): Matrix;
  8239. /**
  8240. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8241. * @returns a matrix
  8242. */
  8243. getAbsoluteTransform(): Matrix;
  8244. /**
  8245. * Links with the given transform node.
  8246. * The local matrix of this bone is copied from the transform node every frame.
  8247. * @param transformNode defines the transform node to link to
  8248. */
  8249. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8250. /** Gets or sets current position (in local space) */
  8251. position: Vector3;
  8252. /** Gets or sets current rotation (in local space) */
  8253. rotation: Vector3;
  8254. /** Gets or sets current rotation quaternion (in local space) */
  8255. rotationQuaternion: Quaternion;
  8256. /** Gets or sets current scaling (in local space) */
  8257. scaling: Vector3;
  8258. /**
  8259. * Gets the animation properties override
  8260. */
  8261. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8262. private _decompose;
  8263. private _compose;
  8264. /**
  8265. * Update the base and local matrices
  8266. * @param matrix defines the new base or local matrix
  8267. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8268. * @param updateLocalMatrix defines if the local matrix should be updated
  8269. */
  8270. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8271. /** @hidden */
  8272. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8273. /**
  8274. * Flag the bone as dirty (Forcing it to update everything)
  8275. */
  8276. markAsDirty(): void;
  8277. /** @hidden */
  8278. _markAsDirtyAndCompose(): void;
  8279. private _markAsDirtyAndDecompose;
  8280. /**
  8281. * Translate the bone in local or world space
  8282. * @param vec The amount to translate the bone
  8283. * @param space The space that the translation is in
  8284. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8285. */
  8286. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8287. /**
  8288. * Set the postion of the bone in local or world space
  8289. * @param position The position to set the bone
  8290. * @param space The space that the position is in
  8291. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8292. */
  8293. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8294. /**
  8295. * Set the absolute position of the bone (world space)
  8296. * @param position The position to set the bone
  8297. * @param mesh The mesh that this bone is attached to
  8298. */
  8299. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8300. /**
  8301. * Scale the bone on the x, y and z axes (in local space)
  8302. * @param x The amount to scale the bone on the x axis
  8303. * @param y The amount to scale the bone on the y axis
  8304. * @param z The amount to scale the bone on the z axis
  8305. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8306. */
  8307. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8308. /**
  8309. * Set the bone scaling in local space
  8310. * @param scale defines the scaling vector
  8311. */
  8312. setScale(scale: Vector3): void;
  8313. /**
  8314. * Gets the current scaling in local space
  8315. * @returns the current scaling vector
  8316. */
  8317. getScale(): Vector3;
  8318. /**
  8319. * Gets the current scaling in local space and stores it in a target vector
  8320. * @param result defines the target vector
  8321. */
  8322. getScaleToRef(result: Vector3): void;
  8323. /**
  8324. * Set the yaw, pitch, and roll of the bone in local or world space
  8325. * @param yaw The rotation of the bone on the y axis
  8326. * @param pitch The rotation of the bone on the x axis
  8327. * @param roll The rotation of the bone on the z axis
  8328. * @param space The space that the axes of rotation are in
  8329. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8330. */
  8331. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8332. /**
  8333. * Add a rotation to the bone on an axis in local or world space
  8334. * @param axis The axis to rotate the bone on
  8335. * @param amount The amount to rotate the bone
  8336. * @param space The space that the axis is in
  8337. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8338. */
  8339. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8340. /**
  8341. * Set the rotation of the bone to a particular axis angle in local or world space
  8342. * @param axis The axis to rotate the bone on
  8343. * @param angle The angle that the bone should be rotated to
  8344. * @param space The space that the axis is in
  8345. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8346. */
  8347. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8348. /**
  8349. * Set the euler rotation of the bone in local of world space
  8350. * @param rotation The euler rotation that the bone should be set to
  8351. * @param space The space that the rotation is in
  8352. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8353. */
  8354. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8355. /**
  8356. * Set the quaternion rotation of the bone in local of world space
  8357. * @param quat The quaternion rotation that the bone should be set to
  8358. * @param space The space that the rotation is in
  8359. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8360. */
  8361. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8362. /**
  8363. * Set the rotation matrix of the bone in local of world space
  8364. * @param rotMat The rotation matrix that the bone should be set to
  8365. * @param space The space that the rotation is in
  8366. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8367. */
  8368. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8369. private _rotateWithMatrix;
  8370. private _getNegativeRotationToRef;
  8371. /**
  8372. * Get the position of the bone in local or world space
  8373. * @param space The space that the returned position is in
  8374. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8375. * @returns The position of the bone
  8376. */
  8377. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8378. /**
  8379. * Copy the position of the bone to a vector3 in local or world space
  8380. * @param space The space that the returned position is in
  8381. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8382. * @param result The vector3 to copy the position to
  8383. */
  8384. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8385. /**
  8386. * Get the absolute position of the bone (world space)
  8387. * @param mesh The mesh that this bone is attached to
  8388. * @returns The absolute position of the bone
  8389. */
  8390. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8391. /**
  8392. * Copy the absolute position of the bone (world space) to the result param
  8393. * @param mesh The mesh that this bone is attached to
  8394. * @param result The vector3 to copy the absolute position to
  8395. */
  8396. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8397. /**
  8398. * Compute the absolute transforms of this bone and its children
  8399. */
  8400. computeAbsoluteTransforms(): void;
  8401. /**
  8402. * Get the world direction from an axis that is in the local space of the bone
  8403. * @param localAxis The local direction that is used to compute the world direction
  8404. * @param mesh The mesh that this bone is attached to
  8405. * @returns The world direction
  8406. */
  8407. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8408. /**
  8409. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8410. * @param localAxis The local direction that is used to compute the world direction
  8411. * @param mesh The mesh that this bone is attached to
  8412. * @param result The vector3 that the world direction will be copied to
  8413. */
  8414. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8415. /**
  8416. * Get the euler rotation of the bone in local or world space
  8417. * @param space The space that the rotation should be in
  8418. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8419. * @returns The euler rotation
  8420. */
  8421. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8422. /**
  8423. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8424. * @param space The space that the rotation should be in
  8425. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8426. * @param result The vector3 that the rotation should be copied to
  8427. */
  8428. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8429. /**
  8430. * Get the quaternion rotation of the bone in either local or world space
  8431. * @param space The space that the rotation should be in
  8432. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8433. * @returns The quaternion rotation
  8434. */
  8435. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8436. /**
  8437. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8438. * @param space The space that the rotation should be in
  8439. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8440. * @param result The quaternion that the rotation should be copied to
  8441. */
  8442. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8443. /**
  8444. * Get the rotation matrix of the bone in local or world space
  8445. * @param space The space that the rotation should be in
  8446. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8447. * @returns The rotation matrix
  8448. */
  8449. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8450. /**
  8451. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8452. * @param space The space that the rotation should be in
  8453. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8454. * @param result The quaternion that the rotation should be copied to
  8455. */
  8456. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8457. /**
  8458. * Get the world position of a point that is in the local space of the bone
  8459. * @param position The local position
  8460. * @param mesh The mesh that this bone is attached to
  8461. * @returns The world position
  8462. */
  8463. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8464. /**
  8465. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8466. * @param position The local position
  8467. * @param mesh The mesh that this bone is attached to
  8468. * @param result The vector3 that the world position should be copied to
  8469. */
  8470. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8471. /**
  8472. * Get the local position of a point that is in world space
  8473. * @param position The world position
  8474. * @param mesh The mesh that this bone is attached to
  8475. * @returns The local position
  8476. */
  8477. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8478. /**
  8479. * Get the local position of a point that is in world space and copy it to the result param
  8480. * @param position The world position
  8481. * @param mesh The mesh that this bone is attached to
  8482. * @param result The vector3 that the local position should be copied to
  8483. */
  8484. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8485. }
  8486. }
  8487. declare module BABYLON {
  8488. /**
  8489. * Enum that determines the text-wrapping mode to use.
  8490. */
  8491. export enum InspectableType {
  8492. /**
  8493. * Checkbox for booleans
  8494. */
  8495. Checkbox = 0,
  8496. /**
  8497. * Sliders for numbers
  8498. */
  8499. Slider = 1,
  8500. /**
  8501. * Vector3
  8502. */
  8503. Vector3 = 2,
  8504. /**
  8505. * Quaternions
  8506. */
  8507. Quaternion = 3,
  8508. /**
  8509. * Color3
  8510. */
  8511. Color3 = 4
  8512. }
  8513. /**
  8514. * Interface used to define custom inspectable properties.
  8515. * This interface is used by the inspector to display custom property grids
  8516. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8517. */
  8518. export interface IInspectable {
  8519. /**
  8520. * Gets the label to display
  8521. */
  8522. label: string;
  8523. /**
  8524. * Gets the name of the property to edit
  8525. */
  8526. propertyName: string;
  8527. /**
  8528. * Gets the type of the editor to use
  8529. */
  8530. type: InspectableType;
  8531. /**
  8532. * Gets the minimum value of the property when using in "slider" mode
  8533. */
  8534. min?: number;
  8535. /**
  8536. * Gets the maximum value of the property when using in "slider" mode
  8537. */
  8538. max?: number;
  8539. /**
  8540. * Gets the setp to use when using in "slider" mode
  8541. */
  8542. step?: number;
  8543. }
  8544. }
  8545. declare module BABYLON {
  8546. /**
  8547. * This represents the required contract to create a new type of texture loader.
  8548. */
  8549. export interface IInternalTextureLoader {
  8550. /**
  8551. * Defines wether the loader supports cascade loading the different faces.
  8552. */
  8553. supportCascades: boolean;
  8554. /**
  8555. * This returns if the loader support the current file information.
  8556. * @param extension defines the file extension of the file being loaded
  8557. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8558. * @param fallback defines the fallback internal texture if any
  8559. * @param isBase64 defines whether the texture is encoded as a base64
  8560. * @param isBuffer defines whether the texture data are stored as a buffer
  8561. * @returns true if the loader can load the specified file
  8562. */
  8563. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8564. /**
  8565. * Transform the url before loading if required.
  8566. * @param rootUrl the url of the texture
  8567. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8568. * @returns the transformed texture
  8569. */
  8570. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8571. /**
  8572. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8573. * @param rootUrl the url of the texture
  8574. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8575. * @returns the fallback texture
  8576. */
  8577. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8578. /**
  8579. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8580. * @param data contains the texture data
  8581. * @param texture defines the BabylonJS internal texture
  8582. * @param createPolynomials will be true if polynomials have been requested
  8583. * @param onLoad defines the callback to trigger once the texture is ready
  8584. * @param onError defines the callback to trigger in case of error
  8585. */
  8586. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8587. /**
  8588. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8589. * @param data contains the texture data
  8590. * @param texture defines the BabylonJS internal texture
  8591. * @param callback defines the method to call once ready to upload
  8592. */
  8593. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8594. }
  8595. }
  8596. declare module BABYLON {
  8597. interface Engine {
  8598. /**
  8599. * Creates a depth stencil cube texture.
  8600. * This is only available in WebGL 2.
  8601. * @param size The size of face edge in the cube texture.
  8602. * @param options The options defining the cube texture.
  8603. * @returns The cube texture
  8604. */
  8605. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8606. /**
  8607. * Creates a cube texture
  8608. * @param rootUrl defines the url where the files to load is located
  8609. * @param scene defines the current scene
  8610. * @param files defines the list of files to load (1 per face)
  8611. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8612. * @param onLoad defines an optional callback raised when the texture is loaded
  8613. * @param onError defines an optional callback raised if there is an issue to load the texture
  8614. * @param format defines the format of the data
  8615. * @param forcedExtension defines the extension to use to pick the right loader
  8616. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8617. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8618. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8619. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8620. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8621. * @returns the cube texture as an InternalTexture
  8622. */
  8623. 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;
  8624. /**
  8625. * Creates a cube texture
  8626. * @param rootUrl defines the url where the files to load is located
  8627. * @param scene defines the current scene
  8628. * @param files defines the list of files to load (1 per face)
  8629. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8630. * @param onLoad defines an optional callback raised when the texture is loaded
  8631. * @param onError defines an optional callback raised if there is an issue to load the texture
  8632. * @param format defines the format of the data
  8633. * @param forcedExtension defines the extension to use to pick the right loader
  8634. * @returns the cube texture as an InternalTexture
  8635. */
  8636. 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;
  8637. /**
  8638. * Creates a cube texture
  8639. * @param rootUrl defines the url where the files to load is located
  8640. * @param scene defines the current scene
  8641. * @param files defines the list of files to load (1 per face)
  8642. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8643. * @param onLoad defines an optional callback raised when the texture is loaded
  8644. * @param onError defines an optional callback raised if there is an issue to load the texture
  8645. * @param format defines the format of the data
  8646. * @param forcedExtension defines the extension to use to pick the right loader
  8647. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8648. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8649. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8650. * @returns the cube texture as an InternalTexture
  8651. */
  8652. 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;
  8653. /** @hidden */
  8654. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8655. /** @hidden */
  8656. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8657. /** @hidden */
  8658. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8659. /** @hidden */
  8660. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8661. }
  8662. }
  8663. declare module BABYLON {
  8664. /**
  8665. * Class for creating a cube texture
  8666. */
  8667. export class CubeTexture extends BaseTexture {
  8668. private _delayedOnLoad;
  8669. /**
  8670. * The url of the texture
  8671. */
  8672. url: string;
  8673. /**
  8674. * Gets or sets the center of the bounding box associated with the cube texture.
  8675. * It must define where the camera used to render the texture was set
  8676. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8677. */
  8678. boundingBoxPosition: Vector3;
  8679. private _boundingBoxSize;
  8680. /**
  8681. * Gets or sets the size of the bounding box associated with the cube texture
  8682. * When defined, the cubemap will switch to local mode
  8683. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8684. * @example https://www.babylonjs-playground.com/#RNASML
  8685. */
  8686. /**
  8687. * Returns the bounding box size
  8688. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8689. */
  8690. boundingBoxSize: Vector3;
  8691. protected _rotationY: number;
  8692. /**
  8693. * Sets texture matrix rotation angle around Y axis in radians.
  8694. */
  8695. /**
  8696. * Gets texture matrix rotation angle around Y axis radians.
  8697. */
  8698. rotationY: number;
  8699. /**
  8700. * Are mip maps generated for this texture or not.
  8701. */
  8702. readonly noMipmap: boolean;
  8703. private _noMipmap;
  8704. private _files;
  8705. private _extensions;
  8706. private _textureMatrix;
  8707. private _format;
  8708. private _createPolynomials;
  8709. /** @hidden */
  8710. _prefiltered: boolean;
  8711. /**
  8712. * Creates a cube texture from an array of image urls
  8713. * @param files defines an array of image urls
  8714. * @param scene defines the hosting scene
  8715. * @param noMipmap specifies if mip maps are not used
  8716. * @returns a cube texture
  8717. */
  8718. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8719. /**
  8720. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8721. * @param url defines the url of the prefiltered texture
  8722. * @param scene defines the scene the texture is attached to
  8723. * @param forcedExtension defines the extension of the file if different from the url
  8724. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8725. * @return the prefiltered texture
  8726. */
  8727. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8728. /**
  8729. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8730. * as prefiltered data.
  8731. * @param rootUrl defines the url of the texture or the root name of the six images
  8732. * @param scene defines the scene the texture is attached to
  8733. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8734. * @param noMipmap defines if mipmaps should be created or not
  8735. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8736. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8737. * @param onError defines a callback triggered in case of error during load
  8738. * @param format defines the internal format to use for the texture once loaded
  8739. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8740. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8741. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8742. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8743. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8744. * @return the cube texture
  8745. */
  8746. 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);
  8747. /**
  8748. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8749. */
  8750. readonly isPrefiltered: boolean;
  8751. /**
  8752. * Get the current class name of the texture useful for serialization or dynamic coding.
  8753. * @returns "CubeTexture"
  8754. */
  8755. getClassName(): string;
  8756. /**
  8757. * Update the url (and optional buffer) of this texture if url was null during construction.
  8758. * @param url the url of the texture
  8759. * @param forcedExtension defines the extension to use
  8760. * @param onLoad callback called when the texture is loaded (defaults to null)
  8761. */
  8762. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8763. /**
  8764. * Delays loading of the cube texture
  8765. * @param forcedExtension defines the extension to use
  8766. */
  8767. delayLoad(forcedExtension?: string): void;
  8768. /**
  8769. * Returns the reflection texture matrix
  8770. * @returns the reflection texture matrix
  8771. */
  8772. getReflectionTextureMatrix(): Matrix;
  8773. /**
  8774. * Sets the reflection texture matrix
  8775. * @param value Reflection texture matrix
  8776. */
  8777. setReflectionTextureMatrix(value: Matrix): void;
  8778. /**
  8779. * Parses text to create a cube texture
  8780. * @param parsedTexture define the serialized text to read from
  8781. * @param scene defines the hosting scene
  8782. * @param rootUrl defines the root url of the cube texture
  8783. * @returns a cube texture
  8784. */
  8785. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8786. /**
  8787. * Makes a clone, or deep copy, of the cube texture
  8788. * @returns a new cube texture
  8789. */
  8790. clone(): CubeTexture;
  8791. }
  8792. }
  8793. declare module BABYLON {
  8794. /** @hidden */
  8795. export var postprocessVertexShader: {
  8796. name: string;
  8797. shader: string;
  8798. };
  8799. }
  8800. declare module BABYLON {
  8801. /**
  8802. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8803. * This is the base of the follow, arc rotate cameras and Free camera
  8804. * @see http://doc.babylonjs.com/features/cameras
  8805. */
  8806. export class TargetCamera extends Camera {
  8807. private static _RigCamTransformMatrix;
  8808. private static _TargetTransformMatrix;
  8809. private static _TargetFocalPoint;
  8810. /**
  8811. * Define the current direction the camera is moving to
  8812. */
  8813. cameraDirection: Vector3;
  8814. /**
  8815. * Define the current rotation the camera is rotating to
  8816. */
  8817. cameraRotation: Vector2;
  8818. /**
  8819. * When set, the up vector of the camera will be updated by the rotation of the camera
  8820. */
  8821. updateUpVectorFromRotation: boolean;
  8822. private _tmpQuaternion;
  8823. /**
  8824. * Define the current rotation of the camera
  8825. */
  8826. rotation: Vector3;
  8827. /**
  8828. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8829. */
  8830. rotationQuaternion: Quaternion;
  8831. /**
  8832. * Define the current speed of the camera
  8833. */
  8834. speed: number;
  8835. /**
  8836. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8837. * around all axis.
  8838. */
  8839. noRotationConstraint: boolean;
  8840. /**
  8841. * Define the current target of the camera as an object or a position.
  8842. */
  8843. lockedTarget: any;
  8844. /** @hidden */
  8845. _currentTarget: Vector3;
  8846. /** @hidden */
  8847. _initialFocalDistance: number;
  8848. /** @hidden */
  8849. _viewMatrix: Matrix;
  8850. /** @hidden */
  8851. _camMatrix: Matrix;
  8852. /** @hidden */
  8853. _cameraTransformMatrix: Matrix;
  8854. /** @hidden */
  8855. _cameraRotationMatrix: Matrix;
  8856. /** @hidden */
  8857. _referencePoint: Vector3;
  8858. /** @hidden */
  8859. _transformedReferencePoint: Vector3;
  8860. protected _globalCurrentTarget: Vector3;
  8861. protected _globalCurrentUpVector: Vector3;
  8862. /** @hidden */
  8863. _reset: () => void;
  8864. private _defaultUp;
  8865. /**
  8866. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8867. * This is the base of the follow, arc rotate cameras and Free camera
  8868. * @see http://doc.babylonjs.com/features/cameras
  8869. * @param name Defines the name of the camera in the scene
  8870. * @param position Defines the start position of the camera in the scene
  8871. * @param scene Defines the scene the camera belongs to
  8872. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8873. */
  8874. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8875. /**
  8876. * Gets the position in front of the camera at a given distance.
  8877. * @param distance The distance from the camera we want the position to be
  8878. * @returns the position
  8879. */
  8880. getFrontPosition(distance: number): Vector3;
  8881. /** @hidden */
  8882. _getLockedTargetPosition(): Nullable<Vector3>;
  8883. private _storedPosition;
  8884. private _storedRotation;
  8885. private _storedRotationQuaternion;
  8886. /**
  8887. * Store current camera state of the camera (fov, position, rotation, etc..)
  8888. * @returns the camera
  8889. */
  8890. storeState(): Camera;
  8891. /**
  8892. * Restored camera state. You must call storeState() first
  8893. * @returns whether it was successful or not
  8894. * @hidden
  8895. */
  8896. _restoreStateValues(): boolean;
  8897. /** @hidden */
  8898. _initCache(): void;
  8899. /** @hidden */
  8900. _updateCache(ignoreParentClass?: boolean): void;
  8901. /** @hidden */
  8902. _isSynchronizedViewMatrix(): boolean;
  8903. /** @hidden */
  8904. _computeLocalCameraSpeed(): number;
  8905. /**
  8906. * Defines the target the camera should look at.
  8907. * This will automatically adapt alpha beta and radius to fit within the new target.
  8908. * @param target Defines the new target as a Vector or a mesh
  8909. */
  8910. setTarget(target: Vector3): void;
  8911. /**
  8912. * Return the current target position of the camera. This value is expressed in local space.
  8913. * @returns the target position
  8914. */
  8915. getTarget(): Vector3;
  8916. /** @hidden */
  8917. _decideIfNeedsToMove(): boolean;
  8918. /** @hidden */
  8919. _updatePosition(): void;
  8920. /** @hidden */
  8921. _checkInputs(): void;
  8922. protected _updateCameraRotationMatrix(): void;
  8923. /**
  8924. * 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)
  8925. * @returns the current camera
  8926. */
  8927. private _rotateUpVectorWithCameraRotationMatrix;
  8928. private _cachedRotationZ;
  8929. private _cachedQuaternionRotationZ;
  8930. /** @hidden */
  8931. _getViewMatrix(): Matrix;
  8932. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8933. /**
  8934. * @hidden
  8935. */
  8936. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8937. /**
  8938. * @hidden
  8939. */
  8940. _updateRigCameras(): void;
  8941. private _getRigCamPositionAndTarget;
  8942. /**
  8943. * Gets the current object class name.
  8944. * @return the class name
  8945. */
  8946. getClassName(): string;
  8947. }
  8948. }
  8949. declare module BABYLON {
  8950. /**
  8951. * @ignore
  8952. * This is a list of all the different input types that are available in the application.
  8953. * Fo instance: ArcRotateCameraGamepadInput...
  8954. */
  8955. export var CameraInputTypes: {};
  8956. /**
  8957. * This is the contract to implement in order to create a new input class.
  8958. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8959. */
  8960. export interface ICameraInput<TCamera extends Camera> {
  8961. /**
  8962. * Defines the camera the input is attached to.
  8963. */
  8964. camera: Nullable<TCamera>;
  8965. /**
  8966. * Gets the class name of the current intput.
  8967. * @returns the class name
  8968. */
  8969. getClassName(): string;
  8970. /**
  8971. * Get the friendly name associated with the input class.
  8972. * @returns the input friendly name
  8973. */
  8974. getSimpleName(): string;
  8975. /**
  8976. * Attach the input controls to a specific dom element to get the input from.
  8977. * @param element Defines the element the controls should be listened from
  8978. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8979. */
  8980. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8981. /**
  8982. * Detach the current controls from the specified dom element.
  8983. * @param element Defines the element to stop listening the inputs from
  8984. */
  8985. detachControl(element: Nullable<HTMLElement>): void;
  8986. /**
  8987. * Update the current camera state depending on the inputs that have been used this frame.
  8988. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8989. */
  8990. checkInputs?: () => void;
  8991. }
  8992. /**
  8993. * Represents a map of input types to input instance or input index to input instance.
  8994. */
  8995. export interface CameraInputsMap<TCamera extends Camera> {
  8996. /**
  8997. * Accessor to the input by input type.
  8998. */
  8999. [name: string]: ICameraInput<TCamera>;
  9000. /**
  9001. * Accessor to the input by input index.
  9002. */
  9003. [idx: number]: ICameraInput<TCamera>;
  9004. }
  9005. /**
  9006. * This represents the input manager used within a camera.
  9007. * It helps dealing with all the different kind of input attached to a camera.
  9008. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9009. */
  9010. export class CameraInputsManager<TCamera extends Camera> {
  9011. /**
  9012. * Defines the list of inputs attahed to the camera.
  9013. */
  9014. attached: CameraInputsMap<TCamera>;
  9015. /**
  9016. * Defines the dom element the camera is collecting inputs from.
  9017. * This is null if the controls have not been attached.
  9018. */
  9019. attachedElement: Nullable<HTMLElement>;
  9020. /**
  9021. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9022. */
  9023. noPreventDefault: boolean;
  9024. /**
  9025. * Defined the camera the input manager belongs to.
  9026. */
  9027. camera: TCamera;
  9028. /**
  9029. * Update the current camera state depending on the inputs that have been used this frame.
  9030. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9031. */
  9032. checkInputs: () => void;
  9033. /**
  9034. * Instantiate a new Camera Input Manager.
  9035. * @param camera Defines the camera the input manager blongs to
  9036. */
  9037. constructor(camera: TCamera);
  9038. /**
  9039. * Add an input method to a camera
  9040. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9041. * @param input camera input method
  9042. */
  9043. add(input: ICameraInput<TCamera>): void;
  9044. /**
  9045. * Remove a specific input method from a camera
  9046. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9047. * @param inputToRemove camera input method
  9048. */
  9049. remove(inputToRemove: ICameraInput<TCamera>): void;
  9050. /**
  9051. * Remove a specific input type from a camera
  9052. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9053. * @param inputType the type of the input to remove
  9054. */
  9055. removeByType(inputType: string): void;
  9056. private _addCheckInputs;
  9057. /**
  9058. * Attach the input controls to the currently attached dom element to listen the events from.
  9059. * @param input Defines the input to attach
  9060. */
  9061. attachInput(input: ICameraInput<TCamera>): void;
  9062. /**
  9063. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9064. * @param element Defines the dom element to collect the events from
  9065. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9066. */
  9067. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  9068. /**
  9069. * Detach the current manager inputs controls from a specific dom element.
  9070. * @param element Defines the dom element to collect the events from
  9071. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9072. */
  9073. detachElement(element: HTMLElement, disconnect?: boolean): void;
  9074. /**
  9075. * Rebuild the dynamic inputCheck function from the current list of
  9076. * defined inputs in the manager.
  9077. */
  9078. rebuildInputCheck(): void;
  9079. /**
  9080. * Remove all attached input methods from a camera
  9081. */
  9082. clear(): void;
  9083. /**
  9084. * Serialize the current input manager attached to a camera.
  9085. * This ensures than once parsed,
  9086. * the input associated to the camera will be identical to the current ones
  9087. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9088. */
  9089. serialize(serializedCamera: any): void;
  9090. /**
  9091. * Parses an input manager serialized JSON to restore the previous list of inputs
  9092. * and states associated to a camera.
  9093. * @param parsedCamera Defines the JSON to parse
  9094. */
  9095. parse(parsedCamera: any): void;
  9096. }
  9097. }
  9098. declare module BABYLON {
  9099. /**
  9100. * Gather the list of keyboard event types as constants.
  9101. */
  9102. export class KeyboardEventTypes {
  9103. /**
  9104. * The keydown event is fired when a key becomes active (pressed).
  9105. */
  9106. static readonly KEYDOWN: number;
  9107. /**
  9108. * The keyup event is fired when a key has been released.
  9109. */
  9110. static readonly KEYUP: number;
  9111. }
  9112. /**
  9113. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9114. */
  9115. export class KeyboardInfo {
  9116. /**
  9117. * Defines the type of event (KeyboardEventTypes)
  9118. */
  9119. type: number;
  9120. /**
  9121. * Defines the related dom event
  9122. */
  9123. event: KeyboardEvent;
  9124. /**
  9125. * Instantiates a new keyboard info.
  9126. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9127. * @param type Defines the type of event (KeyboardEventTypes)
  9128. * @param event Defines the related dom event
  9129. */
  9130. constructor(
  9131. /**
  9132. * Defines the type of event (KeyboardEventTypes)
  9133. */
  9134. type: number,
  9135. /**
  9136. * Defines the related dom event
  9137. */
  9138. event: KeyboardEvent);
  9139. }
  9140. /**
  9141. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9142. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9143. */
  9144. export class KeyboardInfoPre extends KeyboardInfo {
  9145. /**
  9146. * Defines the type of event (KeyboardEventTypes)
  9147. */
  9148. type: number;
  9149. /**
  9150. * Defines the related dom event
  9151. */
  9152. event: KeyboardEvent;
  9153. /**
  9154. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9155. */
  9156. skipOnPointerObservable: boolean;
  9157. /**
  9158. * Instantiates a new keyboard pre info.
  9159. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9160. * @param type Defines the type of event (KeyboardEventTypes)
  9161. * @param event Defines the related dom event
  9162. */
  9163. constructor(
  9164. /**
  9165. * Defines the type of event (KeyboardEventTypes)
  9166. */
  9167. type: number,
  9168. /**
  9169. * Defines the related dom event
  9170. */
  9171. event: KeyboardEvent);
  9172. }
  9173. }
  9174. declare module BABYLON {
  9175. /**
  9176. * Manage the keyboard inputs to control the movement of a free camera.
  9177. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9178. */
  9179. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9180. /**
  9181. * Defines the camera the input is attached to.
  9182. */
  9183. camera: FreeCamera;
  9184. /**
  9185. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9186. */
  9187. keysUp: number[];
  9188. /**
  9189. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9190. */
  9191. keysDown: number[];
  9192. /**
  9193. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9194. */
  9195. keysLeft: number[];
  9196. /**
  9197. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9198. */
  9199. keysRight: number[];
  9200. private _keys;
  9201. private _onCanvasBlurObserver;
  9202. private _onKeyboardObserver;
  9203. private _engine;
  9204. private _scene;
  9205. /**
  9206. * Attach the input controls to a specific dom element to get the input from.
  9207. * @param element Defines the element the controls should be listened from
  9208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9209. */
  9210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9211. /**
  9212. * Detach the current controls from the specified dom element.
  9213. * @param element Defines the element to stop listening the inputs from
  9214. */
  9215. detachControl(element: Nullable<HTMLElement>): void;
  9216. /**
  9217. * Update the current camera state depending on the inputs that have been used this frame.
  9218. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9219. */
  9220. checkInputs(): void;
  9221. /**
  9222. * Gets the class name of the current intput.
  9223. * @returns the class name
  9224. */
  9225. getClassName(): string;
  9226. /** @hidden */
  9227. _onLostFocus(): void;
  9228. /**
  9229. * Get the friendly name associated with the input class.
  9230. * @returns the input friendly name
  9231. */
  9232. getSimpleName(): string;
  9233. }
  9234. }
  9235. declare module BABYLON {
  9236. /**
  9237. * Interface describing all the common properties and methods a shadow light needs to implement.
  9238. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9239. * as well as binding the different shadow properties to the effects.
  9240. */
  9241. export interface IShadowLight extends Light {
  9242. /**
  9243. * The light id in the scene (used in scene.findLighById for instance)
  9244. */
  9245. id: string;
  9246. /**
  9247. * The position the shdow will be casted from.
  9248. */
  9249. position: Vector3;
  9250. /**
  9251. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9252. */
  9253. direction: Vector3;
  9254. /**
  9255. * The transformed position. Position of the light in world space taking parenting in account.
  9256. */
  9257. transformedPosition: Vector3;
  9258. /**
  9259. * The transformed direction. Direction of the light in world space taking parenting in account.
  9260. */
  9261. transformedDirection: Vector3;
  9262. /**
  9263. * The friendly name of the light in the scene.
  9264. */
  9265. name: string;
  9266. /**
  9267. * Defines the shadow projection clipping minimum z value.
  9268. */
  9269. shadowMinZ: number;
  9270. /**
  9271. * Defines the shadow projection clipping maximum z value.
  9272. */
  9273. shadowMaxZ: number;
  9274. /**
  9275. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9276. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9277. */
  9278. computeTransformedInformation(): boolean;
  9279. /**
  9280. * Gets the scene the light belongs to.
  9281. * @returns The scene
  9282. */
  9283. getScene(): Scene;
  9284. /**
  9285. * Callback defining a custom Projection Matrix Builder.
  9286. * This can be used to override the default projection matrix computation.
  9287. */
  9288. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9289. /**
  9290. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9291. * @param matrix The materix to updated with the projection information
  9292. * @param viewMatrix The transform matrix of the light
  9293. * @param renderList The list of mesh to render in the map
  9294. * @returns The current light
  9295. */
  9296. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9297. /**
  9298. * Gets the current depth scale used in ESM.
  9299. * @returns The scale
  9300. */
  9301. getDepthScale(): number;
  9302. /**
  9303. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9304. * @returns true if a cube texture needs to be use
  9305. */
  9306. needCube(): boolean;
  9307. /**
  9308. * Detects if the projection matrix requires to be recomputed this frame.
  9309. * @returns true if it requires to be recomputed otherwise, false.
  9310. */
  9311. needProjectionMatrixCompute(): boolean;
  9312. /**
  9313. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9314. */
  9315. forceProjectionMatrixCompute(): void;
  9316. /**
  9317. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9318. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9319. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9320. */
  9321. getShadowDirection(faceIndex?: number): Vector3;
  9322. /**
  9323. * Gets the minZ used for shadow according to both the scene and the light.
  9324. * @param activeCamera The camera we are returning the min for
  9325. * @returns the depth min z
  9326. */
  9327. getDepthMinZ(activeCamera: Camera): number;
  9328. /**
  9329. * Gets the maxZ used for shadow according to both the scene and the light.
  9330. * @param activeCamera The camera we are returning the max for
  9331. * @returns the depth max z
  9332. */
  9333. getDepthMaxZ(activeCamera: Camera): number;
  9334. }
  9335. /**
  9336. * Base implementation IShadowLight
  9337. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9338. */
  9339. export abstract class ShadowLight extends Light implements IShadowLight {
  9340. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9341. protected _position: Vector3;
  9342. protected _setPosition(value: Vector3): void;
  9343. /**
  9344. * Sets the position the shadow will be casted from. Also use as the light position for both
  9345. * point and spot lights.
  9346. */
  9347. /**
  9348. * Sets the position the shadow will be casted from. Also use as the light position for both
  9349. * point and spot lights.
  9350. */
  9351. position: Vector3;
  9352. protected _direction: Vector3;
  9353. protected _setDirection(value: Vector3): void;
  9354. /**
  9355. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9356. * Also use as the light direction on spot and directional lights.
  9357. */
  9358. /**
  9359. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9360. * Also use as the light direction on spot and directional lights.
  9361. */
  9362. direction: Vector3;
  9363. private _shadowMinZ;
  9364. /**
  9365. * Gets the shadow projection clipping minimum z value.
  9366. */
  9367. /**
  9368. * Sets the shadow projection clipping minimum z value.
  9369. */
  9370. shadowMinZ: number;
  9371. private _shadowMaxZ;
  9372. /**
  9373. * Sets the shadow projection clipping maximum z value.
  9374. */
  9375. /**
  9376. * Gets the shadow projection clipping maximum z value.
  9377. */
  9378. shadowMaxZ: number;
  9379. /**
  9380. * Callback defining a custom Projection Matrix Builder.
  9381. * This can be used to override the default projection matrix computation.
  9382. */
  9383. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9384. /**
  9385. * The transformed position. Position of the light in world space taking parenting in account.
  9386. */
  9387. transformedPosition: Vector3;
  9388. /**
  9389. * The transformed direction. Direction of the light in world space taking parenting in account.
  9390. */
  9391. transformedDirection: Vector3;
  9392. private _needProjectionMatrixCompute;
  9393. /**
  9394. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9395. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9396. */
  9397. computeTransformedInformation(): boolean;
  9398. /**
  9399. * Return the depth scale used for the shadow map.
  9400. * @returns the depth scale.
  9401. */
  9402. getDepthScale(): number;
  9403. /**
  9404. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9405. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9406. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9407. */
  9408. getShadowDirection(faceIndex?: number): Vector3;
  9409. /**
  9410. * Returns the ShadowLight absolute position in the World.
  9411. * @returns the position vector in world space
  9412. */
  9413. getAbsolutePosition(): Vector3;
  9414. /**
  9415. * Sets the ShadowLight direction toward the passed target.
  9416. * @param target The point to target in local space
  9417. * @returns the updated ShadowLight direction
  9418. */
  9419. setDirectionToTarget(target: Vector3): Vector3;
  9420. /**
  9421. * Returns the light rotation in euler definition.
  9422. * @returns the x y z rotation in local space.
  9423. */
  9424. getRotation(): Vector3;
  9425. /**
  9426. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9427. * @returns true if a cube texture needs to be use
  9428. */
  9429. needCube(): boolean;
  9430. /**
  9431. * Detects if the projection matrix requires to be recomputed this frame.
  9432. * @returns true if it requires to be recomputed otherwise, false.
  9433. */
  9434. needProjectionMatrixCompute(): boolean;
  9435. /**
  9436. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9437. */
  9438. forceProjectionMatrixCompute(): void;
  9439. /** @hidden */
  9440. _initCache(): void;
  9441. /** @hidden */
  9442. _isSynchronized(): boolean;
  9443. /**
  9444. * Computes the world matrix of the node
  9445. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9446. * @returns the world matrix
  9447. */
  9448. computeWorldMatrix(force?: boolean): Matrix;
  9449. /**
  9450. * Gets the minZ used for shadow according to both the scene and the light.
  9451. * @param activeCamera The camera we are returning the min for
  9452. * @returns the depth min z
  9453. */
  9454. getDepthMinZ(activeCamera: Camera): number;
  9455. /**
  9456. * Gets the maxZ used for shadow according to both the scene and the light.
  9457. * @param activeCamera The camera we are returning the max for
  9458. * @returns the depth max z
  9459. */
  9460. getDepthMaxZ(activeCamera: Camera): number;
  9461. /**
  9462. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9463. * @param matrix The materix to updated with the projection information
  9464. * @param viewMatrix The transform matrix of the light
  9465. * @param renderList The list of mesh to render in the map
  9466. * @returns The current light
  9467. */
  9468. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9469. }
  9470. }
  9471. declare module BABYLON {
  9472. /**
  9473. * "Static Class" containing the most commonly used helper while dealing with material for
  9474. * rendering purpose.
  9475. *
  9476. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9477. *
  9478. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9479. */
  9480. export class MaterialHelper {
  9481. /**
  9482. * Bind the current view position to an effect.
  9483. * @param effect The effect to be bound
  9484. * @param scene The scene the eyes position is used from
  9485. */
  9486. static BindEyePosition(effect: Effect, scene: Scene): void;
  9487. /**
  9488. * Helps preparing the defines values about the UVs in used in the effect.
  9489. * UVs are shared as much as we can accross channels in the shaders.
  9490. * @param texture The texture we are preparing the UVs for
  9491. * @param defines The defines to update
  9492. * @param key The channel key "diffuse", "specular"... used in the shader
  9493. */
  9494. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9495. /**
  9496. * Binds a texture matrix value to its corrsponding uniform
  9497. * @param texture The texture to bind the matrix for
  9498. * @param uniformBuffer The uniform buffer receivin the data
  9499. * @param key The channel key "diffuse", "specular"... used in the shader
  9500. */
  9501. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9502. /**
  9503. * Gets the current status of the fog (should it be enabled?)
  9504. * @param mesh defines the mesh to evaluate for fog support
  9505. * @param scene defines the hosting scene
  9506. * @returns true if fog must be enabled
  9507. */
  9508. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9509. /**
  9510. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9511. * @param mesh defines the current mesh
  9512. * @param scene defines the current scene
  9513. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9514. * @param pointsCloud defines if point cloud rendering has to be turned on
  9515. * @param fogEnabled defines if fog has to be turned on
  9516. * @param alphaTest defines if alpha testing has to be turned on
  9517. * @param defines defines the current list of defines
  9518. */
  9519. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9520. /**
  9521. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9522. * @param scene defines the current scene
  9523. * @param engine defines the current engine
  9524. * @param defines specifies the list of active defines
  9525. * @param useInstances defines if instances have to be turned on
  9526. * @param useClipPlane defines if clip plane have to be turned on
  9527. */
  9528. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9529. /**
  9530. * Prepares the defines for bones
  9531. * @param mesh The mesh containing the geometry data we will draw
  9532. * @param defines The defines to update
  9533. */
  9534. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9535. /**
  9536. * Prepares the defines for morph targets
  9537. * @param mesh The mesh containing the geometry data we will draw
  9538. * @param defines The defines to update
  9539. */
  9540. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9541. /**
  9542. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9543. * @param mesh The mesh containing the geometry data we will draw
  9544. * @param defines The defines to update
  9545. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9546. * @param useBones Precise whether bones should be used or not (override mesh info)
  9547. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9548. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9549. * @returns false if defines are considered not dirty and have not been checked
  9550. */
  9551. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9552. /**
  9553. * Prepares the defines related to multiview
  9554. * @param scene The scene we are intending to draw
  9555. * @param defines The defines to update
  9556. */
  9557. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9558. /**
  9559. * Prepares the defines related to the light information passed in parameter
  9560. * @param scene The scene we are intending to draw
  9561. * @param mesh The mesh the effect is compiling for
  9562. * @param defines The defines to update
  9563. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9564. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9565. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9566. * @returns true if normals will be required for the rest of the effect
  9567. */
  9568. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9569. /**
  9570. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9571. * that won t be acctive due to defines being turned off.
  9572. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9573. * @param samplersList The samplers list
  9574. * @param defines The defines helping in the list generation
  9575. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9576. */
  9577. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9578. /**
  9579. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9580. * @param defines The defines to update while falling back
  9581. * @param fallbacks The authorized effect fallbacks
  9582. * @param maxSimultaneousLights The maximum number of lights allowed
  9583. * @param rank the current rank of the Effect
  9584. * @returns The newly affected rank
  9585. */
  9586. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9587. /**
  9588. * Prepares the list of attributes required for morph targets according to the effect defines.
  9589. * @param attribs The current list of supported attribs
  9590. * @param mesh The mesh to prepare the morph targets attributes for
  9591. * @param defines The current Defines of the effect
  9592. */
  9593. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9594. /**
  9595. * Prepares the list of attributes required for bones according to the effect defines.
  9596. * @param attribs The current list of supported attribs
  9597. * @param mesh The mesh to prepare the bones attributes for
  9598. * @param defines The current Defines of the effect
  9599. * @param fallbacks The current efffect fallback strategy
  9600. */
  9601. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9602. /**
  9603. * Check and prepare the list of attributes required for instances according to the effect defines.
  9604. * @param attribs The current list of supported attribs
  9605. * @param defines The current MaterialDefines of the effect
  9606. */
  9607. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9608. /**
  9609. * Add the list of attributes required for instances to the attribs array.
  9610. * @param attribs The current list of supported attribs
  9611. */
  9612. static PushAttributesForInstances(attribs: string[]): void;
  9613. /**
  9614. * Binds the light shadow information to the effect for the given mesh.
  9615. * @param light The light containing the generator
  9616. * @param scene The scene the lights belongs to
  9617. * @param mesh The mesh we are binding the information to render
  9618. * @param lightIndex The light index in the effect used to render the mesh
  9619. * @param effect The effect we are binding the data to
  9620. */
  9621. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9622. /**
  9623. * Binds the light information to the effect.
  9624. * @param light The light containing the generator
  9625. * @param effect The effect we are binding the data to
  9626. * @param lightIndex The light index in the effect used to render
  9627. */
  9628. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9629. /**
  9630. * Binds the lights information from the scene to the effect for the given mesh.
  9631. * @param scene The scene the lights belongs to
  9632. * @param mesh The mesh we are binding the information to render
  9633. * @param effect The effect we are binding the data to
  9634. * @param defines The generated defines for the effect
  9635. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9636. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9637. */
  9638. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9639. private static _tempFogColor;
  9640. /**
  9641. * Binds the fog information from the scene to the effect for the given mesh.
  9642. * @param scene The scene the lights belongs to
  9643. * @param mesh The mesh we are binding the information to render
  9644. * @param effect The effect we are binding the data to
  9645. * @param linearSpace Defines if the fog effect is applied in linear space
  9646. */
  9647. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9648. /**
  9649. * Binds the bones information from the mesh to the effect.
  9650. * @param mesh The mesh we are binding the information to render
  9651. * @param effect The effect we are binding the data to
  9652. */
  9653. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9654. /**
  9655. * Binds the morph targets information from the mesh to the effect.
  9656. * @param abstractMesh The mesh we are binding the information to render
  9657. * @param effect The effect we are binding the data to
  9658. */
  9659. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9660. /**
  9661. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9662. * @param defines The generated defines used in the effect
  9663. * @param effect The effect we are binding the data to
  9664. * @param scene The scene we are willing to render with logarithmic scale for
  9665. */
  9666. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9667. /**
  9668. * Binds the clip plane information from the scene to the effect.
  9669. * @param scene The scene the clip plane information are extracted from
  9670. * @param effect The effect we are binding the data to
  9671. */
  9672. static BindClipPlane(effect: Effect, scene: Scene): void;
  9673. }
  9674. }
  9675. declare module BABYLON {
  9676. /** @hidden */
  9677. export var kernelBlurVaryingDeclaration: {
  9678. name: string;
  9679. shader: string;
  9680. };
  9681. }
  9682. declare module BABYLON {
  9683. /** @hidden */
  9684. export var kernelBlurFragment: {
  9685. name: string;
  9686. shader: string;
  9687. };
  9688. }
  9689. declare module BABYLON {
  9690. /** @hidden */
  9691. export var kernelBlurFragment2: {
  9692. name: string;
  9693. shader: string;
  9694. };
  9695. }
  9696. declare module BABYLON {
  9697. /** @hidden */
  9698. export var kernelBlurPixelShader: {
  9699. name: string;
  9700. shader: string;
  9701. };
  9702. }
  9703. declare module BABYLON {
  9704. /** @hidden */
  9705. export var kernelBlurVertex: {
  9706. name: string;
  9707. shader: string;
  9708. };
  9709. }
  9710. declare module BABYLON {
  9711. /** @hidden */
  9712. export var kernelBlurVertexShader: {
  9713. name: string;
  9714. shader: string;
  9715. };
  9716. }
  9717. declare module BABYLON {
  9718. /**
  9719. * The Blur Post Process which blurs an image based on a kernel and direction.
  9720. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9721. */
  9722. export class BlurPostProcess extends PostProcess {
  9723. /** The direction in which to blur the image. */
  9724. direction: Vector2;
  9725. private blockCompilation;
  9726. protected _kernel: number;
  9727. protected _idealKernel: number;
  9728. protected _packedFloat: boolean;
  9729. private _staticDefines;
  9730. /**
  9731. * Sets the length in pixels of the blur sample region
  9732. */
  9733. /**
  9734. * Gets the length in pixels of the blur sample region
  9735. */
  9736. kernel: number;
  9737. /**
  9738. * Sets wether or not the blur needs to unpack/repack floats
  9739. */
  9740. /**
  9741. * Gets wether or not the blur is unpacking/repacking floats
  9742. */
  9743. packedFloat: boolean;
  9744. /**
  9745. * Creates a new instance BlurPostProcess
  9746. * @param name The name of the effect.
  9747. * @param direction The direction in which to blur the image.
  9748. * @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.
  9749. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9750. * @param camera The camera to apply the render pass to.
  9751. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9752. * @param engine The engine which the post process will be applied. (default: current engine)
  9753. * @param reusable If the post process can be reused on the same frame. (default: false)
  9754. * @param textureType Type of textures used when performing the post process. (default: 0)
  9755. * @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)
  9756. */
  9757. constructor(name: string,
  9758. /** The direction in which to blur the image. */
  9759. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9760. /**
  9761. * Updates the effect with the current post process compile time values and recompiles the shader.
  9762. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9763. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9764. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9765. * @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
  9766. * @param onCompiled Called when the shader has been compiled.
  9767. * @param onError Called if there is an error when compiling a shader.
  9768. */
  9769. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9770. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9771. /**
  9772. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9773. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9774. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9775. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9776. * The gaps between physical kernels are compensated for in the weighting of the samples
  9777. * @param idealKernel Ideal blur kernel.
  9778. * @return Nearest best kernel.
  9779. */
  9780. protected _nearestBestKernel(idealKernel: number): number;
  9781. /**
  9782. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9783. * @param x The point on the Gaussian distribution to sample.
  9784. * @return the value of the Gaussian function at x.
  9785. */
  9786. protected _gaussianWeight(x: number): number;
  9787. /**
  9788. * Generates a string that can be used as a floating point number in GLSL.
  9789. * @param x Value to print.
  9790. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9791. * @return GLSL float string.
  9792. */
  9793. protected _glslFloat(x: number, decimalFigures?: number): string;
  9794. }
  9795. }
  9796. declare module BABYLON {
  9797. /** @hidden */
  9798. export var shadowMapPixelShader: {
  9799. name: string;
  9800. shader: string;
  9801. };
  9802. }
  9803. declare module BABYLON {
  9804. /** @hidden */
  9805. export var bonesDeclaration: {
  9806. name: string;
  9807. shader: string;
  9808. };
  9809. }
  9810. declare module BABYLON {
  9811. /** @hidden */
  9812. export var morphTargetsVertexGlobalDeclaration: {
  9813. name: string;
  9814. shader: string;
  9815. };
  9816. }
  9817. declare module BABYLON {
  9818. /** @hidden */
  9819. export var morphTargetsVertexDeclaration: {
  9820. name: string;
  9821. shader: string;
  9822. };
  9823. }
  9824. declare module BABYLON {
  9825. /** @hidden */
  9826. export var instancesDeclaration: {
  9827. name: string;
  9828. shader: string;
  9829. };
  9830. }
  9831. declare module BABYLON {
  9832. /** @hidden */
  9833. export var helperFunctions: {
  9834. name: string;
  9835. shader: string;
  9836. };
  9837. }
  9838. declare module BABYLON {
  9839. /** @hidden */
  9840. export var morphTargetsVertex: {
  9841. name: string;
  9842. shader: string;
  9843. };
  9844. }
  9845. declare module BABYLON {
  9846. /** @hidden */
  9847. export var instancesVertex: {
  9848. name: string;
  9849. shader: string;
  9850. };
  9851. }
  9852. declare module BABYLON {
  9853. /** @hidden */
  9854. export var bonesVertex: {
  9855. name: string;
  9856. shader: string;
  9857. };
  9858. }
  9859. declare module BABYLON {
  9860. /** @hidden */
  9861. export var shadowMapVertexShader: {
  9862. name: string;
  9863. shader: string;
  9864. };
  9865. }
  9866. declare module BABYLON {
  9867. /** @hidden */
  9868. export var depthBoxBlurPixelShader: {
  9869. name: string;
  9870. shader: string;
  9871. };
  9872. }
  9873. declare module BABYLON {
  9874. /**
  9875. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9876. */
  9877. export interface ICustomShaderOptions {
  9878. /**
  9879. * Gets or sets the custom shader name to use
  9880. */
  9881. shaderName: string;
  9882. /**
  9883. * The list of attribute names used in the shader
  9884. */
  9885. attributes?: string[];
  9886. /**
  9887. * The list of unifrom names used in the shader
  9888. */
  9889. uniforms?: string[];
  9890. /**
  9891. * The list of sampler names used in the shader
  9892. */
  9893. samplers?: string[];
  9894. /**
  9895. * The list of defines used in the shader
  9896. */
  9897. defines?: string[];
  9898. }
  9899. /**
  9900. * Interface to implement to create a shadow generator compatible with BJS.
  9901. */
  9902. export interface IShadowGenerator {
  9903. /**
  9904. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9905. * @returns The render target texture if present otherwise, null
  9906. */
  9907. getShadowMap(): Nullable<RenderTargetTexture>;
  9908. /**
  9909. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9910. * @returns The render target texture if the shadow map is present otherwise, null
  9911. */
  9912. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9913. /**
  9914. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9915. * @param subMesh The submesh we want to render in the shadow map
  9916. * @param useInstances Defines wether will draw in the map using instances
  9917. * @returns true if ready otherwise, false
  9918. */
  9919. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9920. /**
  9921. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9922. * @param defines Defines of the material we want to update
  9923. * @param lightIndex Index of the light in the enabled light list of the material
  9924. */
  9925. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9926. /**
  9927. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9928. * defined in the generator but impacting the effect).
  9929. * It implies the unifroms available on the materials are the standard BJS ones.
  9930. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9931. * @param effect The effect we are binfing the information for
  9932. */
  9933. bindShadowLight(lightIndex: string, effect: Effect): void;
  9934. /**
  9935. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9936. * (eq to shadow prjection matrix * light transform matrix)
  9937. * @returns The transform matrix used to create the shadow map
  9938. */
  9939. getTransformMatrix(): Matrix;
  9940. /**
  9941. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9942. * Cube and 2D textures for instance.
  9943. */
  9944. recreateShadowMap(): void;
  9945. /**
  9946. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9947. * @param onCompiled Callback triggered at the and of the effects compilation
  9948. * @param options Sets of optional options forcing the compilation with different modes
  9949. */
  9950. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9951. useInstances: boolean;
  9952. }>): void;
  9953. /**
  9954. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9955. * @param options Sets of optional options forcing the compilation with different modes
  9956. * @returns A promise that resolves when the compilation completes
  9957. */
  9958. forceCompilationAsync(options?: Partial<{
  9959. useInstances: boolean;
  9960. }>): Promise<void>;
  9961. /**
  9962. * Serializes the shadow generator setup to a json object.
  9963. * @returns The serialized JSON object
  9964. */
  9965. serialize(): any;
  9966. /**
  9967. * Disposes the Shadow map and related Textures and effects.
  9968. */
  9969. dispose(): void;
  9970. }
  9971. /**
  9972. * Default implementation IShadowGenerator.
  9973. * This is the main object responsible of generating shadows in the framework.
  9974. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9975. */
  9976. export class ShadowGenerator implements IShadowGenerator {
  9977. /**
  9978. * Shadow generator mode None: no filtering applied.
  9979. */
  9980. static readonly FILTER_NONE: number;
  9981. /**
  9982. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9983. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9984. */
  9985. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9986. /**
  9987. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9988. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9989. */
  9990. static readonly FILTER_POISSONSAMPLING: number;
  9991. /**
  9992. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9993. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9994. */
  9995. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9996. /**
  9997. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9998. * edge artifacts on steep falloff.
  9999. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10000. */
  10001. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  10002. /**
  10003. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  10004. * edge artifacts on steep falloff.
  10005. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10006. */
  10007. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  10008. /**
  10009. * Shadow generator mode PCF: Percentage Closer Filtering
  10010. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10011. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  10012. */
  10013. static readonly FILTER_PCF: number;
  10014. /**
  10015. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  10016. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10017. * Contact Hardening
  10018. */
  10019. static readonly FILTER_PCSS: number;
  10020. /**
  10021. * Reserved for PCF and PCSS
  10022. * Highest Quality.
  10023. *
  10024. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  10025. *
  10026. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  10027. */
  10028. static readonly QUALITY_HIGH: number;
  10029. /**
  10030. * Reserved for PCF and PCSS
  10031. * Good tradeoff for quality/perf cross devices
  10032. *
  10033. * Execute PCF on a 3*3 kernel.
  10034. *
  10035. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  10036. */
  10037. static readonly QUALITY_MEDIUM: number;
  10038. /**
  10039. * Reserved for PCF and PCSS
  10040. * The lowest quality but the fastest.
  10041. *
  10042. * Execute PCF on a 1*1 kernel.
  10043. *
  10044. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  10045. */
  10046. static readonly QUALITY_LOW: number;
  10047. /** Gets or sets the custom shader name to use */
  10048. customShaderOptions: ICustomShaderOptions;
  10049. /**
  10050. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  10051. */
  10052. onBeforeShadowMapRenderObservable: Observable<Effect>;
  10053. /**
  10054. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  10055. */
  10056. onAfterShadowMapRenderObservable: Observable<Effect>;
  10057. /**
  10058. * Observable triggered before a mesh is rendered in the shadow map.
  10059. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  10060. */
  10061. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  10062. /**
  10063. * Observable triggered after a mesh is rendered in the shadow map.
  10064. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  10065. */
  10066. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  10067. private _bias;
  10068. /**
  10069. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10070. */
  10071. /**
  10072. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10073. */
  10074. bias: number;
  10075. private _normalBias;
  10076. /**
  10077. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10078. */
  10079. /**
  10080. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10081. */
  10082. normalBias: number;
  10083. private _blurBoxOffset;
  10084. /**
  10085. * Gets the blur box offset: offset applied during the blur pass.
  10086. * Only useful if useKernelBlur = false
  10087. */
  10088. /**
  10089. * Sets the blur box offset: offset applied during the blur pass.
  10090. * Only useful if useKernelBlur = false
  10091. */
  10092. blurBoxOffset: number;
  10093. private _blurScale;
  10094. /**
  10095. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10096. * 2 means half of the size.
  10097. */
  10098. /**
  10099. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10100. * 2 means half of the size.
  10101. */
  10102. blurScale: number;
  10103. private _blurKernel;
  10104. /**
  10105. * Gets the blur kernel: kernel size of the blur pass.
  10106. * Only useful if useKernelBlur = true
  10107. */
  10108. /**
  10109. * Sets the blur kernel: kernel size of the blur pass.
  10110. * Only useful if useKernelBlur = true
  10111. */
  10112. blurKernel: number;
  10113. private _useKernelBlur;
  10114. /**
  10115. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10116. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10117. */
  10118. /**
  10119. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10120. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10121. */
  10122. useKernelBlur: boolean;
  10123. private _depthScale;
  10124. /**
  10125. * Gets the depth scale used in ESM mode.
  10126. */
  10127. /**
  10128. * Sets the depth scale used in ESM mode.
  10129. * This can override the scale stored on the light.
  10130. */
  10131. depthScale: number;
  10132. private _filter;
  10133. /**
  10134. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10135. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10136. */
  10137. /**
  10138. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10139. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10140. */
  10141. filter: number;
  10142. /**
  10143. * Gets if the current filter is set to Poisson Sampling.
  10144. */
  10145. /**
  10146. * Sets the current filter to Poisson Sampling.
  10147. */
  10148. usePoissonSampling: boolean;
  10149. /**
  10150. * Gets if the current filter is set to ESM.
  10151. */
  10152. /**
  10153. * Sets the current filter is to ESM.
  10154. */
  10155. useExponentialShadowMap: boolean;
  10156. /**
  10157. * Gets if the current filter is set to filtered ESM.
  10158. */
  10159. /**
  10160. * Gets if the current filter is set to filtered ESM.
  10161. */
  10162. useBlurExponentialShadowMap: boolean;
  10163. /**
  10164. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10165. * exponential to prevent steep falloff artifacts).
  10166. */
  10167. /**
  10168. * Sets the current filter to "close ESM" (using the inverse of the
  10169. * exponential to prevent steep falloff artifacts).
  10170. */
  10171. useCloseExponentialShadowMap: boolean;
  10172. /**
  10173. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10174. * exponential to prevent steep falloff artifacts).
  10175. */
  10176. /**
  10177. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10178. * exponential to prevent steep falloff artifacts).
  10179. */
  10180. useBlurCloseExponentialShadowMap: boolean;
  10181. /**
  10182. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10183. */
  10184. /**
  10185. * Sets the current filter to "PCF" (percentage closer filtering).
  10186. */
  10187. usePercentageCloserFiltering: boolean;
  10188. private _filteringQuality;
  10189. /**
  10190. * Gets the PCF or PCSS Quality.
  10191. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10192. */
  10193. /**
  10194. * Sets the PCF or PCSS Quality.
  10195. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10196. */
  10197. filteringQuality: number;
  10198. /**
  10199. * Gets if the current filter is set to "PCSS" (contact hardening).
  10200. */
  10201. /**
  10202. * Sets the current filter to "PCSS" (contact hardening).
  10203. */
  10204. useContactHardeningShadow: boolean;
  10205. private _contactHardeningLightSizeUVRatio;
  10206. /**
  10207. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10208. * Using a ratio helps keeping shape stability independently of the map size.
  10209. *
  10210. * It does not account for the light projection as it was having too much
  10211. * instability during the light setup or during light position changes.
  10212. *
  10213. * Only valid if useContactHardeningShadow is true.
  10214. */
  10215. /**
  10216. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10217. * Using a ratio helps keeping shape stability independently of the map size.
  10218. *
  10219. * It does not account for the light projection as it was having too much
  10220. * instability during the light setup or during light position changes.
  10221. *
  10222. * Only valid if useContactHardeningShadow is true.
  10223. */
  10224. contactHardeningLightSizeUVRatio: number;
  10225. private _darkness;
  10226. /** Gets or sets the actual darkness of a shadow */
  10227. darkness: number;
  10228. /**
  10229. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10230. * 0 means strongest and 1 would means no shadow.
  10231. * @returns the darkness.
  10232. */
  10233. getDarkness(): number;
  10234. /**
  10235. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10236. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10237. * @returns the shadow generator allowing fluent coding.
  10238. */
  10239. setDarkness(darkness: number): ShadowGenerator;
  10240. private _transparencyShadow;
  10241. /** Gets or sets the ability to have transparent shadow */
  10242. transparencyShadow: boolean;
  10243. /**
  10244. * Sets the ability to have transparent shadow (boolean).
  10245. * @param transparent True if transparent else False
  10246. * @returns the shadow generator allowing fluent coding
  10247. */
  10248. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10249. private _shadowMap;
  10250. private _shadowMap2;
  10251. /**
  10252. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10253. * @returns The render target texture if present otherwise, null
  10254. */
  10255. getShadowMap(): Nullable<RenderTargetTexture>;
  10256. /**
  10257. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10258. * @returns The render target texture if the shadow map is present otherwise, null
  10259. */
  10260. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10261. /**
  10262. * Gets the class name of that object
  10263. * @returns "ShadowGenerator"
  10264. */
  10265. getClassName(): string;
  10266. /**
  10267. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10268. * @param mesh Mesh to add
  10269. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10270. * @returns the Shadow Generator itself
  10271. */
  10272. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10273. /**
  10274. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10275. * @param mesh Mesh to remove
  10276. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10277. * @returns the Shadow Generator itself
  10278. */
  10279. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10280. /**
  10281. * Controls the extent to which the shadows fade out at the edge of the frustum
  10282. * Used only by directionals and spots
  10283. */
  10284. frustumEdgeFalloff: number;
  10285. private _light;
  10286. /**
  10287. * Returns the associated light object.
  10288. * @returns the light generating the shadow
  10289. */
  10290. getLight(): IShadowLight;
  10291. /**
  10292. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10293. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10294. * It might on the other hand introduce peter panning.
  10295. */
  10296. forceBackFacesOnly: boolean;
  10297. private _scene;
  10298. private _lightDirection;
  10299. private _effect;
  10300. private _viewMatrix;
  10301. private _projectionMatrix;
  10302. private _transformMatrix;
  10303. private _cachedPosition;
  10304. private _cachedDirection;
  10305. private _cachedDefines;
  10306. private _currentRenderID;
  10307. private _boxBlurPostprocess;
  10308. private _kernelBlurXPostprocess;
  10309. private _kernelBlurYPostprocess;
  10310. private _blurPostProcesses;
  10311. private _mapSize;
  10312. private _currentFaceIndex;
  10313. private _currentFaceIndexCache;
  10314. private _textureType;
  10315. private _defaultTextureMatrix;
  10316. /** @hidden */
  10317. static _SceneComponentInitialization: (scene: Scene) => void;
  10318. /**
  10319. * Creates a ShadowGenerator object.
  10320. * A ShadowGenerator is the required tool to use the shadows.
  10321. * Each light casting shadows needs to use its own ShadowGenerator.
  10322. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10323. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10324. * @param light The light object generating the shadows.
  10325. * @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.
  10326. */
  10327. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10328. private _initializeGenerator;
  10329. private _initializeShadowMap;
  10330. private _initializeBlurRTTAndPostProcesses;
  10331. private _renderForShadowMap;
  10332. private _renderSubMeshForShadowMap;
  10333. private _applyFilterValues;
  10334. /**
  10335. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10336. * @param onCompiled Callback triggered at the and of the effects compilation
  10337. * @param options Sets of optional options forcing the compilation with different modes
  10338. */
  10339. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10340. useInstances: boolean;
  10341. }>): void;
  10342. /**
  10343. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10344. * @param options Sets of optional options forcing the compilation with different modes
  10345. * @returns A promise that resolves when the compilation completes
  10346. */
  10347. forceCompilationAsync(options?: Partial<{
  10348. useInstances: boolean;
  10349. }>): Promise<void>;
  10350. /**
  10351. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10352. * @param subMesh The submesh we want to render in the shadow map
  10353. * @param useInstances Defines wether will draw in the map using instances
  10354. * @returns true if ready otherwise, false
  10355. */
  10356. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10357. /**
  10358. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10359. * @param defines Defines of the material we want to update
  10360. * @param lightIndex Index of the light in the enabled light list of the material
  10361. */
  10362. prepareDefines(defines: any, lightIndex: number): void;
  10363. /**
  10364. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10365. * defined in the generator but impacting the effect).
  10366. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10367. * @param effect The effect we are binfing the information for
  10368. */
  10369. bindShadowLight(lightIndex: string, effect: Effect): void;
  10370. /**
  10371. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10372. * (eq to shadow prjection matrix * light transform matrix)
  10373. * @returns The transform matrix used to create the shadow map
  10374. */
  10375. getTransformMatrix(): Matrix;
  10376. /**
  10377. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10378. * Cube and 2D textures for instance.
  10379. */
  10380. recreateShadowMap(): void;
  10381. private _disposeBlurPostProcesses;
  10382. private _disposeRTTandPostProcesses;
  10383. /**
  10384. * Disposes the ShadowGenerator.
  10385. * Returns nothing.
  10386. */
  10387. dispose(): void;
  10388. /**
  10389. * Serializes the shadow generator setup to a json object.
  10390. * @returns The serialized JSON object
  10391. */
  10392. serialize(): any;
  10393. /**
  10394. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10395. * @param parsedShadowGenerator The JSON object to parse
  10396. * @param scene The scene to create the shadow map for
  10397. * @returns The parsed shadow generator
  10398. */
  10399. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10400. }
  10401. }
  10402. declare module BABYLON {
  10403. /**
  10404. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10405. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10406. * 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.
  10407. */
  10408. export abstract class Light extends Node {
  10409. /**
  10410. * Falloff Default: light is falling off following the material specification:
  10411. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10412. */
  10413. static readonly FALLOFF_DEFAULT: number;
  10414. /**
  10415. * Falloff Physical: light is falling off following the inverse squared distance law.
  10416. */
  10417. static readonly FALLOFF_PHYSICAL: number;
  10418. /**
  10419. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10420. * to enhance interoperability with other engines.
  10421. */
  10422. static readonly FALLOFF_GLTF: number;
  10423. /**
  10424. * Falloff Standard: light is falling off like in the standard material
  10425. * to enhance interoperability with other materials.
  10426. */
  10427. static readonly FALLOFF_STANDARD: number;
  10428. /**
  10429. * If every light affecting the material is in this lightmapMode,
  10430. * material.lightmapTexture adds or multiplies
  10431. * (depends on material.useLightmapAsShadowmap)
  10432. * after every other light calculations.
  10433. */
  10434. static readonly LIGHTMAP_DEFAULT: number;
  10435. /**
  10436. * material.lightmapTexture as only diffuse lighting from this light
  10437. * adds only specular lighting from this light
  10438. * adds dynamic shadows
  10439. */
  10440. static readonly LIGHTMAP_SPECULAR: number;
  10441. /**
  10442. * material.lightmapTexture as only lighting
  10443. * no light calculation from this light
  10444. * only adds dynamic shadows from this light
  10445. */
  10446. static readonly LIGHTMAP_SHADOWSONLY: number;
  10447. /**
  10448. * Each light type uses the default quantity according to its type:
  10449. * point/spot lights use luminous intensity
  10450. * directional lights use illuminance
  10451. */
  10452. static readonly INTENSITYMODE_AUTOMATIC: number;
  10453. /**
  10454. * lumen (lm)
  10455. */
  10456. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10457. /**
  10458. * candela (lm/sr)
  10459. */
  10460. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10461. /**
  10462. * lux (lm/m^2)
  10463. */
  10464. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10465. /**
  10466. * nit (cd/m^2)
  10467. */
  10468. static readonly INTENSITYMODE_LUMINANCE: number;
  10469. /**
  10470. * Light type const id of the point light.
  10471. */
  10472. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10473. /**
  10474. * Light type const id of the directional light.
  10475. */
  10476. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10477. /**
  10478. * Light type const id of the spot light.
  10479. */
  10480. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10481. /**
  10482. * Light type const id of the hemispheric light.
  10483. */
  10484. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10485. /**
  10486. * Diffuse gives the basic color to an object.
  10487. */
  10488. diffuse: Color3;
  10489. /**
  10490. * Specular produces a highlight color on an object.
  10491. * Note: This is note affecting PBR materials.
  10492. */
  10493. specular: Color3;
  10494. /**
  10495. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10496. * falling off base on range or angle.
  10497. * This can be set to any values in Light.FALLOFF_x.
  10498. *
  10499. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10500. * other types of materials.
  10501. */
  10502. falloffType: number;
  10503. /**
  10504. * Strength of the light.
  10505. * Note: By default it is define in the framework own unit.
  10506. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10507. */
  10508. intensity: number;
  10509. private _range;
  10510. protected _inverseSquaredRange: number;
  10511. /**
  10512. * Defines how far from the source the light is impacting in scene units.
  10513. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10514. */
  10515. /**
  10516. * Defines how far from the source the light is impacting in scene units.
  10517. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10518. */
  10519. range: number;
  10520. /**
  10521. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10522. * of light.
  10523. */
  10524. private _photometricScale;
  10525. private _intensityMode;
  10526. /**
  10527. * Gets the photometric scale used to interpret the intensity.
  10528. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10529. */
  10530. /**
  10531. * Sets the photometric scale used to interpret the intensity.
  10532. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10533. */
  10534. intensityMode: number;
  10535. private _radius;
  10536. /**
  10537. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10538. */
  10539. /**
  10540. * sets the light radius used by PBR Materials to simulate soft area lights.
  10541. */
  10542. radius: number;
  10543. private _renderPriority;
  10544. /**
  10545. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10546. * exceeding the number allowed of the materials.
  10547. */
  10548. renderPriority: number;
  10549. private _shadowEnabled;
  10550. /**
  10551. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10552. * the current shadow generator.
  10553. */
  10554. /**
  10555. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10556. * the current shadow generator.
  10557. */
  10558. shadowEnabled: boolean;
  10559. private _includedOnlyMeshes;
  10560. /**
  10561. * Gets the only meshes impacted by this light.
  10562. */
  10563. /**
  10564. * Sets the only meshes impacted by this light.
  10565. */
  10566. includedOnlyMeshes: AbstractMesh[];
  10567. private _excludedMeshes;
  10568. /**
  10569. * Gets the meshes not impacted by this light.
  10570. */
  10571. /**
  10572. * Sets the meshes not impacted by this light.
  10573. */
  10574. excludedMeshes: AbstractMesh[];
  10575. private _excludeWithLayerMask;
  10576. /**
  10577. * Gets the layer id use to find what meshes are not impacted by the light.
  10578. * Inactive if 0
  10579. */
  10580. /**
  10581. * Sets the layer id use to find what meshes are not impacted by the light.
  10582. * Inactive if 0
  10583. */
  10584. excludeWithLayerMask: number;
  10585. private _includeOnlyWithLayerMask;
  10586. /**
  10587. * Gets the layer id use to find what meshes are impacted by the light.
  10588. * Inactive if 0
  10589. */
  10590. /**
  10591. * Sets the layer id use to find what meshes are impacted by the light.
  10592. * Inactive if 0
  10593. */
  10594. includeOnlyWithLayerMask: number;
  10595. private _lightmapMode;
  10596. /**
  10597. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10598. */
  10599. /**
  10600. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10601. */
  10602. lightmapMode: number;
  10603. /**
  10604. * Shadow generator associted to the light.
  10605. * @hidden Internal use only.
  10606. */
  10607. _shadowGenerator: Nullable<IShadowGenerator>;
  10608. /**
  10609. * @hidden Internal use only.
  10610. */
  10611. _excludedMeshesIds: string[];
  10612. /**
  10613. * @hidden Internal use only.
  10614. */
  10615. _includedOnlyMeshesIds: string[];
  10616. /**
  10617. * The current light unifom buffer.
  10618. * @hidden Internal use only.
  10619. */
  10620. _uniformBuffer: UniformBuffer;
  10621. /**
  10622. * Creates a Light object in the scene.
  10623. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10624. * @param name The firendly name of the light
  10625. * @param scene The scene the light belongs too
  10626. */
  10627. constructor(name: string, scene: Scene);
  10628. protected abstract _buildUniformLayout(): void;
  10629. /**
  10630. * Sets the passed Effect "effect" with the Light information.
  10631. * @param effect The effect to update
  10632. * @param lightIndex The index of the light in the effect to update
  10633. * @returns The light
  10634. */
  10635. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10636. /**
  10637. * Returns the string "Light".
  10638. * @returns the class name
  10639. */
  10640. getClassName(): string;
  10641. /** @hidden */
  10642. readonly _isLight: boolean;
  10643. /**
  10644. * Converts the light information to a readable string for debug purpose.
  10645. * @param fullDetails Supports for multiple levels of logging within scene loading
  10646. * @returns the human readable light info
  10647. */
  10648. toString(fullDetails?: boolean): string;
  10649. /** @hidden */
  10650. protected _syncParentEnabledState(): void;
  10651. /**
  10652. * Set the enabled state of this node.
  10653. * @param value - the new enabled state
  10654. */
  10655. setEnabled(value: boolean): void;
  10656. /**
  10657. * Returns the Light associated shadow generator if any.
  10658. * @return the associated shadow generator.
  10659. */
  10660. getShadowGenerator(): Nullable<IShadowGenerator>;
  10661. /**
  10662. * Returns a Vector3, the absolute light position in the World.
  10663. * @returns the world space position of the light
  10664. */
  10665. getAbsolutePosition(): Vector3;
  10666. /**
  10667. * Specifies if the light will affect the passed mesh.
  10668. * @param mesh The mesh to test against the light
  10669. * @return true the mesh is affected otherwise, false.
  10670. */
  10671. canAffectMesh(mesh: AbstractMesh): boolean;
  10672. /**
  10673. * Sort function to order lights for rendering.
  10674. * @param a First Light object to compare to second.
  10675. * @param b Second Light object to compare first.
  10676. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10677. */
  10678. static CompareLightsPriority(a: Light, b: Light): number;
  10679. /**
  10680. * Releases resources associated with this node.
  10681. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10682. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10683. */
  10684. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10685. /**
  10686. * Returns the light type ID (integer).
  10687. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10688. */
  10689. getTypeID(): number;
  10690. /**
  10691. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10692. * @returns the scaled intensity in intensity mode unit
  10693. */
  10694. getScaledIntensity(): number;
  10695. /**
  10696. * Returns a new Light object, named "name", from the current one.
  10697. * @param name The name of the cloned light
  10698. * @returns the new created light
  10699. */
  10700. clone(name: string): Nullable<Light>;
  10701. /**
  10702. * Serializes the current light into a Serialization object.
  10703. * @returns the serialized object.
  10704. */
  10705. serialize(): any;
  10706. /**
  10707. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10708. * This new light is named "name" and added to the passed scene.
  10709. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10710. * @param name The friendly name of the light
  10711. * @param scene The scene the new light will belong to
  10712. * @returns the constructor function
  10713. */
  10714. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10715. /**
  10716. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10717. * @param parsedLight The JSON representation of the light
  10718. * @param scene The scene to create the parsed light in
  10719. * @returns the created light after parsing
  10720. */
  10721. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10722. private _hookArrayForExcluded;
  10723. private _hookArrayForIncludedOnly;
  10724. private _resyncMeshes;
  10725. /**
  10726. * Forces the meshes to update their light related information in their rendering used effects
  10727. * @hidden Internal Use Only
  10728. */
  10729. _markMeshesAsLightDirty(): void;
  10730. /**
  10731. * Recomputes the cached photometric scale if needed.
  10732. */
  10733. private _computePhotometricScale;
  10734. /**
  10735. * Returns the Photometric Scale according to the light type and intensity mode.
  10736. */
  10737. private _getPhotometricScale;
  10738. /**
  10739. * Reorder the light in the scene according to their defined priority.
  10740. * @hidden Internal Use Only
  10741. */
  10742. _reorderLightsInScene(): void;
  10743. /**
  10744. * Prepares the list of defines specific to the light type.
  10745. * @param defines the list of defines
  10746. * @param lightIndex defines the index of the light for the effect
  10747. */
  10748. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10749. }
  10750. }
  10751. declare module BABYLON {
  10752. /**
  10753. * Interface used to define Action
  10754. */
  10755. export interface IAction {
  10756. /**
  10757. * Trigger for the action
  10758. */
  10759. trigger: number;
  10760. /** Options of the trigger */
  10761. triggerOptions: any;
  10762. /**
  10763. * Gets the trigger parameters
  10764. * @returns the trigger parameters
  10765. */
  10766. getTriggerParameter(): any;
  10767. /**
  10768. * Internal only - executes current action event
  10769. * @hidden
  10770. */
  10771. _executeCurrent(evt?: ActionEvent): void;
  10772. /**
  10773. * Serialize placeholder for child classes
  10774. * @param parent of child
  10775. * @returns the serialized object
  10776. */
  10777. serialize(parent: any): any;
  10778. /**
  10779. * Internal only
  10780. * @hidden
  10781. */
  10782. _prepare(): void;
  10783. /**
  10784. * Internal only - manager for action
  10785. * @hidden
  10786. */
  10787. _actionManager: AbstractActionManager;
  10788. /**
  10789. * Adds action to chain of actions, may be a DoNothingAction
  10790. * @param action defines the next action to execute
  10791. * @returns The action passed in
  10792. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10793. */
  10794. then(action: IAction): IAction;
  10795. }
  10796. /**
  10797. * The action to be carried out following a trigger
  10798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10799. */
  10800. export class Action implements IAction {
  10801. /** the trigger, with or without parameters, for the action */
  10802. triggerOptions: any;
  10803. /**
  10804. * Trigger for the action
  10805. */
  10806. trigger: number;
  10807. /**
  10808. * Internal only - manager for action
  10809. * @hidden
  10810. */
  10811. _actionManager: ActionManager;
  10812. private _nextActiveAction;
  10813. private _child;
  10814. private _condition?;
  10815. private _triggerParameter;
  10816. /**
  10817. * An event triggered prior to action being executed.
  10818. */
  10819. onBeforeExecuteObservable: Observable<Action>;
  10820. /**
  10821. * Creates a new Action
  10822. * @param triggerOptions the trigger, with or without parameters, for the action
  10823. * @param condition an optional determinant of action
  10824. */
  10825. constructor(
  10826. /** the trigger, with or without parameters, for the action */
  10827. triggerOptions: any, condition?: Condition);
  10828. /**
  10829. * Internal only
  10830. * @hidden
  10831. */
  10832. _prepare(): void;
  10833. /**
  10834. * Gets the trigger parameters
  10835. * @returns the trigger parameters
  10836. */
  10837. getTriggerParameter(): any;
  10838. /**
  10839. * Internal only - executes current action event
  10840. * @hidden
  10841. */
  10842. _executeCurrent(evt?: ActionEvent): void;
  10843. /**
  10844. * Execute placeholder for child classes
  10845. * @param evt optional action event
  10846. */
  10847. execute(evt?: ActionEvent): void;
  10848. /**
  10849. * Skips to next active action
  10850. */
  10851. skipToNextActiveAction(): void;
  10852. /**
  10853. * Adds action to chain of actions, may be a DoNothingAction
  10854. * @param action defines the next action to execute
  10855. * @returns The action passed in
  10856. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10857. */
  10858. then(action: Action): Action;
  10859. /**
  10860. * Internal only
  10861. * @hidden
  10862. */
  10863. _getProperty(propertyPath: string): string;
  10864. /**
  10865. * Internal only
  10866. * @hidden
  10867. */
  10868. _getEffectiveTarget(target: any, propertyPath: string): any;
  10869. /**
  10870. * Serialize placeholder for child classes
  10871. * @param parent of child
  10872. * @returns the serialized object
  10873. */
  10874. serialize(parent: any): any;
  10875. /**
  10876. * Internal only called by serialize
  10877. * @hidden
  10878. */
  10879. protected _serialize(serializedAction: any, parent?: any): any;
  10880. /**
  10881. * Internal only
  10882. * @hidden
  10883. */
  10884. static _SerializeValueAsString: (value: any) => string;
  10885. /**
  10886. * Internal only
  10887. * @hidden
  10888. */
  10889. static _GetTargetProperty: (target: Scene | Node) => {
  10890. name: string;
  10891. targetType: string;
  10892. value: string;
  10893. };
  10894. }
  10895. }
  10896. declare module BABYLON {
  10897. /**
  10898. * A Condition applied to an Action
  10899. */
  10900. export class Condition {
  10901. /**
  10902. * Internal only - manager for action
  10903. * @hidden
  10904. */
  10905. _actionManager: ActionManager;
  10906. /**
  10907. * Internal only
  10908. * @hidden
  10909. */
  10910. _evaluationId: number;
  10911. /**
  10912. * Internal only
  10913. * @hidden
  10914. */
  10915. _currentResult: boolean;
  10916. /**
  10917. * Creates a new Condition
  10918. * @param actionManager the manager of the action the condition is applied to
  10919. */
  10920. constructor(actionManager: ActionManager);
  10921. /**
  10922. * Check if the current condition is valid
  10923. * @returns a boolean
  10924. */
  10925. isValid(): boolean;
  10926. /**
  10927. * Internal only
  10928. * @hidden
  10929. */
  10930. _getProperty(propertyPath: string): string;
  10931. /**
  10932. * Internal only
  10933. * @hidden
  10934. */
  10935. _getEffectiveTarget(target: any, propertyPath: string): any;
  10936. /**
  10937. * Serialize placeholder for child classes
  10938. * @returns the serialized object
  10939. */
  10940. serialize(): any;
  10941. /**
  10942. * Internal only
  10943. * @hidden
  10944. */
  10945. protected _serialize(serializedCondition: any): any;
  10946. }
  10947. /**
  10948. * Defines specific conditional operators as extensions of Condition
  10949. */
  10950. export class ValueCondition extends Condition {
  10951. /** path to specify the property of the target the conditional operator uses */
  10952. propertyPath: string;
  10953. /** the value compared by the conditional operator against the current value of the property */
  10954. value: any;
  10955. /** the conditional operator, default ValueCondition.IsEqual */
  10956. operator: number;
  10957. /**
  10958. * Internal only
  10959. * @hidden
  10960. */
  10961. private static _IsEqual;
  10962. /**
  10963. * Internal only
  10964. * @hidden
  10965. */
  10966. private static _IsDifferent;
  10967. /**
  10968. * Internal only
  10969. * @hidden
  10970. */
  10971. private static _IsGreater;
  10972. /**
  10973. * Internal only
  10974. * @hidden
  10975. */
  10976. private static _IsLesser;
  10977. /**
  10978. * returns the number for IsEqual
  10979. */
  10980. static readonly IsEqual: number;
  10981. /**
  10982. * Returns the number for IsDifferent
  10983. */
  10984. static readonly IsDifferent: number;
  10985. /**
  10986. * Returns the number for IsGreater
  10987. */
  10988. static readonly IsGreater: number;
  10989. /**
  10990. * Returns the number for IsLesser
  10991. */
  10992. static readonly IsLesser: number;
  10993. /**
  10994. * Internal only The action manager for the condition
  10995. * @hidden
  10996. */
  10997. _actionManager: ActionManager;
  10998. /**
  10999. * Internal only
  11000. * @hidden
  11001. */
  11002. private _target;
  11003. /**
  11004. * Internal only
  11005. * @hidden
  11006. */
  11007. private _effectiveTarget;
  11008. /**
  11009. * Internal only
  11010. * @hidden
  11011. */
  11012. private _property;
  11013. /**
  11014. * Creates a new ValueCondition
  11015. * @param actionManager manager for the action the condition applies to
  11016. * @param target for the action
  11017. * @param propertyPath path to specify the property of the target the conditional operator uses
  11018. * @param value the value compared by the conditional operator against the current value of the property
  11019. * @param operator the conditional operator, default ValueCondition.IsEqual
  11020. */
  11021. constructor(actionManager: ActionManager, target: any,
  11022. /** path to specify the property of the target the conditional operator uses */
  11023. propertyPath: string,
  11024. /** the value compared by the conditional operator against the current value of the property */
  11025. value: any,
  11026. /** the conditional operator, default ValueCondition.IsEqual */
  11027. operator?: number);
  11028. /**
  11029. * Compares the given value with the property value for the specified conditional operator
  11030. * @returns the result of the comparison
  11031. */
  11032. isValid(): boolean;
  11033. /**
  11034. * Serialize the ValueCondition into a JSON compatible object
  11035. * @returns serialization object
  11036. */
  11037. serialize(): any;
  11038. /**
  11039. * Gets the name of the conditional operator for the ValueCondition
  11040. * @param operator the conditional operator
  11041. * @returns the name
  11042. */
  11043. static GetOperatorName(operator: number): string;
  11044. }
  11045. /**
  11046. * Defines a predicate condition as an extension of Condition
  11047. */
  11048. export class PredicateCondition extends Condition {
  11049. /** defines the predicate function used to validate the condition */
  11050. predicate: () => boolean;
  11051. /**
  11052. * Internal only - manager for action
  11053. * @hidden
  11054. */
  11055. _actionManager: ActionManager;
  11056. /**
  11057. * Creates a new PredicateCondition
  11058. * @param actionManager manager for the action the condition applies to
  11059. * @param predicate defines the predicate function used to validate the condition
  11060. */
  11061. constructor(actionManager: ActionManager,
  11062. /** defines the predicate function used to validate the condition */
  11063. predicate: () => boolean);
  11064. /**
  11065. * @returns the validity of the predicate condition
  11066. */
  11067. isValid(): boolean;
  11068. }
  11069. /**
  11070. * Defines a state condition as an extension of Condition
  11071. */
  11072. export class StateCondition extends Condition {
  11073. /** Value to compare with target state */
  11074. value: string;
  11075. /**
  11076. * Internal only - manager for action
  11077. * @hidden
  11078. */
  11079. _actionManager: ActionManager;
  11080. /**
  11081. * Internal only
  11082. * @hidden
  11083. */
  11084. private _target;
  11085. /**
  11086. * Creates a new StateCondition
  11087. * @param actionManager manager for the action the condition applies to
  11088. * @param target of the condition
  11089. * @param value to compare with target state
  11090. */
  11091. constructor(actionManager: ActionManager, target: any,
  11092. /** Value to compare with target state */
  11093. value: string);
  11094. /**
  11095. * Gets a boolean indicating if the current condition is met
  11096. * @returns the validity of the state
  11097. */
  11098. isValid(): boolean;
  11099. /**
  11100. * Serialize the StateCondition into a JSON compatible object
  11101. * @returns serialization object
  11102. */
  11103. serialize(): any;
  11104. }
  11105. }
  11106. declare module BABYLON {
  11107. /**
  11108. * This defines an action responsible to toggle a boolean once triggered.
  11109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11110. */
  11111. export class SwitchBooleanAction extends Action {
  11112. /**
  11113. * The path to the boolean property in the target object
  11114. */
  11115. propertyPath: string;
  11116. private _target;
  11117. private _effectiveTarget;
  11118. private _property;
  11119. /**
  11120. * Instantiate the action
  11121. * @param triggerOptions defines the trigger options
  11122. * @param target defines the object containing the boolean
  11123. * @param propertyPath defines the path to the boolean property in the target object
  11124. * @param condition defines the trigger related conditions
  11125. */
  11126. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  11127. /** @hidden */
  11128. _prepare(): void;
  11129. /**
  11130. * Execute the action toggle the boolean value.
  11131. */
  11132. execute(): void;
  11133. /**
  11134. * Serializes the actions and its related information.
  11135. * @param parent defines the object to serialize in
  11136. * @returns the serialized object
  11137. */
  11138. serialize(parent: any): any;
  11139. }
  11140. /**
  11141. * This defines an action responsible to set a the state field of the target
  11142. * to a desired value once triggered.
  11143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11144. */
  11145. export class SetStateAction extends Action {
  11146. /**
  11147. * The value to store in the state field.
  11148. */
  11149. value: string;
  11150. private _target;
  11151. /**
  11152. * Instantiate the action
  11153. * @param triggerOptions defines the trigger options
  11154. * @param target defines the object containing the state property
  11155. * @param value defines the value to store in the state field
  11156. * @param condition defines the trigger related conditions
  11157. */
  11158. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11159. /**
  11160. * Execute the action and store the value on the target state property.
  11161. */
  11162. execute(): void;
  11163. /**
  11164. * Serializes the actions and its related information.
  11165. * @param parent defines the object to serialize in
  11166. * @returns the serialized object
  11167. */
  11168. serialize(parent: any): any;
  11169. }
  11170. /**
  11171. * This defines an action responsible to set a property of the target
  11172. * to a desired value once triggered.
  11173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11174. */
  11175. export class SetValueAction extends Action {
  11176. /**
  11177. * The path of the property to set in the target.
  11178. */
  11179. propertyPath: string;
  11180. /**
  11181. * The value to set in the property
  11182. */
  11183. value: any;
  11184. private _target;
  11185. private _effectiveTarget;
  11186. private _property;
  11187. /**
  11188. * Instantiate the action
  11189. * @param triggerOptions defines the trigger options
  11190. * @param target defines the object containing the property
  11191. * @param propertyPath defines the path of the property to set in the target
  11192. * @param value defines the value to set in the property
  11193. * @param condition defines the trigger related conditions
  11194. */
  11195. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11196. /** @hidden */
  11197. _prepare(): void;
  11198. /**
  11199. * Execute the action and set the targetted property to the desired value.
  11200. */
  11201. execute(): void;
  11202. /**
  11203. * Serializes the actions and its related information.
  11204. * @param parent defines the object to serialize in
  11205. * @returns the serialized object
  11206. */
  11207. serialize(parent: any): any;
  11208. }
  11209. /**
  11210. * This defines an action responsible to increment the target value
  11211. * to a desired value once triggered.
  11212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11213. */
  11214. export class IncrementValueAction extends Action {
  11215. /**
  11216. * The path of the property to increment in the target.
  11217. */
  11218. propertyPath: string;
  11219. /**
  11220. * The value we should increment the property by.
  11221. */
  11222. value: any;
  11223. private _target;
  11224. private _effectiveTarget;
  11225. private _property;
  11226. /**
  11227. * Instantiate the action
  11228. * @param triggerOptions defines the trigger options
  11229. * @param target defines the object containing the property
  11230. * @param propertyPath defines the path of the property to increment in the target
  11231. * @param value defines the value value we should increment the property by
  11232. * @param condition defines the trigger related conditions
  11233. */
  11234. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11235. /** @hidden */
  11236. _prepare(): void;
  11237. /**
  11238. * Execute the action and increment the target of the value amount.
  11239. */
  11240. execute(): void;
  11241. /**
  11242. * Serializes the actions and its related information.
  11243. * @param parent defines the object to serialize in
  11244. * @returns the serialized object
  11245. */
  11246. serialize(parent: any): any;
  11247. }
  11248. /**
  11249. * This defines an action responsible to start an animation once triggered.
  11250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11251. */
  11252. export class PlayAnimationAction extends Action {
  11253. /**
  11254. * Where the animation should start (animation frame)
  11255. */
  11256. from: number;
  11257. /**
  11258. * Where the animation should stop (animation frame)
  11259. */
  11260. to: number;
  11261. /**
  11262. * Define if the animation should loop or stop after the first play.
  11263. */
  11264. loop?: boolean;
  11265. private _target;
  11266. /**
  11267. * Instantiate the action
  11268. * @param triggerOptions defines the trigger options
  11269. * @param target defines the target animation or animation name
  11270. * @param from defines from where the animation should start (animation frame)
  11271. * @param end defines where the animation should stop (animation frame)
  11272. * @param loop defines if the animation should loop or stop after the first play
  11273. * @param condition defines the trigger related conditions
  11274. */
  11275. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11276. /** @hidden */
  11277. _prepare(): void;
  11278. /**
  11279. * Execute the action and play the animation.
  11280. */
  11281. execute(): void;
  11282. /**
  11283. * Serializes the actions and its related information.
  11284. * @param parent defines the object to serialize in
  11285. * @returns the serialized object
  11286. */
  11287. serialize(parent: any): any;
  11288. }
  11289. /**
  11290. * This defines an action responsible to stop an animation once triggered.
  11291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11292. */
  11293. export class StopAnimationAction extends Action {
  11294. private _target;
  11295. /**
  11296. * Instantiate the action
  11297. * @param triggerOptions defines the trigger options
  11298. * @param target defines the target animation or animation name
  11299. * @param condition defines the trigger related conditions
  11300. */
  11301. constructor(triggerOptions: any, target: any, condition?: Condition);
  11302. /** @hidden */
  11303. _prepare(): void;
  11304. /**
  11305. * Execute the action and stop the animation.
  11306. */
  11307. execute(): void;
  11308. /**
  11309. * Serializes the actions and its related information.
  11310. * @param parent defines the object to serialize in
  11311. * @returns the serialized object
  11312. */
  11313. serialize(parent: any): any;
  11314. }
  11315. /**
  11316. * This defines an action responsible that does nothing once triggered.
  11317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11318. */
  11319. export class DoNothingAction extends Action {
  11320. /**
  11321. * Instantiate the action
  11322. * @param triggerOptions defines the trigger options
  11323. * @param condition defines the trigger related conditions
  11324. */
  11325. constructor(triggerOptions?: any, condition?: Condition);
  11326. /**
  11327. * Execute the action and do nothing.
  11328. */
  11329. execute(): void;
  11330. /**
  11331. * Serializes the actions and its related information.
  11332. * @param parent defines the object to serialize in
  11333. * @returns the serialized object
  11334. */
  11335. serialize(parent: any): any;
  11336. }
  11337. /**
  11338. * This defines an action responsible to trigger several actions once triggered.
  11339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11340. */
  11341. export class CombineAction extends Action {
  11342. /**
  11343. * The list of aggregated animations to run.
  11344. */
  11345. children: Action[];
  11346. /**
  11347. * Instantiate the action
  11348. * @param triggerOptions defines the trigger options
  11349. * @param children defines the list of aggregated animations to run
  11350. * @param condition defines the trigger related conditions
  11351. */
  11352. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11353. /** @hidden */
  11354. _prepare(): void;
  11355. /**
  11356. * Execute the action and executes all the aggregated actions.
  11357. */
  11358. execute(evt: ActionEvent): void;
  11359. /**
  11360. * Serializes the actions and its related information.
  11361. * @param parent defines the object to serialize in
  11362. * @returns the serialized object
  11363. */
  11364. serialize(parent: any): any;
  11365. }
  11366. /**
  11367. * This defines an action responsible to run code (external event) once triggered.
  11368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11369. */
  11370. export class ExecuteCodeAction extends Action {
  11371. /**
  11372. * The callback function to run.
  11373. */
  11374. func: (evt: ActionEvent) => void;
  11375. /**
  11376. * Instantiate the action
  11377. * @param triggerOptions defines the trigger options
  11378. * @param func defines the callback function to run
  11379. * @param condition defines the trigger related conditions
  11380. */
  11381. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11382. /**
  11383. * Execute the action and run the attached code.
  11384. */
  11385. execute(evt: ActionEvent): void;
  11386. }
  11387. /**
  11388. * This defines an action responsible to set the parent property of the target once triggered.
  11389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11390. */
  11391. export class SetParentAction extends Action {
  11392. private _parent;
  11393. private _target;
  11394. /**
  11395. * Instantiate the action
  11396. * @param triggerOptions defines the trigger options
  11397. * @param target defines the target containing the parent property
  11398. * @param parent defines from where the animation should start (animation frame)
  11399. * @param condition defines the trigger related conditions
  11400. */
  11401. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11402. /** @hidden */
  11403. _prepare(): void;
  11404. /**
  11405. * Execute the action and set the parent property.
  11406. */
  11407. execute(): void;
  11408. /**
  11409. * Serializes the actions and its related information.
  11410. * @param parent defines the object to serialize in
  11411. * @returns the serialized object
  11412. */
  11413. serialize(parent: any): any;
  11414. }
  11415. }
  11416. declare module BABYLON {
  11417. /**
  11418. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11419. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11421. */
  11422. export class ActionManager extends AbstractActionManager {
  11423. /**
  11424. * Nothing
  11425. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11426. */
  11427. static readonly NothingTrigger: number;
  11428. /**
  11429. * On pick
  11430. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11431. */
  11432. static readonly OnPickTrigger: number;
  11433. /**
  11434. * On left pick
  11435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11436. */
  11437. static readonly OnLeftPickTrigger: number;
  11438. /**
  11439. * On right pick
  11440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11441. */
  11442. static readonly OnRightPickTrigger: number;
  11443. /**
  11444. * On center pick
  11445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11446. */
  11447. static readonly OnCenterPickTrigger: number;
  11448. /**
  11449. * On pick down
  11450. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11451. */
  11452. static readonly OnPickDownTrigger: number;
  11453. /**
  11454. * On double pick
  11455. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11456. */
  11457. static readonly OnDoublePickTrigger: number;
  11458. /**
  11459. * On pick up
  11460. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11461. */
  11462. static readonly OnPickUpTrigger: number;
  11463. /**
  11464. * On pick out.
  11465. * This trigger will only be raised if you also declared a OnPickDown
  11466. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11467. */
  11468. static readonly OnPickOutTrigger: number;
  11469. /**
  11470. * On long press
  11471. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11472. */
  11473. static readonly OnLongPressTrigger: number;
  11474. /**
  11475. * On pointer over
  11476. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11477. */
  11478. static readonly OnPointerOverTrigger: number;
  11479. /**
  11480. * On pointer out
  11481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11482. */
  11483. static readonly OnPointerOutTrigger: number;
  11484. /**
  11485. * On every frame
  11486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11487. */
  11488. static readonly OnEveryFrameTrigger: number;
  11489. /**
  11490. * On intersection enter
  11491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11492. */
  11493. static readonly OnIntersectionEnterTrigger: number;
  11494. /**
  11495. * On intersection exit
  11496. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11497. */
  11498. static readonly OnIntersectionExitTrigger: number;
  11499. /**
  11500. * On key down
  11501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11502. */
  11503. static readonly OnKeyDownTrigger: number;
  11504. /**
  11505. * On key up
  11506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11507. */
  11508. static readonly OnKeyUpTrigger: number;
  11509. private _scene;
  11510. /**
  11511. * Creates a new action manager
  11512. * @param scene defines the hosting scene
  11513. */
  11514. constructor(scene: Scene);
  11515. /**
  11516. * Releases all associated resources
  11517. */
  11518. dispose(): void;
  11519. /**
  11520. * Gets hosting scene
  11521. * @returns the hosting scene
  11522. */
  11523. getScene(): Scene;
  11524. /**
  11525. * Does this action manager handles actions of any of the given triggers
  11526. * @param triggers defines the triggers to be tested
  11527. * @return a boolean indicating whether one (or more) of the triggers is handled
  11528. */
  11529. hasSpecificTriggers(triggers: number[]): boolean;
  11530. /**
  11531. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11532. * speed.
  11533. * @param triggerA defines the trigger to be tested
  11534. * @param triggerB defines the trigger to be tested
  11535. * @return a boolean indicating whether one (or more) of the triggers is handled
  11536. */
  11537. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11538. /**
  11539. * Does this action manager handles actions of a given trigger
  11540. * @param trigger defines the trigger to be tested
  11541. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11542. * @return whether the trigger is handled
  11543. */
  11544. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11545. /**
  11546. * Does this action manager has pointer triggers
  11547. */
  11548. readonly hasPointerTriggers: boolean;
  11549. /**
  11550. * Does this action manager has pick triggers
  11551. */
  11552. readonly hasPickTriggers: boolean;
  11553. /**
  11554. * Registers an action to this action manager
  11555. * @param action defines the action to be registered
  11556. * @return the action amended (prepared) after registration
  11557. */
  11558. registerAction(action: IAction): Nullable<IAction>;
  11559. /**
  11560. * Unregisters an action to this action manager
  11561. * @param action defines the action to be unregistered
  11562. * @return a boolean indicating whether the action has been unregistered
  11563. */
  11564. unregisterAction(action: IAction): Boolean;
  11565. /**
  11566. * Process a specific trigger
  11567. * @param trigger defines the trigger to process
  11568. * @param evt defines the event details to be processed
  11569. */
  11570. processTrigger(trigger: number, evt?: IActionEvent): void;
  11571. /** @hidden */
  11572. _getEffectiveTarget(target: any, propertyPath: string): any;
  11573. /** @hidden */
  11574. _getProperty(propertyPath: string): string;
  11575. /**
  11576. * Serialize this manager to a JSON object
  11577. * @param name defines the property name to store this manager
  11578. * @returns a JSON representation of this manager
  11579. */
  11580. serialize(name: string): any;
  11581. /**
  11582. * Creates a new ActionManager from a JSON data
  11583. * @param parsedActions defines the JSON data to read from
  11584. * @param object defines the hosting mesh
  11585. * @param scene defines the hosting scene
  11586. */
  11587. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11588. /**
  11589. * Get a trigger name by index
  11590. * @param trigger defines the trigger index
  11591. * @returns a trigger name
  11592. */
  11593. static GetTriggerName(trigger: number): string;
  11594. }
  11595. }
  11596. declare module BABYLON {
  11597. /**
  11598. * Class representing a ray with position and direction
  11599. */
  11600. export class Ray {
  11601. /** origin point */
  11602. origin: Vector3;
  11603. /** direction */
  11604. direction: Vector3;
  11605. /** length of the ray */
  11606. length: number;
  11607. private static readonly TmpVector3;
  11608. private _tmpRay;
  11609. /**
  11610. * Creates a new ray
  11611. * @param origin origin point
  11612. * @param direction direction
  11613. * @param length length of the ray
  11614. */
  11615. constructor(
  11616. /** origin point */
  11617. origin: Vector3,
  11618. /** direction */
  11619. direction: Vector3,
  11620. /** length of the ray */
  11621. length?: number);
  11622. /**
  11623. * Checks if the ray intersects a box
  11624. * @param minimum bound of the box
  11625. * @param maximum bound of the box
  11626. * @param intersectionTreshold extra extend to be added to the box in all direction
  11627. * @returns if the box was hit
  11628. */
  11629. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11630. /**
  11631. * Checks if the ray intersects a box
  11632. * @param box the bounding box to check
  11633. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11634. * @returns if the box was hit
  11635. */
  11636. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11637. /**
  11638. * If the ray hits a sphere
  11639. * @param sphere the bounding sphere to check
  11640. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11641. * @returns true if it hits the sphere
  11642. */
  11643. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11644. /**
  11645. * If the ray hits a triange
  11646. * @param vertex0 triangle vertex
  11647. * @param vertex1 triangle vertex
  11648. * @param vertex2 triangle vertex
  11649. * @returns intersection information if hit
  11650. */
  11651. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11652. /**
  11653. * Checks if ray intersects a plane
  11654. * @param plane the plane to check
  11655. * @returns the distance away it was hit
  11656. */
  11657. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11658. /**
  11659. * Checks if ray intersects a mesh
  11660. * @param mesh the mesh to check
  11661. * @param fastCheck if only the bounding box should checked
  11662. * @returns picking info of the intersecton
  11663. */
  11664. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11665. /**
  11666. * Checks if ray intersects a mesh
  11667. * @param meshes the meshes to check
  11668. * @param fastCheck if only the bounding box should checked
  11669. * @param results array to store result in
  11670. * @returns Array of picking infos
  11671. */
  11672. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11673. private _comparePickingInfo;
  11674. private static smallnum;
  11675. private static rayl;
  11676. /**
  11677. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11678. * @param sega the first point of the segment to test the intersection against
  11679. * @param segb the second point of the segment to test the intersection against
  11680. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11681. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11682. */
  11683. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11684. /**
  11685. * Update the ray from viewport position
  11686. * @param x position
  11687. * @param y y position
  11688. * @param viewportWidth viewport width
  11689. * @param viewportHeight viewport height
  11690. * @param world world matrix
  11691. * @param view view matrix
  11692. * @param projection projection matrix
  11693. * @returns this ray updated
  11694. */
  11695. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11696. /**
  11697. * Creates a ray with origin and direction of 0,0,0
  11698. * @returns the new ray
  11699. */
  11700. static Zero(): Ray;
  11701. /**
  11702. * Creates a new ray from screen space and viewport
  11703. * @param x position
  11704. * @param y y position
  11705. * @param viewportWidth viewport width
  11706. * @param viewportHeight viewport height
  11707. * @param world world matrix
  11708. * @param view view matrix
  11709. * @param projection projection matrix
  11710. * @returns new ray
  11711. */
  11712. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11713. /**
  11714. * 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
  11715. * transformed to the given world matrix.
  11716. * @param origin The origin point
  11717. * @param end The end point
  11718. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11719. * @returns the new ray
  11720. */
  11721. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11722. /**
  11723. * Transforms a ray by a matrix
  11724. * @param ray ray to transform
  11725. * @param matrix matrix to apply
  11726. * @returns the resulting new ray
  11727. */
  11728. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11729. /**
  11730. * Transforms a ray by a matrix
  11731. * @param ray ray to transform
  11732. * @param matrix matrix to apply
  11733. * @param result ray to store result in
  11734. */
  11735. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11736. /**
  11737. * Unproject a ray from screen space to object space
  11738. * @param sourceX defines the screen space x coordinate to use
  11739. * @param sourceY defines the screen space y coordinate to use
  11740. * @param viewportWidth defines the current width of the viewport
  11741. * @param viewportHeight defines the current height of the viewport
  11742. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11743. * @param view defines the view matrix to use
  11744. * @param projection defines the projection matrix to use
  11745. */
  11746. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11747. }
  11748. /**
  11749. * Type used to define predicate used to select faces when a mesh intersection is detected
  11750. */
  11751. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11752. interface Scene {
  11753. /** @hidden */
  11754. _tempPickingRay: Nullable<Ray>;
  11755. /** @hidden */
  11756. _cachedRayForTransform: Ray;
  11757. /** @hidden */
  11758. _pickWithRayInverseMatrix: Matrix;
  11759. /** @hidden */
  11760. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11761. /** @hidden */
  11762. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11763. }
  11764. }
  11765. declare module BABYLON {
  11766. /**
  11767. * Groups all the scene component constants in one place to ease maintenance.
  11768. * @hidden
  11769. */
  11770. export class SceneComponentConstants {
  11771. static readonly NAME_EFFECTLAYER: string;
  11772. static readonly NAME_LAYER: string;
  11773. static readonly NAME_LENSFLARESYSTEM: string;
  11774. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11775. static readonly NAME_PARTICLESYSTEM: string;
  11776. static readonly NAME_GAMEPAD: string;
  11777. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11778. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11779. static readonly NAME_DEPTHRENDERER: string;
  11780. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11781. static readonly NAME_SPRITE: string;
  11782. static readonly NAME_OUTLINERENDERER: string;
  11783. static readonly NAME_PROCEDURALTEXTURE: string;
  11784. static readonly NAME_SHADOWGENERATOR: string;
  11785. static readonly NAME_OCTREE: string;
  11786. static readonly NAME_PHYSICSENGINE: string;
  11787. static readonly NAME_AUDIO: string;
  11788. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11789. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11790. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11791. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11792. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11793. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11794. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11795. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11796. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11797. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11798. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11799. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11800. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11801. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11802. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11803. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11804. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11805. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11806. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11807. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11808. static readonly STEP_AFTERRENDER_AUDIO: number;
  11809. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11810. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11811. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11812. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11813. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11814. static readonly STEP_POINTERMOVE_SPRITE: number;
  11815. static readonly STEP_POINTERDOWN_SPRITE: number;
  11816. static readonly STEP_POINTERUP_SPRITE: number;
  11817. }
  11818. /**
  11819. * This represents a scene component.
  11820. *
  11821. * This is used to decouple the dependency the scene is having on the different workloads like
  11822. * layers, post processes...
  11823. */
  11824. export interface ISceneComponent {
  11825. /**
  11826. * The name of the component. Each component must have a unique name.
  11827. */
  11828. name: string;
  11829. /**
  11830. * The scene the component belongs to.
  11831. */
  11832. scene: Scene;
  11833. /**
  11834. * Register the component to one instance of a scene.
  11835. */
  11836. register(): void;
  11837. /**
  11838. * Rebuilds the elements related to this component in case of
  11839. * context lost for instance.
  11840. */
  11841. rebuild(): void;
  11842. /**
  11843. * Disposes the component and the associated ressources.
  11844. */
  11845. dispose(): void;
  11846. }
  11847. /**
  11848. * This represents a SERIALIZABLE scene component.
  11849. *
  11850. * This extends Scene Component to add Serialization methods on top.
  11851. */
  11852. export interface ISceneSerializableComponent extends ISceneComponent {
  11853. /**
  11854. * Adds all the elements from the container to the scene
  11855. * @param container the container holding the elements
  11856. */
  11857. addFromContainer(container: AbstractScene): void;
  11858. /**
  11859. * Removes all the elements in the container from the scene
  11860. * @param container contains the elements to remove
  11861. * @param dispose if the removed element should be disposed (default: false)
  11862. */
  11863. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11864. /**
  11865. * Serializes the component data to the specified json object
  11866. * @param serializationObject The object to serialize to
  11867. */
  11868. serialize(serializationObject: any): void;
  11869. }
  11870. /**
  11871. * Strong typing of a Mesh related stage step action
  11872. */
  11873. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11874. /**
  11875. * Strong typing of a Evaluate Sub Mesh related stage step action
  11876. */
  11877. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11878. /**
  11879. * Strong typing of a Active Mesh related stage step action
  11880. */
  11881. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11882. /**
  11883. * Strong typing of a Camera related stage step action
  11884. */
  11885. export type CameraStageAction = (camera: Camera) => void;
  11886. /**
  11887. * Strong typing of a Camera Frame buffer related stage step action
  11888. */
  11889. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11890. /**
  11891. * Strong typing of a Render Target related stage step action
  11892. */
  11893. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11894. /**
  11895. * Strong typing of a RenderingGroup related stage step action
  11896. */
  11897. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11898. /**
  11899. * Strong typing of a Mesh Render related stage step action
  11900. */
  11901. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11902. /**
  11903. * Strong typing of a simple stage step action
  11904. */
  11905. export type SimpleStageAction = () => void;
  11906. /**
  11907. * Strong typing of a render target action.
  11908. */
  11909. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11910. /**
  11911. * Strong typing of a pointer move action.
  11912. */
  11913. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11914. /**
  11915. * Strong typing of a pointer up/down action.
  11916. */
  11917. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11918. /**
  11919. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11920. * @hidden
  11921. */
  11922. export class Stage<T extends Function> extends Array<{
  11923. index: number;
  11924. component: ISceneComponent;
  11925. action: T;
  11926. }> {
  11927. /**
  11928. * Hide ctor from the rest of the world.
  11929. * @param items The items to add.
  11930. */
  11931. private constructor();
  11932. /**
  11933. * Creates a new Stage.
  11934. * @returns A new instance of a Stage
  11935. */
  11936. static Create<T extends Function>(): Stage<T>;
  11937. /**
  11938. * Registers a step in an ordered way in the targeted stage.
  11939. * @param index Defines the position to register the step in
  11940. * @param component Defines the component attached to the step
  11941. * @param action Defines the action to launch during the step
  11942. */
  11943. registerStep(index: number, component: ISceneComponent, action: T): void;
  11944. /**
  11945. * Clears all the steps from the stage.
  11946. */
  11947. clear(): void;
  11948. }
  11949. }
  11950. declare module BABYLON {
  11951. interface Scene {
  11952. /** @hidden */
  11953. _pointerOverSprite: Nullable<Sprite>;
  11954. /** @hidden */
  11955. _pickedDownSprite: Nullable<Sprite>;
  11956. /** @hidden */
  11957. _tempSpritePickingRay: Nullable<Ray>;
  11958. /**
  11959. * All of the sprite managers added to this scene
  11960. * @see http://doc.babylonjs.com/babylon101/sprites
  11961. */
  11962. spriteManagers: Array<ISpriteManager>;
  11963. /**
  11964. * An event triggered when sprites rendering is about to start
  11965. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11966. */
  11967. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11968. /**
  11969. * An event triggered when sprites rendering is done
  11970. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11971. */
  11972. onAfterSpritesRenderingObservable: Observable<Scene>;
  11973. /** @hidden */
  11974. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11975. /** Launch a ray to try to pick a sprite in the scene
  11976. * @param x position on screen
  11977. * @param y position on screen
  11978. * @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
  11979. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11980. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11981. * @returns a PickingInfo
  11982. */
  11983. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11984. /** Use the given ray to pick a sprite in the scene
  11985. * @param ray The ray (in world space) to use to pick meshes
  11986. * @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
  11987. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11988. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11989. * @returns a PickingInfo
  11990. */
  11991. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11992. /**
  11993. * Force the sprite under the pointer
  11994. * @param sprite defines the sprite to use
  11995. */
  11996. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11997. /**
  11998. * Gets the sprite under the pointer
  11999. * @returns a Sprite or null if no sprite is under the pointer
  12000. */
  12001. getPointerOverSprite(): Nullable<Sprite>;
  12002. }
  12003. /**
  12004. * Defines the sprite scene component responsible to manage sprites
  12005. * in a given scene.
  12006. */
  12007. export class SpriteSceneComponent implements ISceneComponent {
  12008. /**
  12009. * The component name helpfull to identify the component in the list of scene components.
  12010. */
  12011. readonly name: string;
  12012. /**
  12013. * The scene the component belongs to.
  12014. */
  12015. scene: Scene;
  12016. /** @hidden */
  12017. private _spritePredicate;
  12018. /**
  12019. * Creates a new instance of the component for the given scene
  12020. * @param scene Defines the scene to register the component in
  12021. */
  12022. constructor(scene: Scene);
  12023. /**
  12024. * Registers the component in a given scene
  12025. */
  12026. register(): void;
  12027. /**
  12028. * Rebuilds the elements related to this component in case of
  12029. * context lost for instance.
  12030. */
  12031. rebuild(): void;
  12032. /**
  12033. * Disposes the component and the associated ressources.
  12034. */
  12035. dispose(): void;
  12036. private _pickSpriteButKeepRay;
  12037. private _pointerMove;
  12038. private _pointerDown;
  12039. private _pointerUp;
  12040. }
  12041. }
  12042. declare module BABYLON {
  12043. /** @hidden */
  12044. export var fogFragmentDeclaration: {
  12045. name: string;
  12046. shader: string;
  12047. };
  12048. }
  12049. declare module BABYLON {
  12050. /** @hidden */
  12051. export var fogFragment: {
  12052. name: string;
  12053. shader: string;
  12054. };
  12055. }
  12056. declare module BABYLON {
  12057. /** @hidden */
  12058. export var spritesPixelShader: {
  12059. name: string;
  12060. shader: string;
  12061. };
  12062. }
  12063. declare module BABYLON {
  12064. /** @hidden */
  12065. export var fogVertexDeclaration: {
  12066. name: string;
  12067. shader: string;
  12068. };
  12069. }
  12070. declare module BABYLON {
  12071. /** @hidden */
  12072. export var spritesVertexShader: {
  12073. name: string;
  12074. shader: string;
  12075. };
  12076. }
  12077. declare module BABYLON {
  12078. /**
  12079. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12080. */
  12081. export interface ISpriteManager extends IDisposable {
  12082. /**
  12083. * Restricts the camera to viewing objects with the same layerMask.
  12084. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12085. */
  12086. layerMask: number;
  12087. /**
  12088. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12089. */
  12090. isPickable: boolean;
  12091. /**
  12092. * Specifies the rendering group id for this mesh (0 by default)
  12093. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12094. */
  12095. renderingGroupId: number;
  12096. /**
  12097. * Defines the list of sprites managed by the manager.
  12098. */
  12099. sprites: Array<Sprite>;
  12100. /**
  12101. * Tests the intersection of a sprite with a specific ray.
  12102. * @param ray The ray we are sending to test the collision
  12103. * @param camera The camera space we are sending rays in
  12104. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12105. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12106. * @returns picking info or null.
  12107. */
  12108. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12109. /**
  12110. * Renders the list of sprites on screen.
  12111. */
  12112. render(): void;
  12113. }
  12114. /**
  12115. * Class used to manage multiple sprites on the same spritesheet
  12116. * @see http://doc.babylonjs.com/babylon101/sprites
  12117. */
  12118. export class SpriteManager implements ISpriteManager {
  12119. /** defines the manager's name */
  12120. name: string;
  12121. /** Gets the list of sprites */
  12122. sprites: Sprite[];
  12123. /** Gets or sets the rendering group id (0 by default) */
  12124. renderingGroupId: number;
  12125. /** Gets or sets camera layer mask */
  12126. layerMask: number;
  12127. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12128. fogEnabled: boolean;
  12129. /** Gets or sets a boolean indicating if the sprites are pickable */
  12130. isPickable: boolean;
  12131. /** Defines the default width of a cell in the spritesheet */
  12132. cellWidth: number;
  12133. /** Defines the default height of a cell in the spritesheet */
  12134. cellHeight: number;
  12135. /**
  12136. * An event triggered when the manager is disposed.
  12137. */
  12138. onDisposeObservable: Observable<SpriteManager>;
  12139. private _onDisposeObserver;
  12140. /**
  12141. * Callback called when the manager is disposed
  12142. */
  12143. onDispose: () => void;
  12144. private _capacity;
  12145. private _spriteTexture;
  12146. private _epsilon;
  12147. private _scene;
  12148. private _vertexData;
  12149. private _buffer;
  12150. private _vertexBuffers;
  12151. private _indexBuffer;
  12152. private _effectBase;
  12153. private _effectFog;
  12154. /**
  12155. * Gets or sets the spritesheet texture
  12156. */
  12157. texture: Texture;
  12158. /**
  12159. * Creates a new sprite manager
  12160. * @param name defines the manager's name
  12161. * @param imgUrl defines the sprite sheet url
  12162. * @param capacity defines the maximum allowed number of sprites
  12163. * @param cellSize defines the size of a sprite cell
  12164. * @param scene defines the hosting scene
  12165. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12166. * @param samplingMode defines the smapling mode to use with spritesheet
  12167. */
  12168. constructor(
  12169. /** defines the manager's name */
  12170. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12171. private _appendSpriteVertex;
  12172. /**
  12173. * Intersects the sprites with a ray
  12174. * @param ray defines the ray to intersect with
  12175. * @param camera defines the current active camera
  12176. * @param predicate defines a predicate used to select candidate sprites
  12177. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12178. * @returns null if no hit or a PickingInfo
  12179. */
  12180. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12181. /**
  12182. * Render all child sprites
  12183. */
  12184. render(): void;
  12185. /**
  12186. * Release associated resources
  12187. */
  12188. dispose(): void;
  12189. }
  12190. }
  12191. declare module BABYLON {
  12192. /**
  12193. * Class used to represent a sprite
  12194. * @see http://doc.babylonjs.com/babylon101/sprites
  12195. */
  12196. export class Sprite {
  12197. /** defines the name */
  12198. name: string;
  12199. /** Gets or sets the current world position */
  12200. position: Vector3;
  12201. /** Gets or sets the main color */
  12202. color: Color4;
  12203. /** Gets or sets the width */
  12204. width: number;
  12205. /** Gets or sets the height */
  12206. height: number;
  12207. /** Gets or sets rotation angle */
  12208. angle: number;
  12209. /** Gets or sets the cell index in the sprite sheet */
  12210. cellIndex: number;
  12211. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12212. invertU: number;
  12213. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12214. invertV: number;
  12215. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12216. disposeWhenFinishedAnimating: boolean;
  12217. /** Gets the list of attached animations */
  12218. animations: Animation[];
  12219. /** Gets or sets a boolean indicating if the sprite can be picked */
  12220. isPickable: boolean;
  12221. /**
  12222. * Gets or sets the associated action manager
  12223. */
  12224. actionManager: Nullable<ActionManager>;
  12225. private _animationStarted;
  12226. private _loopAnimation;
  12227. private _fromIndex;
  12228. private _toIndex;
  12229. private _delay;
  12230. private _direction;
  12231. private _manager;
  12232. private _time;
  12233. private _onAnimationEnd;
  12234. /**
  12235. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12236. */
  12237. isVisible: boolean;
  12238. /**
  12239. * Gets or sets the sprite size
  12240. */
  12241. size: number;
  12242. /**
  12243. * Creates a new Sprite
  12244. * @param name defines the name
  12245. * @param manager defines the manager
  12246. */
  12247. constructor(
  12248. /** defines the name */
  12249. name: string, manager: ISpriteManager);
  12250. /**
  12251. * Starts an animation
  12252. * @param from defines the initial key
  12253. * @param to defines the end key
  12254. * @param loop defines if the animation must loop
  12255. * @param delay defines the start delay (in ms)
  12256. * @param onAnimationEnd defines a callback to call when animation ends
  12257. */
  12258. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12259. /** Stops current animation (if any) */
  12260. stopAnimation(): void;
  12261. /** @hidden */
  12262. _animate(deltaTime: number): void;
  12263. /** Release associated resources */
  12264. dispose(): void;
  12265. }
  12266. }
  12267. declare module BABYLON {
  12268. /**
  12269. * Information about the result of picking within a scene
  12270. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12271. */
  12272. export class PickingInfo {
  12273. /** @hidden */
  12274. _pickingUnavailable: boolean;
  12275. /**
  12276. * If the pick collided with an object
  12277. */
  12278. hit: boolean;
  12279. /**
  12280. * Distance away where the pick collided
  12281. */
  12282. distance: number;
  12283. /**
  12284. * The location of pick collision
  12285. */
  12286. pickedPoint: Nullable<Vector3>;
  12287. /**
  12288. * The mesh corresponding the the pick collision
  12289. */
  12290. pickedMesh: Nullable<AbstractMesh>;
  12291. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12292. bu: number;
  12293. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12294. bv: number;
  12295. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12296. faceId: number;
  12297. /** Id of the the submesh that was picked */
  12298. subMeshId: number;
  12299. /** If a sprite was picked, this will be the sprite the pick collided with */
  12300. pickedSprite: Nullable<Sprite>;
  12301. /**
  12302. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12303. */
  12304. originMesh: Nullable<AbstractMesh>;
  12305. /**
  12306. * The ray that was used to perform the picking.
  12307. */
  12308. ray: Nullable<Ray>;
  12309. /**
  12310. * Gets the normal correspodning to the face the pick collided with
  12311. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12312. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12313. * @returns The normal correspodning to the face the pick collided with
  12314. */
  12315. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12316. /**
  12317. * Gets the texture coordinates of where the pick occured
  12318. * @returns the vector containing the coordnates of the texture
  12319. */
  12320. getTextureCoordinates(): Nullable<Vector2>;
  12321. }
  12322. }
  12323. declare module BABYLON {
  12324. /**
  12325. * Gather the list of pointer event types as constants.
  12326. */
  12327. export class PointerEventTypes {
  12328. /**
  12329. * 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.
  12330. */
  12331. static readonly POINTERDOWN: number;
  12332. /**
  12333. * The pointerup event is fired when a pointer is no longer active.
  12334. */
  12335. static readonly POINTERUP: number;
  12336. /**
  12337. * The pointermove event is fired when a pointer changes coordinates.
  12338. */
  12339. static readonly POINTERMOVE: number;
  12340. /**
  12341. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12342. */
  12343. static readonly POINTERWHEEL: number;
  12344. /**
  12345. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12346. */
  12347. static readonly POINTERPICK: number;
  12348. /**
  12349. * The pointertap event is fired when a the object has been touched and released without drag.
  12350. */
  12351. static readonly POINTERTAP: number;
  12352. /**
  12353. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12354. */
  12355. static readonly POINTERDOUBLETAP: number;
  12356. }
  12357. /**
  12358. * Base class of pointer info types.
  12359. */
  12360. export class PointerInfoBase {
  12361. /**
  12362. * Defines the type of event (PointerEventTypes)
  12363. */
  12364. type: number;
  12365. /**
  12366. * Defines the related dom event
  12367. */
  12368. event: PointerEvent | MouseWheelEvent;
  12369. /**
  12370. * Instantiates the base class of pointers info.
  12371. * @param type Defines the type of event (PointerEventTypes)
  12372. * @param event Defines the related dom event
  12373. */
  12374. constructor(
  12375. /**
  12376. * Defines the type of event (PointerEventTypes)
  12377. */
  12378. type: number,
  12379. /**
  12380. * Defines the related dom event
  12381. */
  12382. event: PointerEvent | MouseWheelEvent);
  12383. }
  12384. /**
  12385. * This class is used to store pointer related info for the onPrePointerObservable event.
  12386. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12387. */
  12388. export class PointerInfoPre extends PointerInfoBase {
  12389. /**
  12390. * Ray from a pointer if availible (eg. 6dof controller)
  12391. */
  12392. ray: Nullable<Ray>;
  12393. /**
  12394. * Defines the local position of the pointer on the canvas.
  12395. */
  12396. localPosition: Vector2;
  12397. /**
  12398. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12399. */
  12400. skipOnPointerObservable: boolean;
  12401. /**
  12402. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12403. * @param type Defines the type of event (PointerEventTypes)
  12404. * @param event Defines the related dom event
  12405. * @param localX Defines the local x coordinates of the pointer when the event occured
  12406. * @param localY Defines the local y coordinates of the pointer when the event occured
  12407. */
  12408. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12409. }
  12410. /**
  12411. * This type contains all the data related to a pointer event in Babylon.js.
  12412. * 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.
  12413. */
  12414. export class PointerInfo extends PointerInfoBase {
  12415. /**
  12416. * Defines the picking info associated to the info (if any)\
  12417. */
  12418. pickInfo: Nullable<PickingInfo>;
  12419. /**
  12420. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12421. * @param type Defines the type of event (PointerEventTypes)
  12422. * @param event Defines the related dom event
  12423. * @param pickInfo Defines the picking info associated to the info (if any)\
  12424. */
  12425. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12426. /**
  12427. * Defines the picking info associated to the info (if any)\
  12428. */
  12429. pickInfo: Nullable<PickingInfo>);
  12430. }
  12431. /**
  12432. * Data relating to a touch event on the screen.
  12433. */
  12434. export interface PointerTouch {
  12435. /**
  12436. * X coordinate of touch.
  12437. */
  12438. x: number;
  12439. /**
  12440. * Y coordinate of touch.
  12441. */
  12442. y: number;
  12443. /**
  12444. * Id of touch. Unique for each finger.
  12445. */
  12446. pointerId: number;
  12447. /**
  12448. * Event type passed from DOM.
  12449. */
  12450. type: any;
  12451. }
  12452. }
  12453. declare module BABYLON {
  12454. /**
  12455. * Manage the mouse inputs to control the movement of a free camera.
  12456. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12457. */
  12458. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12459. /**
  12460. * Define if touch is enabled in the mouse input
  12461. */
  12462. touchEnabled: boolean;
  12463. /**
  12464. * Defines the camera the input is attached to.
  12465. */
  12466. camera: FreeCamera;
  12467. /**
  12468. * Defines the buttons associated with the input to handle camera move.
  12469. */
  12470. buttons: number[];
  12471. /**
  12472. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12473. */
  12474. angularSensibility: number;
  12475. private _pointerInput;
  12476. private _onMouseMove;
  12477. private _observer;
  12478. private previousPosition;
  12479. /**
  12480. * Observable for when a pointer move event occurs containing the move offset
  12481. */
  12482. onPointerMovedObservable: Observable<{
  12483. offsetX: number;
  12484. offsetY: number;
  12485. }>;
  12486. /**
  12487. * @hidden
  12488. * If the camera should be rotated automatically based on pointer movement
  12489. */
  12490. _allowCameraRotation: boolean;
  12491. /**
  12492. * Manage the mouse inputs to control the movement of a free camera.
  12493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12494. * @param touchEnabled Defines if touch is enabled or not
  12495. */
  12496. constructor(
  12497. /**
  12498. * Define if touch is enabled in the mouse input
  12499. */
  12500. touchEnabled?: boolean);
  12501. /**
  12502. * Attach the input controls to a specific dom element to get the input from.
  12503. * @param element Defines the element the controls should be listened from
  12504. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12505. */
  12506. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12507. /**
  12508. * Called on JS contextmenu event.
  12509. * Override this method to provide functionality.
  12510. */
  12511. protected onContextMenu(evt: PointerEvent): void;
  12512. /**
  12513. * Detach the current controls from the specified dom element.
  12514. * @param element Defines the element to stop listening the inputs from
  12515. */
  12516. detachControl(element: Nullable<HTMLElement>): void;
  12517. /**
  12518. * Gets the class name of the current intput.
  12519. * @returns the class name
  12520. */
  12521. getClassName(): string;
  12522. /**
  12523. * Get the friendly name associated with the input class.
  12524. * @returns the input friendly name
  12525. */
  12526. getSimpleName(): string;
  12527. }
  12528. }
  12529. declare module BABYLON {
  12530. /**
  12531. * Manage the touch inputs to control the movement of a free camera.
  12532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12533. */
  12534. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12535. /**
  12536. * Defines the camera the input is attached to.
  12537. */
  12538. camera: FreeCamera;
  12539. /**
  12540. * Defines the touch sensibility for rotation.
  12541. * The higher the faster.
  12542. */
  12543. touchAngularSensibility: number;
  12544. /**
  12545. * Defines the touch sensibility for move.
  12546. * The higher the faster.
  12547. */
  12548. touchMoveSensibility: number;
  12549. private _offsetX;
  12550. private _offsetY;
  12551. private _pointerPressed;
  12552. private _pointerInput;
  12553. private _observer;
  12554. private _onLostFocus;
  12555. /**
  12556. * Attach the input controls to a specific dom element to get the input from.
  12557. * @param element Defines the element the controls should be listened from
  12558. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12559. */
  12560. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12561. /**
  12562. * Detach the current controls from the specified dom element.
  12563. * @param element Defines the element to stop listening the inputs from
  12564. */
  12565. detachControl(element: Nullable<HTMLElement>): void;
  12566. /**
  12567. * Update the current camera state depending on the inputs that have been used this frame.
  12568. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12569. */
  12570. checkInputs(): void;
  12571. /**
  12572. * Gets the class name of the current intput.
  12573. * @returns the class name
  12574. */
  12575. getClassName(): string;
  12576. /**
  12577. * Get the friendly name associated with the input class.
  12578. * @returns the input friendly name
  12579. */
  12580. getSimpleName(): string;
  12581. }
  12582. }
  12583. declare module BABYLON {
  12584. /**
  12585. * Default Inputs manager for the FreeCamera.
  12586. * It groups all the default supported inputs for ease of use.
  12587. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12588. */
  12589. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12590. /**
  12591. * @hidden
  12592. */
  12593. _mouseInput: Nullable<FreeCameraMouseInput>;
  12594. /**
  12595. * Instantiates a new FreeCameraInputsManager.
  12596. * @param camera Defines the camera the inputs belong to
  12597. */
  12598. constructor(camera: FreeCamera);
  12599. /**
  12600. * Add keyboard input support to the input manager.
  12601. * @returns the current input manager
  12602. */
  12603. addKeyboard(): FreeCameraInputsManager;
  12604. /**
  12605. * Add mouse input support to the input manager.
  12606. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12607. * @returns the current input manager
  12608. */
  12609. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12610. /**
  12611. * Removes the mouse input support from the manager
  12612. * @returns the current input manager
  12613. */
  12614. removeMouse(): FreeCameraInputsManager;
  12615. /**
  12616. * Add touch input support to the input manager.
  12617. * @returns the current input manager
  12618. */
  12619. addTouch(): FreeCameraInputsManager;
  12620. /**
  12621. * Remove all attached input methods from a camera
  12622. */
  12623. clear(): void;
  12624. }
  12625. }
  12626. declare module BABYLON {
  12627. /**
  12628. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12629. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12630. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12631. */
  12632. export class FreeCamera extends TargetCamera {
  12633. /**
  12634. * Define the collision ellipsoid of the camera.
  12635. * This is helpful to simulate a camera body like the player body around the camera
  12636. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12637. */
  12638. ellipsoid: Vector3;
  12639. /**
  12640. * Define an offset for the position of the ellipsoid around the camera.
  12641. * This can be helpful to determine the center of the body near the gravity center of the body
  12642. * instead of its head.
  12643. */
  12644. ellipsoidOffset: Vector3;
  12645. /**
  12646. * Enable or disable collisions of the camera with the rest of the scene objects.
  12647. */
  12648. checkCollisions: boolean;
  12649. /**
  12650. * Enable or disable gravity on the camera.
  12651. */
  12652. applyGravity: boolean;
  12653. /**
  12654. * Define the input manager associated to the camera.
  12655. */
  12656. inputs: FreeCameraInputsManager;
  12657. /**
  12658. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12659. * Higher values reduce sensitivity.
  12660. */
  12661. /**
  12662. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12663. * Higher values reduce sensitivity.
  12664. */
  12665. angularSensibility: number;
  12666. /**
  12667. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12668. */
  12669. keysUp: number[];
  12670. /**
  12671. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12672. */
  12673. keysDown: number[];
  12674. /**
  12675. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12676. */
  12677. keysLeft: number[];
  12678. /**
  12679. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12680. */
  12681. keysRight: number[];
  12682. /**
  12683. * Event raised when the camera collide with a mesh in the scene.
  12684. */
  12685. onCollide: (collidedMesh: AbstractMesh) => void;
  12686. private _collider;
  12687. private _needMoveForGravity;
  12688. private _oldPosition;
  12689. private _diffPosition;
  12690. private _newPosition;
  12691. /** @hidden */
  12692. _localDirection: Vector3;
  12693. /** @hidden */
  12694. _transformedDirection: Vector3;
  12695. /**
  12696. * Instantiates a Free Camera.
  12697. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12698. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12699. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12700. * @param name Define the name of the camera in the scene
  12701. * @param position Define the start position of the camera in the scene
  12702. * @param scene Define the scene the camera belongs to
  12703. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12704. */
  12705. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12706. /**
  12707. * Attached controls to the current camera.
  12708. * @param element Defines the element the controls should be listened from
  12709. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12710. */
  12711. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12712. /**
  12713. * Detach the current controls from the camera.
  12714. * The camera will stop reacting to inputs.
  12715. * @param element Defines the element to stop listening the inputs from
  12716. */
  12717. detachControl(element: HTMLElement): void;
  12718. private _collisionMask;
  12719. /**
  12720. * Define a collision mask to limit the list of object the camera can collide with
  12721. */
  12722. collisionMask: number;
  12723. /** @hidden */
  12724. _collideWithWorld(displacement: Vector3): void;
  12725. private _onCollisionPositionChange;
  12726. /** @hidden */
  12727. _checkInputs(): void;
  12728. /** @hidden */
  12729. _decideIfNeedsToMove(): boolean;
  12730. /** @hidden */
  12731. _updatePosition(): void;
  12732. /**
  12733. * Destroy the camera and release the current resources hold by it.
  12734. */
  12735. dispose(): void;
  12736. /**
  12737. * Gets the current object class name.
  12738. * @return the class name
  12739. */
  12740. getClassName(): string;
  12741. }
  12742. }
  12743. declare module BABYLON {
  12744. /**
  12745. * Represents a gamepad control stick position
  12746. */
  12747. export class StickValues {
  12748. /**
  12749. * The x component of the control stick
  12750. */
  12751. x: number;
  12752. /**
  12753. * The y component of the control stick
  12754. */
  12755. y: number;
  12756. /**
  12757. * Initializes the gamepad x and y control stick values
  12758. * @param x The x component of the gamepad control stick value
  12759. * @param y The y component of the gamepad control stick value
  12760. */
  12761. constructor(
  12762. /**
  12763. * The x component of the control stick
  12764. */
  12765. x: number,
  12766. /**
  12767. * The y component of the control stick
  12768. */
  12769. y: number);
  12770. }
  12771. /**
  12772. * An interface which manages callbacks for gamepad button changes
  12773. */
  12774. export interface GamepadButtonChanges {
  12775. /**
  12776. * Called when a gamepad has been changed
  12777. */
  12778. changed: boolean;
  12779. /**
  12780. * Called when a gamepad press event has been triggered
  12781. */
  12782. pressChanged: boolean;
  12783. /**
  12784. * Called when a touch event has been triggered
  12785. */
  12786. touchChanged: boolean;
  12787. /**
  12788. * Called when a value has changed
  12789. */
  12790. valueChanged: boolean;
  12791. }
  12792. /**
  12793. * Represents a gamepad
  12794. */
  12795. export class Gamepad {
  12796. /**
  12797. * The id of the gamepad
  12798. */
  12799. id: string;
  12800. /**
  12801. * The index of the gamepad
  12802. */
  12803. index: number;
  12804. /**
  12805. * The browser gamepad
  12806. */
  12807. browserGamepad: any;
  12808. /**
  12809. * Specifies what type of gamepad this represents
  12810. */
  12811. type: number;
  12812. private _leftStick;
  12813. private _rightStick;
  12814. /** @hidden */
  12815. _isConnected: boolean;
  12816. private _leftStickAxisX;
  12817. private _leftStickAxisY;
  12818. private _rightStickAxisX;
  12819. private _rightStickAxisY;
  12820. /**
  12821. * Triggered when the left control stick has been changed
  12822. */
  12823. private _onleftstickchanged;
  12824. /**
  12825. * Triggered when the right control stick has been changed
  12826. */
  12827. private _onrightstickchanged;
  12828. /**
  12829. * Represents a gamepad controller
  12830. */
  12831. static GAMEPAD: number;
  12832. /**
  12833. * Represents a generic controller
  12834. */
  12835. static GENERIC: number;
  12836. /**
  12837. * Represents an XBox controller
  12838. */
  12839. static XBOX: number;
  12840. /**
  12841. * Represents a pose-enabled controller
  12842. */
  12843. static POSE_ENABLED: number;
  12844. /**
  12845. * Specifies whether the left control stick should be Y-inverted
  12846. */
  12847. protected _invertLeftStickY: boolean;
  12848. /**
  12849. * Specifies if the gamepad has been connected
  12850. */
  12851. readonly isConnected: boolean;
  12852. /**
  12853. * Initializes the gamepad
  12854. * @param id The id of the gamepad
  12855. * @param index The index of the gamepad
  12856. * @param browserGamepad The browser gamepad
  12857. * @param leftStickX The x component of the left joystick
  12858. * @param leftStickY The y component of the left joystick
  12859. * @param rightStickX The x component of the right joystick
  12860. * @param rightStickY The y component of the right joystick
  12861. */
  12862. constructor(
  12863. /**
  12864. * The id of the gamepad
  12865. */
  12866. id: string,
  12867. /**
  12868. * The index of the gamepad
  12869. */
  12870. index: number,
  12871. /**
  12872. * The browser gamepad
  12873. */
  12874. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12875. /**
  12876. * Callback triggered when the left joystick has changed
  12877. * @param callback
  12878. */
  12879. onleftstickchanged(callback: (values: StickValues) => void): void;
  12880. /**
  12881. * Callback triggered when the right joystick has changed
  12882. * @param callback
  12883. */
  12884. onrightstickchanged(callback: (values: StickValues) => void): void;
  12885. /**
  12886. * Gets the left joystick
  12887. */
  12888. /**
  12889. * Sets the left joystick values
  12890. */
  12891. leftStick: StickValues;
  12892. /**
  12893. * Gets the right joystick
  12894. */
  12895. /**
  12896. * Sets the right joystick value
  12897. */
  12898. rightStick: StickValues;
  12899. /**
  12900. * Updates the gamepad joystick positions
  12901. */
  12902. update(): void;
  12903. /**
  12904. * Disposes the gamepad
  12905. */
  12906. dispose(): void;
  12907. }
  12908. /**
  12909. * Represents a generic gamepad
  12910. */
  12911. export class GenericPad extends Gamepad {
  12912. private _buttons;
  12913. private _onbuttondown;
  12914. private _onbuttonup;
  12915. /**
  12916. * Observable triggered when a button has been pressed
  12917. */
  12918. onButtonDownObservable: Observable<number>;
  12919. /**
  12920. * Observable triggered when a button has been released
  12921. */
  12922. onButtonUpObservable: Observable<number>;
  12923. /**
  12924. * Callback triggered when a button has been pressed
  12925. * @param callback Called when a button has been pressed
  12926. */
  12927. onbuttondown(callback: (buttonPressed: number) => void): void;
  12928. /**
  12929. * Callback triggered when a button has been released
  12930. * @param callback Called when a button has been released
  12931. */
  12932. onbuttonup(callback: (buttonReleased: number) => void): void;
  12933. /**
  12934. * Initializes the generic gamepad
  12935. * @param id The id of the generic gamepad
  12936. * @param index The index of the generic gamepad
  12937. * @param browserGamepad The browser gamepad
  12938. */
  12939. constructor(id: string, index: number, browserGamepad: any);
  12940. private _setButtonValue;
  12941. /**
  12942. * Updates the generic gamepad
  12943. */
  12944. update(): void;
  12945. /**
  12946. * Disposes the generic gamepad
  12947. */
  12948. dispose(): void;
  12949. }
  12950. }
  12951. declare module BABYLON {
  12952. /**
  12953. * Defines the types of pose enabled controllers that are supported
  12954. */
  12955. export enum PoseEnabledControllerType {
  12956. /**
  12957. * HTC Vive
  12958. */
  12959. VIVE = 0,
  12960. /**
  12961. * Oculus Rift
  12962. */
  12963. OCULUS = 1,
  12964. /**
  12965. * Windows mixed reality
  12966. */
  12967. WINDOWS = 2,
  12968. /**
  12969. * Samsung gear VR
  12970. */
  12971. GEAR_VR = 3,
  12972. /**
  12973. * Google Daydream
  12974. */
  12975. DAYDREAM = 4,
  12976. /**
  12977. * Generic
  12978. */
  12979. GENERIC = 5
  12980. }
  12981. /**
  12982. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12983. */
  12984. export interface MutableGamepadButton {
  12985. /**
  12986. * Value of the button/trigger
  12987. */
  12988. value: number;
  12989. /**
  12990. * If the button/trigger is currently touched
  12991. */
  12992. touched: boolean;
  12993. /**
  12994. * If the button/trigger is currently pressed
  12995. */
  12996. pressed: boolean;
  12997. }
  12998. /**
  12999. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13000. * @hidden
  13001. */
  13002. export interface ExtendedGamepadButton extends GamepadButton {
  13003. /**
  13004. * If the button/trigger is currently pressed
  13005. */
  13006. readonly pressed: boolean;
  13007. /**
  13008. * If the button/trigger is currently touched
  13009. */
  13010. readonly touched: boolean;
  13011. /**
  13012. * Value of the button/trigger
  13013. */
  13014. readonly value: number;
  13015. }
  13016. /** @hidden */
  13017. export interface _GamePadFactory {
  13018. /**
  13019. * Returns wether or not the current gamepad can be created for this type of controller.
  13020. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13021. * @returns true if it can be created, otherwise false
  13022. */
  13023. canCreate(gamepadInfo: any): boolean;
  13024. /**
  13025. * Creates a new instance of the Gamepad.
  13026. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13027. * @returns the new gamepad instance
  13028. */
  13029. create(gamepadInfo: any): Gamepad;
  13030. }
  13031. /**
  13032. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13033. */
  13034. export class PoseEnabledControllerHelper {
  13035. /** @hidden */
  13036. static _ControllerFactories: _GamePadFactory[];
  13037. /** @hidden */
  13038. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13039. /**
  13040. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13041. * @param vrGamepad the gamepad to initialized
  13042. * @returns a vr controller of the type the gamepad identified as
  13043. */
  13044. static InitiateController(vrGamepad: any): Gamepad;
  13045. }
  13046. /**
  13047. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13048. */
  13049. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13050. private _deviceRoomPosition;
  13051. private _deviceRoomRotationQuaternion;
  13052. /**
  13053. * The device position in babylon space
  13054. */
  13055. devicePosition: Vector3;
  13056. /**
  13057. * The device rotation in babylon space
  13058. */
  13059. deviceRotationQuaternion: Quaternion;
  13060. /**
  13061. * The scale factor of the device in babylon space
  13062. */
  13063. deviceScaleFactor: number;
  13064. /**
  13065. * (Likely devicePosition should be used instead) The device position in its room space
  13066. */
  13067. position: Vector3;
  13068. /**
  13069. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13070. */
  13071. rotationQuaternion: Quaternion;
  13072. /**
  13073. * The type of controller (Eg. Windows mixed reality)
  13074. */
  13075. controllerType: PoseEnabledControllerType;
  13076. protected _calculatedPosition: Vector3;
  13077. private _calculatedRotation;
  13078. /**
  13079. * The raw pose from the device
  13080. */
  13081. rawPose: DevicePose;
  13082. private _trackPosition;
  13083. private _maxRotationDistFromHeadset;
  13084. private _draggedRoomRotation;
  13085. /**
  13086. * @hidden
  13087. */
  13088. _disableTrackPosition(fixedPosition: Vector3): void;
  13089. /**
  13090. * Internal, the mesh attached to the controller
  13091. * @hidden
  13092. */
  13093. _mesh: Nullable<AbstractMesh>;
  13094. private _poseControlledCamera;
  13095. private _leftHandSystemQuaternion;
  13096. /**
  13097. * Internal, matrix used to convert room space to babylon space
  13098. * @hidden
  13099. */
  13100. _deviceToWorld: Matrix;
  13101. /**
  13102. * Node to be used when casting a ray from the controller
  13103. * @hidden
  13104. */
  13105. _pointingPoseNode: Nullable<TransformNode>;
  13106. /**
  13107. * Name of the child mesh that can be used to cast a ray from the controller
  13108. */
  13109. static readonly POINTING_POSE: string;
  13110. /**
  13111. * Creates a new PoseEnabledController from a gamepad
  13112. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13113. */
  13114. constructor(browserGamepad: any);
  13115. private _workingMatrix;
  13116. /**
  13117. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13118. */
  13119. update(): void;
  13120. /**
  13121. * Updates only the pose device and mesh without doing any button event checking
  13122. */
  13123. protected _updatePoseAndMesh(): void;
  13124. /**
  13125. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13126. * @param poseData raw pose fromthe device
  13127. */
  13128. updateFromDevice(poseData: DevicePose): void;
  13129. /**
  13130. * @hidden
  13131. */
  13132. _meshAttachedObservable: Observable<AbstractMesh>;
  13133. /**
  13134. * Attaches a mesh to the controller
  13135. * @param mesh the mesh to be attached
  13136. */
  13137. attachToMesh(mesh: AbstractMesh): void;
  13138. /**
  13139. * Attaches the controllers mesh to a camera
  13140. * @param camera the camera the mesh should be attached to
  13141. */
  13142. attachToPoseControlledCamera(camera: TargetCamera): void;
  13143. /**
  13144. * Disposes of the controller
  13145. */
  13146. dispose(): void;
  13147. /**
  13148. * The mesh that is attached to the controller
  13149. */
  13150. readonly mesh: Nullable<AbstractMesh>;
  13151. /**
  13152. * Gets the ray of the controller in the direction the controller is pointing
  13153. * @param length the length the resulting ray should be
  13154. * @returns a ray in the direction the controller is pointing
  13155. */
  13156. getForwardRay(length?: number): Ray;
  13157. }
  13158. }
  13159. declare module BABYLON {
  13160. /**
  13161. * Defines the WebVRController object that represents controllers tracked in 3D space
  13162. */
  13163. export abstract class WebVRController extends PoseEnabledController {
  13164. /**
  13165. * Internal, the default controller model for the controller
  13166. */
  13167. protected _defaultModel: AbstractMesh;
  13168. /**
  13169. * Fired when the trigger state has changed
  13170. */
  13171. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13172. /**
  13173. * Fired when the main button state has changed
  13174. */
  13175. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13176. /**
  13177. * Fired when the secondary button state has changed
  13178. */
  13179. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13180. /**
  13181. * Fired when the pad state has changed
  13182. */
  13183. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13184. /**
  13185. * Fired when controllers stick values have changed
  13186. */
  13187. onPadValuesChangedObservable: Observable<StickValues>;
  13188. /**
  13189. * Array of button availible on the controller
  13190. */
  13191. protected _buttons: Array<MutableGamepadButton>;
  13192. private _onButtonStateChange;
  13193. /**
  13194. * Fired when a controller button's state has changed
  13195. * @param callback the callback containing the button that was modified
  13196. */
  13197. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13198. /**
  13199. * X and Y axis corrisponding to the controllers joystick
  13200. */
  13201. pad: StickValues;
  13202. /**
  13203. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13204. */
  13205. hand: string;
  13206. /**
  13207. * The default controller model for the controller
  13208. */
  13209. readonly defaultModel: AbstractMesh;
  13210. /**
  13211. * Creates a new WebVRController from a gamepad
  13212. * @param vrGamepad the gamepad that the WebVRController should be created from
  13213. */
  13214. constructor(vrGamepad: any);
  13215. /**
  13216. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13217. */
  13218. update(): void;
  13219. /**
  13220. * Function to be called when a button is modified
  13221. */
  13222. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13223. /**
  13224. * Loads a mesh and attaches it to the controller
  13225. * @param scene the scene the mesh should be added to
  13226. * @param meshLoaded callback for when the mesh has been loaded
  13227. */
  13228. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13229. private _setButtonValue;
  13230. private _changes;
  13231. private _checkChanges;
  13232. /**
  13233. * Disposes of th webVRCOntroller
  13234. */
  13235. dispose(): void;
  13236. }
  13237. }
  13238. declare module BABYLON {
  13239. /**
  13240. * The HemisphericLight simulates the ambient environment light,
  13241. * so the passed direction is the light reflection direction, not the incoming direction.
  13242. */
  13243. export class HemisphericLight extends Light {
  13244. /**
  13245. * The groundColor is the light in the opposite direction to the one specified during creation.
  13246. * 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.
  13247. */
  13248. groundColor: Color3;
  13249. /**
  13250. * The light reflection direction, not the incoming direction.
  13251. */
  13252. direction: Vector3;
  13253. /**
  13254. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13255. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13256. * The HemisphericLight can't cast shadows.
  13257. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13258. * @param name The friendly name of the light
  13259. * @param direction The direction of the light reflection
  13260. * @param scene The scene the light belongs to
  13261. */
  13262. constructor(name: string, direction: Vector3, scene: Scene);
  13263. protected _buildUniformLayout(): void;
  13264. /**
  13265. * Returns the string "HemisphericLight".
  13266. * @return The class name
  13267. */
  13268. getClassName(): string;
  13269. /**
  13270. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13271. * Returns the updated direction.
  13272. * @param target The target the direction should point to
  13273. * @return The computed direction
  13274. */
  13275. setDirectionToTarget(target: Vector3): Vector3;
  13276. /**
  13277. * Returns the shadow generator associated to the light.
  13278. * @returns Always null for hemispheric lights because it does not support shadows.
  13279. */
  13280. getShadowGenerator(): Nullable<IShadowGenerator>;
  13281. /**
  13282. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13283. * @param effect The effect to update
  13284. * @param lightIndex The index of the light in the effect to update
  13285. * @returns The hemispheric light
  13286. */
  13287. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13288. /**
  13289. * Computes the world matrix of the node
  13290. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13291. * @param useWasUpdatedFlag defines a reserved property
  13292. * @returns the world matrix
  13293. */
  13294. computeWorldMatrix(): Matrix;
  13295. /**
  13296. * Returns the integer 3.
  13297. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13298. */
  13299. getTypeID(): number;
  13300. /**
  13301. * Prepares the list of defines specific to the light type.
  13302. * @param defines the list of defines
  13303. * @param lightIndex defines the index of the light for the effect
  13304. */
  13305. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13306. }
  13307. }
  13308. declare module BABYLON {
  13309. /** @hidden */
  13310. export var vrMultiviewToSingleviewPixelShader: {
  13311. name: string;
  13312. shader: string;
  13313. };
  13314. }
  13315. declare module BABYLON {
  13316. /**
  13317. * Renders to multiple views with a single draw call
  13318. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13319. */
  13320. export class MultiviewRenderTarget extends RenderTargetTexture {
  13321. /**
  13322. * Creates a multiview render target
  13323. * @param scene scene used with the render target
  13324. * @param size the size of the render target (used for each view)
  13325. */
  13326. constructor(scene: Scene, size?: number | {
  13327. width: number;
  13328. height: number;
  13329. } | {
  13330. ratio: number;
  13331. });
  13332. /**
  13333. * @hidden
  13334. * @param faceIndex the face index, if its a cube texture
  13335. */
  13336. _bindFrameBuffer(faceIndex?: number): void;
  13337. /**
  13338. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13339. * @returns the view count
  13340. */
  13341. getViewCount(): number;
  13342. }
  13343. }
  13344. declare module BABYLON {
  13345. interface Engine {
  13346. /**
  13347. * Creates a new multiview render target
  13348. * @param width defines the width of the texture
  13349. * @param height defines the height of the texture
  13350. * @returns the created multiview texture
  13351. */
  13352. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13353. /**
  13354. * Binds a multiview framebuffer to be drawn to
  13355. * @param multiviewTexture texture to bind
  13356. */
  13357. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13358. }
  13359. interface Camera {
  13360. /**
  13361. * @hidden
  13362. * 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)
  13363. */
  13364. _useMultiviewToSingleView: boolean;
  13365. /**
  13366. * @hidden
  13367. * 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)
  13368. */
  13369. _multiviewTexture: Nullable<RenderTargetTexture>;
  13370. /**
  13371. * @hidden
  13372. * ensures the multiview texture of the camera exists and has the specified width/height
  13373. * @param width height to set on the multiview texture
  13374. * @param height width to set on the multiview texture
  13375. */
  13376. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13377. }
  13378. interface Scene {
  13379. /** @hidden */
  13380. _transformMatrixR: Matrix;
  13381. /** @hidden */
  13382. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13383. /** @hidden */
  13384. _createMultiviewUbo(): void;
  13385. /** @hidden */
  13386. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13387. /** @hidden */
  13388. _renderMultiviewToSingleView(camera: Camera): void;
  13389. }
  13390. }
  13391. declare module BABYLON {
  13392. /**
  13393. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13394. * This will not be used for webXR as it supports displaying texture arrays directly
  13395. */
  13396. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13397. /**
  13398. * Initializes a VRMultiviewToSingleview
  13399. * @param name name of the post process
  13400. * @param camera camera to be applied to
  13401. * @param scaleFactor scaling factor to the size of the output texture
  13402. */
  13403. constructor(name: string, camera: Camera, scaleFactor: number);
  13404. }
  13405. }
  13406. declare module BABYLON {
  13407. interface Engine {
  13408. /** @hidden */
  13409. _vrDisplay: any;
  13410. /** @hidden */
  13411. _vrSupported: boolean;
  13412. /** @hidden */
  13413. _oldSize: Size;
  13414. /** @hidden */
  13415. _oldHardwareScaleFactor: number;
  13416. /** @hidden */
  13417. _vrExclusivePointerMode: boolean;
  13418. /** @hidden */
  13419. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13420. /** @hidden */
  13421. _onVRDisplayPointerRestricted: () => void;
  13422. /** @hidden */
  13423. _onVRDisplayPointerUnrestricted: () => void;
  13424. /** @hidden */
  13425. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13426. /** @hidden */
  13427. _onVrDisplayDisconnect: Nullable<() => void>;
  13428. /** @hidden */
  13429. _onVrDisplayPresentChange: Nullable<() => void>;
  13430. /**
  13431. * Observable signaled when VR display mode changes
  13432. */
  13433. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13434. /**
  13435. * Observable signaled when VR request present is complete
  13436. */
  13437. onVRRequestPresentComplete: Observable<boolean>;
  13438. /**
  13439. * Observable signaled when VR request present starts
  13440. */
  13441. onVRRequestPresentStart: Observable<Engine>;
  13442. /**
  13443. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13444. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13445. */
  13446. isInVRExclusivePointerMode: boolean;
  13447. /**
  13448. * Gets a boolean indicating if a webVR device was detected
  13449. * @returns true if a webVR device was detected
  13450. */
  13451. isVRDevicePresent(): boolean;
  13452. /**
  13453. * Gets the current webVR device
  13454. * @returns the current webVR device (or null)
  13455. */
  13456. getVRDevice(): any;
  13457. /**
  13458. * Initializes a webVR display and starts listening to display change events
  13459. * The onVRDisplayChangedObservable will be notified upon these changes
  13460. * @returns A promise containing a VRDisplay and if vr is supported
  13461. */
  13462. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13463. /** @hidden */
  13464. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13465. /**
  13466. * Call this function to switch to webVR mode
  13467. * Will do nothing if webVR is not supported or if there is no webVR device
  13468. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13469. */
  13470. enableVR(): void;
  13471. /** @hidden */
  13472. _onVRFullScreenTriggered(): void;
  13473. }
  13474. }
  13475. declare module BABYLON {
  13476. /**
  13477. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13478. * IMPORTANT!! The data is right-hand data.
  13479. * @export
  13480. * @interface DevicePose
  13481. */
  13482. export interface DevicePose {
  13483. /**
  13484. * The position of the device, values in array are [x,y,z].
  13485. */
  13486. readonly position: Nullable<Float32Array>;
  13487. /**
  13488. * The linearVelocity of the device, values in array are [x,y,z].
  13489. */
  13490. readonly linearVelocity: Nullable<Float32Array>;
  13491. /**
  13492. * The linearAcceleration of the device, values in array are [x,y,z].
  13493. */
  13494. readonly linearAcceleration: Nullable<Float32Array>;
  13495. /**
  13496. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13497. */
  13498. readonly orientation: Nullable<Float32Array>;
  13499. /**
  13500. * The angularVelocity of the device, values in array are [x,y,z].
  13501. */
  13502. readonly angularVelocity: Nullable<Float32Array>;
  13503. /**
  13504. * The angularAcceleration of the device, values in array are [x,y,z].
  13505. */
  13506. readonly angularAcceleration: Nullable<Float32Array>;
  13507. }
  13508. /**
  13509. * Interface representing a pose controlled object in Babylon.
  13510. * A pose controlled object has both regular pose values as well as pose values
  13511. * from an external device such as a VR head mounted display
  13512. */
  13513. export interface PoseControlled {
  13514. /**
  13515. * The position of the object in babylon space.
  13516. */
  13517. position: Vector3;
  13518. /**
  13519. * The rotation quaternion of the object in babylon space.
  13520. */
  13521. rotationQuaternion: Quaternion;
  13522. /**
  13523. * The position of the device in babylon space.
  13524. */
  13525. devicePosition?: Vector3;
  13526. /**
  13527. * The rotation quaternion of the device in babylon space.
  13528. */
  13529. deviceRotationQuaternion: Quaternion;
  13530. /**
  13531. * The raw pose coming from the device.
  13532. */
  13533. rawPose: Nullable<DevicePose>;
  13534. /**
  13535. * The scale of the device to be used when translating from device space to babylon space.
  13536. */
  13537. deviceScaleFactor: number;
  13538. /**
  13539. * Updates the poseControlled values based on the input device pose.
  13540. * @param poseData the pose data to update the object with
  13541. */
  13542. updateFromDevice(poseData: DevicePose): void;
  13543. }
  13544. /**
  13545. * Set of options to customize the webVRCamera
  13546. */
  13547. export interface WebVROptions {
  13548. /**
  13549. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13550. */
  13551. trackPosition?: boolean;
  13552. /**
  13553. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13554. */
  13555. positionScale?: number;
  13556. /**
  13557. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13558. */
  13559. displayName?: string;
  13560. /**
  13561. * Should the native controller meshes be initialized. (default: true)
  13562. */
  13563. controllerMeshes?: boolean;
  13564. /**
  13565. * Creating a default HemiLight only on controllers. (default: true)
  13566. */
  13567. defaultLightingOnControllers?: boolean;
  13568. /**
  13569. * If you don't want to use the default VR button of the helper. (default: false)
  13570. */
  13571. useCustomVRButton?: boolean;
  13572. /**
  13573. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13574. */
  13575. customVRButton?: HTMLButtonElement;
  13576. /**
  13577. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13578. */
  13579. rayLength?: number;
  13580. /**
  13581. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13582. */
  13583. defaultHeight?: number;
  13584. /**
  13585. * If multiview should be used if availible (default: false)
  13586. */
  13587. useMultiview?: boolean;
  13588. }
  13589. /**
  13590. * This represents a WebVR camera.
  13591. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13592. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13593. */
  13594. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13595. private webVROptions;
  13596. /**
  13597. * @hidden
  13598. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13599. */
  13600. _vrDevice: any;
  13601. /**
  13602. * The rawPose of the vrDevice.
  13603. */
  13604. rawPose: Nullable<DevicePose>;
  13605. private _onVREnabled;
  13606. private _specsVersion;
  13607. private _attached;
  13608. private _frameData;
  13609. protected _descendants: Array<Node>;
  13610. private _deviceRoomPosition;
  13611. /** @hidden */
  13612. _deviceRoomRotationQuaternion: Quaternion;
  13613. private _standingMatrix;
  13614. /**
  13615. * Represents device position in babylon space.
  13616. */
  13617. devicePosition: Vector3;
  13618. /**
  13619. * Represents device rotation in babylon space.
  13620. */
  13621. deviceRotationQuaternion: Quaternion;
  13622. /**
  13623. * The scale of the device to be used when translating from device space to babylon space.
  13624. */
  13625. deviceScaleFactor: number;
  13626. private _deviceToWorld;
  13627. private _worldToDevice;
  13628. /**
  13629. * References to the webVR controllers for the vrDevice.
  13630. */
  13631. controllers: Array<WebVRController>;
  13632. /**
  13633. * Emits an event when a controller is attached.
  13634. */
  13635. onControllersAttachedObservable: Observable<WebVRController[]>;
  13636. /**
  13637. * Emits an event when a controller's mesh has been loaded;
  13638. */
  13639. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13640. /**
  13641. * Emits an event when the HMD's pose has been updated.
  13642. */
  13643. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13644. private _poseSet;
  13645. /**
  13646. * If the rig cameras be used as parent instead of this camera.
  13647. */
  13648. rigParenting: boolean;
  13649. private _lightOnControllers;
  13650. private _defaultHeight?;
  13651. /**
  13652. * Instantiates a WebVRFreeCamera.
  13653. * @param name The name of the WebVRFreeCamera
  13654. * @param position The starting anchor position for the camera
  13655. * @param scene The scene the camera belongs to
  13656. * @param webVROptions a set of customizable options for the webVRCamera
  13657. */
  13658. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13659. /**
  13660. * Gets the device distance from the ground in meters.
  13661. * @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.
  13662. */
  13663. deviceDistanceToRoomGround(): number;
  13664. /**
  13665. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13666. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13667. */
  13668. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13669. /**
  13670. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13671. * @returns A promise with a boolean set to if the standing matrix is supported.
  13672. */
  13673. useStandingMatrixAsync(): Promise<boolean>;
  13674. /**
  13675. * Disposes the camera
  13676. */
  13677. dispose(): void;
  13678. /**
  13679. * Gets a vrController by name.
  13680. * @param name The name of the controller to retreive
  13681. * @returns the controller matching the name specified or null if not found
  13682. */
  13683. getControllerByName(name: string): Nullable<WebVRController>;
  13684. private _leftController;
  13685. /**
  13686. * The controller corrisponding to the users left hand.
  13687. */
  13688. readonly leftController: Nullable<WebVRController>;
  13689. private _rightController;
  13690. /**
  13691. * The controller corrisponding to the users right hand.
  13692. */
  13693. readonly rightController: Nullable<WebVRController>;
  13694. /**
  13695. * Casts a ray forward from the vrCamera's gaze.
  13696. * @param length Length of the ray (default: 100)
  13697. * @returns the ray corrisponding to the gaze
  13698. */
  13699. getForwardRay(length?: number): Ray;
  13700. /**
  13701. * @hidden
  13702. * Updates the camera based on device's frame data
  13703. */
  13704. _checkInputs(): void;
  13705. /**
  13706. * Updates the poseControlled values based on the input device pose.
  13707. * @param poseData Pose coming from the device
  13708. */
  13709. updateFromDevice(poseData: DevicePose): void;
  13710. private _htmlElementAttached;
  13711. private _detachIfAttached;
  13712. /**
  13713. * WebVR's attach control will start broadcasting frames to the device.
  13714. * Note that in certain browsers (chrome for example) this function must be called
  13715. * within a user-interaction callback. Example:
  13716. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13717. *
  13718. * @param element html element to attach the vrDevice to
  13719. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13720. */
  13721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13722. /**
  13723. * Detaches the camera from the html element and disables VR
  13724. *
  13725. * @param element html element to detach from
  13726. */
  13727. detachControl(element: HTMLElement): void;
  13728. /**
  13729. * @returns the name of this class
  13730. */
  13731. getClassName(): string;
  13732. /**
  13733. * Calls resetPose on the vrDisplay
  13734. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13735. */
  13736. resetToCurrentRotation(): void;
  13737. /**
  13738. * @hidden
  13739. * Updates the rig cameras (left and right eye)
  13740. */
  13741. _updateRigCameras(): void;
  13742. private _workingVector;
  13743. private _oneVector;
  13744. private _workingMatrix;
  13745. private updateCacheCalled;
  13746. private _correctPositionIfNotTrackPosition;
  13747. /**
  13748. * @hidden
  13749. * Updates the cached values of the camera
  13750. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13751. */
  13752. _updateCache(ignoreParentClass?: boolean): void;
  13753. /**
  13754. * @hidden
  13755. * Get current device position in babylon world
  13756. */
  13757. _computeDevicePosition(): void;
  13758. /**
  13759. * Updates the current device position and rotation in the babylon world
  13760. */
  13761. update(): void;
  13762. /**
  13763. * @hidden
  13764. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13765. * @returns an identity matrix
  13766. */
  13767. _getViewMatrix(): Matrix;
  13768. private _tmpMatrix;
  13769. /**
  13770. * This function is called by the two RIG cameras.
  13771. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13772. * @hidden
  13773. */
  13774. _getWebVRViewMatrix(): Matrix;
  13775. /** @hidden */
  13776. _getWebVRProjectionMatrix(): Matrix;
  13777. private _onGamepadConnectedObserver;
  13778. private _onGamepadDisconnectedObserver;
  13779. private _updateCacheWhenTrackingDisabledObserver;
  13780. /**
  13781. * Initializes the controllers and their meshes
  13782. */
  13783. initControllers(): void;
  13784. }
  13785. }
  13786. declare module BABYLON {
  13787. /**
  13788. * Size options for a post process
  13789. */
  13790. export type PostProcessOptions = {
  13791. width: number;
  13792. height: number;
  13793. };
  13794. /**
  13795. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13796. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13797. */
  13798. export class PostProcess {
  13799. /** Name of the PostProcess. */
  13800. name: string;
  13801. /**
  13802. * Gets or sets the unique id of the post process
  13803. */
  13804. uniqueId: number;
  13805. /**
  13806. * Width of the texture to apply the post process on
  13807. */
  13808. width: number;
  13809. /**
  13810. * Height of the texture to apply the post process on
  13811. */
  13812. height: number;
  13813. /**
  13814. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13815. * @hidden
  13816. */
  13817. _outputTexture: Nullable<InternalTexture>;
  13818. /**
  13819. * Sampling mode used by the shader
  13820. * See https://doc.babylonjs.com/classes/3.1/texture
  13821. */
  13822. renderTargetSamplingMode: number;
  13823. /**
  13824. * Clear color to use when screen clearing
  13825. */
  13826. clearColor: Color4;
  13827. /**
  13828. * If the buffer needs to be cleared before applying the post process. (default: true)
  13829. * Should be set to false if shader will overwrite all previous pixels.
  13830. */
  13831. autoClear: boolean;
  13832. /**
  13833. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13834. */
  13835. alphaMode: number;
  13836. /**
  13837. * Sets the setAlphaBlendConstants of the babylon engine
  13838. */
  13839. alphaConstants: Color4;
  13840. /**
  13841. * Animations to be used for the post processing
  13842. */
  13843. animations: Animation[];
  13844. /**
  13845. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13846. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13847. */
  13848. enablePixelPerfectMode: boolean;
  13849. /**
  13850. * Force the postprocess to be applied without taking in account viewport
  13851. */
  13852. forceFullscreenViewport: boolean;
  13853. /**
  13854. * List of inspectable custom properties (used by the Inspector)
  13855. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13856. */
  13857. inspectableCustomProperties: IInspectable[];
  13858. /**
  13859. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13860. *
  13861. * | Value | Type | Description |
  13862. * | ----- | ----------------------------------- | ----------- |
  13863. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13864. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13865. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13866. *
  13867. */
  13868. scaleMode: number;
  13869. /**
  13870. * Force textures to be a power of two (default: false)
  13871. */
  13872. alwaysForcePOT: boolean;
  13873. private _samples;
  13874. /**
  13875. * Number of sample textures (default: 1)
  13876. */
  13877. samples: number;
  13878. /**
  13879. * Modify the scale of the post process to be the same as the viewport (default: false)
  13880. */
  13881. adaptScaleToCurrentViewport: boolean;
  13882. private _camera;
  13883. private _scene;
  13884. private _engine;
  13885. private _options;
  13886. private _reusable;
  13887. private _textureType;
  13888. /**
  13889. * Smart array of input and output textures for the post process.
  13890. * @hidden
  13891. */
  13892. _textures: SmartArray<InternalTexture>;
  13893. /**
  13894. * The index in _textures that corresponds to the output texture.
  13895. * @hidden
  13896. */
  13897. _currentRenderTextureInd: number;
  13898. private _effect;
  13899. private _samplers;
  13900. private _fragmentUrl;
  13901. private _vertexUrl;
  13902. private _parameters;
  13903. private _scaleRatio;
  13904. protected _indexParameters: any;
  13905. private _shareOutputWithPostProcess;
  13906. private _texelSize;
  13907. private _forcedOutputTexture;
  13908. /**
  13909. * Returns the fragment url or shader name used in the post process.
  13910. * @returns the fragment url or name in the shader store.
  13911. */
  13912. getEffectName(): string;
  13913. /**
  13914. * An event triggered when the postprocess is activated.
  13915. */
  13916. onActivateObservable: Observable<Camera>;
  13917. private _onActivateObserver;
  13918. /**
  13919. * A function that is added to the onActivateObservable
  13920. */
  13921. onActivate: Nullable<(camera: Camera) => void>;
  13922. /**
  13923. * An event triggered when the postprocess changes its size.
  13924. */
  13925. onSizeChangedObservable: Observable<PostProcess>;
  13926. private _onSizeChangedObserver;
  13927. /**
  13928. * A function that is added to the onSizeChangedObservable
  13929. */
  13930. onSizeChanged: (postProcess: PostProcess) => void;
  13931. /**
  13932. * An event triggered when the postprocess applies its effect.
  13933. */
  13934. onApplyObservable: Observable<Effect>;
  13935. private _onApplyObserver;
  13936. /**
  13937. * A function that is added to the onApplyObservable
  13938. */
  13939. onApply: (effect: Effect) => void;
  13940. /**
  13941. * An event triggered before rendering the postprocess
  13942. */
  13943. onBeforeRenderObservable: Observable<Effect>;
  13944. private _onBeforeRenderObserver;
  13945. /**
  13946. * A function that is added to the onBeforeRenderObservable
  13947. */
  13948. onBeforeRender: (effect: Effect) => void;
  13949. /**
  13950. * An event triggered after rendering the postprocess
  13951. */
  13952. onAfterRenderObservable: Observable<Effect>;
  13953. private _onAfterRenderObserver;
  13954. /**
  13955. * A function that is added to the onAfterRenderObservable
  13956. */
  13957. onAfterRender: (efect: Effect) => void;
  13958. /**
  13959. * 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
  13960. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13961. */
  13962. inputTexture: InternalTexture;
  13963. /**
  13964. * Gets the camera which post process is applied to.
  13965. * @returns The camera the post process is applied to.
  13966. */
  13967. getCamera(): Camera;
  13968. /**
  13969. * Gets the texel size of the postprocess.
  13970. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13971. */
  13972. readonly texelSize: Vector2;
  13973. /**
  13974. * Creates a new instance PostProcess
  13975. * @param name The name of the PostProcess.
  13976. * @param fragmentUrl The url of the fragment shader to be used.
  13977. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13978. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13979. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13980. * @param camera The camera to apply the render pass to.
  13981. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13982. * @param engine The engine which the post process will be applied. (default: current engine)
  13983. * @param reusable If the post process can be reused on the same frame. (default: false)
  13984. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13985. * @param textureType Type of textures used when performing the post process. (default: 0)
  13986. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13987. * @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
  13988. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13989. */
  13990. constructor(
  13991. /** Name of the PostProcess. */
  13992. 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);
  13993. /**
  13994. * Gets a string idenfifying the name of the class
  13995. * @returns "PostProcess" string
  13996. */
  13997. getClassName(): string;
  13998. /**
  13999. * Gets the engine which this post process belongs to.
  14000. * @returns The engine the post process was enabled with.
  14001. */
  14002. getEngine(): Engine;
  14003. /**
  14004. * The effect that is created when initializing the post process.
  14005. * @returns The created effect corrisponding the the postprocess.
  14006. */
  14007. getEffect(): Effect;
  14008. /**
  14009. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  14010. * @param postProcess The post process to share the output with.
  14011. * @returns This post process.
  14012. */
  14013. shareOutputWith(postProcess: PostProcess): PostProcess;
  14014. /**
  14015. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  14016. * This should be called if the post process that shares output with this post process is disabled/disposed.
  14017. */
  14018. useOwnOutput(): void;
  14019. /**
  14020. * Updates the effect with the current post process compile time values and recompiles the shader.
  14021. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  14022. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  14023. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  14024. * @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
  14025. * @param onCompiled Called when the shader has been compiled.
  14026. * @param onError Called if there is an error when compiling a shader.
  14027. */
  14028. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  14029. /**
  14030. * The post process is reusable if it can be used multiple times within one frame.
  14031. * @returns If the post process is reusable
  14032. */
  14033. isReusable(): boolean;
  14034. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  14035. markTextureDirty(): void;
  14036. /**
  14037. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  14038. * 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.
  14039. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  14040. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  14041. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  14042. * @returns The target texture that was bound to be written to.
  14043. */
  14044. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  14045. /**
  14046. * If the post process is supported.
  14047. */
  14048. readonly isSupported: boolean;
  14049. /**
  14050. * The aspect ratio of the output texture.
  14051. */
  14052. readonly aspectRatio: number;
  14053. /**
  14054. * Get a value indicating if the post-process is ready to be used
  14055. * @returns true if the post-process is ready (shader is compiled)
  14056. */
  14057. isReady(): boolean;
  14058. /**
  14059. * Binds all textures and uniforms to the shader, this will be run on every pass.
  14060. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  14061. */
  14062. apply(): Nullable<Effect>;
  14063. private _disposeTextures;
  14064. /**
  14065. * Disposes the post process.
  14066. * @param camera The camera to dispose the post process on.
  14067. */
  14068. dispose(camera?: Camera): void;
  14069. }
  14070. }
  14071. declare module BABYLON {
  14072. /**
  14073. * PostProcessManager is used to manage one or more post processes or post process pipelines
  14074. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14075. */
  14076. export class PostProcessManager {
  14077. private _scene;
  14078. private _indexBuffer;
  14079. private _vertexBuffers;
  14080. /**
  14081. * Creates a new instance PostProcess
  14082. * @param scene The scene that the post process is associated with.
  14083. */
  14084. constructor(scene: Scene);
  14085. private _prepareBuffers;
  14086. private _buildIndexBuffer;
  14087. /**
  14088. * Rebuilds the vertex buffers of the manager.
  14089. * @hidden
  14090. */
  14091. _rebuild(): void;
  14092. /**
  14093. * Prepares a frame to be run through a post process.
  14094. * @param sourceTexture The input texture to the post procesess. (default: null)
  14095. * @param postProcesses An array of post processes to be run. (default: null)
  14096. * @returns True if the post processes were able to be run.
  14097. * @hidden
  14098. */
  14099. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  14100. /**
  14101. * Manually render a set of post processes to a texture.
  14102. * @param postProcesses An array of post processes to be run.
  14103. * @param targetTexture The target texture to render to.
  14104. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  14105. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  14106. * @param lodLevel defines which lod of the texture to render to
  14107. */
  14108. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  14109. /**
  14110. * Finalize the result of the output of the postprocesses.
  14111. * @param doNotPresent If true the result will not be displayed to the screen.
  14112. * @param targetTexture The target texture to render to.
  14113. * @param faceIndex The index of the face to bind the target texture to.
  14114. * @param postProcesses The array of post processes to render.
  14115. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  14116. * @hidden
  14117. */
  14118. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  14119. /**
  14120. * Disposes of the post process manager.
  14121. */
  14122. dispose(): void;
  14123. }
  14124. }
  14125. declare module BABYLON {
  14126. interface AbstractScene {
  14127. /**
  14128. * The list of procedural textures added to the scene
  14129. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14130. */
  14131. proceduralTextures: Array<ProceduralTexture>;
  14132. }
  14133. /**
  14134. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14135. * in a given scene.
  14136. */
  14137. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14138. /**
  14139. * The component name helpfull to identify the component in the list of scene components.
  14140. */
  14141. readonly name: string;
  14142. /**
  14143. * The scene the component belongs to.
  14144. */
  14145. scene: Scene;
  14146. /**
  14147. * Creates a new instance of the component for the given scene
  14148. * @param scene Defines the scene to register the component in
  14149. */
  14150. constructor(scene: Scene);
  14151. /**
  14152. * Registers the component in a given scene
  14153. */
  14154. register(): void;
  14155. /**
  14156. * Rebuilds the elements related to this component in case of
  14157. * context lost for instance.
  14158. */
  14159. rebuild(): void;
  14160. /**
  14161. * Disposes the component and the associated ressources.
  14162. */
  14163. dispose(): void;
  14164. private _beforeClear;
  14165. }
  14166. }
  14167. declare module BABYLON {
  14168. interface Engine {
  14169. /**
  14170. * Creates a new render target cube texture
  14171. * @param size defines the size of the texture
  14172. * @param options defines the options used to create the texture
  14173. * @returns a new render target cube texture stored in an InternalTexture
  14174. */
  14175. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14176. }
  14177. }
  14178. declare module BABYLON {
  14179. /** @hidden */
  14180. export var proceduralVertexShader: {
  14181. name: string;
  14182. shader: string;
  14183. };
  14184. }
  14185. declare module BABYLON {
  14186. /**
  14187. * 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.
  14188. * This is the base class of any Procedural texture and contains most of the shareable code.
  14189. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14190. */
  14191. export class ProceduralTexture extends Texture {
  14192. isCube: boolean;
  14193. /**
  14194. * Define if the texture is enabled or not (disabled texture will not render)
  14195. */
  14196. isEnabled: boolean;
  14197. /**
  14198. * Define if the texture must be cleared before rendering (default is true)
  14199. */
  14200. autoClear: boolean;
  14201. /**
  14202. * Callback called when the texture is generated
  14203. */
  14204. onGenerated: () => void;
  14205. /**
  14206. * Event raised when the texture is generated
  14207. */
  14208. onGeneratedObservable: Observable<ProceduralTexture>;
  14209. /** @hidden */
  14210. _generateMipMaps: boolean;
  14211. /** @hidden **/
  14212. _effect: Effect;
  14213. /** @hidden */
  14214. _textures: {
  14215. [key: string]: Texture;
  14216. };
  14217. private _size;
  14218. private _currentRefreshId;
  14219. private _refreshRate;
  14220. private _vertexBuffers;
  14221. private _indexBuffer;
  14222. private _uniforms;
  14223. private _samplers;
  14224. private _fragment;
  14225. private _floats;
  14226. private _ints;
  14227. private _floatsArrays;
  14228. private _colors3;
  14229. private _colors4;
  14230. private _vectors2;
  14231. private _vectors3;
  14232. private _matrices;
  14233. private _fallbackTexture;
  14234. private _fallbackTextureUsed;
  14235. private _engine;
  14236. private _cachedDefines;
  14237. private _contentUpdateId;
  14238. private _contentData;
  14239. /**
  14240. * Instantiates a new procedural texture.
  14241. * 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.
  14242. * This is the base class of any Procedural texture and contains most of the shareable code.
  14243. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14244. * @param name Define the name of the texture
  14245. * @param size Define the size of the texture to create
  14246. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14247. * @param scene Define the scene the texture belongs to
  14248. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14249. * @param generateMipMaps Define if the texture should creates mip maps or not
  14250. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14251. */
  14252. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14253. /**
  14254. * The effect that is created when initializing the post process.
  14255. * @returns The created effect corrisponding the the postprocess.
  14256. */
  14257. getEffect(): Effect;
  14258. /**
  14259. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14260. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14261. */
  14262. getContent(): Nullable<ArrayBufferView>;
  14263. private _createIndexBuffer;
  14264. /** @hidden */
  14265. _rebuild(): void;
  14266. /**
  14267. * Resets the texture in order to recreate its associated resources.
  14268. * This can be called in case of context loss
  14269. */
  14270. reset(): void;
  14271. protected _getDefines(): string;
  14272. /**
  14273. * Is the texture ready to be used ? (rendered at least once)
  14274. * @returns true if ready, otherwise, false.
  14275. */
  14276. isReady(): boolean;
  14277. /**
  14278. * Resets the refresh counter of the texture and start bak from scratch.
  14279. * Could be useful to regenerate the texture if it is setup to render only once.
  14280. */
  14281. resetRefreshCounter(): void;
  14282. /**
  14283. * Set the fragment shader to use in order to render the texture.
  14284. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14285. */
  14286. setFragment(fragment: any): void;
  14287. /**
  14288. * Define the refresh rate of the texture or the rendering frequency.
  14289. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14290. */
  14291. refreshRate: number;
  14292. /** @hidden */
  14293. _shouldRender(): boolean;
  14294. /**
  14295. * Get the size the texture is rendering at.
  14296. * @returns the size (texture is always squared)
  14297. */
  14298. getRenderSize(): number;
  14299. /**
  14300. * Resize the texture to new value.
  14301. * @param size Define the new size the texture should have
  14302. * @param generateMipMaps Define whether the new texture should create mip maps
  14303. */
  14304. resize(size: number, generateMipMaps: boolean): void;
  14305. private _checkUniform;
  14306. /**
  14307. * Set a texture in the shader program used to render.
  14308. * @param name Define the name of the uniform samplers as defined in the shader
  14309. * @param texture Define the texture to bind to this sampler
  14310. * @return the texture itself allowing "fluent" like uniform updates
  14311. */
  14312. setTexture(name: string, texture: Texture): ProceduralTexture;
  14313. /**
  14314. * Set a float in the shader.
  14315. * @param name Define the name of the uniform as defined in the shader
  14316. * @param value Define the value to give to the uniform
  14317. * @return the texture itself allowing "fluent" like uniform updates
  14318. */
  14319. setFloat(name: string, value: number): ProceduralTexture;
  14320. /**
  14321. * Set a int in the shader.
  14322. * @param name Define the name of the uniform as defined in the shader
  14323. * @param value Define the value to give to the uniform
  14324. * @return the texture itself allowing "fluent" like uniform updates
  14325. */
  14326. setInt(name: string, value: number): ProceduralTexture;
  14327. /**
  14328. * Set an array of floats in the shader.
  14329. * @param name Define the name of the uniform as defined in the shader
  14330. * @param value Define the value to give to the uniform
  14331. * @return the texture itself allowing "fluent" like uniform updates
  14332. */
  14333. setFloats(name: string, value: number[]): ProceduralTexture;
  14334. /**
  14335. * Set a vec3 in the shader from a Color3.
  14336. * @param name Define the name of the uniform as defined in the shader
  14337. * @param value Define the value to give to the uniform
  14338. * @return the texture itself allowing "fluent" like uniform updates
  14339. */
  14340. setColor3(name: string, value: Color3): ProceduralTexture;
  14341. /**
  14342. * Set a vec4 in the shader from a Color4.
  14343. * @param name Define the name of the uniform as defined in the shader
  14344. * @param value Define the value to give to the uniform
  14345. * @return the texture itself allowing "fluent" like uniform updates
  14346. */
  14347. setColor4(name: string, value: Color4): ProceduralTexture;
  14348. /**
  14349. * Set a vec2 in the shader from a Vector2.
  14350. * @param name Define the name of the uniform as defined in the shader
  14351. * @param value Define the value to give to the uniform
  14352. * @return the texture itself allowing "fluent" like uniform updates
  14353. */
  14354. setVector2(name: string, value: Vector2): ProceduralTexture;
  14355. /**
  14356. * Set a vec3 in the shader from a Vector3.
  14357. * @param name Define the name of the uniform as defined in the shader
  14358. * @param value Define the value to give to the uniform
  14359. * @return the texture itself allowing "fluent" like uniform updates
  14360. */
  14361. setVector3(name: string, value: Vector3): ProceduralTexture;
  14362. /**
  14363. * Set a mat4 in the shader from a MAtrix.
  14364. * @param name Define the name of the uniform as defined in the shader
  14365. * @param value Define the value to give to the uniform
  14366. * @return the texture itself allowing "fluent" like uniform updates
  14367. */
  14368. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14369. /**
  14370. * Render the texture to its associated render target.
  14371. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14372. */
  14373. render(useCameraPostProcess?: boolean): void;
  14374. /**
  14375. * Clone the texture.
  14376. * @returns the cloned texture
  14377. */
  14378. clone(): ProceduralTexture;
  14379. /**
  14380. * Dispose the texture and release its asoociated resources.
  14381. */
  14382. dispose(): void;
  14383. }
  14384. }
  14385. declare module BABYLON {
  14386. /**
  14387. * This represents the base class for particle system in Babylon.
  14388. * 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.
  14389. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14390. * @example https://doc.babylonjs.com/babylon101/particles
  14391. */
  14392. export class BaseParticleSystem {
  14393. /**
  14394. * Source color is added to the destination color without alpha affecting the result
  14395. */
  14396. static BLENDMODE_ONEONE: number;
  14397. /**
  14398. * Blend current color and particle color using particle’s alpha
  14399. */
  14400. static BLENDMODE_STANDARD: number;
  14401. /**
  14402. * Add current color and particle color multiplied by particle’s alpha
  14403. */
  14404. static BLENDMODE_ADD: number;
  14405. /**
  14406. * Multiply current color with particle color
  14407. */
  14408. static BLENDMODE_MULTIPLY: number;
  14409. /**
  14410. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14411. */
  14412. static BLENDMODE_MULTIPLYADD: number;
  14413. /**
  14414. * List of animations used by the particle system.
  14415. */
  14416. animations: Animation[];
  14417. /**
  14418. * The id of the Particle system.
  14419. */
  14420. id: string;
  14421. /**
  14422. * The friendly name of the Particle system.
  14423. */
  14424. name: string;
  14425. /**
  14426. * The rendering group used by the Particle system to chose when to render.
  14427. */
  14428. renderingGroupId: number;
  14429. /**
  14430. * The emitter represents the Mesh or position we are attaching the particle system to.
  14431. */
  14432. emitter: Nullable<AbstractMesh | Vector3>;
  14433. /**
  14434. * The maximum number of particles to emit per frame
  14435. */
  14436. emitRate: number;
  14437. /**
  14438. * If you want to launch only a few particles at once, that can be done, as well.
  14439. */
  14440. manualEmitCount: number;
  14441. /**
  14442. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14443. */
  14444. updateSpeed: number;
  14445. /**
  14446. * The amount of time the particle system is running (depends of the overall update speed).
  14447. */
  14448. targetStopDuration: number;
  14449. /**
  14450. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14451. */
  14452. disposeOnStop: boolean;
  14453. /**
  14454. * Minimum power of emitting particles.
  14455. */
  14456. minEmitPower: number;
  14457. /**
  14458. * Maximum power of emitting particles.
  14459. */
  14460. maxEmitPower: number;
  14461. /**
  14462. * Minimum life time of emitting particles.
  14463. */
  14464. minLifeTime: number;
  14465. /**
  14466. * Maximum life time of emitting particles.
  14467. */
  14468. maxLifeTime: number;
  14469. /**
  14470. * Minimum Size of emitting particles.
  14471. */
  14472. minSize: number;
  14473. /**
  14474. * Maximum Size of emitting particles.
  14475. */
  14476. maxSize: number;
  14477. /**
  14478. * Minimum scale of emitting particles on X axis.
  14479. */
  14480. minScaleX: number;
  14481. /**
  14482. * Maximum scale of emitting particles on X axis.
  14483. */
  14484. maxScaleX: number;
  14485. /**
  14486. * Minimum scale of emitting particles on Y axis.
  14487. */
  14488. minScaleY: number;
  14489. /**
  14490. * Maximum scale of emitting particles on Y axis.
  14491. */
  14492. maxScaleY: number;
  14493. /**
  14494. * Gets or sets the minimal initial rotation in radians.
  14495. */
  14496. minInitialRotation: number;
  14497. /**
  14498. * Gets or sets the maximal initial rotation in radians.
  14499. */
  14500. maxInitialRotation: number;
  14501. /**
  14502. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14503. */
  14504. minAngularSpeed: number;
  14505. /**
  14506. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14507. */
  14508. maxAngularSpeed: number;
  14509. /**
  14510. * The texture used to render each particle. (this can be a spritesheet)
  14511. */
  14512. particleTexture: Nullable<Texture>;
  14513. /**
  14514. * The layer mask we are rendering the particles through.
  14515. */
  14516. layerMask: number;
  14517. /**
  14518. * This can help using your own shader to render the particle system.
  14519. * The according effect will be created
  14520. */
  14521. customShader: any;
  14522. /**
  14523. * By default particle system starts as soon as they are created. This prevents the
  14524. * automatic start to happen and let you decide when to start emitting particles.
  14525. */
  14526. preventAutoStart: boolean;
  14527. private _noiseTexture;
  14528. /**
  14529. * Gets or sets a texture used to add random noise to particle positions
  14530. */
  14531. noiseTexture: Nullable<ProceduralTexture>;
  14532. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14533. noiseStrength: Vector3;
  14534. /**
  14535. * Callback triggered when the particle animation is ending.
  14536. */
  14537. onAnimationEnd: Nullable<() => void>;
  14538. /**
  14539. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14540. */
  14541. blendMode: number;
  14542. /**
  14543. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14544. * to override the particles.
  14545. */
  14546. forceDepthWrite: boolean;
  14547. /** 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 */
  14548. preWarmCycles: number;
  14549. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14550. preWarmStepOffset: number;
  14551. /**
  14552. * 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)
  14553. */
  14554. spriteCellChangeSpeed: number;
  14555. /**
  14556. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14557. */
  14558. startSpriteCellID: number;
  14559. /**
  14560. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14561. */
  14562. endSpriteCellID: number;
  14563. /**
  14564. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14565. */
  14566. spriteCellWidth: number;
  14567. /**
  14568. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14569. */
  14570. spriteCellHeight: number;
  14571. /**
  14572. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14573. */
  14574. spriteRandomStartCell: boolean;
  14575. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14576. translationPivot: Vector2;
  14577. /** @hidden */
  14578. protected _isAnimationSheetEnabled: boolean;
  14579. /**
  14580. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14581. */
  14582. beginAnimationOnStart: boolean;
  14583. /**
  14584. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14585. */
  14586. beginAnimationFrom: number;
  14587. /**
  14588. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14589. */
  14590. beginAnimationTo: number;
  14591. /**
  14592. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14593. */
  14594. beginAnimationLoop: boolean;
  14595. /**
  14596. * Gets or sets a world offset applied to all particles
  14597. */
  14598. worldOffset: Vector3;
  14599. /**
  14600. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14601. */
  14602. isAnimationSheetEnabled: boolean;
  14603. /**
  14604. * Get hosting scene
  14605. * @returns the scene
  14606. */
  14607. getScene(): Scene;
  14608. /**
  14609. * You can use gravity if you want to give an orientation to your particles.
  14610. */
  14611. gravity: Vector3;
  14612. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14613. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14614. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14615. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14616. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14617. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14618. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14619. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14620. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14621. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14622. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14623. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14624. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14625. /**
  14626. * Defines the delay in milliseconds before starting the system (0 by default)
  14627. */
  14628. startDelay: number;
  14629. /**
  14630. * Gets the current list of drag gradients.
  14631. * You must use addDragGradient and removeDragGradient to udpate this list
  14632. * @returns the list of drag gradients
  14633. */
  14634. getDragGradients(): Nullable<Array<FactorGradient>>;
  14635. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14636. limitVelocityDamping: number;
  14637. /**
  14638. * Gets the current list of limit velocity gradients.
  14639. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14640. * @returns the list of limit velocity gradients
  14641. */
  14642. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14643. /**
  14644. * Gets the current list of color gradients.
  14645. * You must use addColorGradient and removeColorGradient to udpate this list
  14646. * @returns the list of color gradients
  14647. */
  14648. getColorGradients(): Nullable<Array<ColorGradient>>;
  14649. /**
  14650. * Gets the current list of size gradients.
  14651. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14652. * @returns the list of size gradients
  14653. */
  14654. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14655. /**
  14656. * Gets the current list of color remap gradients.
  14657. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14658. * @returns the list of color remap gradients
  14659. */
  14660. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14661. /**
  14662. * Gets the current list of alpha remap gradients.
  14663. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14664. * @returns the list of alpha remap gradients
  14665. */
  14666. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14667. /**
  14668. * Gets the current list of life time gradients.
  14669. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14670. * @returns the list of life time gradients
  14671. */
  14672. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14673. /**
  14674. * Gets the current list of angular speed gradients.
  14675. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14676. * @returns the list of angular speed gradients
  14677. */
  14678. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14679. /**
  14680. * Gets the current list of velocity gradients.
  14681. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14682. * @returns the list of velocity gradients
  14683. */
  14684. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14685. /**
  14686. * Gets the current list of start size gradients.
  14687. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14688. * @returns the list of start size gradients
  14689. */
  14690. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14691. /**
  14692. * Gets the current list of emit rate gradients.
  14693. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14694. * @returns the list of emit rate gradients
  14695. */
  14696. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14697. /**
  14698. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14699. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14700. */
  14701. direction1: Vector3;
  14702. /**
  14703. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14704. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14705. */
  14706. direction2: Vector3;
  14707. /**
  14708. * 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.
  14709. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14710. */
  14711. minEmitBox: Vector3;
  14712. /**
  14713. * 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.
  14714. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14715. */
  14716. maxEmitBox: Vector3;
  14717. /**
  14718. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14719. */
  14720. color1: Color4;
  14721. /**
  14722. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14723. */
  14724. color2: Color4;
  14725. /**
  14726. * Color the particle will have at the end of its lifetime
  14727. */
  14728. colorDead: Color4;
  14729. /**
  14730. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14731. */
  14732. textureMask: Color4;
  14733. /**
  14734. * The particle emitter type defines the emitter used by the particle system.
  14735. * It can be for example box, sphere, or cone...
  14736. */
  14737. particleEmitterType: IParticleEmitterType;
  14738. /** @hidden */
  14739. _isSubEmitter: boolean;
  14740. /**
  14741. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14742. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14743. */
  14744. billboardMode: number;
  14745. protected _isBillboardBased: boolean;
  14746. /**
  14747. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14748. */
  14749. isBillboardBased: boolean;
  14750. /**
  14751. * The scene the particle system belongs to.
  14752. */
  14753. protected _scene: Scene;
  14754. /**
  14755. * Local cache of defines for image processing.
  14756. */
  14757. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14758. /**
  14759. * Default configuration related to image processing available in the standard Material.
  14760. */
  14761. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14762. /**
  14763. * Gets the image processing configuration used either in this material.
  14764. */
  14765. /**
  14766. * Sets the Default image processing configuration used either in the this material.
  14767. *
  14768. * If sets to null, the scene one is in use.
  14769. */
  14770. imageProcessingConfiguration: ImageProcessingConfiguration;
  14771. /**
  14772. * Attaches a new image processing configuration to the Standard Material.
  14773. * @param configuration
  14774. */
  14775. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14776. /** @hidden */
  14777. protected _reset(): void;
  14778. /** @hidden */
  14779. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14780. /**
  14781. * Instantiates a particle system.
  14782. * 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.
  14783. * @param name The name of the particle system
  14784. */
  14785. constructor(name: string);
  14786. /**
  14787. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14788. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14789. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14790. * @returns the emitter
  14791. */
  14792. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14793. /**
  14794. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14795. * @param radius The radius of the hemisphere to emit from
  14796. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14797. * @returns the emitter
  14798. */
  14799. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14800. /**
  14801. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14802. * @param radius The radius of the sphere to emit from
  14803. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14804. * @returns the emitter
  14805. */
  14806. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14807. /**
  14808. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14809. * @param radius The radius of the sphere to emit from
  14810. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14811. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14812. * @returns the emitter
  14813. */
  14814. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14815. /**
  14816. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14817. * @param radius The radius of the emission cylinder
  14818. * @param height The height of the emission cylinder
  14819. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14820. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14821. * @returns the emitter
  14822. */
  14823. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14824. /**
  14825. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14826. * @param radius The radius of the cylinder to emit from
  14827. * @param height The height of the emission cylinder
  14828. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14829. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14830. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14831. * @returns the emitter
  14832. */
  14833. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14834. /**
  14835. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14836. * @param radius The radius of the cone to emit from
  14837. * @param angle The base angle of the cone
  14838. * @returns the emitter
  14839. */
  14840. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14841. /**
  14842. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14843. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14844. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14845. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14846. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14847. * @returns the emitter
  14848. */
  14849. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14850. }
  14851. }
  14852. declare module BABYLON {
  14853. /**
  14854. * Type of sub emitter
  14855. */
  14856. export enum SubEmitterType {
  14857. /**
  14858. * Attached to the particle over it's lifetime
  14859. */
  14860. ATTACHED = 0,
  14861. /**
  14862. * Created when the particle dies
  14863. */
  14864. END = 1
  14865. }
  14866. /**
  14867. * Sub emitter class used to emit particles from an existing particle
  14868. */
  14869. export class SubEmitter {
  14870. /**
  14871. * the particle system to be used by the sub emitter
  14872. */
  14873. particleSystem: ParticleSystem;
  14874. /**
  14875. * Type of the submitter (Default: END)
  14876. */
  14877. type: SubEmitterType;
  14878. /**
  14879. * 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)
  14880. * Note: This only is supported when using an emitter of type Mesh
  14881. */
  14882. inheritDirection: boolean;
  14883. /**
  14884. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14885. */
  14886. inheritedVelocityAmount: number;
  14887. /**
  14888. * Creates a sub emitter
  14889. * @param particleSystem the particle system to be used by the sub emitter
  14890. */
  14891. constructor(
  14892. /**
  14893. * the particle system to be used by the sub emitter
  14894. */
  14895. particleSystem: ParticleSystem);
  14896. /**
  14897. * Clones the sub emitter
  14898. * @returns the cloned sub emitter
  14899. */
  14900. clone(): SubEmitter;
  14901. /**
  14902. * Serialize current object to a JSON object
  14903. * @returns the serialized object
  14904. */
  14905. serialize(): any;
  14906. /** @hidden */
  14907. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14908. /**
  14909. * Creates a new SubEmitter from a serialized JSON version
  14910. * @param serializationObject defines the JSON object to read from
  14911. * @param scene defines the hosting scene
  14912. * @param rootUrl defines the rootUrl for data loading
  14913. * @returns a new SubEmitter
  14914. */
  14915. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14916. /** Release associated resources */
  14917. dispose(): void;
  14918. }
  14919. }
  14920. declare module BABYLON {
  14921. /** @hidden */
  14922. export var clipPlaneFragmentDeclaration: {
  14923. name: string;
  14924. shader: string;
  14925. };
  14926. }
  14927. declare module BABYLON {
  14928. /** @hidden */
  14929. export var imageProcessingDeclaration: {
  14930. name: string;
  14931. shader: string;
  14932. };
  14933. }
  14934. declare module BABYLON {
  14935. /** @hidden */
  14936. export var imageProcessingFunctions: {
  14937. name: string;
  14938. shader: string;
  14939. };
  14940. }
  14941. declare module BABYLON {
  14942. /** @hidden */
  14943. export var clipPlaneFragment: {
  14944. name: string;
  14945. shader: string;
  14946. };
  14947. }
  14948. declare module BABYLON {
  14949. /** @hidden */
  14950. export var particlesPixelShader: {
  14951. name: string;
  14952. shader: string;
  14953. };
  14954. }
  14955. declare module BABYLON {
  14956. /** @hidden */
  14957. export var clipPlaneVertexDeclaration: {
  14958. name: string;
  14959. shader: string;
  14960. };
  14961. }
  14962. declare module BABYLON {
  14963. /** @hidden */
  14964. export var clipPlaneVertex: {
  14965. name: string;
  14966. shader: string;
  14967. };
  14968. }
  14969. declare module BABYLON {
  14970. /** @hidden */
  14971. export var particlesVertexShader: {
  14972. name: string;
  14973. shader: string;
  14974. };
  14975. }
  14976. declare module BABYLON {
  14977. /**
  14978. * This represents a particle system in Babylon.
  14979. * 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.
  14980. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14981. * @example https://doc.babylonjs.com/babylon101/particles
  14982. */
  14983. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14984. /**
  14985. * Billboard mode will only apply to Y axis
  14986. */
  14987. static readonly BILLBOARDMODE_Y: number;
  14988. /**
  14989. * Billboard mode will apply to all axes
  14990. */
  14991. static readonly BILLBOARDMODE_ALL: number;
  14992. /**
  14993. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14994. */
  14995. static readonly BILLBOARDMODE_STRETCHED: number;
  14996. /**
  14997. * This function can be defined to provide custom update for active particles.
  14998. * This function will be called instead of regular update (age, position, color, etc.).
  14999. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15000. */
  15001. updateFunction: (particles: Particle[]) => void;
  15002. private _emitterWorldMatrix;
  15003. /**
  15004. * This function can be defined to specify initial direction for every new particle.
  15005. * It by default use the emitterType defined function
  15006. */
  15007. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15008. /**
  15009. * This function can be defined to specify initial position for every new particle.
  15010. * It by default use the emitterType defined function
  15011. */
  15012. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15013. /**
  15014. * @hidden
  15015. */
  15016. _inheritedVelocityOffset: Vector3;
  15017. /**
  15018. * An event triggered when the system is disposed
  15019. */
  15020. onDisposeObservable: Observable<ParticleSystem>;
  15021. private _onDisposeObserver;
  15022. /**
  15023. * Sets a callback that will be triggered when the system is disposed
  15024. */
  15025. onDispose: () => void;
  15026. private _particles;
  15027. private _epsilon;
  15028. private _capacity;
  15029. private _stockParticles;
  15030. private _newPartsExcess;
  15031. private _vertexData;
  15032. private _vertexBuffer;
  15033. private _vertexBuffers;
  15034. private _spriteBuffer;
  15035. private _indexBuffer;
  15036. private _effect;
  15037. private _customEffect;
  15038. private _cachedDefines;
  15039. private _scaledColorStep;
  15040. private _colorDiff;
  15041. private _scaledDirection;
  15042. private _scaledGravity;
  15043. private _currentRenderId;
  15044. private _alive;
  15045. private _useInstancing;
  15046. private _started;
  15047. private _stopped;
  15048. private _actualFrame;
  15049. private _scaledUpdateSpeed;
  15050. private _vertexBufferSize;
  15051. /** @hidden */
  15052. _currentEmitRateGradient: Nullable<FactorGradient>;
  15053. /** @hidden */
  15054. _currentEmitRate1: number;
  15055. /** @hidden */
  15056. _currentEmitRate2: number;
  15057. /** @hidden */
  15058. _currentStartSizeGradient: Nullable<FactorGradient>;
  15059. /** @hidden */
  15060. _currentStartSize1: number;
  15061. /** @hidden */
  15062. _currentStartSize2: number;
  15063. private readonly _rawTextureWidth;
  15064. private _rampGradientsTexture;
  15065. private _useRampGradients;
  15066. /** Gets or sets a boolean indicating that ramp gradients must be used
  15067. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15068. */
  15069. useRampGradients: boolean;
  15070. /**
  15071. * 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.
  15072. * 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: [])
  15073. */
  15074. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15075. private _subEmitters;
  15076. /**
  15077. * @hidden
  15078. * If the particle systems emitter should be disposed when the particle system is disposed
  15079. */
  15080. _disposeEmitterOnDispose: boolean;
  15081. /**
  15082. * The current active Sub-systems, this property is used by the root particle system only.
  15083. */
  15084. activeSubSystems: Array<ParticleSystem>;
  15085. private _rootParticleSystem;
  15086. /**
  15087. * Gets the current list of active particles
  15088. */
  15089. readonly particles: Particle[];
  15090. /**
  15091. * Returns the string "ParticleSystem"
  15092. * @returns a string containing the class name
  15093. */
  15094. getClassName(): string;
  15095. /**
  15096. * Instantiates a particle system.
  15097. * 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.
  15098. * @param name The name of the particle system
  15099. * @param capacity The max number of particles alive at the same time
  15100. * @param scene The scene the particle system belongs to
  15101. * @param customEffect a custom effect used to change the way particles are rendered by default
  15102. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15103. * @param epsilon Offset used to render the particles
  15104. */
  15105. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15106. private _addFactorGradient;
  15107. private _removeFactorGradient;
  15108. /**
  15109. * Adds a new life time gradient
  15110. * @param gradient defines the gradient to use (between 0 and 1)
  15111. * @param factor defines the life time factor to affect to the specified gradient
  15112. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15113. * @returns the current particle system
  15114. */
  15115. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15116. /**
  15117. * Remove a specific life time gradient
  15118. * @param gradient defines the gradient to remove
  15119. * @returns the current particle system
  15120. */
  15121. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15122. /**
  15123. * Adds a new size gradient
  15124. * @param gradient defines the gradient to use (between 0 and 1)
  15125. * @param factor defines the size factor to affect to the specified gradient
  15126. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15127. * @returns the current particle system
  15128. */
  15129. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15130. /**
  15131. * Remove a specific size gradient
  15132. * @param gradient defines the gradient to remove
  15133. * @returns the current particle system
  15134. */
  15135. removeSizeGradient(gradient: number): IParticleSystem;
  15136. /**
  15137. * Adds a new color remap gradient
  15138. * @param gradient defines the gradient to use (between 0 and 1)
  15139. * @param min defines the color remap minimal range
  15140. * @param max defines the color remap maximal range
  15141. * @returns the current particle system
  15142. */
  15143. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15144. /**
  15145. * Remove a specific color remap gradient
  15146. * @param gradient defines the gradient to remove
  15147. * @returns the current particle system
  15148. */
  15149. removeColorRemapGradient(gradient: number): IParticleSystem;
  15150. /**
  15151. * Adds a new alpha remap gradient
  15152. * @param gradient defines the gradient to use (between 0 and 1)
  15153. * @param min defines the alpha remap minimal range
  15154. * @param max defines the alpha remap maximal range
  15155. * @returns the current particle system
  15156. */
  15157. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15158. /**
  15159. * Remove a specific alpha remap gradient
  15160. * @param gradient defines the gradient to remove
  15161. * @returns the current particle system
  15162. */
  15163. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15164. /**
  15165. * Adds a new angular speed gradient
  15166. * @param gradient defines the gradient to use (between 0 and 1)
  15167. * @param factor defines the angular speed to affect to the specified gradient
  15168. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15169. * @returns the current particle system
  15170. */
  15171. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15172. /**
  15173. * Remove a specific angular speed gradient
  15174. * @param gradient defines the gradient to remove
  15175. * @returns the current particle system
  15176. */
  15177. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15178. /**
  15179. * Adds a new velocity gradient
  15180. * @param gradient defines the gradient to use (between 0 and 1)
  15181. * @param factor defines the velocity to affect to the specified gradient
  15182. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15183. * @returns the current particle system
  15184. */
  15185. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15186. /**
  15187. * Remove a specific velocity gradient
  15188. * @param gradient defines the gradient to remove
  15189. * @returns the current particle system
  15190. */
  15191. removeVelocityGradient(gradient: number): IParticleSystem;
  15192. /**
  15193. * Adds a new limit velocity gradient
  15194. * @param gradient defines the gradient to use (between 0 and 1)
  15195. * @param factor defines the limit velocity value to affect to the specified gradient
  15196. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15197. * @returns the current particle system
  15198. */
  15199. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15200. /**
  15201. * Remove a specific limit velocity gradient
  15202. * @param gradient defines the gradient to remove
  15203. * @returns the current particle system
  15204. */
  15205. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15206. /**
  15207. * Adds a new drag gradient
  15208. * @param gradient defines the gradient to use (between 0 and 1)
  15209. * @param factor defines the drag value to affect to the specified gradient
  15210. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15211. * @returns the current particle system
  15212. */
  15213. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15214. /**
  15215. * Remove a specific drag gradient
  15216. * @param gradient defines the gradient to remove
  15217. * @returns the current particle system
  15218. */
  15219. removeDragGradient(gradient: number): IParticleSystem;
  15220. /**
  15221. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15222. * @param gradient defines the gradient to use (between 0 and 1)
  15223. * @param factor defines the emit rate value to affect to the specified gradient
  15224. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15225. * @returns the current particle system
  15226. */
  15227. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15228. /**
  15229. * Remove a specific emit rate gradient
  15230. * @param gradient defines the gradient to remove
  15231. * @returns the current particle system
  15232. */
  15233. removeEmitRateGradient(gradient: number): IParticleSystem;
  15234. /**
  15235. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15236. * @param gradient defines the gradient to use (between 0 and 1)
  15237. * @param factor defines the start size value to affect to the specified gradient
  15238. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15239. * @returns the current particle system
  15240. */
  15241. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15242. /**
  15243. * Remove a specific start size gradient
  15244. * @param gradient defines the gradient to remove
  15245. * @returns the current particle system
  15246. */
  15247. removeStartSizeGradient(gradient: number): IParticleSystem;
  15248. private _createRampGradientTexture;
  15249. /**
  15250. * Gets the current list of ramp gradients.
  15251. * You must use addRampGradient and removeRampGradient to udpate this list
  15252. * @returns the list of ramp gradients
  15253. */
  15254. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15255. /**
  15256. * Adds a new ramp gradient used to remap particle colors
  15257. * @param gradient defines the gradient to use (between 0 and 1)
  15258. * @param color defines the color to affect to the specified gradient
  15259. * @returns the current particle system
  15260. */
  15261. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15262. /**
  15263. * Remove a specific ramp gradient
  15264. * @param gradient defines the gradient to remove
  15265. * @returns the current particle system
  15266. */
  15267. removeRampGradient(gradient: number): ParticleSystem;
  15268. /**
  15269. * Adds a new color gradient
  15270. * @param gradient defines the gradient to use (between 0 and 1)
  15271. * @param color1 defines the color to affect to the specified gradient
  15272. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15273. * @returns this particle system
  15274. */
  15275. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15276. /**
  15277. * Remove a specific color gradient
  15278. * @param gradient defines the gradient to remove
  15279. * @returns this particle system
  15280. */
  15281. removeColorGradient(gradient: number): IParticleSystem;
  15282. private _fetchR;
  15283. protected _reset(): void;
  15284. private _resetEffect;
  15285. private _createVertexBuffers;
  15286. private _createIndexBuffer;
  15287. /**
  15288. * Gets the maximum number of particles active at the same time.
  15289. * @returns The max number of active particles.
  15290. */
  15291. getCapacity(): number;
  15292. /**
  15293. * Gets whether there are still active particles in the system.
  15294. * @returns True if it is alive, otherwise false.
  15295. */
  15296. isAlive(): boolean;
  15297. /**
  15298. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15299. * @returns True if it has been started, otherwise false.
  15300. */
  15301. isStarted(): boolean;
  15302. private _prepareSubEmitterInternalArray;
  15303. /**
  15304. * Starts the particle system and begins to emit
  15305. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15306. */
  15307. start(delay?: number): void;
  15308. /**
  15309. * Stops the particle system.
  15310. * @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.
  15311. */
  15312. stop(stopSubEmitters?: boolean): void;
  15313. /**
  15314. * Remove all active particles
  15315. */
  15316. reset(): void;
  15317. /**
  15318. * @hidden (for internal use only)
  15319. */
  15320. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15321. /**
  15322. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15323. * Its lifetime will start back at 0.
  15324. */
  15325. recycleParticle: (particle: Particle) => void;
  15326. private _stopSubEmitters;
  15327. private _createParticle;
  15328. private _removeFromRoot;
  15329. private _emitFromParticle;
  15330. private _update;
  15331. /** @hidden */
  15332. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15333. /** @hidden */
  15334. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15335. /** @hidden */
  15336. private _getEffect;
  15337. /**
  15338. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15339. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15340. */
  15341. animate(preWarmOnly?: boolean): void;
  15342. private _appendParticleVertices;
  15343. /**
  15344. * Rebuilds the particle system.
  15345. */
  15346. rebuild(): void;
  15347. /**
  15348. * Is this system ready to be used/rendered
  15349. * @return true if the system is ready
  15350. */
  15351. isReady(): boolean;
  15352. private _render;
  15353. /**
  15354. * Renders the particle system in its current state.
  15355. * @returns the current number of particles
  15356. */
  15357. render(): number;
  15358. /**
  15359. * Disposes the particle system and free the associated resources
  15360. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15361. */
  15362. dispose(disposeTexture?: boolean): void;
  15363. /**
  15364. * Clones the particle system.
  15365. * @param name The name of the cloned object
  15366. * @param newEmitter The new emitter to use
  15367. * @returns the cloned particle system
  15368. */
  15369. clone(name: string, newEmitter: any): ParticleSystem;
  15370. /**
  15371. * Serializes the particle system to a JSON object.
  15372. * @returns the JSON object
  15373. */
  15374. serialize(): any;
  15375. /** @hidden */
  15376. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15377. /** @hidden */
  15378. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15379. /**
  15380. * Parses a JSON object to create a particle system.
  15381. * @param parsedParticleSystem The JSON object to parse
  15382. * @param scene The scene to create the particle system in
  15383. * @param rootUrl The root url to use to load external dependencies like texture
  15384. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15385. * @returns the Parsed particle system
  15386. */
  15387. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15388. }
  15389. }
  15390. declare module BABYLON {
  15391. /**
  15392. * A particle represents one of the element emitted by a particle system.
  15393. * This is mainly define by its coordinates, direction, velocity and age.
  15394. */
  15395. export class Particle {
  15396. /**
  15397. * The particle system the particle belongs to.
  15398. */
  15399. particleSystem: ParticleSystem;
  15400. private static _Count;
  15401. /**
  15402. * Unique ID of the particle
  15403. */
  15404. id: number;
  15405. /**
  15406. * The world position of the particle in the scene.
  15407. */
  15408. position: Vector3;
  15409. /**
  15410. * The world direction of the particle in the scene.
  15411. */
  15412. direction: Vector3;
  15413. /**
  15414. * The color of the particle.
  15415. */
  15416. color: Color4;
  15417. /**
  15418. * The color change of the particle per step.
  15419. */
  15420. colorStep: Color4;
  15421. /**
  15422. * Defines how long will the life of the particle be.
  15423. */
  15424. lifeTime: number;
  15425. /**
  15426. * The current age of the particle.
  15427. */
  15428. age: number;
  15429. /**
  15430. * The current size of the particle.
  15431. */
  15432. size: number;
  15433. /**
  15434. * The current scale of the particle.
  15435. */
  15436. scale: Vector2;
  15437. /**
  15438. * The current angle of the particle.
  15439. */
  15440. angle: number;
  15441. /**
  15442. * Defines how fast is the angle changing.
  15443. */
  15444. angularSpeed: number;
  15445. /**
  15446. * Defines the cell index used by the particle to be rendered from a sprite.
  15447. */
  15448. cellIndex: number;
  15449. /**
  15450. * The information required to support color remapping
  15451. */
  15452. remapData: Vector4;
  15453. /** @hidden */
  15454. _randomCellOffset?: number;
  15455. /** @hidden */
  15456. _initialDirection: Nullable<Vector3>;
  15457. /** @hidden */
  15458. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15459. /** @hidden */
  15460. _initialStartSpriteCellID: number;
  15461. /** @hidden */
  15462. _initialEndSpriteCellID: number;
  15463. /** @hidden */
  15464. _currentColorGradient: Nullable<ColorGradient>;
  15465. /** @hidden */
  15466. _currentColor1: Color4;
  15467. /** @hidden */
  15468. _currentColor2: Color4;
  15469. /** @hidden */
  15470. _currentSizeGradient: Nullable<FactorGradient>;
  15471. /** @hidden */
  15472. _currentSize1: number;
  15473. /** @hidden */
  15474. _currentSize2: number;
  15475. /** @hidden */
  15476. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15477. /** @hidden */
  15478. _currentAngularSpeed1: number;
  15479. /** @hidden */
  15480. _currentAngularSpeed2: number;
  15481. /** @hidden */
  15482. _currentVelocityGradient: Nullable<FactorGradient>;
  15483. /** @hidden */
  15484. _currentVelocity1: number;
  15485. /** @hidden */
  15486. _currentVelocity2: number;
  15487. /** @hidden */
  15488. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15489. /** @hidden */
  15490. _currentLimitVelocity1: number;
  15491. /** @hidden */
  15492. _currentLimitVelocity2: number;
  15493. /** @hidden */
  15494. _currentDragGradient: Nullable<FactorGradient>;
  15495. /** @hidden */
  15496. _currentDrag1: number;
  15497. /** @hidden */
  15498. _currentDrag2: number;
  15499. /** @hidden */
  15500. _randomNoiseCoordinates1: Vector3;
  15501. /** @hidden */
  15502. _randomNoiseCoordinates2: Vector3;
  15503. /**
  15504. * Creates a new instance Particle
  15505. * @param particleSystem the particle system the particle belongs to
  15506. */
  15507. constructor(
  15508. /**
  15509. * The particle system the particle belongs to.
  15510. */
  15511. particleSystem: ParticleSystem);
  15512. private updateCellInfoFromSystem;
  15513. /**
  15514. * Defines how the sprite cell index is updated for the particle
  15515. */
  15516. updateCellIndex(): void;
  15517. /** @hidden */
  15518. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15519. /** @hidden */
  15520. _inheritParticleInfoToSubEmitters(): void;
  15521. /** @hidden */
  15522. _reset(): void;
  15523. /**
  15524. * Copy the properties of particle to another one.
  15525. * @param other the particle to copy the information to.
  15526. */
  15527. copyTo(other: Particle): void;
  15528. }
  15529. }
  15530. declare module BABYLON {
  15531. /**
  15532. * Particle emitter represents a volume emitting particles.
  15533. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15534. */
  15535. export interface IParticleEmitterType {
  15536. /**
  15537. * Called by the particle System when the direction is computed for the created particle.
  15538. * @param worldMatrix is the world matrix of the particle system
  15539. * @param directionToUpdate is the direction vector to update with the result
  15540. * @param particle is the particle we are computed the direction for
  15541. */
  15542. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15543. /**
  15544. * Called by the particle System when the position is computed for the created particle.
  15545. * @param worldMatrix is the world matrix of the particle system
  15546. * @param positionToUpdate is the position vector to update with the result
  15547. * @param particle is the particle we are computed the position for
  15548. */
  15549. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15550. /**
  15551. * Clones the current emitter and returns a copy of it
  15552. * @returns the new emitter
  15553. */
  15554. clone(): IParticleEmitterType;
  15555. /**
  15556. * Called by the GPUParticleSystem to setup the update shader
  15557. * @param effect defines the update shader
  15558. */
  15559. applyToShader(effect: Effect): void;
  15560. /**
  15561. * Returns a string to use to update the GPU particles update shader
  15562. * @returns the effect defines string
  15563. */
  15564. getEffectDefines(): string;
  15565. /**
  15566. * Returns a string representing the class name
  15567. * @returns a string containing the class name
  15568. */
  15569. getClassName(): string;
  15570. /**
  15571. * Serializes the particle system to a JSON object.
  15572. * @returns the JSON object
  15573. */
  15574. serialize(): any;
  15575. /**
  15576. * Parse properties from a JSON object
  15577. * @param serializationObject defines the JSON object
  15578. */
  15579. parse(serializationObject: any): void;
  15580. }
  15581. }
  15582. declare module BABYLON {
  15583. /**
  15584. * Particle emitter emitting particles from the inside of a box.
  15585. * It emits the particles randomly between 2 given directions.
  15586. */
  15587. export class BoxParticleEmitter implements IParticleEmitterType {
  15588. /**
  15589. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15590. */
  15591. direction1: Vector3;
  15592. /**
  15593. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15594. */
  15595. direction2: Vector3;
  15596. /**
  15597. * 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.
  15598. */
  15599. minEmitBox: Vector3;
  15600. /**
  15601. * 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.
  15602. */
  15603. maxEmitBox: Vector3;
  15604. /**
  15605. * Creates a new instance BoxParticleEmitter
  15606. */
  15607. constructor();
  15608. /**
  15609. * Called by the particle System when the direction is computed for the created particle.
  15610. * @param worldMatrix is the world matrix of the particle system
  15611. * @param directionToUpdate is the direction vector to update with the result
  15612. * @param particle is the particle we are computed the direction for
  15613. */
  15614. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15615. /**
  15616. * Called by the particle System when the position is computed for the created particle.
  15617. * @param worldMatrix is the world matrix of the particle system
  15618. * @param positionToUpdate is the position vector to update with the result
  15619. * @param particle is the particle we are computed the position for
  15620. */
  15621. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15622. /**
  15623. * Clones the current emitter and returns a copy of it
  15624. * @returns the new emitter
  15625. */
  15626. clone(): BoxParticleEmitter;
  15627. /**
  15628. * Called by the GPUParticleSystem to setup the update shader
  15629. * @param effect defines the update shader
  15630. */
  15631. applyToShader(effect: Effect): void;
  15632. /**
  15633. * Returns a string to use to update the GPU particles update shader
  15634. * @returns a string containng the defines string
  15635. */
  15636. getEffectDefines(): string;
  15637. /**
  15638. * Returns the string "BoxParticleEmitter"
  15639. * @returns a string containing the class name
  15640. */
  15641. getClassName(): string;
  15642. /**
  15643. * Serializes the particle system to a JSON object.
  15644. * @returns the JSON object
  15645. */
  15646. serialize(): any;
  15647. /**
  15648. * Parse properties from a JSON object
  15649. * @param serializationObject defines the JSON object
  15650. */
  15651. parse(serializationObject: any): void;
  15652. }
  15653. }
  15654. declare module BABYLON {
  15655. /**
  15656. * Particle emitter emitting particles from the inside of a cone.
  15657. * It emits the particles alongside the cone volume from the base to the particle.
  15658. * The emission direction might be randomized.
  15659. */
  15660. export class ConeParticleEmitter implements IParticleEmitterType {
  15661. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15662. directionRandomizer: number;
  15663. private _radius;
  15664. private _angle;
  15665. private _height;
  15666. /**
  15667. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15668. */
  15669. radiusRange: number;
  15670. /**
  15671. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15672. */
  15673. heightRange: number;
  15674. /**
  15675. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15676. */
  15677. emitFromSpawnPointOnly: boolean;
  15678. /**
  15679. * Gets or sets the radius of the emission cone
  15680. */
  15681. radius: number;
  15682. /**
  15683. * Gets or sets the angle of the emission cone
  15684. */
  15685. angle: number;
  15686. private _buildHeight;
  15687. /**
  15688. * Creates a new instance ConeParticleEmitter
  15689. * @param radius the radius of the emission cone (1 by default)
  15690. * @param angle the cone base angle (PI by default)
  15691. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15692. */
  15693. constructor(radius?: number, angle?: number,
  15694. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15695. directionRandomizer?: number);
  15696. /**
  15697. * Called by the particle System when the direction is computed for the created particle.
  15698. * @param worldMatrix is the world matrix of the particle system
  15699. * @param directionToUpdate is the direction vector to update with the result
  15700. * @param particle is the particle we are computed the direction for
  15701. */
  15702. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15703. /**
  15704. * Called by the particle System when the position is computed for the created particle.
  15705. * @param worldMatrix is the world matrix of the particle system
  15706. * @param positionToUpdate is the position vector to update with the result
  15707. * @param particle is the particle we are computed the position for
  15708. */
  15709. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15710. /**
  15711. * Clones the current emitter and returns a copy of it
  15712. * @returns the new emitter
  15713. */
  15714. clone(): ConeParticleEmitter;
  15715. /**
  15716. * Called by the GPUParticleSystem to setup the update shader
  15717. * @param effect defines the update shader
  15718. */
  15719. applyToShader(effect: Effect): void;
  15720. /**
  15721. * Returns a string to use to update the GPU particles update shader
  15722. * @returns a string containng the defines string
  15723. */
  15724. getEffectDefines(): string;
  15725. /**
  15726. * Returns the string "ConeParticleEmitter"
  15727. * @returns a string containing the class name
  15728. */
  15729. getClassName(): string;
  15730. /**
  15731. * Serializes the particle system to a JSON object.
  15732. * @returns the JSON object
  15733. */
  15734. serialize(): any;
  15735. /**
  15736. * Parse properties from a JSON object
  15737. * @param serializationObject defines the JSON object
  15738. */
  15739. parse(serializationObject: any): void;
  15740. }
  15741. }
  15742. declare module BABYLON {
  15743. /**
  15744. * Particle emitter emitting particles from the inside of a cylinder.
  15745. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15746. */
  15747. export class CylinderParticleEmitter implements IParticleEmitterType {
  15748. /**
  15749. * The radius of the emission cylinder.
  15750. */
  15751. radius: number;
  15752. /**
  15753. * The height of the emission cylinder.
  15754. */
  15755. height: number;
  15756. /**
  15757. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15758. */
  15759. radiusRange: number;
  15760. /**
  15761. * How much to randomize the particle direction [0-1].
  15762. */
  15763. directionRandomizer: number;
  15764. /**
  15765. * Creates a new instance CylinderParticleEmitter
  15766. * @param radius the radius of the emission cylinder (1 by default)
  15767. * @param height the height of the emission cylinder (1 by default)
  15768. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15769. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15770. */
  15771. constructor(
  15772. /**
  15773. * The radius of the emission cylinder.
  15774. */
  15775. radius?: number,
  15776. /**
  15777. * The height of the emission cylinder.
  15778. */
  15779. height?: number,
  15780. /**
  15781. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15782. */
  15783. radiusRange?: number,
  15784. /**
  15785. * How much to randomize the particle direction [0-1].
  15786. */
  15787. directionRandomizer?: number);
  15788. /**
  15789. * Called by the particle System when the direction is computed for the created particle.
  15790. * @param worldMatrix is the world matrix of the particle system
  15791. * @param directionToUpdate is the direction vector to update with the result
  15792. * @param particle is the particle we are computed the direction for
  15793. */
  15794. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15795. /**
  15796. * Called by the particle System when the position is computed for the created particle.
  15797. * @param worldMatrix is the world matrix of the particle system
  15798. * @param positionToUpdate is the position vector to update with the result
  15799. * @param particle is the particle we are computed the position for
  15800. */
  15801. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15802. /**
  15803. * Clones the current emitter and returns a copy of it
  15804. * @returns the new emitter
  15805. */
  15806. clone(): CylinderParticleEmitter;
  15807. /**
  15808. * Called by the GPUParticleSystem to setup the update shader
  15809. * @param effect defines the update shader
  15810. */
  15811. applyToShader(effect: Effect): void;
  15812. /**
  15813. * Returns a string to use to update the GPU particles update shader
  15814. * @returns a string containng the defines string
  15815. */
  15816. getEffectDefines(): string;
  15817. /**
  15818. * Returns the string "CylinderParticleEmitter"
  15819. * @returns a string containing the class name
  15820. */
  15821. getClassName(): string;
  15822. /**
  15823. * Serializes the particle system to a JSON object.
  15824. * @returns the JSON object
  15825. */
  15826. serialize(): any;
  15827. /**
  15828. * Parse properties from a JSON object
  15829. * @param serializationObject defines the JSON object
  15830. */
  15831. parse(serializationObject: any): void;
  15832. }
  15833. /**
  15834. * Particle emitter emitting particles from the inside of a cylinder.
  15835. * It emits the particles randomly between two vectors.
  15836. */
  15837. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15838. /**
  15839. * The min limit of the emission direction.
  15840. */
  15841. direction1: Vector3;
  15842. /**
  15843. * The max limit of the emission direction.
  15844. */
  15845. direction2: Vector3;
  15846. /**
  15847. * Creates a new instance CylinderDirectedParticleEmitter
  15848. * @param radius the radius of the emission cylinder (1 by default)
  15849. * @param height the height of the emission cylinder (1 by default)
  15850. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15851. * @param direction1 the min limit of the emission direction (up vector by default)
  15852. * @param direction2 the max limit of the emission direction (up vector by default)
  15853. */
  15854. constructor(radius?: number, height?: number, radiusRange?: number,
  15855. /**
  15856. * The min limit of the emission direction.
  15857. */
  15858. direction1?: Vector3,
  15859. /**
  15860. * The max limit of the emission direction.
  15861. */
  15862. direction2?: Vector3);
  15863. /**
  15864. * Called by the particle System when the direction is computed for the created particle.
  15865. * @param worldMatrix is the world matrix of the particle system
  15866. * @param directionToUpdate is the direction vector to update with the result
  15867. * @param particle is the particle we are computed the direction for
  15868. */
  15869. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15870. /**
  15871. * Clones the current emitter and returns a copy of it
  15872. * @returns the new emitter
  15873. */
  15874. clone(): CylinderDirectedParticleEmitter;
  15875. /**
  15876. * Called by the GPUParticleSystem to setup the update shader
  15877. * @param effect defines the update shader
  15878. */
  15879. applyToShader(effect: Effect): void;
  15880. /**
  15881. * Returns a string to use to update the GPU particles update shader
  15882. * @returns a string containng the defines string
  15883. */
  15884. getEffectDefines(): string;
  15885. /**
  15886. * Returns the string "CylinderDirectedParticleEmitter"
  15887. * @returns a string containing the class name
  15888. */
  15889. getClassName(): string;
  15890. /**
  15891. * Serializes the particle system to a JSON object.
  15892. * @returns the JSON object
  15893. */
  15894. serialize(): any;
  15895. /**
  15896. * Parse properties from a JSON object
  15897. * @param serializationObject defines the JSON object
  15898. */
  15899. parse(serializationObject: any): void;
  15900. }
  15901. }
  15902. declare module BABYLON {
  15903. /**
  15904. * Particle emitter emitting particles from the inside of a hemisphere.
  15905. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15906. */
  15907. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15908. /**
  15909. * The radius of the emission hemisphere.
  15910. */
  15911. radius: number;
  15912. /**
  15913. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15914. */
  15915. radiusRange: number;
  15916. /**
  15917. * How much to randomize the particle direction [0-1].
  15918. */
  15919. directionRandomizer: number;
  15920. /**
  15921. * Creates a new instance HemisphericParticleEmitter
  15922. * @param radius the radius of the emission hemisphere (1 by default)
  15923. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15924. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15925. */
  15926. constructor(
  15927. /**
  15928. * The radius of the emission hemisphere.
  15929. */
  15930. radius?: number,
  15931. /**
  15932. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15933. */
  15934. radiusRange?: number,
  15935. /**
  15936. * How much to randomize the particle direction [0-1].
  15937. */
  15938. directionRandomizer?: number);
  15939. /**
  15940. * Called by the particle System when the direction is computed for the created particle.
  15941. * @param worldMatrix is the world matrix of the particle system
  15942. * @param directionToUpdate is the direction vector to update with the result
  15943. * @param particle is the particle we are computed the direction for
  15944. */
  15945. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15946. /**
  15947. * Called by the particle System when the position is computed for the created particle.
  15948. * @param worldMatrix is the world matrix of the particle system
  15949. * @param positionToUpdate is the position vector to update with the result
  15950. * @param particle is the particle we are computed the position for
  15951. */
  15952. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15953. /**
  15954. * Clones the current emitter and returns a copy of it
  15955. * @returns the new emitter
  15956. */
  15957. clone(): HemisphericParticleEmitter;
  15958. /**
  15959. * Called by the GPUParticleSystem to setup the update shader
  15960. * @param effect defines the update shader
  15961. */
  15962. applyToShader(effect: Effect): void;
  15963. /**
  15964. * Returns a string to use to update the GPU particles update shader
  15965. * @returns a string containng the defines string
  15966. */
  15967. getEffectDefines(): string;
  15968. /**
  15969. * Returns the string "HemisphericParticleEmitter"
  15970. * @returns a string containing the class name
  15971. */
  15972. getClassName(): string;
  15973. /**
  15974. * Serializes the particle system to a JSON object.
  15975. * @returns the JSON object
  15976. */
  15977. serialize(): any;
  15978. /**
  15979. * Parse properties from a JSON object
  15980. * @param serializationObject defines the JSON object
  15981. */
  15982. parse(serializationObject: any): void;
  15983. }
  15984. }
  15985. declare module BABYLON {
  15986. /**
  15987. * Particle emitter emitting particles from a point.
  15988. * It emits the particles randomly between 2 given directions.
  15989. */
  15990. export class PointParticleEmitter implements IParticleEmitterType {
  15991. /**
  15992. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15993. */
  15994. direction1: Vector3;
  15995. /**
  15996. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15997. */
  15998. direction2: Vector3;
  15999. /**
  16000. * Creates a new instance PointParticleEmitter
  16001. */
  16002. constructor();
  16003. /**
  16004. * Called by the particle System when the direction is computed for the created particle.
  16005. * @param worldMatrix is the world matrix of the particle system
  16006. * @param directionToUpdate is the direction vector to update with the result
  16007. * @param particle is the particle we are computed the direction for
  16008. */
  16009. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16010. /**
  16011. * Called by the particle System when the position is computed for the created particle.
  16012. * @param worldMatrix is the world matrix of the particle system
  16013. * @param positionToUpdate is the position vector to update with the result
  16014. * @param particle is the particle we are computed the position for
  16015. */
  16016. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16017. /**
  16018. * Clones the current emitter and returns a copy of it
  16019. * @returns the new emitter
  16020. */
  16021. clone(): PointParticleEmitter;
  16022. /**
  16023. * Called by the GPUParticleSystem to setup the update shader
  16024. * @param effect defines the update shader
  16025. */
  16026. applyToShader(effect: Effect): void;
  16027. /**
  16028. * Returns a string to use to update the GPU particles update shader
  16029. * @returns a string containng the defines string
  16030. */
  16031. getEffectDefines(): string;
  16032. /**
  16033. * Returns the string "PointParticleEmitter"
  16034. * @returns a string containing the class name
  16035. */
  16036. getClassName(): string;
  16037. /**
  16038. * Serializes the particle system to a JSON object.
  16039. * @returns the JSON object
  16040. */
  16041. serialize(): any;
  16042. /**
  16043. * Parse properties from a JSON object
  16044. * @param serializationObject defines the JSON object
  16045. */
  16046. parse(serializationObject: any): void;
  16047. }
  16048. }
  16049. declare module BABYLON {
  16050. /**
  16051. * Particle emitter emitting particles from the inside of a sphere.
  16052. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16053. */
  16054. export class SphereParticleEmitter implements IParticleEmitterType {
  16055. /**
  16056. * The radius of the emission sphere.
  16057. */
  16058. radius: number;
  16059. /**
  16060. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16061. */
  16062. radiusRange: number;
  16063. /**
  16064. * How much to randomize the particle direction [0-1].
  16065. */
  16066. directionRandomizer: number;
  16067. /**
  16068. * Creates a new instance SphereParticleEmitter
  16069. * @param radius the radius of the emission sphere (1 by default)
  16070. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16071. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16072. */
  16073. constructor(
  16074. /**
  16075. * The radius of the emission sphere.
  16076. */
  16077. radius?: number,
  16078. /**
  16079. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16080. */
  16081. radiusRange?: number,
  16082. /**
  16083. * How much to randomize the particle direction [0-1].
  16084. */
  16085. directionRandomizer?: number);
  16086. /**
  16087. * Called by the particle System when the direction is computed for the created particle.
  16088. * @param worldMatrix is the world matrix of the particle system
  16089. * @param directionToUpdate is the direction vector to update with the result
  16090. * @param particle is the particle we are computed the direction for
  16091. */
  16092. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16093. /**
  16094. * Called by the particle System when the position is computed for the created particle.
  16095. * @param worldMatrix is the world matrix of the particle system
  16096. * @param positionToUpdate is the position vector to update with the result
  16097. * @param particle is the particle we are computed the position for
  16098. */
  16099. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16100. /**
  16101. * Clones the current emitter and returns a copy of it
  16102. * @returns the new emitter
  16103. */
  16104. clone(): SphereParticleEmitter;
  16105. /**
  16106. * Called by the GPUParticleSystem to setup the update shader
  16107. * @param effect defines the update shader
  16108. */
  16109. applyToShader(effect: Effect): void;
  16110. /**
  16111. * Returns a string to use to update the GPU particles update shader
  16112. * @returns a string containng the defines string
  16113. */
  16114. getEffectDefines(): string;
  16115. /**
  16116. * Returns the string "SphereParticleEmitter"
  16117. * @returns a string containing the class name
  16118. */
  16119. getClassName(): string;
  16120. /**
  16121. * Serializes the particle system to a JSON object.
  16122. * @returns the JSON object
  16123. */
  16124. serialize(): any;
  16125. /**
  16126. * Parse properties from a JSON object
  16127. * @param serializationObject defines the JSON object
  16128. */
  16129. parse(serializationObject: any): void;
  16130. }
  16131. /**
  16132. * Particle emitter emitting particles from the inside of a sphere.
  16133. * It emits the particles randomly between two vectors.
  16134. */
  16135. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16136. /**
  16137. * The min limit of the emission direction.
  16138. */
  16139. direction1: Vector3;
  16140. /**
  16141. * The max limit of the emission direction.
  16142. */
  16143. direction2: Vector3;
  16144. /**
  16145. * Creates a new instance SphereDirectedParticleEmitter
  16146. * @param radius the radius of the emission sphere (1 by default)
  16147. * @param direction1 the min limit of the emission direction (up vector by default)
  16148. * @param direction2 the max limit of the emission direction (up vector by default)
  16149. */
  16150. constructor(radius?: number,
  16151. /**
  16152. * The min limit of the emission direction.
  16153. */
  16154. direction1?: Vector3,
  16155. /**
  16156. * The max limit of the emission direction.
  16157. */
  16158. direction2?: Vector3);
  16159. /**
  16160. * Called by the particle System when the direction is computed for the created particle.
  16161. * @param worldMatrix is the world matrix of the particle system
  16162. * @param directionToUpdate is the direction vector to update with the result
  16163. * @param particle is the particle we are computed the direction for
  16164. */
  16165. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16166. /**
  16167. * Clones the current emitter and returns a copy of it
  16168. * @returns the new emitter
  16169. */
  16170. clone(): SphereDirectedParticleEmitter;
  16171. /**
  16172. * Called by the GPUParticleSystem to setup the update shader
  16173. * @param effect defines the update shader
  16174. */
  16175. applyToShader(effect: Effect): void;
  16176. /**
  16177. * Returns a string to use to update the GPU particles update shader
  16178. * @returns a string containng the defines string
  16179. */
  16180. getEffectDefines(): string;
  16181. /**
  16182. * Returns the string "SphereDirectedParticleEmitter"
  16183. * @returns a string containing the class name
  16184. */
  16185. getClassName(): string;
  16186. /**
  16187. * Serializes the particle system to a JSON object.
  16188. * @returns the JSON object
  16189. */
  16190. serialize(): any;
  16191. /**
  16192. * Parse properties from a JSON object
  16193. * @param serializationObject defines the JSON object
  16194. */
  16195. parse(serializationObject: any): void;
  16196. }
  16197. }
  16198. declare module BABYLON {
  16199. /**
  16200. * Interface representing a particle system in Babylon.js.
  16201. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16202. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16203. */
  16204. export interface IParticleSystem {
  16205. /**
  16206. * List of animations used by the particle system.
  16207. */
  16208. animations: Animation[];
  16209. /**
  16210. * The id of the Particle system.
  16211. */
  16212. id: string;
  16213. /**
  16214. * The name of the Particle system.
  16215. */
  16216. name: string;
  16217. /**
  16218. * The emitter represents the Mesh or position we are attaching the particle system to.
  16219. */
  16220. emitter: Nullable<AbstractMesh | Vector3>;
  16221. /**
  16222. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16223. */
  16224. isBillboardBased: boolean;
  16225. /**
  16226. * The rendering group used by the Particle system to chose when to render.
  16227. */
  16228. renderingGroupId: number;
  16229. /**
  16230. * The layer mask we are rendering the particles through.
  16231. */
  16232. layerMask: number;
  16233. /**
  16234. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16235. */
  16236. updateSpeed: number;
  16237. /**
  16238. * The amount of time the particle system is running (depends of the overall update speed).
  16239. */
  16240. targetStopDuration: number;
  16241. /**
  16242. * The texture used to render each particle. (this can be a spritesheet)
  16243. */
  16244. particleTexture: Nullable<Texture>;
  16245. /**
  16246. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16247. */
  16248. blendMode: number;
  16249. /**
  16250. * Minimum life time of emitting particles.
  16251. */
  16252. minLifeTime: number;
  16253. /**
  16254. * Maximum life time of emitting particles.
  16255. */
  16256. maxLifeTime: number;
  16257. /**
  16258. * Minimum Size of emitting particles.
  16259. */
  16260. minSize: number;
  16261. /**
  16262. * Maximum Size of emitting particles.
  16263. */
  16264. maxSize: number;
  16265. /**
  16266. * Minimum scale of emitting particles on X axis.
  16267. */
  16268. minScaleX: number;
  16269. /**
  16270. * Maximum scale of emitting particles on X axis.
  16271. */
  16272. maxScaleX: number;
  16273. /**
  16274. * Minimum scale of emitting particles on Y axis.
  16275. */
  16276. minScaleY: number;
  16277. /**
  16278. * Maximum scale of emitting particles on Y axis.
  16279. */
  16280. maxScaleY: number;
  16281. /**
  16282. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16283. */
  16284. color1: Color4;
  16285. /**
  16286. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16287. */
  16288. color2: Color4;
  16289. /**
  16290. * Color the particle will have at the end of its lifetime.
  16291. */
  16292. colorDead: Color4;
  16293. /**
  16294. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16295. */
  16296. emitRate: number;
  16297. /**
  16298. * You can use gravity if you want to give an orientation to your particles.
  16299. */
  16300. gravity: Vector3;
  16301. /**
  16302. * Minimum power of emitting particles.
  16303. */
  16304. minEmitPower: number;
  16305. /**
  16306. * Maximum power of emitting particles.
  16307. */
  16308. maxEmitPower: number;
  16309. /**
  16310. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16311. */
  16312. minAngularSpeed: number;
  16313. /**
  16314. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16315. */
  16316. maxAngularSpeed: number;
  16317. /**
  16318. * Gets or sets the minimal initial rotation in radians.
  16319. */
  16320. minInitialRotation: number;
  16321. /**
  16322. * Gets or sets the maximal initial rotation in radians.
  16323. */
  16324. maxInitialRotation: number;
  16325. /**
  16326. * The particle emitter type defines the emitter used by the particle system.
  16327. * It can be for example box, sphere, or cone...
  16328. */
  16329. particleEmitterType: Nullable<IParticleEmitterType>;
  16330. /**
  16331. * Defines the delay in milliseconds before starting the system (0 by default)
  16332. */
  16333. startDelay: number;
  16334. /**
  16335. * 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
  16336. */
  16337. preWarmCycles: number;
  16338. /**
  16339. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16340. */
  16341. preWarmStepOffset: number;
  16342. /**
  16343. * 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)
  16344. */
  16345. spriteCellChangeSpeed: number;
  16346. /**
  16347. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16348. */
  16349. startSpriteCellID: number;
  16350. /**
  16351. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16352. */
  16353. endSpriteCellID: number;
  16354. /**
  16355. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16356. */
  16357. spriteCellWidth: number;
  16358. /**
  16359. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16360. */
  16361. spriteCellHeight: number;
  16362. /**
  16363. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16364. */
  16365. spriteRandomStartCell: boolean;
  16366. /**
  16367. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16368. */
  16369. isAnimationSheetEnabled: boolean;
  16370. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16371. translationPivot: Vector2;
  16372. /**
  16373. * Gets or sets a texture used to add random noise to particle positions
  16374. */
  16375. noiseTexture: Nullable<BaseTexture>;
  16376. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16377. noiseStrength: Vector3;
  16378. /**
  16379. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16380. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16381. */
  16382. billboardMode: number;
  16383. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16384. limitVelocityDamping: number;
  16385. /**
  16386. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16387. */
  16388. beginAnimationOnStart: boolean;
  16389. /**
  16390. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16391. */
  16392. beginAnimationFrom: number;
  16393. /**
  16394. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16395. */
  16396. beginAnimationTo: number;
  16397. /**
  16398. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16399. */
  16400. beginAnimationLoop: boolean;
  16401. /**
  16402. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16403. */
  16404. disposeOnStop: boolean;
  16405. /**
  16406. * Gets the maximum number of particles active at the same time.
  16407. * @returns The max number of active particles.
  16408. */
  16409. getCapacity(): number;
  16410. /**
  16411. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16412. * @returns True if it has been started, otherwise false.
  16413. */
  16414. isStarted(): boolean;
  16415. /**
  16416. * Animates the particle system for this frame.
  16417. */
  16418. animate(): void;
  16419. /**
  16420. * Renders the particle system in its current state.
  16421. * @returns the current number of particles
  16422. */
  16423. render(): number;
  16424. /**
  16425. * Dispose the particle system and frees its associated resources.
  16426. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16427. */
  16428. dispose(disposeTexture?: boolean): void;
  16429. /**
  16430. * Clones the particle system.
  16431. * @param name The name of the cloned object
  16432. * @param newEmitter The new emitter to use
  16433. * @returns the cloned particle system
  16434. */
  16435. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16436. /**
  16437. * Serializes the particle system to a JSON object.
  16438. * @returns the JSON object
  16439. */
  16440. serialize(): any;
  16441. /**
  16442. * Rebuild the particle system
  16443. */
  16444. rebuild(): void;
  16445. /**
  16446. * Starts the particle system and begins to emit
  16447. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16448. */
  16449. start(delay?: number): void;
  16450. /**
  16451. * Stops the particle system.
  16452. */
  16453. stop(): void;
  16454. /**
  16455. * Remove all active particles
  16456. */
  16457. reset(): void;
  16458. /**
  16459. * Is this system ready to be used/rendered
  16460. * @return true if the system is ready
  16461. */
  16462. isReady(): boolean;
  16463. /**
  16464. * Adds a new color gradient
  16465. * @param gradient defines the gradient to use (between 0 and 1)
  16466. * @param color1 defines the color to affect to the specified gradient
  16467. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16468. * @returns the current particle system
  16469. */
  16470. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16471. /**
  16472. * Remove a specific color gradient
  16473. * @param gradient defines the gradient to remove
  16474. * @returns the current particle system
  16475. */
  16476. removeColorGradient(gradient: number): IParticleSystem;
  16477. /**
  16478. * Adds a new size gradient
  16479. * @param gradient defines the gradient to use (between 0 and 1)
  16480. * @param factor defines the size factor to affect to the specified gradient
  16481. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16482. * @returns the current particle system
  16483. */
  16484. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16485. /**
  16486. * Remove a specific size gradient
  16487. * @param gradient defines the gradient to remove
  16488. * @returns the current particle system
  16489. */
  16490. removeSizeGradient(gradient: number): IParticleSystem;
  16491. /**
  16492. * Gets the current list of color gradients.
  16493. * You must use addColorGradient and removeColorGradient to udpate this list
  16494. * @returns the list of color gradients
  16495. */
  16496. getColorGradients(): Nullable<Array<ColorGradient>>;
  16497. /**
  16498. * Gets the current list of size gradients.
  16499. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16500. * @returns the list of size gradients
  16501. */
  16502. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16503. /**
  16504. * Gets the current list of angular speed gradients.
  16505. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16506. * @returns the list of angular speed gradients
  16507. */
  16508. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16509. /**
  16510. * Adds a new angular speed gradient
  16511. * @param gradient defines the gradient to use (between 0 and 1)
  16512. * @param factor defines the angular speed to affect to the specified gradient
  16513. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16514. * @returns the current particle system
  16515. */
  16516. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16517. /**
  16518. * Remove a specific angular speed gradient
  16519. * @param gradient defines the gradient to remove
  16520. * @returns the current particle system
  16521. */
  16522. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16523. /**
  16524. * Gets the current list of velocity gradients.
  16525. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16526. * @returns the list of velocity gradients
  16527. */
  16528. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16529. /**
  16530. * Adds a new velocity gradient
  16531. * @param gradient defines the gradient to use (between 0 and 1)
  16532. * @param factor defines the velocity to affect to the specified gradient
  16533. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16534. * @returns the current particle system
  16535. */
  16536. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16537. /**
  16538. * Remove a specific velocity gradient
  16539. * @param gradient defines the gradient to remove
  16540. * @returns the current particle system
  16541. */
  16542. removeVelocityGradient(gradient: number): IParticleSystem;
  16543. /**
  16544. * Gets the current list of limit velocity gradients.
  16545. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16546. * @returns the list of limit velocity gradients
  16547. */
  16548. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16549. /**
  16550. * Adds a new limit velocity gradient
  16551. * @param gradient defines the gradient to use (between 0 and 1)
  16552. * @param factor defines the limit velocity to affect to the specified gradient
  16553. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16554. * @returns the current particle system
  16555. */
  16556. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16557. /**
  16558. * Remove a specific limit velocity gradient
  16559. * @param gradient defines the gradient to remove
  16560. * @returns the current particle system
  16561. */
  16562. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16563. /**
  16564. * Adds a new drag gradient
  16565. * @param gradient defines the gradient to use (between 0 and 1)
  16566. * @param factor defines the drag to affect to the specified gradient
  16567. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16568. * @returns the current particle system
  16569. */
  16570. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16571. /**
  16572. * Remove a specific drag gradient
  16573. * @param gradient defines the gradient to remove
  16574. * @returns the current particle system
  16575. */
  16576. removeDragGradient(gradient: number): IParticleSystem;
  16577. /**
  16578. * Gets the current list of drag gradients.
  16579. * You must use addDragGradient and removeDragGradient to udpate this list
  16580. * @returns the list of drag gradients
  16581. */
  16582. getDragGradients(): Nullable<Array<FactorGradient>>;
  16583. /**
  16584. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16585. * @param gradient defines the gradient to use (between 0 and 1)
  16586. * @param factor defines the emit rate to affect to the specified gradient
  16587. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16588. * @returns the current particle system
  16589. */
  16590. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16591. /**
  16592. * Remove a specific emit rate gradient
  16593. * @param gradient defines the gradient to remove
  16594. * @returns the current particle system
  16595. */
  16596. removeEmitRateGradient(gradient: number): IParticleSystem;
  16597. /**
  16598. * Gets the current list of emit rate gradients.
  16599. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16600. * @returns the list of emit rate gradients
  16601. */
  16602. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16603. /**
  16604. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16605. * @param gradient defines the gradient to use (between 0 and 1)
  16606. * @param factor defines the start size to affect to the specified gradient
  16607. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16608. * @returns the current particle system
  16609. */
  16610. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16611. /**
  16612. * Remove a specific start size gradient
  16613. * @param gradient defines the gradient to remove
  16614. * @returns the current particle system
  16615. */
  16616. removeStartSizeGradient(gradient: number): IParticleSystem;
  16617. /**
  16618. * Gets the current list of start size gradients.
  16619. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16620. * @returns the list of start size gradients
  16621. */
  16622. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16623. /**
  16624. * Adds a new life time gradient
  16625. * @param gradient defines the gradient to use (between 0 and 1)
  16626. * @param factor defines the life time factor to affect to the specified gradient
  16627. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16628. * @returns the current particle system
  16629. */
  16630. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16631. /**
  16632. * Remove a specific life time gradient
  16633. * @param gradient defines the gradient to remove
  16634. * @returns the current particle system
  16635. */
  16636. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16637. /**
  16638. * Gets the current list of life time gradients.
  16639. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16640. * @returns the list of life time gradients
  16641. */
  16642. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16643. /**
  16644. * Gets the current list of color gradients.
  16645. * You must use addColorGradient and removeColorGradient to udpate this list
  16646. * @returns the list of color gradients
  16647. */
  16648. getColorGradients(): Nullable<Array<ColorGradient>>;
  16649. /**
  16650. * Adds a new ramp gradient used to remap particle colors
  16651. * @param gradient defines the gradient to use (between 0 and 1)
  16652. * @param color defines the color to affect to the specified gradient
  16653. * @returns the current particle system
  16654. */
  16655. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16656. /**
  16657. * Gets the current list of ramp gradients.
  16658. * You must use addRampGradient and removeRampGradient to udpate this list
  16659. * @returns the list of ramp gradients
  16660. */
  16661. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16662. /** Gets or sets a boolean indicating that ramp gradients must be used
  16663. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16664. */
  16665. useRampGradients: boolean;
  16666. /**
  16667. * Adds a new color remap gradient
  16668. * @param gradient defines the gradient to use (between 0 and 1)
  16669. * @param min defines the color remap minimal range
  16670. * @param max defines the color remap maximal range
  16671. * @returns the current particle system
  16672. */
  16673. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16674. /**
  16675. * Gets the current list of color remap gradients.
  16676. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16677. * @returns the list of color remap gradients
  16678. */
  16679. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16680. /**
  16681. * Adds a new alpha remap gradient
  16682. * @param gradient defines the gradient to use (between 0 and 1)
  16683. * @param min defines the alpha remap minimal range
  16684. * @param max defines the alpha remap maximal range
  16685. * @returns the current particle system
  16686. */
  16687. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16688. /**
  16689. * Gets the current list of alpha remap gradients.
  16690. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16691. * @returns the list of alpha remap gradients
  16692. */
  16693. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16694. /**
  16695. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16696. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16697. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16698. * @returns the emitter
  16699. */
  16700. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16701. /**
  16702. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16703. * @param radius The radius of the hemisphere to emit from
  16704. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16705. * @returns the emitter
  16706. */
  16707. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16708. /**
  16709. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16710. * @param radius The radius of the sphere to emit from
  16711. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16712. * @returns the emitter
  16713. */
  16714. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16715. /**
  16716. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16717. * @param radius The radius of the sphere to emit from
  16718. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16719. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16720. * @returns the emitter
  16721. */
  16722. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16723. /**
  16724. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16725. * @param radius The radius of the emission cylinder
  16726. * @param height The height of the emission cylinder
  16727. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16728. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16729. * @returns the emitter
  16730. */
  16731. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16732. /**
  16733. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16734. * @param radius The radius of the cylinder to emit from
  16735. * @param height The height of the emission cylinder
  16736. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16737. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16738. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16739. * @returns the emitter
  16740. */
  16741. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16742. /**
  16743. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16744. * @param radius The radius of the cone to emit from
  16745. * @param angle The base angle of the cone
  16746. * @returns the emitter
  16747. */
  16748. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16749. /**
  16750. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16751. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16752. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16753. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16754. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16755. * @returns the emitter
  16756. */
  16757. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16758. /**
  16759. * Get hosting scene
  16760. * @returns the scene
  16761. */
  16762. getScene(): Scene;
  16763. }
  16764. }
  16765. declare module BABYLON {
  16766. /**
  16767. * Creates an instance based on a source mesh.
  16768. */
  16769. export class InstancedMesh extends AbstractMesh {
  16770. private _sourceMesh;
  16771. private _currentLOD;
  16772. /** @hidden */
  16773. _indexInSourceMeshInstanceArray: number;
  16774. constructor(name: string, source: Mesh);
  16775. /**
  16776. * Returns the string "InstancedMesh".
  16777. */
  16778. getClassName(): string;
  16779. /** Gets the list of lights affecting that mesh */
  16780. readonly lightSources: Light[];
  16781. _resyncLightSources(): void;
  16782. _resyncLighSource(light: Light): void;
  16783. _removeLightSource(light: Light): void;
  16784. /**
  16785. * If the source mesh receives shadows
  16786. */
  16787. readonly receiveShadows: boolean;
  16788. /**
  16789. * The material of the source mesh
  16790. */
  16791. readonly material: Nullable<Material>;
  16792. /**
  16793. * Visibility of the source mesh
  16794. */
  16795. readonly visibility: number;
  16796. /**
  16797. * Skeleton of the source mesh
  16798. */
  16799. readonly skeleton: Nullable<Skeleton>;
  16800. /**
  16801. * Rendering ground id of the source mesh
  16802. */
  16803. renderingGroupId: number;
  16804. /**
  16805. * Returns the total number of vertices (integer).
  16806. */
  16807. getTotalVertices(): number;
  16808. /**
  16809. * Returns a positive integer : the total number of indices in this mesh geometry.
  16810. * @returns the numner of indices or zero if the mesh has no geometry.
  16811. */
  16812. getTotalIndices(): number;
  16813. /**
  16814. * The source mesh of the instance
  16815. */
  16816. readonly sourceMesh: Mesh;
  16817. /**
  16818. * Is this node ready to be used/rendered
  16819. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16820. * @return {boolean} is it ready
  16821. */
  16822. isReady(completeCheck?: boolean): boolean;
  16823. /**
  16824. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16825. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16826. * @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.
  16827. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16828. */
  16829. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16830. /**
  16831. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16832. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16833. * The `data` are either a numeric array either a Float32Array.
  16834. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16835. * 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).
  16836. * Note that a new underlying VertexBuffer object is created each call.
  16837. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16838. *
  16839. * Possible `kind` values :
  16840. * - VertexBuffer.PositionKind
  16841. * - VertexBuffer.UVKind
  16842. * - VertexBuffer.UV2Kind
  16843. * - VertexBuffer.UV3Kind
  16844. * - VertexBuffer.UV4Kind
  16845. * - VertexBuffer.UV5Kind
  16846. * - VertexBuffer.UV6Kind
  16847. * - VertexBuffer.ColorKind
  16848. * - VertexBuffer.MatricesIndicesKind
  16849. * - VertexBuffer.MatricesIndicesExtraKind
  16850. * - VertexBuffer.MatricesWeightsKind
  16851. * - VertexBuffer.MatricesWeightsExtraKind
  16852. *
  16853. * Returns the Mesh.
  16854. */
  16855. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16856. /**
  16857. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16858. * If the mesh has no geometry, it is simply returned as it is.
  16859. * The `data` are either a numeric array either a Float32Array.
  16860. * No new underlying VertexBuffer object is created.
  16861. * 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.
  16862. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16863. *
  16864. * Possible `kind` values :
  16865. * - VertexBuffer.PositionKind
  16866. * - VertexBuffer.UVKind
  16867. * - VertexBuffer.UV2Kind
  16868. * - VertexBuffer.UV3Kind
  16869. * - VertexBuffer.UV4Kind
  16870. * - VertexBuffer.UV5Kind
  16871. * - VertexBuffer.UV6Kind
  16872. * - VertexBuffer.ColorKind
  16873. * - VertexBuffer.MatricesIndicesKind
  16874. * - VertexBuffer.MatricesIndicesExtraKind
  16875. * - VertexBuffer.MatricesWeightsKind
  16876. * - VertexBuffer.MatricesWeightsExtraKind
  16877. *
  16878. * Returns the Mesh.
  16879. */
  16880. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16881. /**
  16882. * Sets the mesh indices.
  16883. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16884. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16885. * This method creates a new index buffer each call.
  16886. * Returns the Mesh.
  16887. */
  16888. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16889. /**
  16890. * Boolean : True if the mesh owns the requested kind of data.
  16891. */
  16892. isVerticesDataPresent(kind: string): boolean;
  16893. /**
  16894. * Returns an array of indices (IndicesArray).
  16895. */
  16896. getIndices(): Nullable<IndicesArray>;
  16897. readonly _positions: Nullable<Vector3[]>;
  16898. /**
  16899. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16900. * This means the mesh underlying bounding box and sphere are recomputed.
  16901. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16902. * @returns the current mesh
  16903. */
  16904. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16905. /** @hidden */
  16906. _preActivate(): InstancedMesh;
  16907. /** @hidden */
  16908. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16909. /** @hidden */
  16910. _postActivate(): void;
  16911. getWorldMatrix(): Matrix;
  16912. readonly isAnInstance: boolean;
  16913. /**
  16914. * Returns the current associated LOD AbstractMesh.
  16915. */
  16916. getLOD(camera: Camera): AbstractMesh;
  16917. /** @hidden */
  16918. _syncSubMeshes(): InstancedMesh;
  16919. /** @hidden */
  16920. _generatePointsArray(): boolean;
  16921. /**
  16922. * Creates a new InstancedMesh from the current mesh.
  16923. * - name (string) : the cloned mesh name
  16924. * - newParent (optional Node) : the optional Node to parent the clone to.
  16925. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16926. *
  16927. * Returns the clone.
  16928. */
  16929. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16930. /**
  16931. * Disposes the InstancedMesh.
  16932. * Returns nothing.
  16933. */
  16934. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16935. }
  16936. }
  16937. declare module BABYLON {
  16938. /**
  16939. * Defines the options associated with the creation of a shader material.
  16940. */
  16941. export interface IShaderMaterialOptions {
  16942. /**
  16943. * Does the material work in alpha blend mode
  16944. */
  16945. needAlphaBlending: boolean;
  16946. /**
  16947. * Does the material work in alpha test mode
  16948. */
  16949. needAlphaTesting: boolean;
  16950. /**
  16951. * The list of attribute names used in the shader
  16952. */
  16953. attributes: string[];
  16954. /**
  16955. * The list of unifrom names used in the shader
  16956. */
  16957. uniforms: string[];
  16958. /**
  16959. * The list of UBO names used in the shader
  16960. */
  16961. uniformBuffers: string[];
  16962. /**
  16963. * The list of sampler names used in the shader
  16964. */
  16965. samplers: string[];
  16966. /**
  16967. * The list of defines used in the shader
  16968. */
  16969. defines: string[];
  16970. }
  16971. /**
  16972. * 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.
  16973. *
  16974. * This returned material effects how the mesh will look based on the code in the shaders.
  16975. *
  16976. * @see http://doc.babylonjs.com/how_to/shader_material
  16977. */
  16978. export class ShaderMaterial extends Material {
  16979. private _shaderPath;
  16980. private _options;
  16981. private _textures;
  16982. private _textureArrays;
  16983. private _floats;
  16984. private _ints;
  16985. private _floatsArrays;
  16986. private _colors3;
  16987. private _colors3Arrays;
  16988. private _colors4;
  16989. private _vectors2;
  16990. private _vectors3;
  16991. private _vectors4;
  16992. private _matrices;
  16993. private _matrices3x3;
  16994. private _matrices2x2;
  16995. private _vectors2Arrays;
  16996. private _vectors3Arrays;
  16997. private _cachedWorldViewMatrix;
  16998. private _cachedWorldViewProjectionMatrix;
  16999. private _renderId;
  17000. /**
  17001. * Instantiate a new shader material.
  17002. * 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.
  17003. * This returned material effects how the mesh will look based on the code in the shaders.
  17004. * @see http://doc.babylonjs.com/how_to/shader_material
  17005. * @param name Define the name of the material in the scene
  17006. * @param scene Define the scene the material belongs to
  17007. * @param shaderPath Defines the route to the shader code in one of three ways:
  17008. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17009. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17010. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17011. * @param options Define the options used to create the shader
  17012. */
  17013. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17014. /**
  17015. * Gets the options used to compile the shader.
  17016. * They can be modified to trigger a new compilation
  17017. */
  17018. readonly options: IShaderMaterialOptions;
  17019. /**
  17020. * Gets the current class name of the material e.g. "ShaderMaterial"
  17021. * Mainly use in serialization.
  17022. * @returns the class name
  17023. */
  17024. getClassName(): string;
  17025. /**
  17026. * Specifies if the material will require alpha blending
  17027. * @returns a boolean specifying if alpha blending is needed
  17028. */
  17029. needAlphaBlending(): boolean;
  17030. /**
  17031. * Specifies if this material should be rendered in alpha test mode
  17032. * @returns a boolean specifying if an alpha test is needed.
  17033. */
  17034. needAlphaTesting(): boolean;
  17035. private _checkUniform;
  17036. /**
  17037. * Set a texture in the shader.
  17038. * @param name Define the name of the uniform samplers as defined in the shader
  17039. * @param texture Define the texture to bind to this sampler
  17040. * @return the material itself allowing "fluent" like uniform updates
  17041. */
  17042. setTexture(name: string, texture: Texture): ShaderMaterial;
  17043. /**
  17044. * Set a texture array in the shader.
  17045. * @param name Define the name of the uniform sampler array as defined in the shader
  17046. * @param textures Define the list of textures to bind to this sampler
  17047. * @return the material itself allowing "fluent" like uniform updates
  17048. */
  17049. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17050. /**
  17051. * Set a float in the shader.
  17052. * @param name Define the name of the uniform as defined in the shader
  17053. * @param value Define the value to give to the uniform
  17054. * @return the material itself allowing "fluent" like uniform updates
  17055. */
  17056. setFloat(name: string, value: number): ShaderMaterial;
  17057. /**
  17058. * Set a int in the shader.
  17059. * @param name Define the name of the uniform as defined in the shader
  17060. * @param value Define the value to give to the uniform
  17061. * @return the material itself allowing "fluent" like uniform updates
  17062. */
  17063. setInt(name: string, value: number): ShaderMaterial;
  17064. /**
  17065. * Set an array of floats in the shader.
  17066. * @param name Define the name of the uniform as defined in the shader
  17067. * @param value Define the value to give to the uniform
  17068. * @return the material itself allowing "fluent" like uniform updates
  17069. */
  17070. setFloats(name: string, value: number[]): ShaderMaterial;
  17071. /**
  17072. * Set a vec3 in the shader from a Color3.
  17073. * @param name Define the name of the uniform as defined in the shader
  17074. * @param value Define the value to give to the uniform
  17075. * @return the material itself allowing "fluent" like uniform updates
  17076. */
  17077. setColor3(name: string, value: Color3): ShaderMaterial;
  17078. /**
  17079. * Set a vec3 array in the shader from a Color3 array.
  17080. * @param name Define the name of the uniform as defined in the shader
  17081. * @param value Define the value to give to the uniform
  17082. * @return the material itself allowing "fluent" like uniform updates
  17083. */
  17084. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17085. /**
  17086. * Set a vec4 in the shader from a Color4.
  17087. * @param name Define the name of the uniform as defined in the shader
  17088. * @param value Define the value to give to the uniform
  17089. * @return the material itself allowing "fluent" like uniform updates
  17090. */
  17091. setColor4(name: string, value: Color4): ShaderMaterial;
  17092. /**
  17093. * Set a vec2 in the shader from a Vector2.
  17094. * @param name Define the name of the uniform as defined in the shader
  17095. * @param value Define the value to give to the uniform
  17096. * @return the material itself allowing "fluent" like uniform updates
  17097. */
  17098. setVector2(name: string, value: Vector2): ShaderMaterial;
  17099. /**
  17100. * Set a vec3 in the shader from a Vector3.
  17101. * @param name Define the name of the uniform as defined in the shader
  17102. * @param value Define the value to give to the uniform
  17103. * @return the material itself allowing "fluent" like uniform updates
  17104. */
  17105. setVector3(name: string, value: Vector3): ShaderMaterial;
  17106. /**
  17107. * Set a vec4 in the shader from a Vector4.
  17108. * @param name Define the name of the uniform as defined in the shader
  17109. * @param value Define the value to give to the uniform
  17110. * @return the material itself allowing "fluent" like uniform updates
  17111. */
  17112. setVector4(name: string, value: Vector4): ShaderMaterial;
  17113. /**
  17114. * Set a mat4 in the shader from a Matrix.
  17115. * @param name Define the name of the uniform as defined in the shader
  17116. * @param value Define the value to give to the uniform
  17117. * @return the material itself allowing "fluent" like uniform updates
  17118. */
  17119. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17120. /**
  17121. * Set a mat3 in the shader from a Float32Array.
  17122. * @param name Define the name of the uniform as defined in the shader
  17123. * @param value Define the value to give to the uniform
  17124. * @return the material itself allowing "fluent" like uniform updates
  17125. */
  17126. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17127. /**
  17128. * Set a mat2 in the shader from a Float32Array.
  17129. * @param name Define the name of the uniform as defined in the shader
  17130. * @param value Define the value to give to the uniform
  17131. * @return the material itself allowing "fluent" like uniform updates
  17132. */
  17133. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17134. /**
  17135. * Set a vec2 array in the shader from a number array.
  17136. * @param name Define the name of the uniform as defined in the shader
  17137. * @param value Define the value to give to the uniform
  17138. * @return the material itself allowing "fluent" like uniform updates
  17139. */
  17140. setArray2(name: string, value: number[]): ShaderMaterial;
  17141. /**
  17142. * Set a vec3 array in the shader from a number array.
  17143. * @param name Define the name of the uniform as defined in the shader
  17144. * @param value Define the value to give to the uniform
  17145. * @return the material itself allowing "fluent" like uniform updates
  17146. */
  17147. setArray3(name: string, value: number[]): ShaderMaterial;
  17148. private _checkCache;
  17149. /**
  17150. * Specifies that the submesh is ready to be used
  17151. * @param mesh defines the mesh to check
  17152. * @param subMesh defines which submesh to check
  17153. * @param useInstances specifies that instances should be used
  17154. * @returns a boolean indicating that the submesh is ready or not
  17155. */
  17156. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17157. /**
  17158. * Checks if the material is ready to render the requested mesh
  17159. * @param mesh Define the mesh to render
  17160. * @param useInstances Define whether or not the material is used with instances
  17161. * @returns true if ready, otherwise false
  17162. */
  17163. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17164. /**
  17165. * Binds the world matrix to the material
  17166. * @param world defines the world transformation matrix
  17167. */
  17168. bindOnlyWorldMatrix(world: Matrix): void;
  17169. /**
  17170. * Binds the material to the mesh
  17171. * @param world defines the world transformation matrix
  17172. * @param mesh defines the mesh to bind the material to
  17173. */
  17174. bind(world: Matrix, mesh?: Mesh): void;
  17175. /**
  17176. * Gets the active textures from the material
  17177. * @returns an array of textures
  17178. */
  17179. getActiveTextures(): BaseTexture[];
  17180. /**
  17181. * Specifies if the material uses a texture
  17182. * @param texture defines the texture to check against the material
  17183. * @returns a boolean specifying if the material uses the texture
  17184. */
  17185. hasTexture(texture: BaseTexture): boolean;
  17186. /**
  17187. * Makes a duplicate of the material, and gives it a new name
  17188. * @param name defines the new name for the duplicated material
  17189. * @returns the cloned material
  17190. */
  17191. clone(name: string): ShaderMaterial;
  17192. /**
  17193. * Disposes the material
  17194. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17195. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17196. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17197. */
  17198. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17199. /**
  17200. * Serializes this material in a JSON representation
  17201. * @returns the serialized material object
  17202. */
  17203. serialize(): any;
  17204. /**
  17205. * Creates a shader material from parsed shader material data
  17206. * @param source defines the JSON represnetation of the material
  17207. * @param scene defines the hosting scene
  17208. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17209. * @returns a new material
  17210. */
  17211. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17212. }
  17213. }
  17214. declare module BABYLON {
  17215. /** @hidden */
  17216. export var colorPixelShader: {
  17217. name: string;
  17218. shader: string;
  17219. };
  17220. }
  17221. declare module BABYLON {
  17222. /** @hidden */
  17223. export var colorVertexShader: {
  17224. name: string;
  17225. shader: string;
  17226. };
  17227. }
  17228. declare module BABYLON {
  17229. /**
  17230. * Line mesh
  17231. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17232. */
  17233. export class LinesMesh extends Mesh {
  17234. /**
  17235. * If vertex color should be applied to the mesh
  17236. */
  17237. readonly useVertexColor?: boolean | undefined;
  17238. /**
  17239. * If vertex alpha should be applied to the mesh
  17240. */
  17241. readonly useVertexAlpha?: boolean | undefined;
  17242. /**
  17243. * Color of the line (Default: White)
  17244. */
  17245. color: Color3;
  17246. /**
  17247. * Alpha of the line (Default: 1)
  17248. */
  17249. alpha: number;
  17250. /**
  17251. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17252. * This margin is expressed in world space coordinates, so its value may vary.
  17253. * Default value is 0.1
  17254. */
  17255. intersectionThreshold: number;
  17256. private _colorShader;
  17257. private color4;
  17258. /**
  17259. * Creates a new LinesMesh
  17260. * @param name defines the name
  17261. * @param scene defines the hosting scene
  17262. * @param parent defines the parent mesh if any
  17263. * @param source defines the optional source LinesMesh used to clone data from
  17264. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17265. * When false, achieved by calling a clone(), also passing False.
  17266. * This will make creation of children, recursive.
  17267. * @param useVertexColor defines if this LinesMesh supports vertex color
  17268. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17269. */
  17270. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17271. /**
  17272. * If vertex color should be applied to the mesh
  17273. */
  17274. useVertexColor?: boolean | undefined,
  17275. /**
  17276. * If vertex alpha should be applied to the mesh
  17277. */
  17278. useVertexAlpha?: boolean | undefined);
  17279. private _addClipPlaneDefine;
  17280. private _removeClipPlaneDefine;
  17281. isReady(): boolean;
  17282. /**
  17283. * Returns the string "LineMesh"
  17284. */
  17285. getClassName(): string;
  17286. /**
  17287. * @hidden
  17288. */
  17289. /**
  17290. * @hidden
  17291. */
  17292. material: Material;
  17293. /**
  17294. * @hidden
  17295. */
  17296. readonly checkCollisions: boolean;
  17297. /** @hidden */
  17298. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17299. /** @hidden */
  17300. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17301. /**
  17302. * Disposes of the line mesh
  17303. * @param doNotRecurse If children should be disposed
  17304. */
  17305. dispose(doNotRecurse?: boolean): void;
  17306. /**
  17307. * Returns a new LineMesh object cloned from the current one.
  17308. */
  17309. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17310. /**
  17311. * Creates a new InstancedLinesMesh object from the mesh model.
  17312. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17313. * @param name defines the name of the new instance
  17314. * @returns a new InstancedLinesMesh
  17315. */
  17316. createInstance(name: string): InstancedLinesMesh;
  17317. }
  17318. /**
  17319. * Creates an instance based on a source LinesMesh
  17320. */
  17321. export class InstancedLinesMesh extends InstancedMesh {
  17322. /**
  17323. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17324. * This margin is expressed in world space coordinates, so its value may vary.
  17325. * Initilized with the intersectionThreshold value of the source LinesMesh
  17326. */
  17327. intersectionThreshold: number;
  17328. constructor(name: string, source: LinesMesh);
  17329. /**
  17330. * Returns the string "InstancedLinesMesh".
  17331. */
  17332. getClassName(): string;
  17333. }
  17334. }
  17335. declare module BABYLON {
  17336. /** @hidden */
  17337. export var linePixelShader: {
  17338. name: string;
  17339. shader: string;
  17340. };
  17341. }
  17342. declare module BABYLON {
  17343. /** @hidden */
  17344. export var lineVertexShader: {
  17345. name: string;
  17346. shader: string;
  17347. };
  17348. }
  17349. declare module BABYLON {
  17350. interface AbstractMesh {
  17351. /**
  17352. * Gets the edgesRenderer associated with the mesh
  17353. */
  17354. edgesRenderer: Nullable<EdgesRenderer>;
  17355. }
  17356. interface LinesMesh {
  17357. /**
  17358. * Enables the edge rendering mode on the mesh.
  17359. * This mode makes the mesh edges visible
  17360. * @param epsilon defines the maximal distance between two angles to detect a face
  17361. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17362. * @returns the currentAbstractMesh
  17363. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17364. */
  17365. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17366. }
  17367. interface InstancedLinesMesh {
  17368. /**
  17369. * Enables the edge rendering mode on the mesh.
  17370. * This mode makes the mesh edges visible
  17371. * @param epsilon defines the maximal distance between two angles to detect a face
  17372. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17373. * @returns the current InstancedLinesMesh
  17374. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17375. */
  17376. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17377. }
  17378. /**
  17379. * Defines the minimum contract an Edges renderer should follow.
  17380. */
  17381. export interface IEdgesRenderer extends IDisposable {
  17382. /**
  17383. * Gets or sets a boolean indicating if the edgesRenderer is active
  17384. */
  17385. isEnabled: boolean;
  17386. /**
  17387. * Renders the edges of the attached mesh,
  17388. */
  17389. render(): void;
  17390. /**
  17391. * Checks wether or not the edges renderer is ready to render.
  17392. * @return true if ready, otherwise false.
  17393. */
  17394. isReady(): boolean;
  17395. }
  17396. /**
  17397. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17398. */
  17399. export class EdgesRenderer implements IEdgesRenderer {
  17400. /**
  17401. * Define the size of the edges with an orthographic camera
  17402. */
  17403. edgesWidthScalerForOrthographic: number;
  17404. /**
  17405. * Define the size of the edges with a perspective camera
  17406. */
  17407. edgesWidthScalerForPerspective: number;
  17408. protected _source: AbstractMesh;
  17409. protected _linesPositions: number[];
  17410. protected _linesNormals: number[];
  17411. protected _linesIndices: number[];
  17412. protected _epsilon: number;
  17413. protected _indicesCount: number;
  17414. protected _lineShader: ShaderMaterial;
  17415. protected _ib: DataBuffer;
  17416. protected _buffers: {
  17417. [key: string]: Nullable<VertexBuffer>;
  17418. };
  17419. protected _checkVerticesInsteadOfIndices: boolean;
  17420. private _meshRebuildObserver;
  17421. private _meshDisposeObserver;
  17422. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17423. isEnabled: boolean;
  17424. /**
  17425. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17426. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17427. * @param source Mesh used to create edges
  17428. * @param epsilon sum of angles in adjacency to check for edge
  17429. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17430. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17431. */
  17432. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17433. protected _prepareRessources(): void;
  17434. /** @hidden */
  17435. _rebuild(): void;
  17436. /**
  17437. * Releases the required resources for the edges renderer
  17438. */
  17439. dispose(): void;
  17440. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17441. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17442. /**
  17443. * Checks if the pair of p0 and p1 is en edge
  17444. * @param faceIndex
  17445. * @param edge
  17446. * @param faceNormals
  17447. * @param p0
  17448. * @param p1
  17449. * @private
  17450. */
  17451. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17452. /**
  17453. * push line into the position, normal and index buffer
  17454. * @protected
  17455. */
  17456. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17457. /**
  17458. * Generates lines edges from adjacencjes
  17459. * @private
  17460. */
  17461. _generateEdgesLines(): void;
  17462. /**
  17463. * Checks wether or not the edges renderer is ready to render.
  17464. * @return true if ready, otherwise false.
  17465. */
  17466. isReady(): boolean;
  17467. /**
  17468. * Renders the edges of the attached mesh,
  17469. */
  17470. render(): void;
  17471. }
  17472. /**
  17473. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17474. */
  17475. export class LineEdgesRenderer extends EdgesRenderer {
  17476. /**
  17477. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17478. * @param source LineMesh used to generate edges
  17479. * @param epsilon not important (specified angle for edge detection)
  17480. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17481. */
  17482. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17483. /**
  17484. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17485. */
  17486. _generateEdgesLines(): void;
  17487. }
  17488. }
  17489. declare module BABYLON {
  17490. /**
  17491. * This represents the object necessary to create a rendering group.
  17492. * This is exclusively used and created by the rendering manager.
  17493. * To modify the behavior, you use the available helpers in your scene or meshes.
  17494. * @hidden
  17495. */
  17496. export class RenderingGroup {
  17497. index: number;
  17498. private static _zeroVector;
  17499. private _scene;
  17500. private _opaqueSubMeshes;
  17501. private _transparentSubMeshes;
  17502. private _alphaTestSubMeshes;
  17503. private _depthOnlySubMeshes;
  17504. private _particleSystems;
  17505. private _spriteManagers;
  17506. private _opaqueSortCompareFn;
  17507. private _alphaTestSortCompareFn;
  17508. private _transparentSortCompareFn;
  17509. private _renderOpaque;
  17510. private _renderAlphaTest;
  17511. private _renderTransparent;
  17512. /** @hidden */
  17513. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17514. onBeforeTransparentRendering: () => void;
  17515. /**
  17516. * Set the opaque sort comparison function.
  17517. * If null the sub meshes will be render in the order they were created
  17518. */
  17519. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17520. /**
  17521. * Set the alpha test sort comparison function.
  17522. * If null the sub meshes will be render in the order they were created
  17523. */
  17524. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17525. /**
  17526. * Set the transparent sort comparison function.
  17527. * If null the sub meshes will be render in the order they were created
  17528. */
  17529. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17530. /**
  17531. * Creates a new rendering group.
  17532. * @param index The rendering group index
  17533. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17534. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17535. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17536. */
  17537. 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>);
  17538. /**
  17539. * Render all the sub meshes contained in the group.
  17540. * @param customRenderFunction Used to override the default render behaviour of the group.
  17541. * @returns true if rendered some submeshes.
  17542. */
  17543. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17544. /**
  17545. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17546. * @param subMeshes The submeshes to render
  17547. */
  17548. private renderOpaqueSorted;
  17549. /**
  17550. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17551. * @param subMeshes The submeshes to render
  17552. */
  17553. private renderAlphaTestSorted;
  17554. /**
  17555. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17556. * @param subMeshes The submeshes to render
  17557. */
  17558. private renderTransparentSorted;
  17559. /**
  17560. * Renders the submeshes in a specified order.
  17561. * @param subMeshes The submeshes to sort before render
  17562. * @param sortCompareFn The comparison function use to sort
  17563. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17564. * @param transparent Specifies to activate blending if true
  17565. */
  17566. private static renderSorted;
  17567. /**
  17568. * Renders the submeshes in the order they were dispatched (no sort applied).
  17569. * @param subMeshes The submeshes to render
  17570. */
  17571. private static renderUnsorted;
  17572. /**
  17573. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17574. * are rendered back to front if in the same alpha index.
  17575. *
  17576. * @param a The first submesh
  17577. * @param b The second submesh
  17578. * @returns The result of the comparison
  17579. */
  17580. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17581. /**
  17582. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17583. * are rendered back to front.
  17584. *
  17585. * @param a The first submesh
  17586. * @param b The second submesh
  17587. * @returns The result of the comparison
  17588. */
  17589. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17590. /**
  17591. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17592. * are rendered front to back (prevent overdraw).
  17593. *
  17594. * @param a The first submesh
  17595. * @param b The second submesh
  17596. * @returns The result of the comparison
  17597. */
  17598. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17599. /**
  17600. * Resets the different lists of submeshes to prepare a new frame.
  17601. */
  17602. prepare(): void;
  17603. dispose(): void;
  17604. /**
  17605. * Inserts the submesh in its correct queue depending on its material.
  17606. * @param subMesh The submesh to dispatch
  17607. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17608. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17609. */
  17610. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17611. dispatchSprites(spriteManager: ISpriteManager): void;
  17612. dispatchParticles(particleSystem: IParticleSystem): void;
  17613. private _renderParticles;
  17614. private _renderSprites;
  17615. }
  17616. }
  17617. declare module BABYLON {
  17618. /**
  17619. * Interface describing the different options available in the rendering manager
  17620. * regarding Auto Clear between groups.
  17621. */
  17622. export interface IRenderingManagerAutoClearSetup {
  17623. /**
  17624. * Defines whether or not autoclear is enable.
  17625. */
  17626. autoClear: boolean;
  17627. /**
  17628. * Defines whether or not to autoclear the depth buffer.
  17629. */
  17630. depth: boolean;
  17631. /**
  17632. * Defines whether or not to autoclear the stencil buffer.
  17633. */
  17634. stencil: boolean;
  17635. }
  17636. /**
  17637. * This class is used by the onRenderingGroupObservable
  17638. */
  17639. export class RenderingGroupInfo {
  17640. /**
  17641. * The Scene that being rendered
  17642. */
  17643. scene: Scene;
  17644. /**
  17645. * The camera currently used for the rendering pass
  17646. */
  17647. camera: Nullable<Camera>;
  17648. /**
  17649. * The ID of the renderingGroup being processed
  17650. */
  17651. renderingGroupId: number;
  17652. }
  17653. /**
  17654. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17655. * It is enable to manage the different groups as well as the different necessary sort functions.
  17656. * This should not be used directly aside of the few static configurations
  17657. */
  17658. export class RenderingManager {
  17659. /**
  17660. * The max id used for rendering groups (not included)
  17661. */
  17662. static MAX_RENDERINGGROUPS: number;
  17663. /**
  17664. * The min id used for rendering groups (included)
  17665. */
  17666. static MIN_RENDERINGGROUPS: number;
  17667. /**
  17668. * Used to globally prevent autoclearing scenes.
  17669. */
  17670. static AUTOCLEAR: boolean;
  17671. /**
  17672. * @hidden
  17673. */
  17674. _useSceneAutoClearSetup: boolean;
  17675. private _scene;
  17676. private _renderingGroups;
  17677. private _depthStencilBufferAlreadyCleaned;
  17678. private _autoClearDepthStencil;
  17679. private _customOpaqueSortCompareFn;
  17680. private _customAlphaTestSortCompareFn;
  17681. private _customTransparentSortCompareFn;
  17682. private _renderingGroupInfo;
  17683. /**
  17684. * Instantiates a new rendering group for a particular scene
  17685. * @param scene Defines the scene the groups belongs to
  17686. */
  17687. constructor(scene: Scene);
  17688. private _clearDepthStencilBuffer;
  17689. /**
  17690. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17691. * @hidden
  17692. */
  17693. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17694. /**
  17695. * Resets the different information of the group to prepare a new frame
  17696. * @hidden
  17697. */
  17698. reset(): void;
  17699. /**
  17700. * Dispose and release the group and its associated resources.
  17701. * @hidden
  17702. */
  17703. dispose(): void;
  17704. /**
  17705. * Clear the info related to rendering groups preventing retention points during dispose.
  17706. */
  17707. freeRenderingGroups(): void;
  17708. private _prepareRenderingGroup;
  17709. /**
  17710. * Add a sprite manager to the rendering manager in order to render it this frame.
  17711. * @param spriteManager Define the sprite manager to render
  17712. */
  17713. dispatchSprites(spriteManager: ISpriteManager): void;
  17714. /**
  17715. * Add a particle system to the rendering manager in order to render it this frame.
  17716. * @param particleSystem Define the particle system to render
  17717. */
  17718. dispatchParticles(particleSystem: IParticleSystem): void;
  17719. /**
  17720. * Add a submesh to the manager in order to render it this frame
  17721. * @param subMesh The submesh to dispatch
  17722. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17723. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17724. */
  17725. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17726. /**
  17727. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17728. * This allowed control for front to back rendering or reversly depending of the special needs.
  17729. *
  17730. * @param renderingGroupId The rendering group id corresponding to its index
  17731. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17732. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17733. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17734. */
  17735. 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;
  17736. /**
  17737. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17738. *
  17739. * @param renderingGroupId The rendering group id corresponding to its index
  17740. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17741. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17742. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17743. */
  17744. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17745. /**
  17746. * Gets the current auto clear configuration for one rendering group of the rendering
  17747. * manager.
  17748. * @param index the rendering group index to get the information for
  17749. * @returns The auto clear setup for the requested rendering group
  17750. */
  17751. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17752. }
  17753. }
  17754. declare module BABYLON {
  17755. /**
  17756. * This Helps creating a texture that will be created from a camera in your scene.
  17757. * It is basically a dynamic texture that could be used to create special effects for instance.
  17758. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17759. */
  17760. export class RenderTargetTexture extends Texture {
  17761. isCube: boolean;
  17762. /**
  17763. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17764. */
  17765. static readonly REFRESHRATE_RENDER_ONCE: number;
  17766. /**
  17767. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17768. */
  17769. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17770. /**
  17771. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17772. * the central point of your effect and can save a lot of performances.
  17773. */
  17774. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17775. /**
  17776. * Use this predicate to dynamically define the list of mesh you want to render.
  17777. * If set, the renderList property will be overwritten.
  17778. */
  17779. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17780. private _renderList;
  17781. /**
  17782. * Use this list to define the list of mesh you want to render.
  17783. */
  17784. renderList: Nullable<Array<AbstractMesh>>;
  17785. private _hookArray;
  17786. /**
  17787. * Define if particles should be rendered in your texture.
  17788. */
  17789. renderParticles: boolean;
  17790. /**
  17791. * Define if sprites should be rendered in your texture.
  17792. */
  17793. renderSprites: boolean;
  17794. /**
  17795. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17796. */
  17797. coordinatesMode: number;
  17798. /**
  17799. * Define the camera used to render the texture.
  17800. */
  17801. activeCamera: Nullable<Camera>;
  17802. /**
  17803. * Override the render function of the texture with your own one.
  17804. */
  17805. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17806. /**
  17807. * Define if camera post processes should be use while rendering the texture.
  17808. */
  17809. useCameraPostProcesses: boolean;
  17810. /**
  17811. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17812. */
  17813. ignoreCameraViewport: boolean;
  17814. private _postProcessManager;
  17815. private _postProcesses;
  17816. private _resizeObserver;
  17817. /**
  17818. * An event triggered when the texture is unbind.
  17819. */
  17820. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17821. /**
  17822. * An event triggered when the texture is unbind.
  17823. */
  17824. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17825. private _onAfterUnbindObserver;
  17826. /**
  17827. * Set a after unbind callback in the texture.
  17828. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17829. */
  17830. onAfterUnbind: () => void;
  17831. /**
  17832. * An event triggered before rendering the texture
  17833. */
  17834. onBeforeRenderObservable: Observable<number>;
  17835. private _onBeforeRenderObserver;
  17836. /**
  17837. * Set a before render callback in the texture.
  17838. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17839. */
  17840. onBeforeRender: (faceIndex: number) => void;
  17841. /**
  17842. * An event triggered after rendering the texture
  17843. */
  17844. onAfterRenderObservable: Observable<number>;
  17845. private _onAfterRenderObserver;
  17846. /**
  17847. * Set a after render callback in the texture.
  17848. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17849. */
  17850. onAfterRender: (faceIndex: number) => void;
  17851. /**
  17852. * An event triggered after the texture clear
  17853. */
  17854. onClearObservable: Observable<Engine>;
  17855. private _onClearObserver;
  17856. /**
  17857. * Set a clear callback in the texture.
  17858. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17859. */
  17860. onClear: (Engine: Engine) => void;
  17861. /**
  17862. * Define the clear color of the Render Target if it should be different from the scene.
  17863. */
  17864. clearColor: Color4;
  17865. protected _size: number | {
  17866. width: number;
  17867. height: number;
  17868. };
  17869. protected _initialSizeParameter: number | {
  17870. width: number;
  17871. height: number;
  17872. } | {
  17873. ratio: number;
  17874. };
  17875. protected _sizeRatio: Nullable<number>;
  17876. /** @hidden */
  17877. _generateMipMaps: boolean;
  17878. protected _renderingManager: RenderingManager;
  17879. /** @hidden */
  17880. _waitingRenderList: string[];
  17881. protected _doNotChangeAspectRatio: boolean;
  17882. protected _currentRefreshId: number;
  17883. protected _refreshRate: number;
  17884. protected _textureMatrix: Matrix;
  17885. protected _samples: number;
  17886. protected _renderTargetOptions: RenderTargetCreationOptions;
  17887. /**
  17888. * Gets render target creation options that were used.
  17889. */
  17890. readonly renderTargetOptions: RenderTargetCreationOptions;
  17891. protected _engine: Engine;
  17892. protected _onRatioRescale(): void;
  17893. /**
  17894. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17895. * It must define where the camera used to render the texture is set
  17896. */
  17897. boundingBoxPosition: Vector3;
  17898. private _boundingBoxSize;
  17899. /**
  17900. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17901. * When defined, the cubemap will switch to local mode
  17902. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17903. * @example https://www.babylonjs-playground.com/#RNASML
  17904. */
  17905. boundingBoxSize: Vector3;
  17906. /**
  17907. * In case the RTT has been created with a depth texture, get the associated
  17908. * depth texture.
  17909. * Otherwise, return null.
  17910. */
  17911. depthStencilTexture: Nullable<InternalTexture>;
  17912. /**
  17913. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17914. * or used a shadow, depth texture...
  17915. * @param name The friendly name of the texture
  17916. * @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)
  17917. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17918. * @param generateMipMaps True if mip maps need to be generated after render.
  17919. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17920. * @param type The type of the buffer in the RTT (int, half float, float...)
  17921. * @param isCube True if a cube texture needs to be created
  17922. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17923. * @param generateDepthBuffer True to generate a depth buffer
  17924. * @param generateStencilBuffer True to generate a stencil buffer
  17925. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17926. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17927. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17928. */
  17929. constructor(name: string, size: number | {
  17930. width: number;
  17931. height: number;
  17932. } | {
  17933. ratio: number;
  17934. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17935. /**
  17936. * Creates a depth stencil texture.
  17937. * This is only available in WebGL 2 or with the depth texture extension available.
  17938. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17939. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17940. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17941. */
  17942. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17943. private _processSizeParameter;
  17944. /**
  17945. * Define the number of samples to use in case of MSAA.
  17946. * It defaults to one meaning no MSAA has been enabled.
  17947. */
  17948. samples: number;
  17949. /**
  17950. * Resets the refresh counter of the texture and start bak from scratch.
  17951. * Could be useful to regenerate the texture if it is setup to render only once.
  17952. */
  17953. resetRefreshCounter(): void;
  17954. /**
  17955. * Define the refresh rate of the texture or the rendering frequency.
  17956. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17957. */
  17958. refreshRate: number;
  17959. /**
  17960. * Adds a post process to the render target rendering passes.
  17961. * @param postProcess define the post process to add
  17962. */
  17963. addPostProcess(postProcess: PostProcess): void;
  17964. /**
  17965. * Clear all the post processes attached to the render target
  17966. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17967. */
  17968. clearPostProcesses(dispose?: boolean): void;
  17969. /**
  17970. * Remove one of the post process from the list of attached post processes to the texture
  17971. * @param postProcess define the post process to remove from the list
  17972. */
  17973. removePostProcess(postProcess: PostProcess): void;
  17974. /** @hidden */
  17975. _shouldRender(): boolean;
  17976. /**
  17977. * Gets the actual render size of the texture.
  17978. * @returns the width of the render size
  17979. */
  17980. getRenderSize(): number;
  17981. /**
  17982. * Gets the actual render width of the texture.
  17983. * @returns the width of the render size
  17984. */
  17985. getRenderWidth(): number;
  17986. /**
  17987. * Gets the actual render height of the texture.
  17988. * @returns the height of the render size
  17989. */
  17990. getRenderHeight(): number;
  17991. /**
  17992. * Get if the texture can be rescaled or not.
  17993. */
  17994. readonly canRescale: boolean;
  17995. /**
  17996. * Resize the texture using a ratio.
  17997. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17998. */
  17999. scale(ratio: number): void;
  18000. /**
  18001. * Get the texture reflection matrix used to rotate/transform the reflection.
  18002. * @returns the reflection matrix
  18003. */
  18004. getReflectionTextureMatrix(): Matrix;
  18005. /**
  18006. * Resize the texture to a new desired size.
  18007. * Be carrefull as it will recreate all the data in the new texture.
  18008. * @param size Define the new size. It can be:
  18009. * - a number for squared texture,
  18010. * - an object containing { width: number, height: number }
  18011. * - or an object containing a ratio { ratio: number }
  18012. */
  18013. resize(size: number | {
  18014. width: number;
  18015. height: number;
  18016. } | {
  18017. ratio: number;
  18018. }): void;
  18019. /**
  18020. * Renders all the objects from the render list into the texture.
  18021. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18022. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18023. */
  18024. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18025. private _bestReflectionRenderTargetDimension;
  18026. /**
  18027. * @hidden
  18028. * @param faceIndex face index to bind to if this is a cubetexture
  18029. */
  18030. _bindFrameBuffer(faceIndex?: number): void;
  18031. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18032. private renderToTarget;
  18033. /**
  18034. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18035. * This allowed control for front to back rendering or reversly depending of the special needs.
  18036. *
  18037. * @param renderingGroupId The rendering group id corresponding to its index
  18038. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18039. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18040. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18041. */
  18042. 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;
  18043. /**
  18044. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18045. *
  18046. * @param renderingGroupId The rendering group id corresponding to its index
  18047. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18048. */
  18049. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18050. /**
  18051. * Clones the texture.
  18052. * @returns the cloned texture
  18053. */
  18054. clone(): RenderTargetTexture;
  18055. /**
  18056. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18057. * @returns The JSON representation of the texture
  18058. */
  18059. serialize(): any;
  18060. /**
  18061. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18062. */
  18063. disposeFramebufferObjects(): void;
  18064. /**
  18065. * Dispose the texture and release its associated resources.
  18066. */
  18067. dispose(): void;
  18068. /** @hidden */
  18069. _rebuild(): void;
  18070. /**
  18071. * Clear the info related to rendering groups preventing retention point in material dispose.
  18072. */
  18073. freeRenderingGroups(): void;
  18074. /**
  18075. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18076. * @returns the view count
  18077. */
  18078. getViewCount(): number;
  18079. }
  18080. }
  18081. declare module BABYLON {
  18082. /**
  18083. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18084. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18085. * You can then easily use it as a reflectionTexture on a flat surface.
  18086. * In case the surface is not a plane, please consider relying on reflection probes.
  18087. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18088. */
  18089. export class MirrorTexture extends RenderTargetTexture {
  18090. private scene;
  18091. /**
  18092. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18093. * 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.
  18094. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18095. */
  18096. mirrorPlane: Plane;
  18097. /**
  18098. * Define the blur ratio used to blur the reflection if needed.
  18099. */
  18100. blurRatio: number;
  18101. /**
  18102. * Define the adaptive blur kernel used to blur the reflection if needed.
  18103. * This will autocompute the closest best match for the `blurKernel`
  18104. */
  18105. adaptiveBlurKernel: number;
  18106. /**
  18107. * Define the blur kernel used to blur the reflection if needed.
  18108. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18109. */
  18110. blurKernel: number;
  18111. /**
  18112. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18113. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18114. */
  18115. blurKernelX: number;
  18116. /**
  18117. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18118. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18119. */
  18120. blurKernelY: number;
  18121. private _autoComputeBlurKernel;
  18122. protected _onRatioRescale(): void;
  18123. private _updateGammaSpace;
  18124. private _imageProcessingConfigChangeObserver;
  18125. private _transformMatrix;
  18126. private _mirrorMatrix;
  18127. private _savedViewMatrix;
  18128. private _blurX;
  18129. private _blurY;
  18130. private _adaptiveBlurKernel;
  18131. private _blurKernelX;
  18132. private _blurKernelY;
  18133. private _blurRatio;
  18134. /**
  18135. * Instantiates a Mirror Texture.
  18136. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18137. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18138. * You can then easily use it as a reflectionTexture on a flat surface.
  18139. * In case the surface is not a plane, please consider relying on reflection probes.
  18140. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18141. * @param name
  18142. * @param size
  18143. * @param scene
  18144. * @param generateMipMaps
  18145. * @param type
  18146. * @param samplingMode
  18147. * @param generateDepthBuffer
  18148. */
  18149. constructor(name: string, size: number | {
  18150. width: number;
  18151. height: number;
  18152. } | {
  18153. ratio: number;
  18154. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18155. private _preparePostProcesses;
  18156. /**
  18157. * Clone the mirror texture.
  18158. * @returns the cloned texture
  18159. */
  18160. clone(): MirrorTexture;
  18161. /**
  18162. * Serialize the texture to a JSON representation you could use in Parse later on
  18163. * @returns the serialized JSON representation
  18164. */
  18165. serialize(): any;
  18166. /**
  18167. * Dispose the texture and release its associated resources.
  18168. */
  18169. dispose(): void;
  18170. }
  18171. }
  18172. declare module BABYLON {
  18173. /**
  18174. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18175. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18176. */
  18177. export class Texture extends BaseTexture {
  18178. /** @hidden */
  18179. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18180. /** @hidden */
  18181. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18182. /** @hidden */
  18183. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18184. /** nearest is mag = nearest and min = nearest and mip = linear */
  18185. static readonly NEAREST_SAMPLINGMODE: number;
  18186. /** nearest is mag = nearest and min = nearest and mip = linear */
  18187. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18188. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18189. static readonly BILINEAR_SAMPLINGMODE: number;
  18190. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18191. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18192. /** Trilinear is mag = linear and min = linear and mip = linear */
  18193. static readonly TRILINEAR_SAMPLINGMODE: number;
  18194. /** Trilinear is mag = linear and min = linear and mip = linear */
  18195. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18196. /** mag = nearest and min = nearest and mip = nearest */
  18197. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18198. /** mag = nearest and min = linear and mip = nearest */
  18199. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18200. /** mag = nearest and min = linear and mip = linear */
  18201. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18202. /** mag = nearest and min = linear and mip = none */
  18203. static readonly NEAREST_LINEAR: number;
  18204. /** mag = nearest and min = nearest and mip = none */
  18205. static readonly NEAREST_NEAREST: number;
  18206. /** mag = linear and min = nearest and mip = nearest */
  18207. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18208. /** mag = linear and min = nearest and mip = linear */
  18209. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18210. /** mag = linear and min = linear and mip = none */
  18211. static readonly LINEAR_LINEAR: number;
  18212. /** mag = linear and min = nearest and mip = none */
  18213. static readonly LINEAR_NEAREST: number;
  18214. /** Explicit coordinates mode */
  18215. static readonly EXPLICIT_MODE: number;
  18216. /** Spherical coordinates mode */
  18217. static readonly SPHERICAL_MODE: number;
  18218. /** Planar coordinates mode */
  18219. static readonly PLANAR_MODE: number;
  18220. /** Cubic coordinates mode */
  18221. static readonly CUBIC_MODE: number;
  18222. /** Projection coordinates mode */
  18223. static readonly PROJECTION_MODE: number;
  18224. /** Inverse Cubic coordinates mode */
  18225. static readonly SKYBOX_MODE: number;
  18226. /** Inverse Cubic coordinates mode */
  18227. static readonly INVCUBIC_MODE: number;
  18228. /** Equirectangular coordinates mode */
  18229. static readonly EQUIRECTANGULAR_MODE: number;
  18230. /** Equirectangular Fixed coordinates mode */
  18231. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18232. /** Equirectangular Fixed Mirrored coordinates mode */
  18233. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18234. /** Texture is not repeating outside of 0..1 UVs */
  18235. static readonly CLAMP_ADDRESSMODE: number;
  18236. /** Texture is repeating outside of 0..1 UVs */
  18237. static readonly WRAP_ADDRESSMODE: number;
  18238. /** Texture is repeating and mirrored */
  18239. static readonly MIRROR_ADDRESSMODE: number;
  18240. /**
  18241. * 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
  18242. */
  18243. static UseSerializedUrlIfAny: boolean;
  18244. /**
  18245. * Define the url of the texture.
  18246. */
  18247. url: Nullable<string>;
  18248. /**
  18249. * Define an offset on the texture to offset the u coordinates of the UVs
  18250. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18251. */
  18252. uOffset: number;
  18253. /**
  18254. * Define an offset on the texture to offset the v coordinates of the UVs
  18255. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18256. */
  18257. vOffset: number;
  18258. /**
  18259. * Define an offset on the texture to scale the u coordinates of the UVs
  18260. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18261. */
  18262. uScale: number;
  18263. /**
  18264. * Define an offset on the texture to scale the v coordinates of the UVs
  18265. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18266. */
  18267. vScale: number;
  18268. /**
  18269. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18270. * @see http://doc.babylonjs.com/how_to/more_materials
  18271. */
  18272. uAng: number;
  18273. /**
  18274. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18275. * @see http://doc.babylonjs.com/how_to/more_materials
  18276. */
  18277. vAng: number;
  18278. /**
  18279. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18280. * @see http://doc.babylonjs.com/how_to/more_materials
  18281. */
  18282. wAng: number;
  18283. /**
  18284. * Defines the center of rotation (U)
  18285. */
  18286. uRotationCenter: number;
  18287. /**
  18288. * Defines the center of rotation (V)
  18289. */
  18290. vRotationCenter: number;
  18291. /**
  18292. * Defines the center of rotation (W)
  18293. */
  18294. wRotationCenter: number;
  18295. /**
  18296. * Are mip maps generated for this texture or not.
  18297. */
  18298. readonly noMipmap: boolean;
  18299. /**
  18300. * List of inspectable custom properties (used by the Inspector)
  18301. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18302. */
  18303. inspectableCustomProperties: Nullable<IInspectable[]>;
  18304. private _noMipmap;
  18305. /** @hidden */
  18306. _invertY: boolean;
  18307. private _rowGenerationMatrix;
  18308. private _cachedTextureMatrix;
  18309. private _projectionModeMatrix;
  18310. private _t0;
  18311. private _t1;
  18312. private _t2;
  18313. private _cachedUOffset;
  18314. private _cachedVOffset;
  18315. private _cachedUScale;
  18316. private _cachedVScale;
  18317. private _cachedUAng;
  18318. private _cachedVAng;
  18319. private _cachedWAng;
  18320. private _cachedProjectionMatrixId;
  18321. private _cachedCoordinatesMode;
  18322. /** @hidden */
  18323. protected _initialSamplingMode: number;
  18324. /** @hidden */
  18325. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18326. private _deleteBuffer;
  18327. protected _format: Nullable<number>;
  18328. private _delayedOnLoad;
  18329. private _delayedOnError;
  18330. /**
  18331. * Observable triggered once the texture has been loaded.
  18332. */
  18333. onLoadObservable: Observable<Texture>;
  18334. protected _isBlocking: boolean;
  18335. /**
  18336. * Is the texture preventing material to render while loading.
  18337. * If false, a default texture will be used instead of the loading one during the preparation step.
  18338. */
  18339. isBlocking: boolean;
  18340. /**
  18341. * Get the current sampling mode associated with the texture.
  18342. */
  18343. readonly samplingMode: number;
  18344. /**
  18345. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18346. */
  18347. readonly invertY: boolean;
  18348. /**
  18349. * Instantiates a new texture.
  18350. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18351. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18352. * @param url define the url of the picture to load as a texture
  18353. * @param scene define the scene the texture will belong to
  18354. * @param noMipmap define if the texture will require mip maps or not
  18355. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18356. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18357. * @param onLoad define a callback triggered when the texture has been loaded
  18358. * @param onError define a callback triggered when an error occurred during the loading session
  18359. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18360. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18361. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18362. */
  18363. 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);
  18364. /**
  18365. * Update the url (and optional buffer) of this texture if url was null during construction.
  18366. * @param url the url of the texture
  18367. * @param buffer the buffer of the texture (defaults to null)
  18368. * @param onLoad callback called when the texture is loaded (defaults to null)
  18369. */
  18370. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18371. /**
  18372. * Finish the loading sequence of a texture flagged as delayed load.
  18373. * @hidden
  18374. */
  18375. delayLoad(): void;
  18376. private _prepareRowForTextureGeneration;
  18377. /**
  18378. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18379. * @returns the transform matrix of the texture.
  18380. */
  18381. getTextureMatrix(): Matrix;
  18382. /**
  18383. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18384. * @returns The reflection texture transform
  18385. */
  18386. getReflectionTextureMatrix(): Matrix;
  18387. /**
  18388. * Clones the texture.
  18389. * @returns the cloned texture
  18390. */
  18391. clone(): Texture;
  18392. /**
  18393. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18394. * @returns The JSON representation of the texture
  18395. */
  18396. serialize(): any;
  18397. /**
  18398. * Get the current class name of the texture useful for serialization or dynamic coding.
  18399. * @returns "Texture"
  18400. */
  18401. getClassName(): string;
  18402. /**
  18403. * Dispose the texture and release its associated resources.
  18404. */
  18405. dispose(): void;
  18406. /**
  18407. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18408. * @param parsedTexture Define the JSON representation of the texture
  18409. * @param scene Define the scene the parsed texture should be instantiated in
  18410. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18411. * @returns The parsed texture if successful
  18412. */
  18413. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18414. /**
  18415. * Creates a texture from its base 64 representation.
  18416. * @param data Define the base64 payload without the data: prefix
  18417. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18418. * @param scene Define the scene the texture should belong to
  18419. * @param noMipmap Forces the texture to not create mip map information if true
  18420. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18421. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18422. * @param onLoad define a callback triggered when the texture has been loaded
  18423. * @param onError define a callback triggered when an error occurred during the loading session
  18424. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18425. * @returns the created texture
  18426. */
  18427. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18428. /**
  18429. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18430. * @param data Define the base64 payload without the data: prefix
  18431. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18432. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18433. * @param scene Define the scene the texture should belong to
  18434. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18435. * @param noMipmap Forces the texture to not create mip map information if true
  18436. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18437. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18438. * @param onLoad define a callback triggered when the texture has been loaded
  18439. * @param onError define a callback triggered when an error occurred during the loading session
  18440. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18441. * @returns the created texture
  18442. */
  18443. 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;
  18444. }
  18445. }
  18446. declare module BABYLON {
  18447. interface Engine {
  18448. /**
  18449. * Creates a raw texture
  18450. * @param data defines the data to store in the texture
  18451. * @param width defines the width of the texture
  18452. * @param height defines the height of the texture
  18453. * @param format defines the format of the data
  18454. * @param generateMipMaps defines if the engine should generate the mip levels
  18455. * @param invertY defines if data must be stored with Y axis inverted
  18456. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18457. * @param compression defines the compression used (null by default)
  18458. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18459. * @returns the raw texture inside an InternalTexture
  18460. */
  18461. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18462. /**
  18463. * Update a raw texture
  18464. * @param texture defines the texture to update
  18465. * @param data defines the data to store in the texture
  18466. * @param format defines the format of the data
  18467. * @param invertY defines if data must be stored with Y axis inverted
  18468. */
  18469. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18470. /**
  18471. * Update a raw texture
  18472. * @param texture defines the texture to update
  18473. * @param data defines the data to store in the texture
  18474. * @param format defines the format of the data
  18475. * @param invertY defines if data must be stored with Y axis inverted
  18476. * @param compression defines the compression used (null by default)
  18477. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18478. */
  18479. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18480. /**
  18481. * Creates a new raw cube texture
  18482. * @param data defines the array of data to use to create each face
  18483. * @param size defines the size of the textures
  18484. * @param format defines the format of the data
  18485. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18486. * @param generateMipMaps defines if the engine should generate the mip levels
  18487. * @param invertY defines if data must be stored with Y axis inverted
  18488. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18489. * @param compression defines the compression used (null by default)
  18490. * @returns the cube texture as an InternalTexture
  18491. */
  18492. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18493. /**
  18494. * Update a raw cube texture
  18495. * @param texture defines the texture to udpdate
  18496. * @param data defines the data to store
  18497. * @param format defines the data format
  18498. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18499. * @param invertY defines if data must be stored with Y axis inverted
  18500. */
  18501. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18502. /**
  18503. * Update a raw cube texture
  18504. * @param texture defines the texture to udpdate
  18505. * @param data defines the data to store
  18506. * @param format defines the data format
  18507. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18508. * @param invertY defines if data must be stored with Y axis inverted
  18509. * @param compression defines the compression used (null by default)
  18510. */
  18511. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18512. /**
  18513. * Update a raw cube texture
  18514. * @param texture defines the texture to udpdate
  18515. * @param data defines the data to store
  18516. * @param format defines the data format
  18517. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18518. * @param invertY defines if data must be stored with Y axis inverted
  18519. * @param compression defines the compression used (null by default)
  18520. * @param level defines which level of the texture to update
  18521. */
  18522. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18523. /**
  18524. * Creates a new raw cube texture from a specified url
  18525. * @param url defines the url where the data is located
  18526. * @param scene defines the current scene
  18527. * @param size defines the size of the textures
  18528. * @param format defines the format of the data
  18529. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18530. * @param noMipmap defines if the engine should avoid generating the mip levels
  18531. * @param callback defines a callback used to extract texture data from loaded data
  18532. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18533. * @param onLoad defines a callback called when texture is loaded
  18534. * @param onError defines a callback called if there is an error
  18535. * @returns the cube texture as an InternalTexture
  18536. */
  18537. 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;
  18538. /**
  18539. * Creates a new raw cube texture from a specified url
  18540. * @param url defines the url where the data is located
  18541. * @param scene defines the current scene
  18542. * @param size defines the size of the textures
  18543. * @param format defines the format of the data
  18544. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18545. * @param noMipmap defines if the engine should avoid generating the mip levels
  18546. * @param callback defines a callback used to extract texture data from loaded data
  18547. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18548. * @param onLoad defines a callback called when texture is loaded
  18549. * @param onError defines a callback called if there is an error
  18550. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18551. * @param invertY defines if data must be stored with Y axis inverted
  18552. * @returns the cube texture as an InternalTexture
  18553. */
  18554. 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;
  18555. /**
  18556. * Creates a new raw 3D texture
  18557. * @param data defines the data used to create the texture
  18558. * @param width defines the width of the texture
  18559. * @param height defines the height of the texture
  18560. * @param depth defines the depth of the texture
  18561. * @param format defines the format of the texture
  18562. * @param generateMipMaps defines if the engine must generate mip levels
  18563. * @param invertY defines if data must be stored with Y axis inverted
  18564. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18565. * @param compression defines the compressed used (can be null)
  18566. * @param textureType defines the compressed used (can be null)
  18567. * @returns a new raw 3D texture (stored in an InternalTexture)
  18568. */
  18569. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18570. /**
  18571. * Update a raw 3D texture
  18572. * @param texture defines the texture to update
  18573. * @param data defines the data to store
  18574. * @param format defines the data format
  18575. * @param invertY defines if data must be stored with Y axis inverted
  18576. */
  18577. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18578. /**
  18579. * Update a raw 3D texture
  18580. * @param texture defines the texture to update
  18581. * @param data defines the data to store
  18582. * @param format defines the data format
  18583. * @param invertY defines if data must be stored with Y axis inverted
  18584. * @param compression defines the used compression (can be null)
  18585. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18586. */
  18587. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18588. }
  18589. }
  18590. declare module BABYLON {
  18591. /**
  18592. * Raw texture can help creating a texture directly from an array of data.
  18593. * This can be super useful if you either get the data from an uncompressed source or
  18594. * if you wish to create your texture pixel by pixel.
  18595. */
  18596. export class RawTexture extends Texture {
  18597. /**
  18598. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18599. */
  18600. format: number;
  18601. private _engine;
  18602. /**
  18603. * Instantiates a new RawTexture.
  18604. * Raw texture can help creating a texture directly from an array of data.
  18605. * This can be super useful if you either get the data from an uncompressed source or
  18606. * if you wish to create your texture pixel by pixel.
  18607. * @param data define the array of data to use to create the texture
  18608. * @param width define the width of the texture
  18609. * @param height define the height of the texture
  18610. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18611. * @param scene define the scene the texture belongs to
  18612. * @param generateMipMaps define whether mip maps should be generated or not
  18613. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18614. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18615. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18616. */
  18617. constructor(data: ArrayBufferView, width: number, height: number,
  18618. /**
  18619. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18620. */
  18621. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18622. /**
  18623. * Updates the texture underlying data.
  18624. * @param data Define the new data of the texture
  18625. */
  18626. update(data: ArrayBufferView): void;
  18627. /**
  18628. * Creates a luminance texture from some data.
  18629. * @param data Define the texture data
  18630. * @param width Define the width of the texture
  18631. * @param height Define the height of the texture
  18632. * @param scene Define the scene the texture belongs to
  18633. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18634. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18635. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18636. * @returns the luminance texture
  18637. */
  18638. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18639. /**
  18640. * Creates a luminance alpha texture from some data.
  18641. * @param data Define the texture data
  18642. * @param width Define the width of the texture
  18643. * @param height Define the height of the texture
  18644. * @param scene Define the scene the texture belongs to
  18645. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18646. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18647. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18648. * @returns the luminance alpha texture
  18649. */
  18650. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18651. /**
  18652. * Creates an alpha texture from some data.
  18653. * @param data Define the texture data
  18654. * @param width Define the width of the texture
  18655. * @param height Define the height of the texture
  18656. * @param scene Define the scene the texture belongs to
  18657. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18658. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18659. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18660. * @returns the alpha texture
  18661. */
  18662. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18663. /**
  18664. * Creates a RGB texture from some data.
  18665. * @param data Define the texture data
  18666. * @param width Define the width of the texture
  18667. * @param height Define the height of the texture
  18668. * @param scene Define the scene the texture belongs to
  18669. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18670. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18671. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18672. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18673. * @returns the RGB alpha texture
  18674. */
  18675. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18676. /**
  18677. * Creates a RGBA texture from some data.
  18678. * @param data Define the texture data
  18679. * @param width Define the width of the texture
  18680. * @param height Define the height of the texture
  18681. * @param scene Define the scene the texture belongs to
  18682. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18683. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18684. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18685. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18686. * @returns the RGBA texture
  18687. */
  18688. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18689. /**
  18690. * Creates a R texture from some data.
  18691. * @param data Define the texture data
  18692. * @param width Define the width of the texture
  18693. * @param height Define the height of the texture
  18694. * @param scene Define the scene the texture belongs to
  18695. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18696. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18697. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18698. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18699. * @returns the R texture
  18700. */
  18701. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18702. }
  18703. }
  18704. declare module BABYLON {
  18705. /**
  18706. * Defines a runtime animation
  18707. */
  18708. export class RuntimeAnimation {
  18709. private _events;
  18710. /**
  18711. * The current frame of the runtime animation
  18712. */
  18713. private _currentFrame;
  18714. /**
  18715. * The animation used by the runtime animation
  18716. */
  18717. private _animation;
  18718. /**
  18719. * The target of the runtime animation
  18720. */
  18721. private _target;
  18722. /**
  18723. * The initiating animatable
  18724. */
  18725. private _host;
  18726. /**
  18727. * The original value of the runtime animation
  18728. */
  18729. private _originalValue;
  18730. /**
  18731. * The original blend value of the runtime animation
  18732. */
  18733. private _originalBlendValue;
  18734. /**
  18735. * The offsets cache of the runtime animation
  18736. */
  18737. private _offsetsCache;
  18738. /**
  18739. * The high limits cache of the runtime animation
  18740. */
  18741. private _highLimitsCache;
  18742. /**
  18743. * Specifies if the runtime animation has been stopped
  18744. */
  18745. private _stopped;
  18746. /**
  18747. * The blending factor of the runtime animation
  18748. */
  18749. private _blendingFactor;
  18750. /**
  18751. * The BabylonJS scene
  18752. */
  18753. private _scene;
  18754. /**
  18755. * The current value of the runtime animation
  18756. */
  18757. private _currentValue;
  18758. /** @hidden */
  18759. _animationState: _IAnimationState;
  18760. /**
  18761. * The active target of the runtime animation
  18762. */
  18763. private _activeTargets;
  18764. private _currentActiveTarget;
  18765. private _directTarget;
  18766. /**
  18767. * The target path of the runtime animation
  18768. */
  18769. private _targetPath;
  18770. /**
  18771. * The weight of the runtime animation
  18772. */
  18773. private _weight;
  18774. /**
  18775. * The ratio offset of the runtime animation
  18776. */
  18777. private _ratioOffset;
  18778. /**
  18779. * The previous delay of the runtime animation
  18780. */
  18781. private _previousDelay;
  18782. /**
  18783. * The previous ratio of the runtime animation
  18784. */
  18785. private _previousRatio;
  18786. private _enableBlending;
  18787. private _keys;
  18788. private _minFrame;
  18789. private _maxFrame;
  18790. private _minValue;
  18791. private _maxValue;
  18792. private _targetIsArray;
  18793. /**
  18794. * Gets the current frame of the runtime animation
  18795. */
  18796. readonly currentFrame: number;
  18797. /**
  18798. * Gets the weight of the runtime animation
  18799. */
  18800. readonly weight: number;
  18801. /**
  18802. * Gets the current value of the runtime animation
  18803. */
  18804. readonly currentValue: any;
  18805. /**
  18806. * Gets the target path of the runtime animation
  18807. */
  18808. readonly targetPath: string;
  18809. /**
  18810. * Gets the actual target of the runtime animation
  18811. */
  18812. readonly target: any;
  18813. /** @hidden */
  18814. _onLoop: () => void;
  18815. /**
  18816. * Create a new RuntimeAnimation object
  18817. * @param target defines the target of the animation
  18818. * @param animation defines the source animation object
  18819. * @param scene defines the hosting scene
  18820. * @param host defines the initiating Animatable
  18821. */
  18822. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18823. private _preparePath;
  18824. /**
  18825. * Gets the animation from the runtime animation
  18826. */
  18827. readonly animation: Animation;
  18828. /**
  18829. * Resets the runtime animation to the beginning
  18830. * @param restoreOriginal defines whether to restore the target property to the original value
  18831. */
  18832. reset(restoreOriginal?: boolean): void;
  18833. /**
  18834. * Specifies if the runtime animation is stopped
  18835. * @returns Boolean specifying if the runtime animation is stopped
  18836. */
  18837. isStopped(): boolean;
  18838. /**
  18839. * Disposes of the runtime animation
  18840. */
  18841. dispose(): void;
  18842. /**
  18843. * Apply the interpolated value to the target
  18844. * @param currentValue defines the value computed by the animation
  18845. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18846. */
  18847. setValue(currentValue: any, weight: number): void;
  18848. private _getOriginalValues;
  18849. private _setValue;
  18850. /**
  18851. * Gets the loop pmode of the runtime animation
  18852. * @returns Loop Mode
  18853. */
  18854. private _getCorrectLoopMode;
  18855. /**
  18856. * Move the current animation to a given frame
  18857. * @param frame defines the frame to move to
  18858. */
  18859. goToFrame(frame: number): void;
  18860. /**
  18861. * @hidden Internal use only
  18862. */
  18863. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18864. /**
  18865. * Execute the current animation
  18866. * @param delay defines the delay to add to the current frame
  18867. * @param from defines the lower bound of the animation range
  18868. * @param to defines the upper bound of the animation range
  18869. * @param loop defines if the current animation must loop
  18870. * @param speedRatio defines the current speed ratio
  18871. * @param weight defines the weight of the animation (default is -1 so no weight)
  18872. * @param onLoop optional callback called when animation loops
  18873. * @returns a boolean indicating if the animation is running
  18874. */
  18875. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18876. }
  18877. }
  18878. declare module BABYLON {
  18879. /**
  18880. * Class used to store an actual running animation
  18881. */
  18882. export class Animatable {
  18883. /** defines the target object */
  18884. target: any;
  18885. /** defines the starting frame number (default is 0) */
  18886. fromFrame: number;
  18887. /** defines the ending frame number (default is 100) */
  18888. toFrame: number;
  18889. /** defines if the animation must loop (default is false) */
  18890. loopAnimation: boolean;
  18891. /** defines a callback to call when animation ends if it is not looping */
  18892. onAnimationEnd?: (() => void) | null | undefined;
  18893. /** defines a callback to call when animation loops */
  18894. onAnimationLoop?: (() => void) | null | undefined;
  18895. private _localDelayOffset;
  18896. private _pausedDelay;
  18897. private _runtimeAnimations;
  18898. private _paused;
  18899. private _scene;
  18900. private _speedRatio;
  18901. private _weight;
  18902. private _syncRoot;
  18903. /**
  18904. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18905. * This will only apply for non looping animation (default is true)
  18906. */
  18907. disposeOnEnd: boolean;
  18908. /**
  18909. * Gets a boolean indicating if the animation has started
  18910. */
  18911. animationStarted: boolean;
  18912. /**
  18913. * Observer raised when the animation ends
  18914. */
  18915. onAnimationEndObservable: Observable<Animatable>;
  18916. /**
  18917. * Observer raised when the animation loops
  18918. */
  18919. onAnimationLoopObservable: Observable<Animatable>;
  18920. /**
  18921. * Gets the root Animatable used to synchronize and normalize animations
  18922. */
  18923. readonly syncRoot: Nullable<Animatable>;
  18924. /**
  18925. * Gets the current frame of the first RuntimeAnimation
  18926. * Used to synchronize Animatables
  18927. */
  18928. readonly masterFrame: number;
  18929. /**
  18930. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18931. */
  18932. weight: number;
  18933. /**
  18934. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18935. */
  18936. speedRatio: number;
  18937. /**
  18938. * Creates a new Animatable
  18939. * @param scene defines the hosting scene
  18940. * @param target defines the target object
  18941. * @param fromFrame defines the starting frame number (default is 0)
  18942. * @param toFrame defines the ending frame number (default is 100)
  18943. * @param loopAnimation defines if the animation must loop (default is false)
  18944. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18945. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18946. * @param animations defines a group of animation to add to the new Animatable
  18947. * @param onAnimationLoop defines a callback to call when animation loops
  18948. */
  18949. constructor(scene: Scene,
  18950. /** defines the target object */
  18951. target: any,
  18952. /** defines the starting frame number (default is 0) */
  18953. fromFrame?: number,
  18954. /** defines the ending frame number (default is 100) */
  18955. toFrame?: number,
  18956. /** defines if the animation must loop (default is false) */
  18957. loopAnimation?: boolean, speedRatio?: number,
  18958. /** defines a callback to call when animation ends if it is not looping */
  18959. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18960. /** defines a callback to call when animation loops */
  18961. onAnimationLoop?: (() => void) | null | undefined);
  18962. /**
  18963. * Synchronize and normalize current Animatable with a source Animatable
  18964. * This is useful when using animation weights and when animations are not of the same length
  18965. * @param root defines the root Animatable to synchronize with
  18966. * @returns the current Animatable
  18967. */
  18968. syncWith(root: Animatable): Animatable;
  18969. /**
  18970. * Gets the list of runtime animations
  18971. * @returns an array of RuntimeAnimation
  18972. */
  18973. getAnimations(): RuntimeAnimation[];
  18974. /**
  18975. * Adds more animations to the current animatable
  18976. * @param target defines the target of the animations
  18977. * @param animations defines the new animations to add
  18978. */
  18979. appendAnimations(target: any, animations: Animation[]): void;
  18980. /**
  18981. * Gets the source animation for a specific property
  18982. * @param property defines the propertyu to look for
  18983. * @returns null or the source animation for the given property
  18984. */
  18985. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18986. /**
  18987. * Gets the runtime animation for a specific property
  18988. * @param property defines the propertyu to look for
  18989. * @returns null or the runtime animation for the given property
  18990. */
  18991. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18992. /**
  18993. * Resets the animatable to its original state
  18994. */
  18995. reset(): void;
  18996. /**
  18997. * Allows the animatable to blend with current running animations
  18998. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18999. * @param blendingSpeed defines the blending speed to use
  19000. */
  19001. enableBlending(blendingSpeed: number): void;
  19002. /**
  19003. * Disable animation blending
  19004. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19005. */
  19006. disableBlending(): void;
  19007. /**
  19008. * Jump directly to a given frame
  19009. * @param frame defines the frame to jump to
  19010. */
  19011. goToFrame(frame: number): void;
  19012. /**
  19013. * Pause the animation
  19014. */
  19015. pause(): void;
  19016. /**
  19017. * Restart the animation
  19018. */
  19019. restart(): void;
  19020. private _raiseOnAnimationEnd;
  19021. /**
  19022. * Stop and delete the current animation
  19023. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19024. * @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)
  19025. */
  19026. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19027. /**
  19028. * Wait asynchronously for the animation to end
  19029. * @returns a promise which will be fullfilled when the animation ends
  19030. */
  19031. waitAsync(): Promise<Animatable>;
  19032. /** @hidden */
  19033. _animate(delay: number): boolean;
  19034. }
  19035. interface Scene {
  19036. /** @hidden */
  19037. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19038. /** @hidden */
  19039. _processLateAnimationBindingsForMatrices(holder: {
  19040. totalWeight: number;
  19041. animations: RuntimeAnimation[];
  19042. originalValue: Matrix;
  19043. }): any;
  19044. /** @hidden */
  19045. _processLateAnimationBindingsForQuaternions(holder: {
  19046. totalWeight: number;
  19047. animations: RuntimeAnimation[];
  19048. originalValue: Quaternion;
  19049. }, refQuaternion: Quaternion): Quaternion;
  19050. /** @hidden */
  19051. _processLateAnimationBindings(): void;
  19052. /**
  19053. * Will start the animation sequence of a given target
  19054. * @param target defines the target
  19055. * @param from defines from which frame should animation start
  19056. * @param to defines until which frame should animation run.
  19057. * @param weight defines the weight to apply to the animation (1.0 by default)
  19058. * @param loop defines if the animation loops
  19059. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19060. * @param onAnimationEnd defines the function to be executed when the animation ends
  19061. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19062. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19063. * @param onAnimationLoop defines the callback to call when an animation loops
  19064. * @returns the animatable object created for this animation
  19065. */
  19066. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19067. /**
  19068. * Will start the animation sequence of a given target
  19069. * @param target defines the target
  19070. * @param from defines from which frame should animation start
  19071. * @param to defines until which frame should animation run.
  19072. * @param loop defines if the animation loops
  19073. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19074. * @param onAnimationEnd defines the function to be executed when the animation ends
  19075. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19076. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19077. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19078. * @param onAnimationLoop defines the callback to call when an animation loops
  19079. * @returns the animatable object created for this animation
  19080. */
  19081. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19082. /**
  19083. * Will start the animation sequence of a given target and its hierarchy
  19084. * @param target defines the target
  19085. * @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.
  19086. * @param from defines from which frame should animation start
  19087. * @param to defines until which frame should animation run.
  19088. * @param loop defines if the animation loops
  19089. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19090. * @param onAnimationEnd defines the function to be executed when the animation ends
  19091. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19092. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19093. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19094. * @param onAnimationLoop defines the callback to call when an animation loops
  19095. * @returns the list of created animatables
  19096. */
  19097. 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[];
  19098. /**
  19099. * Begin a new animation on a given node
  19100. * @param target defines the target where the animation will take place
  19101. * @param animations defines the list of animations to start
  19102. * @param from defines the initial value
  19103. * @param to defines the final value
  19104. * @param loop defines if you want animation to loop (off by default)
  19105. * @param speedRatio defines the speed ratio to apply to all animations
  19106. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19107. * @param onAnimationLoop defines the callback to call when an animation loops
  19108. * @returns the list of created animatables
  19109. */
  19110. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19111. /**
  19112. * Begin a new animation on a given node and its hierarchy
  19113. * @param target defines the root node where the animation will take place
  19114. * @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.
  19115. * @param animations defines the list of animations to start
  19116. * @param from defines the initial value
  19117. * @param to defines the final value
  19118. * @param loop defines if you want animation to loop (off by default)
  19119. * @param speedRatio defines the speed ratio to apply to all animations
  19120. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19121. * @param onAnimationLoop defines the callback to call when an animation loops
  19122. * @returns the list of animatables created for all nodes
  19123. */
  19124. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19125. /**
  19126. * Gets the animatable associated with a specific target
  19127. * @param target defines the target of the animatable
  19128. * @returns the required animatable if found
  19129. */
  19130. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19131. /**
  19132. * Gets all animatables associated with a given target
  19133. * @param target defines the target to look animatables for
  19134. * @returns an array of Animatables
  19135. */
  19136. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19137. /**
  19138. * Stops and removes all animations that have been applied to the scene
  19139. */
  19140. stopAllAnimations(): void;
  19141. }
  19142. interface Bone {
  19143. /**
  19144. * Copy an animation range from another bone
  19145. * @param source defines the source bone
  19146. * @param rangeName defines the range name to copy
  19147. * @param frameOffset defines the frame offset
  19148. * @param rescaleAsRequired defines if rescaling must be applied if required
  19149. * @param skelDimensionsRatio defines the scaling ratio
  19150. * @returns true if operation was successful
  19151. */
  19152. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19153. }
  19154. }
  19155. declare module BABYLON {
  19156. /**
  19157. * Class used to handle skinning animations
  19158. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19159. */
  19160. export class Skeleton implements IAnimatable {
  19161. /** defines the skeleton name */
  19162. name: string;
  19163. /** defines the skeleton Id */
  19164. id: string;
  19165. /**
  19166. * Defines the list of child bones
  19167. */
  19168. bones: Bone[];
  19169. /**
  19170. * Defines an estimate of the dimension of the skeleton at rest
  19171. */
  19172. dimensionsAtRest: Vector3;
  19173. /**
  19174. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19175. */
  19176. needInitialSkinMatrix: boolean;
  19177. /**
  19178. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19179. */
  19180. overrideMesh: Nullable<AbstractMesh>;
  19181. /**
  19182. * Gets the list of animations attached to this skeleton
  19183. */
  19184. animations: Array<Animation>;
  19185. private _scene;
  19186. private _isDirty;
  19187. private _transformMatrices;
  19188. private _transformMatrixTexture;
  19189. private _meshesWithPoseMatrix;
  19190. private _animatables;
  19191. private _identity;
  19192. private _synchronizedWithMesh;
  19193. private _ranges;
  19194. private _lastAbsoluteTransformsUpdateId;
  19195. private _canUseTextureForBones;
  19196. private _uniqueId;
  19197. /** @hidden */
  19198. _numBonesWithLinkedTransformNode: number;
  19199. /** @hidden */
  19200. _hasWaitingData: Nullable<boolean>;
  19201. /**
  19202. * Specifies if the skeleton should be serialized
  19203. */
  19204. doNotSerialize: boolean;
  19205. private _useTextureToStoreBoneMatrices;
  19206. /**
  19207. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19208. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19209. */
  19210. useTextureToStoreBoneMatrices: boolean;
  19211. private _animationPropertiesOverride;
  19212. /**
  19213. * Gets or sets the animation properties override
  19214. */
  19215. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19216. /**
  19217. * List of inspectable custom properties (used by the Inspector)
  19218. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19219. */
  19220. inspectableCustomProperties: IInspectable[];
  19221. /**
  19222. * An observable triggered before computing the skeleton's matrices
  19223. */
  19224. onBeforeComputeObservable: Observable<Skeleton>;
  19225. /**
  19226. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19227. */
  19228. readonly isUsingTextureForMatrices: boolean;
  19229. /**
  19230. * Gets the unique ID of this skeleton
  19231. */
  19232. readonly uniqueId: number;
  19233. /**
  19234. * Creates a new skeleton
  19235. * @param name defines the skeleton name
  19236. * @param id defines the skeleton Id
  19237. * @param scene defines the hosting scene
  19238. */
  19239. constructor(
  19240. /** defines the skeleton name */
  19241. name: string,
  19242. /** defines the skeleton Id */
  19243. id: string, scene: Scene);
  19244. /**
  19245. * Gets the current object class name.
  19246. * @return the class name
  19247. */
  19248. getClassName(): string;
  19249. /**
  19250. * Returns an array containing the root bones
  19251. * @returns an array containing the root bones
  19252. */
  19253. getChildren(): Array<Bone>;
  19254. /**
  19255. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19256. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19257. * @returns a Float32Array containing matrices data
  19258. */
  19259. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19260. /**
  19261. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19262. * @returns a raw texture containing the data
  19263. */
  19264. getTransformMatrixTexture(): Nullable<RawTexture>;
  19265. /**
  19266. * Gets the current hosting scene
  19267. * @returns a scene object
  19268. */
  19269. getScene(): Scene;
  19270. /**
  19271. * Gets a string representing the current skeleton data
  19272. * @param fullDetails defines a boolean indicating if we want a verbose version
  19273. * @returns a string representing the current skeleton data
  19274. */
  19275. toString(fullDetails?: boolean): string;
  19276. /**
  19277. * Get bone's index searching by name
  19278. * @param name defines bone's name to search for
  19279. * @return the indice of the bone. Returns -1 if not found
  19280. */
  19281. getBoneIndexByName(name: string): number;
  19282. /**
  19283. * Creater a new animation range
  19284. * @param name defines the name of the range
  19285. * @param from defines the start key
  19286. * @param to defines the end key
  19287. */
  19288. createAnimationRange(name: string, from: number, to: number): void;
  19289. /**
  19290. * Delete a specific animation range
  19291. * @param name defines the name of the range
  19292. * @param deleteFrames defines if frames must be removed as well
  19293. */
  19294. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19295. /**
  19296. * Gets a specific animation range
  19297. * @param name defines the name of the range to look for
  19298. * @returns the requested animation range or null if not found
  19299. */
  19300. getAnimationRange(name: string): Nullable<AnimationRange>;
  19301. /**
  19302. * Gets the list of all animation ranges defined on this skeleton
  19303. * @returns an array
  19304. */
  19305. getAnimationRanges(): Nullable<AnimationRange>[];
  19306. /**
  19307. * Copy animation range from a source skeleton.
  19308. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19309. * @param source defines the source skeleton
  19310. * @param name defines the name of the range to copy
  19311. * @param rescaleAsRequired defines if rescaling must be applied if required
  19312. * @returns true if operation was successful
  19313. */
  19314. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19315. /**
  19316. * Forces the skeleton to go to rest pose
  19317. */
  19318. returnToRest(): void;
  19319. private _getHighestAnimationFrame;
  19320. /**
  19321. * Begin a specific animation range
  19322. * @param name defines the name of the range to start
  19323. * @param loop defines if looping must be turned on (false by default)
  19324. * @param speedRatio defines the speed ratio to apply (1 by default)
  19325. * @param onAnimationEnd defines a callback which will be called when animation will end
  19326. * @returns a new animatable
  19327. */
  19328. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19329. /** @hidden */
  19330. _markAsDirty(): void;
  19331. /** @hidden */
  19332. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19333. /** @hidden */
  19334. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19335. private _computeTransformMatrices;
  19336. /**
  19337. * Build all resources required to render a skeleton
  19338. */
  19339. prepare(): void;
  19340. /**
  19341. * Gets the list of animatables currently running for this skeleton
  19342. * @returns an array of animatables
  19343. */
  19344. getAnimatables(): IAnimatable[];
  19345. /**
  19346. * Clone the current skeleton
  19347. * @param name defines the name of the new skeleton
  19348. * @param id defines the id of the new skeleton
  19349. * @returns the new skeleton
  19350. */
  19351. clone(name: string, id: string): Skeleton;
  19352. /**
  19353. * Enable animation blending for this skeleton
  19354. * @param blendingSpeed defines the blending speed to apply
  19355. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19356. */
  19357. enableBlending(blendingSpeed?: number): void;
  19358. /**
  19359. * Releases all resources associated with the current skeleton
  19360. */
  19361. dispose(): void;
  19362. /**
  19363. * Serialize the skeleton in a JSON object
  19364. * @returns a JSON object
  19365. */
  19366. serialize(): any;
  19367. /**
  19368. * Creates a new skeleton from serialized data
  19369. * @param parsedSkeleton defines the serialized data
  19370. * @param scene defines the hosting scene
  19371. * @returns a new skeleton
  19372. */
  19373. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19374. /**
  19375. * Compute all node absolute transforms
  19376. * @param forceUpdate defines if computation must be done even if cache is up to date
  19377. */
  19378. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19379. /**
  19380. * Gets the root pose matrix
  19381. * @returns a matrix
  19382. */
  19383. getPoseMatrix(): Nullable<Matrix>;
  19384. /**
  19385. * Sorts bones per internal index
  19386. */
  19387. sortBones(): void;
  19388. private _sortBones;
  19389. }
  19390. }
  19391. declare module BABYLON {
  19392. /**
  19393. * Defines a target to use with MorphTargetManager
  19394. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19395. */
  19396. export class MorphTarget implements IAnimatable {
  19397. /** defines the name of the target */
  19398. name: string;
  19399. /**
  19400. * Gets or sets the list of animations
  19401. */
  19402. animations: Animation[];
  19403. private _scene;
  19404. private _positions;
  19405. private _normals;
  19406. private _tangents;
  19407. private _influence;
  19408. /**
  19409. * Observable raised when the influence changes
  19410. */
  19411. onInfluenceChanged: Observable<boolean>;
  19412. /** @hidden */
  19413. _onDataLayoutChanged: Observable<void>;
  19414. /**
  19415. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19416. */
  19417. influence: number;
  19418. /**
  19419. * Gets or sets the id of the morph Target
  19420. */
  19421. id: string;
  19422. private _animationPropertiesOverride;
  19423. /**
  19424. * Gets or sets the animation properties override
  19425. */
  19426. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19427. /**
  19428. * Creates a new MorphTarget
  19429. * @param name defines the name of the target
  19430. * @param influence defines the influence to use
  19431. * @param scene defines the scene the morphtarget belongs to
  19432. */
  19433. constructor(
  19434. /** defines the name of the target */
  19435. name: string, influence?: number, scene?: Nullable<Scene>);
  19436. /**
  19437. * Gets a boolean defining if the target contains position data
  19438. */
  19439. readonly hasPositions: boolean;
  19440. /**
  19441. * Gets a boolean defining if the target contains normal data
  19442. */
  19443. readonly hasNormals: boolean;
  19444. /**
  19445. * Gets a boolean defining if the target contains tangent data
  19446. */
  19447. readonly hasTangents: boolean;
  19448. /**
  19449. * Affects position data to this target
  19450. * @param data defines the position data to use
  19451. */
  19452. setPositions(data: Nullable<FloatArray>): void;
  19453. /**
  19454. * Gets the position data stored in this target
  19455. * @returns a FloatArray containing the position data (or null if not present)
  19456. */
  19457. getPositions(): Nullable<FloatArray>;
  19458. /**
  19459. * Affects normal data to this target
  19460. * @param data defines the normal data to use
  19461. */
  19462. setNormals(data: Nullable<FloatArray>): void;
  19463. /**
  19464. * Gets the normal data stored in this target
  19465. * @returns a FloatArray containing the normal data (or null if not present)
  19466. */
  19467. getNormals(): Nullable<FloatArray>;
  19468. /**
  19469. * Affects tangent data to this target
  19470. * @param data defines the tangent data to use
  19471. */
  19472. setTangents(data: Nullable<FloatArray>): void;
  19473. /**
  19474. * Gets the tangent data stored in this target
  19475. * @returns a FloatArray containing the tangent data (or null if not present)
  19476. */
  19477. getTangents(): Nullable<FloatArray>;
  19478. /**
  19479. * Serializes the current target into a Serialization object
  19480. * @returns the serialized object
  19481. */
  19482. serialize(): any;
  19483. /**
  19484. * Returns the string "MorphTarget"
  19485. * @returns "MorphTarget"
  19486. */
  19487. getClassName(): string;
  19488. /**
  19489. * Creates a new target from serialized data
  19490. * @param serializationObject defines the serialized data to use
  19491. * @returns a new MorphTarget
  19492. */
  19493. static Parse(serializationObject: any): MorphTarget;
  19494. /**
  19495. * Creates a MorphTarget from mesh data
  19496. * @param mesh defines the source mesh
  19497. * @param name defines the name to use for the new target
  19498. * @param influence defines the influence to attach to the target
  19499. * @returns a new MorphTarget
  19500. */
  19501. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19502. }
  19503. }
  19504. declare module BABYLON {
  19505. /**
  19506. * This class is used to deform meshes using morphing between different targets
  19507. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19508. */
  19509. export class MorphTargetManager {
  19510. private _targets;
  19511. private _targetInfluenceChangedObservers;
  19512. private _targetDataLayoutChangedObservers;
  19513. private _activeTargets;
  19514. private _scene;
  19515. private _influences;
  19516. private _supportsNormals;
  19517. private _supportsTangents;
  19518. private _vertexCount;
  19519. private _uniqueId;
  19520. private _tempInfluences;
  19521. /**
  19522. * Creates a new MorphTargetManager
  19523. * @param scene defines the current scene
  19524. */
  19525. constructor(scene?: Nullable<Scene>);
  19526. /**
  19527. * Gets the unique ID of this manager
  19528. */
  19529. readonly uniqueId: number;
  19530. /**
  19531. * Gets the number of vertices handled by this manager
  19532. */
  19533. readonly vertexCount: number;
  19534. /**
  19535. * Gets a boolean indicating if this manager supports morphing of normals
  19536. */
  19537. readonly supportsNormals: boolean;
  19538. /**
  19539. * Gets a boolean indicating if this manager supports morphing of tangents
  19540. */
  19541. readonly supportsTangents: boolean;
  19542. /**
  19543. * Gets the number of targets stored in this manager
  19544. */
  19545. readonly numTargets: number;
  19546. /**
  19547. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19548. */
  19549. readonly numInfluencers: number;
  19550. /**
  19551. * Gets the list of influences (one per target)
  19552. */
  19553. readonly influences: Float32Array;
  19554. /**
  19555. * Gets the active target at specified index. An active target is a target with an influence > 0
  19556. * @param index defines the index to check
  19557. * @returns the requested target
  19558. */
  19559. getActiveTarget(index: number): MorphTarget;
  19560. /**
  19561. * Gets the target at specified index
  19562. * @param index defines the index to check
  19563. * @returns the requested target
  19564. */
  19565. getTarget(index: number): MorphTarget;
  19566. /**
  19567. * Add a new target to this manager
  19568. * @param target defines the target to add
  19569. */
  19570. addTarget(target: MorphTarget): void;
  19571. /**
  19572. * Removes a target from the manager
  19573. * @param target defines the target to remove
  19574. */
  19575. removeTarget(target: MorphTarget): void;
  19576. /**
  19577. * Serializes the current manager into a Serialization object
  19578. * @returns the serialized object
  19579. */
  19580. serialize(): any;
  19581. private _syncActiveTargets;
  19582. /**
  19583. * Syncrhonize the targets with all the meshes using this morph target manager
  19584. */
  19585. synchronize(): void;
  19586. /**
  19587. * Creates a new MorphTargetManager from serialized data
  19588. * @param serializationObject defines the serialized data
  19589. * @param scene defines the hosting scene
  19590. * @returns the new MorphTargetManager
  19591. */
  19592. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19593. }
  19594. }
  19595. declare module BABYLON {
  19596. /**
  19597. * Class used to represent a specific level of detail of a mesh
  19598. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19599. */
  19600. export class MeshLODLevel {
  19601. /** Defines the distance where this level should star being displayed */
  19602. distance: number;
  19603. /** Defines the mesh to use to render this level */
  19604. mesh: Nullable<Mesh>;
  19605. /**
  19606. * Creates a new LOD level
  19607. * @param distance defines the distance where this level should star being displayed
  19608. * @param mesh defines the mesh to use to render this level
  19609. */
  19610. constructor(
  19611. /** Defines the distance where this level should star being displayed */
  19612. distance: number,
  19613. /** Defines the mesh to use to render this level */
  19614. mesh: Nullable<Mesh>);
  19615. }
  19616. }
  19617. declare module BABYLON {
  19618. /**
  19619. * Mesh representing the gorund
  19620. */
  19621. export class GroundMesh extends Mesh {
  19622. /** If octree should be generated */
  19623. generateOctree: boolean;
  19624. private _heightQuads;
  19625. /** @hidden */
  19626. _subdivisionsX: number;
  19627. /** @hidden */
  19628. _subdivisionsY: number;
  19629. /** @hidden */
  19630. _width: number;
  19631. /** @hidden */
  19632. _height: number;
  19633. /** @hidden */
  19634. _minX: number;
  19635. /** @hidden */
  19636. _maxX: number;
  19637. /** @hidden */
  19638. _minZ: number;
  19639. /** @hidden */
  19640. _maxZ: number;
  19641. constructor(name: string, scene: Scene);
  19642. /**
  19643. * "GroundMesh"
  19644. * @returns "GroundMesh"
  19645. */
  19646. getClassName(): string;
  19647. /**
  19648. * The minimum of x and y subdivisions
  19649. */
  19650. readonly subdivisions: number;
  19651. /**
  19652. * X subdivisions
  19653. */
  19654. readonly subdivisionsX: number;
  19655. /**
  19656. * Y subdivisions
  19657. */
  19658. readonly subdivisionsY: number;
  19659. /**
  19660. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19661. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19662. * @param chunksCount the number of subdivisions for x and y
  19663. * @param octreeBlocksSize (Default: 32)
  19664. */
  19665. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19666. /**
  19667. * Returns a height (y) value in the Worl system :
  19668. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19669. * @param x x coordinate
  19670. * @param z z coordinate
  19671. * @returns the ground y position if (x, z) are outside the ground surface.
  19672. */
  19673. getHeightAtCoordinates(x: number, z: number): number;
  19674. /**
  19675. * Returns a normalized vector (Vector3) orthogonal to the ground
  19676. * at the ground coordinates (x, z) expressed in the World system.
  19677. * @param x x coordinate
  19678. * @param z z coordinate
  19679. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19680. */
  19681. getNormalAtCoordinates(x: number, z: number): Vector3;
  19682. /**
  19683. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19684. * at the ground coordinates (x, z) expressed in the World system.
  19685. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19686. * @param x x coordinate
  19687. * @param z z coordinate
  19688. * @param ref vector to store the result
  19689. * @returns the GroundMesh.
  19690. */
  19691. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19692. /**
  19693. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19694. * if the ground has been updated.
  19695. * This can be used in the render loop.
  19696. * @returns the GroundMesh.
  19697. */
  19698. updateCoordinateHeights(): GroundMesh;
  19699. private _getFacetAt;
  19700. private _initHeightQuads;
  19701. private _computeHeightQuads;
  19702. /**
  19703. * Serializes this ground mesh
  19704. * @param serializationObject object to write serialization to
  19705. */
  19706. serialize(serializationObject: any): void;
  19707. /**
  19708. * Parses a serialized ground mesh
  19709. * @param parsedMesh the serialized mesh
  19710. * @param scene the scene to create the ground mesh in
  19711. * @returns the created ground mesh
  19712. */
  19713. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19714. }
  19715. }
  19716. declare module BABYLON {
  19717. /**
  19718. * Interface for Physics-Joint data
  19719. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19720. */
  19721. export interface PhysicsJointData {
  19722. /**
  19723. * The main pivot of the joint
  19724. */
  19725. mainPivot?: Vector3;
  19726. /**
  19727. * The connected pivot of the joint
  19728. */
  19729. connectedPivot?: Vector3;
  19730. /**
  19731. * The main axis of the joint
  19732. */
  19733. mainAxis?: Vector3;
  19734. /**
  19735. * The connected axis of the joint
  19736. */
  19737. connectedAxis?: Vector3;
  19738. /**
  19739. * The collision of the joint
  19740. */
  19741. collision?: boolean;
  19742. /**
  19743. * Native Oimo/Cannon/Energy data
  19744. */
  19745. nativeParams?: any;
  19746. }
  19747. /**
  19748. * This is a holder class for the physics joint created by the physics plugin
  19749. * It holds a set of functions to control the underlying joint
  19750. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19751. */
  19752. export class PhysicsJoint {
  19753. /**
  19754. * The type of the physics joint
  19755. */
  19756. type: number;
  19757. /**
  19758. * The data for the physics joint
  19759. */
  19760. jointData: PhysicsJointData;
  19761. private _physicsJoint;
  19762. protected _physicsPlugin: IPhysicsEnginePlugin;
  19763. /**
  19764. * Initializes the physics joint
  19765. * @param type The type of the physics joint
  19766. * @param jointData The data for the physics joint
  19767. */
  19768. constructor(
  19769. /**
  19770. * The type of the physics joint
  19771. */
  19772. type: number,
  19773. /**
  19774. * The data for the physics joint
  19775. */
  19776. jointData: PhysicsJointData);
  19777. /**
  19778. * Gets the physics joint
  19779. */
  19780. /**
  19781. * Sets the physics joint
  19782. */
  19783. physicsJoint: any;
  19784. /**
  19785. * Sets the physics plugin
  19786. */
  19787. physicsPlugin: IPhysicsEnginePlugin;
  19788. /**
  19789. * Execute a function that is physics-plugin specific.
  19790. * @param {Function} func the function that will be executed.
  19791. * It accepts two parameters: the physics world and the physics joint
  19792. */
  19793. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19794. /**
  19795. * Distance-Joint type
  19796. */
  19797. static DistanceJoint: number;
  19798. /**
  19799. * Hinge-Joint type
  19800. */
  19801. static HingeJoint: number;
  19802. /**
  19803. * Ball-and-Socket joint type
  19804. */
  19805. static BallAndSocketJoint: number;
  19806. /**
  19807. * Wheel-Joint type
  19808. */
  19809. static WheelJoint: number;
  19810. /**
  19811. * Slider-Joint type
  19812. */
  19813. static SliderJoint: number;
  19814. /**
  19815. * Prismatic-Joint type
  19816. */
  19817. static PrismaticJoint: number;
  19818. /**
  19819. * Universal-Joint type
  19820. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19821. */
  19822. static UniversalJoint: number;
  19823. /**
  19824. * Hinge-Joint 2 type
  19825. */
  19826. static Hinge2Joint: number;
  19827. /**
  19828. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19829. */
  19830. static PointToPointJoint: number;
  19831. /**
  19832. * Spring-Joint type
  19833. */
  19834. static SpringJoint: number;
  19835. /**
  19836. * Lock-Joint type
  19837. */
  19838. static LockJoint: number;
  19839. }
  19840. /**
  19841. * A class representing a physics distance joint
  19842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19843. */
  19844. export class DistanceJoint extends PhysicsJoint {
  19845. /**
  19846. *
  19847. * @param jointData The data for the Distance-Joint
  19848. */
  19849. constructor(jointData: DistanceJointData);
  19850. /**
  19851. * Update the predefined distance.
  19852. * @param maxDistance The maximum preferred distance
  19853. * @param minDistance The minimum preferred distance
  19854. */
  19855. updateDistance(maxDistance: number, minDistance?: number): void;
  19856. }
  19857. /**
  19858. * Represents a Motor-Enabled Joint
  19859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19860. */
  19861. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19862. /**
  19863. * Initializes the Motor-Enabled Joint
  19864. * @param type The type of the joint
  19865. * @param jointData The physica joint data for the joint
  19866. */
  19867. constructor(type: number, jointData: PhysicsJointData);
  19868. /**
  19869. * Set the motor values.
  19870. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19871. * @param force the force to apply
  19872. * @param maxForce max force for this motor.
  19873. */
  19874. setMotor(force?: number, maxForce?: number): void;
  19875. /**
  19876. * Set the motor's limits.
  19877. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19878. * @param upperLimit The upper limit of the motor
  19879. * @param lowerLimit The lower limit of the motor
  19880. */
  19881. setLimit(upperLimit: number, lowerLimit?: number): void;
  19882. }
  19883. /**
  19884. * This class represents a single physics Hinge-Joint
  19885. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19886. */
  19887. export class HingeJoint extends MotorEnabledJoint {
  19888. /**
  19889. * Initializes the Hinge-Joint
  19890. * @param jointData The joint data for the Hinge-Joint
  19891. */
  19892. constructor(jointData: PhysicsJointData);
  19893. /**
  19894. * Set the motor values.
  19895. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19896. * @param {number} force the force to apply
  19897. * @param {number} maxForce max force for this motor.
  19898. */
  19899. setMotor(force?: number, maxForce?: number): void;
  19900. /**
  19901. * Set the motor's limits.
  19902. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19903. * @param upperLimit The upper limit of the motor
  19904. * @param lowerLimit The lower limit of the motor
  19905. */
  19906. setLimit(upperLimit: number, lowerLimit?: number): void;
  19907. }
  19908. /**
  19909. * This class represents a dual hinge physics joint (same as wheel joint)
  19910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19911. */
  19912. export class Hinge2Joint extends MotorEnabledJoint {
  19913. /**
  19914. * Initializes the Hinge2-Joint
  19915. * @param jointData The joint data for the Hinge2-Joint
  19916. */
  19917. constructor(jointData: PhysicsJointData);
  19918. /**
  19919. * Set the motor values.
  19920. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19921. * @param {number} targetSpeed the speed the motor is to reach
  19922. * @param {number} maxForce max force for this motor.
  19923. * @param {motorIndex} the motor's index, 0 or 1.
  19924. */
  19925. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19926. /**
  19927. * Set the motor limits.
  19928. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19929. * @param {number} upperLimit the upper limit
  19930. * @param {number} lowerLimit lower limit
  19931. * @param {motorIndex} the motor's index, 0 or 1.
  19932. */
  19933. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19934. }
  19935. /**
  19936. * Interface for a motor enabled joint
  19937. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19938. */
  19939. export interface IMotorEnabledJoint {
  19940. /**
  19941. * Physics joint
  19942. */
  19943. physicsJoint: any;
  19944. /**
  19945. * Sets the motor of the motor-enabled joint
  19946. * @param force The force of the motor
  19947. * @param maxForce The maximum force of the motor
  19948. * @param motorIndex The index of the motor
  19949. */
  19950. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19951. /**
  19952. * Sets the limit of the motor
  19953. * @param upperLimit The upper limit of the motor
  19954. * @param lowerLimit The lower limit of the motor
  19955. * @param motorIndex The index of the motor
  19956. */
  19957. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19958. }
  19959. /**
  19960. * Joint data for a Distance-Joint
  19961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19962. */
  19963. export interface DistanceJointData extends PhysicsJointData {
  19964. /**
  19965. * Max distance the 2 joint objects can be apart
  19966. */
  19967. maxDistance: number;
  19968. }
  19969. /**
  19970. * Joint data from a spring joint
  19971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19972. */
  19973. export interface SpringJointData extends PhysicsJointData {
  19974. /**
  19975. * Length of the spring
  19976. */
  19977. length: number;
  19978. /**
  19979. * Stiffness of the spring
  19980. */
  19981. stiffness: number;
  19982. /**
  19983. * Damping of the spring
  19984. */
  19985. damping: number;
  19986. /** this callback will be called when applying the force to the impostors. */
  19987. forceApplicationCallback: () => void;
  19988. }
  19989. }
  19990. declare module BABYLON {
  19991. /**
  19992. * Holds the data for the raycast result
  19993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19994. */
  19995. export class PhysicsRaycastResult {
  19996. private _hasHit;
  19997. private _hitDistance;
  19998. private _hitNormalWorld;
  19999. private _hitPointWorld;
  20000. private _rayFromWorld;
  20001. private _rayToWorld;
  20002. /**
  20003. * Gets if there was a hit
  20004. */
  20005. readonly hasHit: boolean;
  20006. /**
  20007. * Gets the distance from the hit
  20008. */
  20009. readonly hitDistance: number;
  20010. /**
  20011. * Gets the hit normal/direction in the world
  20012. */
  20013. readonly hitNormalWorld: Vector3;
  20014. /**
  20015. * Gets the hit point in the world
  20016. */
  20017. readonly hitPointWorld: Vector3;
  20018. /**
  20019. * Gets the ray "start point" of the ray in the world
  20020. */
  20021. readonly rayFromWorld: Vector3;
  20022. /**
  20023. * Gets the ray "end point" of the ray in the world
  20024. */
  20025. readonly rayToWorld: Vector3;
  20026. /**
  20027. * Sets the hit data (normal & point in world space)
  20028. * @param hitNormalWorld defines the normal in world space
  20029. * @param hitPointWorld defines the point in world space
  20030. */
  20031. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20032. /**
  20033. * Sets the distance from the start point to the hit point
  20034. * @param distance
  20035. */
  20036. setHitDistance(distance: number): void;
  20037. /**
  20038. * Calculates the distance manually
  20039. */
  20040. calculateHitDistance(): void;
  20041. /**
  20042. * Resets all the values to default
  20043. * @param from The from point on world space
  20044. * @param to The to point on world space
  20045. */
  20046. reset(from?: Vector3, to?: Vector3): void;
  20047. }
  20048. /**
  20049. * Interface for the size containing width and height
  20050. */
  20051. interface IXYZ {
  20052. /**
  20053. * X
  20054. */
  20055. x: number;
  20056. /**
  20057. * Y
  20058. */
  20059. y: number;
  20060. /**
  20061. * Z
  20062. */
  20063. z: number;
  20064. }
  20065. }
  20066. declare module BABYLON {
  20067. /**
  20068. * Interface used to describe a physics joint
  20069. */
  20070. export interface PhysicsImpostorJoint {
  20071. /** Defines the main impostor to which the joint is linked */
  20072. mainImpostor: PhysicsImpostor;
  20073. /** Defines the impostor that is connected to the main impostor using this joint */
  20074. connectedImpostor: PhysicsImpostor;
  20075. /** Defines the joint itself */
  20076. joint: PhysicsJoint;
  20077. }
  20078. /** @hidden */
  20079. export interface IPhysicsEnginePlugin {
  20080. world: any;
  20081. name: string;
  20082. setGravity(gravity: Vector3): void;
  20083. setTimeStep(timeStep: number): void;
  20084. getTimeStep(): number;
  20085. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20086. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20087. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20088. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20089. removePhysicsBody(impostor: PhysicsImpostor): void;
  20090. generateJoint(joint: PhysicsImpostorJoint): void;
  20091. removeJoint(joint: PhysicsImpostorJoint): void;
  20092. isSupported(): boolean;
  20093. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20094. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20095. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20096. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20097. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20098. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20099. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20100. getBodyMass(impostor: PhysicsImpostor): number;
  20101. getBodyFriction(impostor: PhysicsImpostor): number;
  20102. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20103. getBodyRestitution(impostor: PhysicsImpostor): number;
  20104. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20105. getBodyPressure?(impostor: PhysicsImpostor): number;
  20106. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20107. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20108. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20109. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20110. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20111. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20112. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20113. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20114. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20115. sleepBody(impostor: PhysicsImpostor): void;
  20116. wakeUpBody(impostor: PhysicsImpostor): void;
  20117. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20118. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20119. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20120. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20121. getRadius(impostor: PhysicsImpostor): number;
  20122. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20123. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20124. dispose(): void;
  20125. }
  20126. /**
  20127. * Interface used to define a physics engine
  20128. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20129. */
  20130. export interface IPhysicsEngine {
  20131. /**
  20132. * Gets the gravity vector used by the simulation
  20133. */
  20134. gravity: Vector3;
  20135. /**
  20136. * Sets the gravity vector used by the simulation
  20137. * @param gravity defines the gravity vector to use
  20138. */
  20139. setGravity(gravity: Vector3): void;
  20140. /**
  20141. * Set the time step of the physics engine.
  20142. * Default is 1/60.
  20143. * To slow it down, enter 1/600 for example.
  20144. * To speed it up, 1/30
  20145. * @param newTimeStep the new timestep to apply to this world.
  20146. */
  20147. setTimeStep(newTimeStep: number): void;
  20148. /**
  20149. * Get the time step of the physics engine.
  20150. * @returns the current time step
  20151. */
  20152. getTimeStep(): number;
  20153. /**
  20154. * Release all resources
  20155. */
  20156. dispose(): void;
  20157. /**
  20158. * Gets the name of the current physics plugin
  20159. * @returns the name of the plugin
  20160. */
  20161. getPhysicsPluginName(): string;
  20162. /**
  20163. * Adding a new impostor for the impostor tracking.
  20164. * This will be done by the impostor itself.
  20165. * @param impostor the impostor to add
  20166. */
  20167. addImpostor(impostor: PhysicsImpostor): void;
  20168. /**
  20169. * Remove an impostor from the engine.
  20170. * This impostor and its mesh will not longer be updated by the physics engine.
  20171. * @param impostor the impostor to remove
  20172. */
  20173. removeImpostor(impostor: PhysicsImpostor): void;
  20174. /**
  20175. * Add a joint to the physics engine
  20176. * @param mainImpostor defines the main impostor to which the joint is added.
  20177. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20178. * @param joint defines the joint that will connect both impostors.
  20179. */
  20180. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20181. /**
  20182. * Removes a joint from the simulation
  20183. * @param mainImpostor defines the impostor used with the joint
  20184. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20185. * @param joint defines the joint to remove
  20186. */
  20187. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20188. /**
  20189. * Gets the current plugin used to run the simulation
  20190. * @returns current plugin
  20191. */
  20192. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20193. /**
  20194. * Gets the list of physic impostors
  20195. * @returns an array of PhysicsImpostor
  20196. */
  20197. getImpostors(): Array<PhysicsImpostor>;
  20198. /**
  20199. * Gets the impostor for a physics enabled object
  20200. * @param object defines the object impersonated by the impostor
  20201. * @returns the PhysicsImpostor or null if not found
  20202. */
  20203. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20204. /**
  20205. * Gets the impostor for a physics body object
  20206. * @param body defines physics body used by the impostor
  20207. * @returns the PhysicsImpostor or null if not found
  20208. */
  20209. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20210. /**
  20211. * Does a raycast in the physics world
  20212. * @param from when should the ray start?
  20213. * @param to when should the ray end?
  20214. * @returns PhysicsRaycastResult
  20215. */
  20216. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20217. /**
  20218. * Called by the scene. No need to call it.
  20219. * @param delta defines the timespam between frames
  20220. */
  20221. _step(delta: number): void;
  20222. }
  20223. }
  20224. declare module BABYLON {
  20225. /**
  20226. * The interface for the physics imposter parameters
  20227. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20228. */
  20229. export interface PhysicsImpostorParameters {
  20230. /**
  20231. * The mass of the physics imposter
  20232. */
  20233. mass: number;
  20234. /**
  20235. * The friction of the physics imposter
  20236. */
  20237. friction?: number;
  20238. /**
  20239. * The coefficient of restitution of the physics imposter
  20240. */
  20241. restitution?: number;
  20242. /**
  20243. * The native options of the physics imposter
  20244. */
  20245. nativeOptions?: any;
  20246. /**
  20247. * Specifies if the parent should be ignored
  20248. */
  20249. ignoreParent?: boolean;
  20250. /**
  20251. * Specifies if bi-directional transformations should be disabled
  20252. */
  20253. disableBidirectionalTransformation?: boolean;
  20254. /**
  20255. * The pressure inside the physics imposter, soft object only
  20256. */
  20257. pressure?: number;
  20258. /**
  20259. * The stiffness the physics imposter, soft object only
  20260. */
  20261. stiffness?: number;
  20262. /**
  20263. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20264. */
  20265. velocityIterations?: number;
  20266. /**
  20267. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20268. */
  20269. positionIterations?: number;
  20270. /**
  20271. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20272. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20273. * Add to fix multiple points
  20274. */
  20275. fixedPoints?: number;
  20276. /**
  20277. * The collision margin around a soft object
  20278. */
  20279. margin?: number;
  20280. /**
  20281. * The collision margin around a soft object
  20282. */
  20283. damping?: number;
  20284. /**
  20285. * The path for a rope based on an extrusion
  20286. */
  20287. path?: any;
  20288. /**
  20289. * The shape of an extrusion used for a rope based on an extrusion
  20290. */
  20291. shape?: any;
  20292. }
  20293. /**
  20294. * Interface for a physics-enabled object
  20295. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20296. */
  20297. export interface IPhysicsEnabledObject {
  20298. /**
  20299. * The position of the physics-enabled object
  20300. */
  20301. position: Vector3;
  20302. /**
  20303. * The rotation of the physics-enabled object
  20304. */
  20305. rotationQuaternion: Nullable<Quaternion>;
  20306. /**
  20307. * The scale of the physics-enabled object
  20308. */
  20309. scaling: Vector3;
  20310. /**
  20311. * The rotation of the physics-enabled object
  20312. */
  20313. rotation?: Vector3;
  20314. /**
  20315. * The parent of the physics-enabled object
  20316. */
  20317. parent?: any;
  20318. /**
  20319. * The bounding info of the physics-enabled object
  20320. * @returns The bounding info of the physics-enabled object
  20321. */
  20322. getBoundingInfo(): BoundingInfo;
  20323. /**
  20324. * Computes the world matrix
  20325. * @param force Specifies if the world matrix should be computed by force
  20326. * @returns A world matrix
  20327. */
  20328. computeWorldMatrix(force: boolean): Matrix;
  20329. /**
  20330. * Gets the world matrix
  20331. * @returns A world matrix
  20332. */
  20333. getWorldMatrix?(): Matrix;
  20334. /**
  20335. * Gets the child meshes
  20336. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20337. * @returns An array of abstract meshes
  20338. */
  20339. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20340. /**
  20341. * Gets the vertex data
  20342. * @param kind The type of vertex data
  20343. * @returns A nullable array of numbers, or a float32 array
  20344. */
  20345. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20346. /**
  20347. * Gets the indices from the mesh
  20348. * @returns A nullable array of index arrays
  20349. */
  20350. getIndices?(): Nullable<IndicesArray>;
  20351. /**
  20352. * Gets the scene from the mesh
  20353. * @returns the indices array or null
  20354. */
  20355. getScene?(): Scene;
  20356. /**
  20357. * Gets the absolute position from the mesh
  20358. * @returns the absolute position
  20359. */
  20360. getAbsolutePosition(): Vector3;
  20361. /**
  20362. * Gets the absolute pivot point from the mesh
  20363. * @returns the absolute pivot point
  20364. */
  20365. getAbsolutePivotPoint(): Vector3;
  20366. /**
  20367. * Rotates the mesh
  20368. * @param axis The axis of rotation
  20369. * @param amount The amount of rotation
  20370. * @param space The space of the rotation
  20371. * @returns The rotation transform node
  20372. */
  20373. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20374. /**
  20375. * Translates the mesh
  20376. * @param axis The axis of translation
  20377. * @param distance The distance of translation
  20378. * @param space The space of the translation
  20379. * @returns The transform node
  20380. */
  20381. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20382. /**
  20383. * Sets the absolute position of the mesh
  20384. * @param absolutePosition The absolute position of the mesh
  20385. * @returns The transform node
  20386. */
  20387. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20388. /**
  20389. * Gets the class name of the mesh
  20390. * @returns The class name
  20391. */
  20392. getClassName(): string;
  20393. }
  20394. /**
  20395. * Represents a physics imposter
  20396. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20397. */
  20398. export class PhysicsImpostor {
  20399. /**
  20400. * The physics-enabled object used as the physics imposter
  20401. */
  20402. object: IPhysicsEnabledObject;
  20403. /**
  20404. * The type of the physics imposter
  20405. */
  20406. type: number;
  20407. private _options;
  20408. private _scene?;
  20409. /**
  20410. * The default object size of the imposter
  20411. */
  20412. static DEFAULT_OBJECT_SIZE: Vector3;
  20413. /**
  20414. * The identity quaternion of the imposter
  20415. */
  20416. static IDENTITY_QUATERNION: Quaternion;
  20417. /** @hidden */
  20418. _pluginData: any;
  20419. private _physicsEngine;
  20420. private _physicsBody;
  20421. private _bodyUpdateRequired;
  20422. private _onBeforePhysicsStepCallbacks;
  20423. private _onAfterPhysicsStepCallbacks;
  20424. /** @hidden */
  20425. _onPhysicsCollideCallbacks: Array<{
  20426. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20427. otherImpostors: Array<PhysicsImpostor>;
  20428. }>;
  20429. private _deltaPosition;
  20430. private _deltaRotation;
  20431. private _deltaRotationConjugated;
  20432. /** hidden */
  20433. _isFromLine: boolean;
  20434. private _parent;
  20435. private _isDisposed;
  20436. private static _tmpVecs;
  20437. private static _tmpQuat;
  20438. /**
  20439. * Specifies if the physics imposter is disposed
  20440. */
  20441. readonly isDisposed: boolean;
  20442. /**
  20443. * Gets the mass of the physics imposter
  20444. */
  20445. mass: number;
  20446. /**
  20447. * Gets the coefficient of friction
  20448. */
  20449. /**
  20450. * Sets the coefficient of friction
  20451. */
  20452. friction: number;
  20453. /**
  20454. * Gets the coefficient of restitution
  20455. */
  20456. /**
  20457. * Sets the coefficient of restitution
  20458. */
  20459. restitution: number;
  20460. /**
  20461. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20462. */
  20463. /**
  20464. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20465. */
  20466. pressure: number;
  20467. /**
  20468. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20469. */
  20470. /**
  20471. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20472. */
  20473. stiffness: number;
  20474. /**
  20475. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20476. */
  20477. /**
  20478. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20479. */
  20480. velocityIterations: number;
  20481. /**
  20482. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20483. */
  20484. /**
  20485. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20486. */
  20487. positionIterations: number;
  20488. /**
  20489. * The unique id of the physics imposter
  20490. * set by the physics engine when adding this impostor to the array
  20491. */
  20492. uniqueId: number;
  20493. /**
  20494. * @hidden
  20495. */
  20496. soft: boolean;
  20497. /**
  20498. * @hidden
  20499. */
  20500. segments: number;
  20501. private _joints;
  20502. /**
  20503. * Initializes the physics imposter
  20504. * @param object The physics-enabled object used as the physics imposter
  20505. * @param type The type of the physics imposter
  20506. * @param _options The options for the physics imposter
  20507. * @param _scene The Babylon scene
  20508. */
  20509. constructor(
  20510. /**
  20511. * The physics-enabled object used as the physics imposter
  20512. */
  20513. object: IPhysicsEnabledObject,
  20514. /**
  20515. * The type of the physics imposter
  20516. */
  20517. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20518. /**
  20519. * This function will completly initialize this impostor.
  20520. * It will create a new body - but only if this mesh has no parent.
  20521. * If it has, this impostor will not be used other than to define the impostor
  20522. * of the child mesh.
  20523. * @hidden
  20524. */
  20525. _init(): void;
  20526. private _getPhysicsParent;
  20527. /**
  20528. * Should a new body be generated.
  20529. * @returns boolean specifying if body initialization is required
  20530. */
  20531. isBodyInitRequired(): boolean;
  20532. /**
  20533. * Sets the updated scaling
  20534. * @param updated Specifies if the scaling is updated
  20535. */
  20536. setScalingUpdated(): void;
  20537. /**
  20538. * Force a regeneration of this or the parent's impostor's body.
  20539. * Use under cautious - This will remove all joints already implemented.
  20540. */
  20541. forceUpdate(): void;
  20542. /**
  20543. * Gets the body that holds this impostor. Either its own, or its parent.
  20544. */
  20545. /**
  20546. * Set the physics body. Used mainly by the physics engine/plugin
  20547. */
  20548. physicsBody: any;
  20549. /**
  20550. * Get the parent of the physics imposter
  20551. * @returns Physics imposter or null
  20552. */
  20553. /**
  20554. * Sets the parent of the physics imposter
  20555. */
  20556. parent: Nullable<PhysicsImpostor>;
  20557. /**
  20558. * Resets the update flags
  20559. */
  20560. resetUpdateFlags(): void;
  20561. /**
  20562. * Gets the object extend size
  20563. * @returns the object extend size
  20564. */
  20565. getObjectExtendSize(): Vector3;
  20566. /**
  20567. * Gets the object center
  20568. * @returns The object center
  20569. */
  20570. getObjectCenter(): Vector3;
  20571. /**
  20572. * Get a specific parametes from the options parameter
  20573. * @param paramName The object parameter name
  20574. * @returns The object parameter
  20575. */
  20576. getParam(paramName: string): any;
  20577. /**
  20578. * Sets a specific parameter in the options given to the physics plugin
  20579. * @param paramName The parameter name
  20580. * @param value The value of the parameter
  20581. */
  20582. setParam(paramName: string, value: number): void;
  20583. /**
  20584. * Specifically change the body's mass option. Won't recreate the physics body object
  20585. * @param mass The mass of the physics imposter
  20586. */
  20587. setMass(mass: number): void;
  20588. /**
  20589. * Gets the linear velocity
  20590. * @returns linear velocity or null
  20591. */
  20592. getLinearVelocity(): Nullable<Vector3>;
  20593. /**
  20594. * Sets the linear velocity
  20595. * @param velocity linear velocity or null
  20596. */
  20597. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20598. /**
  20599. * Gets the angular velocity
  20600. * @returns angular velocity or null
  20601. */
  20602. getAngularVelocity(): Nullable<Vector3>;
  20603. /**
  20604. * Sets the angular velocity
  20605. * @param velocity The velocity or null
  20606. */
  20607. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20608. /**
  20609. * Execute a function with the physics plugin native code
  20610. * Provide a function the will have two variables - the world object and the physics body object
  20611. * @param func The function to execute with the physics plugin native code
  20612. */
  20613. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20614. /**
  20615. * Register a function that will be executed before the physics world is stepping forward
  20616. * @param func The function to execute before the physics world is stepped forward
  20617. */
  20618. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20619. /**
  20620. * Unregister a function that will be executed before the physics world is stepping forward
  20621. * @param func The function to execute before the physics world is stepped forward
  20622. */
  20623. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20624. /**
  20625. * Register a function that will be executed after the physics step
  20626. * @param func The function to execute after physics step
  20627. */
  20628. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20629. /**
  20630. * Unregisters a function that will be executed after the physics step
  20631. * @param func The function to execute after physics step
  20632. */
  20633. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20634. /**
  20635. * register a function that will be executed when this impostor collides against a different body
  20636. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20637. * @param func Callback that is executed on collision
  20638. */
  20639. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20640. /**
  20641. * Unregisters the physics imposter on contact
  20642. * @param collideAgainst The physics object to collide against
  20643. * @param func Callback to execute on collision
  20644. */
  20645. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20646. private _tmpQuat;
  20647. private _tmpQuat2;
  20648. /**
  20649. * Get the parent rotation
  20650. * @returns The parent rotation
  20651. */
  20652. getParentsRotation(): Quaternion;
  20653. /**
  20654. * this function is executed by the physics engine.
  20655. */
  20656. beforeStep: () => void;
  20657. /**
  20658. * this function is executed by the physics engine
  20659. */
  20660. afterStep: () => void;
  20661. /**
  20662. * Legacy collision detection event support
  20663. */
  20664. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20665. /**
  20666. * event and body object due to cannon's event-based architecture.
  20667. */
  20668. onCollide: (e: {
  20669. body: any;
  20670. }) => void;
  20671. /**
  20672. * Apply a force
  20673. * @param force The force to apply
  20674. * @param contactPoint The contact point for the force
  20675. * @returns The physics imposter
  20676. */
  20677. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20678. /**
  20679. * Apply an impulse
  20680. * @param force The impulse force
  20681. * @param contactPoint The contact point for the impulse force
  20682. * @returns The physics imposter
  20683. */
  20684. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20685. /**
  20686. * A help function to create a joint
  20687. * @param otherImpostor A physics imposter used to create a joint
  20688. * @param jointType The type of joint
  20689. * @param jointData The data for the joint
  20690. * @returns The physics imposter
  20691. */
  20692. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20693. /**
  20694. * Add a joint to this impostor with a different impostor
  20695. * @param otherImpostor A physics imposter used to add a joint
  20696. * @param joint The joint to add
  20697. * @returns The physics imposter
  20698. */
  20699. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20700. /**
  20701. * Add an anchor to a cloth impostor
  20702. * @param otherImpostor rigid impostor to anchor to
  20703. * @param width ratio across width from 0 to 1
  20704. * @param height ratio up height from 0 to 1
  20705. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20706. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20707. * @returns impostor the soft imposter
  20708. */
  20709. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20710. /**
  20711. * Add a hook to a rope impostor
  20712. * @param otherImpostor rigid impostor to anchor to
  20713. * @param length ratio across rope from 0 to 1
  20714. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20715. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20716. * @returns impostor the rope imposter
  20717. */
  20718. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20719. /**
  20720. * Will keep this body still, in a sleep mode.
  20721. * @returns the physics imposter
  20722. */
  20723. sleep(): PhysicsImpostor;
  20724. /**
  20725. * Wake the body up.
  20726. * @returns The physics imposter
  20727. */
  20728. wakeUp(): PhysicsImpostor;
  20729. /**
  20730. * Clones the physics imposter
  20731. * @param newObject The physics imposter clones to this physics-enabled object
  20732. * @returns A nullable physics imposter
  20733. */
  20734. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20735. /**
  20736. * Disposes the physics imposter
  20737. */
  20738. dispose(): void;
  20739. /**
  20740. * Sets the delta position
  20741. * @param position The delta position amount
  20742. */
  20743. setDeltaPosition(position: Vector3): void;
  20744. /**
  20745. * Sets the delta rotation
  20746. * @param rotation The delta rotation amount
  20747. */
  20748. setDeltaRotation(rotation: Quaternion): void;
  20749. /**
  20750. * Gets the box size of the physics imposter and stores the result in the input parameter
  20751. * @param result Stores the box size
  20752. * @returns The physics imposter
  20753. */
  20754. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20755. /**
  20756. * Gets the radius of the physics imposter
  20757. * @returns Radius of the physics imposter
  20758. */
  20759. getRadius(): number;
  20760. /**
  20761. * Sync a bone with this impostor
  20762. * @param bone The bone to sync to the impostor.
  20763. * @param boneMesh The mesh that the bone is influencing.
  20764. * @param jointPivot The pivot of the joint / bone in local space.
  20765. * @param distToJoint Optional distance from the impostor to the joint.
  20766. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20767. */
  20768. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20769. /**
  20770. * Sync impostor to a bone
  20771. * @param bone The bone that the impostor will be synced to.
  20772. * @param boneMesh The mesh that the bone is influencing.
  20773. * @param jointPivot The pivot of the joint / bone in local space.
  20774. * @param distToJoint Optional distance from the impostor to the joint.
  20775. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20776. * @param boneAxis Optional vector3 axis the bone is aligned with
  20777. */
  20778. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20779. /**
  20780. * No-Imposter type
  20781. */
  20782. static NoImpostor: number;
  20783. /**
  20784. * Sphere-Imposter type
  20785. */
  20786. static SphereImpostor: number;
  20787. /**
  20788. * Box-Imposter type
  20789. */
  20790. static BoxImpostor: number;
  20791. /**
  20792. * Plane-Imposter type
  20793. */
  20794. static PlaneImpostor: number;
  20795. /**
  20796. * Mesh-imposter type
  20797. */
  20798. static MeshImpostor: number;
  20799. /**
  20800. * Cylinder-Imposter type
  20801. */
  20802. static CylinderImpostor: number;
  20803. /**
  20804. * Particle-Imposter type
  20805. */
  20806. static ParticleImpostor: number;
  20807. /**
  20808. * Heightmap-Imposter type
  20809. */
  20810. static HeightmapImpostor: number;
  20811. /**
  20812. * ConvexHull-Impostor type (Ammo.js plugin only)
  20813. */
  20814. static ConvexHullImpostor: number;
  20815. /**
  20816. * Rope-Imposter type
  20817. */
  20818. static RopeImpostor: number;
  20819. /**
  20820. * Cloth-Imposter type
  20821. */
  20822. static ClothImpostor: number;
  20823. /**
  20824. * Softbody-Imposter type
  20825. */
  20826. static SoftbodyImpostor: number;
  20827. }
  20828. }
  20829. declare module BABYLON {
  20830. /**
  20831. * @hidden
  20832. **/
  20833. export class _CreationDataStorage {
  20834. closePath?: boolean;
  20835. closeArray?: boolean;
  20836. idx: number[];
  20837. dashSize: number;
  20838. gapSize: number;
  20839. path3D: Path3D;
  20840. pathArray: Vector3[][];
  20841. arc: number;
  20842. radius: number;
  20843. cap: number;
  20844. tessellation: number;
  20845. }
  20846. /**
  20847. * @hidden
  20848. **/
  20849. class _InstanceDataStorage {
  20850. visibleInstances: any;
  20851. batchCache: _InstancesBatch;
  20852. instancesBufferSize: number;
  20853. instancesBuffer: Nullable<Buffer>;
  20854. instancesData: Float32Array;
  20855. overridenInstanceCount: number;
  20856. isFrozen: boolean;
  20857. previousBatch: _InstancesBatch;
  20858. hardwareInstancedRendering: boolean;
  20859. sideOrientation: number;
  20860. }
  20861. /**
  20862. * @hidden
  20863. **/
  20864. export class _InstancesBatch {
  20865. mustReturn: boolean;
  20866. visibleInstances: Nullable<InstancedMesh[]>[];
  20867. renderSelf: boolean[];
  20868. hardwareInstancedRendering: boolean[];
  20869. }
  20870. /**
  20871. * Class used to represent renderable models
  20872. */
  20873. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20874. /**
  20875. * Mesh side orientation : usually the external or front surface
  20876. */
  20877. static readonly FRONTSIDE: number;
  20878. /**
  20879. * Mesh side orientation : usually the internal or back surface
  20880. */
  20881. static readonly BACKSIDE: number;
  20882. /**
  20883. * Mesh side orientation : both internal and external or front and back surfaces
  20884. */
  20885. static readonly DOUBLESIDE: number;
  20886. /**
  20887. * Mesh side orientation : by default, `FRONTSIDE`
  20888. */
  20889. static readonly DEFAULTSIDE: number;
  20890. /**
  20891. * Mesh cap setting : no cap
  20892. */
  20893. static readonly NO_CAP: number;
  20894. /**
  20895. * Mesh cap setting : one cap at the beginning of the mesh
  20896. */
  20897. static readonly CAP_START: number;
  20898. /**
  20899. * Mesh cap setting : one cap at the end of the mesh
  20900. */
  20901. static readonly CAP_END: number;
  20902. /**
  20903. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20904. */
  20905. static readonly CAP_ALL: number;
  20906. /**
  20907. * Mesh pattern setting : no flip or rotate
  20908. */
  20909. static readonly NO_FLIP: number;
  20910. /**
  20911. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  20912. */
  20913. static readonly FLIP_TILE: number;
  20914. /**
  20915. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  20916. */
  20917. static readonly ROTATE_TILE: number;
  20918. /**
  20919. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  20920. */
  20921. static readonly FLIP_ROW: number;
  20922. /**
  20923. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  20924. */
  20925. static readonly ROTATE_ROW: number;
  20926. /**
  20927. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  20928. */
  20929. static readonly FLIP_N_ROTATE_TILE: number;
  20930. /**
  20931. * Mesh pattern setting : rotate pattern and rotate
  20932. */
  20933. static readonly FLIP_N_ROTATE_ROW: number;
  20934. /**
  20935. * Mesh tile positioning : part tiles same on left/right or top/bottom
  20936. */
  20937. static readonly CENTER: number;
  20938. /**
  20939. * Mesh tile positioning : part tiles on left
  20940. */
  20941. static readonly LEFT: number;
  20942. /**
  20943. * Mesh tile positioning : part tiles on right
  20944. */
  20945. static readonly RIGHT: number;
  20946. /**
  20947. * Mesh tile positioning : part tiles on top
  20948. */
  20949. static readonly TOP: number;
  20950. /**
  20951. * Mesh tile positioning : part tiles on bottom
  20952. */
  20953. static readonly BOTTOM: number;
  20954. /**
  20955. * Gets the default side orientation.
  20956. * @param orientation the orientation to value to attempt to get
  20957. * @returns the default orientation
  20958. * @hidden
  20959. */
  20960. static _GetDefaultSideOrientation(orientation?: number): number;
  20961. private _internalMeshDataInfo;
  20962. /**
  20963. * An event triggered before rendering the mesh
  20964. */
  20965. readonly onBeforeRenderObservable: Observable<Mesh>;
  20966. /**
  20967. * An event triggered before binding the mesh
  20968. */
  20969. readonly onBeforeBindObservable: Observable<Mesh>;
  20970. /**
  20971. * An event triggered after rendering the mesh
  20972. */
  20973. readonly onAfterRenderObservable: Observable<Mesh>;
  20974. /**
  20975. * An event triggered before drawing the mesh
  20976. */
  20977. readonly onBeforeDrawObservable: Observable<Mesh>;
  20978. private _onBeforeDrawObserver;
  20979. /**
  20980. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20981. */
  20982. onBeforeDraw: () => void;
  20983. /**
  20984. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20985. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20986. */
  20987. delayLoadState: number;
  20988. /**
  20989. * Gets the list of instances created from this mesh
  20990. * it is not supposed to be modified manually.
  20991. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20992. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20993. */
  20994. instances: InstancedMesh[];
  20995. /**
  20996. * Gets the file containing delay loading data for this mesh
  20997. */
  20998. delayLoadingFile: string;
  20999. /** @hidden */
  21000. _binaryInfo: any;
  21001. /**
  21002. * User defined function used to change how LOD level selection is done
  21003. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21004. */
  21005. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21006. /**
  21007. * Gets or sets the morph target manager
  21008. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21009. */
  21010. morphTargetManager: Nullable<MorphTargetManager>;
  21011. /** @hidden */
  21012. _creationDataStorage: Nullable<_CreationDataStorage>;
  21013. /** @hidden */
  21014. _geometry: Nullable<Geometry>;
  21015. /** @hidden */
  21016. _delayInfo: Array<string>;
  21017. /** @hidden */
  21018. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21019. /** @hidden */
  21020. _instanceDataStorage: _InstanceDataStorage;
  21021. private _effectiveMaterial;
  21022. /** @hidden */
  21023. _shouldGenerateFlatShading: boolean;
  21024. /** @hidden */
  21025. _originalBuilderSideOrientation: number;
  21026. /**
  21027. * Use this property to change the original side orientation defined at construction time
  21028. */
  21029. overrideMaterialSideOrientation: Nullable<number>;
  21030. /**
  21031. * Gets the source mesh (the one used to clone this one from)
  21032. */
  21033. readonly source: Nullable<Mesh>;
  21034. /**
  21035. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21036. */
  21037. isUnIndexed: boolean;
  21038. /**
  21039. * @constructor
  21040. * @param name The value used by scene.getMeshByName() to do a lookup.
  21041. * @param scene The scene to add this mesh to.
  21042. * @param parent The parent of this mesh, if it has one
  21043. * @param source An optional Mesh from which geometry is shared, cloned.
  21044. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21045. * When false, achieved by calling a clone(), also passing False.
  21046. * This will make creation of children, recursive.
  21047. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21048. */
  21049. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21050. /**
  21051. * Gets the class name
  21052. * @returns the string "Mesh".
  21053. */
  21054. getClassName(): string;
  21055. /** @hidden */
  21056. readonly _isMesh: boolean;
  21057. /**
  21058. * Returns a description of this mesh
  21059. * @param fullDetails define if full details about this mesh must be used
  21060. * @returns a descriptive string representing this mesh
  21061. */
  21062. toString(fullDetails?: boolean): string;
  21063. /** @hidden */
  21064. _unBindEffect(): void;
  21065. /**
  21066. * Gets a boolean indicating if this mesh has LOD
  21067. */
  21068. readonly hasLODLevels: boolean;
  21069. /**
  21070. * Gets the list of MeshLODLevel associated with the current mesh
  21071. * @returns an array of MeshLODLevel
  21072. */
  21073. getLODLevels(): MeshLODLevel[];
  21074. private _sortLODLevels;
  21075. /**
  21076. * Add a mesh as LOD level triggered at the given distance.
  21077. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21078. * @param distance The distance from the center of the object to show this level
  21079. * @param mesh The mesh to be added as LOD level (can be null)
  21080. * @return This mesh (for chaining)
  21081. */
  21082. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21083. /**
  21084. * Returns the LOD level mesh at the passed distance or null if not found.
  21085. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21086. * @param distance The distance from the center of the object to show this level
  21087. * @returns a Mesh or `null`
  21088. */
  21089. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21090. /**
  21091. * Remove a mesh from the LOD array
  21092. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21093. * @param mesh defines the mesh to be removed
  21094. * @return This mesh (for chaining)
  21095. */
  21096. removeLODLevel(mesh: Mesh): Mesh;
  21097. /**
  21098. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21099. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21100. * @param camera defines the camera to use to compute distance
  21101. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21102. * @return This mesh (for chaining)
  21103. */
  21104. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21105. /**
  21106. * Gets the mesh internal Geometry object
  21107. */
  21108. readonly geometry: Nullable<Geometry>;
  21109. /**
  21110. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21111. * @returns the total number of vertices
  21112. */
  21113. getTotalVertices(): number;
  21114. /**
  21115. * Returns the content of an associated vertex buffer
  21116. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21117. * - VertexBuffer.PositionKind
  21118. * - VertexBuffer.UVKind
  21119. * - VertexBuffer.UV2Kind
  21120. * - VertexBuffer.UV3Kind
  21121. * - VertexBuffer.UV4Kind
  21122. * - VertexBuffer.UV5Kind
  21123. * - VertexBuffer.UV6Kind
  21124. * - VertexBuffer.ColorKind
  21125. * - VertexBuffer.MatricesIndicesKind
  21126. * - VertexBuffer.MatricesIndicesExtraKind
  21127. * - VertexBuffer.MatricesWeightsKind
  21128. * - VertexBuffer.MatricesWeightsExtraKind
  21129. * @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
  21130. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21131. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21132. */
  21133. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21134. /**
  21135. * Returns the mesh VertexBuffer object from the requested `kind`
  21136. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21137. * - VertexBuffer.PositionKind
  21138. * - VertexBuffer.NormalKind
  21139. * - VertexBuffer.UVKind
  21140. * - VertexBuffer.UV2Kind
  21141. * - VertexBuffer.UV3Kind
  21142. * - VertexBuffer.UV4Kind
  21143. * - VertexBuffer.UV5Kind
  21144. * - VertexBuffer.UV6Kind
  21145. * - VertexBuffer.ColorKind
  21146. * - VertexBuffer.MatricesIndicesKind
  21147. * - VertexBuffer.MatricesIndicesExtraKind
  21148. * - VertexBuffer.MatricesWeightsKind
  21149. * - VertexBuffer.MatricesWeightsExtraKind
  21150. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21151. */
  21152. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21153. /**
  21154. * Tests if a specific vertex buffer is associated with this mesh
  21155. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21156. * - VertexBuffer.PositionKind
  21157. * - VertexBuffer.NormalKind
  21158. * - VertexBuffer.UVKind
  21159. * - VertexBuffer.UV2Kind
  21160. * - VertexBuffer.UV3Kind
  21161. * - VertexBuffer.UV4Kind
  21162. * - VertexBuffer.UV5Kind
  21163. * - VertexBuffer.UV6Kind
  21164. * - VertexBuffer.ColorKind
  21165. * - VertexBuffer.MatricesIndicesKind
  21166. * - VertexBuffer.MatricesIndicesExtraKind
  21167. * - VertexBuffer.MatricesWeightsKind
  21168. * - VertexBuffer.MatricesWeightsExtraKind
  21169. * @returns a boolean
  21170. */
  21171. isVerticesDataPresent(kind: string): boolean;
  21172. /**
  21173. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21174. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21175. * - VertexBuffer.PositionKind
  21176. * - VertexBuffer.UVKind
  21177. * - VertexBuffer.UV2Kind
  21178. * - VertexBuffer.UV3Kind
  21179. * - VertexBuffer.UV4Kind
  21180. * - VertexBuffer.UV5Kind
  21181. * - VertexBuffer.UV6Kind
  21182. * - VertexBuffer.ColorKind
  21183. * - VertexBuffer.MatricesIndicesKind
  21184. * - VertexBuffer.MatricesIndicesExtraKind
  21185. * - VertexBuffer.MatricesWeightsKind
  21186. * - VertexBuffer.MatricesWeightsExtraKind
  21187. * @returns a boolean
  21188. */
  21189. isVertexBufferUpdatable(kind: string): boolean;
  21190. /**
  21191. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21192. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21193. * - VertexBuffer.PositionKind
  21194. * - VertexBuffer.NormalKind
  21195. * - VertexBuffer.UVKind
  21196. * - VertexBuffer.UV2Kind
  21197. * - VertexBuffer.UV3Kind
  21198. * - VertexBuffer.UV4Kind
  21199. * - VertexBuffer.UV5Kind
  21200. * - VertexBuffer.UV6Kind
  21201. * - VertexBuffer.ColorKind
  21202. * - VertexBuffer.MatricesIndicesKind
  21203. * - VertexBuffer.MatricesIndicesExtraKind
  21204. * - VertexBuffer.MatricesWeightsKind
  21205. * - VertexBuffer.MatricesWeightsExtraKind
  21206. * @returns an array of strings
  21207. */
  21208. getVerticesDataKinds(): string[];
  21209. /**
  21210. * Returns a positive integer : the total number of indices in this mesh geometry.
  21211. * @returns the numner of indices or zero if the mesh has no geometry.
  21212. */
  21213. getTotalIndices(): number;
  21214. /**
  21215. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21216. * @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.
  21217. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21218. * @returns the indices array or an empty array if the mesh has no geometry
  21219. */
  21220. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21221. readonly isBlocked: boolean;
  21222. /**
  21223. * Determine if the current mesh is ready to be rendered
  21224. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21225. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21226. * @returns true if all associated assets are ready (material, textures, shaders)
  21227. */
  21228. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21229. /**
  21230. * 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.
  21231. */
  21232. readonly areNormalsFrozen: boolean;
  21233. /**
  21234. * 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.
  21235. * @returns the current mesh
  21236. */
  21237. freezeNormals(): Mesh;
  21238. /**
  21239. * 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
  21240. * @returns the current mesh
  21241. */
  21242. unfreezeNormals(): Mesh;
  21243. /**
  21244. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21245. */
  21246. overridenInstanceCount: number;
  21247. /** @hidden */
  21248. _preActivate(): Mesh;
  21249. /** @hidden */
  21250. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21251. /** @hidden */
  21252. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21253. /**
  21254. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21255. * This means the mesh underlying bounding box and sphere are recomputed.
  21256. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21257. * @returns the current mesh
  21258. */
  21259. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21260. /** @hidden */
  21261. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21262. /**
  21263. * This function will subdivide the mesh into multiple submeshes
  21264. * @param count defines the expected number of submeshes
  21265. */
  21266. subdivide(count: number): void;
  21267. /**
  21268. * Copy a FloatArray into a specific associated vertex buffer
  21269. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21270. * - VertexBuffer.PositionKind
  21271. * - VertexBuffer.UVKind
  21272. * - VertexBuffer.UV2Kind
  21273. * - VertexBuffer.UV3Kind
  21274. * - VertexBuffer.UV4Kind
  21275. * - VertexBuffer.UV5Kind
  21276. * - VertexBuffer.UV6Kind
  21277. * - VertexBuffer.ColorKind
  21278. * - VertexBuffer.MatricesIndicesKind
  21279. * - VertexBuffer.MatricesIndicesExtraKind
  21280. * - VertexBuffer.MatricesWeightsKind
  21281. * - VertexBuffer.MatricesWeightsExtraKind
  21282. * @param data defines the data source
  21283. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21284. * @param stride defines the data stride size (can be null)
  21285. * @returns the current mesh
  21286. */
  21287. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21288. /**
  21289. * Flags an associated vertex buffer as updatable
  21290. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21291. * - VertexBuffer.PositionKind
  21292. * - VertexBuffer.UVKind
  21293. * - VertexBuffer.UV2Kind
  21294. * - VertexBuffer.UV3Kind
  21295. * - VertexBuffer.UV4Kind
  21296. * - VertexBuffer.UV5Kind
  21297. * - VertexBuffer.UV6Kind
  21298. * - VertexBuffer.ColorKind
  21299. * - VertexBuffer.MatricesIndicesKind
  21300. * - VertexBuffer.MatricesIndicesExtraKind
  21301. * - VertexBuffer.MatricesWeightsKind
  21302. * - VertexBuffer.MatricesWeightsExtraKind
  21303. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21304. */
  21305. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21306. /**
  21307. * Sets the mesh global Vertex Buffer
  21308. * @param buffer defines the buffer to use
  21309. * @returns the current mesh
  21310. */
  21311. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21312. /**
  21313. * Update a specific associated vertex buffer
  21314. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21315. * - VertexBuffer.PositionKind
  21316. * - VertexBuffer.UVKind
  21317. * - VertexBuffer.UV2Kind
  21318. * - VertexBuffer.UV3Kind
  21319. * - VertexBuffer.UV4Kind
  21320. * - VertexBuffer.UV5Kind
  21321. * - VertexBuffer.UV6Kind
  21322. * - VertexBuffer.ColorKind
  21323. * - VertexBuffer.MatricesIndicesKind
  21324. * - VertexBuffer.MatricesIndicesExtraKind
  21325. * - VertexBuffer.MatricesWeightsKind
  21326. * - VertexBuffer.MatricesWeightsExtraKind
  21327. * @param data defines the data source
  21328. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21329. * @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)
  21330. * @returns the current mesh
  21331. */
  21332. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21333. /**
  21334. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21335. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21336. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21337. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21338. * @returns the current mesh
  21339. */
  21340. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21341. /**
  21342. * Creates a un-shared specific occurence of the geometry for the mesh.
  21343. * @returns the current mesh
  21344. */
  21345. makeGeometryUnique(): Mesh;
  21346. /**
  21347. * Set the index buffer of this mesh
  21348. * @param indices defines the source data
  21349. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21350. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21351. * @returns the current mesh
  21352. */
  21353. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21354. /**
  21355. * Update the current index buffer
  21356. * @param indices defines the source data
  21357. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21358. * @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)
  21359. * @returns the current mesh
  21360. */
  21361. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21362. /**
  21363. * Invert the geometry to move from a right handed system to a left handed one.
  21364. * @returns the current mesh
  21365. */
  21366. toLeftHanded(): Mesh;
  21367. /** @hidden */
  21368. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21369. /** @hidden */
  21370. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21371. /**
  21372. * Registers for this mesh a javascript function called just before the rendering process
  21373. * @param func defines the function to call before rendering this mesh
  21374. * @returns the current mesh
  21375. */
  21376. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21377. /**
  21378. * Disposes a previously registered javascript function called before the rendering
  21379. * @param func defines the function to remove
  21380. * @returns the current mesh
  21381. */
  21382. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21383. /**
  21384. * Registers for this mesh a javascript function called just after the rendering is complete
  21385. * @param func defines the function to call after rendering this mesh
  21386. * @returns the current mesh
  21387. */
  21388. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21389. /**
  21390. * Disposes a previously registered javascript function called after the rendering.
  21391. * @param func defines the function to remove
  21392. * @returns the current mesh
  21393. */
  21394. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21395. /** @hidden */
  21396. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21397. /** @hidden */
  21398. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21399. /** @hidden */
  21400. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21401. /** @hidden */
  21402. _freeze(): void;
  21403. /** @hidden */
  21404. _unFreeze(): void;
  21405. /**
  21406. * 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
  21407. * @param subMesh defines the subMesh to render
  21408. * @param enableAlphaMode defines if alpha mode can be changed
  21409. * @returns the current mesh
  21410. */
  21411. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21412. private _onBeforeDraw;
  21413. /**
  21414. * Renormalize the mesh and patch it up if there are no weights
  21415. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21416. * However in the case of zero weights then we set just a single influence to 1.
  21417. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21418. */
  21419. cleanMatrixWeights(): void;
  21420. private normalizeSkinFourWeights;
  21421. private normalizeSkinWeightsAndExtra;
  21422. /**
  21423. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21424. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21425. * the user know there was an issue with importing the mesh
  21426. * @returns a validation object with skinned, valid and report string
  21427. */
  21428. validateSkinning(): {
  21429. skinned: boolean;
  21430. valid: boolean;
  21431. report: string;
  21432. };
  21433. /** @hidden */
  21434. _checkDelayState(): Mesh;
  21435. private _queueLoad;
  21436. /**
  21437. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21438. * A mesh is in the frustum if its bounding box intersects the frustum
  21439. * @param frustumPlanes defines the frustum to test
  21440. * @returns true if the mesh is in the frustum planes
  21441. */
  21442. isInFrustum(frustumPlanes: Plane[]): boolean;
  21443. /**
  21444. * Sets the mesh material by the material or multiMaterial `id` property
  21445. * @param id is a string identifying the material or the multiMaterial
  21446. * @returns the current mesh
  21447. */
  21448. setMaterialByID(id: string): Mesh;
  21449. /**
  21450. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21451. * @returns an array of IAnimatable
  21452. */
  21453. getAnimatables(): IAnimatable[];
  21454. /**
  21455. * Modifies the mesh geometry according to the passed transformation matrix.
  21456. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21457. * The mesh normals are modified using the same transformation.
  21458. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21459. * @param transform defines the transform matrix to use
  21460. * @see http://doc.babylonjs.com/resources/baking_transformations
  21461. * @returns the current mesh
  21462. */
  21463. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21464. /**
  21465. * Modifies the mesh geometry according to its own current World Matrix.
  21466. * The mesh World Matrix is then reset.
  21467. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21468. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21469. * @see http://doc.babylonjs.com/resources/baking_transformations
  21470. * @returns the current mesh
  21471. */
  21472. bakeCurrentTransformIntoVertices(): Mesh;
  21473. /** @hidden */
  21474. readonly _positions: Nullable<Vector3[]>;
  21475. /** @hidden */
  21476. _resetPointsArrayCache(): Mesh;
  21477. /** @hidden */
  21478. _generatePointsArray(): boolean;
  21479. /**
  21480. * Returns a new Mesh object generated from the current mesh properties.
  21481. * This method must not get confused with createInstance()
  21482. * @param name is a string, the name given to the new mesh
  21483. * @param newParent can be any Node object (default `null`)
  21484. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21485. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21486. * @returns a new mesh
  21487. */
  21488. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21489. /**
  21490. * Releases resources associated with this mesh.
  21491. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21492. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21493. */
  21494. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21495. /**
  21496. * Modifies the mesh geometry according to a displacement map.
  21497. * 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.
  21498. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21499. * @param url is a string, the URL from the image file is to be downloaded.
  21500. * @param minHeight is the lower limit of the displacement.
  21501. * @param maxHeight is the upper limit of the displacement.
  21502. * @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.
  21503. * @param uvOffset is an optional vector2 used to offset UV.
  21504. * @param uvScale is an optional vector2 used to scale UV.
  21505. * @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.
  21506. * @returns the Mesh.
  21507. */
  21508. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21509. /**
  21510. * Modifies the mesh geometry according to a displacementMap buffer.
  21511. * 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.
  21512. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21513. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21514. * @param heightMapWidth is the width of the buffer image.
  21515. * @param heightMapHeight is the height of the buffer image.
  21516. * @param minHeight is the lower limit of the displacement.
  21517. * @param maxHeight is the upper limit of the displacement.
  21518. * @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.
  21519. * @param uvOffset is an optional vector2 used to offset UV.
  21520. * @param uvScale is an optional vector2 used to scale UV.
  21521. * @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.
  21522. * @returns the Mesh.
  21523. */
  21524. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21525. /**
  21526. * Modify the mesh to get a flat shading rendering.
  21527. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21528. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21529. * @returns current mesh
  21530. */
  21531. convertToFlatShadedMesh(): Mesh;
  21532. /**
  21533. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21534. * In other words, more vertices, no more indices and a single bigger VBO.
  21535. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21536. * @returns current mesh
  21537. */
  21538. convertToUnIndexedMesh(): Mesh;
  21539. /**
  21540. * Inverses facet orientations.
  21541. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21542. * @param flipNormals will also inverts the normals
  21543. * @returns current mesh
  21544. */
  21545. flipFaces(flipNormals?: boolean): Mesh;
  21546. /**
  21547. * Increase the number of facets and hence vertices in a mesh
  21548. * Vertex normals are interpolated from existing vertex normals
  21549. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21550. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21551. */
  21552. increaseVertices(numberPerEdge: number): void;
  21553. /**
  21554. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21555. * This will undo any application of covertToFlatShadedMesh
  21556. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21557. */
  21558. forceSharedVertices(): void;
  21559. /** @hidden */
  21560. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21561. /** @hidden */
  21562. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21563. /**
  21564. * Creates a new InstancedMesh object from the mesh model.
  21565. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21566. * @param name defines the name of the new instance
  21567. * @returns a new InstancedMesh
  21568. */
  21569. createInstance(name: string): InstancedMesh;
  21570. /**
  21571. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21572. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21573. * @returns the current mesh
  21574. */
  21575. synchronizeInstances(): Mesh;
  21576. /**
  21577. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21578. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21579. * This should be used together with the simplification to avoid disappearing triangles.
  21580. * @param successCallback an optional success callback to be called after the optimization finished.
  21581. * @returns the current mesh
  21582. */
  21583. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21584. /**
  21585. * Serialize current mesh
  21586. * @param serializationObject defines the object which will receive the serialization data
  21587. */
  21588. serialize(serializationObject: any): void;
  21589. /** @hidden */
  21590. _syncGeometryWithMorphTargetManager(): void;
  21591. /** @hidden */
  21592. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21593. /**
  21594. * Returns a new Mesh object parsed from the source provided.
  21595. * @param parsedMesh is the source
  21596. * @param scene defines the hosting scene
  21597. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21598. * @returns a new Mesh
  21599. */
  21600. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21601. /**
  21602. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21603. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21604. * @param name defines the name of the mesh to create
  21605. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21606. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21607. * @param closePath creates a seam between the first and the last points of each path of the path array
  21608. * @param offset is taken in account only if the `pathArray` is containing a single path
  21609. * @param scene defines the hosting scene
  21610. * @param updatable defines if the mesh must be flagged as updatable
  21611. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21612. * @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)
  21613. * @returns a new Mesh
  21614. */
  21615. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21616. /**
  21617. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21618. * @param name defines the name of the mesh to create
  21619. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21620. * @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
  21621. * @param scene defines the hosting scene
  21622. * @param updatable defines if the mesh must be flagged as updatable
  21623. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21624. * @returns a new Mesh
  21625. */
  21626. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21627. /**
  21628. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21629. * @param name defines the name of the mesh to create
  21630. * @param size sets the size (float) of each box side (default 1)
  21631. * @param scene defines the hosting scene
  21632. * @param updatable defines if the mesh must be flagged as updatable
  21633. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21634. * @returns a new Mesh
  21635. */
  21636. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21637. /**
  21638. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21639. * @param name defines the name of the mesh to create
  21640. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21641. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21642. * @param scene defines the hosting scene
  21643. * @param updatable defines if the mesh must be flagged as updatable
  21644. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21645. * @returns a new Mesh
  21646. */
  21647. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21648. /**
  21649. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21650. * @param name defines the name of the mesh to create
  21651. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21652. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21653. * @param scene defines the hosting scene
  21654. * @returns a new Mesh
  21655. */
  21656. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21657. /**
  21658. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21659. * @param name defines the name of the mesh to create
  21660. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21661. * @param diameterTop set the top cap diameter (floats, default 1)
  21662. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21663. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21664. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21665. * @param scene defines the hosting scene
  21666. * @param updatable defines if the mesh must be flagged as updatable
  21667. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21668. * @returns a new Mesh
  21669. */
  21670. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21671. /**
  21672. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21673. * @param name defines the name of the mesh to create
  21674. * @param diameter sets the diameter size (float) of the torus (default 1)
  21675. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21676. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21677. * @param scene defines the hosting scene
  21678. * @param updatable defines if the mesh must be flagged as updatable
  21679. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21680. * @returns a new Mesh
  21681. */
  21682. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21683. /**
  21684. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21685. * @param name defines the name of the mesh to create
  21686. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21687. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21688. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21689. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21690. * @param p the number of windings on X axis (positive integers, default 2)
  21691. * @param q the number of windings on Y axis (positive integers, default 3)
  21692. * @param scene defines the hosting scene
  21693. * @param updatable defines if the mesh must be flagged as updatable
  21694. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21695. * @returns a new Mesh
  21696. */
  21697. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21698. /**
  21699. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21700. * @param name defines the name of the mesh to create
  21701. * @param points is an array successive Vector3
  21702. * @param scene defines the hosting scene
  21703. * @param updatable defines if the mesh must be flagged as updatable
  21704. * @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).
  21705. * @returns a new Mesh
  21706. */
  21707. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21708. /**
  21709. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21710. * @param name defines the name of the mesh to create
  21711. * @param points is an array successive Vector3
  21712. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21713. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21714. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21715. * @param scene defines the hosting scene
  21716. * @param updatable defines if the mesh must be flagged as updatable
  21717. * @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)
  21718. * @returns a new Mesh
  21719. */
  21720. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21721. /**
  21722. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21723. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21724. * 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.
  21725. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21726. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21727. * Remember you can only change the shape positions, not their number when updating a polygon.
  21728. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21729. * @param name defines the name of the mesh to create
  21730. * @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
  21731. * @param scene defines the hosting scene
  21732. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21733. * @param updatable defines if the mesh must be flagged as updatable
  21734. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21735. * @param earcutInjection can be used to inject your own earcut reference
  21736. * @returns a new Mesh
  21737. */
  21738. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21739. /**
  21740. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21741. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21742. * @param name defines the name of the mesh to create
  21743. * @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
  21744. * @param depth defines the height of extrusion
  21745. * @param scene defines the hosting scene
  21746. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21747. * @param updatable defines if the mesh must be flagged as updatable
  21748. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21749. * @param earcutInjection can be used to inject your own earcut reference
  21750. * @returns a new Mesh
  21751. */
  21752. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21753. /**
  21754. * Creates an extruded shape mesh.
  21755. * 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
  21756. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21757. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21758. * @param name defines the name of the mesh to create
  21759. * @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
  21760. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21761. * @param scale is the value to scale the shape
  21762. * @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
  21763. * @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
  21764. * @param scene defines the hosting scene
  21765. * @param updatable defines if the mesh must be flagged as updatable
  21766. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21767. * @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)
  21768. * @returns a new Mesh
  21769. */
  21770. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21771. /**
  21772. * Creates an custom extruded shape mesh.
  21773. * The custom extrusion is a parametric shape.
  21774. * It has no predefined shape. Its final shape will depend on the input parameters.
  21775. * Please consider using the same method from the MeshBuilder class instead
  21776. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21777. * @param name defines the name of the mesh to create
  21778. * @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
  21779. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21780. * @param scaleFunction is a custom Javascript function called on each path point
  21781. * @param rotationFunction is a custom Javascript function called on each path point
  21782. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21783. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21784. * @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
  21785. * @param scene defines the hosting scene
  21786. * @param updatable defines if the mesh must be flagged as updatable
  21787. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21788. * @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)
  21789. * @returns a new Mesh
  21790. */
  21791. 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;
  21792. /**
  21793. * Creates lathe mesh.
  21794. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21795. * Please consider using the same method from the MeshBuilder class instead
  21796. * @param name defines the name of the mesh to create
  21797. * @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
  21798. * @param radius is the radius value of the lathe
  21799. * @param tessellation is the side number of the lathe.
  21800. * @param scene defines the hosting scene
  21801. * @param updatable defines if the mesh must be flagged as updatable
  21802. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21803. * @returns a new Mesh
  21804. */
  21805. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21806. /**
  21807. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21808. * @param name defines the name of the mesh to create
  21809. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21810. * @param scene defines the hosting scene
  21811. * @param updatable defines if the mesh must be flagged as updatable
  21812. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21813. * @returns a new Mesh
  21814. */
  21815. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21816. /**
  21817. * Creates a ground mesh.
  21818. * Please consider using the same method from the MeshBuilder class instead
  21819. * @param name defines the name of the mesh to create
  21820. * @param width set the width of the ground
  21821. * @param height set the height of the ground
  21822. * @param subdivisions sets the number of subdivisions per side
  21823. * @param scene defines the hosting scene
  21824. * @param updatable defines if the mesh must be flagged as updatable
  21825. * @returns a new Mesh
  21826. */
  21827. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21828. /**
  21829. * Creates a tiled ground mesh.
  21830. * Please consider using the same method from the MeshBuilder class instead
  21831. * @param name defines the name of the mesh to create
  21832. * @param xmin set the ground minimum X coordinate
  21833. * @param zmin set the ground minimum Y coordinate
  21834. * @param xmax set the ground maximum X coordinate
  21835. * @param zmax set the ground maximum Z coordinate
  21836. * @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
  21837. * @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
  21838. * @param scene defines the hosting scene
  21839. * @param updatable defines if the mesh must be flagged as updatable
  21840. * @returns a new Mesh
  21841. */
  21842. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21843. w: number;
  21844. h: number;
  21845. }, precision: {
  21846. w: number;
  21847. h: number;
  21848. }, scene: Scene, updatable?: boolean): Mesh;
  21849. /**
  21850. * Creates a ground mesh from a height map.
  21851. * Please consider using the same method from the MeshBuilder class instead
  21852. * @see http://doc.babylonjs.com/babylon101/height_map
  21853. * @param name defines the name of the mesh to create
  21854. * @param url sets the URL of the height map image resource
  21855. * @param width set the ground width size
  21856. * @param height set the ground height size
  21857. * @param subdivisions sets the number of subdivision per side
  21858. * @param minHeight is the minimum altitude on the ground
  21859. * @param maxHeight is the maximum altitude on the ground
  21860. * @param scene defines the hosting scene
  21861. * @param updatable defines if the mesh must be flagged as updatable
  21862. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21863. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21864. * @returns a new Mesh
  21865. */
  21866. 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;
  21867. /**
  21868. * Creates a tube mesh.
  21869. * The tube is a parametric shape.
  21870. * It has no predefined shape. Its final shape will depend on the input parameters.
  21871. * Please consider using the same method from the MeshBuilder class instead
  21872. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21873. * @param name defines the name of the mesh to create
  21874. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21875. * @param radius sets the tube radius size
  21876. * @param tessellation is the number of sides on the tubular surface
  21877. * @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
  21878. * @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
  21879. * @param scene defines the hosting scene
  21880. * @param updatable defines if the mesh must be flagged as updatable
  21881. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21882. * @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)
  21883. * @returns a new Mesh
  21884. */
  21885. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21886. (i: number, distance: number): number;
  21887. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21888. /**
  21889. * Creates a polyhedron mesh.
  21890. * Please consider using the same method from the MeshBuilder class instead.
  21891. * * 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
  21892. * * The parameter `size` (positive float, default 1) sets the polygon size
  21893. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21894. * * 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`
  21895. * * 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
  21896. * * 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)`)
  21897. * * 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
  21898. * * 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
  21899. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21900. * * 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
  21901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21902. * @param name defines the name of the mesh to create
  21903. * @param options defines the options used to create the mesh
  21904. * @param scene defines the hosting scene
  21905. * @returns a new Mesh
  21906. */
  21907. static CreatePolyhedron(name: string, options: {
  21908. type?: number;
  21909. size?: number;
  21910. sizeX?: number;
  21911. sizeY?: number;
  21912. sizeZ?: number;
  21913. custom?: any;
  21914. faceUV?: Vector4[];
  21915. faceColors?: Color4[];
  21916. updatable?: boolean;
  21917. sideOrientation?: number;
  21918. }, scene: Scene): Mesh;
  21919. /**
  21920. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21921. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21922. * * 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`)
  21923. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21924. * * 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
  21925. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21926. * * 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
  21927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21928. * @param name defines the name of the mesh
  21929. * @param options defines the options used to create the mesh
  21930. * @param scene defines the hosting scene
  21931. * @returns a new Mesh
  21932. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21933. */
  21934. static CreateIcoSphere(name: string, options: {
  21935. radius?: number;
  21936. flat?: boolean;
  21937. subdivisions?: number;
  21938. sideOrientation?: number;
  21939. updatable?: boolean;
  21940. }, scene: Scene): Mesh;
  21941. /**
  21942. * Creates a decal mesh.
  21943. * Please consider using the same method from the MeshBuilder class instead.
  21944. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21945. * @param name defines the name of the mesh
  21946. * @param sourceMesh defines the mesh receiving the decal
  21947. * @param position sets the position of the decal in world coordinates
  21948. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21949. * @param size sets the decal scaling
  21950. * @param angle sets the angle to rotate the decal
  21951. * @returns a new Mesh
  21952. */
  21953. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21954. /**
  21955. * Prepare internal position array for software CPU skinning
  21956. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21957. */
  21958. setPositionsForCPUSkinning(): Float32Array;
  21959. /**
  21960. * Prepare internal normal array for software CPU skinning
  21961. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21962. */
  21963. setNormalsForCPUSkinning(): Float32Array;
  21964. /**
  21965. * Updates the vertex buffer by applying transformation from the bones
  21966. * @param skeleton defines the skeleton to apply to current mesh
  21967. * @returns the current mesh
  21968. */
  21969. applySkeleton(skeleton: Skeleton): Mesh;
  21970. /**
  21971. * 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
  21972. * @param meshes defines the list of meshes to scan
  21973. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21974. */
  21975. static MinMax(meshes: AbstractMesh[]): {
  21976. min: Vector3;
  21977. max: Vector3;
  21978. };
  21979. /**
  21980. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21981. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21982. * @returns a vector3
  21983. */
  21984. static Center(meshesOrMinMaxVector: {
  21985. min: Vector3;
  21986. max: Vector3;
  21987. } | AbstractMesh[]): Vector3;
  21988. /**
  21989. * Merge the array of meshes into a single mesh for performance reasons.
  21990. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21991. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21992. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21993. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21994. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21995. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21996. * @returns a new mesh
  21997. */
  21998. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21999. /** @hidden */
  22000. addInstance(instance: InstancedMesh): void;
  22001. /** @hidden */
  22002. removeInstance(instance: InstancedMesh): void;
  22003. }
  22004. }
  22005. declare module BABYLON {
  22006. /**
  22007. * Base class for the main features of a material in Babylon.js
  22008. */
  22009. export class Material implements IAnimatable {
  22010. /**
  22011. * Returns the triangle fill mode
  22012. */
  22013. static readonly TriangleFillMode: number;
  22014. /**
  22015. * Returns the wireframe mode
  22016. */
  22017. static readonly WireFrameFillMode: number;
  22018. /**
  22019. * Returns the point fill mode
  22020. */
  22021. static readonly PointFillMode: number;
  22022. /**
  22023. * Returns the point list draw mode
  22024. */
  22025. static readonly PointListDrawMode: number;
  22026. /**
  22027. * Returns the line list draw mode
  22028. */
  22029. static readonly LineListDrawMode: number;
  22030. /**
  22031. * Returns the line loop draw mode
  22032. */
  22033. static readonly LineLoopDrawMode: number;
  22034. /**
  22035. * Returns the line strip draw mode
  22036. */
  22037. static readonly LineStripDrawMode: number;
  22038. /**
  22039. * Returns the triangle strip draw mode
  22040. */
  22041. static readonly TriangleStripDrawMode: number;
  22042. /**
  22043. * Returns the triangle fan draw mode
  22044. */
  22045. static readonly TriangleFanDrawMode: number;
  22046. /**
  22047. * Stores the clock-wise side orientation
  22048. */
  22049. static readonly ClockWiseSideOrientation: number;
  22050. /**
  22051. * Stores the counter clock-wise side orientation
  22052. */
  22053. static readonly CounterClockWiseSideOrientation: number;
  22054. /**
  22055. * The dirty texture flag value
  22056. */
  22057. static readonly TextureDirtyFlag: number;
  22058. /**
  22059. * The dirty light flag value
  22060. */
  22061. static readonly LightDirtyFlag: number;
  22062. /**
  22063. * The dirty fresnel flag value
  22064. */
  22065. static readonly FresnelDirtyFlag: number;
  22066. /**
  22067. * The dirty attribute flag value
  22068. */
  22069. static readonly AttributesDirtyFlag: number;
  22070. /**
  22071. * The dirty misc flag value
  22072. */
  22073. static readonly MiscDirtyFlag: number;
  22074. /**
  22075. * The all dirty flag value
  22076. */
  22077. static readonly AllDirtyFlag: number;
  22078. /**
  22079. * The ID of the material
  22080. */
  22081. id: string;
  22082. /**
  22083. * Gets or sets the unique id of the material
  22084. */
  22085. uniqueId: number;
  22086. /**
  22087. * The name of the material
  22088. */
  22089. name: string;
  22090. /**
  22091. * Gets or sets user defined metadata
  22092. */
  22093. metadata: any;
  22094. /**
  22095. * For internal use only. Please do not use.
  22096. */
  22097. reservedDataStore: any;
  22098. /**
  22099. * Specifies if the ready state should be checked on each call
  22100. */
  22101. checkReadyOnEveryCall: boolean;
  22102. /**
  22103. * Specifies if the ready state should be checked once
  22104. */
  22105. checkReadyOnlyOnce: boolean;
  22106. /**
  22107. * The state of the material
  22108. */
  22109. state: string;
  22110. /**
  22111. * The alpha value of the material
  22112. */
  22113. protected _alpha: number;
  22114. /**
  22115. * List of inspectable custom properties (used by the Inspector)
  22116. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22117. */
  22118. inspectableCustomProperties: IInspectable[];
  22119. /**
  22120. * Sets the alpha value of the material
  22121. */
  22122. /**
  22123. * Gets the alpha value of the material
  22124. */
  22125. alpha: number;
  22126. /**
  22127. * Specifies if back face culling is enabled
  22128. */
  22129. protected _backFaceCulling: boolean;
  22130. /**
  22131. * Sets the back-face culling state
  22132. */
  22133. /**
  22134. * Gets the back-face culling state
  22135. */
  22136. backFaceCulling: boolean;
  22137. /**
  22138. * Stores the value for side orientation
  22139. */
  22140. sideOrientation: number;
  22141. /**
  22142. * Callback triggered when the material is compiled
  22143. */
  22144. onCompiled: Nullable<(effect: Effect) => void>;
  22145. /**
  22146. * Callback triggered when an error occurs
  22147. */
  22148. onError: Nullable<(effect: Effect, errors: string) => void>;
  22149. /**
  22150. * Callback triggered to get the render target textures
  22151. */
  22152. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22153. /**
  22154. * Gets a boolean indicating that current material needs to register RTT
  22155. */
  22156. readonly hasRenderTargetTextures: boolean;
  22157. /**
  22158. * Specifies if the material should be serialized
  22159. */
  22160. doNotSerialize: boolean;
  22161. /**
  22162. * @hidden
  22163. */
  22164. _storeEffectOnSubMeshes: boolean;
  22165. /**
  22166. * Stores the animations for the material
  22167. */
  22168. animations: Nullable<Array<Animation>>;
  22169. /**
  22170. * An event triggered when the material is disposed
  22171. */
  22172. onDisposeObservable: Observable<Material>;
  22173. /**
  22174. * An observer which watches for dispose events
  22175. */
  22176. private _onDisposeObserver;
  22177. private _onUnBindObservable;
  22178. /**
  22179. * Called during a dispose event
  22180. */
  22181. onDispose: () => void;
  22182. private _onBindObservable;
  22183. /**
  22184. * An event triggered when the material is bound
  22185. */
  22186. readonly onBindObservable: Observable<AbstractMesh>;
  22187. /**
  22188. * An observer which watches for bind events
  22189. */
  22190. private _onBindObserver;
  22191. /**
  22192. * Called during a bind event
  22193. */
  22194. onBind: (Mesh: AbstractMesh) => void;
  22195. /**
  22196. * An event triggered when the material is unbound
  22197. */
  22198. readonly onUnBindObservable: Observable<Material>;
  22199. /**
  22200. * Stores the value of the alpha mode
  22201. */
  22202. private _alphaMode;
  22203. /**
  22204. * Sets the value of the alpha mode.
  22205. *
  22206. * | Value | Type | Description |
  22207. * | --- | --- | --- |
  22208. * | 0 | ALPHA_DISABLE | |
  22209. * | 1 | ALPHA_ADD | |
  22210. * | 2 | ALPHA_COMBINE | |
  22211. * | 3 | ALPHA_SUBTRACT | |
  22212. * | 4 | ALPHA_MULTIPLY | |
  22213. * | 5 | ALPHA_MAXIMIZED | |
  22214. * | 6 | ALPHA_ONEONE | |
  22215. * | 7 | ALPHA_PREMULTIPLIED | |
  22216. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22217. * | 9 | ALPHA_INTERPOLATE | |
  22218. * | 10 | ALPHA_SCREENMODE | |
  22219. *
  22220. */
  22221. /**
  22222. * Gets the value of the alpha mode
  22223. */
  22224. alphaMode: number;
  22225. /**
  22226. * Stores the state of the need depth pre-pass value
  22227. */
  22228. private _needDepthPrePass;
  22229. /**
  22230. * Sets the need depth pre-pass value
  22231. */
  22232. /**
  22233. * Gets the depth pre-pass value
  22234. */
  22235. needDepthPrePass: boolean;
  22236. /**
  22237. * Specifies if depth writing should be disabled
  22238. */
  22239. disableDepthWrite: boolean;
  22240. /**
  22241. * Specifies if depth writing should be forced
  22242. */
  22243. forceDepthWrite: boolean;
  22244. /**
  22245. * Specifies if there should be a separate pass for culling
  22246. */
  22247. separateCullingPass: boolean;
  22248. /**
  22249. * Stores the state specifing if fog should be enabled
  22250. */
  22251. private _fogEnabled;
  22252. /**
  22253. * Sets the state for enabling fog
  22254. */
  22255. /**
  22256. * Gets the value of the fog enabled state
  22257. */
  22258. fogEnabled: boolean;
  22259. /**
  22260. * Stores the size of points
  22261. */
  22262. pointSize: number;
  22263. /**
  22264. * Stores the z offset value
  22265. */
  22266. zOffset: number;
  22267. /**
  22268. * Gets a value specifying if wireframe mode is enabled
  22269. */
  22270. /**
  22271. * Sets the state of wireframe mode
  22272. */
  22273. wireframe: boolean;
  22274. /**
  22275. * Gets the value specifying if point clouds are enabled
  22276. */
  22277. /**
  22278. * Sets the state of point cloud mode
  22279. */
  22280. pointsCloud: boolean;
  22281. /**
  22282. * Gets the material fill mode
  22283. */
  22284. /**
  22285. * Sets the material fill mode
  22286. */
  22287. fillMode: number;
  22288. /**
  22289. * @hidden
  22290. * Stores the effects for the material
  22291. */
  22292. _effect: Nullable<Effect>;
  22293. /**
  22294. * @hidden
  22295. * Specifies if the material was previously ready
  22296. */
  22297. _wasPreviouslyReady: boolean;
  22298. /**
  22299. * Specifies if uniform buffers should be used
  22300. */
  22301. private _useUBO;
  22302. /**
  22303. * Stores a reference to the scene
  22304. */
  22305. private _scene;
  22306. /**
  22307. * Stores the fill mode state
  22308. */
  22309. private _fillMode;
  22310. /**
  22311. * Specifies if the depth write state should be cached
  22312. */
  22313. private _cachedDepthWriteState;
  22314. /**
  22315. * Stores the uniform buffer
  22316. */
  22317. protected _uniformBuffer: UniformBuffer;
  22318. /** @hidden */
  22319. _indexInSceneMaterialArray: number;
  22320. /** @hidden */
  22321. meshMap: Nullable<{
  22322. [id: string]: AbstractMesh | undefined;
  22323. }>;
  22324. /**
  22325. * Creates a material instance
  22326. * @param name defines the name of the material
  22327. * @param scene defines the scene to reference
  22328. * @param doNotAdd specifies if the material should be added to the scene
  22329. */
  22330. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22331. /**
  22332. * Returns a string representation of the current material
  22333. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22334. * @returns a string with material information
  22335. */
  22336. toString(fullDetails?: boolean): string;
  22337. /**
  22338. * Gets the class name of the material
  22339. * @returns a string with the class name of the material
  22340. */
  22341. getClassName(): string;
  22342. /**
  22343. * Specifies if updates for the material been locked
  22344. */
  22345. readonly isFrozen: boolean;
  22346. /**
  22347. * Locks updates for the material
  22348. */
  22349. freeze(): void;
  22350. /**
  22351. * Unlocks updates for the material
  22352. */
  22353. unfreeze(): void;
  22354. /**
  22355. * Specifies if the material is ready to be used
  22356. * @param mesh defines the mesh to check
  22357. * @param useInstances specifies if instances should be used
  22358. * @returns a boolean indicating if the material is ready to be used
  22359. */
  22360. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22361. /**
  22362. * Specifies that the submesh is ready to be used
  22363. * @param mesh defines the mesh to check
  22364. * @param subMesh defines which submesh to check
  22365. * @param useInstances specifies that instances should be used
  22366. * @returns a boolean indicating that the submesh is ready or not
  22367. */
  22368. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22369. /**
  22370. * Returns the material effect
  22371. * @returns the effect associated with the material
  22372. */
  22373. getEffect(): Nullable<Effect>;
  22374. /**
  22375. * Returns the current scene
  22376. * @returns a Scene
  22377. */
  22378. getScene(): Scene;
  22379. /**
  22380. * Specifies if the material will require alpha blending
  22381. * @returns a boolean specifying if alpha blending is needed
  22382. */
  22383. needAlphaBlending(): boolean;
  22384. /**
  22385. * Specifies if the mesh will require alpha blending
  22386. * @param mesh defines the mesh to check
  22387. * @returns a boolean specifying if alpha blending is needed for the mesh
  22388. */
  22389. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22390. /**
  22391. * Specifies if this material should be rendered in alpha test mode
  22392. * @returns a boolean specifying if an alpha test is needed.
  22393. */
  22394. needAlphaTesting(): boolean;
  22395. /**
  22396. * Gets the texture used for the alpha test
  22397. * @returns the texture to use for alpha testing
  22398. */
  22399. getAlphaTestTexture(): Nullable<BaseTexture>;
  22400. /**
  22401. * Marks the material to indicate that it needs to be re-calculated
  22402. */
  22403. markDirty(): void;
  22404. /** @hidden */
  22405. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22406. /**
  22407. * Binds the material to the mesh
  22408. * @param world defines the world transformation matrix
  22409. * @param mesh defines the mesh to bind the material to
  22410. */
  22411. bind(world: Matrix, mesh?: Mesh): void;
  22412. /**
  22413. * Binds the submesh to the material
  22414. * @param world defines the world transformation matrix
  22415. * @param mesh defines the mesh containing the submesh
  22416. * @param subMesh defines the submesh to bind the material to
  22417. */
  22418. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22419. /**
  22420. * Binds the world matrix to the material
  22421. * @param world defines the world transformation matrix
  22422. */
  22423. bindOnlyWorldMatrix(world: Matrix): void;
  22424. /**
  22425. * Binds the scene's uniform buffer to the effect.
  22426. * @param effect defines the effect to bind to the scene uniform buffer
  22427. * @param sceneUbo defines the uniform buffer storing scene data
  22428. */
  22429. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22430. /**
  22431. * Binds the view matrix to the effect
  22432. * @param effect defines the effect to bind the view matrix to
  22433. */
  22434. bindView(effect: Effect): void;
  22435. /**
  22436. * Binds the view projection matrix to the effect
  22437. * @param effect defines the effect to bind the view projection matrix to
  22438. */
  22439. bindViewProjection(effect: Effect): void;
  22440. /**
  22441. * Specifies if material alpha testing should be turned on for the mesh
  22442. * @param mesh defines the mesh to check
  22443. */
  22444. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22445. /**
  22446. * Processes to execute after binding the material to a mesh
  22447. * @param mesh defines the rendered mesh
  22448. */
  22449. protected _afterBind(mesh?: Mesh): void;
  22450. /**
  22451. * Unbinds the material from the mesh
  22452. */
  22453. unbind(): void;
  22454. /**
  22455. * Gets the active textures from the material
  22456. * @returns an array of textures
  22457. */
  22458. getActiveTextures(): BaseTexture[];
  22459. /**
  22460. * Specifies if the material uses a texture
  22461. * @param texture defines the texture to check against the material
  22462. * @returns a boolean specifying if the material uses the texture
  22463. */
  22464. hasTexture(texture: BaseTexture): boolean;
  22465. /**
  22466. * Makes a duplicate of the material, and gives it a new name
  22467. * @param name defines the new name for the duplicated material
  22468. * @returns the cloned material
  22469. */
  22470. clone(name: string): Nullable<Material>;
  22471. /**
  22472. * Gets the meshes bound to the material
  22473. * @returns an array of meshes bound to the material
  22474. */
  22475. getBindedMeshes(): AbstractMesh[];
  22476. /**
  22477. * Force shader compilation
  22478. * @param mesh defines the mesh associated with this material
  22479. * @param onCompiled defines a function to execute once the material is compiled
  22480. * @param options defines the options to configure the compilation
  22481. */
  22482. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22483. clipPlane: boolean;
  22484. }>): void;
  22485. /**
  22486. * Force shader compilation
  22487. * @param mesh defines the mesh that will use this material
  22488. * @param options defines additional options for compiling the shaders
  22489. * @returns a promise that resolves when the compilation completes
  22490. */
  22491. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22492. clipPlane: boolean;
  22493. }>): Promise<void>;
  22494. private static readonly _AllDirtyCallBack;
  22495. private static readonly _ImageProcessingDirtyCallBack;
  22496. private static readonly _TextureDirtyCallBack;
  22497. private static readonly _FresnelDirtyCallBack;
  22498. private static readonly _MiscDirtyCallBack;
  22499. private static readonly _LightsDirtyCallBack;
  22500. private static readonly _AttributeDirtyCallBack;
  22501. private static _FresnelAndMiscDirtyCallBack;
  22502. private static _TextureAndMiscDirtyCallBack;
  22503. private static readonly _DirtyCallbackArray;
  22504. private static readonly _RunDirtyCallBacks;
  22505. /**
  22506. * Marks a define in the material to indicate that it needs to be re-computed
  22507. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22508. */
  22509. markAsDirty(flag: number): void;
  22510. /**
  22511. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22512. * @param func defines a function which checks material defines against the submeshes
  22513. */
  22514. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22515. /**
  22516. * Indicates that we need to re-calculated for all submeshes
  22517. */
  22518. protected _markAllSubMeshesAsAllDirty(): void;
  22519. /**
  22520. * Indicates that image processing needs to be re-calculated for all submeshes
  22521. */
  22522. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22523. /**
  22524. * Indicates that textures need to be re-calculated for all submeshes
  22525. */
  22526. protected _markAllSubMeshesAsTexturesDirty(): void;
  22527. /**
  22528. * Indicates that fresnel needs to be re-calculated for all submeshes
  22529. */
  22530. protected _markAllSubMeshesAsFresnelDirty(): void;
  22531. /**
  22532. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22533. */
  22534. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22535. /**
  22536. * Indicates that lights need to be re-calculated for all submeshes
  22537. */
  22538. protected _markAllSubMeshesAsLightsDirty(): void;
  22539. /**
  22540. * Indicates that attributes need to be re-calculated for all submeshes
  22541. */
  22542. protected _markAllSubMeshesAsAttributesDirty(): void;
  22543. /**
  22544. * Indicates that misc needs to be re-calculated for all submeshes
  22545. */
  22546. protected _markAllSubMeshesAsMiscDirty(): void;
  22547. /**
  22548. * Indicates that textures and misc need to be re-calculated for all submeshes
  22549. */
  22550. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22551. /**
  22552. * Disposes the material
  22553. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22554. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22555. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22556. */
  22557. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22558. /** @hidden */
  22559. private releaseVertexArrayObject;
  22560. /**
  22561. * Serializes this material
  22562. * @returns the serialized material object
  22563. */
  22564. serialize(): any;
  22565. /**
  22566. * Creates a material from parsed material data
  22567. * @param parsedMaterial defines parsed material data
  22568. * @param scene defines the hosting scene
  22569. * @param rootUrl defines the root URL to use to load textures
  22570. * @returns a new material
  22571. */
  22572. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22573. }
  22574. }
  22575. declare module BABYLON {
  22576. /**
  22577. * Base class for submeshes
  22578. */
  22579. export class BaseSubMesh {
  22580. /** @hidden */
  22581. _materialDefines: Nullable<MaterialDefines>;
  22582. /** @hidden */
  22583. _materialEffect: Nullable<Effect>;
  22584. /**
  22585. * Gets associated effect
  22586. */
  22587. readonly effect: Nullable<Effect>;
  22588. /**
  22589. * Sets associated effect (effect used to render this submesh)
  22590. * @param effect defines the effect to associate with
  22591. * @param defines defines the set of defines used to compile this effect
  22592. */
  22593. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22594. }
  22595. /**
  22596. * Defines a subdivision inside a mesh
  22597. */
  22598. export class SubMesh extends BaseSubMesh implements ICullable {
  22599. /** the material index to use */
  22600. materialIndex: number;
  22601. /** vertex index start */
  22602. verticesStart: number;
  22603. /** vertices count */
  22604. verticesCount: number;
  22605. /** index start */
  22606. indexStart: number;
  22607. /** indices count */
  22608. indexCount: number;
  22609. /** @hidden */
  22610. _linesIndexCount: number;
  22611. private _mesh;
  22612. private _renderingMesh;
  22613. private _boundingInfo;
  22614. private _linesIndexBuffer;
  22615. /** @hidden */
  22616. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22617. /** @hidden */
  22618. _trianglePlanes: Plane[];
  22619. /** @hidden */
  22620. _lastColliderTransformMatrix: Nullable<Matrix>;
  22621. /** @hidden */
  22622. _renderId: number;
  22623. /** @hidden */
  22624. _alphaIndex: number;
  22625. /** @hidden */
  22626. _distanceToCamera: number;
  22627. /** @hidden */
  22628. _id: number;
  22629. private _currentMaterial;
  22630. /**
  22631. * Add a new submesh to a mesh
  22632. * @param materialIndex defines the material index to use
  22633. * @param verticesStart defines vertex index start
  22634. * @param verticesCount defines vertices count
  22635. * @param indexStart defines index start
  22636. * @param indexCount defines indices count
  22637. * @param mesh defines the parent mesh
  22638. * @param renderingMesh defines an optional rendering mesh
  22639. * @param createBoundingBox defines if bounding box should be created for this submesh
  22640. * @returns the new submesh
  22641. */
  22642. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22643. /**
  22644. * Creates a new submesh
  22645. * @param materialIndex defines the material index to use
  22646. * @param verticesStart defines vertex index start
  22647. * @param verticesCount defines vertices count
  22648. * @param indexStart defines index start
  22649. * @param indexCount defines indices count
  22650. * @param mesh defines the parent mesh
  22651. * @param renderingMesh defines an optional rendering mesh
  22652. * @param createBoundingBox defines if bounding box should be created for this submesh
  22653. */
  22654. constructor(
  22655. /** the material index to use */
  22656. materialIndex: number,
  22657. /** vertex index start */
  22658. verticesStart: number,
  22659. /** vertices count */
  22660. verticesCount: number,
  22661. /** index start */
  22662. indexStart: number,
  22663. /** indices count */
  22664. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22665. /**
  22666. * Returns true if this submesh covers the entire parent mesh
  22667. * @ignorenaming
  22668. */
  22669. readonly IsGlobal: boolean;
  22670. /**
  22671. * Returns the submesh BoudingInfo object
  22672. * @returns current bounding info (or mesh's one if the submesh is global)
  22673. */
  22674. getBoundingInfo(): BoundingInfo;
  22675. /**
  22676. * Sets the submesh BoundingInfo
  22677. * @param boundingInfo defines the new bounding info to use
  22678. * @returns the SubMesh
  22679. */
  22680. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22681. /**
  22682. * Returns the mesh of the current submesh
  22683. * @return the parent mesh
  22684. */
  22685. getMesh(): AbstractMesh;
  22686. /**
  22687. * Returns the rendering mesh of the submesh
  22688. * @returns the rendering mesh (could be different from parent mesh)
  22689. */
  22690. getRenderingMesh(): Mesh;
  22691. /**
  22692. * Returns the submesh material
  22693. * @returns null or the current material
  22694. */
  22695. getMaterial(): Nullable<Material>;
  22696. /**
  22697. * Sets a new updated BoundingInfo object to the submesh
  22698. * @param data defines an optional position array to use to determine the bounding info
  22699. * @returns the SubMesh
  22700. */
  22701. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22702. /** @hidden */
  22703. _checkCollision(collider: Collider): boolean;
  22704. /**
  22705. * Updates the submesh BoundingInfo
  22706. * @param world defines the world matrix to use to update the bounding info
  22707. * @returns the submesh
  22708. */
  22709. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22710. /**
  22711. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22712. * @param frustumPlanes defines the frustum planes
  22713. * @returns true if the submesh is intersecting with the frustum
  22714. */
  22715. isInFrustum(frustumPlanes: Plane[]): boolean;
  22716. /**
  22717. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22718. * @param frustumPlanes defines the frustum planes
  22719. * @returns true if the submesh is inside the frustum
  22720. */
  22721. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22722. /**
  22723. * Renders the submesh
  22724. * @param enableAlphaMode defines if alpha needs to be used
  22725. * @returns the submesh
  22726. */
  22727. render(enableAlphaMode: boolean): SubMesh;
  22728. /**
  22729. * @hidden
  22730. */
  22731. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22732. /**
  22733. * Checks if the submesh intersects with a ray
  22734. * @param ray defines the ray to test
  22735. * @returns true is the passed ray intersects the submesh bounding box
  22736. */
  22737. canIntersects(ray: Ray): boolean;
  22738. /**
  22739. * Intersects current submesh with a ray
  22740. * @param ray defines the ray to test
  22741. * @param positions defines mesh's positions array
  22742. * @param indices defines mesh's indices array
  22743. * @param fastCheck defines if only bounding info should be used
  22744. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22745. * @returns intersection info or null if no intersection
  22746. */
  22747. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22748. /** @hidden */
  22749. private _intersectLines;
  22750. /** @hidden */
  22751. private _intersectUnIndexedLines;
  22752. /** @hidden */
  22753. private _intersectTriangles;
  22754. /** @hidden */
  22755. private _intersectUnIndexedTriangles;
  22756. /** @hidden */
  22757. _rebuild(): void;
  22758. /**
  22759. * Creates a new submesh from the passed mesh
  22760. * @param newMesh defines the new hosting mesh
  22761. * @param newRenderingMesh defines an optional rendering mesh
  22762. * @returns the new submesh
  22763. */
  22764. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22765. /**
  22766. * Release associated resources
  22767. */
  22768. dispose(): void;
  22769. /**
  22770. * Gets the class name
  22771. * @returns the string "SubMesh".
  22772. */
  22773. getClassName(): string;
  22774. /**
  22775. * Creates a new submesh from indices data
  22776. * @param materialIndex the index of the main mesh material
  22777. * @param startIndex the index where to start the copy in the mesh indices array
  22778. * @param indexCount the number of indices to copy then from the startIndex
  22779. * @param mesh the main mesh to create the submesh from
  22780. * @param renderingMesh the optional rendering mesh
  22781. * @returns a new submesh
  22782. */
  22783. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22784. }
  22785. }
  22786. declare module BABYLON {
  22787. /**
  22788. * Class used to store geometry data (vertex buffers + index buffer)
  22789. */
  22790. export class Geometry implements IGetSetVerticesData {
  22791. /**
  22792. * Gets or sets the ID of the geometry
  22793. */
  22794. id: string;
  22795. /**
  22796. * Gets or sets the unique ID of the geometry
  22797. */
  22798. uniqueId: number;
  22799. /**
  22800. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22801. */
  22802. delayLoadState: number;
  22803. /**
  22804. * Gets the file containing the data to load when running in delay load state
  22805. */
  22806. delayLoadingFile: Nullable<string>;
  22807. /**
  22808. * Callback called when the geometry is updated
  22809. */
  22810. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22811. private _scene;
  22812. private _engine;
  22813. private _meshes;
  22814. private _totalVertices;
  22815. /** @hidden */
  22816. _indices: IndicesArray;
  22817. /** @hidden */
  22818. _vertexBuffers: {
  22819. [key: string]: VertexBuffer;
  22820. };
  22821. private _isDisposed;
  22822. private _extend;
  22823. private _boundingBias;
  22824. /** @hidden */
  22825. _delayInfo: Array<string>;
  22826. private _indexBuffer;
  22827. private _indexBufferIsUpdatable;
  22828. /** @hidden */
  22829. _boundingInfo: Nullable<BoundingInfo>;
  22830. /** @hidden */
  22831. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22832. /** @hidden */
  22833. _softwareSkinningFrameId: number;
  22834. private _vertexArrayObjects;
  22835. private _updatable;
  22836. /** @hidden */
  22837. _positions: Nullable<Vector3[]>;
  22838. /**
  22839. * 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
  22840. */
  22841. /**
  22842. * 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
  22843. */
  22844. boundingBias: Vector2;
  22845. /**
  22846. * Static function used to attach a new empty geometry to a mesh
  22847. * @param mesh defines the mesh to attach the geometry to
  22848. * @returns the new Geometry
  22849. */
  22850. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22851. /**
  22852. * Creates a new geometry
  22853. * @param id defines the unique ID
  22854. * @param scene defines the hosting scene
  22855. * @param vertexData defines the VertexData used to get geometry data
  22856. * @param updatable defines if geometry must be updatable (false by default)
  22857. * @param mesh defines the mesh that will be associated with the geometry
  22858. */
  22859. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22860. /**
  22861. * Gets the current extend of the geometry
  22862. */
  22863. readonly extend: {
  22864. minimum: Vector3;
  22865. maximum: Vector3;
  22866. };
  22867. /**
  22868. * Gets the hosting scene
  22869. * @returns the hosting Scene
  22870. */
  22871. getScene(): Scene;
  22872. /**
  22873. * Gets the hosting engine
  22874. * @returns the hosting Engine
  22875. */
  22876. getEngine(): Engine;
  22877. /**
  22878. * Defines if the geometry is ready to use
  22879. * @returns true if the geometry is ready to be used
  22880. */
  22881. isReady(): boolean;
  22882. /**
  22883. * Gets a value indicating that the geometry should not be serialized
  22884. */
  22885. readonly doNotSerialize: boolean;
  22886. /** @hidden */
  22887. _rebuild(): void;
  22888. /**
  22889. * Affects all geometry data in one call
  22890. * @param vertexData defines the geometry data
  22891. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22892. */
  22893. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22894. /**
  22895. * Set specific vertex data
  22896. * @param kind defines the data kind (Position, normal, etc...)
  22897. * @param data defines the vertex data to use
  22898. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22899. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22900. */
  22901. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22902. /**
  22903. * Removes a specific vertex data
  22904. * @param kind defines the data kind (Position, normal, etc...)
  22905. */
  22906. removeVerticesData(kind: string): void;
  22907. /**
  22908. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22909. * @param buffer defines the vertex buffer to use
  22910. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22911. */
  22912. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22913. /**
  22914. * Update a specific vertex buffer
  22915. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22916. * It will do nothing if the buffer is not updatable
  22917. * @param kind defines the data kind (Position, normal, etc...)
  22918. * @param data defines the data to use
  22919. * @param offset defines the offset in the target buffer where to store the data
  22920. * @param useBytes set to true if the offset is in bytes
  22921. */
  22922. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22923. /**
  22924. * Update a specific vertex buffer
  22925. * This function will create a new buffer if the current one is not updatable
  22926. * @param kind defines the data kind (Position, normal, etc...)
  22927. * @param data defines the data to use
  22928. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22929. */
  22930. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22931. private _updateBoundingInfo;
  22932. /** @hidden */
  22933. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22934. /**
  22935. * Gets total number of vertices
  22936. * @returns the total number of vertices
  22937. */
  22938. getTotalVertices(): number;
  22939. /**
  22940. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22941. * @param kind defines the data kind (Position, normal, etc...)
  22942. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22943. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22944. * @returns a float array containing vertex data
  22945. */
  22946. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22947. /**
  22948. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22949. * @param kind defines the data kind (Position, normal, etc...)
  22950. * @returns true if the vertex buffer with the specified kind is updatable
  22951. */
  22952. isVertexBufferUpdatable(kind: string): boolean;
  22953. /**
  22954. * Gets a specific vertex buffer
  22955. * @param kind defines the data kind (Position, normal, etc...)
  22956. * @returns a VertexBuffer
  22957. */
  22958. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22959. /**
  22960. * Returns all vertex buffers
  22961. * @return an object holding all vertex buffers indexed by kind
  22962. */
  22963. getVertexBuffers(): Nullable<{
  22964. [key: string]: VertexBuffer;
  22965. }>;
  22966. /**
  22967. * Gets a boolean indicating if specific vertex buffer is present
  22968. * @param kind defines the data kind (Position, normal, etc...)
  22969. * @returns true if data is present
  22970. */
  22971. isVerticesDataPresent(kind: string): boolean;
  22972. /**
  22973. * Gets a list of all attached data kinds (Position, normal, etc...)
  22974. * @returns a list of string containing all kinds
  22975. */
  22976. getVerticesDataKinds(): string[];
  22977. /**
  22978. * Update index buffer
  22979. * @param indices defines the indices to store in the index buffer
  22980. * @param offset defines the offset in the target buffer where to store the data
  22981. * @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)
  22982. */
  22983. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22984. /**
  22985. * Creates a new index buffer
  22986. * @param indices defines the indices to store in the index buffer
  22987. * @param totalVertices defines the total number of vertices (could be null)
  22988. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22989. */
  22990. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22991. /**
  22992. * Return the total number of indices
  22993. * @returns the total number of indices
  22994. */
  22995. getTotalIndices(): number;
  22996. /**
  22997. * Gets the index buffer array
  22998. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22999. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23000. * @returns the index buffer array
  23001. */
  23002. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23003. /**
  23004. * Gets the index buffer
  23005. * @return the index buffer
  23006. */
  23007. getIndexBuffer(): Nullable<DataBuffer>;
  23008. /** @hidden */
  23009. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23010. /**
  23011. * Release the associated resources for a specific mesh
  23012. * @param mesh defines the source mesh
  23013. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23014. */
  23015. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23016. /**
  23017. * Apply current geometry to a given mesh
  23018. * @param mesh defines the mesh to apply geometry to
  23019. */
  23020. applyToMesh(mesh: Mesh): void;
  23021. private _updateExtend;
  23022. private _applyToMesh;
  23023. private notifyUpdate;
  23024. /**
  23025. * Load the geometry if it was flagged as delay loaded
  23026. * @param scene defines the hosting scene
  23027. * @param onLoaded defines a callback called when the geometry is loaded
  23028. */
  23029. load(scene: Scene, onLoaded?: () => void): void;
  23030. private _queueLoad;
  23031. /**
  23032. * Invert the geometry to move from a right handed system to a left handed one.
  23033. */
  23034. toLeftHanded(): void;
  23035. /** @hidden */
  23036. _resetPointsArrayCache(): void;
  23037. /** @hidden */
  23038. _generatePointsArray(): boolean;
  23039. /**
  23040. * Gets a value indicating if the geometry is disposed
  23041. * @returns true if the geometry was disposed
  23042. */
  23043. isDisposed(): boolean;
  23044. private _disposeVertexArrayObjects;
  23045. /**
  23046. * Free all associated resources
  23047. */
  23048. dispose(): void;
  23049. /**
  23050. * Clone the current geometry into a new geometry
  23051. * @param id defines the unique ID of the new geometry
  23052. * @returns a new geometry object
  23053. */
  23054. copy(id: string): Geometry;
  23055. /**
  23056. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23057. * @return a JSON representation of the current geometry data (without the vertices data)
  23058. */
  23059. serialize(): any;
  23060. private toNumberArray;
  23061. /**
  23062. * Serialize all vertices data into a JSON oject
  23063. * @returns a JSON representation of the current geometry data
  23064. */
  23065. serializeVerticeData(): any;
  23066. /**
  23067. * Extracts a clone of a mesh geometry
  23068. * @param mesh defines the source mesh
  23069. * @param id defines the unique ID of the new geometry object
  23070. * @returns the new geometry object
  23071. */
  23072. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23073. /**
  23074. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23075. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23076. * Be aware Math.random() could cause collisions, but:
  23077. * "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"
  23078. * @returns a string containing a new GUID
  23079. */
  23080. static RandomId(): string;
  23081. /** @hidden */
  23082. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23083. private static _CleanMatricesWeights;
  23084. /**
  23085. * Create a new geometry from persisted data (Using .babylon file format)
  23086. * @param parsedVertexData defines the persisted data
  23087. * @param scene defines the hosting scene
  23088. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23089. * @returns the new geometry object
  23090. */
  23091. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23092. }
  23093. }
  23094. declare module BABYLON {
  23095. /**
  23096. * Define an interface for all classes that will get and set the data on vertices
  23097. */
  23098. export interface IGetSetVerticesData {
  23099. /**
  23100. * Gets a boolean indicating if specific vertex data is present
  23101. * @param kind defines the vertex data kind to use
  23102. * @returns true is data kind is present
  23103. */
  23104. isVerticesDataPresent(kind: string): boolean;
  23105. /**
  23106. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23107. * @param kind defines the data kind (Position, normal, etc...)
  23108. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23109. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23110. * @returns a float array containing vertex data
  23111. */
  23112. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23113. /**
  23114. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23115. * @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.
  23116. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23117. * @returns the indices array or an empty array if the mesh has no geometry
  23118. */
  23119. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23120. /**
  23121. * Set specific vertex data
  23122. * @param kind defines the data kind (Position, normal, etc...)
  23123. * @param data defines the vertex data to use
  23124. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23125. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23126. */
  23127. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23128. /**
  23129. * Update a specific associated vertex buffer
  23130. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23131. * - VertexBuffer.PositionKind
  23132. * - VertexBuffer.UVKind
  23133. * - VertexBuffer.UV2Kind
  23134. * - VertexBuffer.UV3Kind
  23135. * - VertexBuffer.UV4Kind
  23136. * - VertexBuffer.UV5Kind
  23137. * - VertexBuffer.UV6Kind
  23138. * - VertexBuffer.ColorKind
  23139. * - VertexBuffer.MatricesIndicesKind
  23140. * - VertexBuffer.MatricesIndicesExtraKind
  23141. * - VertexBuffer.MatricesWeightsKind
  23142. * - VertexBuffer.MatricesWeightsExtraKind
  23143. * @param data defines the data source
  23144. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23145. * @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)
  23146. */
  23147. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23148. /**
  23149. * Creates a new index buffer
  23150. * @param indices defines the indices to store in the index buffer
  23151. * @param totalVertices defines the total number of vertices (could be null)
  23152. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23153. */
  23154. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23155. }
  23156. /**
  23157. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23158. */
  23159. export class VertexData {
  23160. /**
  23161. * Mesh side orientation : usually the external or front surface
  23162. */
  23163. static readonly FRONTSIDE: number;
  23164. /**
  23165. * Mesh side orientation : usually the internal or back surface
  23166. */
  23167. static readonly BACKSIDE: number;
  23168. /**
  23169. * Mesh side orientation : both internal and external or front and back surfaces
  23170. */
  23171. static readonly DOUBLESIDE: number;
  23172. /**
  23173. * Mesh side orientation : by default, `FRONTSIDE`
  23174. */
  23175. static readonly DEFAULTSIDE: number;
  23176. /**
  23177. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23178. */
  23179. positions: Nullable<FloatArray>;
  23180. /**
  23181. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23182. */
  23183. normals: Nullable<FloatArray>;
  23184. /**
  23185. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23186. */
  23187. tangents: Nullable<FloatArray>;
  23188. /**
  23189. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23190. */
  23191. uvs: Nullable<FloatArray>;
  23192. /**
  23193. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23194. */
  23195. uvs2: Nullable<FloatArray>;
  23196. /**
  23197. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23198. */
  23199. uvs3: Nullable<FloatArray>;
  23200. /**
  23201. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23202. */
  23203. uvs4: Nullable<FloatArray>;
  23204. /**
  23205. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23206. */
  23207. uvs5: Nullable<FloatArray>;
  23208. /**
  23209. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23210. */
  23211. uvs6: Nullable<FloatArray>;
  23212. /**
  23213. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23214. */
  23215. colors: Nullable<FloatArray>;
  23216. /**
  23217. * 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).
  23218. */
  23219. matricesIndices: Nullable<FloatArray>;
  23220. /**
  23221. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23222. */
  23223. matricesWeights: Nullable<FloatArray>;
  23224. /**
  23225. * An array extending the number of possible indices
  23226. */
  23227. matricesIndicesExtra: Nullable<FloatArray>;
  23228. /**
  23229. * An array extending the number of possible weights when the number of indices is extended
  23230. */
  23231. matricesWeightsExtra: Nullable<FloatArray>;
  23232. /**
  23233. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23234. */
  23235. indices: Nullable<IndicesArray>;
  23236. /**
  23237. * Uses the passed data array to set the set the values for the specified kind of data
  23238. * @param data a linear array of floating numbers
  23239. * @param kind the type of data that is being set, eg positions, colors etc
  23240. */
  23241. set(data: FloatArray, kind: string): void;
  23242. /**
  23243. * Associates the vertexData to the passed Mesh.
  23244. * Sets it as updatable or not (default `false`)
  23245. * @param mesh the mesh the vertexData is applied to
  23246. * @param updatable when used and having the value true allows new data to update the vertexData
  23247. * @returns the VertexData
  23248. */
  23249. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23250. /**
  23251. * Associates the vertexData to the passed Geometry.
  23252. * Sets it as updatable or not (default `false`)
  23253. * @param geometry the geometry the vertexData is applied to
  23254. * @param updatable when used and having the value true allows new data to update the vertexData
  23255. * @returns VertexData
  23256. */
  23257. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23258. /**
  23259. * Updates the associated mesh
  23260. * @param mesh the mesh to be updated
  23261. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23262. * @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
  23263. * @returns VertexData
  23264. */
  23265. updateMesh(mesh: Mesh): VertexData;
  23266. /**
  23267. * Updates the associated geometry
  23268. * @param geometry the geometry to be updated
  23269. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23270. * @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
  23271. * @returns VertexData.
  23272. */
  23273. updateGeometry(geometry: Geometry): VertexData;
  23274. private _applyTo;
  23275. private _update;
  23276. /**
  23277. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23278. * @param matrix the transforming matrix
  23279. * @returns the VertexData
  23280. */
  23281. transform(matrix: Matrix): VertexData;
  23282. /**
  23283. * Merges the passed VertexData into the current one
  23284. * @param other the VertexData to be merged into the current one
  23285. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23286. * @returns the modified VertexData
  23287. */
  23288. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23289. private _mergeElement;
  23290. private _validate;
  23291. /**
  23292. * Serializes the VertexData
  23293. * @returns a serialized object
  23294. */
  23295. serialize(): any;
  23296. /**
  23297. * Extracts the vertexData from a mesh
  23298. * @param mesh the mesh from which to extract the VertexData
  23299. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23300. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23301. * @returns the object VertexData associated to the passed mesh
  23302. */
  23303. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23304. /**
  23305. * Extracts the vertexData from the geometry
  23306. * @param geometry the geometry from which to extract the VertexData
  23307. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23308. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23309. * @returns the object VertexData associated to the passed mesh
  23310. */
  23311. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23312. private static _ExtractFrom;
  23313. /**
  23314. * Creates the VertexData for a Ribbon
  23315. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23316. * * pathArray array of paths, each of which an array of successive Vector3
  23317. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23318. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23319. * * 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
  23320. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23321. * * 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)
  23322. * * 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)
  23323. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23324. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23325. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23326. * @returns the VertexData of the ribbon
  23327. */
  23328. static CreateRibbon(options: {
  23329. pathArray: Vector3[][];
  23330. closeArray?: boolean;
  23331. closePath?: boolean;
  23332. offset?: number;
  23333. sideOrientation?: number;
  23334. frontUVs?: Vector4;
  23335. backUVs?: Vector4;
  23336. invertUV?: boolean;
  23337. uvs?: Vector2[];
  23338. colors?: Color4[];
  23339. }): VertexData;
  23340. /**
  23341. * Creates the VertexData for a box
  23342. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23343. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23344. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23345. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23346. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23347. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23348. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23349. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23350. * * 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)
  23351. * * 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)
  23352. * @returns the VertexData of the box
  23353. */
  23354. static CreateBox(options: {
  23355. size?: number;
  23356. width?: number;
  23357. height?: number;
  23358. depth?: number;
  23359. faceUV?: Vector4[];
  23360. faceColors?: Color4[];
  23361. sideOrientation?: number;
  23362. frontUVs?: Vector4;
  23363. backUVs?: Vector4;
  23364. }): VertexData;
  23365. /**
  23366. * Creates the VertexData for a tiled box
  23367. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23368. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23369. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23370. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23371. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23372. * @returns the VertexData of the box
  23373. */
  23374. static CreateTiledBox(options: {
  23375. pattern?: number;
  23376. width?: number;
  23377. height?: number;
  23378. depth?: number;
  23379. tileSize?: number;
  23380. tileWidth?: number;
  23381. tileHeight?: number;
  23382. alignHorizontal?: number;
  23383. alignVertical?: number;
  23384. faceUV?: Vector4[];
  23385. faceColors?: Color4[];
  23386. sideOrientation?: number;
  23387. }): VertexData;
  23388. /**
  23389. * Creates the VertexData for a tiled plane
  23390. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23391. * * pattern a limited pattern arrangement depending on the number
  23392. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23393. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23394. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23395. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23396. * * 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)
  23397. * * 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)
  23398. * @returns the VertexData of the tiled plane
  23399. */
  23400. static CreateTiledPlane(options: {
  23401. pattern?: number;
  23402. tileSize?: number;
  23403. tileWidth?: number;
  23404. tileHeight?: number;
  23405. size?: number;
  23406. width?: number;
  23407. height?: number;
  23408. alignHorizontal?: number;
  23409. alignVertical?: number;
  23410. sideOrientation?: number;
  23411. frontUVs?: Vector4;
  23412. backUVs?: Vector4;
  23413. }): VertexData;
  23414. /**
  23415. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23416. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23417. * * segments sets the number of horizontal strips optional, default 32
  23418. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23419. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23420. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23421. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23422. * * 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
  23423. * * 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
  23424. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23425. * * 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)
  23426. * * 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)
  23427. * @returns the VertexData of the ellipsoid
  23428. */
  23429. static CreateSphere(options: {
  23430. segments?: number;
  23431. diameter?: number;
  23432. diameterX?: number;
  23433. diameterY?: number;
  23434. diameterZ?: number;
  23435. arc?: number;
  23436. slice?: number;
  23437. sideOrientation?: number;
  23438. frontUVs?: Vector4;
  23439. backUVs?: Vector4;
  23440. }): VertexData;
  23441. /**
  23442. * Creates the VertexData for a cylinder, cone or prism
  23443. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23444. * * height sets the height (y direction) of the cylinder, optional, default 2
  23445. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23446. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23447. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23448. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23449. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23450. * * 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
  23451. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23452. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23453. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23454. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23455. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23456. * * 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)
  23457. * * 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)
  23458. * @returns the VertexData of the cylinder, cone or prism
  23459. */
  23460. static CreateCylinder(options: {
  23461. height?: number;
  23462. diameterTop?: number;
  23463. diameterBottom?: number;
  23464. diameter?: number;
  23465. tessellation?: number;
  23466. subdivisions?: number;
  23467. arc?: number;
  23468. faceColors?: Color4[];
  23469. faceUV?: Vector4[];
  23470. hasRings?: boolean;
  23471. enclose?: boolean;
  23472. sideOrientation?: number;
  23473. frontUVs?: Vector4;
  23474. backUVs?: Vector4;
  23475. }): VertexData;
  23476. /**
  23477. * Creates the VertexData for a torus
  23478. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23479. * * diameter the diameter of the torus, optional default 1
  23480. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23481. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23482. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23483. * * 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)
  23484. * * 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)
  23485. * @returns the VertexData of the torus
  23486. */
  23487. static CreateTorus(options: {
  23488. diameter?: number;
  23489. thickness?: number;
  23490. tessellation?: number;
  23491. sideOrientation?: number;
  23492. frontUVs?: Vector4;
  23493. backUVs?: Vector4;
  23494. }): VertexData;
  23495. /**
  23496. * Creates the VertexData of the LineSystem
  23497. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23498. * - lines an array of lines, each line being an array of successive Vector3
  23499. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23500. * @returns the VertexData of the LineSystem
  23501. */
  23502. static CreateLineSystem(options: {
  23503. lines: Vector3[][];
  23504. colors?: Nullable<Color4[][]>;
  23505. }): VertexData;
  23506. /**
  23507. * Create the VertexData for a DashedLines
  23508. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23509. * - points an array successive Vector3
  23510. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23511. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23512. * - dashNb the intended total number of dashes, optional, default 200
  23513. * @returns the VertexData for the DashedLines
  23514. */
  23515. static CreateDashedLines(options: {
  23516. points: Vector3[];
  23517. dashSize?: number;
  23518. gapSize?: number;
  23519. dashNb?: number;
  23520. }): VertexData;
  23521. /**
  23522. * Creates the VertexData for a Ground
  23523. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23524. * - width the width (x direction) of the ground, optional, default 1
  23525. * - height the height (z direction) of the ground, optional, default 1
  23526. * - subdivisions the number of subdivisions per side, optional, default 1
  23527. * @returns the VertexData of the Ground
  23528. */
  23529. static CreateGround(options: {
  23530. width?: number;
  23531. height?: number;
  23532. subdivisions?: number;
  23533. subdivisionsX?: number;
  23534. subdivisionsY?: number;
  23535. }): VertexData;
  23536. /**
  23537. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23538. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23539. * * xmin the ground minimum X coordinate, optional, default -1
  23540. * * zmin the ground minimum Z coordinate, optional, default -1
  23541. * * xmax the ground maximum X coordinate, optional, default 1
  23542. * * zmax the ground maximum Z coordinate, optional, default 1
  23543. * * 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}
  23544. * * 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}
  23545. * @returns the VertexData of the TiledGround
  23546. */
  23547. static CreateTiledGround(options: {
  23548. xmin: number;
  23549. zmin: number;
  23550. xmax: number;
  23551. zmax: number;
  23552. subdivisions?: {
  23553. w: number;
  23554. h: number;
  23555. };
  23556. precision?: {
  23557. w: number;
  23558. h: number;
  23559. };
  23560. }): VertexData;
  23561. /**
  23562. * Creates the VertexData of the Ground designed from a heightmap
  23563. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23564. * * width the width (x direction) of the ground
  23565. * * height the height (z direction) of the ground
  23566. * * subdivisions the number of subdivisions per side
  23567. * * minHeight the minimum altitude on the ground, optional, default 0
  23568. * * maxHeight the maximum altitude on the ground, optional default 1
  23569. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23570. * * buffer the array holding the image color data
  23571. * * bufferWidth the width of image
  23572. * * bufferHeight the height of image
  23573. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23574. * @returns the VertexData of the Ground designed from a heightmap
  23575. */
  23576. static CreateGroundFromHeightMap(options: {
  23577. width: number;
  23578. height: number;
  23579. subdivisions: number;
  23580. minHeight: number;
  23581. maxHeight: number;
  23582. colorFilter: Color3;
  23583. buffer: Uint8Array;
  23584. bufferWidth: number;
  23585. bufferHeight: number;
  23586. alphaFilter: number;
  23587. }): VertexData;
  23588. /**
  23589. * Creates the VertexData for a Plane
  23590. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23591. * * size sets the width and height of the plane to the value of size, optional default 1
  23592. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23593. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23594. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23595. * * 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)
  23596. * * 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)
  23597. * @returns the VertexData of the box
  23598. */
  23599. static CreatePlane(options: {
  23600. size?: number;
  23601. width?: number;
  23602. height?: number;
  23603. sideOrientation?: number;
  23604. frontUVs?: Vector4;
  23605. backUVs?: Vector4;
  23606. }): VertexData;
  23607. /**
  23608. * Creates the VertexData of the Disc or regular Polygon
  23609. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23610. * * radius the radius of the disc, optional default 0.5
  23611. * * tessellation the number of polygon sides, optional, default 64
  23612. * * 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
  23613. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23614. * * 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)
  23615. * * 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)
  23616. * @returns the VertexData of the box
  23617. */
  23618. static CreateDisc(options: {
  23619. radius?: number;
  23620. tessellation?: number;
  23621. arc?: number;
  23622. sideOrientation?: number;
  23623. frontUVs?: Vector4;
  23624. backUVs?: Vector4;
  23625. }): VertexData;
  23626. /**
  23627. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23628. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23629. * @param polygon a mesh built from polygonTriangulation.build()
  23630. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23631. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23632. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23633. * @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)
  23634. * @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)
  23635. * @returns the VertexData of the Polygon
  23636. */
  23637. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23638. /**
  23639. * Creates the VertexData of the IcoSphere
  23640. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23641. * * radius the radius of the IcoSphere, optional default 1
  23642. * * radiusX allows stretching in the x direction, optional, default radius
  23643. * * radiusY allows stretching in the y direction, optional, default radius
  23644. * * radiusZ allows stretching in the z direction, optional, default radius
  23645. * * flat when true creates a flat shaded mesh, optional, default true
  23646. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23647. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23648. * * 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)
  23649. * * 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)
  23650. * @returns the VertexData of the IcoSphere
  23651. */
  23652. static CreateIcoSphere(options: {
  23653. radius?: number;
  23654. radiusX?: number;
  23655. radiusY?: number;
  23656. radiusZ?: number;
  23657. flat?: boolean;
  23658. subdivisions?: number;
  23659. sideOrientation?: number;
  23660. frontUVs?: Vector4;
  23661. backUVs?: Vector4;
  23662. }): VertexData;
  23663. /**
  23664. * Creates the VertexData for a Polyhedron
  23665. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23666. * * type provided types are:
  23667. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23668. * * 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)
  23669. * * size the size of the IcoSphere, optional default 1
  23670. * * sizeX allows stretching in the x direction, optional, default size
  23671. * * sizeY allows stretching in the y direction, optional, default size
  23672. * * sizeZ allows stretching in the z direction, optional, default size
  23673. * * 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
  23674. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23675. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23676. * * flat when true creates a flat shaded mesh, optional, default true
  23677. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23678. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23679. * * 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)
  23680. * * 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)
  23681. * @returns the VertexData of the Polyhedron
  23682. */
  23683. static CreatePolyhedron(options: {
  23684. type?: number;
  23685. size?: number;
  23686. sizeX?: number;
  23687. sizeY?: number;
  23688. sizeZ?: number;
  23689. custom?: any;
  23690. faceUV?: Vector4[];
  23691. faceColors?: Color4[];
  23692. flat?: boolean;
  23693. sideOrientation?: number;
  23694. frontUVs?: Vector4;
  23695. backUVs?: Vector4;
  23696. }): VertexData;
  23697. /**
  23698. * Creates the VertexData for a TorusKnot
  23699. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23700. * * radius the radius of the torus knot, optional, default 2
  23701. * * tube the thickness of the tube, optional, default 0.5
  23702. * * radialSegments the number of sides on each tube segments, optional, default 32
  23703. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23704. * * p the number of windings around the z axis, optional, default 2
  23705. * * q the number of windings around the x axis, optional, default 3
  23706. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23707. * * 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)
  23708. * * 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)
  23709. * @returns the VertexData of the Torus Knot
  23710. */
  23711. static CreateTorusKnot(options: {
  23712. radius?: number;
  23713. tube?: number;
  23714. radialSegments?: number;
  23715. tubularSegments?: number;
  23716. p?: number;
  23717. q?: number;
  23718. sideOrientation?: number;
  23719. frontUVs?: Vector4;
  23720. backUVs?: Vector4;
  23721. }): VertexData;
  23722. /**
  23723. * Compute normals for given positions and indices
  23724. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23725. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23726. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23727. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23728. * * facetNormals : optional array of facet normals (vector3)
  23729. * * facetPositions : optional array of facet positions (vector3)
  23730. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23731. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23732. * * bInfo : optional bounding info, required for facetPartitioning computation
  23733. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23734. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23735. * * useRightHandedSystem: optional boolean to for right handed system computation
  23736. * * depthSort : optional boolean to enable the facet depth sort computation
  23737. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23738. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23739. */
  23740. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23741. facetNormals?: any;
  23742. facetPositions?: any;
  23743. facetPartitioning?: any;
  23744. ratio?: number;
  23745. bInfo?: any;
  23746. bbSize?: Vector3;
  23747. subDiv?: any;
  23748. useRightHandedSystem?: boolean;
  23749. depthSort?: boolean;
  23750. distanceTo?: Vector3;
  23751. depthSortedFacets?: any;
  23752. }): void;
  23753. /** @hidden */
  23754. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23755. /**
  23756. * Applies VertexData created from the imported parameters to the geometry
  23757. * @param parsedVertexData the parsed data from an imported file
  23758. * @param geometry the geometry to apply the VertexData to
  23759. */
  23760. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23761. }
  23762. }
  23763. declare module BABYLON {
  23764. /**
  23765. * Class containing static functions to help procedurally build meshes
  23766. */
  23767. export class DiscBuilder {
  23768. /**
  23769. * Creates a plane polygonal mesh. By default, this is a disc
  23770. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23771. * * 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
  23772. * * 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
  23773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23774. * * 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
  23775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23776. * @param name defines the name of the mesh
  23777. * @param options defines the options used to create the mesh
  23778. * @param scene defines the hosting scene
  23779. * @returns the plane polygonal mesh
  23780. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23781. */
  23782. static CreateDisc(name: string, options: {
  23783. radius?: number;
  23784. tessellation?: number;
  23785. arc?: number;
  23786. updatable?: boolean;
  23787. sideOrientation?: number;
  23788. frontUVs?: Vector4;
  23789. backUVs?: Vector4;
  23790. }, scene?: Nullable<Scene>): Mesh;
  23791. }
  23792. }
  23793. declare module BABYLON {
  23794. /**
  23795. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23796. *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.
  23797. * The SPS is also a particle system. It provides some methods to manage the particles.
  23798. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23799. *
  23800. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23801. */
  23802. export class SolidParticleSystem implements IDisposable {
  23803. /**
  23804. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23805. * Example : var p = SPS.particles[i];
  23806. */
  23807. particles: SolidParticle[];
  23808. /**
  23809. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23810. */
  23811. nbParticles: number;
  23812. /**
  23813. * If the particles must ever face the camera (default false). Useful for planar particles.
  23814. */
  23815. billboard: boolean;
  23816. /**
  23817. * Recompute normals when adding a shape
  23818. */
  23819. recomputeNormals: boolean;
  23820. /**
  23821. * This a counter ofr your own usage. It's not set by any SPS functions.
  23822. */
  23823. counter: number;
  23824. /**
  23825. * The SPS name. This name is also given to the underlying mesh.
  23826. */
  23827. name: string;
  23828. /**
  23829. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23830. */
  23831. mesh: Mesh;
  23832. /**
  23833. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23834. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23835. */
  23836. vars: any;
  23837. /**
  23838. * This array is populated when the SPS is set as 'pickable'.
  23839. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23840. * Each element of this array is an object `{idx: int, faceId: int}`.
  23841. * `idx` is the picked particle index in the `SPS.particles` array
  23842. * `faceId` is the picked face index counted within this particle.
  23843. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23844. */
  23845. pickedParticles: {
  23846. idx: number;
  23847. faceId: number;
  23848. }[];
  23849. /**
  23850. * This array is populated when `enableDepthSort` is set to true.
  23851. * Each element of this array is an instance of the class DepthSortedParticle.
  23852. */
  23853. depthSortedParticles: DepthSortedParticle[];
  23854. /**
  23855. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23856. * @hidden
  23857. */
  23858. _bSphereOnly: boolean;
  23859. /**
  23860. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23861. * @hidden
  23862. */
  23863. _bSphereRadiusFactor: number;
  23864. private _scene;
  23865. private _positions;
  23866. private _indices;
  23867. private _normals;
  23868. private _colors;
  23869. private _uvs;
  23870. private _indices32;
  23871. private _positions32;
  23872. private _normals32;
  23873. private _fixedNormal32;
  23874. private _colors32;
  23875. private _uvs32;
  23876. private _index;
  23877. private _updatable;
  23878. private _pickable;
  23879. private _isVisibilityBoxLocked;
  23880. private _alwaysVisible;
  23881. private _depthSort;
  23882. private _shapeCounter;
  23883. private _copy;
  23884. private _color;
  23885. private _computeParticleColor;
  23886. private _computeParticleTexture;
  23887. private _computeParticleRotation;
  23888. private _computeParticleVertex;
  23889. private _computeBoundingBox;
  23890. private _depthSortParticles;
  23891. private _camera;
  23892. private _mustUnrotateFixedNormals;
  23893. private _particlesIntersect;
  23894. private _needs32Bits;
  23895. /**
  23896. * Creates a SPS (Solid Particle System) object.
  23897. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23898. * @param scene (Scene) is the scene in which the SPS is added.
  23899. * @param options defines the options of the sps e.g.
  23900. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23901. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23902. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23903. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23904. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23905. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23906. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23907. */
  23908. constructor(name: string, scene: Scene, options?: {
  23909. updatable?: boolean;
  23910. isPickable?: boolean;
  23911. enableDepthSort?: boolean;
  23912. particleIntersection?: boolean;
  23913. boundingSphereOnly?: boolean;
  23914. bSphereRadiusFactor?: number;
  23915. });
  23916. /**
  23917. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23918. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23919. * @returns the created mesh
  23920. */
  23921. buildMesh(): Mesh;
  23922. /**
  23923. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23924. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23925. * Thus the particles generated from `digest()` have their property `position` set yet.
  23926. * @param mesh ( Mesh ) is the mesh to be digested
  23927. * @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
  23928. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23929. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23930. * @returns the current SPS
  23931. */
  23932. digest(mesh: Mesh, options?: {
  23933. facetNb?: number;
  23934. number?: number;
  23935. delta?: number;
  23936. }): SolidParticleSystem;
  23937. private _unrotateFixedNormals;
  23938. private _resetCopy;
  23939. private _meshBuilder;
  23940. private _posToShape;
  23941. private _uvsToShapeUV;
  23942. private _addParticle;
  23943. /**
  23944. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23945. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23946. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23947. * @param nb (positive integer) the number of particles to be created from this model
  23948. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23949. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23950. * @returns the number of shapes in the system
  23951. */
  23952. addShape(mesh: Mesh, nb: number, options?: {
  23953. positionFunction?: any;
  23954. vertexFunction?: any;
  23955. }): number;
  23956. private _rebuildParticle;
  23957. /**
  23958. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23959. * @returns the SPS.
  23960. */
  23961. rebuildMesh(): SolidParticleSystem;
  23962. /**
  23963. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23964. * This method calls `updateParticle()` for each particle of the SPS.
  23965. * For an animated SPS, it is usually called within the render loop.
  23966. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23967. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23968. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23969. * @returns the SPS.
  23970. */
  23971. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23972. /**
  23973. * Disposes the SPS.
  23974. */
  23975. dispose(): void;
  23976. /**
  23977. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23978. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23979. * @returns the SPS.
  23980. */
  23981. refreshVisibleSize(): SolidParticleSystem;
  23982. /**
  23983. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23984. * @param size the size (float) of the visibility box
  23985. * note : this doesn't lock the SPS mesh bounding box.
  23986. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23987. */
  23988. setVisibilityBox(size: number): void;
  23989. /**
  23990. * Gets whether the SPS as always visible or not
  23991. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23992. */
  23993. /**
  23994. * Sets the SPS as always visible or not
  23995. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23996. */
  23997. isAlwaysVisible: boolean;
  23998. /**
  23999. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24000. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24001. */
  24002. /**
  24003. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24004. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24005. */
  24006. isVisibilityBoxLocked: boolean;
  24007. /**
  24008. * Tells to `setParticles()` to compute the particle rotations or not.
  24009. * Default value : true. The SPS is faster when it's set to false.
  24010. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24011. */
  24012. /**
  24013. * Gets if `setParticles()` computes the particle rotations or not.
  24014. * Default value : true. The SPS is faster when it's set to false.
  24015. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24016. */
  24017. computeParticleRotation: boolean;
  24018. /**
  24019. * Tells to `setParticles()` to compute the particle colors or not.
  24020. * Default value : true. The SPS is faster when it's set to false.
  24021. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24022. */
  24023. /**
  24024. * Gets if `setParticles()` computes the particle colors or not.
  24025. * Default value : true. The SPS is faster when it's set to false.
  24026. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24027. */
  24028. computeParticleColor: boolean;
  24029. /**
  24030. * Gets if `setParticles()` computes the particle textures or not.
  24031. * Default value : true. The SPS is faster when it's set to false.
  24032. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24033. */
  24034. computeParticleTexture: boolean;
  24035. /**
  24036. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24037. * Default value : false. The SPS is faster when it's set to false.
  24038. * Note : the particle custom vertex positions aren't stored values.
  24039. */
  24040. /**
  24041. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24042. * Default value : false. The SPS is faster when it's set to false.
  24043. * Note : the particle custom vertex positions aren't stored values.
  24044. */
  24045. computeParticleVertex: boolean;
  24046. /**
  24047. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24048. */
  24049. /**
  24050. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24051. */
  24052. computeBoundingBox: boolean;
  24053. /**
  24054. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24055. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24056. * Default : `true`
  24057. */
  24058. /**
  24059. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24060. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24061. * Default : `true`
  24062. */
  24063. depthSortParticles: boolean;
  24064. /**
  24065. * This function does nothing. It may be overwritten to set all the particle first values.
  24066. * The SPS doesn't call this function, you may have to call it by your own.
  24067. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24068. */
  24069. initParticles(): void;
  24070. /**
  24071. * This function does nothing. It may be overwritten to recycle a particle.
  24072. * The SPS doesn't call this function, you may have to call it by your own.
  24073. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24074. * @param particle The particle to recycle
  24075. * @returns the recycled particle
  24076. */
  24077. recycleParticle(particle: SolidParticle): SolidParticle;
  24078. /**
  24079. * Updates a particle : this function should be overwritten by the user.
  24080. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24081. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24082. * @example : just set a particle position or velocity and recycle conditions
  24083. * @param particle The particle to update
  24084. * @returns the updated particle
  24085. */
  24086. updateParticle(particle: SolidParticle): SolidParticle;
  24087. /**
  24088. * Updates a vertex of a particle : it can be overwritten by the user.
  24089. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24090. * @param particle the current particle
  24091. * @param vertex the current index of the current particle
  24092. * @param pt the index of the current vertex in the particle shape
  24093. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24094. * @example : just set a vertex particle position
  24095. * @returns the updated vertex
  24096. */
  24097. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24098. /**
  24099. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24100. * This does nothing and may be overwritten by the user.
  24101. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24102. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24103. * @param update the boolean update value actually passed to setParticles()
  24104. */
  24105. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24106. /**
  24107. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24108. * This will be passed three parameters.
  24109. * This does nothing and may be overwritten by the user.
  24110. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24111. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24112. * @param update the boolean update value actually passed to setParticles()
  24113. */
  24114. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24115. }
  24116. }
  24117. declare module BABYLON {
  24118. /**
  24119. * Represents one particle of a solid particle system.
  24120. */
  24121. export class SolidParticle {
  24122. /**
  24123. * particle global index
  24124. */
  24125. idx: number;
  24126. /**
  24127. * The color of the particle
  24128. */
  24129. color: Nullable<Color4>;
  24130. /**
  24131. * The world space position of the particle.
  24132. */
  24133. position: Vector3;
  24134. /**
  24135. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24136. */
  24137. rotation: Vector3;
  24138. /**
  24139. * The world space rotation quaternion of the particle.
  24140. */
  24141. rotationQuaternion: Nullable<Quaternion>;
  24142. /**
  24143. * The scaling of the particle.
  24144. */
  24145. scaling: Vector3;
  24146. /**
  24147. * The uvs of the particle.
  24148. */
  24149. uvs: Vector4;
  24150. /**
  24151. * The current speed of the particle.
  24152. */
  24153. velocity: Vector3;
  24154. /**
  24155. * The pivot point in the particle local space.
  24156. */
  24157. pivot: Vector3;
  24158. /**
  24159. * Must the particle be translated from its pivot point in its local space ?
  24160. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24161. * Default : false
  24162. */
  24163. translateFromPivot: boolean;
  24164. /**
  24165. * Is the particle active or not ?
  24166. */
  24167. alive: boolean;
  24168. /**
  24169. * Is the particle visible or not ?
  24170. */
  24171. isVisible: boolean;
  24172. /**
  24173. * Index of this particle in the global "positions" array (Internal use)
  24174. * @hidden
  24175. */
  24176. _pos: number;
  24177. /**
  24178. * @hidden Index of this particle in the global "indices" array (Internal use)
  24179. */
  24180. _ind: number;
  24181. /**
  24182. * @hidden ModelShape of this particle (Internal use)
  24183. */
  24184. _model: ModelShape;
  24185. /**
  24186. * ModelShape id of this particle
  24187. */
  24188. shapeId: number;
  24189. /**
  24190. * Index of the particle in its shape id (Internal use)
  24191. */
  24192. idxInShape: number;
  24193. /**
  24194. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24195. */
  24196. _modelBoundingInfo: BoundingInfo;
  24197. /**
  24198. * @hidden Particle BoundingInfo object (Internal use)
  24199. */
  24200. _boundingInfo: BoundingInfo;
  24201. /**
  24202. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24203. */
  24204. _sps: SolidParticleSystem;
  24205. /**
  24206. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24207. */
  24208. _stillInvisible: boolean;
  24209. /**
  24210. * @hidden Last computed particle rotation matrix
  24211. */
  24212. _rotationMatrix: number[];
  24213. /**
  24214. * Parent particle Id, if any.
  24215. * Default null.
  24216. */
  24217. parentId: Nullable<number>;
  24218. /**
  24219. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24220. * The possible values are :
  24221. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24222. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24223. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24224. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24225. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24226. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24227. * */
  24228. cullingStrategy: number;
  24229. /**
  24230. * @hidden Internal global position in the SPS.
  24231. */
  24232. _globalPosition: Vector3;
  24233. /**
  24234. * Creates a Solid Particle object.
  24235. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24236. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24237. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24238. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24239. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24240. * @param shapeId (integer) is the model shape identifier in the SPS.
  24241. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24242. * @param sps defines the sps it is associated to
  24243. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24244. */
  24245. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24246. /**
  24247. * Legacy support, changed scale to scaling
  24248. */
  24249. /**
  24250. * Legacy support, changed scale to scaling
  24251. */
  24252. scale: Vector3;
  24253. /**
  24254. * Legacy support, changed quaternion to rotationQuaternion
  24255. */
  24256. /**
  24257. * Legacy support, changed quaternion to rotationQuaternion
  24258. */
  24259. quaternion: Nullable<Quaternion>;
  24260. /**
  24261. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24262. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24263. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24264. * @returns true if it intersects
  24265. */
  24266. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24267. /**
  24268. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24269. * A particle is in the frustum if its bounding box intersects the frustum
  24270. * @param frustumPlanes defines the frustum to test
  24271. * @returns true if the particle is in the frustum planes
  24272. */
  24273. isInFrustum(frustumPlanes: Plane[]): boolean;
  24274. /**
  24275. * get the rotation matrix of the particle
  24276. * @hidden
  24277. */
  24278. getRotationMatrix(m: Matrix): void;
  24279. }
  24280. /**
  24281. * Represents the shape of the model used by one particle of a solid particle system.
  24282. * SPS internal tool, don't use it manually.
  24283. */
  24284. export class ModelShape {
  24285. /**
  24286. * The shape id
  24287. * @hidden
  24288. */
  24289. shapeID: number;
  24290. /**
  24291. * flat array of model positions (internal use)
  24292. * @hidden
  24293. */
  24294. _shape: Vector3[];
  24295. /**
  24296. * flat array of model UVs (internal use)
  24297. * @hidden
  24298. */
  24299. _shapeUV: number[];
  24300. /**
  24301. * length of the shape in the model indices array (internal use)
  24302. * @hidden
  24303. */
  24304. _indicesLength: number;
  24305. /**
  24306. * Custom position function (internal use)
  24307. * @hidden
  24308. */
  24309. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24310. /**
  24311. * Custom vertex function (internal use)
  24312. * @hidden
  24313. */
  24314. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24315. /**
  24316. * 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.
  24317. * SPS internal tool, don't use it manually.
  24318. * @hidden
  24319. */
  24320. 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>);
  24321. }
  24322. /**
  24323. * Represents a Depth Sorted Particle in the solid particle system.
  24324. */
  24325. export class DepthSortedParticle {
  24326. /**
  24327. * Index of the particle in the "indices" array
  24328. */
  24329. ind: number;
  24330. /**
  24331. * Length of the particle shape in the "indices" array
  24332. */
  24333. indicesLength: number;
  24334. /**
  24335. * Squared distance from the particle to the camera
  24336. */
  24337. sqDistance: number;
  24338. }
  24339. }
  24340. declare module BABYLON {
  24341. /**
  24342. * @hidden
  24343. */
  24344. export class _MeshCollisionData {
  24345. _checkCollisions: boolean;
  24346. _collisionMask: number;
  24347. _collisionGroup: number;
  24348. _collider: Nullable<Collider>;
  24349. _oldPositionForCollisions: Vector3;
  24350. _diffPositionForCollisions: Vector3;
  24351. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24352. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24353. }
  24354. }
  24355. declare module BABYLON {
  24356. /** @hidden */
  24357. class _FacetDataStorage {
  24358. facetPositions: Vector3[];
  24359. facetNormals: Vector3[];
  24360. facetPartitioning: number[][];
  24361. facetNb: number;
  24362. partitioningSubdivisions: number;
  24363. partitioningBBoxRatio: number;
  24364. facetDataEnabled: boolean;
  24365. facetParameters: any;
  24366. bbSize: Vector3;
  24367. subDiv: {
  24368. max: number;
  24369. X: number;
  24370. Y: number;
  24371. Z: number;
  24372. };
  24373. facetDepthSort: boolean;
  24374. facetDepthSortEnabled: boolean;
  24375. depthSortedIndices: IndicesArray;
  24376. depthSortedFacets: {
  24377. ind: number;
  24378. sqDistance: number;
  24379. }[];
  24380. facetDepthSortFunction: (f1: {
  24381. ind: number;
  24382. sqDistance: number;
  24383. }, f2: {
  24384. ind: number;
  24385. sqDistance: number;
  24386. }) => number;
  24387. facetDepthSortFrom: Vector3;
  24388. facetDepthSortOrigin: Vector3;
  24389. invertedMatrix: Matrix;
  24390. }
  24391. /**
  24392. * @hidden
  24393. **/
  24394. class _InternalAbstractMeshDataInfo {
  24395. _hasVertexAlpha: boolean;
  24396. _useVertexColors: boolean;
  24397. _numBoneInfluencers: number;
  24398. _applyFog: boolean;
  24399. _receiveShadows: boolean;
  24400. _facetData: _FacetDataStorage;
  24401. _visibility: number;
  24402. _skeleton: Nullable<Skeleton>;
  24403. _layerMask: number;
  24404. _computeBonesUsingShaders: boolean;
  24405. _isActive: boolean;
  24406. _onlyForInstances: boolean;
  24407. _isActiveIntermediate: boolean;
  24408. _onlyForInstancesIntermediate: boolean;
  24409. }
  24410. /**
  24411. * Class used to store all common mesh properties
  24412. */
  24413. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24414. /** No occlusion */
  24415. static OCCLUSION_TYPE_NONE: number;
  24416. /** Occlusion set to optimisitic */
  24417. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24418. /** Occlusion set to strict */
  24419. static OCCLUSION_TYPE_STRICT: number;
  24420. /** Use an accurante occlusion algorithm */
  24421. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24422. /** Use a conservative occlusion algorithm */
  24423. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24424. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24425. * Test order :
  24426. * Is the bounding sphere outside the frustum ?
  24427. * If not, are the bounding box vertices outside the frustum ?
  24428. * It not, then the cullable object is in the frustum.
  24429. */
  24430. static readonly CULLINGSTRATEGY_STANDARD: number;
  24431. /** Culling strategy : Bounding Sphere Only.
  24432. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24433. * It's also less accurate than the standard because some not visible objects can still be selected.
  24434. * Test : is the bounding sphere outside the frustum ?
  24435. * If not, then the cullable object is in the frustum.
  24436. */
  24437. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24438. /** Culling strategy : Optimistic Inclusion.
  24439. * This in an inclusion test first, then the standard exclusion test.
  24440. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24441. * 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.
  24442. * Anyway, it's as accurate as the standard strategy.
  24443. * Test :
  24444. * Is the cullable object bounding sphere center in the frustum ?
  24445. * If not, apply the default culling strategy.
  24446. */
  24447. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24448. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24449. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24450. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24451. * 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.
  24452. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24453. * Test :
  24454. * Is the cullable object bounding sphere center in the frustum ?
  24455. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24456. */
  24457. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24458. /**
  24459. * No billboard
  24460. */
  24461. static readonly BILLBOARDMODE_NONE: number;
  24462. /** Billboard on X axis */
  24463. static readonly BILLBOARDMODE_X: number;
  24464. /** Billboard on Y axis */
  24465. static readonly BILLBOARDMODE_Y: number;
  24466. /** Billboard on Z axis */
  24467. static readonly BILLBOARDMODE_Z: number;
  24468. /** Billboard on all axes */
  24469. static readonly BILLBOARDMODE_ALL: number;
  24470. /** @hidden */
  24471. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  24472. /**
  24473. * The culling strategy to use to check whether the mesh must be rendered or not.
  24474. * This value can be changed at any time and will be used on the next render mesh selection.
  24475. * The possible values are :
  24476. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24477. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24478. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24479. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24480. * Please read each static variable documentation to get details about the culling process.
  24481. * */
  24482. cullingStrategy: number;
  24483. /**
  24484. * Gets the number of facets in the mesh
  24485. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24486. */
  24487. readonly facetNb: number;
  24488. /**
  24489. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24490. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24491. */
  24492. partitioningSubdivisions: number;
  24493. /**
  24494. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24495. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24496. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24497. */
  24498. partitioningBBoxRatio: number;
  24499. /**
  24500. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24501. * Works only for updatable meshes.
  24502. * Doesn't work with multi-materials
  24503. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24504. */
  24505. mustDepthSortFacets: boolean;
  24506. /**
  24507. * The location (Vector3) where the facet depth sort must be computed from.
  24508. * By default, the active camera position.
  24509. * Used only when facet depth sort is enabled
  24510. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24511. */
  24512. facetDepthSortFrom: Vector3;
  24513. /**
  24514. * gets a boolean indicating if facetData is enabled
  24515. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24516. */
  24517. readonly isFacetDataEnabled: boolean;
  24518. /** @hidden */
  24519. _updateNonUniformScalingState(value: boolean): boolean;
  24520. /**
  24521. * An event triggered when this mesh collides with another one
  24522. */
  24523. onCollideObservable: Observable<AbstractMesh>;
  24524. /** Set a function to call when this mesh collides with another one */
  24525. onCollide: () => void;
  24526. /**
  24527. * An event triggered when the collision's position changes
  24528. */
  24529. onCollisionPositionChangeObservable: Observable<Vector3>;
  24530. /** Set a function to call when the collision's position changes */
  24531. onCollisionPositionChange: () => void;
  24532. /**
  24533. * An event triggered when material is changed
  24534. */
  24535. onMaterialChangedObservable: Observable<AbstractMesh>;
  24536. /**
  24537. * Gets or sets the orientation for POV movement & rotation
  24538. */
  24539. definedFacingForward: boolean;
  24540. /** @hidden */
  24541. _occlusionQuery: Nullable<WebGLQuery>;
  24542. /** @hidden */
  24543. _renderingGroup: Nullable<RenderingGroup>;
  24544. /**
  24545. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24546. */
  24547. /**
  24548. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24549. */
  24550. visibility: number;
  24551. /** Gets or sets the alpha index used to sort transparent meshes
  24552. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24553. */
  24554. alphaIndex: number;
  24555. /**
  24556. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24557. */
  24558. isVisible: boolean;
  24559. /**
  24560. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24561. */
  24562. isPickable: boolean;
  24563. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24564. showSubMeshesBoundingBox: boolean;
  24565. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24566. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24567. */
  24568. isBlocker: boolean;
  24569. /**
  24570. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24571. */
  24572. enablePointerMoveEvents: boolean;
  24573. /**
  24574. * Specifies the rendering group id for this mesh (0 by default)
  24575. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24576. */
  24577. renderingGroupId: number;
  24578. private _material;
  24579. /** Gets or sets current material */
  24580. material: Nullable<Material>;
  24581. /**
  24582. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24583. * @see http://doc.babylonjs.com/babylon101/shadows
  24584. */
  24585. receiveShadows: boolean;
  24586. /** Defines color to use when rendering outline */
  24587. outlineColor: Color3;
  24588. /** Define width to use when rendering outline */
  24589. outlineWidth: number;
  24590. /** Defines color to use when rendering overlay */
  24591. overlayColor: Color3;
  24592. /** Defines alpha to use when rendering overlay */
  24593. overlayAlpha: number;
  24594. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24595. hasVertexAlpha: boolean;
  24596. /** 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) */
  24597. useVertexColors: boolean;
  24598. /**
  24599. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24600. */
  24601. computeBonesUsingShaders: boolean;
  24602. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24603. numBoneInfluencers: number;
  24604. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24605. applyFog: boolean;
  24606. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24607. useOctreeForRenderingSelection: boolean;
  24608. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24609. useOctreeForPicking: boolean;
  24610. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24611. useOctreeForCollisions: boolean;
  24612. /**
  24613. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24614. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24615. */
  24616. layerMask: number;
  24617. /**
  24618. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24619. */
  24620. alwaysSelectAsActiveMesh: boolean;
  24621. /**
  24622. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24623. */
  24624. doNotSyncBoundingInfo: boolean;
  24625. /**
  24626. * Gets or sets the current action manager
  24627. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24628. */
  24629. actionManager: Nullable<AbstractActionManager>;
  24630. private _meshCollisionData;
  24631. /**
  24632. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24633. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24634. */
  24635. ellipsoid: Vector3;
  24636. /**
  24637. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24638. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24639. */
  24640. ellipsoidOffset: Vector3;
  24641. /**
  24642. * Gets or sets a collision mask used to mask collisions (default is -1).
  24643. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24644. */
  24645. collisionMask: number;
  24646. /**
  24647. * Gets or sets the current collision group mask (-1 by default).
  24648. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24649. */
  24650. collisionGroup: number;
  24651. /**
  24652. * Defines edge width used when edgesRenderer is enabled
  24653. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24654. */
  24655. edgesWidth: number;
  24656. /**
  24657. * Defines edge color used when edgesRenderer is enabled
  24658. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24659. */
  24660. edgesColor: Color4;
  24661. /** @hidden */
  24662. _edgesRenderer: Nullable<IEdgesRenderer>;
  24663. /** @hidden */
  24664. _masterMesh: Nullable<AbstractMesh>;
  24665. /** @hidden */
  24666. _boundingInfo: Nullable<BoundingInfo>;
  24667. /** @hidden */
  24668. _renderId: number;
  24669. /**
  24670. * Gets or sets the list of subMeshes
  24671. * @see http://doc.babylonjs.com/how_to/multi_materials
  24672. */
  24673. subMeshes: SubMesh[];
  24674. /** @hidden */
  24675. _intersectionsInProgress: AbstractMesh[];
  24676. /** @hidden */
  24677. _unIndexed: boolean;
  24678. /** @hidden */
  24679. _lightSources: Light[];
  24680. /** Gets the list of lights affecting that mesh */
  24681. readonly lightSources: Light[];
  24682. /** @hidden */
  24683. readonly _positions: Nullable<Vector3[]>;
  24684. /** @hidden */
  24685. _waitingData: {
  24686. lods: Nullable<any>;
  24687. actions: Nullable<any>;
  24688. freezeWorldMatrix: Nullable<boolean>;
  24689. };
  24690. /** @hidden */
  24691. _bonesTransformMatrices: Nullable<Float32Array>;
  24692. /**
  24693. * Gets or sets a skeleton to apply skining transformations
  24694. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24695. */
  24696. skeleton: Nullable<Skeleton>;
  24697. /**
  24698. * An event triggered when the mesh is rebuilt.
  24699. */
  24700. onRebuildObservable: Observable<AbstractMesh>;
  24701. /**
  24702. * Creates a new AbstractMesh
  24703. * @param name defines the name of the mesh
  24704. * @param scene defines the hosting scene
  24705. */
  24706. constructor(name: string, scene?: Nullable<Scene>);
  24707. /**
  24708. * Returns the string "AbstractMesh"
  24709. * @returns "AbstractMesh"
  24710. */
  24711. getClassName(): string;
  24712. /**
  24713. * Gets a string representation of the current mesh
  24714. * @param fullDetails defines a boolean indicating if full details must be included
  24715. * @returns a string representation of the current mesh
  24716. */
  24717. toString(fullDetails?: boolean): string;
  24718. /**
  24719. * @hidden
  24720. */
  24721. protected _getEffectiveParent(): Nullable<Node>;
  24722. /** @hidden */
  24723. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24724. /** @hidden */
  24725. _rebuild(): void;
  24726. /** @hidden */
  24727. _resyncLightSources(): void;
  24728. /** @hidden */
  24729. _resyncLighSource(light: Light): void;
  24730. /** @hidden */
  24731. _unBindEffect(): void;
  24732. /** @hidden */
  24733. _removeLightSource(light: Light): void;
  24734. private _markSubMeshesAsDirty;
  24735. /** @hidden */
  24736. _markSubMeshesAsLightDirty(): void;
  24737. /** @hidden */
  24738. _markSubMeshesAsAttributesDirty(): void;
  24739. /** @hidden */
  24740. _markSubMeshesAsMiscDirty(): void;
  24741. /**
  24742. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24743. */
  24744. scaling: Vector3;
  24745. /**
  24746. * Returns true if the mesh is blocked. Implemented by child classes
  24747. */
  24748. readonly isBlocked: boolean;
  24749. /**
  24750. * Returns the mesh itself by default. Implemented by child classes
  24751. * @param camera defines the camera to use to pick the right LOD level
  24752. * @returns the currentAbstractMesh
  24753. */
  24754. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24755. /**
  24756. * Returns 0 by default. Implemented by child classes
  24757. * @returns an integer
  24758. */
  24759. getTotalVertices(): number;
  24760. /**
  24761. * Returns a positive integer : the total number of indices in this mesh geometry.
  24762. * @returns the numner of indices or zero if the mesh has no geometry.
  24763. */
  24764. getTotalIndices(): number;
  24765. /**
  24766. * Returns null by default. Implemented by child classes
  24767. * @returns null
  24768. */
  24769. getIndices(): Nullable<IndicesArray>;
  24770. /**
  24771. * Returns the array of the requested vertex data kind. Implemented by child classes
  24772. * @param kind defines the vertex data kind to use
  24773. * @returns null
  24774. */
  24775. getVerticesData(kind: string): Nullable<FloatArray>;
  24776. /**
  24777. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24778. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24779. * Note that a new underlying VertexBuffer object is created each call.
  24780. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24781. * @param kind defines vertex data kind:
  24782. * * VertexBuffer.PositionKind
  24783. * * VertexBuffer.UVKind
  24784. * * VertexBuffer.UV2Kind
  24785. * * VertexBuffer.UV3Kind
  24786. * * VertexBuffer.UV4Kind
  24787. * * VertexBuffer.UV5Kind
  24788. * * VertexBuffer.UV6Kind
  24789. * * VertexBuffer.ColorKind
  24790. * * VertexBuffer.MatricesIndicesKind
  24791. * * VertexBuffer.MatricesIndicesExtraKind
  24792. * * VertexBuffer.MatricesWeightsKind
  24793. * * VertexBuffer.MatricesWeightsExtraKind
  24794. * @param data defines the data source
  24795. * @param updatable defines if the data must be flagged as updatable (or static)
  24796. * @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
  24797. * @returns the current mesh
  24798. */
  24799. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24800. /**
  24801. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24802. * If the mesh has no geometry, it is simply returned as it is.
  24803. * @param kind defines vertex data kind:
  24804. * * VertexBuffer.PositionKind
  24805. * * VertexBuffer.UVKind
  24806. * * VertexBuffer.UV2Kind
  24807. * * VertexBuffer.UV3Kind
  24808. * * VertexBuffer.UV4Kind
  24809. * * VertexBuffer.UV5Kind
  24810. * * VertexBuffer.UV6Kind
  24811. * * VertexBuffer.ColorKind
  24812. * * VertexBuffer.MatricesIndicesKind
  24813. * * VertexBuffer.MatricesIndicesExtraKind
  24814. * * VertexBuffer.MatricesWeightsKind
  24815. * * VertexBuffer.MatricesWeightsExtraKind
  24816. * @param data defines the data source
  24817. * @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
  24818. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24819. * @returns the current mesh
  24820. */
  24821. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24822. /**
  24823. * Sets the mesh indices,
  24824. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24825. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24826. * @param totalVertices Defines the total number of vertices
  24827. * @returns the current mesh
  24828. */
  24829. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24830. /**
  24831. * Gets a boolean indicating if specific vertex data is present
  24832. * @param kind defines the vertex data kind to use
  24833. * @returns true is data kind is present
  24834. */
  24835. isVerticesDataPresent(kind: string): boolean;
  24836. /**
  24837. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24838. * @returns a BoundingInfo
  24839. */
  24840. getBoundingInfo(): BoundingInfo;
  24841. /**
  24842. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24843. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24844. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24845. * @returns the current mesh
  24846. */
  24847. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24848. /**
  24849. * Overwrite the current bounding info
  24850. * @param boundingInfo defines the new bounding info
  24851. * @returns the current mesh
  24852. */
  24853. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24854. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24855. readonly useBones: boolean;
  24856. /** @hidden */
  24857. _preActivate(): void;
  24858. /** @hidden */
  24859. _preActivateForIntermediateRendering(renderId: number): void;
  24860. /** @hidden */
  24861. _activate(renderId: number, intermediateRendering: boolean): boolean;
  24862. /** @hidden */
  24863. _postActivate(): void;
  24864. /** @hidden */
  24865. _freeze(): void;
  24866. /** @hidden */
  24867. _unFreeze(): void;
  24868. /**
  24869. * Gets the current world matrix
  24870. * @returns a Matrix
  24871. */
  24872. getWorldMatrix(): Matrix;
  24873. /** @hidden */
  24874. _getWorldMatrixDeterminant(): number;
  24875. /**
  24876. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24877. */
  24878. readonly isAnInstance: boolean;
  24879. /**
  24880. * Perform relative position change from the point of view of behind the front of the mesh.
  24881. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24882. * Supports definition of mesh facing forward or backward
  24883. * @param amountRight defines the distance on the right axis
  24884. * @param amountUp defines the distance on the up axis
  24885. * @param amountForward defines the distance on the forward axis
  24886. * @returns the current mesh
  24887. */
  24888. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24889. /**
  24890. * Calculate relative position change from the point of view of behind the front of the mesh.
  24891. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24892. * Supports definition of mesh facing forward or backward
  24893. * @param amountRight defines the distance on the right axis
  24894. * @param amountUp defines the distance on the up axis
  24895. * @param amountForward defines the distance on the forward axis
  24896. * @returns the new displacement vector
  24897. */
  24898. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24899. /**
  24900. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24901. * Supports definition of mesh facing forward or backward
  24902. * @param flipBack defines the flip
  24903. * @param twirlClockwise defines the twirl
  24904. * @param tiltRight defines the tilt
  24905. * @returns the current mesh
  24906. */
  24907. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24908. /**
  24909. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24910. * Supports definition of mesh facing forward or backward.
  24911. * @param flipBack defines the flip
  24912. * @param twirlClockwise defines the twirl
  24913. * @param tiltRight defines the tilt
  24914. * @returns the new rotation vector
  24915. */
  24916. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24917. /**
  24918. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24919. * This means the mesh underlying bounding box and sphere are recomputed.
  24920. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24921. * @returns the current mesh
  24922. */
  24923. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24924. /** @hidden */
  24925. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24926. /** @hidden */
  24927. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24928. /** @hidden */
  24929. _updateBoundingInfo(): AbstractMesh;
  24930. /** @hidden */
  24931. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24932. /** @hidden */
  24933. protected _afterComputeWorldMatrix(): void;
  24934. /** @hidden */
  24935. readonly _effectiveMesh: AbstractMesh;
  24936. /**
  24937. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24938. * A mesh is in the frustum if its bounding box intersects the frustum
  24939. * @param frustumPlanes defines the frustum to test
  24940. * @returns true if the mesh is in the frustum planes
  24941. */
  24942. isInFrustum(frustumPlanes: Plane[]): boolean;
  24943. /**
  24944. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24945. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24946. * @param frustumPlanes defines the frustum to test
  24947. * @returns true if the mesh is completely in the frustum planes
  24948. */
  24949. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24950. /**
  24951. * True if the mesh intersects another mesh or a SolidParticle object
  24952. * @param mesh defines a target mesh or SolidParticle to test
  24953. * @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)
  24954. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24955. * @returns true if there is an intersection
  24956. */
  24957. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24958. /**
  24959. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24960. * @param point defines the point to test
  24961. * @returns true if there is an intersection
  24962. */
  24963. intersectsPoint(point: Vector3): boolean;
  24964. /**
  24965. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24966. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24967. */
  24968. checkCollisions: boolean;
  24969. /**
  24970. * Gets Collider object used to compute collisions (not physics)
  24971. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24972. */
  24973. readonly collider: Nullable<Collider>;
  24974. /**
  24975. * Move the mesh using collision engine
  24976. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24977. * @param displacement defines the requested displacement vector
  24978. * @returns the current mesh
  24979. */
  24980. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24981. private _onCollisionPositionChange;
  24982. /** @hidden */
  24983. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24984. /** @hidden */
  24985. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24986. /** @hidden */
  24987. _checkCollision(collider: Collider): AbstractMesh;
  24988. /** @hidden */
  24989. _generatePointsArray(): boolean;
  24990. /**
  24991. * Checks if the passed Ray intersects with the mesh
  24992. * @param ray defines the ray to use
  24993. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24994. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24995. * @returns the picking info
  24996. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24997. */
  24998. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24999. /**
  25000. * Clones the current mesh
  25001. * @param name defines the mesh name
  25002. * @param newParent defines the new mesh parent
  25003. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25004. * @returns the new mesh
  25005. */
  25006. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25007. /**
  25008. * Disposes all the submeshes of the current meshnp
  25009. * @returns the current mesh
  25010. */
  25011. releaseSubMeshes(): AbstractMesh;
  25012. /**
  25013. * Releases resources associated with this abstract mesh.
  25014. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25015. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25016. */
  25017. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25018. /**
  25019. * Adds the passed mesh as a child to the current mesh
  25020. * @param mesh defines the child mesh
  25021. * @returns the current mesh
  25022. */
  25023. addChild(mesh: AbstractMesh): AbstractMesh;
  25024. /**
  25025. * Removes the passed mesh from the current mesh children list
  25026. * @param mesh defines the child mesh
  25027. * @returns the current mesh
  25028. */
  25029. removeChild(mesh: AbstractMesh): AbstractMesh;
  25030. /** @hidden */
  25031. private _initFacetData;
  25032. /**
  25033. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25034. * This method can be called within the render loop.
  25035. * 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
  25036. * @returns the current mesh
  25037. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25038. */
  25039. updateFacetData(): AbstractMesh;
  25040. /**
  25041. * Returns the facetLocalNormals array.
  25042. * The normals are expressed in the mesh local spac
  25043. * @returns an array of Vector3
  25044. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25045. */
  25046. getFacetLocalNormals(): Vector3[];
  25047. /**
  25048. * Returns the facetLocalPositions array.
  25049. * The facet positions are expressed in the mesh local space
  25050. * @returns an array of Vector3
  25051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25052. */
  25053. getFacetLocalPositions(): Vector3[];
  25054. /**
  25055. * Returns the facetLocalPartioning array
  25056. * @returns an array of array of numbers
  25057. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25058. */
  25059. getFacetLocalPartitioning(): number[][];
  25060. /**
  25061. * Returns the i-th facet position in the world system.
  25062. * This method allocates a new Vector3 per call
  25063. * @param i defines the facet index
  25064. * @returns a new Vector3
  25065. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25066. */
  25067. getFacetPosition(i: number): Vector3;
  25068. /**
  25069. * Sets the reference Vector3 with the i-th facet position in the world system
  25070. * @param i defines the facet index
  25071. * @param ref defines the target vector
  25072. * @returns the current mesh
  25073. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25074. */
  25075. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25076. /**
  25077. * Returns the i-th facet normal in the world system.
  25078. * This method allocates a new Vector3 per call
  25079. * @param i defines the facet index
  25080. * @returns a new Vector3
  25081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25082. */
  25083. getFacetNormal(i: number): Vector3;
  25084. /**
  25085. * Sets the reference Vector3 with the i-th facet normal in the world system
  25086. * @param i defines the facet index
  25087. * @param ref defines the target vector
  25088. * @returns the current mesh
  25089. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25090. */
  25091. getFacetNormalToRef(i: number, ref: Vector3): this;
  25092. /**
  25093. * 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)
  25094. * @param x defines x coordinate
  25095. * @param y defines y coordinate
  25096. * @param z defines z coordinate
  25097. * @returns the array of facet indexes
  25098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25099. */
  25100. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25101. /**
  25102. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25103. * @param projected sets as the (x,y,z) world projection on the facet
  25104. * @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
  25105. * @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
  25106. * @param x defines x coordinate
  25107. * @param y defines y coordinate
  25108. * @param z defines z coordinate
  25109. * @returns the face index if found (or null instead)
  25110. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25111. */
  25112. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25113. /**
  25114. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25115. * @param projected sets as the (x,y,z) local projection on the facet
  25116. * @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
  25117. * @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
  25118. * @param x defines x coordinate
  25119. * @param y defines y coordinate
  25120. * @param z defines z coordinate
  25121. * @returns the face index if found (or null instead)
  25122. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25123. */
  25124. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25125. /**
  25126. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25127. * @returns the parameters
  25128. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25129. */
  25130. getFacetDataParameters(): any;
  25131. /**
  25132. * Disables the feature FacetData and frees the related memory
  25133. * @returns the current mesh
  25134. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25135. */
  25136. disableFacetData(): AbstractMesh;
  25137. /**
  25138. * Updates the AbstractMesh indices array
  25139. * @param indices defines the data source
  25140. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25141. * @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)
  25142. * @returns the current mesh
  25143. */
  25144. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25145. /**
  25146. * Creates new normals data for the mesh
  25147. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25148. * @returns the current mesh
  25149. */
  25150. createNormals(updatable: boolean): AbstractMesh;
  25151. /**
  25152. * Align the mesh with a normal
  25153. * @param normal defines the normal to use
  25154. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25155. * @returns the current mesh
  25156. */
  25157. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25158. /** @hidden */
  25159. _checkOcclusionQuery(): boolean;
  25160. /**
  25161. * Disables the mesh edge rendering mode
  25162. * @returns the currentAbstractMesh
  25163. */
  25164. disableEdgesRendering(): AbstractMesh;
  25165. /**
  25166. * Enables the edge rendering mode on the mesh.
  25167. * This mode makes the mesh edges visible
  25168. * @param epsilon defines the maximal distance between two angles to detect a face
  25169. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25170. * @returns the currentAbstractMesh
  25171. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25172. */
  25173. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25174. }
  25175. }
  25176. declare module BABYLON {
  25177. /**
  25178. * Interface used to define ActionEvent
  25179. */
  25180. export interface IActionEvent {
  25181. /** The mesh or sprite that triggered the action */
  25182. source: any;
  25183. /** The X mouse cursor position at the time of the event */
  25184. pointerX: number;
  25185. /** The Y mouse cursor position at the time of the event */
  25186. pointerY: number;
  25187. /** The mesh that is currently pointed at (can be null) */
  25188. meshUnderPointer: Nullable<AbstractMesh>;
  25189. /** the original (browser) event that triggered the ActionEvent */
  25190. sourceEvent?: any;
  25191. /** additional data for the event */
  25192. additionalData?: any;
  25193. }
  25194. /**
  25195. * ActionEvent is the event being sent when an action is triggered.
  25196. */
  25197. export class ActionEvent implements IActionEvent {
  25198. /** The mesh or sprite that triggered the action */
  25199. source: any;
  25200. /** The X mouse cursor position at the time of the event */
  25201. pointerX: number;
  25202. /** The Y mouse cursor position at the time of the event */
  25203. pointerY: number;
  25204. /** The mesh that is currently pointed at (can be null) */
  25205. meshUnderPointer: Nullable<AbstractMesh>;
  25206. /** the original (browser) event that triggered the ActionEvent */
  25207. sourceEvent?: any;
  25208. /** additional data for the event */
  25209. additionalData?: any;
  25210. /**
  25211. * Creates a new ActionEvent
  25212. * @param source The mesh or sprite that triggered the action
  25213. * @param pointerX The X mouse cursor position at the time of the event
  25214. * @param pointerY The Y mouse cursor position at the time of the event
  25215. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25216. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25217. * @param additionalData additional data for the event
  25218. */
  25219. constructor(
  25220. /** The mesh or sprite that triggered the action */
  25221. source: any,
  25222. /** The X mouse cursor position at the time of the event */
  25223. pointerX: number,
  25224. /** The Y mouse cursor position at the time of the event */
  25225. pointerY: number,
  25226. /** The mesh that is currently pointed at (can be null) */
  25227. meshUnderPointer: Nullable<AbstractMesh>,
  25228. /** the original (browser) event that triggered the ActionEvent */
  25229. sourceEvent?: any,
  25230. /** additional data for the event */
  25231. additionalData?: any);
  25232. /**
  25233. * Helper function to auto-create an ActionEvent from a source mesh.
  25234. * @param source The source mesh that triggered the event
  25235. * @param evt The original (browser) event
  25236. * @param additionalData additional data for the event
  25237. * @returns the new ActionEvent
  25238. */
  25239. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25240. /**
  25241. * Helper function to auto-create an ActionEvent from a source sprite
  25242. * @param source The source sprite that triggered the event
  25243. * @param scene Scene associated with the sprite
  25244. * @param evt The original (browser) event
  25245. * @param additionalData additional data for the event
  25246. * @returns the new ActionEvent
  25247. */
  25248. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25249. /**
  25250. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25251. * @param scene the scene where the event occurred
  25252. * @param evt The original (browser) event
  25253. * @returns the new ActionEvent
  25254. */
  25255. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25256. /**
  25257. * Helper function to auto-create an ActionEvent from a primitive
  25258. * @param prim defines the target primitive
  25259. * @param pointerPos defines the pointer position
  25260. * @param evt The original (browser) event
  25261. * @param additionalData additional data for the event
  25262. * @returns the new ActionEvent
  25263. */
  25264. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25265. }
  25266. }
  25267. declare module BABYLON {
  25268. /**
  25269. * Abstract class used to decouple action Manager from scene and meshes.
  25270. * Do not instantiate.
  25271. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25272. */
  25273. export abstract class AbstractActionManager implements IDisposable {
  25274. /** Gets the list of active triggers */
  25275. static Triggers: {
  25276. [key: string]: number;
  25277. };
  25278. /** Gets the cursor to use when hovering items */
  25279. hoverCursor: string;
  25280. /** Gets the list of actions */
  25281. actions: IAction[];
  25282. /**
  25283. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25284. */
  25285. isRecursive: boolean;
  25286. /**
  25287. * Releases all associated resources
  25288. */
  25289. abstract dispose(): void;
  25290. /**
  25291. * Does this action manager has pointer triggers
  25292. */
  25293. abstract readonly hasPointerTriggers: boolean;
  25294. /**
  25295. * Does this action manager has pick triggers
  25296. */
  25297. abstract readonly hasPickTriggers: boolean;
  25298. /**
  25299. * Process a specific trigger
  25300. * @param trigger defines the trigger to process
  25301. * @param evt defines the event details to be processed
  25302. */
  25303. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25304. /**
  25305. * Does this action manager handles actions of any of the given triggers
  25306. * @param triggers defines the triggers to be tested
  25307. * @return a boolean indicating whether one (or more) of the triggers is handled
  25308. */
  25309. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25310. /**
  25311. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25312. * speed.
  25313. * @param triggerA defines the trigger to be tested
  25314. * @param triggerB defines the trigger to be tested
  25315. * @return a boolean indicating whether one (or more) of the triggers is handled
  25316. */
  25317. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25318. /**
  25319. * Does this action manager handles actions of a given trigger
  25320. * @param trigger defines the trigger to be tested
  25321. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25322. * @return whether the trigger is handled
  25323. */
  25324. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25325. /**
  25326. * Serialize this manager to a JSON object
  25327. * @param name defines the property name to store this manager
  25328. * @returns a JSON representation of this manager
  25329. */
  25330. abstract serialize(name: string): any;
  25331. /**
  25332. * Registers an action to this action manager
  25333. * @param action defines the action to be registered
  25334. * @return the action amended (prepared) after registration
  25335. */
  25336. abstract registerAction(action: IAction): Nullable<IAction>;
  25337. /**
  25338. * Unregisters an action to this action manager
  25339. * @param action defines the action to be unregistered
  25340. * @return a boolean indicating whether the action has been unregistered
  25341. */
  25342. abstract unregisterAction(action: IAction): Boolean;
  25343. /**
  25344. * Does exist one action manager with at least one trigger
  25345. **/
  25346. static readonly HasTriggers: boolean;
  25347. /**
  25348. * Does exist one action manager with at least one pick trigger
  25349. **/
  25350. static readonly HasPickTriggers: boolean;
  25351. /**
  25352. * Does exist one action manager that handles actions of a given trigger
  25353. * @param trigger defines the trigger to be tested
  25354. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25355. **/
  25356. static HasSpecificTrigger(trigger: number): boolean;
  25357. }
  25358. }
  25359. declare module BABYLON {
  25360. /**
  25361. * Defines how a node can be built from a string name.
  25362. */
  25363. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25364. /**
  25365. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25366. */
  25367. export class Node implements IBehaviorAware<Node> {
  25368. /** @hidden */
  25369. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25370. private static _NodeConstructors;
  25371. /**
  25372. * Add a new node constructor
  25373. * @param type defines the type name of the node to construct
  25374. * @param constructorFunc defines the constructor function
  25375. */
  25376. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25377. /**
  25378. * Returns a node constructor based on type name
  25379. * @param type defines the type name
  25380. * @param name defines the new node name
  25381. * @param scene defines the hosting scene
  25382. * @param options defines optional options to transmit to constructors
  25383. * @returns the new constructor or null
  25384. */
  25385. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25386. /**
  25387. * Gets or sets the name of the node
  25388. */
  25389. name: string;
  25390. /**
  25391. * Gets or sets the id of the node
  25392. */
  25393. id: string;
  25394. /**
  25395. * Gets or sets the unique id of the node
  25396. */
  25397. uniqueId: number;
  25398. /**
  25399. * Gets or sets a string used to store user defined state for the node
  25400. */
  25401. state: string;
  25402. /**
  25403. * Gets or sets an object used to store user defined information for the node
  25404. */
  25405. metadata: any;
  25406. /**
  25407. * For internal use only. Please do not use.
  25408. */
  25409. reservedDataStore: any;
  25410. /**
  25411. * List of inspectable custom properties (used by the Inspector)
  25412. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25413. */
  25414. inspectableCustomProperties: IInspectable[];
  25415. /**
  25416. * Gets or sets a boolean used to define if the node must be serialized
  25417. */
  25418. doNotSerialize: boolean;
  25419. /** @hidden */
  25420. _isDisposed: boolean;
  25421. /**
  25422. * Gets a list of Animations associated with the node
  25423. */
  25424. animations: Animation[];
  25425. protected _ranges: {
  25426. [name: string]: Nullable<AnimationRange>;
  25427. };
  25428. /**
  25429. * Callback raised when the node is ready to be used
  25430. */
  25431. onReady: Nullable<(node: Node) => void>;
  25432. private _isEnabled;
  25433. private _isParentEnabled;
  25434. private _isReady;
  25435. /** @hidden */
  25436. _currentRenderId: number;
  25437. private _parentUpdateId;
  25438. /** @hidden */
  25439. _childUpdateId: number;
  25440. /** @hidden */
  25441. _waitingParentId: Nullable<string>;
  25442. /** @hidden */
  25443. _scene: Scene;
  25444. /** @hidden */
  25445. _cache: any;
  25446. private _parentNode;
  25447. private _children;
  25448. /** @hidden */
  25449. _worldMatrix: Matrix;
  25450. /** @hidden */
  25451. _worldMatrixDeterminant: number;
  25452. /** @hidden */
  25453. _worldMatrixDeterminantIsDirty: boolean;
  25454. /** @hidden */
  25455. private _sceneRootNodesIndex;
  25456. /**
  25457. * Gets a boolean indicating if the node has been disposed
  25458. * @returns true if the node was disposed
  25459. */
  25460. isDisposed(): boolean;
  25461. /**
  25462. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25463. * @see https://doc.babylonjs.com/how_to/parenting
  25464. */
  25465. parent: Nullable<Node>;
  25466. private addToSceneRootNodes;
  25467. private removeFromSceneRootNodes;
  25468. private _animationPropertiesOverride;
  25469. /**
  25470. * Gets or sets the animation properties override
  25471. */
  25472. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25473. /**
  25474. * Gets a string idenfifying the name of the class
  25475. * @returns "Node" string
  25476. */
  25477. getClassName(): string;
  25478. /** @hidden */
  25479. readonly _isNode: boolean;
  25480. /**
  25481. * An event triggered when the mesh is disposed
  25482. */
  25483. onDisposeObservable: Observable<Node>;
  25484. private _onDisposeObserver;
  25485. /**
  25486. * Sets a callback that will be raised when the node will be disposed
  25487. */
  25488. onDispose: () => void;
  25489. /**
  25490. * Creates a new Node
  25491. * @param name the name and id to be given to this node
  25492. * @param scene the scene this node will be added to
  25493. * @param addToRootNodes the node will be added to scene.rootNodes
  25494. */
  25495. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25496. /**
  25497. * Gets the scene of the node
  25498. * @returns a scene
  25499. */
  25500. getScene(): Scene;
  25501. /**
  25502. * Gets the engine of the node
  25503. * @returns a Engine
  25504. */
  25505. getEngine(): Engine;
  25506. private _behaviors;
  25507. /**
  25508. * Attach a behavior to the node
  25509. * @see http://doc.babylonjs.com/features/behaviour
  25510. * @param behavior defines the behavior to attach
  25511. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25512. * @returns the current Node
  25513. */
  25514. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25515. /**
  25516. * Remove an attached behavior
  25517. * @see http://doc.babylonjs.com/features/behaviour
  25518. * @param behavior defines the behavior to attach
  25519. * @returns the current Node
  25520. */
  25521. removeBehavior(behavior: Behavior<Node>): Node;
  25522. /**
  25523. * Gets the list of attached behaviors
  25524. * @see http://doc.babylonjs.com/features/behaviour
  25525. */
  25526. readonly behaviors: Behavior<Node>[];
  25527. /**
  25528. * Gets an attached behavior by name
  25529. * @param name defines the name of the behavior to look for
  25530. * @see http://doc.babylonjs.com/features/behaviour
  25531. * @returns null if behavior was not found else the requested behavior
  25532. */
  25533. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25534. /**
  25535. * Returns the latest update of the World matrix
  25536. * @returns a Matrix
  25537. */
  25538. getWorldMatrix(): Matrix;
  25539. /** @hidden */
  25540. _getWorldMatrixDeterminant(): number;
  25541. /**
  25542. * Returns directly the latest state of the mesh World matrix.
  25543. * A Matrix is returned.
  25544. */
  25545. readonly worldMatrixFromCache: Matrix;
  25546. /** @hidden */
  25547. _initCache(): void;
  25548. /** @hidden */
  25549. updateCache(force?: boolean): void;
  25550. /** @hidden */
  25551. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25552. /** @hidden */
  25553. _updateCache(ignoreParentClass?: boolean): void;
  25554. /** @hidden */
  25555. _isSynchronized(): boolean;
  25556. /** @hidden */
  25557. _markSyncedWithParent(): void;
  25558. /** @hidden */
  25559. isSynchronizedWithParent(): boolean;
  25560. /** @hidden */
  25561. isSynchronized(): boolean;
  25562. /**
  25563. * Is this node ready to be used/rendered
  25564. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25565. * @return true if the node is ready
  25566. */
  25567. isReady(completeCheck?: boolean): boolean;
  25568. /**
  25569. * Is this node enabled?
  25570. * 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
  25571. * @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
  25572. * @return whether this node (and its parent) is enabled
  25573. */
  25574. isEnabled(checkAncestors?: boolean): boolean;
  25575. /** @hidden */
  25576. protected _syncParentEnabledState(): void;
  25577. /**
  25578. * Set the enabled state of this node
  25579. * @param value defines the new enabled state
  25580. */
  25581. setEnabled(value: boolean): void;
  25582. /**
  25583. * Is this node a descendant of the given node?
  25584. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25585. * @param ancestor defines the parent node to inspect
  25586. * @returns a boolean indicating if this node is a descendant of the given node
  25587. */
  25588. isDescendantOf(ancestor: Node): boolean;
  25589. /** @hidden */
  25590. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25591. /**
  25592. * Will return all nodes that have this node as ascendant
  25593. * @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
  25594. * @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
  25595. * @return all children nodes of all types
  25596. */
  25597. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25598. /**
  25599. * Get all child-meshes of this node
  25600. * @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)
  25601. * @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
  25602. * @returns an array of AbstractMesh
  25603. */
  25604. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25605. /**
  25606. * Get all direct children of this node
  25607. * @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
  25608. * @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)
  25609. * @returns an array of Node
  25610. */
  25611. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25612. /** @hidden */
  25613. _setReady(state: boolean): void;
  25614. /**
  25615. * Get an animation by name
  25616. * @param name defines the name of the animation to look for
  25617. * @returns null if not found else the requested animation
  25618. */
  25619. getAnimationByName(name: string): Nullable<Animation>;
  25620. /**
  25621. * Creates an animation range for this node
  25622. * @param name defines the name of the range
  25623. * @param from defines the starting key
  25624. * @param to defines the end key
  25625. */
  25626. createAnimationRange(name: string, from: number, to: number): void;
  25627. /**
  25628. * Delete a specific animation range
  25629. * @param name defines the name of the range to delete
  25630. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25631. */
  25632. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25633. /**
  25634. * Get an animation range by name
  25635. * @param name defines the name of the animation range to look for
  25636. * @returns null if not found else the requested animation range
  25637. */
  25638. getAnimationRange(name: string): Nullable<AnimationRange>;
  25639. /**
  25640. * Gets the list of all animation ranges defined on this node
  25641. * @returns an array
  25642. */
  25643. getAnimationRanges(): Nullable<AnimationRange>[];
  25644. /**
  25645. * Will start the animation sequence
  25646. * @param name defines the range frames for animation sequence
  25647. * @param loop defines if the animation should loop (false by default)
  25648. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25649. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25650. * @returns the object created for this animation. If range does not exist, it will return null
  25651. */
  25652. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25653. /**
  25654. * Serialize animation ranges into a JSON compatible object
  25655. * @returns serialization object
  25656. */
  25657. serializeAnimationRanges(): any;
  25658. /**
  25659. * Computes the world matrix of the node
  25660. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25661. * @returns the world matrix
  25662. */
  25663. computeWorldMatrix(force?: boolean): Matrix;
  25664. /**
  25665. * Releases resources associated with this node.
  25666. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25667. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25668. */
  25669. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25670. /**
  25671. * Parse animation range data from a serialization object and store them into a given node
  25672. * @param node defines where to store the animation ranges
  25673. * @param parsedNode defines the serialization object to read data from
  25674. * @param scene defines the hosting scene
  25675. */
  25676. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25677. /**
  25678. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25679. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25680. * @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
  25681. * @returns the new bounding vectors
  25682. */
  25683. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25684. min: Vector3;
  25685. max: Vector3;
  25686. };
  25687. }
  25688. }
  25689. declare module BABYLON {
  25690. /**
  25691. * @hidden
  25692. */
  25693. export class _IAnimationState {
  25694. key: number;
  25695. repeatCount: number;
  25696. workValue?: any;
  25697. loopMode?: number;
  25698. offsetValue?: any;
  25699. highLimitValue?: any;
  25700. }
  25701. /**
  25702. * Class used to store any kind of animation
  25703. */
  25704. export class Animation {
  25705. /**Name of the animation */
  25706. name: string;
  25707. /**Property to animate */
  25708. targetProperty: string;
  25709. /**The frames per second of the animation */
  25710. framePerSecond: number;
  25711. /**The data type of the animation */
  25712. dataType: number;
  25713. /**The loop mode of the animation */
  25714. loopMode?: number | undefined;
  25715. /**Specifies if blending should be enabled */
  25716. enableBlending?: boolean | undefined;
  25717. /**
  25718. * Use matrix interpolation instead of using direct key value when animating matrices
  25719. */
  25720. static AllowMatricesInterpolation: boolean;
  25721. /**
  25722. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25723. */
  25724. static AllowMatrixDecomposeForInterpolation: boolean;
  25725. /**
  25726. * Stores the key frames of the animation
  25727. */
  25728. private _keys;
  25729. /**
  25730. * Stores the easing function of the animation
  25731. */
  25732. private _easingFunction;
  25733. /**
  25734. * @hidden Internal use only
  25735. */
  25736. _runtimeAnimations: RuntimeAnimation[];
  25737. /**
  25738. * The set of event that will be linked to this animation
  25739. */
  25740. private _events;
  25741. /**
  25742. * Stores an array of target property paths
  25743. */
  25744. targetPropertyPath: string[];
  25745. /**
  25746. * Stores the blending speed of the animation
  25747. */
  25748. blendingSpeed: number;
  25749. /**
  25750. * Stores the animation ranges for the animation
  25751. */
  25752. private _ranges;
  25753. /**
  25754. * @hidden Internal use
  25755. */
  25756. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25757. /**
  25758. * Sets up an animation
  25759. * @param property The property to animate
  25760. * @param animationType The animation type to apply
  25761. * @param framePerSecond The frames per second of the animation
  25762. * @param easingFunction The easing function used in the animation
  25763. * @returns The created animation
  25764. */
  25765. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25766. /**
  25767. * Create and start an animation on a node
  25768. * @param name defines the name of the global animation that will be run on all nodes
  25769. * @param node defines the root node where the animation will take place
  25770. * @param targetProperty defines property to animate
  25771. * @param framePerSecond defines the number of frame per second yo use
  25772. * @param totalFrame defines the number of frames in total
  25773. * @param from defines the initial value
  25774. * @param to defines the final value
  25775. * @param loopMode defines which loop mode you want to use (off by default)
  25776. * @param easingFunction defines the easing function to use (linear by default)
  25777. * @param onAnimationEnd defines the callback to call when animation end
  25778. * @returns the animatable created for this animation
  25779. */
  25780. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25781. /**
  25782. * Create and start an animation on a node and its descendants
  25783. * @param name defines the name of the global animation that will be run on all nodes
  25784. * @param node defines the root node where the animation will take place
  25785. * @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
  25786. * @param targetProperty defines property to animate
  25787. * @param framePerSecond defines the number of frame per second to use
  25788. * @param totalFrame defines the number of frames in total
  25789. * @param from defines the initial value
  25790. * @param to defines the final value
  25791. * @param loopMode defines which loop mode you want to use (off by default)
  25792. * @param easingFunction defines the easing function to use (linear by default)
  25793. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25794. * @returns the list of animatables created for all nodes
  25795. * @example https://www.babylonjs-playground.com/#MH0VLI
  25796. */
  25797. 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[]>;
  25798. /**
  25799. * Creates a new animation, merges it with the existing animations and starts it
  25800. * @param name Name of the animation
  25801. * @param node Node which contains the scene that begins the animations
  25802. * @param targetProperty Specifies which property to animate
  25803. * @param framePerSecond The frames per second of the animation
  25804. * @param totalFrame The total number of frames
  25805. * @param from The frame at the beginning of the animation
  25806. * @param to The frame at the end of the animation
  25807. * @param loopMode Specifies the loop mode of the animation
  25808. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25809. * @param onAnimationEnd Callback to run once the animation is complete
  25810. * @returns Nullable animation
  25811. */
  25812. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25813. /**
  25814. * Transition property of an host to the target Value
  25815. * @param property The property to transition
  25816. * @param targetValue The target Value of the property
  25817. * @param host The object where the property to animate belongs
  25818. * @param scene Scene used to run the animation
  25819. * @param frameRate Framerate (in frame/s) to use
  25820. * @param transition The transition type we want to use
  25821. * @param duration The duration of the animation, in milliseconds
  25822. * @param onAnimationEnd Callback trigger at the end of the animation
  25823. * @returns Nullable animation
  25824. */
  25825. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25826. /**
  25827. * Return the array of runtime animations currently using this animation
  25828. */
  25829. readonly runtimeAnimations: RuntimeAnimation[];
  25830. /**
  25831. * Specifies if any of the runtime animations are currently running
  25832. */
  25833. readonly hasRunningRuntimeAnimations: boolean;
  25834. /**
  25835. * Initializes the animation
  25836. * @param name Name of the animation
  25837. * @param targetProperty Property to animate
  25838. * @param framePerSecond The frames per second of the animation
  25839. * @param dataType The data type of the animation
  25840. * @param loopMode The loop mode of the animation
  25841. * @param enableBlending Specifies if blending should be enabled
  25842. */
  25843. constructor(
  25844. /**Name of the animation */
  25845. name: string,
  25846. /**Property to animate */
  25847. targetProperty: string,
  25848. /**The frames per second of the animation */
  25849. framePerSecond: number,
  25850. /**The data type of the animation */
  25851. dataType: number,
  25852. /**The loop mode of the animation */
  25853. loopMode?: number | undefined,
  25854. /**Specifies if blending should be enabled */
  25855. enableBlending?: boolean | undefined);
  25856. /**
  25857. * Converts the animation to a string
  25858. * @param fullDetails support for multiple levels of logging within scene loading
  25859. * @returns String form of the animation
  25860. */
  25861. toString(fullDetails?: boolean): string;
  25862. /**
  25863. * Add an event to this animation
  25864. * @param event Event to add
  25865. */
  25866. addEvent(event: AnimationEvent): void;
  25867. /**
  25868. * Remove all events found at the given frame
  25869. * @param frame The frame to remove events from
  25870. */
  25871. removeEvents(frame: number): void;
  25872. /**
  25873. * Retrieves all the events from the animation
  25874. * @returns Events from the animation
  25875. */
  25876. getEvents(): AnimationEvent[];
  25877. /**
  25878. * Creates an animation range
  25879. * @param name Name of the animation range
  25880. * @param from Starting frame of the animation range
  25881. * @param to Ending frame of the animation
  25882. */
  25883. createRange(name: string, from: number, to: number): void;
  25884. /**
  25885. * Deletes an animation range by name
  25886. * @param name Name of the animation range to delete
  25887. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25888. */
  25889. deleteRange(name: string, deleteFrames?: boolean): void;
  25890. /**
  25891. * Gets the animation range by name, or null if not defined
  25892. * @param name Name of the animation range
  25893. * @returns Nullable animation range
  25894. */
  25895. getRange(name: string): Nullable<AnimationRange>;
  25896. /**
  25897. * Gets the key frames from the animation
  25898. * @returns The key frames of the animation
  25899. */
  25900. getKeys(): Array<IAnimationKey>;
  25901. /**
  25902. * Gets the highest frame rate of the animation
  25903. * @returns Highest frame rate of the animation
  25904. */
  25905. getHighestFrame(): number;
  25906. /**
  25907. * Gets the easing function of the animation
  25908. * @returns Easing function of the animation
  25909. */
  25910. getEasingFunction(): IEasingFunction;
  25911. /**
  25912. * Sets the easing function of the animation
  25913. * @param easingFunction A custom mathematical formula for animation
  25914. */
  25915. setEasingFunction(easingFunction: EasingFunction): void;
  25916. /**
  25917. * Interpolates a scalar linearly
  25918. * @param startValue Start value of the animation curve
  25919. * @param endValue End value of the animation curve
  25920. * @param gradient Scalar amount to interpolate
  25921. * @returns Interpolated scalar value
  25922. */
  25923. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25924. /**
  25925. * Interpolates a scalar cubically
  25926. * @param startValue Start value of the animation curve
  25927. * @param outTangent End tangent of the animation
  25928. * @param endValue End value of the animation curve
  25929. * @param inTangent Start tangent of the animation curve
  25930. * @param gradient Scalar amount to interpolate
  25931. * @returns Interpolated scalar value
  25932. */
  25933. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25934. /**
  25935. * Interpolates a quaternion using a spherical linear interpolation
  25936. * @param startValue Start value of the animation curve
  25937. * @param endValue End value of the animation curve
  25938. * @param gradient Scalar amount to interpolate
  25939. * @returns Interpolated quaternion value
  25940. */
  25941. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25942. /**
  25943. * Interpolates a quaternion cubically
  25944. * @param startValue Start value of the animation curve
  25945. * @param outTangent End tangent of the animation curve
  25946. * @param endValue End value of the animation curve
  25947. * @param inTangent Start tangent of the animation curve
  25948. * @param gradient Scalar amount to interpolate
  25949. * @returns Interpolated quaternion value
  25950. */
  25951. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25952. /**
  25953. * Interpolates a Vector3 linearl
  25954. * @param startValue Start value of the animation curve
  25955. * @param endValue End value of the animation curve
  25956. * @param gradient Scalar amount to interpolate
  25957. * @returns Interpolated scalar value
  25958. */
  25959. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25960. /**
  25961. * Interpolates a Vector3 cubically
  25962. * @param startValue Start value of the animation curve
  25963. * @param outTangent End tangent of the animation
  25964. * @param endValue End value of the animation curve
  25965. * @param inTangent Start tangent of the animation curve
  25966. * @param gradient Scalar amount to interpolate
  25967. * @returns InterpolatedVector3 value
  25968. */
  25969. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25970. /**
  25971. * Interpolates a Vector2 linearly
  25972. * @param startValue Start value of the animation curve
  25973. * @param endValue End value of the animation curve
  25974. * @param gradient Scalar amount to interpolate
  25975. * @returns Interpolated Vector2 value
  25976. */
  25977. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25978. /**
  25979. * Interpolates a Vector2 cubically
  25980. * @param startValue Start value of the animation curve
  25981. * @param outTangent End tangent of the animation
  25982. * @param endValue End value of the animation curve
  25983. * @param inTangent Start tangent of the animation curve
  25984. * @param gradient Scalar amount to interpolate
  25985. * @returns Interpolated Vector2 value
  25986. */
  25987. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25988. /**
  25989. * Interpolates a size linearly
  25990. * @param startValue Start value of the animation curve
  25991. * @param endValue End value of the animation curve
  25992. * @param gradient Scalar amount to interpolate
  25993. * @returns Interpolated Size value
  25994. */
  25995. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25996. /**
  25997. * Interpolates a Color3 linearly
  25998. * @param startValue Start value of the animation curve
  25999. * @param endValue End value of the animation curve
  26000. * @param gradient Scalar amount to interpolate
  26001. * @returns Interpolated Color3 value
  26002. */
  26003. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26004. /**
  26005. * @hidden Internal use only
  26006. */
  26007. _getKeyValue(value: any): any;
  26008. /**
  26009. * @hidden Internal use only
  26010. */
  26011. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26012. /**
  26013. * Defines the function to use to interpolate matrices
  26014. * @param startValue defines the start matrix
  26015. * @param endValue defines the end matrix
  26016. * @param gradient defines the gradient between both matrices
  26017. * @param result defines an optional target matrix where to store the interpolation
  26018. * @returns the interpolated matrix
  26019. */
  26020. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26021. /**
  26022. * Makes a copy of the animation
  26023. * @returns Cloned animation
  26024. */
  26025. clone(): Animation;
  26026. /**
  26027. * Sets the key frames of the animation
  26028. * @param values The animation key frames to set
  26029. */
  26030. setKeys(values: Array<IAnimationKey>): void;
  26031. /**
  26032. * Serializes the animation to an object
  26033. * @returns Serialized object
  26034. */
  26035. serialize(): any;
  26036. /**
  26037. * Float animation type
  26038. */
  26039. private static _ANIMATIONTYPE_FLOAT;
  26040. /**
  26041. * Vector3 animation type
  26042. */
  26043. private static _ANIMATIONTYPE_VECTOR3;
  26044. /**
  26045. * Quaternion animation type
  26046. */
  26047. private static _ANIMATIONTYPE_QUATERNION;
  26048. /**
  26049. * Matrix animation type
  26050. */
  26051. private static _ANIMATIONTYPE_MATRIX;
  26052. /**
  26053. * Color3 animation type
  26054. */
  26055. private static _ANIMATIONTYPE_COLOR3;
  26056. /**
  26057. * Vector2 animation type
  26058. */
  26059. private static _ANIMATIONTYPE_VECTOR2;
  26060. /**
  26061. * Size animation type
  26062. */
  26063. private static _ANIMATIONTYPE_SIZE;
  26064. /**
  26065. * Relative Loop Mode
  26066. */
  26067. private static _ANIMATIONLOOPMODE_RELATIVE;
  26068. /**
  26069. * Cycle Loop Mode
  26070. */
  26071. private static _ANIMATIONLOOPMODE_CYCLE;
  26072. /**
  26073. * Constant Loop Mode
  26074. */
  26075. private static _ANIMATIONLOOPMODE_CONSTANT;
  26076. /**
  26077. * Get the float animation type
  26078. */
  26079. static readonly ANIMATIONTYPE_FLOAT: number;
  26080. /**
  26081. * Get the Vector3 animation type
  26082. */
  26083. static readonly ANIMATIONTYPE_VECTOR3: number;
  26084. /**
  26085. * Get the Vector2 animation type
  26086. */
  26087. static readonly ANIMATIONTYPE_VECTOR2: number;
  26088. /**
  26089. * Get the Size animation type
  26090. */
  26091. static readonly ANIMATIONTYPE_SIZE: number;
  26092. /**
  26093. * Get the Quaternion animation type
  26094. */
  26095. static readonly ANIMATIONTYPE_QUATERNION: number;
  26096. /**
  26097. * Get the Matrix animation type
  26098. */
  26099. static readonly ANIMATIONTYPE_MATRIX: number;
  26100. /**
  26101. * Get the Color3 animation type
  26102. */
  26103. static readonly ANIMATIONTYPE_COLOR3: number;
  26104. /**
  26105. * Get the Relative Loop Mode
  26106. */
  26107. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26108. /**
  26109. * Get the Cycle Loop Mode
  26110. */
  26111. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26112. /**
  26113. * Get the Constant Loop Mode
  26114. */
  26115. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26116. /** @hidden */
  26117. static _UniversalLerp(left: any, right: any, amount: number): any;
  26118. /**
  26119. * Parses an animation object and creates an animation
  26120. * @param parsedAnimation Parsed animation object
  26121. * @returns Animation object
  26122. */
  26123. static Parse(parsedAnimation: any): Animation;
  26124. /**
  26125. * Appends the serialized animations from the source animations
  26126. * @param source Source containing the animations
  26127. * @param destination Target to store the animations
  26128. */
  26129. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26130. }
  26131. }
  26132. declare module BABYLON {
  26133. /**
  26134. * Base class of all the textures in babylon.
  26135. * It groups all the common properties the materials, post process, lights... might need
  26136. * in order to make a correct use of the texture.
  26137. */
  26138. export class BaseTexture implements IAnimatable {
  26139. /**
  26140. * Default anisotropic filtering level for the application.
  26141. * It is set to 4 as a good tradeoff between perf and quality.
  26142. */
  26143. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26144. /**
  26145. * Gets or sets the unique id of the texture
  26146. */
  26147. uniqueId: number;
  26148. /**
  26149. * Define the name of the texture.
  26150. */
  26151. name: string;
  26152. /**
  26153. * Gets or sets an object used to store user defined information.
  26154. */
  26155. metadata: any;
  26156. /**
  26157. * For internal use only. Please do not use.
  26158. */
  26159. reservedDataStore: any;
  26160. private _hasAlpha;
  26161. /**
  26162. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26163. */
  26164. hasAlpha: boolean;
  26165. /**
  26166. * Defines if the alpha value should be determined via the rgb values.
  26167. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26168. */
  26169. getAlphaFromRGB: boolean;
  26170. /**
  26171. * Intensity or strength of the texture.
  26172. * It is commonly used by materials to fine tune the intensity of the texture
  26173. */
  26174. level: number;
  26175. /**
  26176. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26177. * This is part of the texture as textures usually maps to one uv set.
  26178. */
  26179. coordinatesIndex: number;
  26180. private _coordinatesMode;
  26181. /**
  26182. * How a texture is mapped.
  26183. *
  26184. * | Value | Type | Description |
  26185. * | ----- | ----------------------------------- | ----------- |
  26186. * | 0 | EXPLICIT_MODE | |
  26187. * | 1 | SPHERICAL_MODE | |
  26188. * | 2 | PLANAR_MODE | |
  26189. * | 3 | CUBIC_MODE | |
  26190. * | 4 | PROJECTION_MODE | |
  26191. * | 5 | SKYBOX_MODE | |
  26192. * | 6 | INVCUBIC_MODE | |
  26193. * | 7 | EQUIRECTANGULAR_MODE | |
  26194. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26195. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26196. */
  26197. coordinatesMode: number;
  26198. /**
  26199. * | Value | Type | Description |
  26200. * | ----- | ------------------ | ----------- |
  26201. * | 0 | CLAMP_ADDRESSMODE | |
  26202. * | 1 | WRAP_ADDRESSMODE | |
  26203. * | 2 | MIRROR_ADDRESSMODE | |
  26204. */
  26205. wrapU: number;
  26206. /**
  26207. * | Value | Type | Description |
  26208. * | ----- | ------------------ | ----------- |
  26209. * | 0 | CLAMP_ADDRESSMODE | |
  26210. * | 1 | WRAP_ADDRESSMODE | |
  26211. * | 2 | MIRROR_ADDRESSMODE | |
  26212. */
  26213. wrapV: number;
  26214. /**
  26215. * | Value | Type | Description |
  26216. * | ----- | ------------------ | ----------- |
  26217. * | 0 | CLAMP_ADDRESSMODE | |
  26218. * | 1 | WRAP_ADDRESSMODE | |
  26219. * | 2 | MIRROR_ADDRESSMODE | |
  26220. */
  26221. wrapR: number;
  26222. /**
  26223. * With compliant hardware and browser (supporting anisotropic filtering)
  26224. * this defines the level of anisotropic filtering in the texture.
  26225. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26226. */
  26227. anisotropicFilteringLevel: number;
  26228. /**
  26229. * Define if the texture is a cube texture or if false a 2d texture.
  26230. */
  26231. isCube: boolean;
  26232. /**
  26233. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26234. */
  26235. is3D: boolean;
  26236. /**
  26237. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26238. * HDR texture are usually stored in linear space.
  26239. * This only impacts the PBR and Background materials
  26240. */
  26241. gammaSpace: boolean;
  26242. /**
  26243. * Gets whether or not the texture contains RGBD data.
  26244. */
  26245. readonly isRGBD: boolean;
  26246. /**
  26247. * Is Z inverted in the texture (useful in a cube texture).
  26248. */
  26249. invertZ: boolean;
  26250. /**
  26251. * Are mip maps generated for this texture or not.
  26252. */
  26253. readonly noMipmap: boolean;
  26254. /**
  26255. * @hidden
  26256. */
  26257. lodLevelInAlpha: boolean;
  26258. /**
  26259. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26260. */
  26261. lodGenerationOffset: number;
  26262. /**
  26263. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26264. */
  26265. lodGenerationScale: number;
  26266. /**
  26267. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  26268. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  26269. * average roughness values.
  26270. */
  26271. linearSpecularLOD: boolean;
  26272. /**
  26273. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  26274. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  26275. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  26276. */
  26277. irradianceTexture: Nullable<BaseTexture>;
  26278. /**
  26279. * Define if the texture is a render target.
  26280. */
  26281. isRenderTarget: boolean;
  26282. /**
  26283. * Define the unique id of the texture in the scene.
  26284. */
  26285. readonly uid: string;
  26286. /**
  26287. * Return a string representation of the texture.
  26288. * @returns the texture as a string
  26289. */
  26290. toString(): string;
  26291. /**
  26292. * Get the class name of the texture.
  26293. * @returns "BaseTexture"
  26294. */
  26295. getClassName(): string;
  26296. /**
  26297. * Define the list of animation attached to the texture.
  26298. */
  26299. animations: Animation[];
  26300. /**
  26301. * An event triggered when the texture is disposed.
  26302. */
  26303. onDisposeObservable: Observable<BaseTexture>;
  26304. private _onDisposeObserver;
  26305. /**
  26306. * Callback triggered when the texture has been disposed.
  26307. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26308. */
  26309. onDispose: () => void;
  26310. /**
  26311. * Define the current state of the loading sequence when in delayed load mode.
  26312. */
  26313. delayLoadState: number;
  26314. private _scene;
  26315. /** @hidden */
  26316. _texture: Nullable<InternalTexture>;
  26317. private _uid;
  26318. /**
  26319. * Define if the texture is preventinga material to render or not.
  26320. * If not and the texture is not ready, the engine will use a default black texture instead.
  26321. */
  26322. readonly isBlocking: boolean;
  26323. /**
  26324. * Instantiates a new BaseTexture.
  26325. * Base class of all the textures in babylon.
  26326. * It groups all the common properties the materials, post process, lights... might need
  26327. * in order to make a correct use of the texture.
  26328. * @param scene Define the scene the texture blongs to
  26329. */
  26330. constructor(scene: Nullable<Scene>);
  26331. /**
  26332. * Get the scene the texture belongs to.
  26333. * @returns the scene or null if undefined
  26334. */
  26335. getScene(): Nullable<Scene>;
  26336. /**
  26337. * Get the texture transform matrix used to offset tile the texture for istance.
  26338. * @returns the transformation matrix
  26339. */
  26340. getTextureMatrix(): Matrix;
  26341. /**
  26342. * Get the texture reflection matrix used to rotate/transform the reflection.
  26343. * @returns the reflection matrix
  26344. */
  26345. getReflectionTextureMatrix(): Matrix;
  26346. /**
  26347. * Get the underlying lower level texture from Babylon.
  26348. * @returns the insternal texture
  26349. */
  26350. getInternalTexture(): Nullable<InternalTexture>;
  26351. /**
  26352. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26353. * @returns true if ready or not blocking
  26354. */
  26355. isReadyOrNotBlocking(): boolean;
  26356. /**
  26357. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26358. * @returns true if fully ready
  26359. */
  26360. isReady(): boolean;
  26361. private _cachedSize;
  26362. /**
  26363. * Get the size of the texture.
  26364. * @returns the texture size.
  26365. */
  26366. getSize(): ISize;
  26367. /**
  26368. * Get the base size of the texture.
  26369. * It can be different from the size if the texture has been resized for POT for instance
  26370. * @returns the base size
  26371. */
  26372. getBaseSize(): ISize;
  26373. /**
  26374. * Update the sampling mode of the texture.
  26375. * Default is Trilinear mode.
  26376. *
  26377. * | Value | Type | Description |
  26378. * | ----- | ------------------ | ----------- |
  26379. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26380. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26381. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26382. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26383. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26384. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26385. * | 7 | NEAREST_LINEAR | |
  26386. * | 8 | NEAREST_NEAREST | |
  26387. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26388. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26389. * | 11 | LINEAR_LINEAR | |
  26390. * | 12 | LINEAR_NEAREST | |
  26391. *
  26392. * > _mag_: magnification filter (close to the viewer)
  26393. * > _min_: minification filter (far from the viewer)
  26394. * > _mip_: filter used between mip map levels
  26395. *@param samplingMode Define the new sampling mode of the texture
  26396. */
  26397. updateSamplingMode(samplingMode: number): void;
  26398. /**
  26399. * Scales the texture if is `canRescale()`
  26400. * @param ratio the resize factor we want to use to rescale
  26401. */
  26402. scale(ratio: number): void;
  26403. /**
  26404. * Get if the texture can rescale.
  26405. */
  26406. readonly canRescale: boolean;
  26407. /** @hidden */
  26408. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26409. /** @hidden */
  26410. _rebuild(): void;
  26411. /**
  26412. * Triggers the load sequence in delayed load mode.
  26413. */
  26414. delayLoad(): void;
  26415. /**
  26416. * Clones the texture.
  26417. * @returns the cloned texture
  26418. */
  26419. clone(): Nullable<BaseTexture>;
  26420. /**
  26421. * Get the texture underlying type (INT, FLOAT...)
  26422. */
  26423. readonly textureType: number;
  26424. /**
  26425. * Get the texture underlying format (RGB, RGBA...)
  26426. */
  26427. readonly textureFormat: number;
  26428. /**
  26429. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26430. * This will returns an RGBA array buffer containing either in values (0-255) or
  26431. * float values (0-1) depending of the underlying buffer type.
  26432. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26433. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26434. * @param buffer defines a user defined buffer to fill with data (can be null)
  26435. * @returns The Array buffer containing the pixels data.
  26436. */
  26437. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26438. /**
  26439. * Release and destroy the underlying lower level texture aka internalTexture.
  26440. */
  26441. releaseInternalTexture(): void;
  26442. /**
  26443. * Get the polynomial representation of the texture data.
  26444. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26445. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26446. */
  26447. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26448. /** @hidden */
  26449. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26450. /** @hidden */
  26451. readonly _lodTextureMid: Nullable<BaseTexture>;
  26452. /** @hidden */
  26453. readonly _lodTextureLow: Nullable<BaseTexture>;
  26454. /**
  26455. * Dispose the texture and release its associated resources.
  26456. */
  26457. dispose(): void;
  26458. /**
  26459. * Serialize the texture into a JSON representation that can be parsed later on.
  26460. * @returns the JSON representation of the texture
  26461. */
  26462. serialize(): any;
  26463. /**
  26464. * Helper function to be called back once a list of texture contains only ready textures.
  26465. * @param textures Define the list of textures to wait for
  26466. * @param callback Define the callback triggered once the entire list will be ready
  26467. */
  26468. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26469. }
  26470. }
  26471. declare module BABYLON {
  26472. /**
  26473. * Uniform buffer objects.
  26474. *
  26475. * Handles blocks of uniform on the GPU.
  26476. *
  26477. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26478. *
  26479. * For more information, please refer to :
  26480. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26481. */
  26482. export class UniformBuffer {
  26483. private _engine;
  26484. private _buffer;
  26485. private _data;
  26486. private _bufferData;
  26487. private _dynamic?;
  26488. private _uniformLocations;
  26489. private _uniformSizes;
  26490. private _uniformLocationPointer;
  26491. private _needSync;
  26492. private _noUBO;
  26493. private _currentEffect;
  26494. private static _MAX_UNIFORM_SIZE;
  26495. private static _tempBuffer;
  26496. /**
  26497. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26498. * This is dynamic to allow compat with webgl 1 and 2.
  26499. * You will need to pass the name of the uniform as well as the value.
  26500. */
  26501. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26502. /**
  26503. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26504. * This is dynamic to allow compat with webgl 1 and 2.
  26505. * You will need to pass the name of the uniform as well as the value.
  26506. */
  26507. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26508. /**
  26509. * Lambda to Update a single float in a uniform buffer.
  26510. * This is dynamic to allow compat with webgl 1 and 2.
  26511. * You will need to pass the name of the uniform as well as the value.
  26512. */
  26513. updateFloat: (name: string, x: number) => void;
  26514. /**
  26515. * Lambda to Update a vec2 of float in a uniform buffer.
  26516. * This is dynamic to allow compat with webgl 1 and 2.
  26517. * You will need to pass the name of the uniform as well as the value.
  26518. */
  26519. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26520. /**
  26521. * Lambda to Update a vec3 of float in a uniform buffer.
  26522. * This is dynamic to allow compat with webgl 1 and 2.
  26523. * You will need to pass the name of the uniform as well as the value.
  26524. */
  26525. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26526. /**
  26527. * Lambda to Update a vec4 of float in a uniform buffer.
  26528. * This is dynamic to allow compat with webgl 1 and 2.
  26529. * You will need to pass the name of the uniform as well as the value.
  26530. */
  26531. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26532. /**
  26533. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26534. * This is dynamic to allow compat with webgl 1 and 2.
  26535. * You will need to pass the name of the uniform as well as the value.
  26536. */
  26537. updateMatrix: (name: string, mat: Matrix) => void;
  26538. /**
  26539. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26540. * This is dynamic to allow compat with webgl 1 and 2.
  26541. * You will need to pass the name of the uniform as well as the value.
  26542. */
  26543. updateVector3: (name: string, vector: Vector3) => void;
  26544. /**
  26545. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26546. * This is dynamic to allow compat with webgl 1 and 2.
  26547. * You will need to pass the name of the uniform as well as the value.
  26548. */
  26549. updateVector4: (name: string, vector: Vector4) => void;
  26550. /**
  26551. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26552. * This is dynamic to allow compat with webgl 1 and 2.
  26553. * You will need to pass the name of the uniform as well as the value.
  26554. */
  26555. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26556. /**
  26557. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26558. * This is dynamic to allow compat with webgl 1 and 2.
  26559. * You will need to pass the name of the uniform as well as the value.
  26560. */
  26561. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26562. /**
  26563. * Instantiates a new Uniform buffer objects.
  26564. *
  26565. * Handles blocks of uniform on the GPU.
  26566. *
  26567. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26568. *
  26569. * For more information, please refer to :
  26570. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26571. * @param engine Define the engine the buffer is associated with
  26572. * @param data Define the data contained in the buffer
  26573. * @param dynamic Define if the buffer is updatable
  26574. */
  26575. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26576. /**
  26577. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26578. * or just falling back on setUniformXXX calls.
  26579. */
  26580. readonly useUbo: boolean;
  26581. /**
  26582. * Indicates if the WebGL underlying uniform buffer is in sync
  26583. * with the javascript cache data.
  26584. */
  26585. readonly isSync: boolean;
  26586. /**
  26587. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26588. * Also, a dynamic UniformBuffer will disable cache verification and always
  26589. * update the underlying WebGL uniform buffer to the GPU.
  26590. * @returns if Dynamic, otherwise false
  26591. */
  26592. isDynamic(): boolean;
  26593. /**
  26594. * The data cache on JS side.
  26595. * @returns the underlying data as a float array
  26596. */
  26597. getData(): Float32Array;
  26598. /**
  26599. * The underlying WebGL Uniform buffer.
  26600. * @returns the webgl buffer
  26601. */
  26602. getBuffer(): Nullable<DataBuffer>;
  26603. /**
  26604. * std140 layout specifies how to align data within an UBO structure.
  26605. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26606. * for specs.
  26607. */
  26608. private _fillAlignment;
  26609. /**
  26610. * Adds an uniform in the buffer.
  26611. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26612. * for the layout to be correct !
  26613. * @param name Name of the uniform, as used in the uniform block in the shader.
  26614. * @param size Data size, or data directly.
  26615. */
  26616. addUniform(name: string, size: number | number[]): void;
  26617. /**
  26618. * Adds a Matrix 4x4 to the uniform buffer.
  26619. * @param name Name of the uniform, as used in the uniform block in the shader.
  26620. * @param mat A 4x4 matrix.
  26621. */
  26622. addMatrix(name: string, mat: Matrix): void;
  26623. /**
  26624. * Adds a vec2 to the uniform buffer.
  26625. * @param name Name of the uniform, as used in the uniform block in the shader.
  26626. * @param x Define the x component value of the vec2
  26627. * @param y Define the y component value of the vec2
  26628. */
  26629. addFloat2(name: string, x: number, y: number): void;
  26630. /**
  26631. * Adds a vec3 to the uniform buffer.
  26632. * @param name Name of the uniform, as used in the uniform block in the shader.
  26633. * @param x Define the x component value of the vec3
  26634. * @param y Define the y component value of the vec3
  26635. * @param z Define the z component value of the vec3
  26636. */
  26637. addFloat3(name: string, x: number, y: number, z: number): void;
  26638. /**
  26639. * Adds a vec3 to the uniform buffer.
  26640. * @param name Name of the uniform, as used in the uniform block in the shader.
  26641. * @param color Define the vec3 from a Color
  26642. */
  26643. addColor3(name: string, color: Color3): void;
  26644. /**
  26645. * Adds a vec4 to the uniform buffer.
  26646. * @param name Name of the uniform, as used in the uniform block in the shader.
  26647. * @param color Define the rgb components from a Color
  26648. * @param alpha Define the a component of the vec4
  26649. */
  26650. addColor4(name: string, color: Color3, alpha: number): void;
  26651. /**
  26652. * Adds a vec3 to the uniform buffer.
  26653. * @param name Name of the uniform, as used in the uniform block in the shader.
  26654. * @param vector Define the vec3 components from a Vector
  26655. */
  26656. addVector3(name: string, vector: Vector3): void;
  26657. /**
  26658. * Adds a Matrix 3x3 to the uniform buffer.
  26659. * @param name Name of the uniform, as used in the uniform block in the shader.
  26660. */
  26661. addMatrix3x3(name: string): void;
  26662. /**
  26663. * Adds a Matrix 2x2 to the uniform buffer.
  26664. * @param name Name of the uniform, as used in the uniform block in the shader.
  26665. */
  26666. addMatrix2x2(name: string): void;
  26667. /**
  26668. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26669. */
  26670. create(): void;
  26671. /** @hidden */
  26672. _rebuild(): void;
  26673. /**
  26674. * Updates the WebGL Uniform Buffer on the GPU.
  26675. * If the `dynamic` flag is set to true, no cache comparison is done.
  26676. * Otherwise, the buffer will be updated only if the cache differs.
  26677. */
  26678. update(): void;
  26679. /**
  26680. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26681. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26682. * @param data Define the flattened data
  26683. * @param size Define the size of the data.
  26684. */
  26685. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26686. private _updateMatrix3x3ForUniform;
  26687. private _updateMatrix3x3ForEffect;
  26688. private _updateMatrix2x2ForEffect;
  26689. private _updateMatrix2x2ForUniform;
  26690. private _updateFloatForEffect;
  26691. private _updateFloatForUniform;
  26692. private _updateFloat2ForEffect;
  26693. private _updateFloat2ForUniform;
  26694. private _updateFloat3ForEffect;
  26695. private _updateFloat3ForUniform;
  26696. private _updateFloat4ForEffect;
  26697. private _updateFloat4ForUniform;
  26698. private _updateMatrixForEffect;
  26699. private _updateMatrixForUniform;
  26700. private _updateVector3ForEffect;
  26701. private _updateVector3ForUniform;
  26702. private _updateVector4ForEffect;
  26703. private _updateVector4ForUniform;
  26704. private _updateColor3ForEffect;
  26705. private _updateColor3ForUniform;
  26706. private _updateColor4ForEffect;
  26707. private _updateColor4ForUniform;
  26708. /**
  26709. * Sets a sampler uniform on the effect.
  26710. * @param name Define the name of the sampler.
  26711. * @param texture Define the texture to set in the sampler
  26712. */
  26713. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26714. /**
  26715. * Directly updates the value of the uniform in the cache AND on the GPU.
  26716. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26717. * @param data Define the flattened data
  26718. */
  26719. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26720. /**
  26721. * Binds this uniform buffer to an effect.
  26722. * @param effect Define the effect to bind the buffer to
  26723. * @param name Name of the uniform block in the shader.
  26724. */
  26725. bindToEffect(effect: Effect, name: string): void;
  26726. /**
  26727. * Disposes the uniform buffer.
  26728. */
  26729. dispose(): void;
  26730. }
  26731. }
  26732. declare module BABYLON {
  26733. /**
  26734. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26735. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26736. */
  26737. export class Analyser {
  26738. /**
  26739. * Gets or sets the smoothing
  26740. * @ignorenaming
  26741. */
  26742. SMOOTHING: number;
  26743. /**
  26744. * Gets or sets the FFT table size
  26745. * @ignorenaming
  26746. */
  26747. FFT_SIZE: number;
  26748. /**
  26749. * Gets or sets the bar graph amplitude
  26750. * @ignorenaming
  26751. */
  26752. BARGRAPHAMPLITUDE: number;
  26753. /**
  26754. * Gets or sets the position of the debug canvas
  26755. * @ignorenaming
  26756. */
  26757. DEBUGCANVASPOS: {
  26758. x: number;
  26759. y: number;
  26760. };
  26761. /**
  26762. * Gets or sets the debug canvas size
  26763. * @ignorenaming
  26764. */
  26765. DEBUGCANVASSIZE: {
  26766. width: number;
  26767. height: number;
  26768. };
  26769. private _byteFreqs;
  26770. private _byteTime;
  26771. private _floatFreqs;
  26772. private _webAudioAnalyser;
  26773. private _debugCanvas;
  26774. private _debugCanvasContext;
  26775. private _scene;
  26776. private _registerFunc;
  26777. private _audioEngine;
  26778. /**
  26779. * Creates a new analyser
  26780. * @param scene defines hosting scene
  26781. */
  26782. constructor(scene: Scene);
  26783. /**
  26784. * Get the number of data values you will have to play with for the visualization
  26785. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26786. * @returns a number
  26787. */
  26788. getFrequencyBinCount(): number;
  26789. /**
  26790. * Gets the current frequency data as a byte array
  26791. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26792. * @returns a Uint8Array
  26793. */
  26794. getByteFrequencyData(): Uint8Array;
  26795. /**
  26796. * Gets the current waveform as a byte array
  26797. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26798. * @returns a Uint8Array
  26799. */
  26800. getByteTimeDomainData(): Uint8Array;
  26801. /**
  26802. * Gets the current frequency data as a float array
  26803. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26804. * @returns a Float32Array
  26805. */
  26806. getFloatFrequencyData(): Float32Array;
  26807. /**
  26808. * Renders the debug canvas
  26809. */
  26810. drawDebugCanvas(): void;
  26811. /**
  26812. * Stops rendering the debug canvas and removes it
  26813. */
  26814. stopDebugCanvas(): void;
  26815. /**
  26816. * Connects two audio nodes
  26817. * @param inputAudioNode defines first node to connect
  26818. * @param outputAudioNode defines second node to connect
  26819. */
  26820. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26821. /**
  26822. * Releases all associated resources
  26823. */
  26824. dispose(): void;
  26825. }
  26826. }
  26827. declare module BABYLON {
  26828. /**
  26829. * This represents an audio engine and it is responsible
  26830. * to play, synchronize and analyse sounds throughout the application.
  26831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26832. */
  26833. export interface IAudioEngine extends IDisposable {
  26834. /**
  26835. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26836. */
  26837. readonly canUseWebAudio: boolean;
  26838. /**
  26839. * Gets the current AudioContext if available.
  26840. */
  26841. readonly audioContext: Nullable<AudioContext>;
  26842. /**
  26843. * The master gain node defines the global audio volume of your audio engine.
  26844. */
  26845. readonly masterGain: GainNode;
  26846. /**
  26847. * Gets whether or not mp3 are supported by your browser.
  26848. */
  26849. readonly isMP3supported: boolean;
  26850. /**
  26851. * Gets whether or not ogg are supported by your browser.
  26852. */
  26853. readonly isOGGsupported: boolean;
  26854. /**
  26855. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26856. * @ignoreNaming
  26857. */
  26858. WarnedWebAudioUnsupported: boolean;
  26859. /**
  26860. * Defines if the audio engine relies on a custom unlocked button.
  26861. * In this case, the embedded button will not be displayed.
  26862. */
  26863. useCustomUnlockedButton: boolean;
  26864. /**
  26865. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26866. */
  26867. readonly unlocked: boolean;
  26868. /**
  26869. * Event raised when audio has been unlocked on the browser.
  26870. */
  26871. onAudioUnlockedObservable: Observable<AudioEngine>;
  26872. /**
  26873. * Event raised when audio has been locked on the browser.
  26874. */
  26875. onAudioLockedObservable: Observable<AudioEngine>;
  26876. /**
  26877. * Flags the audio engine in Locked state.
  26878. * This happens due to new browser policies preventing audio to autoplay.
  26879. */
  26880. lock(): void;
  26881. /**
  26882. * Unlocks the audio engine once a user action has been done on the dom.
  26883. * This is helpful to resume play once browser policies have been satisfied.
  26884. */
  26885. unlock(): void;
  26886. }
  26887. /**
  26888. * This represents the default audio engine used in babylon.
  26889. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26890. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26891. */
  26892. export class AudioEngine implements IAudioEngine {
  26893. private _audioContext;
  26894. private _audioContextInitialized;
  26895. private _muteButton;
  26896. private _hostElement;
  26897. /**
  26898. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26899. */
  26900. canUseWebAudio: boolean;
  26901. /**
  26902. * The master gain node defines the global audio volume of your audio engine.
  26903. */
  26904. masterGain: GainNode;
  26905. /**
  26906. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26907. * @ignoreNaming
  26908. */
  26909. WarnedWebAudioUnsupported: boolean;
  26910. /**
  26911. * Gets whether or not mp3 are supported by your browser.
  26912. */
  26913. isMP3supported: boolean;
  26914. /**
  26915. * Gets whether or not ogg are supported by your browser.
  26916. */
  26917. isOGGsupported: boolean;
  26918. /**
  26919. * Gets whether audio has been unlocked on the device.
  26920. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26921. * a user interaction has happened.
  26922. */
  26923. unlocked: boolean;
  26924. /**
  26925. * Defines if the audio engine relies on a custom unlocked button.
  26926. * In this case, the embedded button will not be displayed.
  26927. */
  26928. useCustomUnlockedButton: boolean;
  26929. /**
  26930. * Event raised when audio has been unlocked on the browser.
  26931. */
  26932. onAudioUnlockedObservable: Observable<AudioEngine>;
  26933. /**
  26934. * Event raised when audio has been locked on the browser.
  26935. */
  26936. onAudioLockedObservable: Observable<AudioEngine>;
  26937. /**
  26938. * Gets the current AudioContext if available.
  26939. */
  26940. readonly audioContext: Nullable<AudioContext>;
  26941. private _connectedAnalyser;
  26942. /**
  26943. * Instantiates a new audio engine.
  26944. *
  26945. * There should be only one per page as some browsers restrict the number
  26946. * of audio contexts you can create.
  26947. * @param hostElement defines the host element where to display the mute icon if necessary
  26948. */
  26949. constructor(hostElement?: Nullable<HTMLElement>);
  26950. /**
  26951. * Flags the audio engine in Locked state.
  26952. * This happens due to new browser policies preventing audio to autoplay.
  26953. */
  26954. lock(): void;
  26955. /**
  26956. * Unlocks the audio engine once a user action has been done on the dom.
  26957. * This is helpful to resume play once browser policies have been satisfied.
  26958. */
  26959. unlock(): void;
  26960. private _resumeAudioContext;
  26961. private _initializeAudioContext;
  26962. private _tryToRun;
  26963. private _triggerRunningState;
  26964. private _triggerSuspendedState;
  26965. private _displayMuteButton;
  26966. private _moveButtonToTopLeft;
  26967. private _onResize;
  26968. private _hideMuteButton;
  26969. /**
  26970. * Destroy and release the resources associated with the audio ccontext.
  26971. */
  26972. dispose(): void;
  26973. /**
  26974. * Gets the global volume sets on the master gain.
  26975. * @returns the global volume if set or -1 otherwise
  26976. */
  26977. getGlobalVolume(): number;
  26978. /**
  26979. * Sets the global volume of your experience (sets on the master gain).
  26980. * @param newVolume Defines the new global volume of the application
  26981. */
  26982. setGlobalVolume(newVolume: number): void;
  26983. /**
  26984. * Connect the audio engine to an audio analyser allowing some amazing
  26985. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26987. * @param analyser The analyser to connect to the engine
  26988. */
  26989. connectToAnalyser(analyser: Analyser): void;
  26990. }
  26991. }
  26992. declare module BABYLON {
  26993. /**
  26994. * Interface used to present a loading screen while loading a scene
  26995. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26996. */
  26997. export interface ILoadingScreen {
  26998. /**
  26999. * Function called to display the loading screen
  27000. */
  27001. displayLoadingUI: () => void;
  27002. /**
  27003. * Function called to hide the loading screen
  27004. */
  27005. hideLoadingUI: () => void;
  27006. /**
  27007. * Gets or sets the color to use for the background
  27008. */
  27009. loadingUIBackgroundColor: string;
  27010. /**
  27011. * Gets or sets the text to display while loading
  27012. */
  27013. loadingUIText: string;
  27014. }
  27015. /**
  27016. * Class used for the default loading screen
  27017. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27018. */
  27019. export class DefaultLoadingScreen implements ILoadingScreen {
  27020. private _renderingCanvas;
  27021. private _loadingText;
  27022. private _loadingDivBackgroundColor;
  27023. private _loadingDiv;
  27024. private _loadingTextDiv;
  27025. /** Gets or sets the logo url to use for the default loading screen */
  27026. static DefaultLogoUrl: string;
  27027. /** Gets or sets the spinner url to use for the default loading screen */
  27028. static DefaultSpinnerUrl: string;
  27029. /**
  27030. * Creates a new default loading screen
  27031. * @param _renderingCanvas defines the canvas used to render the scene
  27032. * @param _loadingText defines the default text to display
  27033. * @param _loadingDivBackgroundColor defines the default background color
  27034. */
  27035. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27036. /**
  27037. * Function called to display the loading screen
  27038. */
  27039. displayLoadingUI(): void;
  27040. /**
  27041. * Function called to hide the loading screen
  27042. */
  27043. hideLoadingUI(): void;
  27044. /**
  27045. * Gets or sets the text to display while loading
  27046. */
  27047. loadingUIText: string;
  27048. /**
  27049. * Gets or sets the color to use for the background
  27050. */
  27051. loadingUIBackgroundColor: string;
  27052. private _resizeLoadingUI;
  27053. }
  27054. }
  27055. declare module BABYLON {
  27056. /** @hidden */
  27057. export class WebGLPipelineContext implements IPipelineContext {
  27058. engine: Engine;
  27059. program: Nullable<WebGLProgram>;
  27060. context?: WebGLRenderingContext;
  27061. vertexShader?: WebGLShader;
  27062. fragmentShader?: WebGLShader;
  27063. isParallelCompiled: boolean;
  27064. onCompiled?: () => void;
  27065. transformFeedback?: WebGLTransformFeedback | null;
  27066. readonly isAsync: boolean;
  27067. readonly isReady: boolean;
  27068. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27069. }
  27070. }
  27071. declare module BABYLON {
  27072. /** @hidden */
  27073. export class WebGLDataBuffer extends DataBuffer {
  27074. private _buffer;
  27075. constructor(resource: WebGLBuffer);
  27076. readonly underlyingResource: any;
  27077. }
  27078. }
  27079. declare module BABYLON {
  27080. /** @hidden */
  27081. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27082. attributeProcessor(attribute: string): string;
  27083. varyingProcessor(varying: string, isFragment: boolean): string;
  27084. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27085. }
  27086. }
  27087. declare module BABYLON {
  27088. /**
  27089. * Settings for finer control over video usage
  27090. */
  27091. export interface VideoTextureSettings {
  27092. /**
  27093. * Applies `autoplay` to video, if specified
  27094. */
  27095. autoPlay?: boolean;
  27096. /**
  27097. * Applies `loop` to video, if specified
  27098. */
  27099. loop?: boolean;
  27100. /**
  27101. * Automatically updates internal texture from video at every frame in the render loop
  27102. */
  27103. autoUpdateTexture: boolean;
  27104. /**
  27105. * Image src displayed during the video loading or until the user interacts with the video.
  27106. */
  27107. poster?: string;
  27108. }
  27109. /**
  27110. * If you want to display a video in your scene, this is the special texture for that.
  27111. * This special texture works similar to other textures, with the exception of a few parameters.
  27112. * @see https://doc.babylonjs.com/how_to/video_texture
  27113. */
  27114. export class VideoTexture extends Texture {
  27115. /**
  27116. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27117. */
  27118. readonly autoUpdateTexture: boolean;
  27119. /**
  27120. * The video instance used by the texture internally
  27121. */
  27122. readonly video: HTMLVideoElement;
  27123. private _onUserActionRequestedObservable;
  27124. /**
  27125. * Event triggerd when a dom action is required by the user to play the video.
  27126. * This happens due to recent changes in browser policies preventing video to auto start.
  27127. */
  27128. readonly onUserActionRequestedObservable: Observable<Texture>;
  27129. private _generateMipMaps;
  27130. private _engine;
  27131. private _stillImageCaptured;
  27132. private _displayingPosterTexture;
  27133. private _settings;
  27134. private _createInternalTextureOnEvent;
  27135. /**
  27136. * Creates a video texture.
  27137. * If you want to display a video in your scene, this is the special texture for that.
  27138. * This special texture works similar to other textures, with the exception of a few parameters.
  27139. * @see https://doc.babylonjs.com/how_to/video_texture
  27140. * @param name optional name, will detect from video source, if not defined
  27141. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27142. * @param scene is obviously the current scene.
  27143. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27144. * @param invertY is false by default but can be used to invert video on Y axis
  27145. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27146. * @param settings allows finer control over video usage
  27147. */
  27148. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27149. private _getName;
  27150. private _getVideo;
  27151. private _createInternalTexture;
  27152. private reset;
  27153. /**
  27154. * @hidden Internal method to initiate `update`.
  27155. */
  27156. _rebuild(): void;
  27157. /**
  27158. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27159. */
  27160. update(): void;
  27161. /**
  27162. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27163. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27164. */
  27165. updateTexture(isVisible: boolean): void;
  27166. protected _updateInternalTexture: () => void;
  27167. /**
  27168. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27169. * @param url New url.
  27170. */
  27171. updateURL(url: string): void;
  27172. /**
  27173. * Dispose the texture and release its associated resources.
  27174. */
  27175. dispose(): void;
  27176. /**
  27177. * Creates a video texture straight from a stream.
  27178. * @param scene Define the scene the texture should be created in
  27179. * @param stream Define the stream the texture should be created from
  27180. * @returns The created video texture as a promise
  27181. */
  27182. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27183. /**
  27184. * Creates a video texture straight from your WebCam video feed.
  27185. * @param scene Define the scene the texture should be created in
  27186. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27187. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27188. * @returns The created video texture as a promise
  27189. */
  27190. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27191. minWidth: number;
  27192. maxWidth: number;
  27193. minHeight: number;
  27194. maxHeight: number;
  27195. deviceId: string;
  27196. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27197. /**
  27198. * Creates a video texture straight from your WebCam video feed.
  27199. * @param scene Define the scene the texture should be created in
  27200. * @param onReady Define a callback to triggered once the texture will be ready
  27201. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27202. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27203. */
  27204. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27205. minWidth: number;
  27206. maxWidth: number;
  27207. minHeight: number;
  27208. maxHeight: number;
  27209. deviceId: string;
  27210. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27211. }
  27212. }
  27213. declare module BABYLON {
  27214. /**
  27215. * Interface for attribute information associated with buffer instanciation
  27216. */
  27217. export class InstancingAttributeInfo {
  27218. /**
  27219. * Index/offset of the attribute in the vertex shader
  27220. */
  27221. index: number;
  27222. /**
  27223. * size of the attribute, 1, 2, 3 or 4
  27224. */
  27225. attributeSize: number;
  27226. /**
  27227. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27228. * default is FLOAT
  27229. */
  27230. attribyteType: number;
  27231. /**
  27232. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27233. */
  27234. normalized: boolean;
  27235. /**
  27236. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27237. */
  27238. offset: number;
  27239. /**
  27240. * Name of the GLSL attribute, for debugging purpose only
  27241. */
  27242. attributeName: string;
  27243. }
  27244. /**
  27245. * Define options used to create a depth texture
  27246. */
  27247. export class DepthTextureCreationOptions {
  27248. /** Specifies whether or not a stencil should be allocated in the texture */
  27249. generateStencil?: boolean;
  27250. /** Specifies whether or not bilinear filtering is enable on the texture */
  27251. bilinearFiltering?: boolean;
  27252. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27253. comparisonFunction?: number;
  27254. /** Specifies if the created texture is a cube texture */
  27255. isCube?: boolean;
  27256. }
  27257. /**
  27258. * Class used to describe the capabilities of the engine relatively to the current browser
  27259. */
  27260. export class EngineCapabilities {
  27261. /** Maximum textures units per fragment shader */
  27262. maxTexturesImageUnits: number;
  27263. /** Maximum texture units per vertex shader */
  27264. maxVertexTextureImageUnits: number;
  27265. /** Maximum textures units in the entire pipeline */
  27266. maxCombinedTexturesImageUnits: number;
  27267. /** Maximum texture size */
  27268. maxTextureSize: number;
  27269. /** Maximum cube texture size */
  27270. maxCubemapTextureSize: number;
  27271. /** Maximum render texture size */
  27272. maxRenderTextureSize: number;
  27273. /** Maximum number of vertex attributes */
  27274. maxVertexAttribs: number;
  27275. /** Maximum number of varyings */
  27276. maxVaryingVectors: number;
  27277. /** Maximum number of uniforms per vertex shader */
  27278. maxVertexUniformVectors: number;
  27279. /** Maximum number of uniforms per fragment shader */
  27280. maxFragmentUniformVectors: number;
  27281. /** Defines if standard derivates (dx/dy) are supported */
  27282. standardDerivatives: boolean;
  27283. /** Defines if s3tc texture compression is supported */
  27284. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27285. /** Defines if pvrtc texture compression is supported */
  27286. pvrtc: any;
  27287. /** Defines if etc1 texture compression is supported */
  27288. etc1: any;
  27289. /** Defines if etc2 texture compression is supported */
  27290. etc2: any;
  27291. /** Defines if astc texture compression is supported */
  27292. astc: any;
  27293. /** Defines if float textures are supported */
  27294. textureFloat: boolean;
  27295. /** Defines if vertex array objects are supported */
  27296. vertexArrayObject: boolean;
  27297. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27298. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27299. /** Gets the maximum level of anisotropy supported */
  27300. maxAnisotropy: number;
  27301. /** Defines if instancing is supported */
  27302. instancedArrays: boolean;
  27303. /** Defines if 32 bits indices are supported */
  27304. uintIndices: boolean;
  27305. /** Defines if high precision shaders are supported */
  27306. highPrecisionShaderSupported: boolean;
  27307. /** Defines if depth reading in the fragment shader is supported */
  27308. fragmentDepthSupported: boolean;
  27309. /** Defines if float texture linear filtering is supported*/
  27310. textureFloatLinearFiltering: boolean;
  27311. /** Defines if rendering to float textures is supported */
  27312. textureFloatRender: boolean;
  27313. /** Defines if half float textures are supported*/
  27314. textureHalfFloat: boolean;
  27315. /** Defines if half float texture linear filtering is supported*/
  27316. textureHalfFloatLinearFiltering: boolean;
  27317. /** Defines if rendering to half float textures is supported */
  27318. textureHalfFloatRender: boolean;
  27319. /** Defines if textureLOD shader command is supported */
  27320. textureLOD: boolean;
  27321. /** Defines if draw buffers extension is supported */
  27322. drawBuffersExtension: boolean;
  27323. /** Defines if depth textures are supported */
  27324. depthTextureExtension: boolean;
  27325. /** Defines if float color buffer are supported */
  27326. colorBufferFloat: boolean;
  27327. /** Gets disjoint timer query extension (null if not supported) */
  27328. timerQuery: EXT_disjoint_timer_query;
  27329. /** Defines if timestamp can be used with timer query */
  27330. canUseTimestampForTimerQuery: boolean;
  27331. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27332. multiview: any;
  27333. /** Function used to let the system compiles shaders in background */
  27334. parallelShaderCompile: {
  27335. COMPLETION_STATUS_KHR: number;
  27336. };
  27337. }
  27338. /** Interface defining initialization parameters for Engine class */
  27339. export interface EngineOptions extends WebGLContextAttributes {
  27340. /**
  27341. * Defines if the engine should no exceed a specified device ratio
  27342. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27343. */
  27344. limitDeviceRatio?: number;
  27345. /**
  27346. * Defines if webvr should be enabled automatically
  27347. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27348. */
  27349. autoEnableWebVR?: boolean;
  27350. /**
  27351. * Defines if webgl2 should be turned off even if supported
  27352. * @see http://doc.babylonjs.com/features/webgl2
  27353. */
  27354. disableWebGL2Support?: boolean;
  27355. /**
  27356. * Defines if webaudio should be initialized as well
  27357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27358. */
  27359. audioEngine?: boolean;
  27360. /**
  27361. * Defines if animations should run using a deterministic lock step
  27362. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27363. */
  27364. deterministicLockstep?: boolean;
  27365. /** Defines the maximum steps to use with deterministic lock step mode */
  27366. lockstepMaxSteps?: number;
  27367. /**
  27368. * Defines that engine should ignore context lost events
  27369. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27370. */
  27371. doNotHandleContextLost?: boolean;
  27372. /**
  27373. * Defines that engine should ignore modifying touch action attribute and style
  27374. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27375. */
  27376. doNotHandleTouchAction?: boolean;
  27377. /**
  27378. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27379. */
  27380. useHighPrecisionFloats?: boolean;
  27381. }
  27382. /**
  27383. * Defines the interface used by display changed events
  27384. */
  27385. export interface IDisplayChangedEventArgs {
  27386. /** Gets the vrDisplay object (if any) */
  27387. vrDisplay: Nullable<any>;
  27388. /** Gets a boolean indicating if webVR is supported */
  27389. vrSupported: boolean;
  27390. }
  27391. /**
  27392. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27393. */
  27394. export class Engine {
  27395. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27396. static ExceptionList: ({
  27397. key: string;
  27398. capture: string;
  27399. captureConstraint: number;
  27400. targets: string[];
  27401. } | {
  27402. key: string;
  27403. capture: null;
  27404. captureConstraint: null;
  27405. targets: string[];
  27406. })[];
  27407. /** Gets the list of created engines */
  27408. static readonly Instances: Engine[];
  27409. /**
  27410. * Gets the latest created engine
  27411. */
  27412. static readonly LastCreatedEngine: Nullable<Engine>;
  27413. /**
  27414. * Gets the latest created scene
  27415. */
  27416. static readonly LastCreatedScene: Nullable<Scene>;
  27417. /**
  27418. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27419. * @param flag defines which part of the materials must be marked as dirty
  27420. * @param predicate defines a predicate used to filter which materials should be affected
  27421. */
  27422. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27423. /** @hidden */
  27424. static _TextureLoaders: IInternalTextureLoader[];
  27425. /** Defines that alpha blending is disabled */
  27426. static readonly ALPHA_DISABLE: number;
  27427. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27428. static readonly ALPHA_ADD: number;
  27429. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27430. static readonly ALPHA_COMBINE: number;
  27431. /** Defines that alpha blending to DEST - SRC * DEST */
  27432. static readonly ALPHA_SUBTRACT: number;
  27433. /** Defines that alpha blending to SRC * DEST */
  27434. static readonly ALPHA_MULTIPLY: number;
  27435. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27436. static readonly ALPHA_MAXIMIZED: number;
  27437. /** Defines that alpha blending to SRC + DEST */
  27438. static readonly ALPHA_ONEONE: number;
  27439. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27440. static readonly ALPHA_PREMULTIPLIED: number;
  27441. /**
  27442. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27443. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27444. */
  27445. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27446. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27447. static readonly ALPHA_INTERPOLATE: number;
  27448. /**
  27449. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27450. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27451. */
  27452. static readonly ALPHA_SCREENMODE: number;
  27453. /** Defines that the ressource is not delayed*/
  27454. static readonly DELAYLOADSTATE_NONE: number;
  27455. /** Defines that the ressource was successfully delay loaded */
  27456. static readonly DELAYLOADSTATE_LOADED: number;
  27457. /** Defines that the ressource is currently delay loading */
  27458. static readonly DELAYLOADSTATE_LOADING: number;
  27459. /** Defines that the ressource is delayed and has not started loading */
  27460. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27461. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27462. static readonly NEVER: number;
  27463. /** 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 */
  27464. static readonly ALWAYS: number;
  27465. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27466. static readonly LESS: number;
  27467. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27468. static readonly EQUAL: number;
  27469. /** 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 */
  27470. static readonly LEQUAL: number;
  27471. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27472. static readonly GREATER: number;
  27473. /** 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 */
  27474. static readonly GEQUAL: number;
  27475. /** 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 */
  27476. static readonly NOTEQUAL: number;
  27477. /** Passed to stencilOperation to specify that stencil value must be kept */
  27478. static readonly KEEP: number;
  27479. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27480. static readonly REPLACE: number;
  27481. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27482. static readonly INCR: number;
  27483. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27484. static readonly DECR: number;
  27485. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27486. static readonly INVERT: number;
  27487. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27488. static readonly INCR_WRAP: number;
  27489. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27490. static readonly DECR_WRAP: number;
  27491. /** Texture is not repeating outside of 0..1 UVs */
  27492. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27493. /** Texture is repeating outside of 0..1 UVs */
  27494. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27495. /** Texture is repeating and mirrored */
  27496. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27497. /** ALPHA */
  27498. static readonly TEXTUREFORMAT_ALPHA: number;
  27499. /** LUMINANCE */
  27500. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27501. /** LUMINANCE_ALPHA */
  27502. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27503. /** RGB */
  27504. static readonly TEXTUREFORMAT_RGB: number;
  27505. /** RGBA */
  27506. static readonly TEXTUREFORMAT_RGBA: number;
  27507. /** RED */
  27508. static readonly TEXTUREFORMAT_RED: number;
  27509. /** RED (2nd reference) */
  27510. static readonly TEXTUREFORMAT_R: number;
  27511. /** RG */
  27512. static readonly TEXTUREFORMAT_RG: number;
  27513. /** RED_INTEGER */
  27514. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27515. /** RED_INTEGER (2nd reference) */
  27516. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27517. /** RG_INTEGER */
  27518. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27519. /** RGB_INTEGER */
  27520. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27521. /** RGBA_INTEGER */
  27522. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27523. /** UNSIGNED_BYTE */
  27524. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27525. /** UNSIGNED_BYTE (2nd reference) */
  27526. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27527. /** FLOAT */
  27528. static readonly TEXTURETYPE_FLOAT: number;
  27529. /** HALF_FLOAT */
  27530. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27531. /** BYTE */
  27532. static readonly TEXTURETYPE_BYTE: number;
  27533. /** SHORT */
  27534. static readonly TEXTURETYPE_SHORT: number;
  27535. /** UNSIGNED_SHORT */
  27536. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27537. /** INT */
  27538. static readonly TEXTURETYPE_INT: number;
  27539. /** UNSIGNED_INT */
  27540. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27541. /** UNSIGNED_SHORT_4_4_4_4 */
  27542. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27543. /** UNSIGNED_SHORT_5_5_5_1 */
  27544. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27545. /** UNSIGNED_SHORT_5_6_5 */
  27546. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27547. /** UNSIGNED_INT_2_10_10_10_REV */
  27548. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27549. /** UNSIGNED_INT_24_8 */
  27550. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27551. /** UNSIGNED_INT_10F_11F_11F_REV */
  27552. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27553. /** UNSIGNED_INT_5_9_9_9_REV */
  27554. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27555. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27556. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27557. /** nearest is mag = nearest and min = nearest and mip = linear */
  27558. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27559. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27560. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27561. /** Trilinear is mag = linear and min = linear and mip = linear */
  27562. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27563. /** nearest is mag = nearest and min = nearest and mip = linear */
  27564. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27565. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27566. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27567. /** Trilinear is mag = linear and min = linear and mip = linear */
  27568. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27569. /** mag = nearest and min = nearest and mip = nearest */
  27570. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27571. /** mag = nearest and min = linear and mip = nearest */
  27572. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27573. /** mag = nearest and min = linear and mip = linear */
  27574. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27575. /** mag = nearest and min = linear and mip = none */
  27576. static readonly TEXTURE_NEAREST_LINEAR: number;
  27577. /** mag = nearest and min = nearest and mip = none */
  27578. static readonly TEXTURE_NEAREST_NEAREST: number;
  27579. /** mag = linear and min = nearest and mip = nearest */
  27580. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27581. /** mag = linear and min = nearest and mip = linear */
  27582. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27583. /** mag = linear and min = linear and mip = none */
  27584. static readonly TEXTURE_LINEAR_LINEAR: number;
  27585. /** mag = linear and min = nearest and mip = none */
  27586. static readonly TEXTURE_LINEAR_NEAREST: number;
  27587. /** Explicit coordinates mode */
  27588. static readonly TEXTURE_EXPLICIT_MODE: number;
  27589. /** Spherical coordinates mode */
  27590. static readonly TEXTURE_SPHERICAL_MODE: number;
  27591. /** Planar coordinates mode */
  27592. static readonly TEXTURE_PLANAR_MODE: number;
  27593. /** Cubic coordinates mode */
  27594. static readonly TEXTURE_CUBIC_MODE: number;
  27595. /** Projection coordinates mode */
  27596. static readonly TEXTURE_PROJECTION_MODE: number;
  27597. /** Skybox coordinates mode */
  27598. static readonly TEXTURE_SKYBOX_MODE: number;
  27599. /** Inverse Cubic coordinates mode */
  27600. static readonly TEXTURE_INVCUBIC_MODE: number;
  27601. /** Equirectangular coordinates mode */
  27602. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27603. /** Equirectangular Fixed coordinates mode */
  27604. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27605. /** Equirectangular Fixed Mirrored coordinates mode */
  27606. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27607. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27608. static readonly SCALEMODE_FLOOR: number;
  27609. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27610. static readonly SCALEMODE_NEAREST: number;
  27611. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27612. static readonly SCALEMODE_CEILING: number;
  27613. /**
  27614. * Returns the current npm package of the sdk
  27615. */
  27616. static readonly NpmPackage: string;
  27617. /**
  27618. * Returns the current version of the framework
  27619. */
  27620. static readonly Version: string;
  27621. /**
  27622. * Returns a string describing the current engine
  27623. */
  27624. readonly description: string;
  27625. /**
  27626. * Gets or sets the epsilon value used by collision engine
  27627. */
  27628. static CollisionsEpsilon: number;
  27629. /**
  27630. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27631. */
  27632. static ShadersRepository: string;
  27633. /**
  27634. * Method called to create the default loading screen.
  27635. * This can be overriden in your own app.
  27636. * @param canvas The rendering canvas element
  27637. * @returns The loading screen
  27638. */
  27639. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27640. /**
  27641. * Method called to create the default rescale post process on each engine.
  27642. */
  27643. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27644. /** @hidden */
  27645. _shaderProcessor: IShaderProcessor;
  27646. /**
  27647. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27648. */
  27649. forcePOTTextures: boolean;
  27650. /**
  27651. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27652. */
  27653. isFullscreen: boolean;
  27654. /**
  27655. * Gets a boolean indicating if the pointer is currently locked
  27656. */
  27657. isPointerLock: boolean;
  27658. /**
  27659. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27660. */
  27661. cullBackFaces: boolean;
  27662. /**
  27663. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27664. */
  27665. renderEvenInBackground: boolean;
  27666. /**
  27667. * Gets or sets a boolean indicating that cache can be kept between frames
  27668. */
  27669. preventCacheWipeBetweenFrames: boolean;
  27670. /**
  27671. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27672. **/
  27673. enableOfflineSupport: boolean;
  27674. /**
  27675. * 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)
  27676. **/
  27677. disableManifestCheck: boolean;
  27678. /**
  27679. * Gets the list of created scenes
  27680. */
  27681. scenes: Scene[];
  27682. /**
  27683. * Event raised when a new scene is created
  27684. */
  27685. onNewSceneAddedObservable: Observable<Scene>;
  27686. /**
  27687. * Gets the list of created postprocesses
  27688. */
  27689. postProcesses: PostProcess[];
  27690. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27691. validateShaderPrograms: boolean;
  27692. /**
  27693. * Observable event triggered each time the rendering canvas is resized
  27694. */
  27695. onResizeObservable: Observable<Engine>;
  27696. /**
  27697. * Observable event triggered each time the canvas loses focus
  27698. */
  27699. onCanvasBlurObservable: Observable<Engine>;
  27700. /**
  27701. * Observable event triggered each time the canvas gains focus
  27702. */
  27703. onCanvasFocusObservable: Observable<Engine>;
  27704. /**
  27705. * Observable event triggered each time the canvas receives pointerout event
  27706. */
  27707. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27708. /**
  27709. * Observable event triggered before each texture is initialized
  27710. */
  27711. onBeforeTextureInitObservable: Observable<Texture>;
  27712. /**
  27713. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27714. */
  27715. disableUniformBuffers: boolean;
  27716. /** @hidden */
  27717. _uniformBuffers: UniformBuffer[];
  27718. /**
  27719. * Gets a boolean indicating that the engine supports uniform buffers
  27720. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27721. */
  27722. readonly supportsUniformBuffers: boolean;
  27723. /**
  27724. * Observable raised when the engine begins a new frame
  27725. */
  27726. onBeginFrameObservable: Observable<Engine>;
  27727. /**
  27728. * If set, will be used to request the next animation frame for the render loop
  27729. */
  27730. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27731. /**
  27732. * Observable raised when the engine ends the current frame
  27733. */
  27734. onEndFrameObservable: Observable<Engine>;
  27735. /**
  27736. * Observable raised when the engine is about to compile a shader
  27737. */
  27738. onBeforeShaderCompilationObservable: Observable<Engine>;
  27739. /**
  27740. * Observable raised when the engine has jsut compiled a shader
  27741. */
  27742. onAfterShaderCompilationObservable: Observable<Engine>;
  27743. /** @hidden */
  27744. _gl: WebGLRenderingContext;
  27745. private _renderingCanvas;
  27746. private _windowIsBackground;
  27747. private _webGLVersion;
  27748. protected _highPrecisionShadersAllowed: boolean;
  27749. /** @hidden */
  27750. readonly _shouldUseHighPrecisionShader: boolean;
  27751. /**
  27752. * Gets a boolean indicating that only power of 2 textures are supported
  27753. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27754. */
  27755. readonly needPOTTextures: boolean;
  27756. /** @hidden */
  27757. _badOS: boolean;
  27758. /** @hidden */
  27759. _badDesktopOS: boolean;
  27760. /**
  27761. * Gets the audio engine
  27762. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27763. * @ignorenaming
  27764. */
  27765. static audioEngine: IAudioEngine;
  27766. /**
  27767. * Default AudioEngine factory responsible of creating the Audio Engine.
  27768. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27769. */
  27770. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27771. /**
  27772. * Default offline support factory responsible of creating a tool used to store data locally.
  27773. * By default, this will create a Database object if the workload has been embedded.
  27774. */
  27775. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27776. private _onFocus;
  27777. private _onBlur;
  27778. private _onCanvasPointerOut;
  27779. private _onCanvasBlur;
  27780. private _onCanvasFocus;
  27781. private _onFullscreenChange;
  27782. private _onPointerLockChange;
  27783. private _hardwareScalingLevel;
  27784. /** @hidden */
  27785. _caps: EngineCapabilities;
  27786. private _pointerLockRequested;
  27787. private _isStencilEnable;
  27788. private _colorWrite;
  27789. private _loadingScreen;
  27790. /** @hidden */
  27791. _drawCalls: PerfCounter;
  27792. private _glVersion;
  27793. private _glRenderer;
  27794. private _glVendor;
  27795. private _videoTextureSupported;
  27796. private _renderingQueueLaunched;
  27797. private _activeRenderLoops;
  27798. private _deterministicLockstep;
  27799. private _lockstepMaxSteps;
  27800. /**
  27801. * Observable signaled when a context lost event is raised
  27802. */
  27803. onContextLostObservable: Observable<Engine>;
  27804. /**
  27805. * Observable signaled when a context restored event is raised
  27806. */
  27807. onContextRestoredObservable: Observable<Engine>;
  27808. private _onContextLost;
  27809. private _onContextRestored;
  27810. private _contextWasLost;
  27811. /** @hidden */
  27812. _doNotHandleContextLost: boolean;
  27813. /**
  27814. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27815. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27816. */
  27817. doNotHandleContextLost: boolean;
  27818. private _performanceMonitor;
  27819. private _fps;
  27820. private _deltaTime;
  27821. /**
  27822. * Turn this value on if you want to pause FPS computation when in background
  27823. */
  27824. disablePerformanceMonitorInBackground: boolean;
  27825. /**
  27826. * Gets the performance monitor attached to this engine
  27827. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27828. */
  27829. readonly performanceMonitor: PerformanceMonitor;
  27830. /**
  27831. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27832. */
  27833. disableVertexArrayObjects: boolean;
  27834. /** @hidden */
  27835. protected _depthCullingState: _DepthCullingState;
  27836. /** @hidden */
  27837. protected _stencilState: _StencilState;
  27838. /** @hidden */
  27839. protected _alphaState: _AlphaState;
  27840. /** @hidden */
  27841. protected _alphaMode: number;
  27842. /** @hidden */
  27843. _internalTexturesCache: InternalTexture[];
  27844. /** @hidden */
  27845. protected _activeChannel: number;
  27846. private _currentTextureChannel;
  27847. /** @hidden */
  27848. protected _boundTexturesCache: {
  27849. [key: string]: Nullable<InternalTexture>;
  27850. };
  27851. /** @hidden */
  27852. protected _currentEffect: Nullable<Effect>;
  27853. /** @hidden */
  27854. protected _currentProgram: Nullable<WebGLProgram>;
  27855. private _compiledEffects;
  27856. private _vertexAttribArraysEnabled;
  27857. /** @hidden */
  27858. protected _cachedViewport: Nullable<Viewport>;
  27859. private _cachedVertexArrayObject;
  27860. /** @hidden */
  27861. protected _cachedVertexBuffers: any;
  27862. /** @hidden */
  27863. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27864. /** @hidden */
  27865. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27866. /** @hidden */
  27867. _currentRenderTarget: Nullable<InternalTexture>;
  27868. private _uintIndicesCurrentlySet;
  27869. private _currentBoundBuffer;
  27870. /** @hidden */
  27871. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27872. private _currentBufferPointers;
  27873. private _currentInstanceLocations;
  27874. private _currentInstanceBuffers;
  27875. private _textureUnits;
  27876. /** @hidden */
  27877. _workingCanvas: Nullable<HTMLCanvasElement>;
  27878. /** @hidden */
  27879. _workingContext: Nullable<CanvasRenderingContext2D>;
  27880. private _rescalePostProcess;
  27881. private _dummyFramebuffer;
  27882. private _externalData;
  27883. /** @hidden */
  27884. _bindedRenderFunction: any;
  27885. private _vaoRecordInProgress;
  27886. private _mustWipeVertexAttributes;
  27887. private _emptyTexture;
  27888. private _emptyCubeTexture;
  27889. private _emptyTexture3D;
  27890. /** @hidden */
  27891. _frameHandler: number;
  27892. private _nextFreeTextureSlots;
  27893. private _maxSimultaneousTextures;
  27894. private _activeRequests;
  27895. private _texturesSupported;
  27896. /** @hidden */
  27897. _textureFormatInUse: Nullable<string>;
  27898. /**
  27899. * Gets the list of texture formats supported
  27900. */
  27901. readonly texturesSupported: Array<string>;
  27902. /**
  27903. * Gets the list of texture formats in use
  27904. */
  27905. readonly textureFormatInUse: Nullable<string>;
  27906. /**
  27907. * Gets the current viewport
  27908. */
  27909. readonly currentViewport: Nullable<Viewport>;
  27910. /**
  27911. * Gets the default empty texture
  27912. */
  27913. readonly emptyTexture: InternalTexture;
  27914. /**
  27915. * Gets the default empty 3D texture
  27916. */
  27917. readonly emptyTexture3D: InternalTexture;
  27918. /**
  27919. * Gets the default empty cube texture
  27920. */
  27921. readonly emptyCubeTexture: InternalTexture;
  27922. /**
  27923. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27924. */
  27925. readonly premultipliedAlpha: boolean;
  27926. /**
  27927. * Creates a new engine
  27928. * @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
  27929. * @param antialias defines enable antialiasing (default: false)
  27930. * @param options defines further options to be sent to the getContext() function
  27931. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27932. */
  27933. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27934. /**
  27935. * Initializes a webVR display and starts listening to display change events
  27936. * The onVRDisplayChangedObservable will be notified upon these changes
  27937. * @returns The onVRDisplayChangedObservable
  27938. */
  27939. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27940. /** @hidden */
  27941. _prepareVRComponent(): void;
  27942. /** @hidden */
  27943. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27944. /** @hidden */
  27945. _submitVRFrame(): void;
  27946. /**
  27947. * Call this function to leave webVR mode
  27948. * Will do nothing if webVR is not supported or if there is no webVR device
  27949. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27950. */
  27951. disableVR(): void;
  27952. /**
  27953. * Gets a boolean indicating that the system is in VR mode and is presenting
  27954. * @returns true if VR mode is engaged
  27955. */
  27956. isVRPresenting(): boolean;
  27957. /** @hidden */
  27958. _requestVRFrame(): void;
  27959. private _disableTouchAction;
  27960. private _rebuildInternalTextures;
  27961. private _rebuildEffects;
  27962. /**
  27963. * Gets a boolean indicating if all created effects are ready
  27964. * @returns true if all effects are ready
  27965. */
  27966. areAllEffectsReady(): boolean;
  27967. private _rebuildBuffers;
  27968. private _initGLContext;
  27969. /**
  27970. * Gets version of the current webGL context
  27971. */
  27972. readonly webGLVersion: number;
  27973. /**
  27974. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27975. */
  27976. readonly isStencilEnable: boolean;
  27977. /** @hidden */
  27978. _prepareWorkingCanvas(): void;
  27979. /**
  27980. * Reset the texture cache to empty state
  27981. */
  27982. resetTextureCache(): void;
  27983. /**
  27984. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27985. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27986. * @returns true if engine is in deterministic lock step mode
  27987. */
  27988. isDeterministicLockStep(): boolean;
  27989. /**
  27990. * Gets the max steps when engine is running in deterministic lock step
  27991. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27992. * @returns the max steps
  27993. */
  27994. getLockstepMaxSteps(): number;
  27995. /**
  27996. * Gets an object containing information about the current webGL context
  27997. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27998. */
  27999. getGlInfo(): {
  28000. vendor: string;
  28001. renderer: string;
  28002. version: string;
  28003. };
  28004. /**
  28005. * Gets current aspect ratio
  28006. * @param camera defines the camera to use to get the aspect ratio
  28007. * @param useScreen defines if screen size must be used (or the current render target if any)
  28008. * @returns a number defining the aspect ratio
  28009. */
  28010. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28011. /**
  28012. * Gets current screen aspect ratio
  28013. * @returns a number defining the aspect ratio
  28014. */
  28015. getScreenAspectRatio(): number;
  28016. /**
  28017. * Gets the current render width
  28018. * @param useScreen defines if screen size must be used (or the current render target if any)
  28019. * @returns a number defining the current render width
  28020. */
  28021. getRenderWidth(useScreen?: boolean): number;
  28022. /**
  28023. * Gets the current render height
  28024. * @param useScreen defines if screen size must be used (or the current render target if any)
  28025. * @returns a number defining the current render height
  28026. */
  28027. getRenderHeight(useScreen?: boolean): number;
  28028. /**
  28029. * Gets the HTML canvas attached with the current webGL context
  28030. * @returns a HTML canvas
  28031. */
  28032. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28033. /**
  28034. * Gets the client rect of the HTML canvas attached with the current webGL context
  28035. * @returns a client rectanglee
  28036. */
  28037. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28038. /**
  28039. * Defines the hardware scaling level.
  28040. * By default the hardware scaling level is computed from the window device ratio.
  28041. * 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.
  28042. * @param level defines the level to use
  28043. */
  28044. setHardwareScalingLevel(level: number): void;
  28045. /**
  28046. * Gets the current hardware scaling level.
  28047. * By default the hardware scaling level is computed from the window device ratio.
  28048. * 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.
  28049. * @returns a number indicating the current hardware scaling level
  28050. */
  28051. getHardwareScalingLevel(): number;
  28052. /**
  28053. * Gets the list of loaded textures
  28054. * @returns an array containing all loaded textures
  28055. */
  28056. getLoadedTexturesCache(): InternalTexture[];
  28057. /**
  28058. * Gets the object containing all engine capabilities
  28059. * @returns the EngineCapabilities object
  28060. */
  28061. getCaps(): EngineCapabilities;
  28062. /**
  28063. * Gets the current depth function
  28064. * @returns a number defining the depth function
  28065. */
  28066. getDepthFunction(): Nullable<number>;
  28067. /**
  28068. * Sets the current depth function
  28069. * @param depthFunc defines the function to use
  28070. */
  28071. setDepthFunction(depthFunc: number): void;
  28072. /**
  28073. * Sets the current depth function to GREATER
  28074. */
  28075. setDepthFunctionToGreater(): void;
  28076. /**
  28077. * Sets the current depth function to GEQUAL
  28078. */
  28079. setDepthFunctionToGreaterOrEqual(): void;
  28080. /**
  28081. * Sets the current depth function to LESS
  28082. */
  28083. setDepthFunctionToLess(): void;
  28084. private _cachedStencilBuffer;
  28085. private _cachedStencilFunction;
  28086. private _cachedStencilMask;
  28087. private _cachedStencilOperationPass;
  28088. private _cachedStencilOperationFail;
  28089. private _cachedStencilOperationDepthFail;
  28090. private _cachedStencilReference;
  28091. /**
  28092. * Caches the the state of the stencil buffer
  28093. */
  28094. cacheStencilState(): void;
  28095. /**
  28096. * Restores the state of the stencil buffer
  28097. */
  28098. restoreStencilState(): void;
  28099. /**
  28100. * Sets the current depth function to LEQUAL
  28101. */
  28102. setDepthFunctionToLessOrEqual(): void;
  28103. /**
  28104. * Gets a boolean indicating if stencil buffer is enabled
  28105. * @returns the current stencil buffer state
  28106. */
  28107. getStencilBuffer(): boolean;
  28108. /**
  28109. * Enable or disable the stencil buffer
  28110. * @param enable defines if the stencil buffer must be enabled or disabled
  28111. */
  28112. setStencilBuffer(enable: boolean): void;
  28113. /**
  28114. * Gets the current stencil mask
  28115. * @returns a number defining the new stencil mask to use
  28116. */
  28117. getStencilMask(): number;
  28118. /**
  28119. * Sets the current stencil mask
  28120. * @param mask defines the new stencil mask to use
  28121. */
  28122. setStencilMask(mask: number): void;
  28123. /**
  28124. * Gets the current stencil function
  28125. * @returns a number defining the stencil function to use
  28126. */
  28127. getStencilFunction(): number;
  28128. /**
  28129. * Gets the current stencil reference value
  28130. * @returns a number defining the stencil reference value to use
  28131. */
  28132. getStencilFunctionReference(): number;
  28133. /**
  28134. * Gets the current stencil mask
  28135. * @returns a number defining the stencil mask to use
  28136. */
  28137. getStencilFunctionMask(): number;
  28138. /**
  28139. * Sets the current stencil function
  28140. * @param stencilFunc defines the new stencil function to use
  28141. */
  28142. setStencilFunction(stencilFunc: number): void;
  28143. /**
  28144. * Sets the current stencil reference
  28145. * @param reference defines the new stencil reference to use
  28146. */
  28147. setStencilFunctionReference(reference: number): void;
  28148. /**
  28149. * Sets the current stencil mask
  28150. * @param mask defines the new stencil mask to use
  28151. */
  28152. setStencilFunctionMask(mask: number): void;
  28153. /**
  28154. * Gets the current stencil operation when stencil fails
  28155. * @returns a number defining stencil operation to use when stencil fails
  28156. */
  28157. getStencilOperationFail(): number;
  28158. /**
  28159. * Gets the current stencil operation when depth fails
  28160. * @returns a number defining stencil operation to use when depth fails
  28161. */
  28162. getStencilOperationDepthFail(): number;
  28163. /**
  28164. * Gets the current stencil operation when stencil passes
  28165. * @returns a number defining stencil operation to use when stencil passes
  28166. */
  28167. getStencilOperationPass(): number;
  28168. /**
  28169. * Sets the stencil operation to use when stencil fails
  28170. * @param operation defines the stencil operation to use when stencil fails
  28171. */
  28172. setStencilOperationFail(operation: number): void;
  28173. /**
  28174. * Sets the stencil operation to use when depth fails
  28175. * @param operation defines the stencil operation to use when depth fails
  28176. */
  28177. setStencilOperationDepthFail(operation: number): void;
  28178. /**
  28179. * Sets the stencil operation to use when stencil passes
  28180. * @param operation defines the stencil operation to use when stencil passes
  28181. */
  28182. setStencilOperationPass(operation: number): void;
  28183. /**
  28184. * Sets a boolean indicating if the dithering state is enabled or disabled
  28185. * @param value defines the dithering state
  28186. */
  28187. setDitheringState(value: boolean): void;
  28188. /**
  28189. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28190. * @param value defines the rasterizer state
  28191. */
  28192. setRasterizerState(value: boolean): void;
  28193. /**
  28194. * stop executing a render loop function and remove it from the execution array
  28195. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28196. */
  28197. stopRenderLoop(renderFunction?: () => void): void;
  28198. /** @hidden */
  28199. _renderLoop(): void;
  28200. /**
  28201. * Register and execute a render loop. The engine can have more than one render function
  28202. * @param renderFunction defines the function to continuously execute
  28203. */
  28204. runRenderLoop(renderFunction: () => void): void;
  28205. /**
  28206. * Toggle full screen mode
  28207. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28208. */
  28209. switchFullscreen(requestPointerLock: boolean): void;
  28210. /**
  28211. * Enters full screen mode
  28212. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28213. */
  28214. enterFullscreen(requestPointerLock: boolean): void;
  28215. /**
  28216. * Exits full screen mode
  28217. */
  28218. exitFullscreen(): void;
  28219. /**
  28220. * Clear the current render buffer or the current render target (if any is set up)
  28221. * @param color defines the color to use
  28222. * @param backBuffer defines if the back buffer must be cleared
  28223. * @param depth defines if the depth buffer must be cleared
  28224. * @param stencil defines if the stencil buffer must be cleared
  28225. */
  28226. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28227. /**
  28228. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28229. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28230. * @param y defines the y-coordinate of the corner of the clear rectangle
  28231. * @param width defines the width of the clear rectangle
  28232. * @param height defines the height of the clear rectangle
  28233. * @param clearColor defines the clear color
  28234. */
  28235. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28236. /**
  28237. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28238. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28239. * @param y defines the y-coordinate of the corner of the clear rectangle
  28240. * @param width defines the width of the clear rectangle
  28241. * @param height defines the height of the clear rectangle
  28242. */
  28243. enableScissor(x: number, y: number, width: number, height: number): void;
  28244. /**
  28245. * Disable previously set scissor test rectangle
  28246. */
  28247. disableScissor(): void;
  28248. private _viewportCached;
  28249. /** @hidden */
  28250. _viewport(x: number, y: number, width: number, height: number): void;
  28251. /**
  28252. * Set the WebGL's viewport
  28253. * @param viewport defines the viewport element to be used
  28254. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28255. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28256. */
  28257. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28258. /**
  28259. * Directly set the WebGL Viewport
  28260. * @param x defines the x coordinate of the viewport (in screen space)
  28261. * @param y defines the y coordinate of the viewport (in screen space)
  28262. * @param width defines the width of the viewport (in screen space)
  28263. * @param height defines the height of the viewport (in screen space)
  28264. * @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
  28265. */
  28266. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28267. /**
  28268. * Begin a new frame
  28269. */
  28270. beginFrame(): void;
  28271. /**
  28272. * Enf the current frame
  28273. */
  28274. endFrame(): void;
  28275. /**
  28276. * Resize the view according to the canvas' size
  28277. */
  28278. resize(): void;
  28279. /**
  28280. * Force a specific size of the canvas
  28281. * @param width defines the new canvas' width
  28282. * @param height defines the new canvas' height
  28283. */
  28284. setSize(width: number, height: number): void;
  28285. /**
  28286. * Binds the frame buffer to the specified texture.
  28287. * @param texture The texture to render to or null for the default canvas
  28288. * @param faceIndex The face of the texture to render to in case of cube texture
  28289. * @param requiredWidth The width of the target to render to
  28290. * @param requiredHeight The height of the target to render to
  28291. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28292. * @param depthStencilTexture The depth stencil texture to use to render
  28293. * @param lodLevel defines le lod level to bind to the frame buffer
  28294. */
  28295. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28296. /** @hidden */
  28297. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28298. /**
  28299. * Unbind the current render target texture from the webGL context
  28300. * @param texture defines the render target texture to unbind
  28301. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28302. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28303. */
  28304. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28305. /**
  28306. * Force the mipmap generation for the given render target texture
  28307. * @param texture defines the render target texture to use
  28308. */
  28309. generateMipMapsForCubemap(texture: InternalTexture): void;
  28310. /**
  28311. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28312. */
  28313. flushFramebuffer(): void;
  28314. /**
  28315. * Unbind the current render target and bind the default framebuffer
  28316. */
  28317. restoreDefaultFramebuffer(): void;
  28318. /**
  28319. * Create an uniform buffer
  28320. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28321. * @param elements defines the content of the uniform buffer
  28322. * @returns the webGL uniform buffer
  28323. */
  28324. createUniformBuffer(elements: FloatArray): DataBuffer;
  28325. /**
  28326. * Create a dynamic uniform buffer
  28327. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28328. * @param elements defines the content of the uniform buffer
  28329. * @returns the webGL uniform buffer
  28330. */
  28331. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28332. /**
  28333. * Update an existing uniform buffer
  28334. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28335. * @param uniformBuffer defines the target uniform buffer
  28336. * @param elements defines the content to update
  28337. * @param offset defines the offset in the uniform buffer where update should start
  28338. * @param count defines the size of the data to update
  28339. */
  28340. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28341. private _resetVertexBufferBinding;
  28342. /**
  28343. * Creates a vertex buffer
  28344. * @param data the data for the vertex buffer
  28345. * @returns the new WebGL static buffer
  28346. */
  28347. createVertexBuffer(data: DataArray): DataBuffer;
  28348. /**
  28349. * Creates a dynamic vertex buffer
  28350. * @param data the data for the dynamic vertex buffer
  28351. * @returns the new WebGL dynamic buffer
  28352. */
  28353. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28354. /**
  28355. * Update a dynamic index buffer
  28356. * @param indexBuffer defines the target index buffer
  28357. * @param indices defines the data to update
  28358. * @param offset defines the offset in the target index buffer where update should start
  28359. */
  28360. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28361. /**
  28362. * Updates a dynamic vertex buffer.
  28363. * @param vertexBuffer the vertex buffer to update
  28364. * @param data the data used to update the vertex buffer
  28365. * @param byteOffset the byte offset of the data
  28366. * @param byteLength the byte length of the data
  28367. */
  28368. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28369. private _resetIndexBufferBinding;
  28370. /**
  28371. * Creates a new index buffer
  28372. * @param indices defines the content of the index buffer
  28373. * @param updatable defines if the index buffer must be updatable
  28374. * @returns a new webGL buffer
  28375. */
  28376. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28377. /**
  28378. * Bind a webGL buffer to the webGL context
  28379. * @param buffer defines the buffer to bind
  28380. */
  28381. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28382. /**
  28383. * Bind an uniform buffer to the current webGL context
  28384. * @param buffer defines the buffer to bind
  28385. */
  28386. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28387. /**
  28388. * Bind a buffer to the current webGL context at a given location
  28389. * @param buffer defines the buffer to bind
  28390. * @param location defines the index where to bind the buffer
  28391. */
  28392. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28393. /**
  28394. * Bind a specific block at a given index in a specific shader program
  28395. * @param pipelineContext defines the pipeline context to use
  28396. * @param blockName defines the block name
  28397. * @param index defines the index where to bind the block
  28398. */
  28399. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28400. private bindIndexBuffer;
  28401. private bindBuffer;
  28402. /**
  28403. * update the bound buffer with the given data
  28404. * @param data defines the data to update
  28405. */
  28406. updateArrayBuffer(data: Float32Array): void;
  28407. private _vertexAttribPointer;
  28408. private _bindIndexBufferWithCache;
  28409. private _bindVertexBuffersAttributes;
  28410. /**
  28411. * Records a vertex array object
  28412. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28413. * @param vertexBuffers defines the list of vertex buffers to store
  28414. * @param indexBuffer defines the index buffer to store
  28415. * @param effect defines the effect to store
  28416. * @returns the new vertex array object
  28417. */
  28418. recordVertexArrayObject(vertexBuffers: {
  28419. [key: string]: VertexBuffer;
  28420. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28421. /**
  28422. * Bind a specific vertex array object
  28423. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28424. * @param vertexArrayObject defines the vertex array object to bind
  28425. * @param indexBuffer defines the index buffer to bind
  28426. */
  28427. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28428. /**
  28429. * Bind webGl buffers directly to the webGL context
  28430. * @param vertexBuffer defines the vertex buffer to bind
  28431. * @param indexBuffer defines the index buffer to bind
  28432. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28433. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28434. * @param effect defines the effect associated with the vertex buffer
  28435. */
  28436. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28437. private _unbindVertexArrayObject;
  28438. /**
  28439. * Bind a list of vertex buffers to the webGL context
  28440. * @param vertexBuffers defines the list of vertex buffers to bind
  28441. * @param indexBuffer defines the index buffer to bind
  28442. * @param effect defines the effect associated with the vertex buffers
  28443. */
  28444. bindBuffers(vertexBuffers: {
  28445. [key: string]: Nullable<VertexBuffer>;
  28446. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28447. /**
  28448. * Unbind all instance attributes
  28449. */
  28450. unbindInstanceAttributes(): void;
  28451. /**
  28452. * Release and free the memory of a vertex array object
  28453. * @param vao defines the vertex array object to delete
  28454. */
  28455. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28456. /** @hidden */
  28457. _releaseBuffer(buffer: DataBuffer): boolean;
  28458. /**
  28459. * Creates a webGL buffer to use with instanciation
  28460. * @param capacity defines the size of the buffer
  28461. * @returns the webGL buffer
  28462. */
  28463. createInstancesBuffer(capacity: number): DataBuffer;
  28464. /**
  28465. * Delete a webGL buffer used with instanciation
  28466. * @param buffer defines the webGL buffer to delete
  28467. */
  28468. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28469. /**
  28470. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28471. * @param instancesBuffer defines the webGL buffer to update and bind
  28472. * @param data defines the data to store in the buffer
  28473. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28474. */
  28475. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28476. /**
  28477. * Apply all cached states (depth, culling, stencil and alpha)
  28478. */
  28479. applyStates(): void;
  28480. /**
  28481. * Send a draw order
  28482. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28483. * @param indexStart defines the starting index
  28484. * @param indexCount defines the number of index to draw
  28485. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28486. */
  28487. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28488. /**
  28489. * Draw a list of points
  28490. * @param verticesStart defines the index of first vertex to draw
  28491. * @param verticesCount defines the count of vertices to draw
  28492. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28493. */
  28494. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28495. /**
  28496. * Draw a list of unindexed primitives
  28497. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28498. * @param verticesStart defines the index of first vertex to draw
  28499. * @param verticesCount defines the count of vertices to draw
  28500. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28501. */
  28502. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28503. /**
  28504. * Draw a list of indexed primitives
  28505. * @param fillMode defines the primitive to use
  28506. * @param indexStart defines the starting index
  28507. * @param indexCount defines the number of index to draw
  28508. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28509. */
  28510. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28511. /**
  28512. * Draw a list of unindexed primitives
  28513. * @param fillMode defines the primitive to use
  28514. * @param verticesStart defines the index of first vertex to draw
  28515. * @param verticesCount defines the count of vertices to draw
  28516. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28517. */
  28518. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28519. private _drawMode;
  28520. /** @hidden */
  28521. _releaseEffect(effect: Effect): void;
  28522. /** @hidden */
  28523. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28524. /**
  28525. * Create a new effect (used to store vertex/fragment shaders)
  28526. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28527. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28528. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28529. * @param samplers defines an array of string used to represent textures
  28530. * @param defines defines the string containing the defines to use to compile the shaders
  28531. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28532. * @param onCompiled defines a function to call when the effect creation is successful
  28533. * @param onError defines a function to call when the effect creation has failed
  28534. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28535. * @returns the new Effect
  28536. */
  28537. 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;
  28538. private _compileShader;
  28539. private _compileRawShader;
  28540. /**
  28541. * Directly creates a webGL program
  28542. * @param pipelineContext defines the pipeline context to attach to
  28543. * @param vertexCode defines the vertex shader code to use
  28544. * @param fragmentCode defines the fragment shader code to use
  28545. * @param context defines the webGL context to use (if not set, the current one will be used)
  28546. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28547. * @returns the new webGL program
  28548. */
  28549. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28550. /**
  28551. * 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 defines defines the string containing the defines to use to compile the shaders
  28556. * @param context defines the webGL context to use (if not set, the current one will be used)
  28557. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28558. * @returns the new webGL program
  28559. */
  28560. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28561. /**
  28562. * Creates a new pipeline context
  28563. * @returns the new pipeline
  28564. */
  28565. createPipelineContext(): WebGLPipelineContext;
  28566. private _createShaderProgram;
  28567. private _finalizePipelineContext;
  28568. /** @hidden */
  28569. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28570. /** @hidden */
  28571. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28572. /** @hidden */
  28573. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28574. /**
  28575. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28576. * @param pipelineContext defines the pipeline context to use
  28577. * @param uniformsNames defines the list of uniform names
  28578. * @returns an array of webGL uniform locations
  28579. */
  28580. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28581. /**
  28582. * Gets the lsit of active attributes for a given webGL program
  28583. * @param pipelineContext defines the pipeline context to use
  28584. * @param attributesNames defines the list of attribute names to get
  28585. * @returns an array of indices indicating the offset of each attribute
  28586. */
  28587. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28588. /**
  28589. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28590. * @param effect defines the effect to activate
  28591. */
  28592. enableEffect(effect: Nullable<Effect>): void;
  28593. /**
  28594. * Set the value of an uniform to an array of int32
  28595. * @param uniform defines the webGL uniform location where to store the value
  28596. * @param array defines the array of int32 to store
  28597. */
  28598. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28599. /**
  28600. * Set the value of an uniform to an array of int32 (stored as vec2)
  28601. * @param uniform defines the webGL uniform location where to store the value
  28602. * @param array defines the array of int32 to store
  28603. */
  28604. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28605. /**
  28606. * Set the value of an uniform to an array of int32 (stored as vec3)
  28607. * @param uniform defines the webGL uniform location where to store the value
  28608. * @param array defines the array of int32 to store
  28609. */
  28610. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28611. /**
  28612. * Set the value of an uniform to an array of int32 (stored as vec4)
  28613. * @param uniform defines the webGL uniform location where to store the value
  28614. * @param array defines the array of int32 to store
  28615. */
  28616. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28617. /**
  28618. * Set the value of an uniform to an array of float32
  28619. * @param uniform defines the webGL uniform location where to store the value
  28620. * @param array defines the array of float32 to store
  28621. */
  28622. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28623. /**
  28624. * Set the value of an uniform to an array of float32 (stored as vec2)
  28625. * @param uniform defines the webGL uniform location where to store the value
  28626. * @param array defines the array of float32 to store
  28627. */
  28628. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28629. /**
  28630. * Set the value of an uniform to an array of float32 (stored as vec3)
  28631. * @param uniform defines the webGL uniform location where to store the value
  28632. * @param array defines the array of float32 to store
  28633. */
  28634. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28635. /**
  28636. * Set the value of an uniform to an array of float32 (stored as vec4)
  28637. * @param uniform defines the webGL uniform location where to store the value
  28638. * @param array defines the array of float32 to store
  28639. */
  28640. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28641. /**
  28642. * Set the value of an uniform to an array of number
  28643. * @param uniform defines the webGL uniform location where to store the value
  28644. * @param array defines the array of number to store
  28645. */
  28646. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28647. /**
  28648. * Set the value of an uniform to an array of number (stored as vec2)
  28649. * @param uniform defines the webGL uniform location where to store the value
  28650. * @param array defines the array of number to store
  28651. */
  28652. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28653. /**
  28654. * Set the value of an uniform to an array of number (stored as vec3)
  28655. * @param uniform defines the webGL uniform location where to store the value
  28656. * @param array defines the array of number to store
  28657. */
  28658. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28659. /**
  28660. * Set the value of an uniform to an array of number (stored as vec4)
  28661. * @param uniform defines the webGL uniform location where to store the value
  28662. * @param array defines the array of number to store
  28663. */
  28664. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28665. /**
  28666. * Set the value of an uniform to an array of float32 (stored as matrices)
  28667. * @param uniform defines the webGL uniform location where to store the value
  28668. * @param matrices defines the array of float32 to store
  28669. */
  28670. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28671. /**
  28672. * Set the value of an uniform to a matrix
  28673. * @param uniform defines the webGL uniform location where to store the value
  28674. * @param matrix defines the matrix to store
  28675. */
  28676. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28677. /**
  28678. * Set the value of an uniform to a matrix (3x3)
  28679. * @param uniform defines the webGL uniform location where to store the value
  28680. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28681. */
  28682. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28683. /**
  28684. * Set the value of an uniform to a matrix (2x2)
  28685. * @param uniform defines the webGL uniform location where to store the value
  28686. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28687. */
  28688. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28689. /**
  28690. * Set the value of an uniform to a number (int)
  28691. * @param uniform defines the webGL uniform location where to store the value
  28692. * @param value defines the int number to store
  28693. */
  28694. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28695. /**
  28696. * Set the value of an uniform to a number (float)
  28697. * @param uniform defines the webGL uniform location where to store the value
  28698. * @param value defines the float number to store
  28699. */
  28700. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28701. /**
  28702. * Set the value of an uniform to a vec2
  28703. * @param uniform defines the webGL uniform location where to store the value
  28704. * @param x defines the 1st component of the value
  28705. * @param y defines the 2nd component of the value
  28706. */
  28707. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28708. /**
  28709. * Set the value of an uniform to a vec3
  28710. * @param uniform defines the webGL uniform location where to store the value
  28711. * @param x defines the 1st component of the value
  28712. * @param y defines the 2nd component of the value
  28713. * @param z defines the 3rd component of the value
  28714. */
  28715. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28716. /**
  28717. * Set the value of an uniform to a boolean
  28718. * @param uniform defines the webGL uniform location where to store the value
  28719. * @param bool defines the boolean to store
  28720. */
  28721. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28722. /**
  28723. * Set the value of an uniform to a vec4
  28724. * @param uniform defines the webGL uniform location where to store the value
  28725. * @param x defines the 1st component of the value
  28726. * @param y defines the 2nd component of the value
  28727. * @param z defines the 3rd component of the value
  28728. * @param w defines the 4th component of the value
  28729. */
  28730. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28731. /**
  28732. * Set the value of an uniform to a Color3
  28733. * @param uniform defines the webGL uniform location where to store the value
  28734. * @param color3 defines the color to store
  28735. */
  28736. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28737. /**
  28738. * Set the value of an uniform to a Color3 and an alpha value
  28739. * @param uniform defines the webGL uniform location where to store the value
  28740. * @param color3 defines the color to store
  28741. * @param alpha defines the alpha component to store
  28742. */
  28743. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28744. /**
  28745. * Sets a Color4 on a uniform variable
  28746. * @param uniform defines the uniform location
  28747. * @param color4 defines the value to be set
  28748. */
  28749. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28750. /**
  28751. * Set various states to the webGL context
  28752. * @param culling defines backface culling state
  28753. * @param zOffset defines the value to apply to zOffset (0 by default)
  28754. * @param force defines if states must be applied even if cache is up to date
  28755. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28756. */
  28757. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28758. /**
  28759. * Set the z offset to apply to current rendering
  28760. * @param value defines the offset to apply
  28761. */
  28762. setZOffset(value: number): void;
  28763. /**
  28764. * Gets the current value of the zOffset
  28765. * @returns the current zOffset state
  28766. */
  28767. getZOffset(): number;
  28768. /**
  28769. * Enable or disable depth buffering
  28770. * @param enable defines the state to set
  28771. */
  28772. setDepthBuffer(enable: boolean): void;
  28773. /**
  28774. * Gets a boolean indicating if depth writing is enabled
  28775. * @returns the current depth writing state
  28776. */
  28777. getDepthWrite(): boolean;
  28778. /**
  28779. * Enable or disable depth writing
  28780. * @param enable defines the state to set
  28781. */
  28782. setDepthWrite(enable: boolean): void;
  28783. /**
  28784. * Enable or disable color writing
  28785. * @param enable defines the state to set
  28786. */
  28787. setColorWrite(enable: boolean): void;
  28788. /**
  28789. * Gets a boolean indicating if color writing is enabled
  28790. * @returns the current color writing state
  28791. */
  28792. getColorWrite(): boolean;
  28793. /**
  28794. * Sets alpha constants used by some alpha blending modes
  28795. * @param r defines the red component
  28796. * @param g defines the green component
  28797. * @param b defines the blue component
  28798. * @param a defines the alpha component
  28799. */
  28800. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28801. /**
  28802. * Sets the current alpha mode
  28803. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28804. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28805. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28806. */
  28807. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28808. /**
  28809. * Gets the current alpha mode
  28810. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28811. * @returns the current alpha mode
  28812. */
  28813. getAlphaMode(): number;
  28814. /**
  28815. * Clears the list of texture accessible through engine.
  28816. * This can help preventing texture load conflict due to name collision.
  28817. */
  28818. clearInternalTexturesCache(): void;
  28819. /**
  28820. * Force the entire cache to be cleared
  28821. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28822. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28823. */
  28824. wipeCaches(bruteForce?: boolean): void;
  28825. /**
  28826. * Set the compressed texture format to use, based on the formats you have, and the formats
  28827. * supported by the hardware / browser.
  28828. *
  28829. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28830. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28831. * to API arguments needed to compressed textures. This puts the burden on the container
  28832. * generator to house the arcane code for determining these for current & future formats.
  28833. *
  28834. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28835. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28836. *
  28837. * Note: The result of this call is not taken into account when a texture is base64.
  28838. *
  28839. * @param formatsAvailable defines the list of those format families you have created
  28840. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28841. *
  28842. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28843. * @returns The extension selected.
  28844. */
  28845. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28846. /** @hidden */
  28847. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28848. min: number;
  28849. mag: number;
  28850. };
  28851. /** @hidden */
  28852. _createTexture(): WebGLTexture;
  28853. /**
  28854. * Usually called from Texture.ts.
  28855. * Passed information to create a WebGLTexture
  28856. * @param urlArg defines a value which contains one of the following:
  28857. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28858. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28859. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28860. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28861. * @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)
  28862. * @param scene needed for loading to the correct scene
  28863. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28864. * @param onLoad optional callback to be called upon successful completion
  28865. * @param onError optional callback to be called upon failure
  28866. * @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
  28867. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28868. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28869. * @param forcedExtension defines the extension to use to pick the right loader
  28870. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28871. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28872. */
  28873. 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;
  28874. private _rescaleTexture;
  28875. private _unpackFlipYCached;
  28876. /**
  28877. * In case you are sharing the context with other applications, it might
  28878. * be interested to not cache the unpack flip y state to ensure a consistent
  28879. * value would be set.
  28880. */
  28881. enableUnpackFlipYCached: boolean;
  28882. /** @hidden */
  28883. _unpackFlipY(value: boolean): void;
  28884. /** @hidden */
  28885. _getUnpackAlignement(): number;
  28886. /**
  28887. * Creates a dynamic texture
  28888. * @param width defines the width of the texture
  28889. * @param height defines the height of the texture
  28890. * @param generateMipMaps defines if the engine should generate the mip levels
  28891. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28892. * @returns the dynamic texture inside an InternalTexture
  28893. */
  28894. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28895. /**
  28896. * Update the sampling mode of a given texture
  28897. * @param samplingMode defines the required sampling mode
  28898. * @param texture defines the texture to update
  28899. */
  28900. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28901. /**
  28902. * Update the content of a dynamic texture
  28903. * @param texture defines the texture to update
  28904. * @param canvas defines the canvas containing the source
  28905. * @param invertY defines if data must be stored with Y axis inverted
  28906. * @param premulAlpha defines if alpha is stored as premultiplied
  28907. * @param format defines the format of the data
  28908. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28909. */
  28910. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28911. /**
  28912. * Update a video texture
  28913. * @param texture defines the texture to update
  28914. * @param video defines the video element to use
  28915. * @param invertY defines if data must be stored with Y axis inverted
  28916. */
  28917. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28918. /**
  28919. * Updates a depth texture Comparison Mode and Function.
  28920. * If the comparison Function is equal to 0, the mode will be set to none.
  28921. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28922. * @param texture The texture to set the comparison function for
  28923. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28924. */
  28925. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28926. /** @hidden */
  28927. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28928. width: number;
  28929. height: number;
  28930. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28931. /**
  28932. * Creates a depth stencil texture.
  28933. * This is only available in WebGL 2 or with the depth texture extension available.
  28934. * @param size The size of face edge in the texture.
  28935. * @param options The options defining the texture.
  28936. * @returns The texture
  28937. */
  28938. createDepthStencilTexture(size: number | {
  28939. width: number;
  28940. height: number;
  28941. }, options: DepthTextureCreationOptions): InternalTexture;
  28942. /**
  28943. * Creates a depth stencil texture.
  28944. * This is only available in WebGL 2 or with the depth texture extension available.
  28945. * @param size The size of face edge in the texture.
  28946. * @param options The options defining the texture.
  28947. * @returns The texture
  28948. */
  28949. private _createDepthStencilTexture;
  28950. /**
  28951. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28952. * @param renderTarget The render target to set the frame buffer for
  28953. */
  28954. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28955. /**
  28956. * Creates a new render target texture
  28957. * @param size defines the size of the texture
  28958. * @param options defines the options used to create the texture
  28959. * @returns a new render target texture stored in an InternalTexture
  28960. */
  28961. createRenderTargetTexture(size: number | {
  28962. width: number;
  28963. height: number;
  28964. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28965. /** @hidden */
  28966. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28967. /**
  28968. * Updates the sample count of a render target texture
  28969. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28970. * @param texture defines the texture to update
  28971. * @param samples defines the sample count to set
  28972. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28973. */
  28974. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28975. /** @hidden */
  28976. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28977. /** @hidden */
  28978. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28979. /** @hidden */
  28980. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28981. /** @hidden */
  28982. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28983. /**
  28984. * @hidden
  28985. */
  28986. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28987. private _prepareWebGLTextureContinuation;
  28988. private _prepareWebGLTexture;
  28989. /** @hidden */
  28990. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28991. /** @hidden */
  28992. _releaseFramebufferObjects(texture: InternalTexture): void;
  28993. /** @hidden */
  28994. _releaseTexture(texture: InternalTexture): void;
  28995. private setProgram;
  28996. private _boundUniforms;
  28997. /**
  28998. * Binds an effect to the webGL context
  28999. * @param effect defines the effect to bind
  29000. */
  29001. bindSamplers(effect: Effect): void;
  29002. private _activateCurrentTexture;
  29003. /** @hidden */
  29004. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29005. /** @hidden */
  29006. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29007. /**
  29008. * Sets a texture to the webGL context from a postprocess
  29009. * @param channel defines the channel to use
  29010. * @param postProcess defines the source postprocess
  29011. */
  29012. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29013. /**
  29014. * Binds the output of the passed in post process to the texture channel specified
  29015. * @param channel The channel the texture should be bound to
  29016. * @param postProcess The post process which's output should be bound
  29017. */
  29018. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29019. /**
  29020. * Unbind all textures from the webGL context
  29021. */
  29022. unbindAllTextures(): void;
  29023. /**
  29024. * Sets a texture to the according uniform.
  29025. * @param channel The texture channel
  29026. * @param uniform The uniform to set
  29027. * @param texture The texture to apply
  29028. */
  29029. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29030. /**
  29031. * Sets a depth stencil texture from a render target to the according uniform.
  29032. * @param channel The texture channel
  29033. * @param uniform The uniform to set
  29034. * @param texture The render target texture containing the depth stencil texture to apply
  29035. */
  29036. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29037. private _bindSamplerUniformToChannel;
  29038. private _getTextureWrapMode;
  29039. private _setTexture;
  29040. /**
  29041. * Sets an array of texture to the webGL context
  29042. * @param channel defines the channel where the texture array must be set
  29043. * @param uniform defines the associated uniform location
  29044. * @param textures defines the array of textures to bind
  29045. */
  29046. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29047. /** @hidden */
  29048. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29049. private _setTextureParameterFloat;
  29050. private _setTextureParameterInteger;
  29051. /**
  29052. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29053. * @param x defines the x coordinate of the rectangle where pixels must be read
  29054. * @param y defines the y coordinate of the rectangle where pixels must be read
  29055. * @param width defines the width of the rectangle where pixels must be read
  29056. * @param height defines the height of the rectangle where pixels must be read
  29057. * @returns a Uint8Array containing RGBA colors
  29058. */
  29059. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29060. /**
  29061. * Add an externaly attached data from its key.
  29062. * This method call will fail and return false, if such key already exists.
  29063. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29064. * @param key the unique key that identifies the data
  29065. * @param data the data object to associate to the key for this Engine instance
  29066. * @return true if no such key were already present and the data was added successfully, false otherwise
  29067. */
  29068. addExternalData<T>(key: string, data: T): boolean;
  29069. /**
  29070. * Get an externaly attached data from its key
  29071. * @param key the unique key that identifies the data
  29072. * @return the associated data, if present (can be null), or undefined if not present
  29073. */
  29074. getExternalData<T>(key: string): T;
  29075. /**
  29076. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29077. * @param key the unique key that identifies the data
  29078. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29079. * @return the associated data, can be null if the factory returned null.
  29080. */
  29081. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29082. /**
  29083. * Remove an externaly attached data from the Engine instance
  29084. * @param key the unique key that identifies the data
  29085. * @return true if the data was successfully removed, false if it doesn't exist
  29086. */
  29087. removeExternalData(key: string): boolean;
  29088. /**
  29089. * Unbind all vertex attributes from the webGL context
  29090. */
  29091. unbindAllAttributes(): void;
  29092. /**
  29093. * 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
  29094. */
  29095. releaseEffects(): void;
  29096. /**
  29097. * Dispose and release all associated resources
  29098. */
  29099. dispose(): void;
  29100. /**
  29101. * Display the loading screen
  29102. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29103. */
  29104. displayLoadingUI(): void;
  29105. /**
  29106. * Hide the loading screen
  29107. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29108. */
  29109. hideLoadingUI(): void;
  29110. /**
  29111. * Gets the current loading screen object
  29112. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29113. */
  29114. /**
  29115. * Sets the current loading screen object
  29116. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29117. */
  29118. loadingScreen: ILoadingScreen;
  29119. /**
  29120. * Sets the current loading screen text
  29121. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29122. */
  29123. loadingUIText: string;
  29124. /**
  29125. * Sets the current loading screen background color
  29126. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29127. */
  29128. loadingUIBackgroundColor: string;
  29129. /**
  29130. * Attach a new callback raised when context lost event is fired
  29131. * @param callback defines the callback to call
  29132. */
  29133. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29134. /**
  29135. * Attach a new callback raised when context restored event is fired
  29136. * @param callback defines the callback to call
  29137. */
  29138. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29139. /**
  29140. * Gets the source code of the vertex shader associated with a specific webGL program
  29141. * @param program defines the program to use
  29142. * @returns a string containing the source code of the vertex shader associated with the program
  29143. */
  29144. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29145. /**
  29146. * Gets the source code of the fragment shader associated with a specific webGL program
  29147. * @param program defines the program to use
  29148. * @returns a string containing the source code of the fragment shader associated with the program
  29149. */
  29150. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29151. /**
  29152. * Get the current error code of the webGL context
  29153. * @returns the error code
  29154. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29155. */
  29156. getError(): number;
  29157. /**
  29158. * Gets the current framerate
  29159. * @returns a number representing the framerate
  29160. */
  29161. getFps(): number;
  29162. /**
  29163. * Gets the time spent between current and previous frame
  29164. * @returns a number representing the delta time in ms
  29165. */
  29166. getDeltaTime(): number;
  29167. private _measureFps;
  29168. /** @hidden */
  29169. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29170. private _canRenderToFloatFramebuffer;
  29171. private _canRenderToHalfFloatFramebuffer;
  29172. private _canRenderToFramebuffer;
  29173. /** @hidden */
  29174. _getWebGLTextureType(type: number): number;
  29175. /** @hidden */
  29176. _getInternalFormat(format: number): number;
  29177. /** @hidden */
  29178. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29179. /** @hidden */
  29180. _getRGBAMultiSampleBufferFormat(type: number): number;
  29181. /** @hidden */
  29182. _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;
  29183. /** @hidden */
  29184. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29185. /**
  29186. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29187. * @returns true if the engine can be created
  29188. * @ignorenaming
  29189. */
  29190. static isSupported(): boolean;
  29191. }
  29192. }
  29193. declare module BABYLON {
  29194. /**
  29195. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29196. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29197. */
  29198. export class EffectFallbacks {
  29199. private _defines;
  29200. private _currentRank;
  29201. private _maxRank;
  29202. private _mesh;
  29203. /**
  29204. * Removes the fallback from the bound mesh.
  29205. */
  29206. unBindMesh(): void;
  29207. /**
  29208. * Adds a fallback on the specified property.
  29209. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29210. * @param define The name of the define in the shader
  29211. */
  29212. addFallback(rank: number, define: string): void;
  29213. /**
  29214. * Sets the mesh to use CPU skinning when needing to fallback.
  29215. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29216. * @param mesh The mesh to use the fallbacks.
  29217. */
  29218. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29219. /**
  29220. * Checks to see if more fallbacks are still availible.
  29221. */
  29222. readonly isMoreFallbacks: boolean;
  29223. /**
  29224. * Removes the defines that should be removed when falling back.
  29225. * @param currentDefines defines the current define statements for the shader.
  29226. * @param effect defines the current effect we try to compile
  29227. * @returns The resulting defines with defines of the current rank removed.
  29228. */
  29229. reduce(currentDefines: string, effect: Effect): string;
  29230. }
  29231. /**
  29232. * Options to be used when creating an effect.
  29233. */
  29234. export class EffectCreationOptions {
  29235. /**
  29236. * Atrributes that will be used in the shader.
  29237. */
  29238. attributes: string[];
  29239. /**
  29240. * Uniform varible names that will be set in the shader.
  29241. */
  29242. uniformsNames: string[];
  29243. /**
  29244. * Uniform buffer varible names that will be set in the shader.
  29245. */
  29246. uniformBuffersNames: string[];
  29247. /**
  29248. * Sampler texture variable names that will be set in the shader.
  29249. */
  29250. samplers: string[];
  29251. /**
  29252. * Define statements that will be set in the shader.
  29253. */
  29254. defines: any;
  29255. /**
  29256. * Possible fallbacks for this effect to improve performance when needed.
  29257. */
  29258. fallbacks: Nullable<EffectFallbacks>;
  29259. /**
  29260. * Callback that will be called when the shader is compiled.
  29261. */
  29262. onCompiled: Nullable<(effect: Effect) => void>;
  29263. /**
  29264. * Callback that will be called if an error occurs during shader compilation.
  29265. */
  29266. onError: Nullable<(effect: Effect, errors: string) => void>;
  29267. /**
  29268. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29269. */
  29270. indexParameters: any;
  29271. /**
  29272. * Max number of lights that can be used in the shader.
  29273. */
  29274. maxSimultaneousLights: number;
  29275. /**
  29276. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29277. */
  29278. transformFeedbackVaryings: Nullable<string[]>;
  29279. }
  29280. /**
  29281. * Effect containing vertex and fragment shader that can be executed on an object.
  29282. */
  29283. export class Effect implements IDisposable {
  29284. /**
  29285. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29286. */
  29287. static ShadersRepository: string;
  29288. /**
  29289. * Name of the effect.
  29290. */
  29291. name: any;
  29292. /**
  29293. * String container all the define statements that should be set on the shader.
  29294. */
  29295. defines: string;
  29296. /**
  29297. * Callback that will be called when the shader is compiled.
  29298. */
  29299. onCompiled: Nullable<(effect: Effect) => void>;
  29300. /**
  29301. * Callback that will be called if an error occurs during shader compilation.
  29302. */
  29303. onError: Nullable<(effect: Effect, errors: string) => void>;
  29304. /**
  29305. * Callback that will be called when effect is bound.
  29306. */
  29307. onBind: Nullable<(effect: Effect) => void>;
  29308. /**
  29309. * Unique ID of the effect.
  29310. */
  29311. uniqueId: number;
  29312. /**
  29313. * Observable that will be called when the shader is compiled.
  29314. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29315. */
  29316. onCompileObservable: Observable<Effect>;
  29317. /**
  29318. * Observable that will be called if an error occurs during shader compilation.
  29319. */
  29320. onErrorObservable: Observable<Effect>;
  29321. /** @hidden */
  29322. _onBindObservable: Nullable<Observable<Effect>>;
  29323. /**
  29324. * Observable that will be called when effect is bound.
  29325. */
  29326. readonly onBindObservable: Observable<Effect>;
  29327. /** @hidden */
  29328. _bonesComputationForcedToCPU: boolean;
  29329. private static _uniqueIdSeed;
  29330. private _engine;
  29331. private _uniformBuffersNames;
  29332. private _uniformsNames;
  29333. private _samplerList;
  29334. private _samplers;
  29335. private _isReady;
  29336. private _compilationError;
  29337. private _attributesNames;
  29338. private _attributes;
  29339. private _uniforms;
  29340. /**
  29341. * Key for the effect.
  29342. * @hidden
  29343. */
  29344. _key: string;
  29345. private _indexParameters;
  29346. private _fallbacks;
  29347. private _vertexSourceCode;
  29348. private _fragmentSourceCode;
  29349. private _vertexSourceCodeOverride;
  29350. private _fragmentSourceCodeOverride;
  29351. private _transformFeedbackVaryings;
  29352. /**
  29353. * Compiled shader to webGL program.
  29354. * @hidden
  29355. */
  29356. _pipelineContext: Nullable<IPipelineContext>;
  29357. private _valueCache;
  29358. private static _baseCache;
  29359. /**
  29360. * Instantiates an effect.
  29361. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29362. * @param baseName Name of the effect.
  29363. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29364. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29365. * @param samplers List of sampler variables that will be passed to the shader.
  29366. * @param engine Engine to be used to render the effect
  29367. * @param defines Define statements to be added to the shader.
  29368. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29369. * @param onCompiled Callback that will be called when the shader is compiled.
  29370. * @param onError Callback that will be called if an error occurs during shader compilation.
  29371. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29372. */
  29373. 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);
  29374. /**
  29375. * Unique key for this effect
  29376. */
  29377. readonly key: string;
  29378. /**
  29379. * If the effect has been compiled and prepared.
  29380. * @returns if the effect is compiled and prepared.
  29381. */
  29382. isReady(): boolean;
  29383. /**
  29384. * The engine the effect was initialized with.
  29385. * @returns the engine.
  29386. */
  29387. getEngine(): Engine;
  29388. /**
  29389. * The pipeline context for this effect
  29390. * @returns the associated pipeline context
  29391. */
  29392. getPipelineContext(): Nullable<IPipelineContext>;
  29393. /**
  29394. * The set of names of attribute variables for the shader.
  29395. * @returns An array of attribute names.
  29396. */
  29397. getAttributesNames(): string[];
  29398. /**
  29399. * Returns the attribute at the given index.
  29400. * @param index The index of the attribute.
  29401. * @returns The location of the attribute.
  29402. */
  29403. getAttributeLocation(index: number): number;
  29404. /**
  29405. * Returns the attribute based on the name of the variable.
  29406. * @param name of the attribute to look up.
  29407. * @returns the attribute location.
  29408. */
  29409. getAttributeLocationByName(name: string): number;
  29410. /**
  29411. * The number of attributes.
  29412. * @returns the numnber of attributes.
  29413. */
  29414. getAttributesCount(): number;
  29415. /**
  29416. * Gets the index of a uniform variable.
  29417. * @param uniformName of the uniform to look up.
  29418. * @returns the index.
  29419. */
  29420. getUniformIndex(uniformName: string): number;
  29421. /**
  29422. * Returns the attribute based on the name of the variable.
  29423. * @param uniformName of the uniform to look up.
  29424. * @returns the location of the uniform.
  29425. */
  29426. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29427. /**
  29428. * Returns an array of sampler variable names
  29429. * @returns The array of sampler variable neames.
  29430. */
  29431. getSamplers(): string[];
  29432. /**
  29433. * The error from the last compilation.
  29434. * @returns the error string.
  29435. */
  29436. getCompilationError(): string;
  29437. /**
  29438. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29439. * @param func The callback to be used.
  29440. */
  29441. executeWhenCompiled(func: (effect: Effect) => void): void;
  29442. private _checkIsReady;
  29443. /** @hidden */
  29444. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29445. /** @hidden */
  29446. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29447. /** @hidden */
  29448. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29449. /**
  29450. * Recompiles the webGL program
  29451. * @param vertexSourceCode The source code for the vertex shader.
  29452. * @param fragmentSourceCode The source code for the fragment shader.
  29453. * @param onCompiled Callback called when completed.
  29454. * @param onError Callback called on error.
  29455. * @hidden
  29456. */
  29457. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29458. /**
  29459. * Prepares the effect
  29460. * @hidden
  29461. */
  29462. _prepareEffect(): void;
  29463. /**
  29464. * Checks if the effect is supported. (Must be called after compilation)
  29465. */
  29466. readonly isSupported: boolean;
  29467. /**
  29468. * Binds a texture to the engine to be used as output of the shader.
  29469. * @param channel Name of the output variable.
  29470. * @param texture Texture to bind.
  29471. * @hidden
  29472. */
  29473. _bindTexture(channel: string, texture: InternalTexture): void;
  29474. /**
  29475. * Sets a texture on the engine to be used in the shader.
  29476. * @param channel Name of the sampler variable.
  29477. * @param texture Texture to set.
  29478. */
  29479. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29480. /**
  29481. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29482. * @param channel Name of the sampler variable.
  29483. * @param texture Texture to set.
  29484. */
  29485. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29486. /**
  29487. * Sets an array of textures on the engine to be used in the shader.
  29488. * @param channel Name of the variable.
  29489. * @param textures Textures to set.
  29490. */
  29491. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29492. /**
  29493. * 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)
  29494. * @param channel Name of the sampler variable.
  29495. * @param postProcess Post process to get the input texture from.
  29496. */
  29497. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29498. /**
  29499. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29500. * 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)
  29501. * @param channel Name of the sampler variable.
  29502. * @param postProcess Post process to get the output texture from.
  29503. */
  29504. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29505. /** @hidden */
  29506. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29507. /** @hidden */
  29508. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29509. /** @hidden */
  29510. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29511. /** @hidden */
  29512. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29513. /**
  29514. * Binds a buffer to a uniform.
  29515. * @param buffer Buffer to bind.
  29516. * @param name Name of the uniform variable to bind to.
  29517. */
  29518. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29519. /**
  29520. * Binds block to a uniform.
  29521. * @param blockName Name of the block to bind.
  29522. * @param index Index to bind.
  29523. */
  29524. bindUniformBlock(blockName: string, index: number): void;
  29525. /**
  29526. * Sets an interger value on a uniform variable.
  29527. * @param uniformName Name of the variable.
  29528. * @param value Value to be set.
  29529. * @returns this effect.
  29530. */
  29531. setInt(uniformName: string, value: number): Effect;
  29532. /**
  29533. * Sets an int array on a uniform variable.
  29534. * @param uniformName Name of the variable.
  29535. * @param array array to be set.
  29536. * @returns this effect.
  29537. */
  29538. setIntArray(uniformName: string, array: Int32Array): Effect;
  29539. /**
  29540. * 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)
  29541. * @param uniformName Name of the variable.
  29542. * @param array array to be set.
  29543. * @returns this effect.
  29544. */
  29545. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29546. /**
  29547. * 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)
  29548. * @param uniformName Name of the variable.
  29549. * @param array array to be set.
  29550. * @returns this effect.
  29551. */
  29552. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29553. /**
  29554. * 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)
  29555. * @param uniformName Name of the variable.
  29556. * @param array array to be set.
  29557. * @returns this effect.
  29558. */
  29559. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29560. /**
  29561. * Sets an float array on a uniform variable.
  29562. * @param uniformName Name of the variable.
  29563. * @param array array to be set.
  29564. * @returns this effect.
  29565. */
  29566. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29567. /**
  29568. * 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)
  29569. * @param uniformName Name of the variable.
  29570. * @param array array to be set.
  29571. * @returns this effect.
  29572. */
  29573. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29574. /**
  29575. * 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)
  29576. * @param uniformName Name of the variable.
  29577. * @param array array to be set.
  29578. * @returns this effect.
  29579. */
  29580. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29581. /**
  29582. * 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)
  29583. * @param uniformName Name of the variable.
  29584. * @param array array to be set.
  29585. * @returns this effect.
  29586. */
  29587. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29588. /**
  29589. * Sets an array on a uniform variable.
  29590. * @param uniformName Name of the variable.
  29591. * @param array array to be set.
  29592. * @returns this effect.
  29593. */
  29594. setArray(uniformName: string, array: number[]): Effect;
  29595. /**
  29596. * 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)
  29597. * @param uniformName Name of the variable.
  29598. * @param array array to be set.
  29599. * @returns this effect.
  29600. */
  29601. setArray2(uniformName: string, array: number[]): Effect;
  29602. /**
  29603. * 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)
  29604. * @param uniformName Name of the variable.
  29605. * @param array array to be set.
  29606. * @returns this effect.
  29607. */
  29608. setArray3(uniformName: string, array: number[]): Effect;
  29609. /**
  29610. * 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)
  29611. * @param uniformName Name of the variable.
  29612. * @param array array to be set.
  29613. * @returns this effect.
  29614. */
  29615. setArray4(uniformName: string, array: number[]): Effect;
  29616. /**
  29617. * Sets matrices on a uniform variable.
  29618. * @param uniformName Name of the variable.
  29619. * @param matrices matrices to be set.
  29620. * @returns this effect.
  29621. */
  29622. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29623. /**
  29624. * Sets matrix on a uniform variable.
  29625. * @param uniformName Name of the variable.
  29626. * @param matrix matrix to be set.
  29627. * @returns this effect.
  29628. */
  29629. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29630. /**
  29631. * 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)
  29632. * @param uniformName Name of the variable.
  29633. * @param matrix matrix to be set.
  29634. * @returns this effect.
  29635. */
  29636. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29637. /**
  29638. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29639. * @param uniformName Name of the variable.
  29640. * @param matrix matrix to be set.
  29641. * @returns this effect.
  29642. */
  29643. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29644. /**
  29645. * Sets a float on a uniform variable.
  29646. * @param uniformName Name of the variable.
  29647. * @param value value to be set.
  29648. * @returns this effect.
  29649. */
  29650. setFloat(uniformName: string, value: number): Effect;
  29651. /**
  29652. * Sets a boolean on a uniform variable.
  29653. * @param uniformName Name of the variable.
  29654. * @param bool value to be set.
  29655. * @returns this effect.
  29656. */
  29657. setBool(uniformName: string, bool: boolean): Effect;
  29658. /**
  29659. * Sets a Vector2 on a uniform variable.
  29660. * @param uniformName Name of the variable.
  29661. * @param vector2 vector2 to be set.
  29662. * @returns this effect.
  29663. */
  29664. setVector2(uniformName: string, vector2: Vector2): Effect;
  29665. /**
  29666. * Sets a float2 on a uniform variable.
  29667. * @param uniformName Name of the variable.
  29668. * @param x First float in float2.
  29669. * @param y Second float in float2.
  29670. * @returns this effect.
  29671. */
  29672. setFloat2(uniformName: string, x: number, y: number): Effect;
  29673. /**
  29674. * Sets a Vector3 on a uniform variable.
  29675. * @param uniformName Name of the variable.
  29676. * @param vector3 Value to be set.
  29677. * @returns this effect.
  29678. */
  29679. setVector3(uniformName: string, vector3: Vector3): Effect;
  29680. /**
  29681. * Sets a float3 on a uniform variable.
  29682. * @param uniformName Name of the variable.
  29683. * @param x First float in float3.
  29684. * @param y Second float in float3.
  29685. * @param z Third float in float3.
  29686. * @returns this effect.
  29687. */
  29688. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29689. /**
  29690. * Sets a Vector4 on a uniform variable.
  29691. * @param uniformName Name of the variable.
  29692. * @param vector4 Value to be set.
  29693. * @returns this effect.
  29694. */
  29695. setVector4(uniformName: string, vector4: Vector4): Effect;
  29696. /**
  29697. * Sets a float4 on a uniform variable.
  29698. * @param uniformName Name of the variable.
  29699. * @param x First float in float4.
  29700. * @param y Second float in float4.
  29701. * @param z Third float in float4.
  29702. * @param w Fourth float in float4.
  29703. * @returns this effect.
  29704. */
  29705. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29706. /**
  29707. * Sets a Color3 on a uniform variable.
  29708. * @param uniformName Name of the variable.
  29709. * @param color3 Value to be set.
  29710. * @returns this effect.
  29711. */
  29712. setColor3(uniformName: string, color3: Color3): Effect;
  29713. /**
  29714. * Sets a Color4 on a uniform variable.
  29715. * @param uniformName Name of the variable.
  29716. * @param color3 Value to be set.
  29717. * @param alpha Alpha value to be set.
  29718. * @returns this effect.
  29719. */
  29720. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29721. /**
  29722. * Sets a Color4 on a uniform variable
  29723. * @param uniformName defines the name of the variable
  29724. * @param color4 defines the value to be set
  29725. * @returns this effect.
  29726. */
  29727. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29728. /** Release all associated resources */
  29729. dispose(): void;
  29730. /**
  29731. * This function will add a new shader to the shader store
  29732. * @param name the name of the shader
  29733. * @param pixelShader optional pixel shader content
  29734. * @param vertexShader optional vertex shader content
  29735. */
  29736. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29737. /**
  29738. * Store of each shader (The can be looked up using effect.key)
  29739. */
  29740. static ShadersStore: {
  29741. [key: string]: string;
  29742. };
  29743. /**
  29744. * Store of each included file for a shader (The can be looked up using effect.key)
  29745. */
  29746. static IncludesShadersStore: {
  29747. [key: string]: string;
  29748. };
  29749. /**
  29750. * Resets the cache of effects.
  29751. */
  29752. static ResetCache(): void;
  29753. }
  29754. }
  29755. declare module BABYLON {
  29756. /**
  29757. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29758. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29759. * 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;
  29760. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29761. */
  29762. export class ColorCurves {
  29763. private _dirty;
  29764. private _tempColor;
  29765. private _globalCurve;
  29766. private _highlightsCurve;
  29767. private _midtonesCurve;
  29768. private _shadowsCurve;
  29769. private _positiveCurve;
  29770. private _negativeCurve;
  29771. private _globalHue;
  29772. private _globalDensity;
  29773. private _globalSaturation;
  29774. private _globalExposure;
  29775. /**
  29776. * Gets the global Hue value.
  29777. * 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).
  29778. */
  29779. /**
  29780. * Sets the global Hue value.
  29781. * 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).
  29782. */
  29783. globalHue: number;
  29784. /**
  29785. * Gets the global Density value.
  29786. * 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.
  29787. * Values less than zero provide a filter of opposite hue.
  29788. */
  29789. /**
  29790. * Sets the global Density value.
  29791. * 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.
  29792. * Values less than zero provide a filter of opposite hue.
  29793. */
  29794. globalDensity: number;
  29795. /**
  29796. * Gets the global Saturation value.
  29797. * 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.
  29798. */
  29799. /**
  29800. * Sets the global Saturation value.
  29801. * 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.
  29802. */
  29803. globalSaturation: number;
  29804. /**
  29805. * Gets the global Exposure value.
  29806. * 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.
  29807. */
  29808. /**
  29809. * Sets the global Exposure value.
  29810. * 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.
  29811. */
  29812. globalExposure: number;
  29813. private _highlightsHue;
  29814. private _highlightsDensity;
  29815. private _highlightsSaturation;
  29816. private _highlightsExposure;
  29817. /**
  29818. * Gets the highlights Hue value.
  29819. * 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).
  29820. */
  29821. /**
  29822. * Sets the highlights Hue value.
  29823. * 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).
  29824. */
  29825. highlightsHue: number;
  29826. /**
  29827. * Gets the highlights Density value.
  29828. * 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.
  29829. * Values less than zero provide a filter of opposite hue.
  29830. */
  29831. /**
  29832. * Sets the highlights Density value.
  29833. * 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.
  29834. * Values less than zero provide a filter of opposite hue.
  29835. */
  29836. highlightsDensity: number;
  29837. /**
  29838. * Gets the highlights Saturation value.
  29839. * 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.
  29840. */
  29841. /**
  29842. * Sets the highlights Saturation value.
  29843. * 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.
  29844. */
  29845. highlightsSaturation: number;
  29846. /**
  29847. * Gets the highlights Exposure value.
  29848. * 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.
  29849. */
  29850. /**
  29851. * Sets the highlights Exposure value.
  29852. * 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.
  29853. */
  29854. highlightsExposure: number;
  29855. private _midtonesHue;
  29856. private _midtonesDensity;
  29857. private _midtonesSaturation;
  29858. private _midtonesExposure;
  29859. /**
  29860. * Gets the midtones Hue value.
  29861. * 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).
  29862. */
  29863. /**
  29864. * Sets the midtones Hue value.
  29865. * 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).
  29866. */
  29867. midtonesHue: number;
  29868. /**
  29869. * Gets the midtones Density value.
  29870. * 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.
  29871. * Values less than zero provide a filter of opposite hue.
  29872. */
  29873. /**
  29874. * Sets the midtones Density value.
  29875. * 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.
  29876. * Values less than zero provide a filter of opposite hue.
  29877. */
  29878. midtonesDensity: number;
  29879. /**
  29880. * Gets the midtones Saturation value.
  29881. * 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.
  29882. */
  29883. /**
  29884. * Sets the midtones Saturation value.
  29885. * 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.
  29886. */
  29887. midtonesSaturation: number;
  29888. /**
  29889. * Gets the midtones Exposure value.
  29890. * 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.
  29891. */
  29892. /**
  29893. * Sets the midtones Exposure value.
  29894. * 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.
  29895. */
  29896. midtonesExposure: number;
  29897. private _shadowsHue;
  29898. private _shadowsDensity;
  29899. private _shadowsSaturation;
  29900. private _shadowsExposure;
  29901. /**
  29902. * Gets the shadows Hue value.
  29903. * 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).
  29904. */
  29905. /**
  29906. * Sets the shadows Hue value.
  29907. * 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).
  29908. */
  29909. shadowsHue: number;
  29910. /**
  29911. * Gets the shadows Density value.
  29912. * 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.
  29913. * Values less than zero provide a filter of opposite hue.
  29914. */
  29915. /**
  29916. * Sets the shadows Density value.
  29917. * 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.
  29918. * Values less than zero provide a filter of opposite hue.
  29919. */
  29920. shadowsDensity: number;
  29921. /**
  29922. * Gets the shadows Saturation value.
  29923. * 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.
  29924. */
  29925. /**
  29926. * Sets the shadows Saturation value.
  29927. * 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.
  29928. */
  29929. shadowsSaturation: number;
  29930. /**
  29931. * Gets the shadows Exposure value.
  29932. * 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.
  29933. */
  29934. /**
  29935. * Sets the shadows Exposure value.
  29936. * 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.
  29937. */
  29938. shadowsExposure: number;
  29939. /**
  29940. * Returns the class name
  29941. * @returns The class name
  29942. */
  29943. getClassName(): string;
  29944. /**
  29945. * Binds the color curves to the shader.
  29946. * @param colorCurves The color curve to bind
  29947. * @param effect The effect to bind to
  29948. * @param positiveUniform The positive uniform shader parameter
  29949. * @param neutralUniform The neutral uniform shader parameter
  29950. * @param negativeUniform The negative uniform shader parameter
  29951. */
  29952. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29953. /**
  29954. * Prepare the list of uniforms associated with the ColorCurves effects.
  29955. * @param uniformsList The list of uniforms used in the effect
  29956. */
  29957. static PrepareUniforms(uniformsList: string[]): void;
  29958. /**
  29959. * Returns color grading data based on a hue, density, saturation and exposure value.
  29960. * @param filterHue The hue of the color filter.
  29961. * @param filterDensity The density of the color filter.
  29962. * @param saturation The saturation.
  29963. * @param exposure The exposure.
  29964. * @param result The result data container.
  29965. */
  29966. private getColorGradingDataToRef;
  29967. /**
  29968. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29969. * @param value The input slider value in range [-100,100].
  29970. * @returns Adjusted value.
  29971. */
  29972. private static applyColorGradingSliderNonlinear;
  29973. /**
  29974. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29975. * @param hue The hue (H) input.
  29976. * @param saturation The saturation (S) input.
  29977. * @param brightness The brightness (B) input.
  29978. * @result An RGBA color represented as Vector4.
  29979. */
  29980. private static fromHSBToRef;
  29981. /**
  29982. * Returns a value clamped between min and max
  29983. * @param value The value to clamp
  29984. * @param min The minimum of value
  29985. * @param max The maximum of value
  29986. * @returns The clamped value.
  29987. */
  29988. private static clamp;
  29989. /**
  29990. * Clones the current color curve instance.
  29991. * @return The cloned curves
  29992. */
  29993. clone(): ColorCurves;
  29994. /**
  29995. * Serializes the current color curve instance to a json representation.
  29996. * @return a JSON representation
  29997. */
  29998. serialize(): any;
  29999. /**
  30000. * Parses the color curve from a json representation.
  30001. * @param source the JSON source to parse
  30002. * @return The parsed curves
  30003. */
  30004. static Parse(source: any): ColorCurves;
  30005. }
  30006. }
  30007. declare module BABYLON {
  30008. /**
  30009. * Interface to follow in your material defines to integrate easily the
  30010. * Image proccessing functions.
  30011. * @hidden
  30012. */
  30013. export interface IImageProcessingConfigurationDefines {
  30014. IMAGEPROCESSING: boolean;
  30015. VIGNETTE: boolean;
  30016. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30017. VIGNETTEBLENDMODEOPAQUE: boolean;
  30018. TONEMAPPING: boolean;
  30019. TONEMAPPING_ACES: boolean;
  30020. CONTRAST: boolean;
  30021. EXPOSURE: boolean;
  30022. COLORCURVES: boolean;
  30023. COLORGRADING: boolean;
  30024. COLORGRADING3D: boolean;
  30025. SAMPLER3DGREENDEPTH: boolean;
  30026. SAMPLER3DBGRMAP: boolean;
  30027. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30028. }
  30029. /**
  30030. * @hidden
  30031. */
  30032. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30033. IMAGEPROCESSING: boolean;
  30034. VIGNETTE: boolean;
  30035. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30036. VIGNETTEBLENDMODEOPAQUE: boolean;
  30037. TONEMAPPING: boolean;
  30038. TONEMAPPING_ACES: boolean;
  30039. CONTRAST: boolean;
  30040. COLORCURVES: boolean;
  30041. COLORGRADING: boolean;
  30042. COLORGRADING3D: boolean;
  30043. SAMPLER3DGREENDEPTH: boolean;
  30044. SAMPLER3DBGRMAP: boolean;
  30045. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30046. EXPOSURE: boolean;
  30047. constructor();
  30048. }
  30049. /**
  30050. * This groups together the common properties used for image processing either in direct forward pass
  30051. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30052. * or not.
  30053. */
  30054. export class ImageProcessingConfiguration {
  30055. /**
  30056. * Default tone mapping applied in BabylonJS.
  30057. */
  30058. static readonly TONEMAPPING_STANDARD: number;
  30059. /**
  30060. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30061. * to other engines rendering to increase portability.
  30062. */
  30063. static readonly TONEMAPPING_ACES: number;
  30064. /**
  30065. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30066. */
  30067. colorCurves: Nullable<ColorCurves>;
  30068. private _colorCurvesEnabled;
  30069. /**
  30070. * Gets wether the color curves effect is enabled.
  30071. */
  30072. /**
  30073. * Sets wether the color curves effect is enabled.
  30074. */
  30075. colorCurvesEnabled: boolean;
  30076. private _colorGradingTexture;
  30077. /**
  30078. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30079. */
  30080. /**
  30081. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30082. */
  30083. colorGradingTexture: Nullable<BaseTexture>;
  30084. private _colorGradingEnabled;
  30085. /**
  30086. * Gets wether the color grading effect is enabled.
  30087. */
  30088. /**
  30089. * Sets wether the color grading effect is enabled.
  30090. */
  30091. colorGradingEnabled: boolean;
  30092. private _colorGradingWithGreenDepth;
  30093. /**
  30094. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30095. */
  30096. /**
  30097. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30098. */
  30099. colorGradingWithGreenDepth: boolean;
  30100. private _colorGradingBGR;
  30101. /**
  30102. * Gets wether the color grading texture contains BGR values.
  30103. */
  30104. /**
  30105. * Sets wether the color grading texture contains BGR values.
  30106. */
  30107. colorGradingBGR: boolean;
  30108. /** @hidden */
  30109. _exposure: number;
  30110. /**
  30111. * Gets the Exposure used in the effect.
  30112. */
  30113. /**
  30114. * Sets the Exposure used in the effect.
  30115. */
  30116. exposure: number;
  30117. private _toneMappingEnabled;
  30118. /**
  30119. * Gets wether the tone mapping effect is enabled.
  30120. */
  30121. /**
  30122. * Sets wether the tone mapping effect is enabled.
  30123. */
  30124. toneMappingEnabled: boolean;
  30125. private _toneMappingType;
  30126. /**
  30127. * Gets the type of tone mapping effect.
  30128. */
  30129. /**
  30130. * Sets the type of tone mapping effect used in BabylonJS.
  30131. */
  30132. toneMappingType: number;
  30133. protected _contrast: number;
  30134. /**
  30135. * Gets the contrast used in the effect.
  30136. */
  30137. /**
  30138. * Sets the contrast used in the effect.
  30139. */
  30140. contrast: number;
  30141. /**
  30142. * Vignette stretch size.
  30143. */
  30144. vignetteStretch: number;
  30145. /**
  30146. * Vignette centre X Offset.
  30147. */
  30148. vignetteCentreX: number;
  30149. /**
  30150. * Vignette centre Y Offset.
  30151. */
  30152. vignetteCentreY: number;
  30153. /**
  30154. * Vignette weight or intensity of the vignette effect.
  30155. */
  30156. vignetteWeight: number;
  30157. /**
  30158. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30159. * if vignetteEnabled is set to true.
  30160. */
  30161. vignetteColor: Color4;
  30162. /**
  30163. * Camera field of view used by the Vignette effect.
  30164. */
  30165. vignetteCameraFov: number;
  30166. private _vignetteBlendMode;
  30167. /**
  30168. * Gets the vignette blend mode allowing different kind of effect.
  30169. */
  30170. /**
  30171. * Sets the vignette blend mode allowing different kind of effect.
  30172. */
  30173. vignetteBlendMode: number;
  30174. private _vignetteEnabled;
  30175. /**
  30176. * Gets wether the vignette effect is enabled.
  30177. */
  30178. /**
  30179. * Sets wether the vignette effect is enabled.
  30180. */
  30181. vignetteEnabled: boolean;
  30182. private _applyByPostProcess;
  30183. /**
  30184. * Gets wether the image processing is applied through a post process or not.
  30185. */
  30186. /**
  30187. * Sets wether the image processing is applied through a post process or not.
  30188. */
  30189. applyByPostProcess: boolean;
  30190. private _isEnabled;
  30191. /**
  30192. * Gets wether the image processing is enabled or not.
  30193. */
  30194. /**
  30195. * Sets wether the image processing is enabled or not.
  30196. */
  30197. isEnabled: boolean;
  30198. /**
  30199. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30200. */
  30201. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30202. /**
  30203. * Method called each time the image processing information changes requires to recompile the effect.
  30204. */
  30205. protected _updateParameters(): void;
  30206. /**
  30207. * Gets the current class name.
  30208. * @return "ImageProcessingConfiguration"
  30209. */
  30210. getClassName(): string;
  30211. /**
  30212. * Prepare the list of uniforms associated with the Image Processing effects.
  30213. * @param uniforms The list of uniforms used in the effect
  30214. * @param defines the list of defines currently in use
  30215. */
  30216. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30217. /**
  30218. * Prepare the list of samplers associated with the Image Processing effects.
  30219. * @param samplersList The list of uniforms used in the effect
  30220. * @param defines the list of defines currently in use
  30221. */
  30222. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30223. /**
  30224. * Prepare the list of defines associated to the shader.
  30225. * @param defines the list of defines to complete
  30226. * @param forPostProcess Define if we are currently in post process mode or not
  30227. */
  30228. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30229. /**
  30230. * Returns true if all the image processing information are ready.
  30231. * @returns True if ready, otherwise, false
  30232. */
  30233. isReady(): boolean;
  30234. /**
  30235. * Binds the image processing to the shader.
  30236. * @param effect The effect to bind to
  30237. * @param aspectRatio Define the current aspect ratio of the effect
  30238. */
  30239. bind(effect: Effect, aspectRatio?: number): void;
  30240. /**
  30241. * Clones the current image processing instance.
  30242. * @return The cloned image processing
  30243. */
  30244. clone(): ImageProcessingConfiguration;
  30245. /**
  30246. * Serializes the current image processing instance to a json representation.
  30247. * @return a JSON representation
  30248. */
  30249. serialize(): any;
  30250. /**
  30251. * Parses the image processing from a json representation.
  30252. * @param source the JSON source to parse
  30253. * @return The parsed image processing
  30254. */
  30255. static Parse(source: any): ImageProcessingConfiguration;
  30256. private static _VIGNETTEMODE_MULTIPLY;
  30257. private static _VIGNETTEMODE_OPAQUE;
  30258. /**
  30259. * Used to apply the vignette as a mix with the pixel color.
  30260. */
  30261. static readonly VIGNETTEMODE_MULTIPLY: number;
  30262. /**
  30263. * Used to apply the vignette as a replacement of the pixel color.
  30264. */
  30265. static readonly VIGNETTEMODE_OPAQUE: number;
  30266. }
  30267. }
  30268. declare module BABYLON {
  30269. /**
  30270. * This represents all the required information to add a fresnel effect on a material:
  30271. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30272. */
  30273. export class FresnelParameters {
  30274. private _isEnabled;
  30275. /**
  30276. * Define if the fresnel effect is enable or not.
  30277. */
  30278. isEnabled: boolean;
  30279. /**
  30280. * Define the color used on edges (grazing angle)
  30281. */
  30282. leftColor: Color3;
  30283. /**
  30284. * Define the color used on center
  30285. */
  30286. rightColor: Color3;
  30287. /**
  30288. * Define bias applied to computed fresnel term
  30289. */
  30290. bias: number;
  30291. /**
  30292. * Defined the power exponent applied to fresnel term
  30293. */
  30294. power: number;
  30295. /**
  30296. * Clones the current fresnel and its valuues
  30297. * @returns a clone fresnel configuration
  30298. */
  30299. clone(): FresnelParameters;
  30300. /**
  30301. * Serializes the current fresnel parameters to a JSON representation.
  30302. * @return the JSON serialization
  30303. */
  30304. serialize(): any;
  30305. /**
  30306. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30307. * @param parsedFresnelParameters Define the JSON representation
  30308. * @returns the parsed parameters
  30309. */
  30310. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30311. }
  30312. }
  30313. declare module BABYLON {
  30314. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30315. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30316. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30317. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30318. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30319. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30320. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30321. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30322. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30323. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30324. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30325. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30326. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30327. /**
  30328. * Decorator used to define property that can be serialized as reference to a camera
  30329. * @param sourceName defines the name of the property to decorate
  30330. */
  30331. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30332. /**
  30333. * Class used to help serialization objects
  30334. */
  30335. export class SerializationHelper {
  30336. /** hidden */
  30337. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30338. /** hidden */
  30339. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30340. /** hidden */
  30341. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30342. /** hidden */
  30343. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30344. /**
  30345. * Appends the serialized animations from the source animations
  30346. * @param source Source containing the animations
  30347. * @param destination Target to store the animations
  30348. */
  30349. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30350. /**
  30351. * Static function used to serialized a specific entity
  30352. * @param entity defines the entity to serialize
  30353. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30354. * @returns a JSON compatible object representing the serialization of the entity
  30355. */
  30356. static Serialize<T>(entity: T, serializationObject?: any): any;
  30357. /**
  30358. * Creates a new entity from a serialization data object
  30359. * @param creationFunction defines a function used to instanciated the new entity
  30360. * @param source defines the source serialization data
  30361. * @param scene defines the hosting scene
  30362. * @param rootUrl defines the root url for resources
  30363. * @returns a new entity
  30364. */
  30365. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30366. /**
  30367. * Clones an object
  30368. * @param creationFunction defines the function used to instanciate the new object
  30369. * @param source defines the source object
  30370. * @returns the cloned object
  30371. */
  30372. static Clone<T>(creationFunction: () => T, source: T): T;
  30373. /**
  30374. * Instanciates a new object based on a source one (some data will be shared between both object)
  30375. * @param creationFunction defines the function used to instanciate the new object
  30376. * @param source defines the source object
  30377. * @returns the new object
  30378. */
  30379. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30380. }
  30381. }
  30382. declare module BABYLON {
  30383. /**
  30384. * This is the base class of all the camera used in the application.
  30385. * @see http://doc.babylonjs.com/features/cameras
  30386. */
  30387. export class Camera extends Node {
  30388. /** @hidden */
  30389. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30390. /**
  30391. * This is the default projection mode used by the cameras.
  30392. * It helps recreating a feeling of perspective and better appreciate depth.
  30393. * This is the best way to simulate real life cameras.
  30394. */
  30395. static readonly PERSPECTIVE_CAMERA: number;
  30396. /**
  30397. * This helps creating camera with an orthographic mode.
  30398. * 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.
  30399. */
  30400. static readonly ORTHOGRAPHIC_CAMERA: number;
  30401. /**
  30402. * This is the default FOV mode for perspective cameras.
  30403. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30404. */
  30405. static readonly FOVMODE_VERTICAL_FIXED: number;
  30406. /**
  30407. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30408. */
  30409. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30410. /**
  30411. * This specifies ther is no need for a camera rig.
  30412. * Basically only one eye is rendered corresponding to the camera.
  30413. */
  30414. static readonly RIG_MODE_NONE: number;
  30415. /**
  30416. * Simulates a camera Rig with one blue eye and one red eye.
  30417. * This can be use with 3d blue and red glasses.
  30418. */
  30419. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30420. /**
  30421. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30422. */
  30423. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30424. /**
  30425. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30426. */
  30427. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30428. /**
  30429. * Defines that both eyes of the camera will be rendered over under each other.
  30430. */
  30431. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30432. /**
  30433. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30434. */
  30435. static readonly RIG_MODE_VR: number;
  30436. /**
  30437. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30438. */
  30439. static readonly RIG_MODE_WEBVR: number;
  30440. /**
  30441. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30442. */
  30443. static readonly RIG_MODE_CUSTOM: number;
  30444. /**
  30445. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30446. */
  30447. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30448. /**
  30449. * Define the input manager associated with the camera.
  30450. */
  30451. inputs: CameraInputsManager<Camera>;
  30452. /** @hidden */
  30453. _position: Vector3;
  30454. /**
  30455. * Define the current local position of the camera in the scene
  30456. */
  30457. position: Vector3;
  30458. /**
  30459. * The vector the camera should consider as up.
  30460. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30461. */
  30462. upVector: Vector3;
  30463. /**
  30464. * Define the current limit on the left side for an orthographic camera
  30465. * In scene unit
  30466. */
  30467. orthoLeft: Nullable<number>;
  30468. /**
  30469. * Define the current limit on the right side for an orthographic camera
  30470. * In scene unit
  30471. */
  30472. orthoRight: Nullable<number>;
  30473. /**
  30474. * Define the current limit on the bottom side for an orthographic camera
  30475. * In scene unit
  30476. */
  30477. orthoBottom: Nullable<number>;
  30478. /**
  30479. * Define the current limit on the top side for an orthographic camera
  30480. * In scene unit
  30481. */
  30482. orthoTop: Nullable<number>;
  30483. /**
  30484. * Field Of View is set in Radians. (default is 0.8)
  30485. */
  30486. fov: number;
  30487. /**
  30488. * Define the minimum distance the camera can see from.
  30489. * This is important to note that the depth buffer are not infinite and the closer it starts
  30490. * the more your scene might encounter depth fighting issue.
  30491. */
  30492. minZ: number;
  30493. /**
  30494. * Define the maximum distance the camera can see to.
  30495. * This is important to note that the depth buffer are not infinite and the further it end
  30496. * the more your scene might encounter depth fighting issue.
  30497. */
  30498. maxZ: number;
  30499. /**
  30500. * Define the default inertia of the camera.
  30501. * This helps giving a smooth feeling to the camera movement.
  30502. */
  30503. inertia: number;
  30504. /**
  30505. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30506. */
  30507. mode: number;
  30508. /**
  30509. * Define wether the camera is intermediate.
  30510. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30511. */
  30512. isIntermediate: boolean;
  30513. /**
  30514. * Define the viewport of the camera.
  30515. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30516. */
  30517. viewport: Viewport;
  30518. /**
  30519. * Restricts the camera to viewing objects with the same layerMask.
  30520. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30521. */
  30522. layerMask: number;
  30523. /**
  30524. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30525. */
  30526. fovMode: number;
  30527. /**
  30528. * Rig mode of the camera.
  30529. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30530. * This is normally controlled byt the camera themselves as internal use.
  30531. */
  30532. cameraRigMode: number;
  30533. /**
  30534. * Defines the distance between both "eyes" in case of a RIG
  30535. */
  30536. interaxialDistance: number;
  30537. /**
  30538. * Defines if stereoscopic rendering is done side by side or over under.
  30539. */
  30540. isStereoscopicSideBySide: boolean;
  30541. /**
  30542. * 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
  30543. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30544. * else in the scene.
  30545. */
  30546. customRenderTargets: RenderTargetTexture[];
  30547. /**
  30548. * When set, the camera will render to this render target instead of the default canvas
  30549. */
  30550. outputRenderTarget: Nullable<RenderTargetTexture>;
  30551. /**
  30552. * Observable triggered when the camera view matrix has changed.
  30553. */
  30554. onViewMatrixChangedObservable: Observable<Camera>;
  30555. /**
  30556. * Observable triggered when the camera Projection matrix has changed.
  30557. */
  30558. onProjectionMatrixChangedObservable: Observable<Camera>;
  30559. /**
  30560. * Observable triggered when the inputs have been processed.
  30561. */
  30562. onAfterCheckInputsObservable: Observable<Camera>;
  30563. /**
  30564. * Observable triggered when reset has been called and applied to the camera.
  30565. */
  30566. onRestoreStateObservable: Observable<Camera>;
  30567. /** @hidden */
  30568. _cameraRigParams: any;
  30569. /** @hidden */
  30570. _rigCameras: Camera[];
  30571. /** @hidden */
  30572. _rigPostProcess: Nullable<PostProcess>;
  30573. protected _webvrViewMatrix: Matrix;
  30574. /** @hidden */
  30575. _skipRendering: boolean;
  30576. /** @hidden */
  30577. _projectionMatrix: Matrix;
  30578. /** @hidden */
  30579. _postProcesses: Nullable<PostProcess>[];
  30580. /** @hidden */
  30581. _activeMeshes: SmartArray<AbstractMesh>;
  30582. protected _globalPosition: Vector3;
  30583. /** hidden */
  30584. _computedViewMatrix: Matrix;
  30585. private _doNotComputeProjectionMatrix;
  30586. private _transformMatrix;
  30587. private _frustumPlanes;
  30588. private _refreshFrustumPlanes;
  30589. private _storedFov;
  30590. private _stateStored;
  30591. /**
  30592. * Instantiates a new camera object.
  30593. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30594. * @see http://doc.babylonjs.com/features/cameras
  30595. * @param name Defines the name of the camera in the scene
  30596. * @param position Defines the position of the camera
  30597. * @param scene Defines the scene the camera belongs too
  30598. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30599. */
  30600. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30601. /**
  30602. * Store current camera state (fov, position, etc..)
  30603. * @returns the camera
  30604. */
  30605. storeState(): Camera;
  30606. /**
  30607. * Restores the camera state values if it has been stored. You must call storeState() first
  30608. */
  30609. protected _restoreStateValues(): boolean;
  30610. /**
  30611. * Restored camera state. You must call storeState() first.
  30612. * @returns true if restored and false otherwise
  30613. */
  30614. restoreState(): boolean;
  30615. /**
  30616. * Gets the class name of the camera.
  30617. * @returns the class name
  30618. */
  30619. getClassName(): string;
  30620. /** @hidden */
  30621. readonly _isCamera: boolean;
  30622. /**
  30623. * Gets a string representation of the camera useful for debug purpose.
  30624. * @param fullDetails Defines that a more verboe level of logging is required
  30625. * @returns the string representation
  30626. */
  30627. toString(fullDetails?: boolean): string;
  30628. /**
  30629. * Gets the current world space position of the camera.
  30630. */
  30631. readonly globalPosition: Vector3;
  30632. /**
  30633. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30634. * @returns the active meshe list
  30635. */
  30636. getActiveMeshes(): SmartArray<AbstractMesh>;
  30637. /**
  30638. * Check wether a mesh is part of the current active mesh list of the camera
  30639. * @param mesh Defines the mesh to check
  30640. * @returns true if active, false otherwise
  30641. */
  30642. isActiveMesh(mesh: Mesh): boolean;
  30643. /**
  30644. * Is this camera ready to be used/rendered
  30645. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30646. * @return true if the camera is ready
  30647. */
  30648. isReady(completeCheck?: boolean): boolean;
  30649. /** @hidden */
  30650. _initCache(): void;
  30651. /** @hidden */
  30652. _updateCache(ignoreParentClass?: boolean): void;
  30653. /** @hidden */
  30654. _isSynchronized(): boolean;
  30655. /** @hidden */
  30656. _isSynchronizedViewMatrix(): boolean;
  30657. /** @hidden */
  30658. _isSynchronizedProjectionMatrix(): boolean;
  30659. /**
  30660. * Attach the input controls to a specific dom element to get the input from.
  30661. * @param element Defines the element the controls should be listened from
  30662. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30663. */
  30664. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30665. /**
  30666. * Detach the current controls from the specified dom element.
  30667. * @param element Defines the element to stop listening the inputs from
  30668. */
  30669. detachControl(element: HTMLElement): void;
  30670. /**
  30671. * Update the camera state according to the different inputs gathered during the frame.
  30672. */
  30673. update(): void;
  30674. /** @hidden */
  30675. _checkInputs(): void;
  30676. /** @hidden */
  30677. readonly rigCameras: Camera[];
  30678. /**
  30679. * Gets the post process used by the rig cameras
  30680. */
  30681. readonly rigPostProcess: Nullable<PostProcess>;
  30682. /**
  30683. * Internal, gets the first post proces.
  30684. * @returns the first post process to be run on this camera.
  30685. */
  30686. _getFirstPostProcess(): Nullable<PostProcess>;
  30687. private _cascadePostProcessesToRigCams;
  30688. /**
  30689. * Attach a post process to the camera.
  30690. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30691. * @param postProcess The post process to attach to the camera
  30692. * @param insertAt The position of the post process in case several of them are in use in the scene
  30693. * @returns the position the post process has been inserted at
  30694. */
  30695. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30696. /**
  30697. * Detach a post process to the camera.
  30698. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30699. * @param postProcess The post process to detach from the camera
  30700. */
  30701. detachPostProcess(postProcess: PostProcess): void;
  30702. /**
  30703. * Gets the current world matrix of the camera
  30704. */
  30705. getWorldMatrix(): Matrix;
  30706. /** @hidden */
  30707. _getViewMatrix(): Matrix;
  30708. /**
  30709. * Gets the current view matrix of the camera.
  30710. * @param force forces the camera to recompute the matrix without looking at the cached state
  30711. * @returns the view matrix
  30712. */
  30713. getViewMatrix(force?: boolean): Matrix;
  30714. /**
  30715. * Freeze the projection matrix.
  30716. * It will prevent the cache check of the camera projection compute and can speed up perf
  30717. * if no parameter of the camera are meant to change
  30718. * @param projection Defines manually a projection if necessary
  30719. */
  30720. freezeProjectionMatrix(projection?: Matrix): void;
  30721. /**
  30722. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30723. */
  30724. unfreezeProjectionMatrix(): void;
  30725. /**
  30726. * Gets the current projection matrix of the camera.
  30727. * @param force forces the camera to recompute the matrix without looking at the cached state
  30728. * @returns the projection matrix
  30729. */
  30730. getProjectionMatrix(force?: boolean): Matrix;
  30731. /**
  30732. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30733. * @returns a Matrix
  30734. */
  30735. getTransformationMatrix(): Matrix;
  30736. private _updateFrustumPlanes;
  30737. /**
  30738. * Checks if a cullable object (mesh...) is in the camera frustum
  30739. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30740. * @param target The object to check
  30741. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30742. * @returns true if the object is in frustum otherwise false
  30743. */
  30744. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30745. /**
  30746. * Checks if a cullable object (mesh...) is in the camera frustum
  30747. * Unlike isInFrustum this cheks the full bounding box
  30748. * @param target The object to check
  30749. * @returns true if the object is in frustum otherwise false
  30750. */
  30751. isCompletelyInFrustum(target: ICullable): boolean;
  30752. /**
  30753. * Gets a ray in the forward direction from the camera.
  30754. * @param length Defines the length of the ray to create
  30755. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30756. * @param origin Defines the start point of the ray which defaults to the camera position
  30757. * @returns the forward ray
  30758. */
  30759. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30760. /**
  30761. * Releases resources associated with this node.
  30762. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30763. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30764. */
  30765. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30766. /** @hidden */
  30767. _isLeftCamera: boolean;
  30768. /**
  30769. * Gets the left camera of a rig setup in case of Rigged Camera
  30770. */
  30771. readonly isLeftCamera: boolean;
  30772. /** @hidden */
  30773. _isRightCamera: boolean;
  30774. /**
  30775. * Gets the right camera of a rig setup in case of Rigged Camera
  30776. */
  30777. readonly isRightCamera: boolean;
  30778. /**
  30779. * Gets the left camera of a rig setup in case of Rigged Camera
  30780. */
  30781. readonly leftCamera: Nullable<FreeCamera>;
  30782. /**
  30783. * Gets the right camera of a rig setup in case of Rigged Camera
  30784. */
  30785. readonly rightCamera: Nullable<FreeCamera>;
  30786. /**
  30787. * Gets the left camera target of a rig setup in case of Rigged Camera
  30788. * @returns the target position
  30789. */
  30790. getLeftTarget(): Nullable<Vector3>;
  30791. /**
  30792. * Gets the right camera target of a rig setup in case of Rigged Camera
  30793. * @returns the target position
  30794. */
  30795. getRightTarget(): Nullable<Vector3>;
  30796. /**
  30797. * @hidden
  30798. */
  30799. setCameraRigMode(mode: number, rigParams: any): void;
  30800. /** @hidden */
  30801. static _setStereoscopicRigMode(camera: Camera): void;
  30802. /** @hidden */
  30803. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30804. /** @hidden */
  30805. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30806. /** @hidden */
  30807. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30808. /** @hidden */
  30809. _getVRProjectionMatrix(): Matrix;
  30810. protected _updateCameraRotationMatrix(): void;
  30811. protected _updateWebVRCameraRotationMatrix(): void;
  30812. /**
  30813. * This function MUST be overwritten by the different WebVR cameras available.
  30814. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30815. * @hidden
  30816. */
  30817. _getWebVRProjectionMatrix(): Matrix;
  30818. /**
  30819. * This function MUST be overwritten by the different WebVR cameras available.
  30820. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30821. * @hidden
  30822. */
  30823. _getWebVRViewMatrix(): Matrix;
  30824. /** @hidden */
  30825. setCameraRigParameter(name: string, value: any): void;
  30826. /**
  30827. * needs to be overridden by children so sub has required properties to be copied
  30828. * @hidden
  30829. */
  30830. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30831. /**
  30832. * May need to be overridden by children
  30833. * @hidden
  30834. */
  30835. _updateRigCameras(): void;
  30836. /** @hidden */
  30837. _setupInputs(): void;
  30838. /**
  30839. * Serialiaze the camera setup to a json represention
  30840. * @returns the JSON representation
  30841. */
  30842. serialize(): any;
  30843. /**
  30844. * Clones the current camera.
  30845. * @param name The cloned camera name
  30846. * @returns the cloned camera
  30847. */
  30848. clone(name: string): Camera;
  30849. /**
  30850. * Gets the direction of the camera relative to a given local axis.
  30851. * @param localAxis Defines the reference axis to provide a relative direction.
  30852. * @return the direction
  30853. */
  30854. getDirection(localAxis: Vector3): Vector3;
  30855. /**
  30856. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30857. * @param localAxis Defines the reference axis to provide a relative direction.
  30858. * @param result Defines the vector to store the result in
  30859. */
  30860. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30861. /**
  30862. * Gets a camera constructor for a given camera type
  30863. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30864. * @param name The name of the camera the result will be able to instantiate
  30865. * @param scene The scene the result will construct the camera in
  30866. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30867. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30868. * @returns a factory method to construc the camera
  30869. */
  30870. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30871. /**
  30872. * Compute the world matrix of the camera.
  30873. * @returns the camera workd matrix
  30874. */
  30875. computeWorldMatrix(): Matrix;
  30876. /**
  30877. * Parse a JSON and creates the camera from the parsed information
  30878. * @param parsedCamera The JSON to parse
  30879. * @param scene The scene to instantiate the camera in
  30880. * @returns the newly constructed camera
  30881. */
  30882. static Parse(parsedCamera: any, scene: Scene): Camera;
  30883. }
  30884. }
  30885. declare module BABYLON {
  30886. /**
  30887. * Interface for any object that can request an animation frame
  30888. */
  30889. export interface ICustomAnimationFrameRequester {
  30890. /**
  30891. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30892. */
  30893. renderFunction?: Function;
  30894. /**
  30895. * Called to request the next frame to render to
  30896. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30897. */
  30898. requestAnimationFrame: Function;
  30899. /**
  30900. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30901. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30902. */
  30903. requestID?: number;
  30904. }
  30905. /**
  30906. * Interface containing an array of animations
  30907. */
  30908. export interface IAnimatable {
  30909. /**
  30910. * Array of animations
  30911. */
  30912. animations: Nullable<Array<Animation>>;
  30913. }
  30914. /** Interface used by value gradients (color, factor, ...) */
  30915. export interface IValueGradient {
  30916. /**
  30917. * Gets or sets the gradient value (between 0 and 1)
  30918. */
  30919. gradient: number;
  30920. }
  30921. /** Class used to store color4 gradient */
  30922. export class ColorGradient implements IValueGradient {
  30923. /**
  30924. * Gets or sets the gradient value (between 0 and 1)
  30925. */
  30926. gradient: number;
  30927. /**
  30928. * Gets or sets first associated color
  30929. */
  30930. color1: Color4;
  30931. /**
  30932. * Gets or sets second associated color
  30933. */
  30934. color2?: Color4;
  30935. /**
  30936. * Will get a color picked randomly between color1 and color2.
  30937. * If color2 is undefined then color1 will be used
  30938. * @param result defines the target Color4 to store the result in
  30939. */
  30940. getColorToRef(result: Color4): void;
  30941. }
  30942. /** Class used to store color 3 gradient */
  30943. export class Color3Gradient implements IValueGradient {
  30944. /**
  30945. * Gets or sets the gradient value (between 0 and 1)
  30946. */
  30947. gradient: number;
  30948. /**
  30949. * Gets or sets the associated color
  30950. */
  30951. color: Color3;
  30952. }
  30953. /** Class used to store factor gradient */
  30954. export class FactorGradient implements IValueGradient {
  30955. /**
  30956. * Gets or sets the gradient value (between 0 and 1)
  30957. */
  30958. gradient: number;
  30959. /**
  30960. * Gets or sets first associated factor
  30961. */
  30962. factor1: number;
  30963. /**
  30964. * Gets or sets second associated factor
  30965. */
  30966. factor2?: number;
  30967. /**
  30968. * Will get a number picked randomly between factor1 and factor2.
  30969. * If factor2 is undefined then factor1 will be used
  30970. * @returns the picked number
  30971. */
  30972. getFactor(): number;
  30973. }
  30974. /**
  30975. * @ignore
  30976. * Application error to support additional information when loading a file
  30977. */
  30978. export class LoadFileError extends Error {
  30979. /** defines the optional web request */
  30980. request?: WebRequest | undefined;
  30981. private static _setPrototypeOf;
  30982. /**
  30983. * Creates a new LoadFileError
  30984. * @param message defines the message of the error
  30985. * @param request defines the optional web request
  30986. */
  30987. constructor(message: string,
  30988. /** defines the optional web request */
  30989. request?: WebRequest | undefined);
  30990. }
  30991. /**
  30992. * Class used to define a retry strategy when error happens while loading assets
  30993. */
  30994. export class RetryStrategy {
  30995. /**
  30996. * Function used to defines an exponential back off strategy
  30997. * @param maxRetries defines the maximum number of retries (3 by default)
  30998. * @param baseInterval defines the interval between retries
  30999. * @returns the strategy function to use
  31000. */
  31001. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31002. }
  31003. /**
  31004. * File request interface
  31005. */
  31006. export interface IFileRequest {
  31007. /**
  31008. * Raised when the request is complete (success or error).
  31009. */
  31010. onCompleteObservable: Observable<IFileRequest>;
  31011. /**
  31012. * Aborts the request for a file.
  31013. */
  31014. abort: () => void;
  31015. }
  31016. /**
  31017. * Class containing a set of static utilities functions
  31018. */
  31019. export class Tools {
  31020. /**
  31021. * Gets or sets the base URL to use to load assets
  31022. */
  31023. static BaseUrl: string;
  31024. /**
  31025. * Enable/Disable Custom HTTP Request Headers globally.
  31026. * default = false
  31027. * @see CustomRequestHeaders
  31028. */
  31029. static UseCustomRequestHeaders: boolean;
  31030. /**
  31031. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31032. * i.e. when loading files, where the server/service expects an Authorization header
  31033. */
  31034. static CustomRequestHeaders: {
  31035. [key: string]: string;
  31036. };
  31037. /**
  31038. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31039. */
  31040. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31041. /**
  31042. * Default behaviour for cors in the application.
  31043. * It can be a string if the expected behavior is identical in the entire app.
  31044. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31045. */
  31046. static CorsBehavior: string | ((url: string | string[]) => string);
  31047. /**
  31048. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31049. * @ignorenaming
  31050. */
  31051. static UseFallbackTexture: boolean;
  31052. /**
  31053. * Use this object to register external classes like custom textures or material
  31054. * to allow the laoders to instantiate them
  31055. */
  31056. static RegisteredExternalClasses: {
  31057. [key: string]: Object;
  31058. };
  31059. /**
  31060. * Texture content used if a texture cannot loaded
  31061. * @ignorenaming
  31062. */
  31063. static fallbackTexture: string;
  31064. /**
  31065. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31066. * @param u defines the coordinate on X axis
  31067. * @param v defines the coordinate on Y axis
  31068. * @param width defines the width of the source data
  31069. * @param height defines the height of the source data
  31070. * @param pixels defines the source byte array
  31071. * @param color defines the output color
  31072. */
  31073. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31074. /**
  31075. * Interpolates between a and b via alpha
  31076. * @param a The lower value (returned when alpha = 0)
  31077. * @param b The upper value (returned when alpha = 1)
  31078. * @param alpha The interpolation-factor
  31079. * @return The mixed value
  31080. */
  31081. static Mix(a: number, b: number, alpha: number): number;
  31082. /**
  31083. * Tries to instantiate a new object from a given class name
  31084. * @param className defines the class name to instantiate
  31085. * @returns the new object or null if the system was not able to do the instantiation
  31086. */
  31087. static Instantiate(className: string): any;
  31088. /**
  31089. * Provides a slice function that will work even on IE
  31090. * @param data defines the array to slice
  31091. * @param start defines the start of the data (optional)
  31092. * @param end defines the end of the data (optional)
  31093. * @returns the new sliced array
  31094. */
  31095. static Slice<T>(data: T, start?: number, end?: number): T;
  31096. /**
  31097. * Polyfill for setImmediate
  31098. * @param action defines the action to execute after the current execution block
  31099. */
  31100. static SetImmediate(action: () => void): void;
  31101. /**
  31102. * Function indicating if a number is an exponent of 2
  31103. * @param value defines the value to test
  31104. * @returns true if the value is an exponent of 2
  31105. */
  31106. static IsExponentOfTwo(value: number): boolean;
  31107. private static _tmpFloatArray;
  31108. /**
  31109. * Returns the nearest 32-bit single precision float representation of a Number
  31110. * @param value A Number. If the parameter is of a different type, it will get converted
  31111. * to a number or to NaN if it cannot be converted
  31112. * @returns number
  31113. */
  31114. static FloatRound(value: number): number;
  31115. /**
  31116. * Find the next highest power of two.
  31117. * @param x Number to start search from.
  31118. * @return Next highest power of two.
  31119. */
  31120. static CeilingPOT(x: number): number;
  31121. /**
  31122. * Find the next lowest power of two.
  31123. * @param x Number to start search from.
  31124. * @return Next lowest power of two.
  31125. */
  31126. static FloorPOT(x: number): number;
  31127. /**
  31128. * Find the nearest power of two.
  31129. * @param x Number to start search from.
  31130. * @return Next nearest power of two.
  31131. */
  31132. static NearestPOT(x: number): number;
  31133. /**
  31134. * Get the closest exponent of two
  31135. * @param value defines the value to approximate
  31136. * @param max defines the maximum value to return
  31137. * @param mode defines how to define the closest value
  31138. * @returns closest exponent of two of the given value
  31139. */
  31140. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31141. /**
  31142. * Extracts the filename from a path
  31143. * @param path defines the path to use
  31144. * @returns the filename
  31145. */
  31146. static GetFilename(path: string): string;
  31147. /**
  31148. * Extracts the "folder" part of a path (everything before the filename).
  31149. * @param uri The URI to extract the info from
  31150. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31151. * @returns The "folder" part of the path
  31152. */
  31153. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31154. /**
  31155. * Extracts text content from a DOM element hierarchy
  31156. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31157. */
  31158. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31159. /**
  31160. * Convert an angle in radians to degrees
  31161. * @param angle defines the angle to convert
  31162. * @returns the angle in degrees
  31163. */
  31164. static ToDegrees(angle: number): number;
  31165. /**
  31166. * Convert an angle in degrees to radians
  31167. * @param angle defines the angle to convert
  31168. * @returns the angle in radians
  31169. */
  31170. static ToRadians(angle: number): number;
  31171. /**
  31172. * Encode a buffer to a base64 string
  31173. * @param buffer defines the buffer to encode
  31174. * @returns the encoded string
  31175. */
  31176. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31177. /**
  31178. * Extracts minimum and maximum values from a list of indexed positions
  31179. * @param positions defines the positions to use
  31180. * @param indices defines the indices to the positions
  31181. * @param indexStart defines the start index
  31182. * @param indexCount defines the end index
  31183. * @param bias defines bias value to add to the result
  31184. * @return minimum and maximum values
  31185. */
  31186. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31187. minimum: Vector3;
  31188. maximum: Vector3;
  31189. };
  31190. /**
  31191. * Extracts minimum and maximum values from a list of positions
  31192. * @param positions defines the positions to use
  31193. * @param start defines the start index in the positions array
  31194. * @param count defines the number of positions to handle
  31195. * @param bias defines bias value to add to the result
  31196. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31197. * @return minimum and maximum values
  31198. */
  31199. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31200. minimum: Vector3;
  31201. maximum: Vector3;
  31202. };
  31203. /**
  31204. * Returns an array if obj is not an array
  31205. * @param obj defines the object to evaluate as an array
  31206. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31207. * @returns either obj directly if obj is an array or a new array containing obj
  31208. */
  31209. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31210. /**
  31211. * Gets the pointer prefix to use
  31212. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31213. */
  31214. static GetPointerPrefix(): string;
  31215. /**
  31216. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31217. * @param func - the function to be called
  31218. * @param requester - the object that will request the next frame. Falls back to window.
  31219. * @returns frame number
  31220. */
  31221. static QueueNewFrame(func: () => void, requester?: any): number;
  31222. /**
  31223. * Ask the browser to promote the current element to fullscreen rendering mode
  31224. * @param element defines the DOM element to promote
  31225. */
  31226. static RequestFullscreen(element: HTMLElement): void;
  31227. /**
  31228. * Asks the browser to exit fullscreen mode
  31229. */
  31230. static ExitFullscreen(): void;
  31231. /**
  31232. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31233. * @param url define the url we are trying
  31234. * @param element define the dom element where to configure the cors policy
  31235. */
  31236. static SetCorsBehavior(url: string | string[], element: {
  31237. crossOrigin: string | null;
  31238. }): void;
  31239. /**
  31240. * Removes unwanted characters from an url
  31241. * @param url defines the url to clean
  31242. * @returns the cleaned url
  31243. */
  31244. static CleanUrl(url: string): string;
  31245. /**
  31246. * Gets or sets a function used to pre-process url before using them to load assets
  31247. */
  31248. static PreprocessUrl: (url: string) => string;
  31249. /**
  31250. * Loads an image as an HTMLImageElement.
  31251. * @param input url string, ArrayBuffer, or Blob to load
  31252. * @param onLoad callback called when the image successfully loads
  31253. * @param onError callback called when the image fails to load
  31254. * @param offlineProvider offline provider for caching
  31255. * @returns the HTMLImageElement of the loaded image
  31256. */
  31257. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31258. /**
  31259. * Loads a file
  31260. * @param url url string, ArrayBuffer, or Blob to load
  31261. * @param onSuccess callback called when the file successfully loads
  31262. * @param onProgress callback called while file is loading (if the server supports this mode)
  31263. * @param offlineProvider defines the offline provider for caching
  31264. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31265. * @param onError callback called when the file fails to load
  31266. * @returns a file request object
  31267. */
  31268. 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;
  31269. /**
  31270. * Load a script (identified by an url). When the url returns, the
  31271. * content of this file is added into a new script element, attached to the DOM (body element)
  31272. * @param scriptUrl defines the url of the script to laod
  31273. * @param onSuccess defines the callback called when the script is loaded
  31274. * @param onError defines the callback to call if an error occurs
  31275. * @param scriptId defines the id of the script element
  31276. */
  31277. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31278. /**
  31279. * Load an asynchronous script (identified by an url). When the url returns, the
  31280. * content of this file is added into a new script element, attached to the DOM (body element)
  31281. * @param scriptUrl defines the url of the script to laod
  31282. * @param scriptId defines the id of the script element
  31283. * @returns a promise request object
  31284. */
  31285. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31286. /**
  31287. * Loads a file from a blob
  31288. * @param fileToLoad defines the blob to use
  31289. * @param callback defines the callback to call when data is loaded
  31290. * @param progressCallback defines the callback to call during loading process
  31291. * @returns a file request object
  31292. */
  31293. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31294. /**
  31295. * Loads a file
  31296. * @param fileToLoad defines the file to load
  31297. * @param callback defines the callback to call when data is loaded
  31298. * @param progressCallBack defines the callback to call during loading process
  31299. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31300. * @returns a file request object
  31301. */
  31302. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31303. /**
  31304. * Creates a data url from a given string content
  31305. * @param content defines the content to convert
  31306. * @returns the new data url link
  31307. */
  31308. static FileAsURL(content: string): string;
  31309. /**
  31310. * Format the given number to a specific decimal format
  31311. * @param value defines the number to format
  31312. * @param decimals defines the number of decimals to use
  31313. * @returns the formatted string
  31314. */
  31315. static Format(value: number, decimals?: number): string;
  31316. /**
  31317. * Checks if a given vector is inside a specific range
  31318. * @param v defines the vector to test
  31319. * @param min defines the minimum range
  31320. * @param max defines the maximum range
  31321. */
  31322. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31323. /**
  31324. * Tries to copy an object by duplicating every property
  31325. * @param source defines the source object
  31326. * @param destination defines the target object
  31327. * @param doNotCopyList defines a list of properties to avoid
  31328. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31329. */
  31330. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31331. /**
  31332. * Gets a boolean indicating if the given object has no own property
  31333. * @param obj defines the object to test
  31334. * @returns true if object has no own property
  31335. */
  31336. static IsEmpty(obj: any): boolean;
  31337. /**
  31338. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31339. * @param str Source string
  31340. * @param suffix Suffix to search for in the source string
  31341. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31342. */
  31343. static EndsWith(str: string, suffix: string): boolean;
  31344. /**
  31345. * Function used to register events at window level
  31346. * @param events defines the events to register
  31347. */
  31348. static RegisterTopRootEvents(events: {
  31349. name: string;
  31350. handler: Nullable<(e: FocusEvent) => any>;
  31351. }[]): void;
  31352. /**
  31353. * Function used to unregister events from window level
  31354. * @param events defines the events to unregister
  31355. */
  31356. static UnregisterTopRootEvents(events: {
  31357. name: string;
  31358. handler: Nullable<(e: FocusEvent) => any>;
  31359. }[]): void;
  31360. /**
  31361. * @ignore
  31362. */
  31363. static _ScreenshotCanvas: HTMLCanvasElement;
  31364. /**
  31365. * Dumps the current bound framebuffer
  31366. * @param width defines the rendering width
  31367. * @param height defines the rendering height
  31368. * @param engine defines the hosting engine
  31369. * @param successCallback defines the callback triggered once the data are available
  31370. * @param mimeType defines the mime type of the result
  31371. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31372. */
  31373. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31374. /**
  31375. * Converts the canvas data to blob.
  31376. * This acts as a polyfill for browsers not supporting the to blob function.
  31377. * @param canvas Defines the canvas to extract the data from
  31378. * @param successCallback Defines the callback triggered once the data are available
  31379. * @param mimeType Defines the mime type of the result
  31380. */
  31381. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31382. /**
  31383. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31384. * @param successCallback defines the callback triggered once the data are available
  31385. * @param mimeType defines the mime type of the result
  31386. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31387. */
  31388. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31389. /**
  31390. * Downloads a blob in the browser
  31391. * @param blob defines the blob to download
  31392. * @param fileName defines the name of the downloaded file
  31393. */
  31394. static Download(blob: Blob, fileName: string): void;
  31395. /**
  31396. * Captures a screenshot of the current rendering
  31397. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31398. * @param engine defines the rendering engine
  31399. * @param camera defines the source camera
  31400. * @param size This parameter can be set to a single number or to an object with the
  31401. * following (optional) properties: precision, width, height. If a single number is passed,
  31402. * it will be used for both width and height. If an object is passed, the screenshot size
  31403. * will be derived from the parameters. The precision property is a multiplier allowing
  31404. * rendering at a higher or lower resolution
  31405. * @param successCallback defines the callback receives a single parameter which contains the
  31406. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31407. * src parameter of an <img> to display it
  31408. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31409. * Check your browser for supported MIME types
  31410. */
  31411. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31412. /**
  31413. * Generates an image screenshot from the specified camera.
  31414. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31415. * @param engine The engine to use for rendering
  31416. * @param camera The camera to use for rendering
  31417. * @param size This parameter can be set to a single number or to an object with the
  31418. * following (optional) properties: precision, width, height. If a single number is passed,
  31419. * it will be used for both width and height. If an object is passed, the screenshot size
  31420. * will be derived from the parameters. The precision property is a multiplier allowing
  31421. * rendering at a higher or lower resolution
  31422. * @param successCallback The callback receives a single parameter which contains the
  31423. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31424. * src parameter of an <img> to display it
  31425. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31426. * Check your browser for supported MIME types
  31427. * @param samples Texture samples (default: 1)
  31428. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31429. * @param fileName A name for for the downloaded file.
  31430. */
  31431. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31432. /**
  31433. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31434. * Be aware Math.random() could cause collisions, but:
  31435. * "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"
  31436. * @returns a pseudo random id
  31437. */
  31438. static RandomId(): string;
  31439. /**
  31440. * Test if the given uri is a base64 string
  31441. * @param uri The uri to test
  31442. * @return True if the uri is a base64 string or false otherwise
  31443. */
  31444. static IsBase64(uri: string): boolean;
  31445. /**
  31446. * Decode the given base64 uri.
  31447. * @param uri The uri to decode
  31448. * @return The decoded base64 data.
  31449. */
  31450. static DecodeBase64(uri: string): ArrayBuffer;
  31451. /**
  31452. * Gets the absolute url.
  31453. * @param url the input url
  31454. * @return the absolute url
  31455. */
  31456. static GetAbsoluteUrl(url: string): string;
  31457. /**
  31458. * No log
  31459. */
  31460. static readonly NoneLogLevel: number;
  31461. /**
  31462. * Only message logs
  31463. */
  31464. static readonly MessageLogLevel: number;
  31465. /**
  31466. * Only warning logs
  31467. */
  31468. static readonly WarningLogLevel: number;
  31469. /**
  31470. * Only error logs
  31471. */
  31472. static readonly ErrorLogLevel: number;
  31473. /**
  31474. * All logs
  31475. */
  31476. static readonly AllLogLevel: number;
  31477. /**
  31478. * Gets a value indicating the number of loading errors
  31479. * @ignorenaming
  31480. */
  31481. static readonly errorsCount: number;
  31482. /**
  31483. * Callback called when a new log is added
  31484. */
  31485. static OnNewCacheEntry: (entry: string) => void;
  31486. /**
  31487. * Log a message to the console
  31488. * @param message defines the message to log
  31489. */
  31490. static Log(message: string): void;
  31491. /**
  31492. * Write a warning message to the console
  31493. * @param message defines the message to log
  31494. */
  31495. static Warn(message: string): void;
  31496. /**
  31497. * Write an error message to the console
  31498. * @param message defines the message to log
  31499. */
  31500. static Error(message: string): void;
  31501. /**
  31502. * Gets current log cache (list of logs)
  31503. */
  31504. static readonly LogCache: string;
  31505. /**
  31506. * Clears the log cache
  31507. */
  31508. static ClearLogCache(): void;
  31509. /**
  31510. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31511. */
  31512. static LogLevels: number;
  31513. /**
  31514. * Checks if the loaded document was accessed via `file:`-Protocol.
  31515. * @returns boolean
  31516. */
  31517. static IsFileURL(): boolean;
  31518. /**
  31519. * Checks if the window object exists
  31520. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31521. */
  31522. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31523. /**
  31524. * No performance log
  31525. */
  31526. static readonly PerformanceNoneLogLevel: number;
  31527. /**
  31528. * Use user marks to log performance
  31529. */
  31530. static readonly PerformanceUserMarkLogLevel: number;
  31531. /**
  31532. * Log performance to the console
  31533. */
  31534. static readonly PerformanceConsoleLogLevel: number;
  31535. private static _performance;
  31536. /**
  31537. * Sets the current performance log level
  31538. */
  31539. static PerformanceLogLevel: number;
  31540. private static _StartPerformanceCounterDisabled;
  31541. private static _EndPerformanceCounterDisabled;
  31542. private static _StartUserMark;
  31543. private static _EndUserMark;
  31544. private static _StartPerformanceConsole;
  31545. private static _EndPerformanceConsole;
  31546. /**
  31547. * Starts a performance counter
  31548. */
  31549. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31550. /**
  31551. * Ends a specific performance coutner
  31552. */
  31553. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31554. /**
  31555. * Gets either window.performance.now() if supported or Date.now() else
  31556. */
  31557. static readonly Now: number;
  31558. /**
  31559. * This method will return the name of the class used to create the instance of the given object.
  31560. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31561. * @param object the object to get the class name from
  31562. * @param isType defines if the object is actually a type
  31563. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31564. */
  31565. static GetClassName(object: any, isType?: boolean): string;
  31566. /**
  31567. * Gets the first element of an array satisfying a given predicate
  31568. * @param array defines the array to browse
  31569. * @param predicate defines the predicate to use
  31570. * @returns null if not found or the element
  31571. */
  31572. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31573. /**
  31574. * This method will return the name of the full name of the class, including its owning module (if any).
  31575. * 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).
  31576. * @param object the object to get the class name from
  31577. * @param isType defines if the object is actually a type
  31578. * @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.
  31579. * @ignorenaming
  31580. */
  31581. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31582. /**
  31583. * Returns a promise that resolves after the given amount of time.
  31584. * @param delay Number of milliseconds to delay
  31585. * @returns Promise that resolves after the given amount of time
  31586. */
  31587. static DelayAsync(delay: number): Promise<void>;
  31588. /**
  31589. * Gets the current gradient from an array of IValueGradient
  31590. * @param ratio defines the current ratio to get
  31591. * @param gradients defines the array of IValueGradient
  31592. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31593. */
  31594. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31595. }
  31596. /**
  31597. * This class is used to track a performance counter which is number based.
  31598. * The user has access to many properties which give statistics of different nature.
  31599. *
  31600. * The implementer can track two kinds of Performance Counter: time and count.
  31601. * 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.
  31602. * 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.
  31603. */
  31604. export class PerfCounter {
  31605. /**
  31606. * Gets or sets a global boolean to turn on and off all the counters
  31607. */
  31608. static Enabled: boolean;
  31609. /**
  31610. * Returns the smallest value ever
  31611. */
  31612. readonly min: number;
  31613. /**
  31614. * Returns the biggest value ever
  31615. */
  31616. readonly max: number;
  31617. /**
  31618. * Returns the average value since the performance counter is running
  31619. */
  31620. readonly average: number;
  31621. /**
  31622. * Returns the average value of the last second the counter was monitored
  31623. */
  31624. readonly lastSecAverage: number;
  31625. /**
  31626. * Returns the current value
  31627. */
  31628. readonly current: number;
  31629. /**
  31630. * Gets the accumulated total
  31631. */
  31632. readonly total: number;
  31633. /**
  31634. * Gets the total value count
  31635. */
  31636. readonly count: number;
  31637. /**
  31638. * Creates a new counter
  31639. */
  31640. constructor();
  31641. /**
  31642. * Call this method to start monitoring a new frame.
  31643. * 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.
  31644. */
  31645. fetchNewFrame(): void;
  31646. /**
  31647. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31648. * @param newCount the count value to add to the monitored count
  31649. * @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.
  31650. */
  31651. addCount(newCount: number, fetchResult: boolean): void;
  31652. /**
  31653. * Start monitoring this performance counter
  31654. */
  31655. beginMonitoring(): void;
  31656. /**
  31657. * Compute the time lapsed since the previous beginMonitoring() call.
  31658. * @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
  31659. */
  31660. endMonitoring(newFrame?: boolean): void;
  31661. private _fetchResult;
  31662. private _startMonitoringTime;
  31663. private _min;
  31664. private _max;
  31665. private _average;
  31666. private _current;
  31667. private _totalValueCount;
  31668. private _totalAccumulated;
  31669. private _lastSecAverage;
  31670. private _lastSecAccumulated;
  31671. private _lastSecTime;
  31672. private _lastSecValueCount;
  31673. }
  31674. /**
  31675. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31676. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31677. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31678. * @param name The name of the class, case should be preserved
  31679. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31680. */
  31681. export function className(name: string, module?: string): (target: Object) => void;
  31682. /**
  31683. * An implementation of a loop for asynchronous functions.
  31684. */
  31685. export class AsyncLoop {
  31686. /**
  31687. * Defines the number of iterations for the loop
  31688. */
  31689. iterations: number;
  31690. /**
  31691. * Defines the current index of the loop.
  31692. */
  31693. index: number;
  31694. private _done;
  31695. private _fn;
  31696. private _successCallback;
  31697. /**
  31698. * Constructor.
  31699. * @param iterations the number of iterations.
  31700. * @param func the function to run each iteration
  31701. * @param successCallback the callback that will be called upon succesful execution
  31702. * @param offset starting offset.
  31703. */
  31704. constructor(
  31705. /**
  31706. * Defines the number of iterations for the loop
  31707. */
  31708. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31709. /**
  31710. * Execute the next iteration. Must be called after the last iteration was finished.
  31711. */
  31712. executeNext(): void;
  31713. /**
  31714. * Break the loop and run the success callback.
  31715. */
  31716. breakLoop(): void;
  31717. /**
  31718. * Create and run an async loop.
  31719. * @param iterations the number of iterations.
  31720. * @param fn the function to run each iteration
  31721. * @param successCallback the callback that will be called upon succesful execution
  31722. * @param offset starting offset.
  31723. * @returns the created async loop object
  31724. */
  31725. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31726. /**
  31727. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31728. * @param iterations total number of iterations
  31729. * @param syncedIterations number of synchronous iterations in each async iteration.
  31730. * @param fn the function to call each iteration.
  31731. * @param callback a success call back that will be called when iterating stops.
  31732. * @param breakFunction a break condition (optional)
  31733. * @param timeout timeout settings for the setTimeout function. default - 0.
  31734. * @returns the created async loop object
  31735. */
  31736. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31737. }
  31738. }
  31739. declare module BABYLON {
  31740. /** @hidden */
  31741. export interface ICollisionCoordinator {
  31742. createCollider(): Collider;
  31743. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31744. init(scene: Scene): void;
  31745. }
  31746. /** @hidden */
  31747. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31748. private _scene;
  31749. private _scaledPosition;
  31750. private _scaledVelocity;
  31751. private _finalPosition;
  31752. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31753. createCollider(): Collider;
  31754. init(scene: Scene): void;
  31755. private _collideWithWorld;
  31756. }
  31757. }
  31758. declare module BABYLON {
  31759. /**
  31760. * Class used to manage all inputs for the scene.
  31761. */
  31762. export class InputManager {
  31763. /** The distance in pixel that you have to move to prevent some events */
  31764. static DragMovementThreshold: number;
  31765. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31766. static LongPressDelay: number;
  31767. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31768. static DoubleClickDelay: number;
  31769. /** If you need to check double click without raising a single click at first click, enable this flag */
  31770. static ExclusiveDoubleClickMode: boolean;
  31771. private _wheelEventName;
  31772. private _onPointerMove;
  31773. private _onPointerDown;
  31774. private _onPointerUp;
  31775. private _initClickEvent;
  31776. private _initActionManager;
  31777. private _delayedSimpleClick;
  31778. private _delayedSimpleClickTimeout;
  31779. private _previousDelayedSimpleClickTimeout;
  31780. private _meshPickProceed;
  31781. private _previousButtonPressed;
  31782. private _currentPickResult;
  31783. private _previousPickResult;
  31784. private _totalPointersPressed;
  31785. private _doubleClickOccured;
  31786. private _pointerOverMesh;
  31787. private _pickedDownMesh;
  31788. private _pickedUpMesh;
  31789. private _pointerX;
  31790. private _pointerY;
  31791. private _unTranslatedPointerX;
  31792. private _unTranslatedPointerY;
  31793. private _startingPointerPosition;
  31794. private _previousStartingPointerPosition;
  31795. private _startingPointerTime;
  31796. private _previousStartingPointerTime;
  31797. private _pointerCaptures;
  31798. private _onKeyDown;
  31799. private _onKeyUp;
  31800. private _onCanvasFocusObserver;
  31801. private _onCanvasBlurObserver;
  31802. private _scene;
  31803. /**
  31804. * Creates a new InputManager
  31805. * @param scene defines the hosting scene
  31806. */
  31807. constructor(scene: Scene);
  31808. /**
  31809. * Gets the mesh that is currently under the pointer
  31810. */
  31811. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31812. /**
  31813. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31814. */
  31815. readonly unTranslatedPointer: Vector2;
  31816. /**
  31817. * Gets or sets the current on-screen X position of the pointer
  31818. */
  31819. pointerX: number;
  31820. /**
  31821. * Gets or sets the current on-screen Y position of the pointer
  31822. */
  31823. pointerY: number;
  31824. private _updatePointerPosition;
  31825. private _processPointerMove;
  31826. private _setRayOnPointerInfo;
  31827. private _checkPrePointerObservable;
  31828. /**
  31829. * Use this method to simulate a pointer move on a mesh
  31830. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31831. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31832. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31833. */
  31834. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31835. /**
  31836. * Use this method to simulate a pointer down on a mesh
  31837. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31838. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31839. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31840. */
  31841. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31842. private _processPointerDown;
  31843. /** @hidden */
  31844. _isPointerSwiping(): boolean;
  31845. /**
  31846. * Use this method to simulate a pointer up on a mesh
  31847. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31848. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31849. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31850. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31851. */
  31852. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31853. private _processPointerUp;
  31854. /**
  31855. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31856. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31857. * @returns true if the pointer was captured
  31858. */
  31859. isPointerCaptured(pointerId?: number): boolean;
  31860. /**
  31861. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31862. * @param attachUp defines if you want to attach events to pointerup
  31863. * @param attachDown defines if you want to attach events to pointerdown
  31864. * @param attachMove defines if you want to attach events to pointermove
  31865. */
  31866. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31867. /**
  31868. * Detaches all event handlers
  31869. */
  31870. detachControl(): void;
  31871. /**
  31872. * Force the value of meshUnderPointer
  31873. * @param mesh defines the mesh to use
  31874. */
  31875. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31876. /**
  31877. * Gets the mesh under the pointer
  31878. * @returns a Mesh or null if no mesh is under the pointer
  31879. */
  31880. getPointerOverMesh(): Nullable<AbstractMesh>;
  31881. }
  31882. }
  31883. declare module BABYLON {
  31884. /**
  31885. * This class defines the direct association between an animation and a target
  31886. */
  31887. export class TargetedAnimation {
  31888. /**
  31889. * Animation to perform
  31890. */
  31891. animation: Animation;
  31892. /**
  31893. * Target to animate
  31894. */
  31895. target: any;
  31896. /**
  31897. * Serialize the object
  31898. * @returns the JSON object representing the current entity
  31899. */
  31900. serialize(): any;
  31901. }
  31902. /**
  31903. * Use this class to create coordinated animations on multiple targets
  31904. */
  31905. export class AnimationGroup implements IDisposable {
  31906. /** The name of the animation group */
  31907. name: string;
  31908. private _scene;
  31909. private _targetedAnimations;
  31910. private _animatables;
  31911. private _from;
  31912. private _to;
  31913. private _isStarted;
  31914. private _isPaused;
  31915. private _speedRatio;
  31916. private _loopAnimation;
  31917. /**
  31918. * Gets or sets the unique id of the node
  31919. */
  31920. uniqueId: number;
  31921. /**
  31922. * This observable will notify when one animation have ended
  31923. */
  31924. onAnimationEndObservable: Observable<TargetedAnimation>;
  31925. /**
  31926. * Observer raised when one animation loops
  31927. */
  31928. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31929. /**
  31930. * This observable will notify when all animations have ended.
  31931. */
  31932. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31933. /**
  31934. * This observable will notify when all animations have paused.
  31935. */
  31936. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31937. /**
  31938. * This observable will notify when all animations are playing.
  31939. */
  31940. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31941. /**
  31942. * Gets the first frame
  31943. */
  31944. readonly from: number;
  31945. /**
  31946. * Gets the last frame
  31947. */
  31948. readonly to: number;
  31949. /**
  31950. * Define if the animations are started
  31951. */
  31952. readonly isStarted: boolean;
  31953. /**
  31954. * Gets a value indicating that the current group is playing
  31955. */
  31956. readonly isPlaying: boolean;
  31957. /**
  31958. * Gets or sets the speed ratio to use for all animations
  31959. */
  31960. /**
  31961. * Gets or sets the speed ratio to use for all animations
  31962. */
  31963. speedRatio: number;
  31964. /**
  31965. * Gets or sets if all animations should loop or not
  31966. */
  31967. loopAnimation: boolean;
  31968. /**
  31969. * Gets the targeted animations for this animation group
  31970. */
  31971. readonly targetedAnimations: Array<TargetedAnimation>;
  31972. /**
  31973. * returning the list of animatables controlled by this animation group.
  31974. */
  31975. readonly animatables: Array<Animatable>;
  31976. /**
  31977. * Instantiates a new Animation Group.
  31978. * This helps managing several animations at once.
  31979. * @see http://doc.babylonjs.com/how_to/group
  31980. * @param name Defines the name of the group
  31981. * @param scene Defines the scene the group belongs to
  31982. */
  31983. constructor(
  31984. /** The name of the animation group */
  31985. name: string, scene?: Nullable<Scene>);
  31986. /**
  31987. * Add an animation (with its target) in the group
  31988. * @param animation defines the animation we want to add
  31989. * @param target defines the target of the animation
  31990. * @returns the TargetedAnimation object
  31991. */
  31992. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31993. /**
  31994. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31995. * It can add constant keys at begin or end
  31996. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31997. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31998. * @returns the animation group
  31999. */
  32000. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32001. /**
  32002. * Start all animations on given targets
  32003. * @param loop defines if animations must loop
  32004. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32005. * @param from defines the from key (optional)
  32006. * @param to defines the to key (optional)
  32007. * @returns the current animation group
  32008. */
  32009. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32010. /**
  32011. * Pause all animations
  32012. * @returns the animation group
  32013. */
  32014. pause(): AnimationGroup;
  32015. /**
  32016. * Play all animations to initial state
  32017. * This function will start() the animations if they were not started or will restart() them if they were paused
  32018. * @param loop defines if animations must loop
  32019. * @returns the animation group
  32020. */
  32021. play(loop?: boolean): AnimationGroup;
  32022. /**
  32023. * Reset all animations to initial state
  32024. * @returns the animation group
  32025. */
  32026. reset(): AnimationGroup;
  32027. /**
  32028. * Restart animations from key 0
  32029. * @returns the animation group
  32030. */
  32031. restart(): AnimationGroup;
  32032. /**
  32033. * Stop all animations
  32034. * @returns the animation group
  32035. */
  32036. stop(): AnimationGroup;
  32037. /**
  32038. * Set animation weight for all animatables
  32039. * @param weight defines the weight to use
  32040. * @return the animationGroup
  32041. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32042. */
  32043. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32044. /**
  32045. * Synchronize and normalize all animatables with a source animatable
  32046. * @param root defines the root animatable to synchronize with
  32047. * @return the animationGroup
  32048. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32049. */
  32050. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32051. /**
  32052. * Goes to a specific frame in this animation group
  32053. * @param frame the frame number to go to
  32054. * @return the animationGroup
  32055. */
  32056. goToFrame(frame: number): AnimationGroup;
  32057. /**
  32058. * Dispose all associated resources
  32059. */
  32060. dispose(): void;
  32061. private _checkAnimationGroupEnded;
  32062. /**
  32063. * Clone the current animation group and returns a copy
  32064. * @param newName defines the name of the new group
  32065. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32066. * @returns the new aniamtion group
  32067. */
  32068. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32069. /**
  32070. * Serializes the animationGroup to an object
  32071. * @returns Serialized object
  32072. */
  32073. serialize(): any;
  32074. /**
  32075. * Returns a new AnimationGroup object parsed from the source provided.
  32076. * @param parsedAnimationGroup defines the source
  32077. * @param scene defines the scene that will receive the animationGroup
  32078. * @returns a new AnimationGroup
  32079. */
  32080. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32081. /**
  32082. * Returns the string "AnimationGroup"
  32083. * @returns "AnimationGroup"
  32084. */
  32085. getClassName(): string;
  32086. /**
  32087. * Creates a detailled string about the object
  32088. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32089. * @returns a string representing the object
  32090. */
  32091. toString(fullDetails?: boolean): string;
  32092. }
  32093. }
  32094. declare module BABYLON {
  32095. /**
  32096. * Define an interface for all classes that will hold resources
  32097. */
  32098. export interface IDisposable {
  32099. /**
  32100. * Releases all held resources
  32101. */
  32102. dispose(): void;
  32103. }
  32104. /** Interface defining initialization parameters for Scene class */
  32105. export interface SceneOptions {
  32106. /**
  32107. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32108. * It will improve performance when the number of geometries becomes important.
  32109. */
  32110. useGeometryUniqueIdsMap?: boolean;
  32111. /**
  32112. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32113. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32114. */
  32115. useMaterialMeshMap?: boolean;
  32116. /**
  32117. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32118. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32119. */
  32120. useClonedMeshhMap?: boolean;
  32121. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32122. virtual?: boolean;
  32123. }
  32124. /**
  32125. * Represents a scene to be rendered by the engine.
  32126. * @see http://doc.babylonjs.com/features/scene
  32127. */
  32128. export class Scene extends AbstractScene implements IAnimatable {
  32129. private static _uniqueIdCounter;
  32130. /** The fog is deactivated */
  32131. static readonly FOGMODE_NONE: number;
  32132. /** The fog density is following an exponential function */
  32133. static readonly FOGMODE_EXP: number;
  32134. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32135. static readonly FOGMODE_EXP2: number;
  32136. /** The fog density is following a linear function. */
  32137. static readonly FOGMODE_LINEAR: number;
  32138. /**
  32139. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32140. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32141. */
  32142. static MinDeltaTime: number;
  32143. /**
  32144. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32145. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32146. */
  32147. static MaxDeltaTime: number;
  32148. /**
  32149. * Factory used to create the default material.
  32150. * @param name The name of the material to create
  32151. * @param scene The scene to create the material for
  32152. * @returns The default material
  32153. */
  32154. static DefaultMaterialFactory(scene: Scene): Material;
  32155. /**
  32156. * Factory used to create the a collision coordinator.
  32157. * @returns The collision coordinator
  32158. */
  32159. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32160. /** @hidden */
  32161. _inputManager: InputManager;
  32162. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32163. cameraToUseForPointers: Nullable<Camera>;
  32164. /** @hidden */
  32165. readonly _isScene: boolean;
  32166. /**
  32167. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32168. */
  32169. autoClear: boolean;
  32170. /**
  32171. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32172. */
  32173. autoClearDepthAndStencil: boolean;
  32174. /**
  32175. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32176. */
  32177. clearColor: Color4;
  32178. /**
  32179. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32180. */
  32181. ambientColor: Color3;
  32182. /**
  32183. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32184. * It should only be one of the following (if not the default embedded one):
  32185. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32186. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32187. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32188. * The material properties need to be setup according to the type of texture in use.
  32189. */
  32190. environmentBRDFTexture: BaseTexture;
  32191. /** @hidden */
  32192. protected _environmentTexture: Nullable<BaseTexture>;
  32193. /**
  32194. * Texture used in all pbr material as the reflection texture.
  32195. * As in the majority of the scene they are the same (exception for multi room and so on),
  32196. * this is easier to reference from here than from all the materials.
  32197. */
  32198. /**
  32199. * Texture used in all pbr material as the reflection texture.
  32200. * As in the majority of the scene they are the same (exception for multi room and so on),
  32201. * this is easier to set here than in all the materials.
  32202. */
  32203. environmentTexture: Nullable<BaseTexture>;
  32204. /** @hidden */
  32205. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32206. /**
  32207. * Default image processing configuration used either in the rendering
  32208. * Forward main pass or through the imageProcessingPostProcess if present.
  32209. * As in the majority of the scene they are the same (exception for multi camera),
  32210. * this is easier to reference from here than from all the materials and post process.
  32211. *
  32212. * No setter as we it is a shared configuration, you can set the values instead.
  32213. */
  32214. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32215. private _forceWireframe;
  32216. /**
  32217. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32218. */
  32219. forceWireframe: boolean;
  32220. private _forcePointsCloud;
  32221. /**
  32222. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32223. */
  32224. forcePointsCloud: boolean;
  32225. /**
  32226. * Gets or sets the active clipplane 1
  32227. */
  32228. clipPlane: Nullable<Plane>;
  32229. /**
  32230. * Gets or sets the active clipplane 2
  32231. */
  32232. clipPlane2: Nullable<Plane>;
  32233. /**
  32234. * Gets or sets the active clipplane 3
  32235. */
  32236. clipPlane3: Nullable<Plane>;
  32237. /**
  32238. * Gets or sets the active clipplane 4
  32239. */
  32240. clipPlane4: Nullable<Plane>;
  32241. /**
  32242. * Gets or sets a boolean indicating if animations are enabled
  32243. */
  32244. animationsEnabled: boolean;
  32245. private _animationPropertiesOverride;
  32246. /**
  32247. * Gets or sets the animation properties override
  32248. */
  32249. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32250. /**
  32251. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32252. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32253. */
  32254. useConstantAnimationDeltaTime: boolean;
  32255. /**
  32256. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32257. * Please note that it requires to run a ray cast through the scene on every frame
  32258. */
  32259. constantlyUpdateMeshUnderPointer: boolean;
  32260. /**
  32261. * Defines the HTML cursor to use when hovering over interactive elements
  32262. */
  32263. hoverCursor: string;
  32264. /**
  32265. * Defines the HTML default cursor to use (empty by default)
  32266. */
  32267. defaultCursor: string;
  32268. /**
  32269. * This is used to call preventDefault() on pointer down
  32270. * in order to block unwanted artifacts like system double clicks
  32271. */
  32272. preventDefaultOnPointerDown: boolean;
  32273. /**
  32274. * This is used to call preventDefault() on pointer up
  32275. * in order to block unwanted artifacts like system double clicks
  32276. */
  32277. preventDefaultOnPointerUp: boolean;
  32278. /**
  32279. * Gets or sets user defined metadata
  32280. */
  32281. metadata: any;
  32282. /**
  32283. * For internal use only. Please do not use.
  32284. */
  32285. reservedDataStore: any;
  32286. /**
  32287. * Gets the name of the plugin used to load this scene (null by default)
  32288. */
  32289. loadingPluginName: string;
  32290. /**
  32291. * Use this array to add regular expressions used to disable offline support for specific urls
  32292. */
  32293. disableOfflineSupportExceptionRules: RegExp[];
  32294. /**
  32295. * An event triggered when the scene is disposed.
  32296. */
  32297. onDisposeObservable: Observable<Scene>;
  32298. private _onDisposeObserver;
  32299. /** Sets a function to be executed when this scene is disposed. */
  32300. onDispose: () => void;
  32301. /**
  32302. * An event triggered before rendering the scene (right after animations and physics)
  32303. */
  32304. onBeforeRenderObservable: Observable<Scene>;
  32305. private _onBeforeRenderObserver;
  32306. /** Sets a function to be executed before rendering this scene */
  32307. beforeRender: Nullable<() => void>;
  32308. /**
  32309. * An event triggered after rendering the scene
  32310. */
  32311. onAfterRenderObservable: Observable<Scene>;
  32312. private _onAfterRenderObserver;
  32313. /** Sets a function to be executed after rendering this scene */
  32314. afterRender: Nullable<() => void>;
  32315. /**
  32316. * An event triggered before animating the scene
  32317. */
  32318. onBeforeAnimationsObservable: Observable<Scene>;
  32319. /**
  32320. * An event triggered after animations processing
  32321. */
  32322. onAfterAnimationsObservable: Observable<Scene>;
  32323. /**
  32324. * An event triggered before draw calls are ready to be sent
  32325. */
  32326. onBeforeDrawPhaseObservable: Observable<Scene>;
  32327. /**
  32328. * An event triggered after draw calls have been sent
  32329. */
  32330. onAfterDrawPhaseObservable: Observable<Scene>;
  32331. /**
  32332. * An event triggered when the scene is ready
  32333. */
  32334. onReadyObservable: Observable<Scene>;
  32335. /**
  32336. * An event triggered before rendering a camera
  32337. */
  32338. onBeforeCameraRenderObservable: Observable<Camera>;
  32339. private _onBeforeCameraRenderObserver;
  32340. /** Sets a function to be executed before rendering a camera*/
  32341. beforeCameraRender: () => void;
  32342. /**
  32343. * An event triggered after rendering a camera
  32344. */
  32345. onAfterCameraRenderObservable: Observable<Camera>;
  32346. private _onAfterCameraRenderObserver;
  32347. /** Sets a function to be executed after rendering a camera*/
  32348. afterCameraRender: () => void;
  32349. /**
  32350. * An event triggered when active meshes evaluation is about to start
  32351. */
  32352. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32353. /**
  32354. * An event triggered when active meshes evaluation is done
  32355. */
  32356. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32357. /**
  32358. * An event triggered when particles rendering is about to start
  32359. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32360. */
  32361. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32362. /**
  32363. * An event triggered when particles rendering is done
  32364. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32365. */
  32366. onAfterParticlesRenderingObservable: Observable<Scene>;
  32367. /**
  32368. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32369. */
  32370. onDataLoadedObservable: Observable<Scene>;
  32371. /**
  32372. * An event triggered when a camera is created
  32373. */
  32374. onNewCameraAddedObservable: Observable<Camera>;
  32375. /**
  32376. * An event triggered when a camera is removed
  32377. */
  32378. onCameraRemovedObservable: Observable<Camera>;
  32379. /**
  32380. * An event triggered when a light is created
  32381. */
  32382. onNewLightAddedObservable: Observable<Light>;
  32383. /**
  32384. * An event triggered when a light is removed
  32385. */
  32386. onLightRemovedObservable: Observable<Light>;
  32387. /**
  32388. * An event triggered when a geometry is created
  32389. */
  32390. onNewGeometryAddedObservable: Observable<Geometry>;
  32391. /**
  32392. * An event triggered when a geometry is removed
  32393. */
  32394. onGeometryRemovedObservable: Observable<Geometry>;
  32395. /**
  32396. * An event triggered when a transform node is created
  32397. */
  32398. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32399. /**
  32400. * An event triggered when a transform node is removed
  32401. */
  32402. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32403. /**
  32404. * An event triggered when a mesh is created
  32405. */
  32406. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32407. /**
  32408. * An event triggered when a mesh is removed
  32409. */
  32410. onMeshRemovedObservable: Observable<AbstractMesh>;
  32411. /**
  32412. * An event triggered when a skeleton is created
  32413. */
  32414. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32415. /**
  32416. * An event triggered when a skeleton is removed
  32417. */
  32418. onSkeletonRemovedObservable: Observable<Skeleton>;
  32419. /**
  32420. * An event triggered when a material is created
  32421. */
  32422. onNewMaterialAddedObservable: Observable<Material>;
  32423. /**
  32424. * An event triggered when a material is removed
  32425. */
  32426. onMaterialRemovedObservable: Observable<Material>;
  32427. /**
  32428. * An event triggered when a texture is created
  32429. */
  32430. onNewTextureAddedObservable: Observable<BaseTexture>;
  32431. /**
  32432. * An event triggered when a texture is removed
  32433. */
  32434. onTextureRemovedObservable: Observable<BaseTexture>;
  32435. /**
  32436. * An event triggered when render targets are about to be rendered
  32437. * Can happen multiple times per frame.
  32438. */
  32439. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32440. /**
  32441. * An event triggered when render targets were rendered.
  32442. * Can happen multiple times per frame.
  32443. */
  32444. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32445. /**
  32446. * An event triggered before calculating deterministic simulation step
  32447. */
  32448. onBeforeStepObservable: Observable<Scene>;
  32449. /**
  32450. * An event triggered after calculating deterministic simulation step
  32451. */
  32452. onAfterStepObservable: Observable<Scene>;
  32453. /**
  32454. * An event triggered when the activeCamera property is updated
  32455. */
  32456. onActiveCameraChanged: Observable<Scene>;
  32457. /**
  32458. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32459. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32460. * 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)
  32461. */
  32462. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32463. /**
  32464. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32465. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32466. * 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)
  32467. */
  32468. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32469. /**
  32470. * This Observable will when a mesh has been imported into the scene.
  32471. */
  32472. onMeshImportedObservable: Observable<AbstractMesh>;
  32473. /**
  32474. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32475. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32476. */
  32477. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32478. /** @hidden */
  32479. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32480. /**
  32481. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32482. */
  32483. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32484. /**
  32485. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32486. */
  32487. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32488. /**
  32489. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32490. */
  32491. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32492. /** Callback called when a pointer move is detected */
  32493. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32494. /** Callback called when a pointer down is detected */
  32495. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32496. /** Callback called when a pointer up is detected */
  32497. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32498. /** Callback called when a pointer pick is detected */
  32499. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32500. /**
  32501. * 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).
  32502. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32503. */
  32504. onPrePointerObservable: Observable<PointerInfoPre>;
  32505. /**
  32506. * Observable event triggered each time an input event is received from the rendering canvas
  32507. */
  32508. onPointerObservable: Observable<PointerInfo>;
  32509. /**
  32510. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32511. */
  32512. readonly unTranslatedPointer: Vector2;
  32513. /**
  32514. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32515. */
  32516. static DragMovementThreshold: number;
  32517. /**
  32518. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32519. */
  32520. static LongPressDelay: number;
  32521. /**
  32522. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32523. */
  32524. static DoubleClickDelay: number;
  32525. /** If you need to check double click without raising a single click at first click, enable this flag */
  32526. static ExclusiveDoubleClickMode: boolean;
  32527. /** @hidden */
  32528. _mirroredCameraPosition: Nullable<Vector3>;
  32529. /**
  32530. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32531. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32532. */
  32533. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32534. /**
  32535. * Observable event triggered each time an keyboard event is received from the hosting window
  32536. */
  32537. onKeyboardObservable: Observable<KeyboardInfo>;
  32538. private _useRightHandedSystem;
  32539. /**
  32540. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32541. */
  32542. useRightHandedSystem: boolean;
  32543. private _timeAccumulator;
  32544. private _currentStepId;
  32545. private _currentInternalStep;
  32546. /**
  32547. * Sets the step Id used by deterministic lock step
  32548. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32549. * @param newStepId defines the step Id
  32550. */
  32551. setStepId(newStepId: number): void;
  32552. /**
  32553. * Gets the step Id used by deterministic lock step
  32554. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32555. * @returns the step Id
  32556. */
  32557. getStepId(): number;
  32558. /**
  32559. * Gets the internal step used by deterministic lock step
  32560. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32561. * @returns the internal step
  32562. */
  32563. getInternalStep(): number;
  32564. private _fogEnabled;
  32565. /**
  32566. * Gets or sets a boolean indicating if fog is enabled on this scene
  32567. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32568. * (Default is true)
  32569. */
  32570. fogEnabled: boolean;
  32571. private _fogMode;
  32572. /**
  32573. * Gets or sets the fog mode to use
  32574. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32575. * | mode | value |
  32576. * | --- | --- |
  32577. * | FOGMODE_NONE | 0 |
  32578. * | FOGMODE_EXP | 1 |
  32579. * | FOGMODE_EXP2 | 2 |
  32580. * | FOGMODE_LINEAR | 3 |
  32581. */
  32582. fogMode: number;
  32583. /**
  32584. * Gets or sets the fog color to use
  32585. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32586. * (Default is Color3(0.2, 0.2, 0.3))
  32587. */
  32588. fogColor: Color3;
  32589. /**
  32590. * Gets or sets the fog density to use
  32591. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32592. * (Default is 0.1)
  32593. */
  32594. fogDensity: number;
  32595. /**
  32596. * Gets or sets the fog start distance to use
  32597. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32598. * (Default is 0)
  32599. */
  32600. fogStart: number;
  32601. /**
  32602. * Gets or sets the fog end distance to use
  32603. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32604. * (Default is 1000)
  32605. */
  32606. fogEnd: number;
  32607. private _shadowsEnabled;
  32608. /**
  32609. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32610. */
  32611. shadowsEnabled: boolean;
  32612. private _lightsEnabled;
  32613. /**
  32614. * Gets or sets a boolean indicating if lights are enabled on this scene
  32615. */
  32616. lightsEnabled: boolean;
  32617. /** All of the active cameras added to this scene. */
  32618. activeCameras: Camera[];
  32619. /** @hidden */
  32620. _activeCamera: Nullable<Camera>;
  32621. /** Gets or sets the current active camera */
  32622. activeCamera: Nullable<Camera>;
  32623. private _defaultMaterial;
  32624. /** The default material used on meshes when no material is affected */
  32625. /** The default material used on meshes when no material is affected */
  32626. defaultMaterial: Material;
  32627. private _texturesEnabled;
  32628. /**
  32629. * Gets or sets a boolean indicating if textures are enabled on this scene
  32630. */
  32631. texturesEnabled: boolean;
  32632. /**
  32633. * Gets or sets a boolean indicating if particles are enabled on this scene
  32634. */
  32635. particlesEnabled: boolean;
  32636. /**
  32637. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32638. */
  32639. spritesEnabled: boolean;
  32640. private _skeletonsEnabled;
  32641. /**
  32642. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32643. */
  32644. skeletonsEnabled: boolean;
  32645. /**
  32646. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32647. */
  32648. lensFlaresEnabled: boolean;
  32649. /**
  32650. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32651. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32652. */
  32653. collisionsEnabled: boolean;
  32654. private _collisionCoordinator;
  32655. /** @hidden */
  32656. readonly collisionCoordinator: ICollisionCoordinator;
  32657. /**
  32658. * Defines the gravity applied to this scene (used only for collisions)
  32659. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32660. */
  32661. gravity: Vector3;
  32662. /**
  32663. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32664. */
  32665. postProcessesEnabled: boolean;
  32666. /**
  32667. * The list of postprocesses added to the scene
  32668. */
  32669. postProcesses: PostProcess[];
  32670. /**
  32671. * Gets the current postprocess manager
  32672. */
  32673. postProcessManager: PostProcessManager;
  32674. /**
  32675. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32676. */
  32677. renderTargetsEnabled: boolean;
  32678. /**
  32679. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32680. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32681. */
  32682. dumpNextRenderTargets: boolean;
  32683. /**
  32684. * The list of user defined render targets added to the scene
  32685. */
  32686. customRenderTargets: RenderTargetTexture[];
  32687. /**
  32688. * Defines if texture loading must be delayed
  32689. * If true, textures will only be loaded when they need to be rendered
  32690. */
  32691. useDelayedTextureLoading: boolean;
  32692. /**
  32693. * Gets the list of meshes imported to the scene through SceneLoader
  32694. */
  32695. importedMeshesFiles: String[];
  32696. /**
  32697. * Gets or sets a boolean indicating if probes are enabled on this scene
  32698. */
  32699. probesEnabled: boolean;
  32700. /**
  32701. * Gets or sets the current offline provider to use to store scene data
  32702. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32703. */
  32704. offlineProvider: IOfflineProvider;
  32705. /**
  32706. * Gets or sets the action manager associated with the scene
  32707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32708. */
  32709. actionManager: AbstractActionManager;
  32710. private _meshesForIntersections;
  32711. /**
  32712. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32713. */
  32714. proceduralTexturesEnabled: boolean;
  32715. private _engine;
  32716. private _totalVertices;
  32717. /** @hidden */
  32718. _activeIndices: PerfCounter;
  32719. /** @hidden */
  32720. _activeParticles: PerfCounter;
  32721. /** @hidden */
  32722. _activeBones: PerfCounter;
  32723. private _animationRatio;
  32724. /** @hidden */
  32725. _animationTimeLast: number;
  32726. /** @hidden */
  32727. _animationTime: number;
  32728. /**
  32729. * Gets or sets a general scale for animation speed
  32730. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32731. */
  32732. animationTimeScale: number;
  32733. /** @hidden */
  32734. _cachedMaterial: Nullable<Material>;
  32735. /** @hidden */
  32736. _cachedEffect: Nullable<Effect>;
  32737. /** @hidden */
  32738. _cachedVisibility: Nullable<number>;
  32739. private _renderId;
  32740. private _frameId;
  32741. private _executeWhenReadyTimeoutId;
  32742. private _intermediateRendering;
  32743. private _viewUpdateFlag;
  32744. private _projectionUpdateFlag;
  32745. /** @hidden */
  32746. _toBeDisposed: Nullable<IDisposable>[];
  32747. private _activeRequests;
  32748. /** @hidden */
  32749. _pendingData: any[];
  32750. private _isDisposed;
  32751. /**
  32752. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32753. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32754. */
  32755. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32756. private _activeMeshes;
  32757. private _processedMaterials;
  32758. private _renderTargets;
  32759. /** @hidden */
  32760. _activeParticleSystems: SmartArray<IParticleSystem>;
  32761. private _activeSkeletons;
  32762. private _softwareSkinnedMeshes;
  32763. private _renderingManager;
  32764. /** @hidden */
  32765. _activeAnimatables: Animatable[];
  32766. private _transformMatrix;
  32767. private _sceneUbo;
  32768. /** @hidden */
  32769. _viewMatrix: Matrix;
  32770. private _projectionMatrix;
  32771. /** @hidden */
  32772. _forcedViewPosition: Nullable<Vector3>;
  32773. /** @hidden */
  32774. _frustumPlanes: Plane[];
  32775. /**
  32776. * Gets the list of frustum planes (built from the active camera)
  32777. */
  32778. readonly frustumPlanes: Plane[];
  32779. /**
  32780. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32781. * This is useful if there are more lights that the maximum simulteanous authorized
  32782. */
  32783. requireLightSorting: boolean;
  32784. /** @hidden */
  32785. readonly useMaterialMeshMap: boolean;
  32786. /** @hidden */
  32787. readonly useClonedMeshhMap: boolean;
  32788. private _externalData;
  32789. private _uid;
  32790. /**
  32791. * @hidden
  32792. * Backing store of defined scene components.
  32793. */
  32794. _components: ISceneComponent[];
  32795. /**
  32796. * @hidden
  32797. * Backing store of defined scene components.
  32798. */
  32799. _serializableComponents: ISceneSerializableComponent[];
  32800. /**
  32801. * List of components to register on the next registration step.
  32802. */
  32803. private _transientComponents;
  32804. /**
  32805. * Registers the transient components if needed.
  32806. */
  32807. private _registerTransientComponents;
  32808. /**
  32809. * @hidden
  32810. * Add a component to the scene.
  32811. * Note that the ccomponent could be registered on th next frame if this is called after
  32812. * the register component stage.
  32813. * @param component Defines the component to add to the scene
  32814. */
  32815. _addComponent(component: ISceneComponent): void;
  32816. /**
  32817. * @hidden
  32818. * Gets a component from the scene.
  32819. * @param name defines the name of the component to retrieve
  32820. * @returns the component or null if not present
  32821. */
  32822. _getComponent(name: string): Nullable<ISceneComponent>;
  32823. /**
  32824. * @hidden
  32825. * Defines the actions happening before camera updates.
  32826. */
  32827. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32828. /**
  32829. * @hidden
  32830. * Defines the actions happening before clear the canvas.
  32831. */
  32832. _beforeClearStage: Stage<SimpleStageAction>;
  32833. /**
  32834. * @hidden
  32835. * Defines the actions when collecting render targets for the frame.
  32836. */
  32837. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32838. /**
  32839. * @hidden
  32840. * Defines the actions happening for one camera in the frame.
  32841. */
  32842. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32843. /**
  32844. * @hidden
  32845. * Defines the actions happening during the per mesh ready checks.
  32846. */
  32847. _isReadyForMeshStage: Stage<MeshStageAction>;
  32848. /**
  32849. * @hidden
  32850. * Defines the actions happening before evaluate active mesh checks.
  32851. */
  32852. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32853. /**
  32854. * @hidden
  32855. * Defines the actions happening during the evaluate sub mesh checks.
  32856. */
  32857. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32858. /**
  32859. * @hidden
  32860. * Defines the actions happening during the active mesh stage.
  32861. */
  32862. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32863. /**
  32864. * @hidden
  32865. * Defines the actions happening during the per camera render target step.
  32866. */
  32867. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32868. /**
  32869. * @hidden
  32870. * Defines the actions happening just before the active camera is drawing.
  32871. */
  32872. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32873. /**
  32874. * @hidden
  32875. * Defines the actions happening just before a render target is drawing.
  32876. */
  32877. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32878. /**
  32879. * @hidden
  32880. * Defines the actions happening just before a rendering group is drawing.
  32881. */
  32882. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32883. /**
  32884. * @hidden
  32885. * Defines the actions happening just before a mesh is drawing.
  32886. */
  32887. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32888. /**
  32889. * @hidden
  32890. * Defines the actions happening just after a mesh has been drawn.
  32891. */
  32892. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32893. /**
  32894. * @hidden
  32895. * Defines the actions happening just after a rendering group has been drawn.
  32896. */
  32897. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32898. /**
  32899. * @hidden
  32900. * Defines the actions happening just after the active camera has been drawn.
  32901. */
  32902. _afterCameraDrawStage: Stage<CameraStageAction>;
  32903. /**
  32904. * @hidden
  32905. * Defines the actions happening just after a render target has been drawn.
  32906. */
  32907. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32908. /**
  32909. * @hidden
  32910. * Defines the actions happening just after rendering all cameras and computing intersections.
  32911. */
  32912. _afterRenderStage: Stage<SimpleStageAction>;
  32913. /**
  32914. * @hidden
  32915. * Defines the actions happening when a pointer move event happens.
  32916. */
  32917. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32918. /**
  32919. * @hidden
  32920. * Defines the actions happening when a pointer down event happens.
  32921. */
  32922. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32923. /**
  32924. * @hidden
  32925. * Defines the actions happening when a pointer up event happens.
  32926. */
  32927. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32928. /**
  32929. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32930. */
  32931. private geometriesByUniqueId;
  32932. /**
  32933. * Creates a new Scene
  32934. * @param engine defines the engine to use to render this scene
  32935. * @param options defines the scene options
  32936. */
  32937. constructor(engine: Engine, options?: SceneOptions);
  32938. /**
  32939. * Gets a string idenfifying the name of the class
  32940. * @returns "Scene" string
  32941. */
  32942. getClassName(): string;
  32943. private _defaultMeshCandidates;
  32944. /**
  32945. * @hidden
  32946. */
  32947. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32948. private _defaultSubMeshCandidates;
  32949. /**
  32950. * @hidden
  32951. */
  32952. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32953. /**
  32954. * Sets the default candidate providers for the scene.
  32955. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32956. * and getCollidingSubMeshCandidates to their default function
  32957. */
  32958. setDefaultCandidateProviders(): void;
  32959. /**
  32960. * Gets the mesh that is currently under the pointer
  32961. */
  32962. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32963. /**
  32964. * Gets or sets the current on-screen X position of the pointer
  32965. */
  32966. pointerX: number;
  32967. /**
  32968. * Gets or sets the current on-screen Y position of the pointer
  32969. */
  32970. pointerY: number;
  32971. /**
  32972. * Gets the cached material (ie. the latest rendered one)
  32973. * @returns the cached material
  32974. */
  32975. getCachedMaterial(): Nullable<Material>;
  32976. /**
  32977. * Gets the cached effect (ie. the latest rendered one)
  32978. * @returns the cached effect
  32979. */
  32980. getCachedEffect(): Nullable<Effect>;
  32981. /**
  32982. * Gets the cached visibility state (ie. the latest rendered one)
  32983. * @returns the cached visibility state
  32984. */
  32985. getCachedVisibility(): Nullable<number>;
  32986. /**
  32987. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32988. * @param material defines the current material
  32989. * @param effect defines the current effect
  32990. * @param visibility defines the current visibility state
  32991. * @returns true if one parameter is not cached
  32992. */
  32993. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32994. /**
  32995. * Gets the engine associated with the scene
  32996. * @returns an Engine
  32997. */
  32998. getEngine(): Engine;
  32999. /**
  33000. * Gets the total number of vertices rendered per frame
  33001. * @returns the total number of vertices rendered per frame
  33002. */
  33003. getTotalVertices(): number;
  33004. /**
  33005. * Gets the performance counter for total vertices
  33006. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33007. */
  33008. readonly totalVerticesPerfCounter: PerfCounter;
  33009. /**
  33010. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33011. * @returns the total number of active indices rendered per frame
  33012. */
  33013. getActiveIndices(): number;
  33014. /**
  33015. * Gets the performance counter for active indices
  33016. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33017. */
  33018. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33019. /**
  33020. * Gets the total number of active particles rendered per frame
  33021. * @returns the total number of active particles rendered per frame
  33022. */
  33023. getActiveParticles(): number;
  33024. /**
  33025. * Gets the performance counter for active particles
  33026. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33027. */
  33028. readonly activeParticlesPerfCounter: PerfCounter;
  33029. /**
  33030. * Gets the total number of active bones rendered per frame
  33031. * @returns the total number of active bones rendered per frame
  33032. */
  33033. getActiveBones(): number;
  33034. /**
  33035. * Gets the performance counter for active bones
  33036. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33037. */
  33038. readonly activeBonesPerfCounter: PerfCounter;
  33039. /**
  33040. * Gets the array of active meshes
  33041. * @returns an array of AbstractMesh
  33042. */
  33043. getActiveMeshes(): SmartArray<AbstractMesh>;
  33044. /**
  33045. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33046. * @returns a number
  33047. */
  33048. getAnimationRatio(): number;
  33049. /**
  33050. * Gets an unique Id for the current render phase
  33051. * @returns a number
  33052. */
  33053. getRenderId(): number;
  33054. /**
  33055. * Gets an unique Id for the current frame
  33056. * @returns a number
  33057. */
  33058. getFrameId(): number;
  33059. /** Call this function if you want to manually increment the render Id*/
  33060. incrementRenderId(): void;
  33061. private _createUbo;
  33062. /**
  33063. * Use this method to simulate a pointer move on a mesh
  33064. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33065. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33066. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33067. * @returns the current scene
  33068. */
  33069. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33070. /**
  33071. * Use this method to simulate a pointer down on a mesh
  33072. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33073. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33074. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33075. * @returns the current scene
  33076. */
  33077. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33078. /**
  33079. * Use this method to simulate a pointer up on a mesh
  33080. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33081. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33082. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33083. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33084. * @returns the current scene
  33085. */
  33086. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33087. /**
  33088. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33089. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33090. * @returns true if the pointer was captured
  33091. */
  33092. isPointerCaptured(pointerId?: number): boolean;
  33093. /**
  33094. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33095. * @param attachUp defines if you want to attach events to pointerup
  33096. * @param attachDown defines if you want to attach events to pointerdown
  33097. * @param attachMove defines if you want to attach events to pointermove
  33098. */
  33099. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33100. /** Detaches all event handlers*/
  33101. detachControl(): void;
  33102. /**
  33103. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33104. * Delay loaded resources are not taking in account
  33105. * @return true if all required resources are ready
  33106. */
  33107. isReady(): boolean;
  33108. /** Resets all cached information relative to material (including effect and visibility) */
  33109. resetCachedMaterial(): void;
  33110. /**
  33111. * Registers a function to be called before every frame render
  33112. * @param func defines the function to register
  33113. */
  33114. registerBeforeRender(func: () => void): void;
  33115. /**
  33116. * Unregisters a function called before every frame render
  33117. * @param func defines the function to unregister
  33118. */
  33119. unregisterBeforeRender(func: () => void): void;
  33120. /**
  33121. * Registers a function to be called after every frame render
  33122. * @param func defines the function to register
  33123. */
  33124. registerAfterRender(func: () => void): void;
  33125. /**
  33126. * Unregisters a function called after every frame render
  33127. * @param func defines the function to unregister
  33128. */
  33129. unregisterAfterRender(func: () => void): void;
  33130. private _executeOnceBeforeRender;
  33131. /**
  33132. * The provided function will run before render once and will be disposed afterwards.
  33133. * A timeout delay can be provided so that the function will be executed in N ms.
  33134. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33135. * @param func The function to be executed.
  33136. * @param timeout optional delay in ms
  33137. */
  33138. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33139. /** @hidden */
  33140. _addPendingData(data: any): void;
  33141. /** @hidden */
  33142. _removePendingData(data: any): void;
  33143. /**
  33144. * Returns the number of items waiting to be loaded
  33145. * @returns the number of items waiting to be loaded
  33146. */
  33147. getWaitingItemsCount(): number;
  33148. /**
  33149. * Returns a boolean indicating if the scene is still loading data
  33150. */
  33151. readonly isLoading: boolean;
  33152. /**
  33153. * Registers a function to be executed when the scene is ready
  33154. * @param {Function} func - the function to be executed
  33155. */
  33156. executeWhenReady(func: () => void): void;
  33157. /**
  33158. * Returns a promise that resolves when the scene is ready
  33159. * @returns A promise that resolves when the scene is ready
  33160. */
  33161. whenReadyAsync(): Promise<void>;
  33162. /** @hidden */
  33163. _checkIsReady(): void;
  33164. /**
  33165. * Gets all animatable attached to the scene
  33166. */
  33167. readonly animatables: Animatable[];
  33168. /**
  33169. * Resets the last animation time frame.
  33170. * Useful to override when animations start running when loading a scene for the first time.
  33171. */
  33172. resetLastAnimationTimeFrame(): void;
  33173. /**
  33174. * Gets the current view matrix
  33175. * @returns a Matrix
  33176. */
  33177. getViewMatrix(): Matrix;
  33178. /**
  33179. * Gets the current projection matrix
  33180. * @returns a Matrix
  33181. */
  33182. getProjectionMatrix(): Matrix;
  33183. /**
  33184. * Gets the current transform matrix
  33185. * @returns a Matrix made of View * Projection
  33186. */
  33187. getTransformMatrix(): Matrix;
  33188. /**
  33189. * Sets the current transform matrix
  33190. * @param viewL defines the View matrix to use
  33191. * @param projectionL defines the Projection matrix to use
  33192. * @param viewR defines the right View matrix to use (if provided)
  33193. * @param projectionR defines the right Projection matrix to use (if provided)
  33194. */
  33195. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33196. /**
  33197. * Gets the uniform buffer used to store scene data
  33198. * @returns a UniformBuffer
  33199. */
  33200. getSceneUniformBuffer(): UniformBuffer;
  33201. /**
  33202. * Gets an unique (relatively to the current scene) Id
  33203. * @returns an unique number for the scene
  33204. */
  33205. getUniqueId(): number;
  33206. /**
  33207. * Add a mesh to the list of scene's meshes
  33208. * @param newMesh defines the mesh to add
  33209. * @param recursive if all child meshes should also be added to the scene
  33210. */
  33211. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33212. /**
  33213. * Remove a mesh for the list of scene's meshes
  33214. * @param toRemove defines the mesh to remove
  33215. * @param recursive if all child meshes should also be removed from the scene
  33216. * @returns the index where the mesh was in the mesh list
  33217. */
  33218. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33219. /**
  33220. * Add a transform node to the list of scene's transform nodes
  33221. * @param newTransformNode defines the transform node to add
  33222. */
  33223. addTransformNode(newTransformNode: TransformNode): void;
  33224. /**
  33225. * Remove a transform node for the list of scene's transform nodes
  33226. * @param toRemove defines the transform node to remove
  33227. * @returns the index where the transform node was in the transform node list
  33228. */
  33229. removeTransformNode(toRemove: TransformNode): number;
  33230. /**
  33231. * Remove a skeleton for the list of scene's skeletons
  33232. * @param toRemove defines the skeleton to remove
  33233. * @returns the index where the skeleton was in the skeleton list
  33234. */
  33235. removeSkeleton(toRemove: Skeleton): number;
  33236. /**
  33237. * Remove a morph target for the list of scene's morph targets
  33238. * @param toRemove defines the morph target to remove
  33239. * @returns the index where the morph target was in the morph target list
  33240. */
  33241. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33242. /**
  33243. * Remove a light for the list of scene's lights
  33244. * @param toRemove defines the light to remove
  33245. * @returns the index where the light was in the light list
  33246. */
  33247. removeLight(toRemove: Light): number;
  33248. /**
  33249. * Remove a camera for the list of scene's cameras
  33250. * @param toRemove defines the camera to remove
  33251. * @returns the index where the camera was in the camera list
  33252. */
  33253. removeCamera(toRemove: Camera): number;
  33254. /**
  33255. * Remove a particle system for the list of scene's particle systems
  33256. * @param toRemove defines the particle system to remove
  33257. * @returns the index where the particle system was in the particle system list
  33258. */
  33259. removeParticleSystem(toRemove: IParticleSystem): number;
  33260. /**
  33261. * Remove a animation for the list of scene's animations
  33262. * @param toRemove defines the animation to remove
  33263. * @returns the index where the animation was in the animation list
  33264. */
  33265. removeAnimation(toRemove: Animation): number;
  33266. /**
  33267. * Will stop the animation of the given target
  33268. * @param target - the target
  33269. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33270. * @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)
  33271. */
  33272. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33273. /**
  33274. * Removes the given animation group from this scene.
  33275. * @param toRemove The animation group to remove
  33276. * @returns The index of the removed animation group
  33277. */
  33278. removeAnimationGroup(toRemove: AnimationGroup): number;
  33279. /**
  33280. * Removes the given multi-material from this scene.
  33281. * @param toRemove The multi-material to remove
  33282. * @returns The index of the removed multi-material
  33283. */
  33284. removeMultiMaterial(toRemove: MultiMaterial): number;
  33285. /**
  33286. * Removes the given material from this scene.
  33287. * @param toRemove The material to remove
  33288. * @returns The index of the removed material
  33289. */
  33290. removeMaterial(toRemove: Material): number;
  33291. /**
  33292. * Removes the given action manager from this scene.
  33293. * @param toRemove The action manager to remove
  33294. * @returns The index of the removed action manager
  33295. */
  33296. removeActionManager(toRemove: AbstractActionManager): number;
  33297. /**
  33298. * Removes the given texture from this scene.
  33299. * @param toRemove The texture to remove
  33300. * @returns The index of the removed texture
  33301. */
  33302. removeTexture(toRemove: BaseTexture): number;
  33303. /**
  33304. * Adds the given light to this scene
  33305. * @param newLight The light to add
  33306. */
  33307. addLight(newLight: Light): void;
  33308. /**
  33309. * Sorts the list list based on light priorities
  33310. */
  33311. sortLightsByPriority(): void;
  33312. /**
  33313. * Adds the given camera to this scene
  33314. * @param newCamera The camera to add
  33315. */
  33316. addCamera(newCamera: Camera): void;
  33317. /**
  33318. * Adds the given skeleton to this scene
  33319. * @param newSkeleton The skeleton to add
  33320. */
  33321. addSkeleton(newSkeleton: Skeleton): void;
  33322. /**
  33323. * Adds the given particle system to this scene
  33324. * @param newParticleSystem The particle system to add
  33325. */
  33326. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33327. /**
  33328. * Adds the given animation to this scene
  33329. * @param newAnimation The animation to add
  33330. */
  33331. addAnimation(newAnimation: Animation): void;
  33332. /**
  33333. * Adds the given animation group to this scene.
  33334. * @param newAnimationGroup The animation group to add
  33335. */
  33336. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33337. /**
  33338. * Adds the given multi-material to this scene
  33339. * @param newMultiMaterial The multi-material to add
  33340. */
  33341. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33342. /**
  33343. * Adds the given material to this scene
  33344. * @param newMaterial The material to add
  33345. */
  33346. addMaterial(newMaterial: Material): void;
  33347. /**
  33348. * Adds the given morph target to this scene
  33349. * @param newMorphTargetManager The morph target to add
  33350. */
  33351. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33352. /**
  33353. * Adds the given geometry to this scene
  33354. * @param newGeometry The geometry to add
  33355. */
  33356. addGeometry(newGeometry: Geometry): void;
  33357. /**
  33358. * Adds the given action manager to this scene
  33359. * @param newActionManager The action manager to add
  33360. */
  33361. addActionManager(newActionManager: AbstractActionManager): void;
  33362. /**
  33363. * Adds the given texture to this scene.
  33364. * @param newTexture The texture to add
  33365. */
  33366. addTexture(newTexture: BaseTexture): void;
  33367. /**
  33368. * Switch active camera
  33369. * @param newCamera defines the new active camera
  33370. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33371. */
  33372. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33373. /**
  33374. * sets the active camera of the scene using its ID
  33375. * @param id defines the camera's ID
  33376. * @return the new active camera or null if none found.
  33377. */
  33378. setActiveCameraByID(id: string): Nullable<Camera>;
  33379. /**
  33380. * sets the active camera of the scene using its name
  33381. * @param name defines the camera's name
  33382. * @returns the new active camera or null if none found.
  33383. */
  33384. setActiveCameraByName(name: string): Nullable<Camera>;
  33385. /**
  33386. * get an animation group using its name
  33387. * @param name defines the material's name
  33388. * @return the animation group or null if none found.
  33389. */
  33390. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33391. /**
  33392. * Get a material using its unique id
  33393. * @param uniqueId defines the material's unique id
  33394. * @return the material or null if none found.
  33395. */
  33396. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33397. /**
  33398. * get a material using its id
  33399. * @param id defines the material's ID
  33400. * @return the material or null if none found.
  33401. */
  33402. getMaterialByID(id: string): Nullable<Material>;
  33403. /**
  33404. * Gets a material using its name
  33405. * @param name defines the material's name
  33406. * @return the material or null if none found.
  33407. */
  33408. getMaterialByName(name: string): Nullable<Material>;
  33409. /**
  33410. * Gets a camera using its id
  33411. * @param id defines the id to look for
  33412. * @returns the camera or null if not found
  33413. */
  33414. getCameraByID(id: string): Nullable<Camera>;
  33415. /**
  33416. * Gets a camera using its unique id
  33417. * @param uniqueId defines the unique id to look for
  33418. * @returns the camera or null if not found
  33419. */
  33420. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33421. /**
  33422. * Gets a camera using its name
  33423. * @param name defines the camera's name
  33424. * @return the camera or null if none found.
  33425. */
  33426. getCameraByName(name: string): Nullable<Camera>;
  33427. /**
  33428. * Gets a bone using its id
  33429. * @param id defines the bone's id
  33430. * @return the bone or null if not found
  33431. */
  33432. getBoneByID(id: string): Nullable<Bone>;
  33433. /**
  33434. * Gets a bone using its id
  33435. * @param name defines the bone's name
  33436. * @return the bone or null if not found
  33437. */
  33438. getBoneByName(name: string): Nullable<Bone>;
  33439. /**
  33440. * Gets a light node using its name
  33441. * @param name defines the the light's name
  33442. * @return the light or null if none found.
  33443. */
  33444. getLightByName(name: string): Nullable<Light>;
  33445. /**
  33446. * Gets a light node using its id
  33447. * @param id defines the light's id
  33448. * @return the light or null if none found.
  33449. */
  33450. getLightByID(id: string): Nullable<Light>;
  33451. /**
  33452. * Gets a light node using its scene-generated unique ID
  33453. * @param uniqueId defines the light's unique id
  33454. * @return the light or null if none found.
  33455. */
  33456. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33457. /**
  33458. * Gets a particle system by id
  33459. * @param id defines the particle system id
  33460. * @return the corresponding system or null if none found
  33461. */
  33462. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33463. /**
  33464. * Gets a geometry using its ID
  33465. * @param id defines the geometry's id
  33466. * @return the geometry or null if none found.
  33467. */
  33468. getGeometryByID(id: string): Nullable<Geometry>;
  33469. private _getGeometryByUniqueID;
  33470. /**
  33471. * Add a new geometry to this scene
  33472. * @param geometry defines the geometry to be added to the scene.
  33473. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33474. * @return a boolean defining if the geometry was added or not
  33475. */
  33476. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33477. /**
  33478. * Removes an existing geometry
  33479. * @param geometry defines the geometry to be removed from the scene
  33480. * @return a boolean defining if the geometry was removed or not
  33481. */
  33482. removeGeometry(geometry: Geometry): boolean;
  33483. /**
  33484. * Gets the list of geometries attached to the scene
  33485. * @returns an array of Geometry
  33486. */
  33487. getGeometries(): Geometry[];
  33488. /**
  33489. * Gets the first added mesh found of a given ID
  33490. * @param id defines the id to search for
  33491. * @return the mesh found or null if not found at all
  33492. */
  33493. getMeshByID(id: string): Nullable<AbstractMesh>;
  33494. /**
  33495. * Gets a list of meshes using their id
  33496. * @param id defines the id to search for
  33497. * @returns a list of meshes
  33498. */
  33499. getMeshesByID(id: string): Array<AbstractMesh>;
  33500. /**
  33501. * Gets the first added transform node found of a given ID
  33502. * @param id defines the id to search for
  33503. * @return the found transform node or null if not found at all.
  33504. */
  33505. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33506. /**
  33507. * Gets a transform node with its auto-generated unique id
  33508. * @param uniqueId efines the unique id to search for
  33509. * @return the found transform node or null if not found at all.
  33510. */
  33511. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33512. /**
  33513. * Gets a list of transform nodes using their id
  33514. * @param id defines the id to search for
  33515. * @returns a list of transform nodes
  33516. */
  33517. getTransformNodesByID(id: string): Array<TransformNode>;
  33518. /**
  33519. * Gets a mesh with its auto-generated unique id
  33520. * @param uniqueId defines the unique id to search for
  33521. * @return the found mesh or null if not found at all.
  33522. */
  33523. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33524. /**
  33525. * Gets a the last added mesh using a given id
  33526. * @param id defines the id to search for
  33527. * @return the found mesh or null if not found at all.
  33528. */
  33529. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33530. /**
  33531. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33532. * @param id defines the id to search for
  33533. * @return the found node or null if not found at all
  33534. */
  33535. getLastEntryByID(id: string): Nullable<Node>;
  33536. /**
  33537. * Gets a node (Mesh, Camera, Light) using a given id
  33538. * @param id defines the id to search for
  33539. * @return the found node or null if not found at all
  33540. */
  33541. getNodeByID(id: string): Nullable<Node>;
  33542. /**
  33543. * Gets a node (Mesh, Camera, Light) using a given name
  33544. * @param name defines the name to search for
  33545. * @return the found node or null if not found at all.
  33546. */
  33547. getNodeByName(name: string): Nullable<Node>;
  33548. /**
  33549. * Gets a mesh using a given name
  33550. * @param name defines the name to search for
  33551. * @return the found mesh or null if not found at all.
  33552. */
  33553. getMeshByName(name: string): Nullable<AbstractMesh>;
  33554. /**
  33555. * Gets a transform node using a given name
  33556. * @param name defines the name to search for
  33557. * @return the found transform node or null if not found at all.
  33558. */
  33559. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33560. /**
  33561. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33562. * @param id defines the id to search for
  33563. * @return the found skeleton or null if not found at all.
  33564. */
  33565. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33566. /**
  33567. * Gets a skeleton using a given auto generated unique id
  33568. * @param uniqueId defines the unique id to search for
  33569. * @return the found skeleton or null if not found at all.
  33570. */
  33571. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33572. /**
  33573. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33574. * @param id defines the id to search for
  33575. * @return the found skeleton or null if not found at all.
  33576. */
  33577. getSkeletonById(id: string): Nullable<Skeleton>;
  33578. /**
  33579. * Gets a skeleton using a given name
  33580. * @param name defines the name to search for
  33581. * @return the found skeleton or null if not found at all.
  33582. */
  33583. getSkeletonByName(name: string): Nullable<Skeleton>;
  33584. /**
  33585. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33586. * @param id defines the id to search for
  33587. * @return the found morph target manager or null if not found at all.
  33588. */
  33589. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33590. /**
  33591. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33592. * @param id defines the id to search for
  33593. * @return the found morph target or null if not found at all.
  33594. */
  33595. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33596. /**
  33597. * Gets a boolean indicating if the given mesh is active
  33598. * @param mesh defines the mesh to look for
  33599. * @returns true if the mesh is in the active list
  33600. */
  33601. isActiveMesh(mesh: AbstractMesh): boolean;
  33602. /**
  33603. * Return a unique id as a string which can serve as an identifier for the scene
  33604. */
  33605. readonly uid: string;
  33606. /**
  33607. * Add an externaly attached data from its key.
  33608. * This method call will fail and return false, if such key already exists.
  33609. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33610. * @param key the unique key that identifies the data
  33611. * @param data the data object to associate to the key for this Engine instance
  33612. * @return true if no such key were already present and the data was added successfully, false otherwise
  33613. */
  33614. addExternalData<T>(key: string, data: T): boolean;
  33615. /**
  33616. * Get an externaly attached data from its key
  33617. * @param key the unique key that identifies the data
  33618. * @return the associated data, if present (can be null), or undefined if not present
  33619. */
  33620. getExternalData<T>(key: string): Nullable<T>;
  33621. /**
  33622. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33623. * @param key the unique key that identifies the data
  33624. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33625. * @return the associated data, can be null if the factory returned null.
  33626. */
  33627. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33628. /**
  33629. * Remove an externaly attached data from the Engine instance
  33630. * @param key the unique key that identifies the data
  33631. * @return true if the data was successfully removed, false if it doesn't exist
  33632. */
  33633. removeExternalData(key: string): boolean;
  33634. private _evaluateSubMesh;
  33635. /**
  33636. * Clear the processed materials smart array preventing retention point in material dispose.
  33637. */
  33638. freeProcessedMaterials(): void;
  33639. private _preventFreeActiveMeshesAndRenderingGroups;
  33640. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33641. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33642. * when disposing several meshes in a row or a hierarchy of meshes.
  33643. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33644. */
  33645. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33646. /**
  33647. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33648. */
  33649. freeActiveMeshes(): void;
  33650. /**
  33651. * Clear the info related to rendering groups preventing retention points during dispose.
  33652. */
  33653. freeRenderingGroups(): void;
  33654. /** @hidden */
  33655. _isInIntermediateRendering(): boolean;
  33656. /**
  33657. * Lambda returning the list of potentially active meshes.
  33658. */
  33659. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33660. /**
  33661. * Lambda returning the list of potentially active sub meshes.
  33662. */
  33663. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33664. /**
  33665. * Lambda returning the list of potentially intersecting sub meshes.
  33666. */
  33667. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33668. /**
  33669. * Lambda returning the list of potentially colliding sub meshes.
  33670. */
  33671. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33672. private _activeMeshesFrozen;
  33673. /**
  33674. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33675. * @returns the current scene
  33676. */
  33677. freezeActiveMeshes(): Scene;
  33678. /**
  33679. * Use this function to restart evaluating active meshes on every frame
  33680. * @returns the current scene
  33681. */
  33682. unfreezeActiveMeshes(): Scene;
  33683. private _evaluateActiveMeshes;
  33684. private _activeMesh;
  33685. /**
  33686. * Update the transform matrix to update from the current active camera
  33687. * @param force defines a boolean used to force the update even if cache is up to date
  33688. */
  33689. updateTransformMatrix(force?: boolean): void;
  33690. private _bindFrameBuffer;
  33691. /** @hidden */
  33692. _allowPostProcessClearColor: boolean;
  33693. /** @hidden */
  33694. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33695. private _processSubCameras;
  33696. private _checkIntersections;
  33697. /** @hidden */
  33698. _advancePhysicsEngineStep(step: number): void;
  33699. /**
  33700. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33701. */
  33702. getDeterministicFrameTime: () => number;
  33703. /** @hidden */
  33704. _animate(): void;
  33705. /** Execute all animations (for a frame) */
  33706. animate(): void;
  33707. /**
  33708. * Render the scene
  33709. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33710. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33711. */
  33712. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33713. /**
  33714. * Freeze all materials
  33715. * A frozen material will not be updatable but should be faster to render
  33716. */
  33717. freezeMaterials(): void;
  33718. /**
  33719. * Unfreeze all materials
  33720. * A frozen material will not be updatable but should be faster to render
  33721. */
  33722. unfreezeMaterials(): void;
  33723. /**
  33724. * Releases all held ressources
  33725. */
  33726. dispose(): void;
  33727. /**
  33728. * Gets if the scene is already disposed
  33729. */
  33730. readonly isDisposed: boolean;
  33731. /**
  33732. * Call this function to reduce memory footprint of the scene.
  33733. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33734. */
  33735. clearCachedVertexData(): void;
  33736. /**
  33737. * This function will remove the local cached buffer data from texture.
  33738. * It will save memory but will prevent the texture from being rebuilt
  33739. */
  33740. cleanCachedTextureBuffer(): void;
  33741. /**
  33742. * Get the world extend vectors with an optional filter
  33743. *
  33744. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33745. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33746. */
  33747. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33748. min: Vector3;
  33749. max: Vector3;
  33750. };
  33751. /**
  33752. * Creates a ray that can be used to pick in the scene
  33753. * @param x defines the x coordinate of the origin (on-screen)
  33754. * @param y defines the y coordinate of the origin (on-screen)
  33755. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33756. * @param camera defines the camera to use for the picking
  33757. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33758. * @returns a Ray
  33759. */
  33760. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33761. /**
  33762. * Creates a ray that can be used to pick in the scene
  33763. * @param x defines the x coordinate of the origin (on-screen)
  33764. * @param y defines the y coordinate of the origin (on-screen)
  33765. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33766. * @param result defines the ray where to store the picking ray
  33767. * @param camera defines the camera to use for the picking
  33768. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33769. * @returns the current scene
  33770. */
  33771. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33772. /**
  33773. * Creates a ray that can be used to pick in the scene
  33774. * @param x defines the x coordinate of the origin (on-screen)
  33775. * @param y defines the y coordinate of the origin (on-screen)
  33776. * @param camera defines the camera to use for the picking
  33777. * @returns a Ray
  33778. */
  33779. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33780. /**
  33781. * Creates a ray that can be used to pick in the scene
  33782. * @param x defines the x coordinate of the origin (on-screen)
  33783. * @param y defines the y coordinate of the origin (on-screen)
  33784. * @param result defines the ray where to store the picking ray
  33785. * @param camera defines the camera to use for the picking
  33786. * @returns the current scene
  33787. */
  33788. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33789. /** Launch a ray to try to pick a mesh in the scene
  33790. * @param x position on screen
  33791. * @param y position on screen
  33792. * @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
  33793. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33794. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33795. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33796. * @returns a PickingInfo
  33797. */
  33798. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33799. /** Use the given ray to pick a mesh in the scene
  33800. * @param ray The ray to use to pick meshes
  33801. * @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
  33802. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33803. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33804. * @returns a PickingInfo
  33805. */
  33806. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33807. /**
  33808. * Launch a ray to try to pick a mesh in the scene
  33809. * @param x X position on screen
  33810. * @param y Y position on screen
  33811. * @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
  33812. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33813. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33814. * @returns an array of PickingInfo
  33815. */
  33816. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33817. /**
  33818. * Launch a ray to try to pick a mesh in the scene
  33819. * @param ray Ray to use
  33820. * @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
  33821. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33822. * @returns an array of PickingInfo
  33823. */
  33824. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33825. /**
  33826. * Force the value of meshUnderPointer
  33827. * @param mesh defines the mesh to use
  33828. */
  33829. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33830. /**
  33831. * Gets the mesh under the pointer
  33832. * @returns a Mesh or null if no mesh is under the pointer
  33833. */
  33834. getPointerOverMesh(): Nullable<AbstractMesh>;
  33835. /** @hidden */
  33836. _rebuildGeometries(): void;
  33837. /** @hidden */
  33838. _rebuildTextures(): void;
  33839. private _getByTags;
  33840. /**
  33841. * Get a list of meshes by tags
  33842. * @param tagsQuery defines the tags query to use
  33843. * @param forEach defines a predicate used to filter results
  33844. * @returns an array of Mesh
  33845. */
  33846. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33847. /**
  33848. * Get a list of cameras by tags
  33849. * @param tagsQuery defines the tags query to use
  33850. * @param forEach defines a predicate used to filter results
  33851. * @returns an array of Camera
  33852. */
  33853. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33854. /**
  33855. * Get a list of lights by tags
  33856. * @param tagsQuery defines the tags query to use
  33857. * @param forEach defines a predicate used to filter results
  33858. * @returns an array of Light
  33859. */
  33860. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33861. /**
  33862. * Get a list of materials by tags
  33863. * @param tagsQuery defines the tags query to use
  33864. * @param forEach defines a predicate used to filter results
  33865. * @returns an array of Material
  33866. */
  33867. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33868. /**
  33869. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33870. * This allowed control for front to back rendering or reversly depending of the special needs.
  33871. *
  33872. * @param renderingGroupId The rendering group id corresponding to its index
  33873. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33874. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33875. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33876. */
  33877. 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;
  33878. /**
  33879. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33880. *
  33881. * @param renderingGroupId The rendering group id corresponding to its index
  33882. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33883. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33884. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33885. */
  33886. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33887. /**
  33888. * Gets the current auto clear configuration for one rendering group of the rendering
  33889. * manager.
  33890. * @param index the rendering group index to get the information for
  33891. * @returns The auto clear setup for the requested rendering group
  33892. */
  33893. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33894. private _blockMaterialDirtyMechanism;
  33895. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33896. blockMaterialDirtyMechanism: boolean;
  33897. /**
  33898. * Will flag all materials as dirty to trigger new shader compilation
  33899. * @param flag defines the flag used to specify which material part must be marked as dirty
  33900. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33901. */
  33902. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33903. /** @hidden */
  33904. _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;
  33905. /** @hidden */
  33906. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33907. }
  33908. }
  33909. declare module BABYLON {
  33910. /**
  33911. * Set of assets to keep when moving a scene into an asset container.
  33912. */
  33913. export class KeepAssets extends AbstractScene {
  33914. }
  33915. /**
  33916. * Container with a set of assets that can be added or removed from a scene.
  33917. */
  33918. export class AssetContainer extends AbstractScene {
  33919. /**
  33920. * The scene the AssetContainer belongs to.
  33921. */
  33922. scene: Scene;
  33923. /**
  33924. * Instantiates an AssetContainer.
  33925. * @param scene The scene the AssetContainer belongs to.
  33926. */
  33927. constructor(scene: Scene);
  33928. /**
  33929. * Adds all the assets from the container to the scene.
  33930. */
  33931. addAllToScene(): void;
  33932. /**
  33933. * Removes all the assets in the container from the scene
  33934. */
  33935. removeAllFromScene(): void;
  33936. /**
  33937. * Disposes all the assets in the container
  33938. */
  33939. dispose(): void;
  33940. private _moveAssets;
  33941. /**
  33942. * Removes all the assets contained in the scene and adds them to the container.
  33943. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33944. */
  33945. moveAllFromScene(keepAssets?: KeepAssets): void;
  33946. /**
  33947. * 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.
  33948. * @returns the root mesh
  33949. */
  33950. createRootMesh(): Mesh;
  33951. }
  33952. }
  33953. declare module BABYLON {
  33954. /**
  33955. * Defines how the parser contract is defined.
  33956. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33957. */
  33958. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33959. /**
  33960. * Defines how the individual parser contract is defined.
  33961. * These parser can parse an individual asset
  33962. */
  33963. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33964. /**
  33965. * Base class of the scene acting as a container for the different elements composing a scene.
  33966. * This class is dynamically extended by the different components of the scene increasing
  33967. * flexibility and reducing coupling
  33968. */
  33969. export abstract class AbstractScene {
  33970. /**
  33971. * Stores the list of available parsers in the application.
  33972. */
  33973. private static _BabylonFileParsers;
  33974. /**
  33975. * Stores the list of available individual parsers in the application.
  33976. */
  33977. private static _IndividualBabylonFileParsers;
  33978. /**
  33979. * Adds a parser in the list of available ones
  33980. * @param name Defines the name of the parser
  33981. * @param parser Defines the parser to add
  33982. */
  33983. static AddParser(name: string, parser: BabylonFileParser): void;
  33984. /**
  33985. * Gets a general parser from the list of avaialble ones
  33986. * @param name Defines the name of the parser
  33987. * @returns the requested parser or null
  33988. */
  33989. static GetParser(name: string): Nullable<BabylonFileParser>;
  33990. /**
  33991. * Adds n individual parser in the list of available ones
  33992. * @param name Defines the name of the parser
  33993. * @param parser Defines the parser to add
  33994. */
  33995. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33996. /**
  33997. * Gets an individual parser from the list of avaialble ones
  33998. * @param name Defines the name of the parser
  33999. * @returns the requested parser or null
  34000. */
  34001. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34002. /**
  34003. * Parser json data and populate both a scene and its associated container object
  34004. * @param jsonData Defines the data to parse
  34005. * @param scene Defines the scene to parse the data for
  34006. * @param container Defines the container attached to the parsing sequence
  34007. * @param rootUrl Defines the root url of the data
  34008. */
  34009. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34010. /**
  34011. * Gets the list of root nodes (ie. nodes with no parent)
  34012. */
  34013. rootNodes: Node[];
  34014. /** All of the cameras added to this scene
  34015. * @see http://doc.babylonjs.com/babylon101/cameras
  34016. */
  34017. cameras: Camera[];
  34018. /**
  34019. * All of the lights added to this scene
  34020. * @see http://doc.babylonjs.com/babylon101/lights
  34021. */
  34022. lights: Light[];
  34023. /**
  34024. * All of the (abstract) meshes added to this scene
  34025. */
  34026. meshes: AbstractMesh[];
  34027. /**
  34028. * The list of skeletons added to the scene
  34029. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34030. */
  34031. skeletons: Skeleton[];
  34032. /**
  34033. * All of the particle systems added to this scene
  34034. * @see http://doc.babylonjs.com/babylon101/particles
  34035. */
  34036. particleSystems: IParticleSystem[];
  34037. /**
  34038. * Gets a list of Animations associated with the scene
  34039. */
  34040. animations: Animation[];
  34041. /**
  34042. * All of the animation groups added to this scene
  34043. * @see http://doc.babylonjs.com/how_to/group
  34044. */
  34045. animationGroups: AnimationGroup[];
  34046. /**
  34047. * All of the multi-materials added to this scene
  34048. * @see http://doc.babylonjs.com/how_to/multi_materials
  34049. */
  34050. multiMaterials: MultiMaterial[];
  34051. /**
  34052. * All of the materials added to this scene
  34053. * In the context of a Scene, it is not supposed to be modified manually.
  34054. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34055. * Note also that the order of the Material wihin the array is not significant and might change.
  34056. * @see http://doc.babylonjs.com/babylon101/materials
  34057. */
  34058. materials: Material[];
  34059. /**
  34060. * The list of morph target managers added to the scene
  34061. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34062. */
  34063. morphTargetManagers: MorphTargetManager[];
  34064. /**
  34065. * The list of geometries used in the scene.
  34066. */
  34067. geometries: Geometry[];
  34068. /**
  34069. * All of the tranform nodes added to this scene
  34070. * In the context of a Scene, it is not supposed to be modified manually.
  34071. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34072. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34073. * @see http://doc.babylonjs.com/how_to/transformnode
  34074. */
  34075. transformNodes: TransformNode[];
  34076. /**
  34077. * ActionManagers available on the scene.
  34078. */
  34079. actionManagers: AbstractActionManager[];
  34080. /**
  34081. * Textures to keep.
  34082. */
  34083. textures: BaseTexture[];
  34084. /**
  34085. * Environment texture for the scene
  34086. */
  34087. environmentTexture: Nullable<BaseTexture>;
  34088. }
  34089. }
  34090. declare module BABYLON {
  34091. /**
  34092. * Defines a sound that can be played in the application.
  34093. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34094. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34095. */
  34096. export class Sound {
  34097. /**
  34098. * The name of the sound in the scene.
  34099. */
  34100. name: string;
  34101. /**
  34102. * Does the sound autoplay once loaded.
  34103. */
  34104. autoplay: boolean;
  34105. /**
  34106. * Does the sound loop after it finishes playing once.
  34107. */
  34108. loop: boolean;
  34109. /**
  34110. * Does the sound use a custom attenuation curve to simulate the falloff
  34111. * happening when the source gets further away from the camera.
  34112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34113. */
  34114. useCustomAttenuation: boolean;
  34115. /**
  34116. * The sound track id this sound belongs to.
  34117. */
  34118. soundTrackId: number;
  34119. /**
  34120. * Is this sound currently played.
  34121. */
  34122. isPlaying: boolean;
  34123. /**
  34124. * Is this sound currently paused.
  34125. */
  34126. isPaused: boolean;
  34127. /**
  34128. * Does this sound enables spatial sound.
  34129. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34130. */
  34131. spatialSound: boolean;
  34132. /**
  34133. * Define the reference distance the sound should be heard perfectly.
  34134. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34135. */
  34136. refDistance: number;
  34137. /**
  34138. * Define the roll off factor of spatial sounds.
  34139. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34140. */
  34141. rolloffFactor: number;
  34142. /**
  34143. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34144. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34145. */
  34146. maxDistance: number;
  34147. /**
  34148. * Define the distance attenuation model the sound will follow.
  34149. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34150. */
  34151. distanceModel: string;
  34152. /**
  34153. * @hidden
  34154. * Back Compat
  34155. **/
  34156. onended: () => any;
  34157. /**
  34158. * Observable event when the current playing sound finishes.
  34159. */
  34160. onEndedObservable: Observable<Sound>;
  34161. private _panningModel;
  34162. private _playbackRate;
  34163. private _streaming;
  34164. private _startTime;
  34165. private _startOffset;
  34166. private _position;
  34167. /** @hidden */
  34168. _positionInEmitterSpace: boolean;
  34169. private _localDirection;
  34170. private _volume;
  34171. private _isReadyToPlay;
  34172. private _isDirectional;
  34173. private _readyToPlayCallback;
  34174. private _audioBuffer;
  34175. private _soundSource;
  34176. private _streamingSource;
  34177. private _soundPanner;
  34178. private _soundGain;
  34179. private _inputAudioNode;
  34180. private _outputAudioNode;
  34181. private _coneInnerAngle;
  34182. private _coneOuterAngle;
  34183. private _coneOuterGain;
  34184. private _scene;
  34185. private _connectedTransformNode;
  34186. private _customAttenuationFunction;
  34187. private _registerFunc;
  34188. private _isOutputConnected;
  34189. private _htmlAudioElement;
  34190. private _urlType;
  34191. /** @hidden */
  34192. static _SceneComponentInitialization: (scene: Scene) => void;
  34193. /**
  34194. * Create a sound and attach it to a scene
  34195. * @param name Name of your sound
  34196. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34197. * @param scene defines the scene the sound belongs to
  34198. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34199. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34200. */
  34201. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34202. /**
  34203. * Release the sound and its associated resources
  34204. */
  34205. dispose(): void;
  34206. /**
  34207. * Gets if the sounds is ready to be played or not.
  34208. * @returns true if ready, otherwise false
  34209. */
  34210. isReady(): boolean;
  34211. private _soundLoaded;
  34212. /**
  34213. * Sets the data of the sound from an audiobuffer
  34214. * @param audioBuffer The audioBuffer containing the data
  34215. */
  34216. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34217. /**
  34218. * Updates the current sounds options such as maxdistance, loop...
  34219. * @param options A JSON object containing values named as the object properties
  34220. */
  34221. updateOptions(options: any): void;
  34222. private _createSpatialParameters;
  34223. private _updateSpatialParameters;
  34224. /**
  34225. * Switch the panning model to HRTF:
  34226. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34228. */
  34229. switchPanningModelToHRTF(): void;
  34230. /**
  34231. * Switch the panning model to Equal Power:
  34232. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34234. */
  34235. switchPanningModelToEqualPower(): void;
  34236. private _switchPanningModel;
  34237. /**
  34238. * Connect this sound to a sound track audio node like gain...
  34239. * @param soundTrackAudioNode the sound track audio node to connect to
  34240. */
  34241. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34242. /**
  34243. * Transform this sound into a directional source
  34244. * @param coneInnerAngle Size of the inner cone in degree
  34245. * @param coneOuterAngle Size of the outer cone in degree
  34246. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34247. */
  34248. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34249. /**
  34250. * Gets or sets the inner angle for the directional cone.
  34251. */
  34252. /**
  34253. * Gets or sets the inner angle for the directional cone.
  34254. */
  34255. directionalConeInnerAngle: number;
  34256. /**
  34257. * Gets or sets the outer angle for the directional cone.
  34258. */
  34259. /**
  34260. * Gets or sets the outer angle for the directional cone.
  34261. */
  34262. directionalConeOuterAngle: number;
  34263. /**
  34264. * Sets the position of the emitter if spatial sound is enabled
  34265. * @param newPosition Defines the new posisiton
  34266. */
  34267. setPosition(newPosition: Vector3): void;
  34268. /**
  34269. * Sets the local direction of the emitter if spatial sound is enabled
  34270. * @param newLocalDirection Defines the new local direction
  34271. */
  34272. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34273. private _updateDirection;
  34274. /** @hidden */
  34275. updateDistanceFromListener(): void;
  34276. /**
  34277. * Sets a new custom attenuation function for the sound.
  34278. * @param callback Defines the function used for the attenuation
  34279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34280. */
  34281. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34282. /**
  34283. * Play the sound
  34284. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34285. * @param offset (optional) Start the sound setting it at a specific time
  34286. */
  34287. play(time?: number, offset?: number): void;
  34288. private _onended;
  34289. /**
  34290. * Stop the sound
  34291. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34292. */
  34293. stop(time?: number): void;
  34294. /**
  34295. * Put the sound in pause
  34296. */
  34297. pause(): void;
  34298. /**
  34299. * Sets a dedicated volume for this sounds
  34300. * @param newVolume Define the new volume of the sound
  34301. * @param time Define in how long the sound should be at this value
  34302. */
  34303. setVolume(newVolume: number, time?: number): void;
  34304. /**
  34305. * Set the sound play back rate
  34306. * @param newPlaybackRate Define the playback rate the sound should be played at
  34307. */
  34308. setPlaybackRate(newPlaybackRate: number): void;
  34309. /**
  34310. * Gets the volume of the sound.
  34311. * @returns the volume of the sound
  34312. */
  34313. getVolume(): number;
  34314. /**
  34315. * Attach the sound to a dedicated mesh
  34316. * @param transformNode The transform node to connect the sound with
  34317. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34318. */
  34319. attachToMesh(transformNode: TransformNode): void;
  34320. /**
  34321. * Detach the sound from the previously attached mesh
  34322. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34323. */
  34324. detachFromMesh(): void;
  34325. private _onRegisterAfterWorldMatrixUpdate;
  34326. /**
  34327. * Clone the current sound in the scene.
  34328. * @returns the new sound clone
  34329. */
  34330. clone(): Nullable<Sound>;
  34331. /**
  34332. * Gets the current underlying audio buffer containing the data
  34333. * @returns the audio buffer
  34334. */
  34335. getAudioBuffer(): Nullable<AudioBuffer>;
  34336. /**
  34337. * Serializes the Sound in a JSON representation
  34338. * @returns the JSON representation of the sound
  34339. */
  34340. serialize(): any;
  34341. /**
  34342. * Parse a JSON representation of a sound to innstantiate in a given scene
  34343. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34344. * @param scene Define the scene the new parsed sound should be created in
  34345. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34346. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34347. * @returns the newly parsed sound
  34348. */
  34349. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34350. }
  34351. }
  34352. declare module BABYLON {
  34353. /**
  34354. * This defines an action helpful to play a defined sound on a triggered action.
  34355. */
  34356. export class PlaySoundAction extends Action {
  34357. private _sound;
  34358. /**
  34359. * Instantiate the action
  34360. * @param triggerOptions defines the trigger options
  34361. * @param sound defines the sound to play
  34362. * @param condition defines the trigger related conditions
  34363. */
  34364. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34365. /** @hidden */
  34366. _prepare(): void;
  34367. /**
  34368. * Execute the action and play the sound.
  34369. */
  34370. execute(): void;
  34371. /**
  34372. * Serializes the actions and its related information.
  34373. * @param parent defines the object to serialize in
  34374. * @returns the serialized object
  34375. */
  34376. serialize(parent: any): any;
  34377. }
  34378. /**
  34379. * This defines an action helpful to stop a defined sound on a triggered action.
  34380. */
  34381. export class StopSoundAction extends Action {
  34382. private _sound;
  34383. /**
  34384. * Instantiate the action
  34385. * @param triggerOptions defines the trigger options
  34386. * @param sound defines the sound to stop
  34387. * @param condition defines the trigger related conditions
  34388. */
  34389. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34390. /** @hidden */
  34391. _prepare(): void;
  34392. /**
  34393. * Execute the action and stop the sound.
  34394. */
  34395. execute(): void;
  34396. /**
  34397. * Serializes the actions and its related information.
  34398. * @param parent defines the object to serialize in
  34399. * @returns the serialized object
  34400. */
  34401. serialize(parent: any): any;
  34402. }
  34403. }
  34404. declare module BABYLON {
  34405. /**
  34406. * This defines an action responsible to change the value of a property
  34407. * by interpolating between its current value and the newly set one once triggered.
  34408. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34409. */
  34410. export class InterpolateValueAction extends Action {
  34411. /**
  34412. * Defines the path of the property where the value should be interpolated
  34413. */
  34414. propertyPath: string;
  34415. /**
  34416. * Defines the target value at the end of the interpolation.
  34417. */
  34418. value: any;
  34419. /**
  34420. * Defines the time it will take for the property to interpolate to the value.
  34421. */
  34422. duration: number;
  34423. /**
  34424. * Defines if the other scene animations should be stopped when the action has been triggered
  34425. */
  34426. stopOtherAnimations?: boolean;
  34427. /**
  34428. * Defines a callback raised once the interpolation animation has been done.
  34429. */
  34430. onInterpolationDone?: () => void;
  34431. /**
  34432. * Observable triggered once the interpolation animation has been done.
  34433. */
  34434. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34435. private _target;
  34436. private _effectiveTarget;
  34437. private _property;
  34438. /**
  34439. * Instantiate the action
  34440. * @param triggerOptions defines the trigger options
  34441. * @param target defines the object containing the value to interpolate
  34442. * @param propertyPath defines the path to the property in the target object
  34443. * @param value defines the target value at the end of the interpolation
  34444. * @param duration deines the time it will take for the property to interpolate to the value.
  34445. * @param condition defines the trigger related conditions
  34446. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34447. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34448. */
  34449. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34450. /** @hidden */
  34451. _prepare(): void;
  34452. /**
  34453. * Execute the action starts the value interpolation.
  34454. */
  34455. execute(): void;
  34456. /**
  34457. * Serializes the actions and its related information.
  34458. * @param parent defines the object to serialize in
  34459. * @returns the serialized object
  34460. */
  34461. serialize(parent: any): any;
  34462. }
  34463. }
  34464. declare module BABYLON {
  34465. /**
  34466. * Options allowed during the creation of a sound track.
  34467. */
  34468. export interface ISoundTrackOptions {
  34469. /**
  34470. * The volume the sound track should take during creation
  34471. */
  34472. volume?: number;
  34473. /**
  34474. * Define if the sound track is the main sound track of the scene
  34475. */
  34476. mainTrack?: boolean;
  34477. }
  34478. /**
  34479. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34480. * It will be also used in a future release to apply effects on a specific track.
  34481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34482. */
  34483. export class SoundTrack {
  34484. /**
  34485. * The unique identifier of the sound track in the scene.
  34486. */
  34487. id: number;
  34488. /**
  34489. * The list of sounds included in the sound track.
  34490. */
  34491. soundCollection: Array<Sound>;
  34492. private _outputAudioNode;
  34493. private _scene;
  34494. private _isMainTrack;
  34495. private _connectedAnalyser;
  34496. private _options;
  34497. private _isInitialized;
  34498. /**
  34499. * Creates a new sound track.
  34500. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34501. * @param scene Define the scene the sound track belongs to
  34502. * @param options
  34503. */
  34504. constructor(scene: Scene, options?: ISoundTrackOptions);
  34505. private _initializeSoundTrackAudioGraph;
  34506. /**
  34507. * Release the sound track and its associated resources
  34508. */
  34509. dispose(): void;
  34510. /**
  34511. * Adds a sound to this sound track
  34512. * @param sound define the cound to add
  34513. * @ignoreNaming
  34514. */
  34515. AddSound(sound: Sound): void;
  34516. /**
  34517. * Removes a sound to this sound track
  34518. * @param sound define the cound to remove
  34519. * @ignoreNaming
  34520. */
  34521. RemoveSound(sound: Sound): void;
  34522. /**
  34523. * Set a global volume for the full sound track.
  34524. * @param newVolume Define the new volume of the sound track
  34525. */
  34526. setVolume(newVolume: number): void;
  34527. /**
  34528. * Switch the panning model to HRTF:
  34529. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34531. */
  34532. switchPanningModelToHRTF(): void;
  34533. /**
  34534. * Switch the panning model to Equal Power:
  34535. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34537. */
  34538. switchPanningModelToEqualPower(): void;
  34539. /**
  34540. * Connect the sound track to an audio analyser allowing some amazing
  34541. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34543. * @param analyser The analyser to connect to the engine
  34544. */
  34545. connectToAnalyser(analyser: Analyser): void;
  34546. }
  34547. }
  34548. declare module BABYLON {
  34549. interface AbstractScene {
  34550. /**
  34551. * The list of sounds used in the scene.
  34552. */
  34553. sounds: Nullable<Array<Sound>>;
  34554. }
  34555. interface Scene {
  34556. /**
  34557. * @hidden
  34558. * Backing field
  34559. */
  34560. _mainSoundTrack: SoundTrack;
  34561. /**
  34562. * The main sound track played by the scene.
  34563. * It cotains your primary collection of sounds.
  34564. */
  34565. mainSoundTrack: SoundTrack;
  34566. /**
  34567. * The list of sound tracks added to the scene
  34568. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34569. */
  34570. soundTracks: Nullable<Array<SoundTrack>>;
  34571. /**
  34572. * Gets a sound using a given name
  34573. * @param name defines the name to search for
  34574. * @return the found sound or null if not found at all.
  34575. */
  34576. getSoundByName(name: string): Nullable<Sound>;
  34577. /**
  34578. * Gets or sets if audio support is enabled
  34579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34580. */
  34581. audioEnabled: boolean;
  34582. /**
  34583. * Gets or sets if audio will be output to headphones
  34584. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34585. */
  34586. headphone: boolean;
  34587. }
  34588. /**
  34589. * Defines the sound scene component responsible to manage any sounds
  34590. * in a given scene.
  34591. */
  34592. export class AudioSceneComponent implements ISceneSerializableComponent {
  34593. /**
  34594. * The component name helpfull to identify the component in the list of scene components.
  34595. */
  34596. readonly name: string;
  34597. /**
  34598. * The scene the component belongs to.
  34599. */
  34600. scene: Scene;
  34601. private _audioEnabled;
  34602. /**
  34603. * Gets whether audio is enabled or not.
  34604. * Please use related enable/disable method to switch state.
  34605. */
  34606. readonly audioEnabled: boolean;
  34607. private _headphone;
  34608. /**
  34609. * Gets whether audio is outputing to headphone or not.
  34610. * Please use the according Switch methods to change output.
  34611. */
  34612. readonly headphone: boolean;
  34613. /**
  34614. * Creates a new instance of the component for the given scene
  34615. * @param scene Defines the scene to register the component in
  34616. */
  34617. constructor(scene: Scene);
  34618. /**
  34619. * Registers the component in a given scene
  34620. */
  34621. register(): void;
  34622. /**
  34623. * Rebuilds the elements related to this component in case of
  34624. * context lost for instance.
  34625. */
  34626. rebuild(): void;
  34627. /**
  34628. * Serializes the component data to the specified json object
  34629. * @param serializationObject The object to serialize to
  34630. */
  34631. serialize(serializationObject: any): void;
  34632. /**
  34633. * Adds all the elements from the container to the scene
  34634. * @param container the container holding the elements
  34635. */
  34636. addFromContainer(container: AbstractScene): void;
  34637. /**
  34638. * Removes all the elements in the container from the scene
  34639. * @param container contains the elements to remove
  34640. * @param dispose if the removed element should be disposed (default: false)
  34641. */
  34642. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34643. /**
  34644. * Disposes the component and the associated ressources.
  34645. */
  34646. dispose(): void;
  34647. /**
  34648. * Disables audio in the associated scene.
  34649. */
  34650. disableAudio(): void;
  34651. /**
  34652. * Enables audio in the associated scene.
  34653. */
  34654. enableAudio(): void;
  34655. /**
  34656. * Switch audio to headphone output.
  34657. */
  34658. switchAudioModeForHeadphones(): void;
  34659. /**
  34660. * Switch audio to normal speakers.
  34661. */
  34662. switchAudioModeForNormalSpeakers(): void;
  34663. private _afterRender;
  34664. }
  34665. }
  34666. declare module BABYLON {
  34667. /**
  34668. * Wraps one or more Sound objects and selects one with random weight for playback.
  34669. */
  34670. export class WeightedSound {
  34671. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34672. loop: boolean;
  34673. private _coneInnerAngle;
  34674. private _coneOuterAngle;
  34675. private _volume;
  34676. /** A Sound is currently playing. */
  34677. isPlaying: boolean;
  34678. /** A Sound is currently paused. */
  34679. isPaused: boolean;
  34680. private _sounds;
  34681. private _weights;
  34682. private _currentIndex?;
  34683. /**
  34684. * Creates a new WeightedSound from the list of sounds given.
  34685. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34686. * @param sounds Array of Sounds that will be selected from.
  34687. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34688. */
  34689. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34690. /**
  34691. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34692. */
  34693. /**
  34694. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34695. */
  34696. directionalConeInnerAngle: number;
  34697. /**
  34698. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34699. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34700. */
  34701. /**
  34702. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34703. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34704. */
  34705. directionalConeOuterAngle: number;
  34706. /**
  34707. * Playback volume.
  34708. */
  34709. /**
  34710. * Playback volume.
  34711. */
  34712. volume: number;
  34713. private _onended;
  34714. /**
  34715. * Suspend playback
  34716. */
  34717. pause(): void;
  34718. /**
  34719. * Stop playback
  34720. */
  34721. stop(): void;
  34722. /**
  34723. * Start playback.
  34724. * @param startOffset Position the clip head at a specific time in seconds.
  34725. */
  34726. play(startOffset?: number): void;
  34727. }
  34728. }
  34729. declare module BABYLON {
  34730. /**
  34731. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34732. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34733. */
  34734. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34735. /**
  34736. * Gets the name of the behavior.
  34737. */
  34738. readonly name: string;
  34739. /**
  34740. * The easing function used by animations
  34741. */
  34742. static EasingFunction: BackEase;
  34743. /**
  34744. * The easing mode used by animations
  34745. */
  34746. static EasingMode: number;
  34747. /**
  34748. * The duration of the animation, in milliseconds
  34749. */
  34750. transitionDuration: number;
  34751. /**
  34752. * Length of the distance animated by the transition when lower radius is reached
  34753. */
  34754. lowerRadiusTransitionRange: number;
  34755. /**
  34756. * Length of the distance animated by the transition when upper radius is reached
  34757. */
  34758. upperRadiusTransitionRange: number;
  34759. private _autoTransitionRange;
  34760. /**
  34761. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34762. */
  34763. /**
  34764. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34765. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34766. */
  34767. autoTransitionRange: boolean;
  34768. private _attachedCamera;
  34769. private _onAfterCheckInputsObserver;
  34770. private _onMeshTargetChangedObserver;
  34771. /**
  34772. * Initializes the behavior.
  34773. */
  34774. init(): void;
  34775. /**
  34776. * Attaches the behavior to its arc rotate camera.
  34777. * @param camera Defines the camera to attach the behavior to
  34778. */
  34779. attach(camera: ArcRotateCamera): void;
  34780. /**
  34781. * Detaches the behavior from its current arc rotate camera.
  34782. */
  34783. detach(): void;
  34784. private _radiusIsAnimating;
  34785. private _radiusBounceTransition;
  34786. private _animatables;
  34787. private _cachedWheelPrecision;
  34788. /**
  34789. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34790. * @param radiusLimit The limit to check against.
  34791. * @return Bool to indicate if at limit.
  34792. */
  34793. private _isRadiusAtLimit;
  34794. /**
  34795. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34796. * @param radiusDelta The delta by which to animate to. Can be negative.
  34797. */
  34798. private _applyBoundRadiusAnimation;
  34799. /**
  34800. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34801. */
  34802. protected _clearAnimationLocks(): void;
  34803. /**
  34804. * Stops and removes all animations that have been applied to the camera
  34805. */
  34806. stopAllAnimations(): void;
  34807. }
  34808. }
  34809. declare module BABYLON {
  34810. /**
  34811. * 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.
  34812. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34813. */
  34814. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34815. /**
  34816. * Gets the name of the behavior.
  34817. */
  34818. readonly name: string;
  34819. private _mode;
  34820. private _radiusScale;
  34821. private _positionScale;
  34822. private _defaultElevation;
  34823. private _elevationReturnTime;
  34824. private _elevationReturnWaitTime;
  34825. private _zoomStopsAnimation;
  34826. private _framingTime;
  34827. /**
  34828. * The easing function used by animations
  34829. */
  34830. static EasingFunction: ExponentialEase;
  34831. /**
  34832. * The easing mode used by animations
  34833. */
  34834. static EasingMode: number;
  34835. /**
  34836. * Sets the current mode used by the behavior
  34837. */
  34838. /**
  34839. * Gets current mode used by the behavior.
  34840. */
  34841. mode: number;
  34842. /**
  34843. * Sets the scale applied to the radius (1 by default)
  34844. */
  34845. /**
  34846. * Gets the scale applied to the radius
  34847. */
  34848. radiusScale: number;
  34849. /**
  34850. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34851. */
  34852. /**
  34853. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34854. */
  34855. positionScale: number;
  34856. /**
  34857. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34858. * behaviour is triggered, in radians.
  34859. */
  34860. /**
  34861. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34862. * behaviour is triggered, in radians.
  34863. */
  34864. defaultElevation: number;
  34865. /**
  34866. * Sets the time (in milliseconds) taken to return to the default beta position.
  34867. * Negative value indicates camera should not return to default.
  34868. */
  34869. /**
  34870. * Gets the time (in milliseconds) taken to return to the default beta position.
  34871. * Negative value indicates camera should not return to default.
  34872. */
  34873. elevationReturnTime: number;
  34874. /**
  34875. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34876. */
  34877. /**
  34878. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34879. */
  34880. elevationReturnWaitTime: number;
  34881. /**
  34882. * Sets the flag that indicates if user zooming should stop animation.
  34883. */
  34884. /**
  34885. * Gets the flag that indicates if user zooming should stop animation.
  34886. */
  34887. zoomStopsAnimation: boolean;
  34888. /**
  34889. * Sets the transition time when framing the mesh, in milliseconds
  34890. */
  34891. /**
  34892. * Gets the transition time when framing the mesh, in milliseconds
  34893. */
  34894. framingTime: number;
  34895. /**
  34896. * Define if the behavior should automatically change the configured
  34897. * camera limits and sensibilities.
  34898. */
  34899. autoCorrectCameraLimitsAndSensibility: boolean;
  34900. private _onPrePointerObservableObserver;
  34901. private _onAfterCheckInputsObserver;
  34902. private _onMeshTargetChangedObserver;
  34903. private _attachedCamera;
  34904. private _isPointerDown;
  34905. private _lastInteractionTime;
  34906. /**
  34907. * Initializes the behavior.
  34908. */
  34909. init(): void;
  34910. /**
  34911. * Attaches the behavior to its arc rotate camera.
  34912. * @param camera Defines the camera to attach the behavior to
  34913. */
  34914. attach(camera: ArcRotateCamera): void;
  34915. /**
  34916. * Detaches the behavior from its current arc rotate camera.
  34917. */
  34918. detach(): void;
  34919. private _animatables;
  34920. private _betaIsAnimating;
  34921. private _betaTransition;
  34922. private _radiusTransition;
  34923. private _vectorTransition;
  34924. /**
  34925. * Targets the given mesh and updates zoom level accordingly.
  34926. * @param mesh The mesh to target.
  34927. * @param radius Optional. If a cached radius position already exists, overrides default.
  34928. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34929. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34930. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34931. */
  34932. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34933. /**
  34934. * Targets the given mesh with its children and updates zoom level accordingly.
  34935. * @param mesh The mesh to target.
  34936. * @param radius Optional. If a cached radius position already exists, overrides default.
  34937. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34938. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34939. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34940. */
  34941. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34942. /**
  34943. * Targets the given meshes with their children and updates zoom level accordingly.
  34944. * @param meshes The mesh to target.
  34945. * @param radius Optional. If a cached radius position already exists, overrides default.
  34946. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34947. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34948. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34949. */
  34950. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34951. /**
  34952. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34953. * @param minimumWorld Determines the smaller position of the bounding box extend
  34954. * @param maximumWorld Determines the bigger position of the bounding box extend
  34955. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34956. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34957. */
  34958. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34959. /**
  34960. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34961. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34962. * frustum width.
  34963. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34964. * to fully enclose the mesh in the viewing frustum.
  34965. */
  34966. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34967. /**
  34968. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34969. * is automatically returned to its default position (expected to be above ground plane).
  34970. */
  34971. private _maintainCameraAboveGround;
  34972. /**
  34973. * Returns the frustum slope based on the canvas ratio and camera FOV
  34974. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34975. */
  34976. private _getFrustumSlope;
  34977. /**
  34978. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34979. */
  34980. private _clearAnimationLocks;
  34981. /**
  34982. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34983. */
  34984. private _applyUserInteraction;
  34985. /**
  34986. * Stops and removes all animations that have been applied to the camera
  34987. */
  34988. stopAllAnimations(): void;
  34989. /**
  34990. * Gets a value indicating if the user is moving the camera
  34991. */
  34992. readonly isUserIsMoving: boolean;
  34993. /**
  34994. * The camera can move all the way towards the mesh.
  34995. */
  34996. static IgnoreBoundsSizeMode: number;
  34997. /**
  34998. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34999. */
  35000. static FitFrustumSidesMode: number;
  35001. }
  35002. }
  35003. declare module BABYLON {
  35004. /**
  35005. * Base class for Camera Pointer Inputs.
  35006. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35007. * for example usage.
  35008. */
  35009. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35010. /**
  35011. * Defines the camera the input is attached to.
  35012. */
  35013. abstract camera: Camera;
  35014. /**
  35015. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35016. */
  35017. protected _altKey: boolean;
  35018. protected _ctrlKey: boolean;
  35019. protected _metaKey: boolean;
  35020. protected _shiftKey: boolean;
  35021. /**
  35022. * Which mouse buttons were pressed at time of last mouse event.
  35023. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35024. */
  35025. protected _buttonsPressed: number;
  35026. /**
  35027. * Defines the buttons associated with the input to handle camera move.
  35028. */
  35029. buttons: number[];
  35030. /**
  35031. * Attach the input controls to a specific dom element to get the input from.
  35032. * @param element Defines the element the controls should be listened from
  35033. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35034. */
  35035. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35036. /**
  35037. * Detach the current controls from the specified dom element.
  35038. * @param element Defines the element to stop listening the inputs from
  35039. */
  35040. detachControl(element: Nullable<HTMLElement>): void;
  35041. /**
  35042. * Gets the class name of the current input.
  35043. * @returns the class name
  35044. */
  35045. getClassName(): string;
  35046. /**
  35047. * Get the friendly name associated with the input class.
  35048. * @returns the input friendly name
  35049. */
  35050. getSimpleName(): string;
  35051. /**
  35052. * Called on pointer POINTERDOUBLETAP event.
  35053. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35054. */
  35055. protected onDoubleTap(type: string): void;
  35056. /**
  35057. * Called on pointer POINTERMOVE event if only a single touch is active.
  35058. * Override this method to provide functionality.
  35059. */
  35060. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35061. /**
  35062. * Called on pointer POINTERMOVE event if multiple touches are active.
  35063. * Override this method to provide functionality.
  35064. */
  35065. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35066. /**
  35067. * Called on JS contextmenu event.
  35068. * Override this method to provide functionality.
  35069. */
  35070. protected onContextMenu(evt: PointerEvent): void;
  35071. /**
  35072. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35073. * press.
  35074. * Override this method to provide functionality.
  35075. */
  35076. protected onButtonDown(evt: PointerEvent): void;
  35077. /**
  35078. * Called each time a new POINTERUP event occurs. Ie, for each button
  35079. * release.
  35080. * Override this method to provide functionality.
  35081. */
  35082. protected onButtonUp(evt: PointerEvent): void;
  35083. /**
  35084. * Called when window becomes inactive.
  35085. * Override this method to provide functionality.
  35086. */
  35087. protected onLostFocus(): void;
  35088. private _pointerInput;
  35089. private _observer;
  35090. private _onLostFocus;
  35091. private pointA;
  35092. private pointB;
  35093. }
  35094. }
  35095. declare module BABYLON {
  35096. /**
  35097. * Manage the pointers inputs to control an arc rotate camera.
  35098. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35099. */
  35100. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35101. /**
  35102. * Defines the camera the input is attached to.
  35103. */
  35104. camera: ArcRotateCamera;
  35105. /**
  35106. * Gets the class name of the current input.
  35107. * @returns the class name
  35108. */
  35109. getClassName(): string;
  35110. /**
  35111. * Defines the buttons associated with the input to handle camera move.
  35112. */
  35113. buttons: number[];
  35114. /**
  35115. * Defines the pointer angular sensibility along the X axis or how fast is
  35116. * the camera rotating.
  35117. */
  35118. angularSensibilityX: number;
  35119. /**
  35120. * Defines the pointer angular sensibility along the Y axis or how fast is
  35121. * the camera rotating.
  35122. */
  35123. angularSensibilityY: number;
  35124. /**
  35125. * Defines the pointer pinch precision or how fast is the camera zooming.
  35126. */
  35127. pinchPrecision: number;
  35128. /**
  35129. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35130. * from 0.
  35131. * It defines the percentage of current camera.radius to use as delta when
  35132. * pinch zoom is used.
  35133. */
  35134. pinchDeltaPercentage: number;
  35135. /**
  35136. * Defines the pointer panning sensibility or how fast is the camera moving.
  35137. */
  35138. panningSensibility: number;
  35139. /**
  35140. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35141. */
  35142. multiTouchPanning: boolean;
  35143. /**
  35144. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35145. * zoom (pinch) through multitouch.
  35146. */
  35147. multiTouchPanAndZoom: boolean;
  35148. /**
  35149. * Revers pinch action direction.
  35150. */
  35151. pinchInwards: boolean;
  35152. private _isPanClick;
  35153. private _twoFingerActivityCount;
  35154. private _isPinching;
  35155. /**
  35156. * Called on pointer POINTERMOVE event if only a single touch is active.
  35157. */
  35158. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35159. /**
  35160. * Called on pointer POINTERDOUBLETAP event.
  35161. */
  35162. protected onDoubleTap(type: string): void;
  35163. /**
  35164. * Called on pointer POINTERMOVE event if multiple touches are active.
  35165. */
  35166. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35167. /**
  35168. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35169. * press.
  35170. */
  35171. protected onButtonDown(evt: PointerEvent): void;
  35172. /**
  35173. * Called each time a new POINTERUP event occurs. Ie, for each button
  35174. * release.
  35175. */
  35176. protected onButtonUp(evt: PointerEvent): void;
  35177. /**
  35178. * Called when window becomes inactive.
  35179. */
  35180. protected onLostFocus(): void;
  35181. }
  35182. }
  35183. declare module BABYLON {
  35184. /**
  35185. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35187. */
  35188. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35189. /**
  35190. * Defines the camera the input is attached to.
  35191. */
  35192. camera: ArcRotateCamera;
  35193. /**
  35194. * Defines the list of key codes associated with the up action (increase alpha)
  35195. */
  35196. keysUp: number[];
  35197. /**
  35198. * Defines the list of key codes associated with the down action (decrease alpha)
  35199. */
  35200. keysDown: number[];
  35201. /**
  35202. * Defines the list of key codes associated with the left action (increase beta)
  35203. */
  35204. keysLeft: number[];
  35205. /**
  35206. * Defines the list of key codes associated with the right action (decrease beta)
  35207. */
  35208. keysRight: number[];
  35209. /**
  35210. * Defines the list of key codes associated with the reset action.
  35211. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35212. */
  35213. keysReset: number[];
  35214. /**
  35215. * Defines the panning sensibility of the inputs.
  35216. * (How fast is the camera paning)
  35217. */
  35218. panningSensibility: number;
  35219. /**
  35220. * Defines the zooming sensibility of the inputs.
  35221. * (How fast is the camera zooming)
  35222. */
  35223. zoomingSensibility: number;
  35224. /**
  35225. * Defines wether maintaining the alt key down switch the movement mode from
  35226. * orientation to zoom.
  35227. */
  35228. useAltToZoom: boolean;
  35229. /**
  35230. * Rotation speed of the camera
  35231. */
  35232. angularSpeed: number;
  35233. private _keys;
  35234. private _ctrlPressed;
  35235. private _altPressed;
  35236. private _onCanvasBlurObserver;
  35237. private _onKeyboardObserver;
  35238. private _engine;
  35239. private _scene;
  35240. /**
  35241. * Attach the input controls to a specific dom element to get the input from.
  35242. * @param element Defines the element the controls should be listened from
  35243. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35244. */
  35245. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35246. /**
  35247. * Detach the current controls from the specified dom element.
  35248. * @param element Defines the element to stop listening the inputs from
  35249. */
  35250. detachControl(element: Nullable<HTMLElement>): void;
  35251. /**
  35252. * Update the current camera state depending on the inputs that have been used this frame.
  35253. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35254. */
  35255. checkInputs(): void;
  35256. /**
  35257. * Gets the class name of the current intput.
  35258. * @returns the class name
  35259. */
  35260. getClassName(): string;
  35261. /**
  35262. * Get the friendly name associated with the input class.
  35263. * @returns the input friendly name
  35264. */
  35265. getSimpleName(): string;
  35266. }
  35267. }
  35268. declare module BABYLON {
  35269. /**
  35270. * Manage the mouse wheel inputs to control an arc rotate camera.
  35271. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35272. */
  35273. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35274. /**
  35275. * Defines the camera the input is attached to.
  35276. */
  35277. camera: ArcRotateCamera;
  35278. /**
  35279. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35280. */
  35281. wheelPrecision: number;
  35282. /**
  35283. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35284. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35285. */
  35286. wheelDeltaPercentage: number;
  35287. private _wheel;
  35288. private _observer;
  35289. private computeDeltaFromMouseWheelLegacyEvent;
  35290. /**
  35291. * Attach the input controls to a specific dom element to get the input from.
  35292. * @param element Defines the element the controls should be listened from
  35293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35294. */
  35295. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35296. /**
  35297. * Detach the current controls from the specified dom element.
  35298. * @param element Defines the element to stop listening the inputs from
  35299. */
  35300. detachControl(element: Nullable<HTMLElement>): void;
  35301. /**
  35302. * Gets the class name of the current intput.
  35303. * @returns the class name
  35304. */
  35305. getClassName(): string;
  35306. /**
  35307. * Get the friendly name associated with the input class.
  35308. * @returns the input friendly name
  35309. */
  35310. getSimpleName(): string;
  35311. }
  35312. }
  35313. declare module BABYLON {
  35314. /**
  35315. * Default Inputs manager for the ArcRotateCamera.
  35316. * It groups all the default supported inputs for ease of use.
  35317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35318. */
  35319. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35320. /**
  35321. * Instantiates a new ArcRotateCameraInputsManager.
  35322. * @param camera Defines the camera the inputs belong to
  35323. */
  35324. constructor(camera: ArcRotateCamera);
  35325. /**
  35326. * Add mouse wheel input support to the input manager.
  35327. * @returns the current input manager
  35328. */
  35329. addMouseWheel(): ArcRotateCameraInputsManager;
  35330. /**
  35331. * Add pointers input support to the input manager.
  35332. * @returns the current input manager
  35333. */
  35334. addPointers(): ArcRotateCameraInputsManager;
  35335. /**
  35336. * Add keyboard input support to the input manager.
  35337. * @returns the current input manager
  35338. */
  35339. addKeyboard(): ArcRotateCameraInputsManager;
  35340. }
  35341. }
  35342. declare module BABYLON {
  35343. /**
  35344. * This represents an orbital type of camera.
  35345. *
  35346. * 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.
  35347. * 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.
  35348. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35349. */
  35350. export class ArcRotateCamera extends TargetCamera {
  35351. /**
  35352. * Defines the rotation angle of the camera along the longitudinal axis.
  35353. */
  35354. alpha: number;
  35355. /**
  35356. * Defines the rotation angle of the camera along the latitudinal axis.
  35357. */
  35358. beta: number;
  35359. /**
  35360. * Defines the radius of the camera from it s target point.
  35361. */
  35362. radius: number;
  35363. protected _target: Vector3;
  35364. protected _targetHost: Nullable<AbstractMesh>;
  35365. /**
  35366. * Defines the target point of the camera.
  35367. * The camera looks towards it form the radius distance.
  35368. */
  35369. target: Vector3;
  35370. /**
  35371. * Define the current local position of the camera in the scene
  35372. */
  35373. position: Vector3;
  35374. protected _upVector: Vector3;
  35375. protected _upToYMatrix: Matrix;
  35376. protected _YToUpMatrix: Matrix;
  35377. /**
  35378. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35379. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35380. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35381. */
  35382. upVector: Vector3;
  35383. /**
  35384. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35385. */
  35386. setMatUp(): void;
  35387. /**
  35388. * Current inertia value on the longitudinal axis.
  35389. * The bigger this number the longer it will take for the camera to stop.
  35390. */
  35391. inertialAlphaOffset: number;
  35392. /**
  35393. * Current inertia value on the latitudinal axis.
  35394. * The bigger this number the longer it will take for the camera to stop.
  35395. */
  35396. inertialBetaOffset: number;
  35397. /**
  35398. * Current inertia value on the radius axis.
  35399. * The bigger this number the longer it will take for the camera to stop.
  35400. */
  35401. inertialRadiusOffset: number;
  35402. /**
  35403. * Minimum allowed angle on the longitudinal axis.
  35404. * This can help limiting how the Camera is able to move in the scene.
  35405. */
  35406. lowerAlphaLimit: Nullable<number>;
  35407. /**
  35408. * Maximum allowed angle on the longitudinal axis.
  35409. * This can help limiting how the Camera is able to move in the scene.
  35410. */
  35411. upperAlphaLimit: Nullable<number>;
  35412. /**
  35413. * Minimum allowed angle on the latitudinal axis.
  35414. * This can help limiting how the Camera is able to move in the scene.
  35415. */
  35416. lowerBetaLimit: number;
  35417. /**
  35418. * Maximum allowed angle on the latitudinal axis.
  35419. * This can help limiting how the Camera is able to move in the scene.
  35420. */
  35421. upperBetaLimit: number;
  35422. /**
  35423. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35424. * This can help limiting how the Camera is able to move in the scene.
  35425. */
  35426. lowerRadiusLimit: Nullable<number>;
  35427. /**
  35428. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35429. * This can help limiting how the Camera is able to move in the scene.
  35430. */
  35431. upperRadiusLimit: Nullable<number>;
  35432. /**
  35433. * Defines the current inertia value used during panning of the camera along the X axis.
  35434. */
  35435. inertialPanningX: number;
  35436. /**
  35437. * Defines the current inertia value used during panning of the camera along the Y axis.
  35438. */
  35439. inertialPanningY: number;
  35440. /**
  35441. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35442. * Basically if your fingers moves away from more than this distance you will be considered
  35443. * in pinch mode.
  35444. */
  35445. pinchToPanMaxDistance: number;
  35446. /**
  35447. * Defines the maximum distance the camera can pan.
  35448. * This could help keeping the cammera always in your scene.
  35449. */
  35450. panningDistanceLimit: Nullable<number>;
  35451. /**
  35452. * Defines the target of the camera before paning.
  35453. */
  35454. panningOriginTarget: Vector3;
  35455. /**
  35456. * Defines the value of the inertia used during panning.
  35457. * 0 would mean stop inertia and one would mean no decelleration at all.
  35458. */
  35459. panningInertia: number;
  35460. /**
  35461. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35462. */
  35463. angularSensibilityX: number;
  35464. /**
  35465. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35466. */
  35467. angularSensibilityY: number;
  35468. /**
  35469. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35470. */
  35471. pinchPrecision: number;
  35472. /**
  35473. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35474. * It will be used instead of pinchDeltaPrecision if different from 0.
  35475. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35476. */
  35477. pinchDeltaPercentage: number;
  35478. /**
  35479. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35480. */
  35481. panningSensibility: number;
  35482. /**
  35483. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35484. */
  35485. keysUp: number[];
  35486. /**
  35487. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35488. */
  35489. keysDown: number[];
  35490. /**
  35491. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35492. */
  35493. keysLeft: number[];
  35494. /**
  35495. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35496. */
  35497. keysRight: number[];
  35498. /**
  35499. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35500. */
  35501. wheelPrecision: number;
  35502. /**
  35503. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35504. * It will be used instead of pinchDeltaPrecision if different from 0.
  35505. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35506. */
  35507. wheelDeltaPercentage: number;
  35508. /**
  35509. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35510. */
  35511. zoomOnFactor: number;
  35512. /**
  35513. * Defines a screen offset for the camera position.
  35514. */
  35515. targetScreenOffset: Vector2;
  35516. /**
  35517. * Allows the camera to be completely reversed.
  35518. * If false the camera can not arrive upside down.
  35519. */
  35520. allowUpsideDown: boolean;
  35521. /**
  35522. * Define if double tap/click is used to restore the previously saved state of the camera.
  35523. */
  35524. useInputToRestoreState: boolean;
  35525. /** @hidden */
  35526. _viewMatrix: Matrix;
  35527. /** @hidden */
  35528. _useCtrlForPanning: boolean;
  35529. /** @hidden */
  35530. _panningMouseButton: number;
  35531. /**
  35532. * Defines the input associated to the camera.
  35533. */
  35534. inputs: ArcRotateCameraInputsManager;
  35535. /** @hidden */
  35536. _reset: () => void;
  35537. /**
  35538. * Defines the allowed panning axis.
  35539. */
  35540. panningAxis: Vector3;
  35541. protected _localDirection: Vector3;
  35542. protected _transformedDirection: Vector3;
  35543. private _bouncingBehavior;
  35544. /**
  35545. * Gets the bouncing behavior of the camera if it has been enabled.
  35546. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35547. */
  35548. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35549. /**
  35550. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35551. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35552. */
  35553. useBouncingBehavior: boolean;
  35554. private _framingBehavior;
  35555. /**
  35556. * Gets the framing behavior of the camera if it has been enabled.
  35557. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35558. */
  35559. readonly framingBehavior: Nullable<FramingBehavior>;
  35560. /**
  35561. * Defines if the framing behavior of the camera is enabled on the camera.
  35562. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35563. */
  35564. useFramingBehavior: boolean;
  35565. private _autoRotationBehavior;
  35566. /**
  35567. * Gets the auto rotation behavior of the camera if it has been enabled.
  35568. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35569. */
  35570. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35571. /**
  35572. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35573. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35574. */
  35575. useAutoRotationBehavior: boolean;
  35576. /**
  35577. * Observable triggered when the mesh target has been changed on the camera.
  35578. */
  35579. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35580. /**
  35581. * Event raised when the camera is colliding with a mesh.
  35582. */
  35583. onCollide: (collidedMesh: AbstractMesh) => void;
  35584. /**
  35585. * Defines whether the camera should check collision with the objects oh the scene.
  35586. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35587. */
  35588. checkCollisions: boolean;
  35589. /**
  35590. * Defines the collision radius of the camera.
  35591. * This simulates a sphere around the camera.
  35592. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35593. */
  35594. collisionRadius: Vector3;
  35595. protected _collider: Collider;
  35596. protected _previousPosition: Vector3;
  35597. protected _collisionVelocity: Vector3;
  35598. protected _newPosition: Vector3;
  35599. protected _previousAlpha: number;
  35600. protected _previousBeta: number;
  35601. protected _previousRadius: number;
  35602. protected _collisionTriggered: boolean;
  35603. protected _targetBoundingCenter: Nullable<Vector3>;
  35604. private _computationVector;
  35605. /**
  35606. * Instantiates a new ArcRotateCamera in a given scene
  35607. * @param name Defines the name of the camera
  35608. * @param alpha Defines the camera rotation along the logitudinal axis
  35609. * @param beta Defines the camera rotation along the latitudinal axis
  35610. * @param radius Defines the camera distance from its target
  35611. * @param target Defines the camera target
  35612. * @param scene Defines the scene the camera belongs to
  35613. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35614. */
  35615. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35616. /** @hidden */
  35617. _initCache(): void;
  35618. /** @hidden */
  35619. _updateCache(ignoreParentClass?: boolean): void;
  35620. protected _getTargetPosition(): Vector3;
  35621. private _storedAlpha;
  35622. private _storedBeta;
  35623. private _storedRadius;
  35624. private _storedTarget;
  35625. /**
  35626. * Stores the current state of the camera (alpha, beta, radius and target)
  35627. * @returns the camera itself
  35628. */
  35629. storeState(): Camera;
  35630. /**
  35631. * @hidden
  35632. * Restored camera state. You must call storeState() first
  35633. */
  35634. _restoreStateValues(): boolean;
  35635. /** @hidden */
  35636. _isSynchronizedViewMatrix(): boolean;
  35637. /**
  35638. * Attached controls to the current camera.
  35639. * @param element Defines the element the controls should be listened from
  35640. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35641. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35642. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35643. */
  35644. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35645. /**
  35646. * Detach the current controls from the camera.
  35647. * The camera will stop reacting to inputs.
  35648. * @param element Defines the element to stop listening the inputs from
  35649. */
  35650. detachControl(element: HTMLElement): void;
  35651. /** @hidden */
  35652. _checkInputs(): void;
  35653. protected _checkLimits(): void;
  35654. /**
  35655. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35656. */
  35657. rebuildAnglesAndRadius(): void;
  35658. /**
  35659. * Use a position to define the current camera related information like aplha, beta and radius
  35660. * @param position Defines the position to set the camera at
  35661. */
  35662. setPosition(position: Vector3): void;
  35663. /**
  35664. * Defines the target the camera should look at.
  35665. * This will automatically adapt alpha beta and radius to fit within the new target.
  35666. * @param target Defines the new target as a Vector or a mesh
  35667. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35668. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35669. */
  35670. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35671. /** @hidden */
  35672. _getViewMatrix(): Matrix;
  35673. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35674. /**
  35675. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35676. * @param meshes Defines the mesh to zoom on
  35677. * @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)
  35678. */
  35679. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35680. /**
  35681. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35682. * The target will be changed but the radius
  35683. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35684. * @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)
  35685. */
  35686. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35687. min: Vector3;
  35688. max: Vector3;
  35689. distance: number;
  35690. }, doNotUpdateMaxZ?: boolean): void;
  35691. /**
  35692. * @override
  35693. * Override Camera.createRigCamera
  35694. */
  35695. createRigCamera(name: string, cameraIndex: number): Camera;
  35696. /**
  35697. * @hidden
  35698. * @override
  35699. * Override Camera._updateRigCameras
  35700. */
  35701. _updateRigCameras(): void;
  35702. /**
  35703. * Destroy the camera and release the current resources hold by it.
  35704. */
  35705. dispose(): void;
  35706. /**
  35707. * Gets the current object class name.
  35708. * @return the class name
  35709. */
  35710. getClassName(): string;
  35711. }
  35712. }
  35713. declare module BABYLON {
  35714. /**
  35715. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35716. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35717. */
  35718. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35719. /**
  35720. * Gets the name of the behavior.
  35721. */
  35722. readonly name: string;
  35723. private _zoomStopsAnimation;
  35724. private _idleRotationSpeed;
  35725. private _idleRotationWaitTime;
  35726. private _idleRotationSpinupTime;
  35727. /**
  35728. * Sets the flag that indicates if user zooming should stop animation.
  35729. */
  35730. /**
  35731. * Gets the flag that indicates if user zooming should stop animation.
  35732. */
  35733. zoomStopsAnimation: boolean;
  35734. /**
  35735. * Sets the default speed at which the camera rotates around the model.
  35736. */
  35737. /**
  35738. * Gets the default speed at which the camera rotates around the model.
  35739. */
  35740. idleRotationSpeed: number;
  35741. /**
  35742. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35743. */
  35744. /**
  35745. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35746. */
  35747. idleRotationWaitTime: number;
  35748. /**
  35749. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35750. */
  35751. /**
  35752. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35753. */
  35754. idleRotationSpinupTime: number;
  35755. /**
  35756. * Gets a value indicating if the camera is currently rotating because of this behavior
  35757. */
  35758. readonly rotationInProgress: boolean;
  35759. private _onPrePointerObservableObserver;
  35760. private _onAfterCheckInputsObserver;
  35761. private _attachedCamera;
  35762. private _isPointerDown;
  35763. private _lastFrameTime;
  35764. private _lastInteractionTime;
  35765. private _cameraRotationSpeed;
  35766. /**
  35767. * Initializes the behavior.
  35768. */
  35769. init(): void;
  35770. /**
  35771. * Attaches the behavior to its arc rotate camera.
  35772. * @param camera Defines the camera to attach the behavior to
  35773. */
  35774. attach(camera: ArcRotateCamera): void;
  35775. /**
  35776. * Detaches the behavior from its current arc rotate camera.
  35777. */
  35778. detach(): void;
  35779. /**
  35780. * Returns true if user is scrolling.
  35781. * @return true if user is scrolling.
  35782. */
  35783. private _userIsZooming;
  35784. private _lastFrameRadius;
  35785. private _shouldAnimationStopForInteraction;
  35786. /**
  35787. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35788. */
  35789. private _applyUserInteraction;
  35790. private _userIsMoving;
  35791. }
  35792. }
  35793. declare module BABYLON {
  35794. /**
  35795. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35796. */
  35797. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35798. private ui;
  35799. /**
  35800. * The name of the behavior
  35801. */
  35802. name: string;
  35803. /**
  35804. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35805. */
  35806. distanceAwayFromFace: number;
  35807. /**
  35808. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35809. */
  35810. distanceAwayFromBottomOfFace: number;
  35811. private _faceVectors;
  35812. private _target;
  35813. private _scene;
  35814. private _onRenderObserver;
  35815. private _tmpMatrix;
  35816. private _tmpVector;
  35817. /**
  35818. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35819. * @param ui The transform node that should be attched to the mesh
  35820. */
  35821. constructor(ui: TransformNode);
  35822. /**
  35823. * Initializes the behavior
  35824. */
  35825. init(): void;
  35826. private _closestFace;
  35827. private _zeroVector;
  35828. private _lookAtTmpMatrix;
  35829. private _lookAtToRef;
  35830. /**
  35831. * Attaches the AttachToBoxBehavior to the passed in mesh
  35832. * @param target The mesh that the specified node will be attached to
  35833. */
  35834. attach(target: Mesh): void;
  35835. /**
  35836. * Detaches the behavior from the mesh
  35837. */
  35838. detach(): void;
  35839. }
  35840. }
  35841. declare module BABYLON {
  35842. /**
  35843. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35844. */
  35845. export class FadeInOutBehavior implements Behavior<Mesh> {
  35846. /**
  35847. * Time in milliseconds to delay before fading in (Default: 0)
  35848. */
  35849. delay: number;
  35850. /**
  35851. * Time in milliseconds for the mesh to fade in (Default: 300)
  35852. */
  35853. fadeInTime: number;
  35854. private _millisecondsPerFrame;
  35855. private _hovered;
  35856. private _hoverValue;
  35857. private _ownerNode;
  35858. /**
  35859. * Instatiates the FadeInOutBehavior
  35860. */
  35861. constructor();
  35862. /**
  35863. * The name of the behavior
  35864. */
  35865. readonly name: string;
  35866. /**
  35867. * Initializes the behavior
  35868. */
  35869. init(): void;
  35870. /**
  35871. * Attaches the fade behavior on the passed in mesh
  35872. * @param ownerNode The mesh that will be faded in/out once attached
  35873. */
  35874. attach(ownerNode: Mesh): void;
  35875. /**
  35876. * Detaches the behavior from the mesh
  35877. */
  35878. detach(): void;
  35879. /**
  35880. * Triggers the mesh to begin fading in or out
  35881. * @param value if the object should fade in or out (true to fade in)
  35882. */
  35883. fadeIn(value: boolean): void;
  35884. private _update;
  35885. private _setAllVisibility;
  35886. }
  35887. }
  35888. declare module BABYLON {
  35889. /**
  35890. * Class containing a set of static utilities functions for managing Pivots
  35891. * @hidden
  35892. */
  35893. export class PivotTools {
  35894. private static _PivotCached;
  35895. private static _OldPivotPoint;
  35896. private static _PivotTranslation;
  35897. private static _PivotTmpVector;
  35898. /** @hidden */
  35899. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35900. /** @hidden */
  35901. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35902. }
  35903. }
  35904. declare module BABYLON {
  35905. /**
  35906. * Class containing static functions to help procedurally build meshes
  35907. */
  35908. export class PlaneBuilder {
  35909. /**
  35910. * Creates a plane mesh
  35911. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35912. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35913. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35915. * * 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
  35916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35917. * @param name defines the name of the mesh
  35918. * @param options defines the options used to create the mesh
  35919. * @param scene defines the hosting scene
  35920. * @returns the plane mesh
  35921. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35922. */
  35923. static CreatePlane(name: string, options: {
  35924. size?: number;
  35925. width?: number;
  35926. height?: number;
  35927. sideOrientation?: number;
  35928. frontUVs?: Vector4;
  35929. backUVs?: Vector4;
  35930. updatable?: boolean;
  35931. sourcePlane?: Plane;
  35932. }, scene?: Nullable<Scene>): Mesh;
  35933. }
  35934. }
  35935. declare module BABYLON {
  35936. /**
  35937. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35938. */
  35939. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35940. private static _AnyMouseID;
  35941. /**
  35942. * Abstract mesh the behavior is set on
  35943. */
  35944. attachedNode: AbstractMesh;
  35945. private _dragPlane;
  35946. private _scene;
  35947. private _pointerObserver;
  35948. private _beforeRenderObserver;
  35949. private static _planeScene;
  35950. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35951. /**
  35952. * 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)
  35953. */
  35954. maxDragAngle: number;
  35955. /**
  35956. * @hidden
  35957. */
  35958. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35959. /**
  35960. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35961. */
  35962. currentDraggingPointerID: number;
  35963. /**
  35964. * The last position where the pointer hit the drag plane in world space
  35965. */
  35966. lastDragPosition: Vector3;
  35967. /**
  35968. * If the behavior is currently in a dragging state
  35969. */
  35970. dragging: boolean;
  35971. /**
  35972. * 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)
  35973. */
  35974. dragDeltaRatio: number;
  35975. /**
  35976. * If the drag plane orientation should be updated during the dragging (Default: true)
  35977. */
  35978. updateDragPlane: boolean;
  35979. private _debugMode;
  35980. private _moving;
  35981. /**
  35982. * Fires each time the attached mesh is dragged with the pointer
  35983. * * delta between last drag position and current drag position in world space
  35984. * * dragDistance along the drag axis
  35985. * * dragPlaneNormal normal of the current drag plane used during the drag
  35986. * * dragPlanePoint in world space where the drag intersects the drag plane
  35987. */
  35988. onDragObservable: Observable<{
  35989. delta: Vector3;
  35990. dragPlanePoint: Vector3;
  35991. dragPlaneNormal: Vector3;
  35992. dragDistance: number;
  35993. pointerId: number;
  35994. }>;
  35995. /**
  35996. * Fires each time a drag begins (eg. mouse down on mesh)
  35997. */
  35998. onDragStartObservable: Observable<{
  35999. dragPlanePoint: Vector3;
  36000. pointerId: number;
  36001. }>;
  36002. /**
  36003. * Fires each time a drag ends (eg. mouse release after drag)
  36004. */
  36005. onDragEndObservable: Observable<{
  36006. dragPlanePoint: Vector3;
  36007. pointerId: number;
  36008. }>;
  36009. /**
  36010. * If the attached mesh should be moved when dragged
  36011. */
  36012. moveAttached: boolean;
  36013. /**
  36014. * If the drag behavior will react to drag events (Default: true)
  36015. */
  36016. enabled: boolean;
  36017. /**
  36018. * If camera controls should be detached during the drag
  36019. */
  36020. detachCameraControls: boolean;
  36021. /**
  36022. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36023. */
  36024. useObjectOrienationForDragging: boolean;
  36025. private _options;
  36026. /**
  36027. * Creates a pointer drag behavior that can be attached to a mesh
  36028. * @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)
  36029. */
  36030. constructor(options?: {
  36031. dragAxis?: Vector3;
  36032. dragPlaneNormal?: Vector3;
  36033. });
  36034. /**
  36035. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36036. */
  36037. validateDrag: (targetPosition: Vector3) => boolean;
  36038. /**
  36039. * The name of the behavior
  36040. */
  36041. readonly name: string;
  36042. /**
  36043. * Initializes the behavior
  36044. */
  36045. init(): void;
  36046. private _tmpVector;
  36047. private _alternatePickedPoint;
  36048. private _worldDragAxis;
  36049. private _targetPosition;
  36050. private _attachedElement;
  36051. /**
  36052. * Attaches the drag behavior the passed in mesh
  36053. * @param ownerNode The mesh that will be dragged around once attached
  36054. */
  36055. attach(ownerNode: AbstractMesh): void;
  36056. /**
  36057. * Force relase the drag action by code.
  36058. */
  36059. releaseDrag(): void;
  36060. private _startDragRay;
  36061. private _lastPointerRay;
  36062. /**
  36063. * Simulates the start of a pointer drag event on the behavior
  36064. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36065. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36066. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36067. */
  36068. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36069. private _startDrag;
  36070. private _dragDelta;
  36071. private _moveDrag;
  36072. private _pickWithRayOnDragPlane;
  36073. private _pointA;
  36074. private _pointB;
  36075. private _pointC;
  36076. private _lineA;
  36077. private _lineB;
  36078. private _localAxis;
  36079. private _lookAt;
  36080. private _updateDragPlanePosition;
  36081. /**
  36082. * Detaches the behavior from the mesh
  36083. */
  36084. detach(): void;
  36085. }
  36086. }
  36087. declare module BABYLON {
  36088. /**
  36089. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36090. */
  36091. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36092. private _dragBehaviorA;
  36093. private _dragBehaviorB;
  36094. private _startDistance;
  36095. private _initialScale;
  36096. private _targetScale;
  36097. private _ownerNode;
  36098. private _sceneRenderObserver;
  36099. /**
  36100. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36101. */
  36102. constructor();
  36103. /**
  36104. * The name of the behavior
  36105. */
  36106. readonly name: string;
  36107. /**
  36108. * Initializes the behavior
  36109. */
  36110. init(): void;
  36111. private _getCurrentDistance;
  36112. /**
  36113. * Attaches the scale behavior the passed in mesh
  36114. * @param ownerNode The mesh that will be scaled around once attached
  36115. */
  36116. attach(ownerNode: Mesh): void;
  36117. /**
  36118. * Detaches the behavior from the mesh
  36119. */
  36120. detach(): void;
  36121. }
  36122. }
  36123. declare module BABYLON {
  36124. /**
  36125. * 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
  36126. */
  36127. export class SixDofDragBehavior implements Behavior<Mesh> {
  36128. private static _virtualScene;
  36129. private _ownerNode;
  36130. private _sceneRenderObserver;
  36131. private _scene;
  36132. private _targetPosition;
  36133. private _virtualOriginMesh;
  36134. private _virtualDragMesh;
  36135. private _pointerObserver;
  36136. private _moving;
  36137. private _startingOrientation;
  36138. /**
  36139. * 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)
  36140. */
  36141. private zDragFactor;
  36142. /**
  36143. * If the object should rotate to face the drag origin
  36144. */
  36145. rotateDraggedObject: boolean;
  36146. /**
  36147. * If the behavior is currently in a dragging state
  36148. */
  36149. dragging: boolean;
  36150. /**
  36151. * 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)
  36152. */
  36153. dragDeltaRatio: number;
  36154. /**
  36155. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36156. */
  36157. currentDraggingPointerID: number;
  36158. /**
  36159. * If camera controls should be detached during the drag
  36160. */
  36161. detachCameraControls: boolean;
  36162. /**
  36163. * Fires each time a drag starts
  36164. */
  36165. onDragStartObservable: Observable<{}>;
  36166. /**
  36167. * Fires each time a drag ends (eg. mouse release after drag)
  36168. */
  36169. onDragEndObservable: Observable<{}>;
  36170. /**
  36171. * 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
  36172. */
  36173. constructor();
  36174. /**
  36175. * The name of the behavior
  36176. */
  36177. readonly name: string;
  36178. /**
  36179. * Initializes the behavior
  36180. */
  36181. init(): void;
  36182. /**
  36183. * Attaches the scale behavior the passed in mesh
  36184. * @param ownerNode The mesh that will be scaled around once attached
  36185. */
  36186. attach(ownerNode: Mesh): void;
  36187. /**
  36188. * Detaches the behavior from the mesh
  36189. */
  36190. detach(): void;
  36191. }
  36192. }
  36193. declare module BABYLON {
  36194. /**
  36195. * Class used to apply inverse kinematics to bones
  36196. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36197. */
  36198. export class BoneIKController {
  36199. private static _tmpVecs;
  36200. private static _tmpQuat;
  36201. private static _tmpMats;
  36202. /**
  36203. * Gets or sets the target mesh
  36204. */
  36205. targetMesh: AbstractMesh;
  36206. /** Gets or sets the mesh used as pole */
  36207. poleTargetMesh: AbstractMesh;
  36208. /**
  36209. * Gets or sets the bone used as pole
  36210. */
  36211. poleTargetBone: Nullable<Bone>;
  36212. /**
  36213. * Gets or sets the target position
  36214. */
  36215. targetPosition: Vector3;
  36216. /**
  36217. * Gets or sets the pole target position
  36218. */
  36219. poleTargetPosition: Vector3;
  36220. /**
  36221. * Gets or sets the pole target local offset
  36222. */
  36223. poleTargetLocalOffset: Vector3;
  36224. /**
  36225. * Gets or sets the pole angle
  36226. */
  36227. poleAngle: number;
  36228. /**
  36229. * Gets or sets the mesh associated with the controller
  36230. */
  36231. mesh: AbstractMesh;
  36232. /**
  36233. * 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)
  36234. */
  36235. slerpAmount: number;
  36236. private _bone1Quat;
  36237. private _bone1Mat;
  36238. private _bone2Ang;
  36239. private _bone1;
  36240. private _bone2;
  36241. private _bone1Length;
  36242. private _bone2Length;
  36243. private _maxAngle;
  36244. private _maxReach;
  36245. private _rightHandedSystem;
  36246. private _bendAxis;
  36247. private _slerping;
  36248. private _adjustRoll;
  36249. /**
  36250. * Gets or sets maximum allowed angle
  36251. */
  36252. maxAngle: number;
  36253. /**
  36254. * Creates a new BoneIKController
  36255. * @param mesh defines the mesh to control
  36256. * @param bone defines the bone to control
  36257. * @param options defines options to set up the controller
  36258. */
  36259. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36260. targetMesh?: AbstractMesh;
  36261. poleTargetMesh?: AbstractMesh;
  36262. poleTargetBone?: Bone;
  36263. poleTargetLocalOffset?: Vector3;
  36264. poleAngle?: number;
  36265. bendAxis?: Vector3;
  36266. maxAngle?: number;
  36267. slerpAmount?: number;
  36268. });
  36269. private _setMaxAngle;
  36270. /**
  36271. * Force the controller to update the bones
  36272. */
  36273. update(): void;
  36274. }
  36275. }
  36276. declare module BABYLON {
  36277. /**
  36278. * Class used to make a bone look toward a point in space
  36279. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36280. */
  36281. export class BoneLookController {
  36282. private static _tmpVecs;
  36283. private static _tmpQuat;
  36284. private static _tmpMats;
  36285. /**
  36286. * The target Vector3 that the bone will look at
  36287. */
  36288. target: Vector3;
  36289. /**
  36290. * The mesh that the bone is attached to
  36291. */
  36292. mesh: AbstractMesh;
  36293. /**
  36294. * The bone that will be looking to the target
  36295. */
  36296. bone: Bone;
  36297. /**
  36298. * The up axis of the coordinate system that is used when the bone is rotated
  36299. */
  36300. upAxis: Vector3;
  36301. /**
  36302. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36303. */
  36304. upAxisSpace: Space;
  36305. /**
  36306. * Used to make an adjustment to the yaw of the bone
  36307. */
  36308. adjustYaw: number;
  36309. /**
  36310. * Used to make an adjustment to the pitch of the bone
  36311. */
  36312. adjustPitch: number;
  36313. /**
  36314. * Used to make an adjustment to the roll of the bone
  36315. */
  36316. adjustRoll: number;
  36317. /**
  36318. * 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)
  36319. */
  36320. slerpAmount: number;
  36321. private _minYaw;
  36322. private _maxYaw;
  36323. private _minPitch;
  36324. private _maxPitch;
  36325. private _minYawSin;
  36326. private _minYawCos;
  36327. private _maxYawSin;
  36328. private _maxYawCos;
  36329. private _midYawConstraint;
  36330. private _minPitchTan;
  36331. private _maxPitchTan;
  36332. private _boneQuat;
  36333. private _slerping;
  36334. private _transformYawPitch;
  36335. private _transformYawPitchInv;
  36336. private _firstFrameSkipped;
  36337. private _yawRange;
  36338. private _fowardAxis;
  36339. /**
  36340. * Gets or sets the minimum yaw angle that the bone can look to
  36341. */
  36342. minYaw: number;
  36343. /**
  36344. * Gets or sets the maximum yaw angle that the bone can look to
  36345. */
  36346. maxYaw: number;
  36347. /**
  36348. * Gets or sets the minimum pitch angle that the bone can look to
  36349. */
  36350. minPitch: number;
  36351. /**
  36352. * Gets or sets the maximum pitch angle that the bone can look to
  36353. */
  36354. maxPitch: number;
  36355. /**
  36356. * Create a BoneLookController
  36357. * @param mesh the mesh that the bone belongs to
  36358. * @param bone the bone that will be looking to the target
  36359. * @param target the target Vector3 to look at
  36360. * @param options optional settings:
  36361. * * maxYaw: the maximum angle the bone will yaw to
  36362. * * minYaw: the minimum angle the bone will yaw to
  36363. * * maxPitch: the maximum angle the bone will pitch to
  36364. * * minPitch: the minimum angle the bone will yaw to
  36365. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36366. * * upAxis: the up axis of the coordinate system
  36367. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36368. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36369. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36370. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36371. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36372. * * adjustRoll: used to make an adjustment to the roll of the bone
  36373. **/
  36374. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36375. maxYaw?: number;
  36376. minYaw?: number;
  36377. maxPitch?: number;
  36378. minPitch?: number;
  36379. slerpAmount?: number;
  36380. upAxis?: Vector3;
  36381. upAxisSpace?: Space;
  36382. yawAxis?: Vector3;
  36383. pitchAxis?: Vector3;
  36384. adjustYaw?: number;
  36385. adjustPitch?: number;
  36386. adjustRoll?: number;
  36387. });
  36388. /**
  36389. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36390. */
  36391. update(): void;
  36392. private _getAngleDiff;
  36393. private _getAngleBetween;
  36394. private _isAngleBetween;
  36395. }
  36396. }
  36397. declare module BABYLON {
  36398. /**
  36399. * Manage the gamepad inputs to control an arc rotate camera.
  36400. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36401. */
  36402. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36403. /**
  36404. * Defines the camera the input is attached to.
  36405. */
  36406. camera: ArcRotateCamera;
  36407. /**
  36408. * Defines the gamepad the input is gathering event from.
  36409. */
  36410. gamepad: Nullable<Gamepad>;
  36411. /**
  36412. * Defines the gamepad rotation sensiblity.
  36413. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36414. */
  36415. gamepadRotationSensibility: number;
  36416. /**
  36417. * Defines the gamepad move sensiblity.
  36418. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36419. */
  36420. gamepadMoveSensibility: number;
  36421. private _onGamepadConnectedObserver;
  36422. private _onGamepadDisconnectedObserver;
  36423. /**
  36424. * Attach the input controls to a specific dom element to get the input from.
  36425. * @param element Defines the element the controls should be listened from
  36426. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36427. */
  36428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36429. /**
  36430. * Detach the current controls from the specified dom element.
  36431. * @param element Defines the element to stop listening the inputs from
  36432. */
  36433. detachControl(element: Nullable<HTMLElement>): void;
  36434. /**
  36435. * Update the current camera state depending on the inputs that have been used this frame.
  36436. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36437. */
  36438. checkInputs(): void;
  36439. /**
  36440. * Gets the class name of the current intput.
  36441. * @returns the class name
  36442. */
  36443. getClassName(): string;
  36444. /**
  36445. * Get the friendly name associated with the input class.
  36446. * @returns the input friendly name
  36447. */
  36448. getSimpleName(): string;
  36449. }
  36450. }
  36451. declare module BABYLON {
  36452. interface ArcRotateCameraInputsManager {
  36453. /**
  36454. * Add orientation input support to the input manager.
  36455. * @returns the current input manager
  36456. */
  36457. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36458. }
  36459. /**
  36460. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36461. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36462. */
  36463. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36464. /**
  36465. * Defines the camera the input is attached to.
  36466. */
  36467. camera: ArcRotateCamera;
  36468. /**
  36469. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36470. */
  36471. alphaCorrection: number;
  36472. /**
  36473. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36474. */
  36475. gammaCorrection: number;
  36476. private _alpha;
  36477. private _gamma;
  36478. private _dirty;
  36479. private _deviceOrientationHandler;
  36480. /**
  36481. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36482. */
  36483. constructor();
  36484. /**
  36485. * Attach the input controls to a specific dom element to get the input from.
  36486. * @param element Defines the element the controls should be listened from
  36487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36488. */
  36489. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36490. /** @hidden */
  36491. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36492. /**
  36493. * Update the current camera state depending on the inputs that have been used this frame.
  36494. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36495. */
  36496. checkInputs(): void;
  36497. /**
  36498. * Detach the current controls from the specified dom element.
  36499. * @param element Defines the element to stop listening the inputs from
  36500. */
  36501. detachControl(element: Nullable<HTMLElement>): void;
  36502. /**
  36503. * Gets the class name of the current intput.
  36504. * @returns the class name
  36505. */
  36506. getClassName(): string;
  36507. /**
  36508. * Get the friendly name associated with the input class.
  36509. * @returns the input friendly name
  36510. */
  36511. getSimpleName(): string;
  36512. }
  36513. }
  36514. declare module BABYLON {
  36515. /**
  36516. * Listen to mouse events to control the camera.
  36517. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36518. */
  36519. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36520. /**
  36521. * Defines the camera the input is attached to.
  36522. */
  36523. camera: FlyCamera;
  36524. /**
  36525. * Defines if touch is enabled. (Default is true.)
  36526. */
  36527. touchEnabled: boolean;
  36528. /**
  36529. * Defines the buttons associated with the input to handle camera rotation.
  36530. */
  36531. buttons: number[];
  36532. /**
  36533. * Assign buttons for Yaw control.
  36534. */
  36535. buttonsYaw: number[];
  36536. /**
  36537. * Assign buttons for Pitch control.
  36538. */
  36539. buttonsPitch: number[];
  36540. /**
  36541. * Assign buttons for Roll control.
  36542. */
  36543. buttonsRoll: number[];
  36544. /**
  36545. * Detect if any button is being pressed while mouse is moved.
  36546. * -1 = Mouse locked.
  36547. * 0 = Left button.
  36548. * 1 = Middle Button.
  36549. * 2 = Right Button.
  36550. */
  36551. activeButton: number;
  36552. /**
  36553. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36554. * Higher values reduce its sensitivity.
  36555. */
  36556. angularSensibility: number;
  36557. private _mousemoveCallback;
  36558. private _observer;
  36559. private _rollObserver;
  36560. private previousPosition;
  36561. private noPreventDefault;
  36562. private element;
  36563. /**
  36564. * Listen to mouse events to control the camera.
  36565. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36566. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36567. */
  36568. constructor(touchEnabled?: boolean);
  36569. /**
  36570. * Attach the mouse control to the HTML DOM element.
  36571. * @param element Defines the element that listens to the input events.
  36572. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36573. */
  36574. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36575. /**
  36576. * Detach the current controls from the specified dom element.
  36577. * @param element Defines the element to stop listening the inputs from
  36578. */
  36579. detachControl(element: Nullable<HTMLElement>): void;
  36580. /**
  36581. * Gets the class name of the current input.
  36582. * @returns the class name.
  36583. */
  36584. getClassName(): string;
  36585. /**
  36586. * Get the friendly name associated with the input class.
  36587. * @returns the input's friendly name.
  36588. */
  36589. getSimpleName(): string;
  36590. private _pointerInput;
  36591. private _onMouseMove;
  36592. /**
  36593. * Rotate camera by mouse offset.
  36594. */
  36595. private rotateCamera;
  36596. }
  36597. }
  36598. declare module BABYLON {
  36599. /**
  36600. * Default Inputs manager for the FlyCamera.
  36601. * It groups all the default supported inputs for ease of use.
  36602. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36603. */
  36604. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36605. /**
  36606. * Instantiates a new FlyCameraInputsManager.
  36607. * @param camera Defines the camera the inputs belong to.
  36608. */
  36609. constructor(camera: FlyCamera);
  36610. /**
  36611. * Add keyboard input support to the input manager.
  36612. * @returns the new FlyCameraKeyboardMoveInput().
  36613. */
  36614. addKeyboard(): FlyCameraInputsManager;
  36615. /**
  36616. * Add mouse input support to the input manager.
  36617. * @param touchEnabled Enable touch screen support.
  36618. * @returns the new FlyCameraMouseInput().
  36619. */
  36620. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36621. }
  36622. }
  36623. declare module BABYLON {
  36624. /**
  36625. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36626. * such as in a 3D Space Shooter or a Flight Simulator.
  36627. */
  36628. export class FlyCamera extends TargetCamera {
  36629. /**
  36630. * Define the collision ellipsoid of the camera.
  36631. * This is helpful for simulating a camera body, like a player's body.
  36632. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36633. */
  36634. ellipsoid: Vector3;
  36635. /**
  36636. * Define an offset for the position of the ellipsoid around the camera.
  36637. * This can be helpful if the camera is attached away from the player's body center,
  36638. * such as at its head.
  36639. */
  36640. ellipsoidOffset: Vector3;
  36641. /**
  36642. * Enable or disable collisions of the camera with the rest of the scene objects.
  36643. */
  36644. checkCollisions: boolean;
  36645. /**
  36646. * Enable or disable gravity on the camera.
  36647. */
  36648. applyGravity: boolean;
  36649. /**
  36650. * Define the current direction the camera is moving to.
  36651. */
  36652. cameraDirection: Vector3;
  36653. /**
  36654. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36655. * This overrides and empties cameraRotation.
  36656. */
  36657. rotationQuaternion: Quaternion;
  36658. /**
  36659. * Track Roll to maintain the wanted Rolling when looking around.
  36660. */
  36661. _trackRoll: number;
  36662. /**
  36663. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36664. */
  36665. rollCorrect: number;
  36666. /**
  36667. * Mimic a banked turn, Rolling the camera when Yawing.
  36668. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36669. */
  36670. bankedTurn: boolean;
  36671. /**
  36672. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36673. */
  36674. bankedTurnLimit: number;
  36675. /**
  36676. * Value of 0 disables the banked Roll.
  36677. * Value of 1 is equal to the Yaw angle in radians.
  36678. */
  36679. bankedTurnMultiplier: number;
  36680. /**
  36681. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36682. */
  36683. inputs: FlyCameraInputsManager;
  36684. /**
  36685. * Gets the input sensibility for mouse input.
  36686. * Higher values reduce sensitivity.
  36687. */
  36688. /**
  36689. * Sets the input sensibility for a mouse input.
  36690. * Higher values reduce sensitivity.
  36691. */
  36692. angularSensibility: number;
  36693. /**
  36694. * Get the keys for camera movement forward.
  36695. */
  36696. /**
  36697. * Set the keys for camera movement forward.
  36698. */
  36699. keysForward: number[];
  36700. /**
  36701. * Get the keys for camera movement backward.
  36702. */
  36703. keysBackward: number[];
  36704. /**
  36705. * Get the keys for camera movement up.
  36706. */
  36707. /**
  36708. * Set the keys for camera movement up.
  36709. */
  36710. keysUp: number[];
  36711. /**
  36712. * Get the keys for camera movement down.
  36713. */
  36714. /**
  36715. * Set the keys for camera movement down.
  36716. */
  36717. keysDown: number[];
  36718. /**
  36719. * Get the keys for camera movement left.
  36720. */
  36721. /**
  36722. * Set the keys for camera movement left.
  36723. */
  36724. keysLeft: number[];
  36725. /**
  36726. * Set the keys for camera movement right.
  36727. */
  36728. /**
  36729. * Set the keys for camera movement right.
  36730. */
  36731. keysRight: number[];
  36732. /**
  36733. * Event raised when the camera collides with a mesh in the scene.
  36734. */
  36735. onCollide: (collidedMesh: AbstractMesh) => void;
  36736. private _collider;
  36737. private _needMoveForGravity;
  36738. private _oldPosition;
  36739. private _diffPosition;
  36740. private _newPosition;
  36741. /** @hidden */
  36742. _localDirection: Vector3;
  36743. /** @hidden */
  36744. _transformedDirection: Vector3;
  36745. /**
  36746. * Instantiates a FlyCamera.
  36747. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36748. * such as in a 3D Space Shooter or a Flight Simulator.
  36749. * @param name Define the name of the camera in the scene.
  36750. * @param position Define the starting position of the camera in the scene.
  36751. * @param scene Define the scene the camera belongs to.
  36752. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36753. */
  36754. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36755. /**
  36756. * Attach a control to the HTML DOM element.
  36757. * @param element Defines the element that listens to the input events.
  36758. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36759. */
  36760. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36761. /**
  36762. * Detach a control from the HTML DOM element.
  36763. * The camera will stop reacting to that input.
  36764. * @param element Defines the element that listens to the input events.
  36765. */
  36766. detachControl(element: HTMLElement): void;
  36767. private _collisionMask;
  36768. /**
  36769. * Get the mask that the camera ignores in collision events.
  36770. */
  36771. /**
  36772. * Set the mask that the camera ignores in collision events.
  36773. */
  36774. collisionMask: number;
  36775. /** @hidden */
  36776. _collideWithWorld(displacement: Vector3): void;
  36777. /** @hidden */
  36778. private _onCollisionPositionChange;
  36779. /** @hidden */
  36780. _checkInputs(): void;
  36781. /** @hidden */
  36782. _decideIfNeedsToMove(): boolean;
  36783. /** @hidden */
  36784. _updatePosition(): void;
  36785. /**
  36786. * Restore the Roll to its target value at the rate specified.
  36787. * @param rate - Higher means slower restoring.
  36788. * @hidden
  36789. */
  36790. restoreRoll(rate: number): void;
  36791. /**
  36792. * Destroy the camera and release the current resources held by it.
  36793. */
  36794. dispose(): void;
  36795. /**
  36796. * Get the current object class name.
  36797. * @returns the class name.
  36798. */
  36799. getClassName(): string;
  36800. }
  36801. }
  36802. declare module BABYLON {
  36803. /**
  36804. * Listen to keyboard events to control the camera.
  36805. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36806. */
  36807. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36808. /**
  36809. * Defines the camera the input is attached to.
  36810. */
  36811. camera: FlyCamera;
  36812. /**
  36813. * The list of keyboard keys used to control the forward move of the camera.
  36814. */
  36815. keysForward: number[];
  36816. /**
  36817. * The list of keyboard keys used to control the backward move of the camera.
  36818. */
  36819. keysBackward: number[];
  36820. /**
  36821. * The list of keyboard keys used to control the forward move of the camera.
  36822. */
  36823. keysUp: number[];
  36824. /**
  36825. * The list of keyboard keys used to control the backward move of the camera.
  36826. */
  36827. keysDown: number[];
  36828. /**
  36829. * The list of keyboard keys used to control the right strafe move of the camera.
  36830. */
  36831. keysRight: number[];
  36832. /**
  36833. * The list of keyboard keys used to control the left strafe move of the camera.
  36834. */
  36835. keysLeft: number[];
  36836. private _keys;
  36837. private _onCanvasBlurObserver;
  36838. private _onKeyboardObserver;
  36839. private _engine;
  36840. private _scene;
  36841. /**
  36842. * Attach the input controls to a specific dom element to get the input from.
  36843. * @param element Defines the element the controls should be listened from
  36844. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36845. */
  36846. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36847. /**
  36848. * Detach the current controls from the specified dom element.
  36849. * @param element Defines the element to stop listening the inputs from
  36850. */
  36851. detachControl(element: Nullable<HTMLElement>): void;
  36852. /**
  36853. * Gets the class name of the current intput.
  36854. * @returns the class name
  36855. */
  36856. getClassName(): string;
  36857. /** @hidden */
  36858. _onLostFocus(e: FocusEvent): void;
  36859. /**
  36860. * Get the friendly name associated with the input class.
  36861. * @returns the input friendly name
  36862. */
  36863. getSimpleName(): string;
  36864. /**
  36865. * Update the current camera state depending on the inputs that have been used this frame.
  36866. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36867. */
  36868. checkInputs(): void;
  36869. }
  36870. }
  36871. declare module BABYLON {
  36872. /**
  36873. * Manage the mouse wheel inputs to control a follow camera.
  36874. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36875. */
  36876. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36877. /**
  36878. * Defines the camera the input is attached to.
  36879. */
  36880. camera: FollowCamera;
  36881. /**
  36882. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36883. */
  36884. axisControlRadius: boolean;
  36885. /**
  36886. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36887. */
  36888. axisControlHeight: boolean;
  36889. /**
  36890. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36891. */
  36892. axisControlRotation: boolean;
  36893. /**
  36894. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36895. * relation to mouseWheel events.
  36896. */
  36897. wheelPrecision: number;
  36898. /**
  36899. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36900. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36901. */
  36902. wheelDeltaPercentage: number;
  36903. private _wheel;
  36904. private _observer;
  36905. /**
  36906. * Attach the input controls to a specific dom element to get the input from.
  36907. * @param element Defines the element the controls should be listened from
  36908. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36909. */
  36910. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36911. /**
  36912. * Detach the current controls from the specified dom element.
  36913. * @param element Defines the element to stop listening the inputs from
  36914. */
  36915. detachControl(element: Nullable<HTMLElement>): void;
  36916. /**
  36917. * Gets the class name of the current intput.
  36918. * @returns the class name
  36919. */
  36920. getClassName(): string;
  36921. /**
  36922. * Get the friendly name associated with the input class.
  36923. * @returns the input friendly name
  36924. */
  36925. getSimpleName(): string;
  36926. }
  36927. }
  36928. declare module BABYLON {
  36929. /**
  36930. * Manage the pointers inputs to control an follow camera.
  36931. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36932. */
  36933. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36934. /**
  36935. * Defines the camera the input is attached to.
  36936. */
  36937. camera: FollowCamera;
  36938. /**
  36939. * Gets the class name of the current input.
  36940. * @returns the class name
  36941. */
  36942. getClassName(): string;
  36943. /**
  36944. * Defines the pointer angular sensibility along the X axis or how fast is
  36945. * the camera rotating.
  36946. * A negative number will reverse the axis direction.
  36947. */
  36948. angularSensibilityX: number;
  36949. /**
  36950. * Defines the pointer angular sensibility along the Y axis or how fast is
  36951. * the camera rotating.
  36952. * A negative number will reverse the axis direction.
  36953. */
  36954. angularSensibilityY: number;
  36955. /**
  36956. * Defines the pointer pinch precision or how fast is the camera zooming.
  36957. * A negative number will reverse the axis direction.
  36958. */
  36959. pinchPrecision: number;
  36960. /**
  36961. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36962. * from 0.
  36963. * It defines the percentage of current camera.radius to use as delta when
  36964. * pinch zoom is used.
  36965. */
  36966. pinchDeltaPercentage: number;
  36967. /**
  36968. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36969. */
  36970. axisXControlRadius: boolean;
  36971. /**
  36972. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36973. */
  36974. axisXControlHeight: boolean;
  36975. /**
  36976. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36977. */
  36978. axisXControlRotation: boolean;
  36979. /**
  36980. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36981. */
  36982. axisYControlRadius: boolean;
  36983. /**
  36984. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36985. */
  36986. axisYControlHeight: boolean;
  36987. /**
  36988. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36989. */
  36990. axisYControlRotation: boolean;
  36991. /**
  36992. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36993. */
  36994. axisPinchControlRadius: boolean;
  36995. /**
  36996. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36997. */
  36998. axisPinchControlHeight: boolean;
  36999. /**
  37000. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37001. */
  37002. axisPinchControlRotation: boolean;
  37003. /**
  37004. * Log error messages if basic misconfiguration has occurred.
  37005. */
  37006. warningEnable: boolean;
  37007. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37008. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37009. private _warningCounter;
  37010. private _warning;
  37011. }
  37012. }
  37013. declare module BABYLON {
  37014. /**
  37015. * Default Inputs manager for the FollowCamera.
  37016. * It groups all the default supported inputs for ease of use.
  37017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37018. */
  37019. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37020. /**
  37021. * Instantiates a new FollowCameraInputsManager.
  37022. * @param camera Defines the camera the inputs belong to
  37023. */
  37024. constructor(camera: FollowCamera);
  37025. /**
  37026. * Add keyboard input support to the input manager.
  37027. * @returns the current input manager
  37028. */
  37029. addKeyboard(): FollowCameraInputsManager;
  37030. /**
  37031. * Add mouse wheel input support to the input manager.
  37032. * @returns the current input manager
  37033. */
  37034. addMouseWheel(): FollowCameraInputsManager;
  37035. /**
  37036. * Add pointers input support to the input manager.
  37037. * @returns the current input manager
  37038. */
  37039. addPointers(): FollowCameraInputsManager;
  37040. /**
  37041. * Add orientation input support to the input manager.
  37042. * @returns the current input manager
  37043. */
  37044. addVRDeviceOrientation(): FollowCameraInputsManager;
  37045. }
  37046. }
  37047. declare module BABYLON {
  37048. /**
  37049. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37050. * an arc rotate version arcFollowCamera are available.
  37051. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37052. */
  37053. export class FollowCamera extends TargetCamera {
  37054. /**
  37055. * Distance the follow camera should follow an object at
  37056. */
  37057. radius: number;
  37058. /**
  37059. * Minimum allowed distance of the camera to the axis of rotation
  37060. * (The camera can not get closer).
  37061. * This can help limiting how the Camera is able to move in the scene.
  37062. */
  37063. lowerRadiusLimit: Nullable<number>;
  37064. /**
  37065. * Maximum allowed distance of the camera to the axis of rotation
  37066. * (The camera can not get further).
  37067. * This can help limiting how the Camera is able to move in the scene.
  37068. */
  37069. upperRadiusLimit: Nullable<number>;
  37070. /**
  37071. * Define a rotation offset between the camera and the object it follows
  37072. */
  37073. rotationOffset: number;
  37074. /**
  37075. * Minimum allowed angle to camera position relative to target object.
  37076. * This can help limiting how the Camera is able to move in the scene.
  37077. */
  37078. lowerRotationOffsetLimit: Nullable<number>;
  37079. /**
  37080. * Maximum allowed angle to camera position relative to target object.
  37081. * This can help limiting how the Camera is able to move in the scene.
  37082. */
  37083. upperRotationOffsetLimit: Nullable<number>;
  37084. /**
  37085. * Define a height offset between the camera and the object it follows.
  37086. * It can help following an object from the top (like a car chaing a plane)
  37087. */
  37088. heightOffset: number;
  37089. /**
  37090. * Minimum allowed height of camera position relative to target object.
  37091. * This can help limiting how the Camera is able to move in the scene.
  37092. */
  37093. lowerHeightOffsetLimit: Nullable<number>;
  37094. /**
  37095. * Maximum allowed height of camera position relative to target object.
  37096. * This can help limiting how the Camera is able to move in the scene.
  37097. */
  37098. upperHeightOffsetLimit: Nullable<number>;
  37099. /**
  37100. * Define how fast the camera can accelerate to follow it s target.
  37101. */
  37102. cameraAcceleration: number;
  37103. /**
  37104. * Define the speed limit of the camera following an object.
  37105. */
  37106. maxCameraSpeed: number;
  37107. /**
  37108. * Define the target of the camera.
  37109. */
  37110. lockedTarget: Nullable<AbstractMesh>;
  37111. /**
  37112. * Defines the input associated with the camera.
  37113. */
  37114. inputs: FollowCameraInputsManager;
  37115. /**
  37116. * Instantiates the follow camera.
  37117. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37118. * @param name Define the name of the camera in the scene
  37119. * @param position Define the position of the camera
  37120. * @param scene Define the scene the camera belong to
  37121. * @param lockedTarget Define the target of the camera
  37122. */
  37123. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37124. private _follow;
  37125. /**
  37126. * Attached controls to the current camera.
  37127. * @param element Defines the element the controls should be listened from
  37128. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37129. */
  37130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37131. /**
  37132. * Detach the current controls from the camera.
  37133. * The camera will stop reacting to inputs.
  37134. * @param element Defines the element to stop listening the inputs from
  37135. */
  37136. detachControl(element: HTMLElement): void;
  37137. /** @hidden */
  37138. _checkInputs(): void;
  37139. private _checkLimits;
  37140. /**
  37141. * Gets the camera class name.
  37142. * @returns the class name
  37143. */
  37144. getClassName(): string;
  37145. }
  37146. /**
  37147. * Arc Rotate version of the follow camera.
  37148. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37149. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37150. */
  37151. export class ArcFollowCamera extends TargetCamera {
  37152. /** The longitudinal angle of the camera */
  37153. alpha: number;
  37154. /** The latitudinal angle of the camera */
  37155. beta: number;
  37156. /** The radius of the camera from its target */
  37157. radius: number;
  37158. /** Define the camera target (the messh it should follow) */
  37159. target: Nullable<AbstractMesh>;
  37160. private _cartesianCoordinates;
  37161. /**
  37162. * Instantiates a new ArcFollowCamera
  37163. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37164. * @param name Define the name of the camera
  37165. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37166. * @param beta Define the rotation angle of the camera around the elevation axis
  37167. * @param radius Define the radius of the camera from its target point
  37168. * @param target Define the target of the camera
  37169. * @param scene Define the scene the camera belongs to
  37170. */
  37171. constructor(name: string,
  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>, scene: Scene);
  37180. private _follow;
  37181. /** @hidden */
  37182. _checkInputs(): void;
  37183. /**
  37184. * Returns the class name of the object.
  37185. * It is mostly used internally for serialization purposes.
  37186. */
  37187. getClassName(): string;
  37188. }
  37189. }
  37190. declare module BABYLON {
  37191. /**
  37192. * Manage the keyboard inputs to control the movement of a follow camera.
  37193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37194. */
  37195. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37196. /**
  37197. * Defines the camera the input is attached to.
  37198. */
  37199. camera: FollowCamera;
  37200. /**
  37201. * Defines the list of key codes associated with the up action (increase heightOffset)
  37202. */
  37203. keysHeightOffsetIncr: number[];
  37204. /**
  37205. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37206. */
  37207. keysHeightOffsetDecr: number[];
  37208. /**
  37209. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37210. */
  37211. keysHeightOffsetModifierAlt: boolean;
  37212. /**
  37213. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37214. */
  37215. keysHeightOffsetModifierCtrl: boolean;
  37216. /**
  37217. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37218. */
  37219. keysHeightOffsetModifierShift: boolean;
  37220. /**
  37221. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37222. */
  37223. keysRotationOffsetIncr: number[];
  37224. /**
  37225. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37226. */
  37227. keysRotationOffsetDecr: number[];
  37228. /**
  37229. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37230. */
  37231. keysRotationOffsetModifierAlt: boolean;
  37232. /**
  37233. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37234. */
  37235. keysRotationOffsetModifierCtrl: boolean;
  37236. /**
  37237. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37238. */
  37239. keysRotationOffsetModifierShift: boolean;
  37240. /**
  37241. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37242. */
  37243. keysRadiusIncr: number[];
  37244. /**
  37245. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37246. */
  37247. keysRadiusDecr: number[];
  37248. /**
  37249. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37250. */
  37251. keysRadiusModifierAlt: boolean;
  37252. /**
  37253. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37254. */
  37255. keysRadiusModifierCtrl: boolean;
  37256. /**
  37257. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37258. */
  37259. keysRadiusModifierShift: boolean;
  37260. /**
  37261. * Defines the rate of change of heightOffset.
  37262. */
  37263. heightSensibility: number;
  37264. /**
  37265. * Defines the rate of change of rotationOffset.
  37266. */
  37267. rotationSensibility: number;
  37268. /**
  37269. * Defines the rate of change of radius.
  37270. */
  37271. radiusSensibility: number;
  37272. private _keys;
  37273. private _ctrlPressed;
  37274. private _altPressed;
  37275. private _shiftPressed;
  37276. private _onCanvasBlurObserver;
  37277. private _onKeyboardObserver;
  37278. private _engine;
  37279. private _scene;
  37280. /**
  37281. * Attach the input controls to a specific dom element to get the input from.
  37282. * @param element Defines the element the controls should be listened from
  37283. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37284. */
  37285. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37286. /**
  37287. * Detach the current controls from the specified dom element.
  37288. * @param element Defines the element to stop listening the inputs from
  37289. */
  37290. detachControl(element: Nullable<HTMLElement>): void;
  37291. /**
  37292. * Update the current camera state depending on the inputs that have been used this frame.
  37293. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37294. */
  37295. checkInputs(): void;
  37296. /**
  37297. * Gets the class name of the current input.
  37298. * @returns the class name
  37299. */
  37300. getClassName(): string;
  37301. /**
  37302. * Get the friendly name associated with the input class.
  37303. * @returns the input friendly name
  37304. */
  37305. getSimpleName(): string;
  37306. /**
  37307. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37308. * allow modification of the heightOffset value.
  37309. */
  37310. private _modifierHeightOffset;
  37311. /**
  37312. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37313. * allow modification of the rotationOffset value.
  37314. */
  37315. private _modifierRotationOffset;
  37316. /**
  37317. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37318. * allow modification of the radius value.
  37319. */
  37320. private _modifierRadius;
  37321. }
  37322. }
  37323. declare module BABYLON {
  37324. interface FreeCameraInputsManager {
  37325. /**
  37326. * @hidden
  37327. */
  37328. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37329. /**
  37330. * Add orientation input support to the input manager.
  37331. * @returns the current input manager
  37332. */
  37333. addDeviceOrientation(): FreeCameraInputsManager;
  37334. }
  37335. /**
  37336. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37337. * Screen rotation is taken into account.
  37338. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37339. */
  37340. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37341. private _camera;
  37342. private _screenOrientationAngle;
  37343. private _constantTranform;
  37344. private _screenQuaternion;
  37345. private _alpha;
  37346. private _beta;
  37347. private _gamma;
  37348. /**
  37349. * @hidden
  37350. */
  37351. _onDeviceOrientationChangedObservable: Observable<void>;
  37352. /**
  37353. * Instantiates a new input
  37354. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37355. */
  37356. constructor();
  37357. /**
  37358. * Define the camera controlled by the input.
  37359. */
  37360. camera: FreeCamera;
  37361. /**
  37362. * Attach the input controls to a specific dom element to get the input from.
  37363. * @param element Defines the element the controls should be listened from
  37364. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37365. */
  37366. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37367. private _orientationChanged;
  37368. private _deviceOrientation;
  37369. /**
  37370. * Detach the current controls from the specified dom element.
  37371. * @param element Defines the element to stop listening the inputs from
  37372. */
  37373. detachControl(element: Nullable<HTMLElement>): void;
  37374. /**
  37375. * Update the current camera state depending on the inputs that have been used this frame.
  37376. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37377. */
  37378. checkInputs(): void;
  37379. /**
  37380. * Gets the class name of the current intput.
  37381. * @returns the class name
  37382. */
  37383. getClassName(): string;
  37384. /**
  37385. * Get the friendly name associated with the input class.
  37386. * @returns the input friendly name
  37387. */
  37388. getSimpleName(): string;
  37389. }
  37390. }
  37391. declare module BABYLON {
  37392. /**
  37393. * Manage the gamepad inputs to control a free camera.
  37394. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37395. */
  37396. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37397. /**
  37398. * Define the camera the input is attached to.
  37399. */
  37400. camera: FreeCamera;
  37401. /**
  37402. * Define the Gamepad controlling the input
  37403. */
  37404. gamepad: Nullable<Gamepad>;
  37405. /**
  37406. * Defines the gamepad rotation sensiblity.
  37407. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37408. */
  37409. gamepadAngularSensibility: number;
  37410. /**
  37411. * Defines the gamepad move sensiblity.
  37412. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37413. */
  37414. gamepadMoveSensibility: number;
  37415. private _onGamepadConnectedObserver;
  37416. private _onGamepadDisconnectedObserver;
  37417. private _cameraTransform;
  37418. private _deltaTransform;
  37419. private _vector3;
  37420. private _vector2;
  37421. /**
  37422. * Attach the input controls to a specific dom element to get the input from.
  37423. * @param element Defines the element the controls should be listened from
  37424. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37425. */
  37426. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37427. /**
  37428. * Detach the current controls from the specified dom element.
  37429. * @param element Defines the element to stop listening the inputs from
  37430. */
  37431. detachControl(element: Nullable<HTMLElement>): void;
  37432. /**
  37433. * Update the current camera state depending on the inputs that have been used this frame.
  37434. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37435. */
  37436. checkInputs(): void;
  37437. /**
  37438. * Gets the class name of the current intput.
  37439. * @returns the class name
  37440. */
  37441. getClassName(): string;
  37442. /**
  37443. * Get the friendly name associated with the input class.
  37444. * @returns the input friendly name
  37445. */
  37446. getSimpleName(): string;
  37447. }
  37448. }
  37449. declare module BABYLON {
  37450. /**
  37451. * Defines the potential axis of a Joystick
  37452. */
  37453. export enum JoystickAxis {
  37454. /** X axis */
  37455. X = 0,
  37456. /** Y axis */
  37457. Y = 1,
  37458. /** Z axis */
  37459. Z = 2
  37460. }
  37461. /**
  37462. * Class used to define virtual joystick (used in touch mode)
  37463. */
  37464. export class VirtualJoystick {
  37465. /**
  37466. * Gets or sets a boolean indicating that left and right values must be inverted
  37467. */
  37468. reverseLeftRight: boolean;
  37469. /**
  37470. * Gets or sets a boolean indicating that up and down values must be inverted
  37471. */
  37472. reverseUpDown: boolean;
  37473. /**
  37474. * Gets the offset value for the position (ie. the change of the position value)
  37475. */
  37476. deltaPosition: Vector3;
  37477. /**
  37478. * Gets a boolean indicating if the virtual joystick was pressed
  37479. */
  37480. pressed: boolean;
  37481. /**
  37482. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37483. */
  37484. static Canvas: Nullable<HTMLCanvasElement>;
  37485. private static _globalJoystickIndex;
  37486. private static vjCanvasContext;
  37487. private static vjCanvasWidth;
  37488. private static vjCanvasHeight;
  37489. private static halfWidth;
  37490. private _action;
  37491. private _axisTargetedByLeftAndRight;
  37492. private _axisTargetedByUpAndDown;
  37493. private _joystickSensibility;
  37494. private _inversedSensibility;
  37495. private _joystickPointerID;
  37496. private _joystickColor;
  37497. private _joystickPointerPos;
  37498. private _joystickPreviousPointerPos;
  37499. private _joystickPointerStartPos;
  37500. private _deltaJoystickVector;
  37501. private _leftJoystick;
  37502. private _touches;
  37503. private _onPointerDownHandlerRef;
  37504. private _onPointerMoveHandlerRef;
  37505. private _onPointerUpHandlerRef;
  37506. private _onResize;
  37507. /**
  37508. * Creates a new virtual joystick
  37509. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37510. */
  37511. constructor(leftJoystick?: boolean);
  37512. /**
  37513. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37514. * @param newJoystickSensibility defines the new sensibility
  37515. */
  37516. setJoystickSensibility(newJoystickSensibility: number): void;
  37517. private _onPointerDown;
  37518. private _onPointerMove;
  37519. private _onPointerUp;
  37520. /**
  37521. * Change the color of the virtual joystick
  37522. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37523. */
  37524. setJoystickColor(newColor: string): void;
  37525. /**
  37526. * Defines a callback to call when the joystick is touched
  37527. * @param action defines the callback
  37528. */
  37529. setActionOnTouch(action: () => any): void;
  37530. /**
  37531. * Defines which axis you'd like to control for left & right
  37532. * @param axis defines the axis to use
  37533. */
  37534. setAxisForLeftRight(axis: JoystickAxis): void;
  37535. /**
  37536. * Defines which axis you'd like to control for up & down
  37537. * @param axis defines the axis to use
  37538. */
  37539. setAxisForUpDown(axis: JoystickAxis): void;
  37540. private _drawVirtualJoystick;
  37541. /**
  37542. * Release internal HTML canvas
  37543. */
  37544. releaseCanvas(): void;
  37545. }
  37546. }
  37547. declare module BABYLON {
  37548. interface FreeCameraInputsManager {
  37549. /**
  37550. * Add virtual joystick input support to the input manager.
  37551. * @returns the current input manager
  37552. */
  37553. addVirtualJoystick(): FreeCameraInputsManager;
  37554. }
  37555. /**
  37556. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37557. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37558. */
  37559. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37560. /**
  37561. * Defines the camera the input is attached to.
  37562. */
  37563. camera: FreeCamera;
  37564. private _leftjoystick;
  37565. private _rightjoystick;
  37566. /**
  37567. * Gets the left stick of the virtual joystick.
  37568. * @returns The virtual Joystick
  37569. */
  37570. getLeftJoystick(): VirtualJoystick;
  37571. /**
  37572. * Gets the right stick of the virtual joystick.
  37573. * @returns The virtual Joystick
  37574. */
  37575. getRightJoystick(): VirtualJoystick;
  37576. /**
  37577. * Update the current camera state depending on the inputs that have been used this frame.
  37578. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37579. */
  37580. checkInputs(): void;
  37581. /**
  37582. * Attach the input controls to a specific dom element to get the input from.
  37583. * @param element Defines the element the controls should be listened from
  37584. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37585. */
  37586. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37587. /**
  37588. * Detach the current controls from the specified dom element.
  37589. * @param element Defines the element to stop listening the inputs from
  37590. */
  37591. detachControl(element: Nullable<HTMLElement>): void;
  37592. /**
  37593. * Gets the class name of the current intput.
  37594. * @returns the class name
  37595. */
  37596. getClassName(): string;
  37597. /**
  37598. * Get the friendly name associated with the input class.
  37599. * @returns the input friendly name
  37600. */
  37601. getSimpleName(): string;
  37602. }
  37603. }
  37604. declare module BABYLON {
  37605. /**
  37606. * This represents a FPS type of camera controlled by touch.
  37607. * This is like a universal camera minus the Gamepad controls.
  37608. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37609. */
  37610. export class TouchCamera extends FreeCamera {
  37611. /**
  37612. * Defines the touch sensibility for rotation.
  37613. * The higher the faster.
  37614. */
  37615. touchAngularSensibility: number;
  37616. /**
  37617. * Defines the touch sensibility for move.
  37618. * The higher the faster.
  37619. */
  37620. touchMoveSensibility: number;
  37621. /**
  37622. * Instantiates a new touch camera.
  37623. * This represents a FPS type of camera controlled by touch.
  37624. * This is like a universal camera minus the Gamepad controls.
  37625. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37626. * @param name Define the name of the camera in the scene
  37627. * @param position Define the start position of the camera in the scene
  37628. * @param scene Define the scene the camera belongs to
  37629. */
  37630. constructor(name: string, position: Vector3, scene: Scene);
  37631. /**
  37632. * Gets the current object class name.
  37633. * @return the class name
  37634. */
  37635. getClassName(): string;
  37636. /** @hidden */
  37637. _setupInputs(): void;
  37638. }
  37639. }
  37640. declare module BABYLON {
  37641. /**
  37642. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37643. * being tilted forward or back and left or right.
  37644. */
  37645. export class DeviceOrientationCamera extends FreeCamera {
  37646. private _initialQuaternion;
  37647. private _quaternionCache;
  37648. private _tmpDragQuaternion;
  37649. /**
  37650. * Creates a new device orientation camera
  37651. * @param name The name of the camera
  37652. * @param position The start position camera
  37653. * @param scene The scene the camera belongs to
  37654. */
  37655. constructor(name: string, position: Vector3, scene: Scene);
  37656. /**
  37657. * @hidden
  37658. * Disabled pointer input on first orientation sensor update (Default: true)
  37659. */
  37660. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37661. private _dragFactor;
  37662. /**
  37663. * Enabled turning on the y axis when the orientation sensor is active
  37664. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37665. */
  37666. enableHorizontalDragging(dragFactor?: number): void;
  37667. /**
  37668. * Gets the current instance class name ("DeviceOrientationCamera").
  37669. * This helps avoiding instanceof at run time.
  37670. * @returns the class name
  37671. */
  37672. getClassName(): string;
  37673. /**
  37674. * @hidden
  37675. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37676. */
  37677. _checkInputs(): void;
  37678. /**
  37679. * Reset the camera to its default orientation on the specified axis only.
  37680. * @param axis The axis to reset
  37681. */
  37682. resetToCurrentRotation(axis?: Axis): void;
  37683. }
  37684. }
  37685. declare module BABYLON {
  37686. /**
  37687. * Defines supported buttons for XBox360 compatible gamepads
  37688. */
  37689. export enum Xbox360Button {
  37690. /** A */
  37691. A = 0,
  37692. /** B */
  37693. B = 1,
  37694. /** X */
  37695. X = 2,
  37696. /** Y */
  37697. Y = 3,
  37698. /** Start */
  37699. Start = 4,
  37700. /** Back */
  37701. Back = 5,
  37702. /** Left button */
  37703. LB = 6,
  37704. /** Right button */
  37705. RB = 7,
  37706. /** Left stick */
  37707. LeftStick = 8,
  37708. /** Right stick */
  37709. RightStick = 9
  37710. }
  37711. /** Defines values for XBox360 DPad */
  37712. export enum Xbox360Dpad {
  37713. /** Up */
  37714. Up = 0,
  37715. /** Down */
  37716. Down = 1,
  37717. /** Left */
  37718. Left = 2,
  37719. /** Right */
  37720. Right = 3
  37721. }
  37722. /**
  37723. * Defines a XBox360 gamepad
  37724. */
  37725. export class Xbox360Pad extends Gamepad {
  37726. private _leftTrigger;
  37727. private _rightTrigger;
  37728. private _onlefttriggerchanged;
  37729. private _onrighttriggerchanged;
  37730. private _onbuttondown;
  37731. private _onbuttonup;
  37732. private _ondpaddown;
  37733. private _ondpadup;
  37734. /** Observable raised when a button is pressed */
  37735. onButtonDownObservable: Observable<Xbox360Button>;
  37736. /** Observable raised when a button is released */
  37737. onButtonUpObservable: Observable<Xbox360Button>;
  37738. /** Observable raised when a pad is pressed */
  37739. onPadDownObservable: Observable<Xbox360Dpad>;
  37740. /** Observable raised when a pad is released */
  37741. onPadUpObservable: Observable<Xbox360Dpad>;
  37742. private _buttonA;
  37743. private _buttonB;
  37744. private _buttonX;
  37745. private _buttonY;
  37746. private _buttonBack;
  37747. private _buttonStart;
  37748. private _buttonLB;
  37749. private _buttonRB;
  37750. private _buttonLeftStick;
  37751. private _buttonRightStick;
  37752. private _dPadUp;
  37753. private _dPadDown;
  37754. private _dPadLeft;
  37755. private _dPadRight;
  37756. private _isXboxOnePad;
  37757. /**
  37758. * Creates a new XBox360 gamepad object
  37759. * @param id defines the id of this gamepad
  37760. * @param index defines its index
  37761. * @param gamepad defines the internal HTML gamepad object
  37762. * @param xboxOne defines if it is a XBox One gamepad
  37763. */
  37764. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37765. /**
  37766. * Defines the callback to call when left trigger is pressed
  37767. * @param callback defines the callback to use
  37768. */
  37769. onlefttriggerchanged(callback: (value: number) => void): void;
  37770. /**
  37771. * Defines the callback to call when right trigger is pressed
  37772. * @param callback defines the callback to use
  37773. */
  37774. onrighttriggerchanged(callback: (value: number) => void): void;
  37775. /**
  37776. * Gets the left trigger value
  37777. */
  37778. /**
  37779. * Sets the left trigger value
  37780. */
  37781. leftTrigger: number;
  37782. /**
  37783. * Gets the right trigger value
  37784. */
  37785. /**
  37786. * Sets the right trigger value
  37787. */
  37788. rightTrigger: number;
  37789. /**
  37790. * Defines the callback to call when a button is pressed
  37791. * @param callback defines the callback to use
  37792. */
  37793. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37794. /**
  37795. * Defines the callback to call when a button is released
  37796. * @param callback defines the callback to use
  37797. */
  37798. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37799. /**
  37800. * Defines the callback to call when a pad is pressed
  37801. * @param callback defines the callback to use
  37802. */
  37803. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37804. /**
  37805. * Defines the callback to call when a pad is released
  37806. * @param callback defines the callback to use
  37807. */
  37808. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37809. private _setButtonValue;
  37810. private _setDPadValue;
  37811. /**
  37812. * Gets the value of the `A` button
  37813. */
  37814. /**
  37815. * Sets the value of the `A` button
  37816. */
  37817. buttonA: number;
  37818. /**
  37819. * Gets the value of the `B` button
  37820. */
  37821. /**
  37822. * Sets the value of the `B` button
  37823. */
  37824. buttonB: number;
  37825. /**
  37826. * Gets the value of the `X` button
  37827. */
  37828. /**
  37829. * Sets the value of the `X` button
  37830. */
  37831. buttonX: number;
  37832. /**
  37833. * Gets the value of the `Y` button
  37834. */
  37835. /**
  37836. * Sets the value of the `Y` button
  37837. */
  37838. buttonY: number;
  37839. /**
  37840. * Gets the value of the `Start` button
  37841. */
  37842. /**
  37843. * Sets the value of the `Start` button
  37844. */
  37845. buttonStart: number;
  37846. /**
  37847. * Gets the value of the `Back` button
  37848. */
  37849. /**
  37850. * Sets the value of the `Back` button
  37851. */
  37852. buttonBack: number;
  37853. /**
  37854. * Gets the value of the `Left` button
  37855. */
  37856. /**
  37857. * Sets the value of the `Left` button
  37858. */
  37859. buttonLB: number;
  37860. /**
  37861. * Gets the value of the `Right` button
  37862. */
  37863. /**
  37864. * Sets the value of the `Right` button
  37865. */
  37866. buttonRB: number;
  37867. /**
  37868. * Gets the value of the Left joystick
  37869. */
  37870. /**
  37871. * Sets the value of the Left joystick
  37872. */
  37873. buttonLeftStick: number;
  37874. /**
  37875. * Gets the value of the Right joystick
  37876. */
  37877. /**
  37878. * Sets the value of the Right joystick
  37879. */
  37880. buttonRightStick: number;
  37881. /**
  37882. * Gets the value of D-pad up
  37883. */
  37884. /**
  37885. * Sets the value of D-pad up
  37886. */
  37887. dPadUp: number;
  37888. /**
  37889. * Gets the value of D-pad down
  37890. */
  37891. /**
  37892. * Sets the value of D-pad down
  37893. */
  37894. dPadDown: number;
  37895. /**
  37896. * Gets the value of D-pad left
  37897. */
  37898. /**
  37899. * Sets the value of D-pad left
  37900. */
  37901. dPadLeft: number;
  37902. /**
  37903. * Gets the value of D-pad right
  37904. */
  37905. /**
  37906. * Sets the value of D-pad right
  37907. */
  37908. dPadRight: number;
  37909. /**
  37910. * Force the gamepad to synchronize with device values
  37911. */
  37912. update(): void;
  37913. /**
  37914. * Disposes the gamepad
  37915. */
  37916. dispose(): void;
  37917. }
  37918. }
  37919. declare module BABYLON {
  37920. /**
  37921. * Manager for handling gamepads
  37922. */
  37923. export class GamepadManager {
  37924. private _scene?;
  37925. private _babylonGamepads;
  37926. private _oneGamepadConnected;
  37927. /** @hidden */
  37928. _isMonitoring: boolean;
  37929. private _gamepadEventSupported;
  37930. private _gamepadSupport;
  37931. /**
  37932. * observable to be triggered when the gamepad controller has been connected
  37933. */
  37934. onGamepadConnectedObservable: Observable<Gamepad>;
  37935. /**
  37936. * observable to be triggered when the gamepad controller has been disconnected
  37937. */
  37938. onGamepadDisconnectedObservable: Observable<Gamepad>;
  37939. private _onGamepadConnectedEvent;
  37940. private _onGamepadDisconnectedEvent;
  37941. /**
  37942. * Initializes the gamepad manager
  37943. * @param _scene BabylonJS scene
  37944. */
  37945. constructor(_scene?: Scene | undefined);
  37946. /**
  37947. * The gamepads in the game pad manager
  37948. */
  37949. readonly gamepads: Gamepad[];
  37950. /**
  37951. * Get the gamepad controllers based on type
  37952. * @param type The type of gamepad controller
  37953. * @returns Nullable gamepad
  37954. */
  37955. getGamepadByType(type?: number): Nullable<Gamepad>;
  37956. /**
  37957. * Disposes the gamepad manager
  37958. */
  37959. dispose(): void;
  37960. private _addNewGamepad;
  37961. private _startMonitoringGamepads;
  37962. private _stopMonitoringGamepads;
  37963. /** @hidden */
  37964. _checkGamepadsStatus(): void;
  37965. private _updateGamepadObjects;
  37966. }
  37967. }
  37968. declare module BABYLON {
  37969. interface Scene {
  37970. /** @hidden */
  37971. _gamepadManager: Nullable<GamepadManager>;
  37972. /**
  37973. * Gets the gamepad manager associated with the scene
  37974. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  37975. */
  37976. gamepadManager: GamepadManager;
  37977. }
  37978. /**
  37979. * Interface representing a free camera inputs manager
  37980. */
  37981. interface FreeCameraInputsManager {
  37982. /**
  37983. * Adds gamepad input support to the FreeCameraInputsManager.
  37984. * @returns the FreeCameraInputsManager
  37985. */
  37986. addGamepad(): FreeCameraInputsManager;
  37987. }
  37988. /**
  37989. * Interface representing an arc rotate camera inputs manager
  37990. */
  37991. interface ArcRotateCameraInputsManager {
  37992. /**
  37993. * Adds gamepad input support to the ArcRotateCamera InputManager.
  37994. * @returns the camera inputs manager
  37995. */
  37996. addGamepad(): ArcRotateCameraInputsManager;
  37997. }
  37998. /**
  37999. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38000. */
  38001. export class GamepadSystemSceneComponent implements ISceneComponent {
  38002. /**
  38003. * The component name helpfull to identify the component in the list of scene components.
  38004. */
  38005. readonly name: string;
  38006. /**
  38007. * The scene the component belongs to.
  38008. */
  38009. scene: Scene;
  38010. /**
  38011. * Creates a new instance of the component for the given scene
  38012. * @param scene Defines the scene to register the component in
  38013. */
  38014. constructor(scene: Scene);
  38015. /**
  38016. * Registers the component in a given scene
  38017. */
  38018. register(): void;
  38019. /**
  38020. * Rebuilds the elements related to this component in case of
  38021. * context lost for instance.
  38022. */
  38023. rebuild(): void;
  38024. /**
  38025. * Disposes the component and the associated ressources
  38026. */
  38027. dispose(): void;
  38028. private _beforeCameraUpdate;
  38029. }
  38030. }
  38031. declare module BABYLON {
  38032. /**
  38033. * 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,
  38034. * which still works and will still be found in many Playgrounds.
  38035. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38036. */
  38037. export class UniversalCamera extends TouchCamera {
  38038. /**
  38039. * Defines the gamepad rotation sensiblity.
  38040. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38041. */
  38042. gamepadAngularSensibility: number;
  38043. /**
  38044. * Defines the gamepad move sensiblity.
  38045. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38046. */
  38047. gamepadMoveSensibility: number;
  38048. /**
  38049. * 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,
  38050. * which still works and will still be found in many Playgrounds.
  38051. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38052. * @param name Define the name of the camera in the scene
  38053. * @param position Define the start position of the camera in the scene
  38054. * @param scene Define the scene the camera belongs to
  38055. */
  38056. constructor(name: string, position: Vector3, scene: Scene);
  38057. /**
  38058. * Gets the current object class name.
  38059. * @return the class name
  38060. */
  38061. getClassName(): string;
  38062. }
  38063. }
  38064. declare module BABYLON {
  38065. /**
  38066. * This represents a FPS type of camera. This is only here for back compat purpose.
  38067. * Please use the UniversalCamera instead as both are identical.
  38068. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38069. */
  38070. export class GamepadCamera extends UniversalCamera {
  38071. /**
  38072. * Instantiates a new Gamepad Camera
  38073. * This represents a FPS type of camera. This is only here for back compat purpose.
  38074. * Please use the UniversalCamera instead as both are identical.
  38075. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38076. * @param name Define the name of the camera in the scene
  38077. * @param position Define the start position of the camera in the scene
  38078. * @param scene Define the scene the camera belongs to
  38079. */
  38080. constructor(name: string, position: Vector3, scene: Scene);
  38081. /**
  38082. * Gets the current object class name.
  38083. * @return the class name
  38084. */
  38085. getClassName(): string;
  38086. }
  38087. }
  38088. declare module BABYLON {
  38089. /** @hidden */
  38090. export var passPixelShader: {
  38091. name: string;
  38092. shader: string;
  38093. };
  38094. }
  38095. declare module BABYLON {
  38096. /** @hidden */
  38097. export var passCubePixelShader: {
  38098. name: string;
  38099. shader: string;
  38100. };
  38101. }
  38102. declare module BABYLON {
  38103. /**
  38104. * PassPostProcess which produces an output the same as it's input
  38105. */
  38106. export class PassPostProcess extends PostProcess {
  38107. /**
  38108. * Creates the PassPostProcess
  38109. * @param name The name of the effect.
  38110. * @param options The required width/height ratio to downsize to before computing the render pass.
  38111. * @param camera The camera to apply the render pass to.
  38112. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38113. * @param engine The engine which the post process will be applied. (default: current engine)
  38114. * @param reusable If the post process can be reused on the same frame. (default: false)
  38115. * @param textureType The type of texture to be used when performing the post processing.
  38116. * @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)
  38117. */
  38118. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38119. }
  38120. /**
  38121. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38122. */
  38123. export class PassCubePostProcess extends PostProcess {
  38124. private _face;
  38125. /**
  38126. * Gets or sets the cube face to display.
  38127. * * 0 is +X
  38128. * * 1 is -X
  38129. * * 2 is +Y
  38130. * * 3 is -Y
  38131. * * 4 is +Z
  38132. * * 5 is -Z
  38133. */
  38134. face: number;
  38135. /**
  38136. * Creates the PassCubePostProcess
  38137. * @param name The name of the effect.
  38138. * @param options The required width/height ratio to downsize to before computing the render pass.
  38139. * @param camera The camera to apply the render pass to.
  38140. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38141. * @param engine The engine which the post process will be applied. (default: current engine)
  38142. * @param reusable If the post process can be reused on the same frame. (default: false)
  38143. * @param textureType The type of texture to be used when performing the post processing.
  38144. * @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)
  38145. */
  38146. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38147. }
  38148. }
  38149. declare module BABYLON {
  38150. /** @hidden */
  38151. export var anaglyphPixelShader: {
  38152. name: string;
  38153. shader: string;
  38154. };
  38155. }
  38156. declare module BABYLON {
  38157. /**
  38158. * Postprocess used to generate anaglyphic rendering
  38159. */
  38160. export class AnaglyphPostProcess extends PostProcess {
  38161. private _passedProcess;
  38162. /**
  38163. * Creates a new AnaglyphPostProcess
  38164. * @param name defines postprocess name
  38165. * @param options defines creation options or target ratio scale
  38166. * @param rigCameras defines cameras using this postprocess
  38167. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38168. * @param engine defines hosting engine
  38169. * @param reusable defines if the postprocess will be reused multiple times per frame
  38170. */
  38171. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38172. }
  38173. }
  38174. declare module BABYLON {
  38175. /**
  38176. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38177. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38178. */
  38179. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38180. /**
  38181. * Creates a new AnaglyphArcRotateCamera
  38182. * @param name defines camera name
  38183. * @param alpha defines alpha angle (in radians)
  38184. * @param beta defines beta angle (in radians)
  38185. * @param radius defines radius
  38186. * @param target defines camera target
  38187. * @param interaxialDistance defines distance between each color axis
  38188. * @param scene defines the hosting scene
  38189. */
  38190. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38191. /**
  38192. * Gets camera class name
  38193. * @returns AnaglyphArcRotateCamera
  38194. */
  38195. getClassName(): string;
  38196. }
  38197. }
  38198. declare module BABYLON {
  38199. /**
  38200. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38201. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38202. */
  38203. export class AnaglyphFreeCamera extends FreeCamera {
  38204. /**
  38205. * Creates a new AnaglyphFreeCamera
  38206. * @param name defines camera name
  38207. * @param position defines initial position
  38208. * @param interaxialDistance defines distance between each color axis
  38209. * @param scene defines the hosting scene
  38210. */
  38211. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38212. /**
  38213. * Gets camera class name
  38214. * @returns AnaglyphFreeCamera
  38215. */
  38216. getClassName(): string;
  38217. }
  38218. }
  38219. declare module BABYLON {
  38220. /**
  38221. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38222. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38223. */
  38224. export class AnaglyphGamepadCamera extends GamepadCamera {
  38225. /**
  38226. * Creates a new AnaglyphGamepadCamera
  38227. * @param name defines camera name
  38228. * @param position defines initial position
  38229. * @param interaxialDistance defines distance between each color axis
  38230. * @param scene defines the hosting scene
  38231. */
  38232. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38233. /**
  38234. * Gets camera class name
  38235. * @returns AnaglyphGamepadCamera
  38236. */
  38237. getClassName(): string;
  38238. }
  38239. }
  38240. declare module BABYLON {
  38241. /**
  38242. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38243. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38244. */
  38245. export class AnaglyphUniversalCamera extends UniversalCamera {
  38246. /**
  38247. * Creates a new AnaglyphUniversalCamera
  38248. * @param name defines camera name
  38249. * @param position defines initial position
  38250. * @param interaxialDistance defines distance between each color axis
  38251. * @param scene defines the hosting scene
  38252. */
  38253. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38254. /**
  38255. * Gets camera class name
  38256. * @returns AnaglyphUniversalCamera
  38257. */
  38258. getClassName(): string;
  38259. }
  38260. }
  38261. declare module BABYLON {
  38262. /** @hidden */
  38263. export var stereoscopicInterlacePixelShader: {
  38264. name: string;
  38265. shader: string;
  38266. };
  38267. }
  38268. declare module BABYLON {
  38269. /**
  38270. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38271. */
  38272. export class StereoscopicInterlacePostProcess extends PostProcess {
  38273. private _stepSize;
  38274. private _passedProcess;
  38275. /**
  38276. * Initializes a StereoscopicInterlacePostProcess
  38277. * @param name The name of the effect.
  38278. * @param rigCameras The rig cameras to be appled to the post process
  38279. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38280. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38281. * @param engine The engine which the post process will be applied. (default: current engine)
  38282. * @param reusable If the post process can be reused on the same frame. (default: false)
  38283. */
  38284. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38285. }
  38286. }
  38287. declare module BABYLON {
  38288. /**
  38289. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38290. * @see http://doc.babylonjs.com/features/cameras
  38291. */
  38292. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38293. /**
  38294. * Creates a new StereoscopicArcRotateCamera
  38295. * @param name defines camera name
  38296. * @param alpha defines alpha angle (in radians)
  38297. * @param beta defines beta angle (in radians)
  38298. * @param radius defines radius
  38299. * @param target defines camera target
  38300. * @param interaxialDistance defines distance between each color axis
  38301. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38302. * @param scene defines the hosting scene
  38303. */
  38304. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38305. /**
  38306. * Gets camera class name
  38307. * @returns StereoscopicArcRotateCamera
  38308. */
  38309. getClassName(): string;
  38310. }
  38311. }
  38312. declare module BABYLON {
  38313. /**
  38314. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38315. * @see http://doc.babylonjs.com/features/cameras
  38316. */
  38317. export class StereoscopicFreeCamera extends FreeCamera {
  38318. /**
  38319. * Creates a new StereoscopicFreeCamera
  38320. * @param name defines camera name
  38321. * @param position defines initial position
  38322. * @param interaxialDistance defines distance between each color axis
  38323. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38324. * @param scene defines the hosting scene
  38325. */
  38326. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38327. /**
  38328. * Gets camera class name
  38329. * @returns StereoscopicFreeCamera
  38330. */
  38331. getClassName(): string;
  38332. }
  38333. }
  38334. declare module BABYLON {
  38335. /**
  38336. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38337. * @see http://doc.babylonjs.com/features/cameras
  38338. */
  38339. export class StereoscopicGamepadCamera extends GamepadCamera {
  38340. /**
  38341. * Creates a new StereoscopicGamepadCamera
  38342. * @param name defines camera name
  38343. * @param position defines initial position
  38344. * @param interaxialDistance defines distance between each color axis
  38345. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38346. * @param scene defines the hosting scene
  38347. */
  38348. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38349. /**
  38350. * Gets camera class name
  38351. * @returns StereoscopicGamepadCamera
  38352. */
  38353. getClassName(): string;
  38354. }
  38355. }
  38356. declare module BABYLON {
  38357. /**
  38358. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38359. * @see http://doc.babylonjs.com/features/cameras
  38360. */
  38361. export class StereoscopicUniversalCamera extends UniversalCamera {
  38362. /**
  38363. * Creates a new StereoscopicUniversalCamera
  38364. * @param name defines camera name
  38365. * @param position defines initial position
  38366. * @param interaxialDistance defines distance between each color axis
  38367. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38368. * @param scene defines the hosting scene
  38369. */
  38370. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38371. /**
  38372. * Gets camera class name
  38373. * @returns StereoscopicUniversalCamera
  38374. */
  38375. getClassName(): string;
  38376. }
  38377. }
  38378. declare module BABYLON {
  38379. /**
  38380. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38381. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38382. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38383. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38384. */
  38385. export class VirtualJoysticksCamera extends FreeCamera {
  38386. /**
  38387. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38388. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38389. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38390. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38391. * @param name Define the name of the camera in the scene
  38392. * @param position Define the start position of the camera in the scene
  38393. * @param scene Define the scene the camera belongs to
  38394. */
  38395. constructor(name: string, position: Vector3, scene: Scene);
  38396. /**
  38397. * Gets the current object class name.
  38398. * @return the class name
  38399. */
  38400. getClassName(): string;
  38401. }
  38402. }
  38403. declare module BABYLON {
  38404. /**
  38405. * This represents all the required metrics to create a VR camera.
  38406. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38407. */
  38408. export class VRCameraMetrics {
  38409. /**
  38410. * Define the horizontal resolution off the screen.
  38411. */
  38412. hResolution: number;
  38413. /**
  38414. * Define the vertical resolution off the screen.
  38415. */
  38416. vResolution: number;
  38417. /**
  38418. * Define the horizontal screen size.
  38419. */
  38420. hScreenSize: number;
  38421. /**
  38422. * Define the vertical screen size.
  38423. */
  38424. vScreenSize: number;
  38425. /**
  38426. * Define the vertical screen center position.
  38427. */
  38428. vScreenCenter: number;
  38429. /**
  38430. * Define the distance of the eyes to the screen.
  38431. */
  38432. eyeToScreenDistance: number;
  38433. /**
  38434. * Define the distance between both lenses
  38435. */
  38436. lensSeparationDistance: number;
  38437. /**
  38438. * Define the distance between both viewer's eyes.
  38439. */
  38440. interpupillaryDistance: number;
  38441. /**
  38442. * Define the distortion factor of the VR postprocess.
  38443. * Please, touch with care.
  38444. */
  38445. distortionK: number[];
  38446. /**
  38447. * Define the chromatic aberration correction factors for the VR post process.
  38448. */
  38449. chromaAbCorrection: number[];
  38450. /**
  38451. * Define the scale factor of the post process.
  38452. * The smaller the better but the slower.
  38453. */
  38454. postProcessScaleFactor: number;
  38455. /**
  38456. * Define an offset for the lens center.
  38457. */
  38458. lensCenterOffset: number;
  38459. /**
  38460. * Define if the current vr camera should compensate the distortion of the lense or not.
  38461. */
  38462. compensateDistortion: boolean;
  38463. /**
  38464. * Defines if multiview should be enabled when rendering (Default: false)
  38465. */
  38466. multiviewEnabled: boolean;
  38467. /**
  38468. * Gets the rendering aspect ratio based on the provided resolutions.
  38469. */
  38470. readonly aspectRatio: number;
  38471. /**
  38472. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38473. */
  38474. readonly aspectRatioFov: number;
  38475. /**
  38476. * @hidden
  38477. */
  38478. readonly leftHMatrix: Matrix;
  38479. /**
  38480. * @hidden
  38481. */
  38482. readonly rightHMatrix: Matrix;
  38483. /**
  38484. * @hidden
  38485. */
  38486. readonly leftPreViewMatrix: Matrix;
  38487. /**
  38488. * @hidden
  38489. */
  38490. readonly rightPreViewMatrix: Matrix;
  38491. /**
  38492. * Get the default VRMetrics based on the most generic setup.
  38493. * @returns the default vr metrics
  38494. */
  38495. static GetDefault(): VRCameraMetrics;
  38496. }
  38497. }
  38498. declare module BABYLON {
  38499. /** @hidden */
  38500. export var vrDistortionCorrectionPixelShader: {
  38501. name: string;
  38502. shader: string;
  38503. };
  38504. }
  38505. declare module BABYLON {
  38506. /**
  38507. * VRDistortionCorrectionPostProcess used for mobile VR
  38508. */
  38509. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38510. private _isRightEye;
  38511. private _distortionFactors;
  38512. private _postProcessScaleFactor;
  38513. private _lensCenterOffset;
  38514. private _scaleIn;
  38515. private _scaleFactor;
  38516. private _lensCenter;
  38517. /**
  38518. * Initializes the VRDistortionCorrectionPostProcess
  38519. * @param name The name of the effect.
  38520. * @param camera The camera to apply the render pass to.
  38521. * @param isRightEye If this is for the right eye distortion
  38522. * @param vrMetrics All the required metrics for the VR camera
  38523. */
  38524. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38525. }
  38526. }
  38527. declare module BABYLON {
  38528. /**
  38529. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38530. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38531. */
  38532. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38533. /**
  38534. * Creates a new VRDeviceOrientationArcRotateCamera
  38535. * @param name defines camera name
  38536. * @param alpha defines the camera rotation along the logitudinal axis
  38537. * @param beta defines the camera rotation along the latitudinal axis
  38538. * @param radius defines the camera distance from its target
  38539. * @param target defines the camera target
  38540. * @param scene defines the scene the camera belongs to
  38541. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38542. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38543. */
  38544. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38545. /**
  38546. * Gets camera class name
  38547. * @returns VRDeviceOrientationArcRotateCamera
  38548. */
  38549. getClassName(): string;
  38550. }
  38551. }
  38552. declare module BABYLON {
  38553. /**
  38554. * Camera used to simulate VR rendering (based on FreeCamera)
  38555. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38556. */
  38557. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38558. /**
  38559. * Creates a new VRDeviceOrientationFreeCamera
  38560. * @param name defines camera name
  38561. * @param position defines the start position of the camera
  38562. * @param scene defines the scene the camera belongs to
  38563. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38564. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38565. */
  38566. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38567. /**
  38568. * Gets camera class name
  38569. * @returns VRDeviceOrientationFreeCamera
  38570. */
  38571. getClassName(): string;
  38572. }
  38573. }
  38574. declare module BABYLON {
  38575. /**
  38576. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38577. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38578. */
  38579. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38580. /**
  38581. * Creates a new VRDeviceOrientationGamepadCamera
  38582. * @param name defines camera name
  38583. * @param position defines the start position of the camera
  38584. * @param scene defines the scene the camera belongs to
  38585. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38586. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38587. */
  38588. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38589. /**
  38590. * Gets camera class name
  38591. * @returns VRDeviceOrientationGamepadCamera
  38592. */
  38593. getClassName(): string;
  38594. }
  38595. }
  38596. declare module BABYLON {
  38597. /**
  38598. * Base class of materials working in push mode in babylon JS
  38599. * @hidden
  38600. */
  38601. export class PushMaterial extends Material {
  38602. protected _activeEffect: Effect;
  38603. protected _normalMatrix: Matrix;
  38604. /**
  38605. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38606. * This means that the material can keep using a previous shader while a new one is being compiled.
  38607. * This is mostly used when shader parallel compilation is supported (true by default)
  38608. */
  38609. allowShaderHotSwapping: boolean;
  38610. constructor(name: string, scene: Scene);
  38611. getEffect(): Effect;
  38612. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38613. /**
  38614. * Binds the given world matrix to the active effect
  38615. *
  38616. * @param world the matrix to bind
  38617. */
  38618. bindOnlyWorldMatrix(world: Matrix): void;
  38619. /**
  38620. * Binds the given normal matrix to the active effect
  38621. *
  38622. * @param normalMatrix the matrix to bind
  38623. */
  38624. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38625. bind(world: Matrix, mesh?: Mesh): void;
  38626. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38627. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38628. }
  38629. }
  38630. declare module BABYLON {
  38631. /**
  38632. * This groups all the flags used to control the materials channel.
  38633. */
  38634. export class MaterialFlags {
  38635. private static _DiffuseTextureEnabled;
  38636. /**
  38637. * Are diffuse textures enabled in the application.
  38638. */
  38639. static DiffuseTextureEnabled: boolean;
  38640. private static _AmbientTextureEnabled;
  38641. /**
  38642. * Are ambient textures enabled in the application.
  38643. */
  38644. static AmbientTextureEnabled: boolean;
  38645. private static _OpacityTextureEnabled;
  38646. /**
  38647. * Are opacity textures enabled in the application.
  38648. */
  38649. static OpacityTextureEnabled: boolean;
  38650. private static _ReflectionTextureEnabled;
  38651. /**
  38652. * Are reflection textures enabled in the application.
  38653. */
  38654. static ReflectionTextureEnabled: boolean;
  38655. private static _EmissiveTextureEnabled;
  38656. /**
  38657. * Are emissive textures enabled in the application.
  38658. */
  38659. static EmissiveTextureEnabled: boolean;
  38660. private static _SpecularTextureEnabled;
  38661. /**
  38662. * Are specular textures enabled in the application.
  38663. */
  38664. static SpecularTextureEnabled: boolean;
  38665. private static _BumpTextureEnabled;
  38666. /**
  38667. * Are bump textures enabled in the application.
  38668. */
  38669. static BumpTextureEnabled: boolean;
  38670. private static _LightmapTextureEnabled;
  38671. /**
  38672. * Are lightmap textures enabled in the application.
  38673. */
  38674. static LightmapTextureEnabled: boolean;
  38675. private static _RefractionTextureEnabled;
  38676. /**
  38677. * Are refraction textures enabled in the application.
  38678. */
  38679. static RefractionTextureEnabled: boolean;
  38680. private static _ColorGradingTextureEnabled;
  38681. /**
  38682. * Are color grading textures enabled in the application.
  38683. */
  38684. static ColorGradingTextureEnabled: boolean;
  38685. private static _FresnelEnabled;
  38686. /**
  38687. * Are fresnels enabled in the application.
  38688. */
  38689. static FresnelEnabled: boolean;
  38690. private static _ClearCoatTextureEnabled;
  38691. /**
  38692. * Are clear coat textures enabled in the application.
  38693. */
  38694. static ClearCoatTextureEnabled: boolean;
  38695. private static _ClearCoatBumpTextureEnabled;
  38696. /**
  38697. * Are clear coat bump textures enabled in the application.
  38698. */
  38699. static ClearCoatBumpTextureEnabled: boolean;
  38700. private static _ClearCoatTintTextureEnabled;
  38701. /**
  38702. * Are clear coat tint textures enabled in the application.
  38703. */
  38704. static ClearCoatTintTextureEnabled: boolean;
  38705. private static _SheenTextureEnabled;
  38706. /**
  38707. * Are sheen textures enabled in the application.
  38708. */
  38709. static SheenTextureEnabled: boolean;
  38710. private static _AnisotropicTextureEnabled;
  38711. /**
  38712. * Are anisotropic textures enabled in the application.
  38713. */
  38714. static AnisotropicTextureEnabled: boolean;
  38715. private static _ThicknessTextureEnabled;
  38716. /**
  38717. * Are thickness textures enabled in the application.
  38718. */
  38719. static ThicknessTextureEnabled: boolean;
  38720. }
  38721. }
  38722. declare module BABYLON {
  38723. /** @hidden */
  38724. export var defaultFragmentDeclaration: {
  38725. name: string;
  38726. shader: string;
  38727. };
  38728. }
  38729. declare module BABYLON {
  38730. /** @hidden */
  38731. export var defaultUboDeclaration: {
  38732. name: string;
  38733. shader: string;
  38734. };
  38735. }
  38736. declare module BABYLON {
  38737. /** @hidden */
  38738. export var lightFragmentDeclaration: {
  38739. name: string;
  38740. shader: string;
  38741. };
  38742. }
  38743. declare module BABYLON {
  38744. /** @hidden */
  38745. export var lightUboDeclaration: {
  38746. name: string;
  38747. shader: string;
  38748. };
  38749. }
  38750. declare module BABYLON {
  38751. /** @hidden */
  38752. export var lightsFragmentFunctions: {
  38753. name: string;
  38754. shader: string;
  38755. };
  38756. }
  38757. declare module BABYLON {
  38758. /** @hidden */
  38759. export var shadowsFragmentFunctions: {
  38760. name: string;
  38761. shader: string;
  38762. };
  38763. }
  38764. declare module BABYLON {
  38765. /** @hidden */
  38766. export var fresnelFunction: {
  38767. name: string;
  38768. shader: string;
  38769. };
  38770. }
  38771. declare module BABYLON {
  38772. /** @hidden */
  38773. export var reflectionFunction: {
  38774. name: string;
  38775. shader: string;
  38776. };
  38777. }
  38778. declare module BABYLON {
  38779. /** @hidden */
  38780. export var bumpFragmentFunctions: {
  38781. name: string;
  38782. shader: string;
  38783. };
  38784. }
  38785. declare module BABYLON {
  38786. /** @hidden */
  38787. export var logDepthDeclaration: {
  38788. name: string;
  38789. shader: string;
  38790. };
  38791. }
  38792. declare module BABYLON {
  38793. /** @hidden */
  38794. export var bumpFragment: {
  38795. name: string;
  38796. shader: string;
  38797. };
  38798. }
  38799. declare module BABYLON {
  38800. /** @hidden */
  38801. export var depthPrePass: {
  38802. name: string;
  38803. shader: string;
  38804. };
  38805. }
  38806. declare module BABYLON {
  38807. /** @hidden */
  38808. export var lightFragment: {
  38809. name: string;
  38810. shader: string;
  38811. };
  38812. }
  38813. declare module BABYLON {
  38814. /** @hidden */
  38815. export var logDepthFragment: {
  38816. name: string;
  38817. shader: string;
  38818. };
  38819. }
  38820. declare module BABYLON {
  38821. /** @hidden */
  38822. export var defaultPixelShader: {
  38823. name: string;
  38824. shader: string;
  38825. };
  38826. }
  38827. declare module BABYLON {
  38828. /** @hidden */
  38829. export var defaultVertexDeclaration: {
  38830. name: string;
  38831. shader: string;
  38832. };
  38833. }
  38834. declare module BABYLON {
  38835. /** @hidden */
  38836. export var bumpVertexDeclaration: {
  38837. name: string;
  38838. shader: string;
  38839. };
  38840. }
  38841. declare module BABYLON {
  38842. /** @hidden */
  38843. export var bumpVertex: {
  38844. name: string;
  38845. shader: string;
  38846. };
  38847. }
  38848. declare module BABYLON {
  38849. /** @hidden */
  38850. export var fogVertex: {
  38851. name: string;
  38852. shader: string;
  38853. };
  38854. }
  38855. declare module BABYLON {
  38856. /** @hidden */
  38857. export var shadowsVertex: {
  38858. name: string;
  38859. shader: string;
  38860. };
  38861. }
  38862. declare module BABYLON {
  38863. /** @hidden */
  38864. export var pointCloudVertex: {
  38865. name: string;
  38866. shader: string;
  38867. };
  38868. }
  38869. declare module BABYLON {
  38870. /** @hidden */
  38871. export var logDepthVertex: {
  38872. name: string;
  38873. shader: string;
  38874. };
  38875. }
  38876. declare module BABYLON {
  38877. /** @hidden */
  38878. export var defaultVertexShader: {
  38879. name: string;
  38880. shader: string;
  38881. };
  38882. }
  38883. declare module BABYLON {
  38884. /** @hidden */
  38885. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38886. MAINUV1: boolean;
  38887. MAINUV2: boolean;
  38888. DIFFUSE: boolean;
  38889. DIFFUSEDIRECTUV: number;
  38890. AMBIENT: boolean;
  38891. AMBIENTDIRECTUV: number;
  38892. OPACITY: boolean;
  38893. OPACITYDIRECTUV: number;
  38894. OPACITYRGB: boolean;
  38895. REFLECTION: boolean;
  38896. EMISSIVE: boolean;
  38897. EMISSIVEDIRECTUV: number;
  38898. SPECULAR: boolean;
  38899. SPECULARDIRECTUV: number;
  38900. BUMP: boolean;
  38901. BUMPDIRECTUV: number;
  38902. PARALLAX: boolean;
  38903. PARALLAXOCCLUSION: boolean;
  38904. SPECULAROVERALPHA: boolean;
  38905. CLIPPLANE: boolean;
  38906. CLIPPLANE2: boolean;
  38907. CLIPPLANE3: boolean;
  38908. CLIPPLANE4: boolean;
  38909. ALPHATEST: boolean;
  38910. DEPTHPREPASS: boolean;
  38911. ALPHAFROMDIFFUSE: boolean;
  38912. POINTSIZE: boolean;
  38913. FOG: boolean;
  38914. SPECULARTERM: boolean;
  38915. DIFFUSEFRESNEL: boolean;
  38916. OPACITYFRESNEL: boolean;
  38917. REFLECTIONFRESNEL: boolean;
  38918. REFRACTIONFRESNEL: boolean;
  38919. EMISSIVEFRESNEL: boolean;
  38920. FRESNEL: boolean;
  38921. NORMAL: boolean;
  38922. UV1: boolean;
  38923. UV2: boolean;
  38924. VERTEXCOLOR: boolean;
  38925. VERTEXALPHA: boolean;
  38926. NUM_BONE_INFLUENCERS: number;
  38927. BonesPerMesh: number;
  38928. BONETEXTURE: boolean;
  38929. INSTANCES: boolean;
  38930. GLOSSINESS: boolean;
  38931. ROUGHNESS: boolean;
  38932. EMISSIVEASILLUMINATION: boolean;
  38933. LINKEMISSIVEWITHDIFFUSE: boolean;
  38934. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38935. LIGHTMAP: boolean;
  38936. LIGHTMAPDIRECTUV: number;
  38937. OBJECTSPACE_NORMALMAP: boolean;
  38938. USELIGHTMAPASSHADOWMAP: boolean;
  38939. REFLECTIONMAP_3D: boolean;
  38940. REFLECTIONMAP_SPHERICAL: boolean;
  38941. REFLECTIONMAP_PLANAR: boolean;
  38942. REFLECTIONMAP_CUBIC: boolean;
  38943. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38944. REFLECTIONMAP_PROJECTION: boolean;
  38945. REFLECTIONMAP_SKYBOX: boolean;
  38946. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38947. REFLECTIONMAP_EXPLICIT: boolean;
  38948. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38949. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38950. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38951. INVERTCUBICMAP: boolean;
  38952. LOGARITHMICDEPTH: boolean;
  38953. REFRACTION: boolean;
  38954. REFRACTIONMAP_3D: boolean;
  38955. REFLECTIONOVERALPHA: boolean;
  38956. TWOSIDEDLIGHTING: boolean;
  38957. SHADOWFLOAT: boolean;
  38958. MORPHTARGETS: boolean;
  38959. MORPHTARGETS_NORMAL: boolean;
  38960. MORPHTARGETS_TANGENT: boolean;
  38961. NUM_MORPH_INFLUENCERS: number;
  38962. NONUNIFORMSCALING: boolean;
  38963. PREMULTIPLYALPHA: boolean;
  38964. IMAGEPROCESSING: boolean;
  38965. VIGNETTE: boolean;
  38966. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38967. VIGNETTEBLENDMODEOPAQUE: boolean;
  38968. TONEMAPPING: boolean;
  38969. TONEMAPPING_ACES: boolean;
  38970. CONTRAST: boolean;
  38971. COLORCURVES: boolean;
  38972. COLORGRADING: boolean;
  38973. COLORGRADING3D: boolean;
  38974. SAMPLER3DGREENDEPTH: boolean;
  38975. SAMPLER3DBGRMAP: boolean;
  38976. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38977. MULTIVIEW: boolean;
  38978. /**
  38979. * If the reflection texture on this material is in linear color space
  38980. * @hidden
  38981. */
  38982. IS_REFLECTION_LINEAR: boolean;
  38983. /**
  38984. * If the refraction texture on this material is in linear color space
  38985. * @hidden
  38986. */
  38987. IS_REFRACTION_LINEAR: boolean;
  38988. EXPOSURE: boolean;
  38989. constructor();
  38990. setReflectionMode(modeToEnable: string): void;
  38991. }
  38992. /**
  38993. * This is the default material used in Babylon. It is the best trade off between quality
  38994. * and performances.
  38995. * @see http://doc.babylonjs.com/babylon101/materials
  38996. */
  38997. export class StandardMaterial extends PushMaterial {
  38998. private _diffuseTexture;
  38999. /**
  39000. * The basic texture of the material as viewed under a light.
  39001. */
  39002. diffuseTexture: Nullable<BaseTexture>;
  39003. private _ambientTexture;
  39004. /**
  39005. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39006. */
  39007. ambientTexture: Nullable<BaseTexture>;
  39008. private _opacityTexture;
  39009. /**
  39010. * Define the transparency of the material from a texture.
  39011. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39012. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39013. */
  39014. opacityTexture: Nullable<BaseTexture>;
  39015. private _reflectionTexture;
  39016. /**
  39017. * Define the texture used to display the reflection.
  39018. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39019. */
  39020. reflectionTexture: Nullable<BaseTexture>;
  39021. private _emissiveTexture;
  39022. /**
  39023. * Define texture of the material as if self lit.
  39024. * This will be mixed in the final result even in the absence of light.
  39025. */
  39026. emissiveTexture: Nullable<BaseTexture>;
  39027. private _specularTexture;
  39028. /**
  39029. * Define how the color and intensity of the highlight given by the light in the material.
  39030. */
  39031. specularTexture: Nullable<BaseTexture>;
  39032. private _bumpTexture;
  39033. /**
  39034. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39035. * 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.
  39036. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39037. */
  39038. bumpTexture: Nullable<BaseTexture>;
  39039. private _lightmapTexture;
  39040. /**
  39041. * Complex lighting can be computationally expensive to compute at runtime.
  39042. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39043. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39044. */
  39045. lightmapTexture: Nullable<BaseTexture>;
  39046. private _refractionTexture;
  39047. /**
  39048. * Define the texture used to display the refraction.
  39049. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39050. */
  39051. refractionTexture: Nullable<BaseTexture>;
  39052. /**
  39053. * The color of the material lit by the environmental background lighting.
  39054. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39055. */
  39056. ambientColor: Color3;
  39057. /**
  39058. * The basic color of the material as viewed under a light.
  39059. */
  39060. diffuseColor: Color3;
  39061. /**
  39062. * Define how the color and intensity of the highlight given by the light in the material.
  39063. */
  39064. specularColor: Color3;
  39065. /**
  39066. * Define the color of the material as if self lit.
  39067. * This will be mixed in the final result even in the absence of light.
  39068. */
  39069. emissiveColor: Color3;
  39070. /**
  39071. * Defines how sharp are the highlights in the material.
  39072. * The bigger the value the sharper giving a more glossy feeling to the result.
  39073. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39074. */
  39075. specularPower: number;
  39076. private _useAlphaFromDiffuseTexture;
  39077. /**
  39078. * Does the transparency come from the diffuse texture alpha channel.
  39079. */
  39080. useAlphaFromDiffuseTexture: boolean;
  39081. private _useEmissiveAsIllumination;
  39082. /**
  39083. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39084. */
  39085. useEmissiveAsIllumination: boolean;
  39086. private _linkEmissiveWithDiffuse;
  39087. /**
  39088. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39089. * the emissive level when the final color is close to one.
  39090. */
  39091. linkEmissiveWithDiffuse: boolean;
  39092. private _useSpecularOverAlpha;
  39093. /**
  39094. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39095. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39096. */
  39097. useSpecularOverAlpha: boolean;
  39098. private _useReflectionOverAlpha;
  39099. /**
  39100. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39101. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39102. */
  39103. useReflectionOverAlpha: boolean;
  39104. private _disableLighting;
  39105. /**
  39106. * Does lights from the scene impacts this material.
  39107. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39108. */
  39109. disableLighting: boolean;
  39110. private _useObjectSpaceNormalMap;
  39111. /**
  39112. * Allows using an object space normal map (instead of tangent space).
  39113. */
  39114. useObjectSpaceNormalMap: boolean;
  39115. private _useParallax;
  39116. /**
  39117. * Is parallax enabled or not.
  39118. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39119. */
  39120. useParallax: boolean;
  39121. private _useParallaxOcclusion;
  39122. /**
  39123. * Is parallax occlusion enabled or not.
  39124. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39125. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39126. */
  39127. useParallaxOcclusion: boolean;
  39128. /**
  39129. * 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.
  39130. */
  39131. parallaxScaleBias: number;
  39132. private _roughness;
  39133. /**
  39134. * Helps to define how blurry the reflections should appears in the material.
  39135. */
  39136. roughness: number;
  39137. /**
  39138. * In case of refraction, define the value of the indice of refraction.
  39139. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39140. */
  39141. indexOfRefraction: number;
  39142. /**
  39143. * Invert the refraction texture alongside the y axis.
  39144. * It can be useful with procedural textures or probe for instance.
  39145. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39146. */
  39147. invertRefractionY: boolean;
  39148. /**
  39149. * Defines the alpha limits in alpha test mode.
  39150. */
  39151. alphaCutOff: number;
  39152. private _useLightmapAsShadowmap;
  39153. /**
  39154. * In case of light mapping, define whether the map contains light or shadow informations.
  39155. */
  39156. useLightmapAsShadowmap: boolean;
  39157. private _diffuseFresnelParameters;
  39158. /**
  39159. * Define the diffuse fresnel parameters of the material.
  39160. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39161. */
  39162. diffuseFresnelParameters: FresnelParameters;
  39163. private _opacityFresnelParameters;
  39164. /**
  39165. * Define the opacity fresnel parameters of the material.
  39166. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39167. */
  39168. opacityFresnelParameters: FresnelParameters;
  39169. private _reflectionFresnelParameters;
  39170. /**
  39171. * Define the reflection fresnel parameters of the material.
  39172. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39173. */
  39174. reflectionFresnelParameters: FresnelParameters;
  39175. private _refractionFresnelParameters;
  39176. /**
  39177. * Define the refraction fresnel parameters of the material.
  39178. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39179. */
  39180. refractionFresnelParameters: FresnelParameters;
  39181. private _emissiveFresnelParameters;
  39182. /**
  39183. * Define the emissive fresnel parameters of the material.
  39184. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39185. */
  39186. emissiveFresnelParameters: FresnelParameters;
  39187. private _useReflectionFresnelFromSpecular;
  39188. /**
  39189. * If true automatically deducts the fresnels values from the material specularity.
  39190. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39191. */
  39192. useReflectionFresnelFromSpecular: boolean;
  39193. private _useGlossinessFromSpecularMapAlpha;
  39194. /**
  39195. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39196. */
  39197. useGlossinessFromSpecularMapAlpha: boolean;
  39198. private _maxSimultaneousLights;
  39199. /**
  39200. * Defines the maximum number of lights that can be used in the material
  39201. */
  39202. maxSimultaneousLights: number;
  39203. private _invertNormalMapX;
  39204. /**
  39205. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39206. */
  39207. invertNormalMapX: boolean;
  39208. private _invertNormalMapY;
  39209. /**
  39210. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39211. */
  39212. invertNormalMapY: boolean;
  39213. private _twoSidedLighting;
  39214. /**
  39215. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39216. */
  39217. twoSidedLighting: boolean;
  39218. /**
  39219. * Default configuration related to image processing available in the standard Material.
  39220. */
  39221. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39222. /**
  39223. * Gets the image processing configuration used either in this material.
  39224. */
  39225. /**
  39226. * Sets the Default image processing configuration used either in the this material.
  39227. *
  39228. * If sets to null, the scene one is in use.
  39229. */
  39230. imageProcessingConfiguration: ImageProcessingConfiguration;
  39231. /**
  39232. * Keep track of the image processing observer to allow dispose and replace.
  39233. */
  39234. private _imageProcessingObserver;
  39235. /**
  39236. * Attaches a new image processing configuration to the Standard Material.
  39237. * @param configuration
  39238. */
  39239. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39240. /**
  39241. * Gets wether the color curves effect is enabled.
  39242. */
  39243. /**
  39244. * Sets wether the color curves effect is enabled.
  39245. */
  39246. cameraColorCurvesEnabled: boolean;
  39247. /**
  39248. * Gets wether the color grading effect is enabled.
  39249. */
  39250. /**
  39251. * Gets wether the color grading effect is enabled.
  39252. */
  39253. cameraColorGradingEnabled: boolean;
  39254. /**
  39255. * Gets wether tonemapping is enabled or not.
  39256. */
  39257. /**
  39258. * Sets wether tonemapping is enabled or not
  39259. */
  39260. cameraToneMappingEnabled: boolean;
  39261. /**
  39262. * The camera exposure used on this material.
  39263. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39264. * This corresponds to a photographic exposure.
  39265. */
  39266. /**
  39267. * The camera exposure used on this material.
  39268. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39269. * This corresponds to a photographic exposure.
  39270. */
  39271. cameraExposure: number;
  39272. /**
  39273. * Gets The camera contrast used on this material.
  39274. */
  39275. /**
  39276. * Sets The camera contrast used on this material.
  39277. */
  39278. cameraContrast: number;
  39279. /**
  39280. * Gets the Color Grading 2D Lookup Texture.
  39281. */
  39282. /**
  39283. * Sets the Color Grading 2D Lookup Texture.
  39284. */
  39285. cameraColorGradingTexture: Nullable<BaseTexture>;
  39286. /**
  39287. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39288. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39289. * 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;
  39290. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39291. */
  39292. /**
  39293. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39294. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39295. * 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;
  39296. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39297. */
  39298. cameraColorCurves: Nullable<ColorCurves>;
  39299. /**
  39300. * Custom callback helping to override the default shader used in the material.
  39301. */
  39302. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39303. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39304. protected _worldViewProjectionMatrix: Matrix;
  39305. protected _globalAmbientColor: Color3;
  39306. protected _useLogarithmicDepth: boolean;
  39307. /**
  39308. * Instantiates a new standard material.
  39309. * This is the default material used in Babylon. It is the best trade off between quality
  39310. * and performances.
  39311. * @see http://doc.babylonjs.com/babylon101/materials
  39312. * @param name Define the name of the material in the scene
  39313. * @param scene Define the scene the material belong to
  39314. */
  39315. constructor(name: string, scene: Scene);
  39316. /**
  39317. * Gets a boolean indicating that current material needs to register RTT
  39318. */
  39319. readonly hasRenderTargetTextures: boolean;
  39320. /**
  39321. * Gets the current class name of the material e.g. "StandardMaterial"
  39322. * Mainly use in serialization.
  39323. * @returns the class name
  39324. */
  39325. getClassName(): string;
  39326. /**
  39327. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39328. * You can try switching to logarithmic depth.
  39329. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39330. */
  39331. useLogarithmicDepth: boolean;
  39332. /**
  39333. * Specifies if the material will require alpha blending
  39334. * @returns a boolean specifying if alpha blending is needed
  39335. */
  39336. needAlphaBlending(): boolean;
  39337. /**
  39338. * Specifies if this material should be rendered in alpha test mode
  39339. * @returns a boolean specifying if an alpha test is needed.
  39340. */
  39341. needAlphaTesting(): boolean;
  39342. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39343. /**
  39344. * Get the texture used for alpha test purpose.
  39345. * @returns the diffuse texture in case of the standard material.
  39346. */
  39347. getAlphaTestTexture(): Nullable<BaseTexture>;
  39348. /**
  39349. * Get if the submesh is ready to be used and all its information available.
  39350. * Child classes can use it to update shaders
  39351. * @param mesh defines the mesh to check
  39352. * @param subMesh defines which submesh to check
  39353. * @param useInstances specifies that instances should be used
  39354. * @returns a boolean indicating that the submesh is ready or not
  39355. */
  39356. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39357. /**
  39358. * Builds the material UBO layouts.
  39359. * Used internally during the effect preparation.
  39360. */
  39361. buildUniformLayout(): void;
  39362. /**
  39363. * Unbinds the material from the mesh
  39364. */
  39365. unbind(): void;
  39366. /**
  39367. * Binds the submesh to this material by preparing the effect and shader to draw
  39368. * @param world defines the world transformation matrix
  39369. * @param mesh defines the mesh containing the submesh
  39370. * @param subMesh defines the submesh to bind the material to
  39371. */
  39372. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39373. /**
  39374. * Get the list of animatables in the material.
  39375. * @returns the list of animatables object used in the material
  39376. */
  39377. getAnimatables(): IAnimatable[];
  39378. /**
  39379. * Gets the active textures from the material
  39380. * @returns an array of textures
  39381. */
  39382. getActiveTextures(): BaseTexture[];
  39383. /**
  39384. * Specifies if the material uses a texture
  39385. * @param texture defines the texture to check against the material
  39386. * @returns a boolean specifying if the material uses the texture
  39387. */
  39388. hasTexture(texture: BaseTexture): boolean;
  39389. /**
  39390. * Disposes the material
  39391. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39392. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39393. */
  39394. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39395. /**
  39396. * Makes a duplicate of the material, and gives it a new name
  39397. * @param name defines the new name for the duplicated material
  39398. * @returns the cloned material
  39399. */
  39400. clone(name: string): StandardMaterial;
  39401. /**
  39402. * Serializes this material in a JSON representation
  39403. * @returns the serialized material object
  39404. */
  39405. serialize(): any;
  39406. /**
  39407. * Creates a standard material from parsed material data
  39408. * @param source defines the JSON representation of the material
  39409. * @param scene defines the hosting scene
  39410. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39411. * @returns a new standard material
  39412. */
  39413. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39414. /**
  39415. * Are diffuse textures enabled in the application.
  39416. */
  39417. static DiffuseTextureEnabled: boolean;
  39418. /**
  39419. * Are ambient textures enabled in the application.
  39420. */
  39421. static AmbientTextureEnabled: boolean;
  39422. /**
  39423. * Are opacity textures enabled in the application.
  39424. */
  39425. static OpacityTextureEnabled: boolean;
  39426. /**
  39427. * Are reflection textures enabled in the application.
  39428. */
  39429. static ReflectionTextureEnabled: boolean;
  39430. /**
  39431. * Are emissive textures enabled in the application.
  39432. */
  39433. static EmissiveTextureEnabled: boolean;
  39434. /**
  39435. * Are specular textures enabled in the application.
  39436. */
  39437. static SpecularTextureEnabled: boolean;
  39438. /**
  39439. * Are bump textures enabled in the application.
  39440. */
  39441. static BumpTextureEnabled: boolean;
  39442. /**
  39443. * Are lightmap textures enabled in the application.
  39444. */
  39445. static LightmapTextureEnabled: boolean;
  39446. /**
  39447. * Are refraction textures enabled in the application.
  39448. */
  39449. static RefractionTextureEnabled: boolean;
  39450. /**
  39451. * Are color grading textures enabled in the application.
  39452. */
  39453. static ColorGradingTextureEnabled: boolean;
  39454. /**
  39455. * Are fresnels enabled in the application.
  39456. */
  39457. static FresnelEnabled: boolean;
  39458. }
  39459. }
  39460. declare module BABYLON {
  39461. /**
  39462. * A class extending Texture allowing drawing on a texture
  39463. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39464. */
  39465. export class DynamicTexture extends Texture {
  39466. private _generateMipMaps;
  39467. private _canvas;
  39468. private _context;
  39469. private _engine;
  39470. /**
  39471. * Creates a DynamicTexture
  39472. * @param name defines the name of the texture
  39473. * @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
  39474. * @param scene defines the scene where you want the texture
  39475. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39476. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39477. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39478. */
  39479. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39480. /**
  39481. * Get the current class name of the texture useful for serialization or dynamic coding.
  39482. * @returns "DynamicTexture"
  39483. */
  39484. getClassName(): string;
  39485. /**
  39486. * Gets the current state of canRescale
  39487. */
  39488. readonly canRescale: boolean;
  39489. private _recreate;
  39490. /**
  39491. * Scales the texture
  39492. * @param ratio the scale factor to apply to both width and height
  39493. */
  39494. scale(ratio: number): void;
  39495. /**
  39496. * Resizes the texture
  39497. * @param width the new width
  39498. * @param height the new height
  39499. */
  39500. scaleTo(width: number, height: number): void;
  39501. /**
  39502. * Gets the context of the canvas used by the texture
  39503. * @returns the canvas context of the dynamic texture
  39504. */
  39505. getContext(): CanvasRenderingContext2D;
  39506. /**
  39507. * Clears the texture
  39508. */
  39509. clear(): void;
  39510. /**
  39511. * Updates the texture
  39512. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39513. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39514. */
  39515. update(invertY?: boolean, premulAlpha?: boolean): void;
  39516. /**
  39517. * Draws text onto the texture
  39518. * @param text defines the text to be drawn
  39519. * @param x defines the placement of the text from the left
  39520. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39521. * @param font defines the font to be used with font-style, font-size, font-name
  39522. * @param color defines the color used for the text
  39523. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39524. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39525. * @param update defines whether texture is immediately update (default is true)
  39526. */
  39527. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39528. /**
  39529. * Clones the texture
  39530. * @returns the clone of the texture.
  39531. */
  39532. clone(): DynamicTexture;
  39533. /**
  39534. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39535. * @returns a serialized dynamic texture object
  39536. */
  39537. serialize(): any;
  39538. /** @hidden */
  39539. _rebuild(): void;
  39540. }
  39541. }
  39542. declare module BABYLON {
  39543. /** @hidden */
  39544. export var imageProcessingPixelShader: {
  39545. name: string;
  39546. shader: string;
  39547. };
  39548. }
  39549. declare module BABYLON {
  39550. /**
  39551. * ImageProcessingPostProcess
  39552. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39553. */
  39554. export class ImageProcessingPostProcess extends PostProcess {
  39555. /**
  39556. * Default configuration related to image processing available in the PBR Material.
  39557. */
  39558. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39559. /**
  39560. * Gets the image processing configuration used either in this material.
  39561. */
  39562. /**
  39563. * Sets the Default image processing configuration used either in the this material.
  39564. *
  39565. * If sets to null, the scene one is in use.
  39566. */
  39567. imageProcessingConfiguration: ImageProcessingConfiguration;
  39568. /**
  39569. * Keep track of the image processing observer to allow dispose and replace.
  39570. */
  39571. private _imageProcessingObserver;
  39572. /**
  39573. * Attaches a new image processing configuration to the PBR Material.
  39574. * @param configuration
  39575. */
  39576. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39577. /**
  39578. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39579. */
  39580. /**
  39581. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39582. */
  39583. colorCurves: Nullable<ColorCurves>;
  39584. /**
  39585. * Gets wether the color curves effect is enabled.
  39586. */
  39587. /**
  39588. * Sets wether the color curves effect is enabled.
  39589. */
  39590. colorCurvesEnabled: boolean;
  39591. /**
  39592. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39593. */
  39594. /**
  39595. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39596. */
  39597. colorGradingTexture: Nullable<BaseTexture>;
  39598. /**
  39599. * Gets wether the color grading effect is enabled.
  39600. */
  39601. /**
  39602. * Gets wether the color grading effect is enabled.
  39603. */
  39604. colorGradingEnabled: boolean;
  39605. /**
  39606. * Gets exposure used in the effect.
  39607. */
  39608. /**
  39609. * Sets exposure used in the effect.
  39610. */
  39611. exposure: number;
  39612. /**
  39613. * Gets wether tonemapping is enabled or not.
  39614. */
  39615. /**
  39616. * Sets wether tonemapping is enabled or not
  39617. */
  39618. toneMappingEnabled: boolean;
  39619. /**
  39620. * Gets the type of tone mapping effect.
  39621. */
  39622. /**
  39623. * Sets the type of tone mapping effect.
  39624. */
  39625. toneMappingType: number;
  39626. /**
  39627. * Gets contrast used in the effect.
  39628. */
  39629. /**
  39630. * Sets contrast used in the effect.
  39631. */
  39632. contrast: number;
  39633. /**
  39634. * Gets Vignette stretch size.
  39635. */
  39636. /**
  39637. * Sets Vignette stretch size.
  39638. */
  39639. vignetteStretch: number;
  39640. /**
  39641. * Gets Vignette centre X Offset.
  39642. */
  39643. /**
  39644. * Sets Vignette centre X Offset.
  39645. */
  39646. vignetteCentreX: number;
  39647. /**
  39648. * Gets Vignette centre Y Offset.
  39649. */
  39650. /**
  39651. * Sets Vignette centre Y Offset.
  39652. */
  39653. vignetteCentreY: number;
  39654. /**
  39655. * Gets Vignette weight or intensity of the vignette effect.
  39656. */
  39657. /**
  39658. * Sets Vignette weight or intensity of the vignette effect.
  39659. */
  39660. vignetteWeight: number;
  39661. /**
  39662. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39663. * if vignetteEnabled is set to true.
  39664. */
  39665. /**
  39666. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39667. * if vignetteEnabled is set to true.
  39668. */
  39669. vignetteColor: Color4;
  39670. /**
  39671. * Gets Camera field of view used by the Vignette effect.
  39672. */
  39673. /**
  39674. * Sets Camera field of view used by the Vignette effect.
  39675. */
  39676. vignetteCameraFov: number;
  39677. /**
  39678. * Gets the vignette blend mode allowing different kind of effect.
  39679. */
  39680. /**
  39681. * Sets the vignette blend mode allowing different kind of effect.
  39682. */
  39683. vignetteBlendMode: number;
  39684. /**
  39685. * Gets wether the vignette effect is enabled.
  39686. */
  39687. /**
  39688. * Sets wether the vignette effect is enabled.
  39689. */
  39690. vignetteEnabled: boolean;
  39691. private _fromLinearSpace;
  39692. /**
  39693. * Gets wether the input of the processing is in Gamma or Linear Space.
  39694. */
  39695. /**
  39696. * Sets wether the input of the processing is in Gamma or Linear Space.
  39697. */
  39698. fromLinearSpace: boolean;
  39699. /**
  39700. * Defines cache preventing GC.
  39701. */
  39702. private _defines;
  39703. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39704. /**
  39705. * "ImageProcessingPostProcess"
  39706. * @returns "ImageProcessingPostProcess"
  39707. */
  39708. getClassName(): string;
  39709. protected _updateParameters(): void;
  39710. dispose(camera?: Camera): void;
  39711. }
  39712. }
  39713. declare module BABYLON {
  39714. /**
  39715. * Class containing static functions to help procedurally build meshes
  39716. */
  39717. export class GroundBuilder {
  39718. /**
  39719. * Creates a ground mesh
  39720. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39721. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39723. * @param name defines the name of the mesh
  39724. * @param options defines the options used to create the mesh
  39725. * @param scene defines the hosting scene
  39726. * @returns the ground mesh
  39727. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39728. */
  39729. static CreateGround(name: string, options: {
  39730. width?: number;
  39731. height?: number;
  39732. subdivisions?: number;
  39733. subdivisionsX?: number;
  39734. subdivisionsY?: number;
  39735. updatable?: boolean;
  39736. }, scene: any): Mesh;
  39737. /**
  39738. * Creates a tiled ground mesh
  39739. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39740. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39741. * * 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
  39742. * * 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
  39743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39744. * @param name defines the name of the mesh
  39745. * @param options defines the options used to create the mesh
  39746. * @param scene defines the hosting scene
  39747. * @returns the tiled ground mesh
  39748. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39749. */
  39750. static CreateTiledGround(name: string, options: {
  39751. xmin: number;
  39752. zmin: number;
  39753. xmax: number;
  39754. zmax: number;
  39755. subdivisions?: {
  39756. w: number;
  39757. h: number;
  39758. };
  39759. precision?: {
  39760. w: number;
  39761. h: number;
  39762. };
  39763. updatable?: boolean;
  39764. }, scene?: Nullable<Scene>): Mesh;
  39765. /**
  39766. * Creates a ground mesh from a height map
  39767. * * The parameter `url` sets the URL of the height map image resource.
  39768. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39769. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39770. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39771. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39772. * * 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.
  39773. * * 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).
  39774. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39776. * @param name defines the name of the mesh
  39777. * @param url defines the url to the height map
  39778. * @param options defines the options used to create the mesh
  39779. * @param scene defines the hosting scene
  39780. * @returns the ground mesh
  39781. * @see https://doc.babylonjs.com/babylon101/height_map
  39782. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39783. */
  39784. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39785. width?: number;
  39786. height?: number;
  39787. subdivisions?: number;
  39788. minHeight?: number;
  39789. maxHeight?: number;
  39790. colorFilter?: Color3;
  39791. alphaFilter?: number;
  39792. updatable?: boolean;
  39793. onReady?: (mesh: GroundMesh) => void;
  39794. }, scene?: Nullable<Scene>): GroundMesh;
  39795. }
  39796. }
  39797. declare module BABYLON {
  39798. /**
  39799. * Class containing static functions to help procedurally build meshes
  39800. */
  39801. export class TorusBuilder {
  39802. /**
  39803. * Creates a torus mesh
  39804. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39805. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39806. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39808. * * 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
  39809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39810. * @param name defines the name of the mesh
  39811. * @param options defines the options used to create the mesh
  39812. * @param scene defines the hosting scene
  39813. * @returns the torus mesh
  39814. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39815. */
  39816. static CreateTorus(name: string, options: {
  39817. diameter?: number;
  39818. thickness?: number;
  39819. tessellation?: number;
  39820. updatable?: boolean;
  39821. sideOrientation?: number;
  39822. frontUVs?: Vector4;
  39823. backUVs?: Vector4;
  39824. }, scene: any): Mesh;
  39825. }
  39826. }
  39827. declare module BABYLON {
  39828. /**
  39829. * Class containing static functions to help procedurally build meshes
  39830. */
  39831. export class CylinderBuilder {
  39832. /**
  39833. * Creates a cylinder or a cone mesh
  39834. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39835. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39836. * * 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.
  39837. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39838. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39839. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39840. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39841. * * 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).
  39842. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39843. * * 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).
  39844. * * 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
  39845. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39846. * * 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
  39847. * * 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.
  39848. * * If `enclose` is false, a ring surface is one element.
  39849. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39850. * * 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
  39851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39852. * * 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
  39853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39854. * @param name defines the name of the mesh
  39855. * @param options defines the options used to create the mesh
  39856. * @param scene defines the hosting scene
  39857. * @returns the cylinder mesh
  39858. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39859. */
  39860. static CreateCylinder(name: string, options: {
  39861. height?: number;
  39862. diameterTop?: number;
  39863. diameterBottom?: number;
  39864. diameter?: number;
  39865. tessellation?: number;
  39866. subdivisions?: number;
  39867. arc?: number;
  39868. faceColors?: Color4[];
  39869. faceUV?: Vector4[];
  39870. updatable?: boolean;
  39871. hasRings?: boolean;
  39872. enclose?: boolean;
  39873. cap?: number;
  39874. sideOrientation?: number;
  39875. frontUVs?: Vector4;
  39876. backUVs?: Vector4;
  39877. }, scene: any): Mesh;
  39878. }
  39879. }
  39880. declare module BABYLON {
  39881. /**
  39882. * Options to modify the vr teleportation behavior.
  39883. */
  39884. export interface VRTeleportationOptions {
  39885. /**
  39886. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39887. */
  39888. floorMeshName?: string;
  39889. /**
  39890. * A list of meshes to be used as the teleportation floor. (default: empty)
  39891. */
  39892. floorMeshes?: Mesh[];
  39893. }
  39894. /**
  39895. * Options to modify the vr experience helper's behavior.
  39896. */
  39897. export interface VRExperienceHelperOptions extends WebVROptions {
  39898. /**
  39899. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39900. */
  39901. createDeviceOrientationCamera?: boolean;
  39902. /**
  39903. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39904. */
  39905. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39906. /**
  39907. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39908. */
  39909. laserToggle?: boolean;
  39910. /**
  39911. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39912. */
  39913. floorMeshes?: Mesh[];
  39914. /**
  39915. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39916. */
  39917. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39918. }
  39919. /**
  39920. * Event containing information after VR has been entered
  39921. */
  39922. export class OnAfterEnteringVRObservableEvent {
  39923. /**
  39924. * If entering vr was successful
  39925. */
  39926. success: boolean;
  39927. }
  39928. /**
  39929. * Helps to quickly add VR support to an existing scene.
  39930. * See http://doc.babylonjs.com/how_to/webvr_helper
  39931. */
  39932. export class VRExperienceHelper {
  39933. /** Options to modify the vr experience helper's behavior. */
  39934. webVROptions: VRExperienceHelperOptions;
  39935. private _scene;
  39936. private _position;
  39937. private _btnVR;
  39938. private _btnVRDisplayed;
  39939. private _webVRsupported;
  39940. private _webVRready;
  39941. private _webVRrequesting;
  39942. private _webVRpresenting;
  39943. private _hasEnteredVR;
  39944. private _fullscreenVRpresenting;
  39945. private _canvas;
  39946. private _webVRCamera;
  39947. private _vrDeviceOrientationCamera;
  39948. private _deviceOrientationCamera;
  39949. private _existingCamera;
  39950. private _onKeyDown;
  39951. private _onVrDisplayPresentChange;
  39952. private _onVRDisplayChanged;
  39953. private _onVRRequestPresentStart;
  39954. private _onVRRequestPresentComplete;
  39955. /**
  39956. * Observable raised right before entering VR.
  39957. */
  39958. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39959. /**
  39960. * Observable raised when entering VR has completed.
  39961. */
  39962. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39963. /**
  39964. * Observable raised when exiting VR.
  39965. */
  39966. onExitingVRObservable: Observable<VRExperienceHelper>;
  39967. /**
  39968. * Observable raised when controller mesh is loaded.
  39969. */
  39970. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39971. /** Return this.onEnteringVRObservable
  39972. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39973. */
  39974. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39975. /** Return this.onExitingVRObservable
  39976. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39977. */
  39978. readonly onExitingVR: Observable<VRExperienceHelper>;
  39979. /** Return this.onControllerMeshLoadedObservable
  39980. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39981. */
  39982. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39983. private _rayLength;
  39984. private _useCustomVRButton;
  39985. private _teleportationRequested;
  39986. private _teleportActive;
  39987. private _floorMeshName;
  39988. private _floorMeshesCollection;
  39989. private _rotationAllowed;
  39990. private _teleportBackwardsVector;
  39991. private _teleportationTarget;
  39992. private _isDefaultTeleportationTarget;
  39993. private _postProcessMove;
  39994. private _teleportationFillColor;
  39995. private _teleportationBorderColor;
  39996. private _rotationAngle;
  39997. private _haloCenter;
  39998. private _cameraGazer;
  39999. private _padSensibilityUp;
  40000. private _padSensibilityDown;
  40001. private _leftController;
  40002. private _rightController;
  40003. /**
  40004. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40005. */
  40006. onNewMeshSelected: Observable<AbstractMesh>;
  40007. /**
  40008. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40009. */
  40010. onNewMeshPicked: Observable<PickingInfo>;
  40011. private _circleEase;
  40012. /**
  40013. * Observable raised before camera teleportation
  40014. */
  40015. onBeforeCameraTeleport: Observable<Vector3>;
  40016. /**
  40017. * Observable raised after camera teleportation
  40018. */
  40019. onAfterCameraTeleport: Observable<Vector3>;
  40020. /**
  40021. * Observable raised when current selected mesh gets unselected
  40022. */
  40023. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40024. private _raySelectionPredicate;
  40025. /**
  40026. * To be optionaly changed by user to define custom ray selection
  40027. */
  40028. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40029. /**
  40030. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40031. */
  40032. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40033. /**
  40034. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40035. */
  40036. teleportationEnabled: boolean;
  40037. private _defaultHeight;
  40038. private _teleportationInitialized;
  40039. private _interactionsEnabled;
  40040. private _interactionsRequested;
  40041. private _displayGaze;
  40042. private _displayLaserPointer;
  40043. /**
  40044. * The mesh used to display where the user is going to teleport.
  40045. */
  40046. /**
  40047. * Sets the mesh to be used to display where the user is going to teleport.
  40048. */
  40049. teleportationTarget: Mesh;
  40050. /**
  40051. * 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
  40052. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40053. * See http://doc.babylonjs.com/resources/baking_transformations
  40054. */
  40055. gazeTrackerMesh: Mesh;
  40056. /**
  40057. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40058. */
  40059. updateGazeTrackerScale: boolean;
  40060. /**
  40061. * If the gaze trackers color should be updated when selecting meshes
  40062. */
  40063. updateGazeTrackerColor: boolean;
  40064. /**
  40065. * The gaze tracking mesh corresponding to the left controller
  40066. */
  40067. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40068. /**
  40069. * The gaze tracking mesh corresponding to the right controller
  40070. */
  40071. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40072. /**
  40073. * If the ray of the gaze should be displayed.
  40074. */
  40075. /**
  40076. * Sets if the ray of the gaze should be displayed.
  40077. */
  40078. displayGaze: boolean;
  40079. /**
  40080. * If the ray of the LaserPointer should be displayed.
  40081. */
  40082. /**
  40083. * Sets if the ray of the LaserPointer should be displayed.
  40084. */
  40085. displayLaserPointer: boolean;
  40086. /**
  40087. * The deviceOrientationCamera used as the camera when not in VR.
  40088. */
  40089. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40090. /**
  40091. * Based on the current WebVR support, returns the current VR camera used.
  40092. */
  40093. readonly currentVRCamera: Nullable<Camera>;
  40094. /**
  40095. * The webVRCamera which is used when in VR.
  40096. */
  40097. readonly webVRCamera: WebVRFreeCamera;
  40098. /**
  40099. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40100. */
  40101. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40102. private readonly _teleportationRequestInitiated;
  40103. /**
  40104. * Defines wether or not Pointer lock should be requested when switching to
  40105. * full screen.
  40106. */
  40107. requestPointerLockOnFullScreen: boolean;
  40108. /**
  40109. * Instantiates a VRExperienceHelper.
  40110. * Helps to quickly add VR support to an existing scene.
  40111. * @param scene The scene the VRExperienceHelper belongs to.
  40112. * @param webVROptions Options to modify the vr experience helper's behavior.
  40113. */
  40114. constructor(scene: Scene,
  40115. /** Options to modify the vr experience helper's behavior. */
  40116. webVROptions?: VRExperienceHelperOptions);
  40117. private _onDefaultMeshLoaded;
  40118. private _onResize;
  40119. private _onFullscreenChange;
  40120. /**
  40121. * Gets a value indicating if we are currently in VR mode.
  40122. */
  40123. readonly isInVRMode: boolean;
  40124. private onVrDisplayPresentChange;
  40125. private onVRDisplayChanged;
  40126. private moveButtonToBottomRight;
  40127. private displayVRButton;
  40128. private updateButtonVisibility;
  40129. private _cachedAngularSensibility;
  40130. /**
  40131. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40132. * Otherwise, will use the fullscreen API.
  40133. */
  40134. enterVR(): void;
  40135. /**
  40136. * Attempt to exit VR, or fullscreen.
  40137. */
  40138. exitVR(): void;
  40139. /**
  40140. * The position of the vr experience helper.
  40141. */
  40142. /**
  40143. * Sets the position of the vr experience helper.
  40144. */
  40145. position: Vector3;
  40146. /**
  40147. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40148. */
  40149. enableInteractions(): void;
  40150. private readonly _noControllerIsActive;
  40151. private beforeRender;
  40152. private _isTeleportationFloor;
  40153. /**
  40154. * Adds a floor mesh to be used for teleportation.
  40155. * @param floorMesh the mesh to be used for teleportation.
  40156. */
  40157. addFloorMesh(floorMesh: Mesh): void;
  40158. /**
  40159. * Removes a floor mesh from being used for teleportation.
  40160. * @param floorMesh the mesh to be removed.
  40161. */
  40162. removeFloorMesh(floorMesh: Mesh): void;
  40163. /**
  40164. * Enables interactions and teleportation using the VR controllers and gaze.
  40165. * @param vrTeleportationOptions options to modify teleportation behavior.
  40166. */
  40167. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40168. private _onNewGamepadConnected;
  40169. private _tryEnableInteractionOnController;
  40170. private _onNewGamepadDisconnected;
  40171. private _enableInteractionOnController;
  40172. private _checkTeleportWithRay;
  40173. private _checkRotate;
  40174. private _checkTeleportBackwards;
  40175. private _enableTeleportationOnController;
  40176. private _createTeleportationCircles;
  40177. private _displayTeleportationTarget;
  40178. private _hideTeleportationTarget;
  40179. private _rotateCamera;
  40180. private _moveTeleportationSelectorTo;
  40181. private _workingVector;
  40182. private _workingQuaternion;
  40183. private _workingMatrix;
  40184. /**
  40185. * Teleports the users feet to the desired location
  40186. * @param location The location where the user's feet should be placed
  40187. */
  40188. teleportCamera(location: Vector3): void;
  40189. private _convertNormalToDirectionOfRay;
  40190. private _castRayAndSelectObject;
  40191. private _notifySelectedMeshUnselected;
  40192. /**
  40193. * Sets the color of the laser ray from the vr controllers.
  40194. * @param color new color for the ray.
  40195. */
  40196. changeLaserColor(color: Color3): void;
  40197. /**
  40198. * Sets the color of the ray from the vr headsets gaze.
  40199. * @param color new color for the ray.
  40200. */
  40201. changeGazeColor(color: Color3): void;
  40202. /**
  40203. * Exits VR and disposes of the vr experience helper
  40204. */
  40205. dispose(): void;
  40206. /**
  40207. * Gets the name of the VRExperienceHelper class
  40208. * @returns "VRExperienceHelper"
  40209. */
  40210. getClassName(): string;
  40211. }
  40212. }
  40213. declare module BABYLON {
  40214. /**
  40215. * Manages an XRSession
  40216. * @see https://doc.babylonjs.com/how_to/webxr
  40217. */
  40218. export class WebXRSessionManager implements IDisposable {
  40219. private scene;
  40220. /**
  40221. * Fires every time a new xrFrame arrives which can be used to update the camera
  40222. */
  40223. onXRFrameObservable: Observable<any>;
  40224. /**
  40225. * Fires when the xr session is ended either by the device or manually done
  40226. */
  40227. onXRSessionEnded: Observable<any>;
  40228. /** @hidden */
  40229. _xrSession: XRSession;
  40230. /** @hidden */
  40231. _frameOfReference: XRFrameOfReference;
  40232. /** @hidden */
  40233. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40234. /** @hidden */
  40235. _currentXRFrame: Nullable<XRFrame>;
  40236. private _xrNavigator;
  40237. private _xrDevice;
  40238. private _tmpMatrix;
  40239. /**
  40240. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40241. * @param scene The scene which the session should be created for
  40242. */
  40243. constructor(scene: Scene);
  40244. /**
  40245. * Initializes the manager
  40246. * After initialization enterXR can be called to start an XR session
  40247. * @returns Promise which resolves after it is initialized
  40248. */
  40249. initializeAsync(): Promise<void>;
  40250. /**
  40251. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40252. * @param sessionCreationOptions xr options to create the session with
  40253. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40254. * @returns Promise which resolves after it enters XR
  40255. */
  40256. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40257. /**
  40258. * Stops the xrSession and restores the renderloop
  40259. * @returns Promise which resolves after it exits XR
  40260. */
  40261. exitXRAsync(): Promise<void>;
  40262. /**
  40263. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40264. * @param ray ray to cast into the environment
  40265. * @returns Promise which resolves with a collision point in the environment if it exists
  40266. */
  40267. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40268. /**
  40269. * Checks if a session would be supported for the creation options specified
  40270. * @param options creation options to check if they are supported
  40271. * @returns true if supported
  40272. */
  40273. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40274. /**
  40275. * @hidden
  40276. * Converts the render layer of xrSession to a render target
  40277. * @param session session to create render target for
  40278. * @param scene scene the new render target should be created for
  40279. */
  40280. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40281. /**
  40282. * Disposes of the session manager
  40283. */
  40284. dispose(): void;
  40285. }
  40286. }
  40287. declare module BABYLON {
  40288. /**
  40289. * WebXR Camera which holds the views for the xrSession
  40290. * @see https://doc.babylonjs.com/how_to/webxr
  40291. */
  40292. export class WebXRCamera extends FreeCamera {
  40293. private static _TmpMatrix;
  40294. /**
  40295. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40296. * @param name the name of the camera
  40297. * @param scene the scene to add the camera to
  40298. */
  40299. constructor(name: string, scene: Scene);
  40300. private _updateNumberOfRigCameras;
  40301. /** @hidden */
  40302. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40303. /**
  40304. * Updates the cameras position from the current pose information of the XR session
  40305. * @param xrSessionManager the session containing pose information
  40306. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40307. */
  40308. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40309. }
  40310. }
  40311. declare module BABYLON {
  40312. /**
  40313. * States of the webXR experience
  40314. */
  40315. export enum WebXRState {
  40316. /**
  40317. * Transitioning to being in XR mode
  40318. */
  40319. ENTERING_XR = 0,
  40320. /**
  40321. * Transitioning to non XR mode
  40322. */
  40323. EXITING_XR = 1,
  40324. /**
  40325. * In XR mode and presenting
  40326. */
  40327. IN_XR = 2,
  40328. /**
  40329. * Not entered XR mode
  40330. */
  40331. NOT_IN_XR = 3
  40332. }
  40333. /**
  40334. * Helper class used to enable XR
  40335. * @see https://doc.babylonjs.com/how_to/webxr
  40336. */
  40337. export class WebXRExperienceHelper implements IDisposable {
  40338. private scene;
  40339. /**
  40340. * 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
  40341. */
  40342. container: AbstractMesh;
  40343. /**
  40344. * Camera used to render xr content
  40345. */
  40346. camera: WebXRCamera;
  40347. /**
  40348. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40349. */
  40350. state: WebXRState;
  40351. private _setState;
  40352. private static _TmpVector;
  40353. /**
  40354. * Fires when the state of the experience helper has changed
  40355. */
  40356. onStateChangedObservable: Observable<WebXRState>;
  40357. /** @hidden */
  40358. _sessionManager: WebXRSessionManager;
  40359. private _nonVRCamera;
  40360. private _originalSceneAutoClear;
  40361. private _supported;
  40362. /**
  40363. * Creates the experience helper
  40364. * @param scene the scene to attach the experience helper to
  40365. * @returns a promise for the experience helper
  40366. */
  40367. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40368. /**
  40369. * Creates a WebXRExperienceHelper
  40370. * @param scene The scene the helper should be created in
  40371. */
  40372. private constructor();
  40373. /**
  40374. * Exits XR mode and returns the scene to its original state
  40375. * @returns promise that resolves after xr mode has exited
  40376. */
  40377. exitXRAsync(): Promise<void>;
  40378. /**
  40379. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40380. * @param sessionCreationOptions options for the XR session
  40381. * @param frameOfReference frame of reference of the XR session
  40382. * @returns promise that resolves after xr mode has entered
  40383. */
  40384. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40385. /**
  40386. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40387. * @param ray ray to cast into the environment
  40388. * @returns Promise which resolves with a collision point in the environment if it exists
  40389. */
  40390. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40391. /**
  40392. * Updates the global position of the camera by moving the camera's container
  40393. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40394. * @param position The desired global position of the camera
  40395. */
  40396. setPositionOfCameraUsingContainer(position: Vector3): void;
  40397. /**
  40398. * Rotates the xr camera by rotating the camera's container around the camera's position
  40399. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40400. * @param rotation the desired quaternion rotation to apply to the camera
  40401. */
  40402. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40403. /**
  40404. * Checks if the creation options are supported by the xr session
  40405. * @param options creation options
  40406. * @returns true if supported
  40407. */
  40408. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40409. /**
  40410. * Disposes of the experience helper
  40411. */
  40412. dispose(): void;
  40413. }
  40414. }
  40415. declare module BABYLON {
  40416. /**
  40417. * Button which can be used to enter a different mode of XR
  40418. */
  40419. export class WebXREnterExitUIButton {
  40420. /** button element */
  40421. element: HTMLElement;
  40422. /** XR initialization options for the button */
  40423. initializationOptions: XRSessionCreationOptions;
  40424. /**
  40425. * Creates a WebXREnterExitUIButton
  40426. * @param element button element
  40427. * @param initializationOptions XR initialization options for the button
  40428. */
  40429. constructor(
  40430. /** button element */
  40431. element: HTMLElement,
  40432. /** XR initialization options for the button */
  40433. initializationOptions: XRSessionCreationOptions);
  40434. /**
  40435. * Overwritable function which can be used to update the button's visuals when the state changes
  40436. * @param activeButton the current active button in the UI
  40437. */
  40438. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40439. }
  40440. /**
  40441. * Options to create the webXR UI
  40442. */
  40443. export class WebXREnterExitUIOptions {
  40444. /**
  40445. * Context to enter xr with
  40446. */
  40447. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40448. /**
  40449. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40450. */
  40451. customButtons?: Array<WebXREnterExitUIButton>;
  40452. }
  40453. /**
  40454. * UI to allow the user to enter/exit XR mode
  40455. */
  40456. export class WebXREnterExitUI implements IDisposable {
  40457. private scene;
  40458. private _overlay;
  40459. private _buttons;
  40460. private _activeButton;
  40461. /**
  40462. * Fired every time the active button is changed.
  40463. *
  40464. * When xr is entered via a button that launches xr that button will be the callback parameter
  40465. *
  40466. * When exiting xr the callback parameter will be null)
  40467. */
  40468. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40469. /**
  40470. * Creates UI to allow the user to enter/exit XR mode
  40471. * @param scene the scene to add the ui to
  40472. * @param helper the xr experience helper to enter/exit xr with
  40473. * @param options options to configure the UI
  40474. * @returns the created ui
  40475. */
  40476. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40477. private constructor();
  40478. private _updateButtons;
  40479. /**
  40480. * Disposes of the object
  40481. */
  40482. dispose(): void;
  40483. }
  40484. }
  40485. declare module BABYLON {
  40486. /**
  40487. * Represents an XR input
  40488. */
  40489. export class WebXRController {
  40490. /**
  40491. * 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
  40492. */
  40493. grip?: AbstractMesh;
  40494. /**
  40495. * Pointer which can be used to select objects or attach a visible laser to
  40496. */
  40497. pointer: AbstractMesh;
  40498. /**
  40499. * Creates the controller
  40500. * @see https://doc.babylonjs.com/how_to/webxr
  40501. * @param scene the scene which the controller should be associated to
  40502. */
  40503. constructor(scene: Scene);
  40504. /**
  40505. * Disposes of the object
  40506. */
  40507. dispose(): void;
  40508. }
  40509. /**
  40510. * XR input used to track XR inputs such as controllers/rays
  40511. */
  40512. export class WebXRInput implements IDisposable {
  40513. private helper;
  40514. /**
  40515. * XR controllers being tracked
  40516. */
  40517. controllers: Array<WebXRController>;
  40518. private _tmpMatrix;
  40519. private _frameObserver;
  40520. /**
  40521. * Initializes the WebXRInput
  40522. * @param helper experience helper which the input should be created for
  40523. */
  40524. constructor(helper: WebXRExperienceHelper);
  40525. /**
  40526. * Disposes of the object
  40527. */
  40528. dispose(): void;
  40529. }
  40530. }
  40531. declare module BABYLON {
  40532. /**
  40533. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40534. */
  40535. export class WebXRManagedOutputCanvas implements IDisposable {
  40536. private _canvas;
  40537. /**
  40538. * xrpresent context of the canvas which can be used to display/mirror xr content
  40539. */
  40540. canvasContext: Nullable<WebGLRenderingContext>;
  40541. /**
  40542. * Initializes the canvas to be added/removed upon entering/exiting xr
  40543. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40544. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40545. */
  40546. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40547. /**
  40548. * Disposes of the object
  40549. */
  40550. dispose(): void;
  40551. private _setManagedOutputCanvas;
  40552. private _addCanvas;
  40553. private _removeCanvas;
  40554. }
  40555. }
  40556. declare module BABYLON {
  40557. /**
  40558. * Contains an array of blocks representing the octree
  40559. */
  40560. export interface IOctreeContainer<T> {
  40561. /**
  40562. * Blocks within the octree
  40563. */
  40564. blocks: Array<OctreeBlock<T>>;
  40565. }
  40566. /**
  40567. * Class used to store a cell in an octree
  40568. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40569. */
  40570. export class OctreeBlock<T> {
  40571. /**
  40572. * Gets the content of the current block
  40573. */
  40574. entries: T[];
  40575. /**
  40576. * Gets the list of block children
  40577. */
  40578. blocks: Array<OctreeBlock<T>>;
  40579. private _depth;
  40580. private _maxDepth;
  40581. private _capacity;
  40582. private _minPoint;
  40583. private _maxPoint;
  40584. private _boundingVectors;
  40585. private _creationFunc;
  40586. /**
  40587. * Creates a new block
  40588. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40589. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40590. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40591. * @param depth defines the current depth of this block in the octree
  40592. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40593. * @param creationFunc defines a callback to call when an element is added to the block
  40594. */
  40595. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40596. /**
  40597. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40598. */
  40599. readonly capacity: number;
  40600. /**
  40601. * Gets the minimum vector (in world space) of the block's bounding box
  40602. */
  40603. readonly minPoint: Vector3;
  40604. /**
  40605. * Gets the maximum vector (in world space) of the block's bounding box
  40606. */
  40607. readonly maxPoint: Vector3;
  40608. /**
  40609. * Add a new element to this block
  40610. * @param entry defines the element to add
  40611. */
  40612. addEntry(entry: T): void;
  40613. /**
  40614. * Remove an element from this block
  40615. * @param entry defines the element to remove
  40616. */
  40617. removeEntry(entry: T): void;
  40618. /**
  40619. * Add an array of elements to this block
  40620. * @param entries defines the array of elements to add
  40621. */
  40622. addEntries(entries: T[]): void;
  40623. /**
  40624. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40625. * @param frustumPlanes defines the frustum planes to test
  40626. * @param selection defines the array to store current content if selection is positive
  40627. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40628. */
  40629. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40630. /**
  40631. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40632. * @param sphereCenter defines the bounding sphere center
  40633. * @param sphereRadius defines the bounding sphere radius
  40634. * @param selection defines the array to store current content if selection is positive
  40635. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40636. */
  40637. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40638. /**
  40639. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40640. * @param ray defines the ray to test with
  40641. * @param selection defines the array to store current content if selection is positive
  40642. */
  40643. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40644. /**
  40645. * Subdivide the content into child blocks (this block will then be empty)
  40646. */
  40647. createInnerBlocks(): void;
  40648. /**
  40649. * @hidden
  40650. */
  40651. 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;
  40652. }
  40653. }
  40654. declare module BABYLON {
  40655. /**
  40656. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40657. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40658. */
  40659. export class Octree<T> {
  40660. /** 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.) */
  40661. maxDepth: number;
  40662. /**
  40663. * Blocks within the octree containing objects
  40664. */
  40665. blocks: Array<OctreeBlock<T>>;
  40666. /**
  40667. * Content stored in the octree
  40668. */
  40669. dynamicContent: T[];
  40670. private _maxBlockCapacity;
  40671. private _selectionContent;
  40672. private _creationFunc;
  40673. /**
  40674. * Creates a octree
  40675. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40676. * @param creationFunc function to be used to instatiate the octree
  40677. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40678. * @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.)
  40679. */
  40680. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40681. /** 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.) */
  40682. maxDepth?: number);
  40683. /**
  40684. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40685. * @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);
  40686. * @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);
  40687. * @param entries meshes to be added to the octree blocks
  40688. */
  40689. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40690. /**
  40691. * Adds a mesh to the octree
  40692. * @param entry Mesh to add to the octree
  40693. */
  40694. addMesh(entry: T): void;
  40695. /**
  40696. * Remove an element from the octree
  40697. * @param entry defines the element to remove
  40698. */
  40699. removeMesh(entry: T): void;
  40700. /**
  40701. * Selects an array of meshes within the frustum
  40702. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40703. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40704. * @returns array of meshes within the frustum
  40705. */
  40706. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40707. /**
  40708. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40709. * @param sphereCenter defines the bounding sphere center
  40710. * @param sphereRadius defines the bounding sphere radius
  40711. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40712. * @returns an array of objects that intersect the sphere
  40713. */
  40714. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40715. /**
  40716. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40717. * @param ray defines the ray to test with
  40718. * @returns array of intersected objects
  40719. */
  40720. intersectsRay(ray: Ray): SmartArray<T>;
  40721. /**
  40722. * Adds a mesh into the octree block if it intersects the block
  40723. */
  40724. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40725. /**
  40726. * Adds a submesh into the octree block if it intersects the block
  40727. */
  40728. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40729. }
  40730. }
  40731. declare module BABYLON {
  40732. interface Scene {
  40733. /**
  40734. * @hidden
  40735. * Backing Filed
  40736. */
  40737. _selectionOctree: Octree<AbstractMesh>;
  40738. /**
  40739. * Gets the octree used to boost mesh selection (picking)
  40740. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40741. */
  40742. selectionOctree: Octree<AbstractMesh>;
  40743. /**
  40744. * Creates or updates the octree used to boost selection (picking)
  40745. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40746. * @param maxCapacity defines the maximum capacity per leaf
  40747. * @param maxDepth defines the maximum depth of the octree
  40748. * @returns an octree of AbstractMesh
  40749. */
  40750. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40751. }
  40752. interface AbstractMesh {
  40753. /**
  40754. * @hidden
  40755. * Backing Field
  40756. */
  40757. _submeshesOctree: Octree<SubMesh>;
  40758. /**
  40759. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40760. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40761. * @param maxCapacity defines the maximum size of each block (64 by default)
  40762. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40763. * @returns the new octree
  40764. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40765. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40766. */
  40767. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40768. }
  40769. /**
  40770. * Defines the octree scene component responsible to manage any octrees
  40771. * in a given scene.
  40772. */
  40773. export class OctreeSceneComponent {
  40774. /**
  40775. * The component name help to identify the component in the list of scene components.
  40776. */
  40777. readonly name: string;
  40778. /**
  40779. * The scene the component belongs to.
  40780. */
  40781. scene: Scene;
  40782. /**
  40783. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40784. */
  40785. readonly checksIsEnabled: boolean;
  40786. /**
  40787. * Creates a new instance of the component for the given scene
  40788. * @param scene Defines the scene to register the component in
  40789. */
  40790. constructor(scene: Scene);
  40791. /**
  40792. * Registers the component in a given scene
  40793. */
  40794. register(): void;
  40795. /**
  40796. * Return the list of active meshes
  40797. * @returns the list of active meshes
  40798. */
  40799. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40800. /**
  40801. * Return the list of active sub meshes
  40802. * @param mesh The mesh to get the candidates sub meshes from
  40803. * @returns the list of active sub meshes
  40804. */
  40805. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40806. private _tempRay;
  40807. /**
  40808. * Return the list of sub meshes intersecting with a given local ray
  40809. * @param mesh defines the mesh to find the submesh for
  40810. * @param localRay defines the ray in local space
  40811. * @returns the list of intersecting sub meshes
  40812. */
  40813. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40814. /**
  40815. * Return the list of sub meshes colliding with a collider
  40816. * @param mesh defines the mesh to find the submesh for
  40817. * @param collider defines the collider to evaluate the collision against
  40818. * @returns the list of colliding sub meshes
  40819. */
  40820. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40821. /**
  40822. * Rebuilds the elements related to this component in case of
  40823. * context lost for instance.
  40824. */
  40825. rebuild(): void;
  40826. /**
  40827. * Disposes the component and the associated ressources.
  40828. */
  40829. dispose(): void;
  40830. }
  40831. }
  40832. declare module BABYLON {
  40833. /**
  40834. * Renders a layer on top of an existing scene
  40835. */
  40836. export class UtilityLayerRenderer implements IDisposable {
  40837. /** the original scene that will be rendered on top of */
  40838. originalScene: Scene;
  40839. private _pointerCaptures;
  40840. private _lastPointerEvents;
  40841. private static _DefaultUtilityLayer;
  40842. private static _DefaultKeepDepthUtilityLayer;
  40843. private _sharedGizmoLight;
  40844. /**
  40845. * @hidden
  40846. * Light which used by gizmos to get light shading
  40847. */
  40848. _getSharedGizmoLight(): HemisphericLight;
  40849. /**
  40850. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40851. */
  40852. pickUtilitySceneFirst: boolean;
  40853. /**
  40854. * 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)
  40855. */
  40856. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40857. /**
  40858. * 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)
  40859. */
  40860. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40861. /**
  40862. * The scene that is rendered on top of the original scene
  40863. */
  40864. utilityLayerScene: Scene;
  40865. /**
  40866. * If the utility layer should automatically be rendered on top of existing scene
  40867. */
  40868. shouldRender: boolean;
  40869. /**
  40870. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40871. */
  40872. onlyCheckPointerDownEvents: boolean;
  40873. /**
  40874. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40875. */
  40876. processAllEvents: boolean;
  40877. /**
  40878. * Observable raised when the pointer move from the utility layer scene to the main scene
  40879. */
  40880. onPointerOutObservable: Observable<number>;
  40881. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40882. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40883. private _afterRenderObserver;
  40884. private _sceneDisposeObserver;
  40885. private _originalPointerObserver;
  40886. /**
  40887. * Instantiates a UtilityLayerRenderer
  40888. * @param originalScene the original scene that will be rendered on top of
  40889. * @param handleEvents boolean indicating if the utility layer should handle events
  40890. */
  40891. constructor(
  40892. /** the original scene that will be rendered on top of */
  40893. originalScene: Scene, handleEvents?: boolean);
  40894. private _notifyObservers;
  40895. /**
  40896. * Renders the utility layers scene on top of the original scene
  40897. */
  40898. render(): void;
  40899. /**
  40900. * Disposes of the renderer
  40901. */
  40902. dispose(): void;
  40903. private _updateCamera;
  40904. }
  40905. }
  40906. declare module BABYLON {
  40907. /**
  40908. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40909. */
  40910. export class Gizmo implements IDisposable {
  40911. /** The utility layer the gizmo will be added to */
  40912. gizmoLayer: UtilityLayerRenderer;
  40913. /**
  40914. * The root mesh of the gizmo
  40915. */
  40916. _rootMesh: Mesh;
  40917. private _attachedMesh;
  40918. /**
  40919. * Ratio for the scale of the gizmo (Default: 1)
  40920. */
  40921. scaleRatio: number;
  40922. /**
  40923. * If a custom mesh has been set (Default: false)
  40924. */
  40925. protected _customMeshSet: boolean;
  40926. /**
  40927. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40928. * * When set, interactions will be enabled
  40929. */
  40930. attachedMesh: Nullable<AbstractMesh>;
  40931. /**
  40932. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40933. * @param mesh The mesh to replace the default mesh of the gizmo
  40934. */
  40935. setCustomMesh(mesh: Mesh): void;
  40936. /**
  40937. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40938. */
  40939. updateGizmoRotationToMatchAttachedMesh: boolean;
  40940. /**
  40941. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40942. */
  40943. updateGizmoPositionToMatchAttachedMesh: boolean;
  40944. /**
  40945. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40946. */
  40947. protected _updateScale: boolean;
  40948. protected _interactionsEnabled: boolean;
  40949. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40950. private _beforeRenderObserver;
  40951. private _tempVector;
  40952. /**
  40953. * Creates a gizmo
  40954. * @param gizmoLayer The utility layer the gizmo will be added to
  40955. */
  40956. constructor(
  40957. /** The utility layer the gizmo will be added to */
  40958. gizmoLayer?: UtilityLayerRenderer);
  40959. /**
  40960. * Updates the gizmo to match the attached mesh's position/rotation
  40961. */
  40962. protected _update(): void;
  40963. /**
  40964. * Disposes of the gizmo
  40965. */
  40966. dispose(): void;
  40967. }
  40968. }
  40969. declare module BABYLON {
  40970. /**
  40971. * Single plane drag gizmo
  40972. */
  40973. export class PlaneDragGizmo extends Gizmo {
  40974. /**
  40975. * Drag behavior responsible for the gizmos dragging interactions
  40976. */
  40977. dragBehavior: PointerDragBehavior;
  40978. private _pointerObserver;
  40979. /**
  40980. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40981. */
  40982. snapDistance: number;
  40983. /**
  40984. * Event that fires each time the gizmo snaps to a new location.
  40985. * * snapDistance is the the change in distance
  40986. */
  40987. onSnapObservable: Observable<{
  40988. snapDistance: number;
  40989. }>;
  40990. private _plane;
  40991. private _coloredMaterial;
  40992. private _hoverMaterial;
  40993. private _isEnabled;
  40994. private _parent;
  40995. /** @hidden */
  40996. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  40997. /** @hidden */
  40998. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40999. /**
  41000. * Creates a PlaneDragGizmo
  41001. * @param gizmoLayer The utility layer the gizmo will be added to
  41002. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  41003. * @param color The color of the gizmo
  41004. */
  41005. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41006. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41007. /**
  41008. * If the gizmo is enabled
  41009. */
  41010. isEnabled: boolean;
  41011. /**
  41012. * Disposes of the gizmo
  41013. */
  41014. dispose(): void;
  41015. }
  41016. }
  41017. declare module BABYLON {
  41018. /**
  41019. * Gizmo that enables dragging a mesh along 3 axis
  41020. */
  41021. export class PositionGizmo extends Gizmo {
  41022. /**
  41023. * Internal gizmo used for interactions on the x axis
  41024. */
  41025. xGizmo: AxisDragGizmo;
  41026. /**
  41027. * Internal gizmo used for interactions on the y axis
  41028. */
  41029. yGizmo: AxisDragGizmo;
  41030. /**
  41031. * Internal gizmo used for interactions on the z axis
  41032. */
  41033. zGizmo: AxisDragGizmo;
  41034. /**
  41035. * Internal gizmo used for interactions on the yz plane
  41036. */
  41037. xPlaneGizmo: PlaneDragGizmo;
  41038. /**
  41039. * Internal gizmo used for interactions on the xz plane
  41040. */
  41041. yPlaneGizmo: PlaneDragGizmo;
  41042. /**
  41043. * Internal gizmo used for interactions on the xy plane
  41044. */
  41045. zPlaneGizmo: PlaneDragGizmo;
  41046. /**
  41047. * private variables
  41048. */
  41049. private _meshAttached;
  41050. private _updateGizmoRotationToMatchAttachedMesh;
  41051. private _snapDistance;
  41052. private _scaleRatio;
  41053. /** Fires an event when any of it's sub gizmos are dragged */
  41054. onDragStartObservable: Observable<{}>;
  41055. /** Fires an event when any of it's sub gizmos are released from dragging */
  41056. onDragEndObservable: Observable<{}>;
  41057. /**
  41058. * If set to true, planar drag is enabled
  41059. */
  41060. private _planarGizmoEnabled;
  41061. attachedMesh: Nullable<AbstractMesh>;
  41062. /**
  41063. * Creates a PositionGizmo
  41064. * @param gizmoLayer The utility layer the gizmo will be added to
  41065. */
  41066. constructor(gizmoLayer?: UtilityLayerRenderer);
  41067. /**
  41068. * If the planar drag gizmo is enabled
  41069. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  41070. */
  41071. planarGizmoEnabled: boolean;
  41072. updateGizmoRotationToMatchAttachedMesh: boolean;
  41073. /**
  41074. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41075. */
  41076. snapDistance: number;
  41077. /**
  41078. * Ratio for the scale of the gizmo (Default: 1)
  41079. */
  41080. scaleRatio: number;
  41081. /**
  41082. * Disposes of the gizmo
  41083. */
  41084. dispose(): void;
  41085. /**
  41086. * CustomMeshes are not supported by this gizmo
  41087. * @param mesh The mesh to replace the default mesh of the gizmo
  41088. */
  41089. setCustomMesh(mesh: Mesh): void;
  41090. }
  41091. }
  41092. declare module BABYLON {
  41093. /**
  41094. * Single axis drag gizmo
  41095. */
  41096. export class AxisDragGizmo extends Gizmo {
  41097. /**
  41098. * Drag behavior responsible for the gizmos dragging interactions
  41099. */
  41100. dragBehavior: PointerDragBehavior;
  41101. private _pointerObserver;
  41102. /**
  41103. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41104. */
  41105. snapDistance: number;
  41106. /**
  41107. * Event that fires each time the gizmo snaps to a new location.
  41108. * * snapDistance is the the change in distance
  41109. */
  41110. onSnapObservable: Observable<{
  41111. snapDistance: number;
  41112. }>;
  41113. private _isEnabled;
  41114. private _parent;
  41115. private _arrow;
  41116. private _coloredMaterial;
  41117. private _hoverMaterial;
  41118. /** @hidden */
  41119. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41120. /** @hidden */
  41121. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41122. /**
  41123. * Creates an AxisDragGizmo
  41124. * @param gizmoLayer The utility layer the gizmo will be added to
  41125. * @param dragAxis The axis which the gizmo will be able to drag on
  41126. * @param color The color of the gizmo
  41127. */
  41128. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41129. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41130. /**
  41131. * If the gizmo is enabled
  41132. */
  41133. isEnabled: boolean;
  41134. /**
  41135. * Disposes of the gizmo
  41136. */
  41137. dispose(): void;
  41138. }
  41139. }
  41140. declare module BABYLON.Debug {
  41141. /**
  41142. * The Axes viewer will show 3 axes in a specific point in space
  41143. */
  41144. export class AxesViewer {
  41145. private _xAxis;
  41146. private _yAxis;
  41147. private _zAxis;
  41148. private _scaleLinesFactor;
  41149. private _instanced;
  41150. /**
  41151. * Gets the hosting scene
  41152. */
  41153. scene: Scene;
  41154. /**
  41155. * Gets or sets a number used to scale line length
  41156. */
  41157. scaleLines: number;
  41158. /** Gets the node hierarchy used to render x-axis */
  41159. readonly xAxis: TransformNode;
  41160. /** Gets the node hierarchy used to render y-axis */
  41161. readonly yAxis: TransformNode;
  41162. /** Gets the node hierarchy used to render z-axis */
  41163. readonly zAxis: TransformNode;
  41164. /**
  41165. * Creates a new AxesViewer
  41166. * @param scene defines the hosting scene
  41167. * @param scaleLines defines a number used to scale line length (1 by default)
  41168. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41169. * @param xAxis defines the node hierarchy used to render the x-axis
  41170. * @param yAxis defines the node hierarchy used to render the y-axis
  41171. * @param zAxis defines the node hierarchy used to render the z-axis
  41172. */
  41173. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41174. /**
  41175. * Force the viewer to update
  41176. * @param position defines the position of the viewer
  41177. * @param xaxis defines the x axis of the viewer
  41178. * @param yaxis defines the y axis of the viewer
  41179. * @param zaxis defines the z axis of the viewer
  41180. */
  41181. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41182. /**
  41183. * Creates an instance of this axes viewer.
  41184. * @returns a new axes viewer with instanced meshes
  41185. */
  41186. createInstance(): AxesViewer;
  41187. /** Releases resources */
  41188. dispose(): void;
  41189. private static _SetRenderingGroupId;
  41190. }
  41191. }
  41192. declare module BABYLON.Debug {
  41193. /**
  41194. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41195. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41196. */
  41197. export class BoneAxesViewer extends AxesViewer {
  41198. /**
  41199. * Gets or sets the target mesh where to display the axes viewer
  41200. */
  41201. mesh: Nullable<Mesh>;
  41202. /**
  41203. * Gets or sets the target bone where to display the axes viewer
  41204. */
  41205. bone: Nullable<Bone>;
  41206. /** Gets current position */
  41207. pos: Vector3;
  41208. /** Gets direction of X axis */
  41209. xaxis: Vector3;
  41210. /** Gets direction of Y axis */
  41211. yaxis: Vector3;
  41212. /** Gets direction of Z axis */
  41213. zaxis: Vector3;
  41214. /**
  41215. * Creates a new BoneAxesViewer
  41216. * @param scene defines the hosting scene
  41217. * @param bone defines the target bone
  41218. * @param mesh defines the target mesh
  41219. * @param scaleLines defines a scaling factor for line length (1 by default)
  41220. */
  41221. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41222. /**
  41223. * Force the viewer to update
  41224. */
  41225. update(): void;
  41226. /** Releases resources */
  41227. dispose(): void;
  41228. }
  41229. }
  41230. declare module BABYLON {
  41231. /**
  41232. * Interface used to define scene explorer extensibility option
  41233. */
  41234. export interface IExplorerExtensibilityOption {
  41235. /**
  41236. * Define the option label
  41237. */
  41238. label: string;
  41239. /**
  41240. * Defines the action to execute on click
  41241. */
  41242. action: (entity: any) => void;
  41243. }
  41244. /**
  41245. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41246. */
  41247. export interface IExplorerExtensibilityGroup {
  41248. /**
  41249. * Defines a predicate to test if a given type mut be extended
  41250. */
  41251. predicate: (entity: any) => boolean;
  41252. /**
  41253. * Gets the list of options added to a type
  41254. */
  41255. entries: IExplorerExtensibilityOption[];
  41256. }
  41257. /**
  41258. * Interface used to define the options to use to create the Inspector
  41259. */
  41260. export interface IInspectorOptions {
  41261. /**
  41262. * Display in overlay mode (default: false)
  41263. */
  41264. overlay?: boolean;
  41265. /**
  41266. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41267. */
  41268. globalRoot?: HTMLElement;
  41269. /**
  41270. * Display the Scene explorer
  41271. */
  41272. showExplorer?: boolean;
  41273. /**
  41274. * Display the property inspector
  41275. */
  41276. showInspector?: boolean;
  41277. /**
  41278. * Display in embed mode (both panes on the right)
  41279. */
  41280. embedMode?: boolean;
  41281. /**
  41282. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41283. */
  41284. handleResize?: boolean;
  41285. /**
  41286. * Allow the panes to popup (default: true)
  41287. */
  41288. enablePopup?: boolean;
  41289. /**
  41290. * Allow the panes to be closed by users (default: true)
  41291. */
  41292. enableClose?: boolean;
  41293. /**
  41294. * Optional list of extensibility entries
  41295. */
  41296. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41297. /**
  41298. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41299. */
  41300. inspectorURL?: string;
  41301. }
  41302. interface Scene {
  41303. /**
  41304. * @hidden
  41305. * Backing field
  41306. */
  41307. _debugLayer: DebugLayer;
  41308. /**
  41309. * Gets the debug layer (aka Inspector) associated with the scene
  41310. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41311. */
  41312. debugLayer: DebugLayer;
  41313. }
  41314. /**
  41315. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41316. * what is happening in your scene
  41317. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41318. */
  41319. export class DebugLayer {
  41320. /**
  41321. * Define the url to get the inspector script from.
  41322. * By default it uses the babylonjs CDN.
  41323. * @ignoreNaming
  41324. */
  41325. static InspectorURL: string;
  41326. private _scene;
  41327. private BJSINSPECTOR;
  41328. /**
  41329. * Observable triggered when a property is changed through the inspector.
  41330. */
  41331. onPropertyChangedObservable: Observable<{
  41332. object: any;
  41333. property: string;
  41334. value: any;
  41335. initialValue: any;
  41336. }>;
  41337. /**
  41338. * Instantiates a new debug layer.
  41339. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41340. * what is happening in your scene
  41341. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41342. * @param scene Defines the scene to inspect
  41343. */
  41344. constructor(scene: Scene);
  41345. /** Creates the inspector window. */
  41346. private _createInspector;
  41347. /**
  41348. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41349. * @param entity defines the entity to select
  41350. * @param lineContainerTitle defines the specific block to highlight
  41351. */
  41352. select(entity: any, lineContainerTitle?: string): void;
  41353. /** Get the inspector from bundle or global */
  41354. private _getGlobalInspector;
  41355. /**
  41356. * Get if the inspector is visible or not.
  41357. * @returns true if visible otherwise, false
  41358. */
  41359. isVisible(): boolean;
  41360. /**
  41361. * Hide the inspector and close its window.
  41362. */
  41363. hide(): void;
  41364. /**
  41365. * Launch the debugLayer.
  41366. * @param config Define the configuration of the inspector
  41367. * @return a promise fulfilled when the debug layer is visible
  41368. */
  41369. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41370. }
  41371. }
  41372. declare module BABYLON {
  41373. /**
  41374. * Class containing static functions to help procedurally build meshes
  41375. */
  41376. export class BoxBuilder {
  41377. /**
  41378. * Creates a box mesh
  41379. * * The parameter `size` sets the size (float) of each box side (default 1)
  41380. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41381. * * 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)
  41382. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41384. * * 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
  41385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41386. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41387. * @param name defines the name of the mesh
  41388. * @param options defines the options used to create the mesh
  41389. * @param scene defines the hosting scene
  41390. * @returns the box mesh
  41391. */
  41392. static CreateBox(name: string, options: {
  41393. size?: number;
  41394. width?: number;
  41395. height?: number;
  41396. depth?: number;
  41397. faceUV?: Vector4[];
  41398. faceColors?: Color4[];
  41399. sideOrientation?: number;
  41400. frontUVs?: Vector4;
  41401. backUVs?: Vector4;
  41402. wrap?: boolean;
  41403. topBaseAt?: number;
  41404. bottomBaseAt?: number;
  41405. updatable?: boolean;
  41406. }, scene?: Nullable<Scene>): Mesh;
  41407. }
  41408. }
  41409. declare module BABYLON {
  41410. /**
  41411. * Class containing static functions to help procedurally build meshes
  41412. */
  41413. export class SphereBuilder {
  41414. /**
  41415. * Creates a sphere mesh
  41416. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41417. * * 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`)
  41418. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41419. * * 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
  41420. * * 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)
  41421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41422. * * 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
  41423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41424. * @param name defines the name of the mesh
  41425. * @param options defines the options used to create the mesh
  41426. * @param scene defines the hosting scene
  41427. * @returns the sphere mesh
  41428. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41429. */
  41430. static CreateSphere(name: string, options: {
  41431. segments?: number;
  41432. diameter?: number;
  41433. diameterX?: number;
  41434. diameterY?: number;
  41435. diameterZ?: number;
  41436. arc?: number;
  41437. slice?: number;
  41438. sideOrientation?: number;
  41439. frontUVs?: Vector4;
  41440. backUVs?: Vector4;
  41441. updatable?: boolean;
  41442. }, scene: any): Mesh;
  41443. }
  41444. }
  41445. declare module BABYLON.Debug {
  41446. /**
  41447. * Used to show the physics impostor around the specific mesh
  41448. */
  41449. export class PhysicsViewer {
  41450. /** @hidden */
  41451. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41452. /** @hidden */
  41453. protected _meshes: Array<Nullable<AbstractMesh>>;
  41454. /** @hidden */
  41455. protected _scene: Nullable<Scene>;
  41456. /** @hidden */
  41457. protected _numMeshes: number;
  41458. /** @hidden */
  41459. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41460. private _renderFunction;
  41461. private _utilityLayer;
  41462. private _debugBoxMesh;
  41463. private _debugSphereMesh;
  41464. private _debugCylinderMesh;
  41465. private _debugMaterial;
  41466. private _debugMeshMeshes;
  41467. /**
  41468. * Creates a new PhysicsViewer
  41469. * @param scene defines the hosting scene
  41470. */
  41471. constructor(scene: Scene);
  41472. /** @hidden */
  41473. protected _updateDebugMeshes(): void;
  41474. /**
  41475. * Renders a specified physic impostor
  41476. * @param impostor defines the impostor to render
  41477. * @param targetMesh defines the mesh represented by the impostor
  41478. * @returns the new debug mesh used to render the impostor
  41479. */
  41480. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  41481. /**
  41482. * Hides a specified physic impostor
  41483. * @param impostor defines the impostor to hide
  41484. */
  41485. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41486. private _getDebugMaterial;
  41487. private _getDebugBoxMesh;
  41488. private _getDebugSphereMesh;
  41489. private _getDebugCylinderMesh;
  41490. private _getDebugMeshMesh;
  41491. private _getDebugMesh;
  41492. /** Releases all resources */
  41493. dispose(): void;
  41494. }
  41495. }
  41496. declare module BABYLON {
  41497. /**
  41498. * Class containing static functions to help procedurally build meshes
  41499. */
  41500. export class LinesBuilder {
  41501. /**
  41502. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41503. * * 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
  41504. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41505. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41506. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41507. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41508. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41509. * * 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
  41510. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41512. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41513. * @param name defines the name of the new line system
  41514. * @param options defines the options used to create the line system
  41515. * @param scene defines the hosting scene
  41516. * @returns a new line system mesh
  41517. */
  41518. static CreateLineSystem(name: string, options: {
  41519. lines: Vector3[][];
  41520. updatable?: boolean;
  41521. instance?: Nullable<LinesMesh>;
  41522. colors?: Nullable<Color4[][]>;
  41523. useVertexAlpha?: boolean;
  41524. }, scene: Nullable<Scene>): LinesMesh;
  41525. /**
  41526. * Creates a line mesh
  41527. * 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
  41528. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41529. * * The parameter `points` is an array successive Vector3
  41530. * * 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
  41531. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41532. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41533. * * When updating an instance, remember that only point positions can change, not the number of points
  41534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41535. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41536. * @param name defines the name of the new line system
  41537. * @param options defines the options used to create the line system
  41538. * @param scene defines the hosting scene
  41539. * @returns a new line mesh
  41540. */
  41541. static CreateLines(name: string, options: {
  41542. points: Vector3[];
  41543. updatable?: boolean;
  41544. instance?: Nullable<LinesMesh>;
  41545. colors?: Color4[];
  41546. useVertexAlpha?: boolean;
  41547. }, scene?: Nullable<Scene>): LinesMesh;
  41548. /**
  41549. * Creates a dashed line mesh
  41550. * * 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
  41551. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41552. * * The parameter `points` is an array successive Vector3
  41553. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41554. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41555. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41556. * * 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
  41557. * * When updating an instance, remember that only point positions can change, not the number of points
  41558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41559. * @param name defines the name of the mesh
  41560. * @param options defines the options used to create the mesh
  41561. * @param scene defines the hosting scene
  41562. * @returns the dashed line mesh
  41563. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41564. */
  41565. static CreateDashedLines(name: string, options: {
  41566. points: Vector3[];
  41567. dashSize?: number;
  41568. gapSize?: number;
  41569. dashNb?: number;
  41570. updatable?: boolean;
  41571. instance?: LinesMesh;
  41572. }, scene?: Nullable<Scene>): LinesMesh;
  41573. }
  41574. }
  41575. declare module BABYLON {
  41576. /**
  41577. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41578. * in order to better appreciate the issue one might have.
  41579. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41580. */
  41581. export class RayHelper {
  41582. /**
  41583. * Defines the ray we are currently tryin to visualize.
  41584. */
  41585. ray: Nullable<Ray>;
  41586. private _renderPoints;
  41587. private _renderLine;
  41588. private _renderFunction;
  41589. private _scene;
  41590. private _updateToMeshFunction;
  41591. private _attachedToMesh;
  41592. private _meshSpaceDirection;
  41593. private _meshSpaceOrigin;
  41594. /**
  41595. * Helper function to create a colored helper in a scene in one line.
  41596. * @param ray Defines the ray we are currently tryin to visualize
  41597. * @param scene Defines the scene the ray is used in
  41598. * @param color Defines the color we want to see the ray in
  41599. * @returns The newly created ray helper.
  41600. */
  41601. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41602. /**
  41603. * Instantiate a new ray helper.
  41604. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41605. * in order to better appreciate the issue one might have.
  41606. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41607. * @param ray Defines the ray we are currently tryin to visualize
  41608. */
  41609. constructor(ray: Ray);
  41610. /**
  41611. * Shows the ray we are willing to debug.
  41612. * @param scene Defines the scene the ray needs to be rendered in
  41613. * @param color Defines the color the ray needs to be rendered in
  41614. */
  41615. show(scene: Scene, color?: Color3): void;
  41616. /**
  41617. * Hides the ray we are debugging.
  41618. */
  41619. hide(): void;
  41620. private _render;
  41621. /**
  41622. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41623. * @param mesh Defines the mesh we want the helper attached to
  41624. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41625. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41626. * @param length Defines the length of the ray
  41627. */
  41628. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41629. /**
  41630. * Detach the ray helper from the mesh it has previously been attached to.
  41631. */
  41632. detachFromMesh(): void;
  41633. private _updateToMesh;
  41634. /**
  41635. * Dispose the helper and release its associated resources.
  41636. */
  41637. dispose(): void;
  41638. }
  41639. }
  41640. declare module BABYLON.Debug {
  41641. /**
  41642. * Class used to render a debug view of a given skeleton
  41643. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41644. */
  41645. export class SkeletonViewer {
  41646. /** defines the skeleton to render */
  41647. skeleton: Skeleton;
  41648. /** defines the mesh attached to the skeleton */
  41649. mesh: AbstractMesh;
  41650. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41651. autoUpdateBonesMatrices: boolean;
  41652. /** defines the rendering group id to use with the viewer */
  41653. renderingGroupId: number;
  41654. /** Gets or sets the color used to render the skeleton */
  41655. color: Color3;
  41656. private _scene;
  41657. private _debugLines;
  41658. private _debugMesh;
  41659. private _isEnabled;
  41660. private _renderFunction;
  41661. private _utilityLayer;
  41662. /**
  41663. * Returns the mesh used to render the bones
  41664. */
  41665. readonly debugMesh: Nullable<LinesMesh>;
  41666. /**
  41667. * Creates a new SkeletonViewer
  41668. * @param skeleton defines the skeleton to render
  41669. * @param mesh defines the mesh attached to the skeleton
  41670. * @param scene defines the hosting scene
  41671. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41672. * @param renderingGroupId defines the rendering group id to use with the viewer
  41673. */
  41674. constructor(
  41675. /** defines the skeleton to render */
  41676. skeleton: Skeleton,
  41677. /** defines the mesh attached to the skeleton */
  41678. mesh: AbstractMesh, scene: Scene,
  41679. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41680. autoUpdateBonesMatrices?: boolean,
  41681. /** defines the rendering group id to use with the viewer */
  41682. renderingGroupId?: number);
  41683. /** Gets or sets a boolean indicating if the viewer is enabled */
  41684. isEnabled: boolean;
  41685. private _getBonePosition;
  41686. private _getLinesForBonesWithLength;
  41687. private _getLinesForBonesNoLength;
  41688. /** Update the viewer to sync with current skeleton state */
  41689. update(): void;
  41690. /** Release associated resources */
  41691. dispose(): void;
  41692. }
  41693. }
  41694. declare module BABYLON {
  41695. /**
  41696. * Options to create the null engine
  41697. */
  41698. export class NullEngineOptions {
  41699. /**
  41700. * Render width (Default: 512)
  41701. */
  41702. renderWidth: number;
  41703. /**
  41704. * Render height (Default: 256)
  41705. */
  41706. renderHeight: number;
  41707. /**
  41708. * Texture size (Default: 512)
  41709. */
  41710. textureSize: number;
  41711. /**
  41712. * If delta time between frames should be constant
  41713. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41714. */
  41715. deterministicLockstep: boolean;
  41716. /**
  41717. * Maximum about of steps between frames (Default: 4)
  41718. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41719. */
  41720. lockstepMaxSteps: number;
  41721. }
  41722. /**
  41723. * The null engine class provides support for headless version of babylon.js.
  41724. * This can be used in server side scenario or for testing purposes
  41725. */
  41726. export class NullEngine extends Engine {
  41727. private _options;
  41728. /**
  41729. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41730. */
  41731. isDeterministicLockStep(): boolean;
  41732. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41733. getLockstepMaxSteps(): number;
  41734. /**
  41735. * Sets hardware scaling, used to save performance if needed
  41736. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41737. */
  41738. getHardwareScalingLevel(): number;
  41739. constructor(options?: NullEngineOptions);
  41740. createVertexBuffer(vertices: FloatArray): DataBuffer;
  41741. createIndexBuffer(indices: IndicesArray): DataBuffer;
  41742. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41743. getRenderWidth(useScreen?: boolean): number;
  41744. getRenderHeight(useScreen?: boolean): number;
  41745. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41746. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41747. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41748. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41749. bindSamplers(effect: Effect): void;
  41750. enableEffect(effect: Effect): void;
  41751. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41752. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41753. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41754. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41755. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41756. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41757. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41758. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41759. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41760. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41761. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41762. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41763. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41764. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41765. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41766. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41767. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41768. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41769. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41770. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41771. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41772. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41773. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41774. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41775. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41776. bindBuffers(vertexBuffers: {
  41777. [key: string]: VertexBuffer;
  41778. }, indexBuffer: DataBuffer, effect: Effect): void;
  41779. wipeCaches(bruteForce?: boolean): void;
  41780. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41781. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41782. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41783. /** @hidden */
  41784. _createTexture(): WebGLTexture;
  41785. /** @hidden */
  41786. _releaseTexture(texture: InternalTexture): void;
  41787. 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;
  41788. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41789. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41790. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41791. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41792. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  41793. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41794. areAllEffectsReady(): boolean;
  41795. /**
  41796. * @hidden
  41797. * Get the current error code of the webGL context
  41798. * @returns the error code
  41799. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41800. */
  41801. getError(): number;
  41802. /** @hidden */
  41803. _getUnpackAlignement(): number;
  41804. /** @hidden */
  41805. _unpackFlipY(value: boolean): void;
  41806. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41807. /**
  41808. * Updates a dynamic vertex buffer.
  41809. * @param vertexBuffer the vertex buffer to update
  41810. * @param data the data used to update the vertex buffer
  41811. * @param byteOffset the byte offset of the data (optional)
  41812. * @param byteLength the byte length of the data (optional)
  41813. */
  41814. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41815. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41816. /** @hidden */
  41817. _bindTexture(channel: number, texture: InternalTexture): void;
  41818. /** @hidden */
  41819. _releaseBuffer(buffer: DataBuffer): boolean;
  41820. releaseEffects(): void;
  41821. displayLoadingUI(): void;
  41822. hideLoadingUI(): void;
  41823. /** @hidden */
  41824. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41825. /** @hidden */
  41826. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41827. /** @hidden */
  41828. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41829. /** @hidden */
  41830. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41831. }
  41832. }
  41833. declare module BABYLON {
  41834. /** @hidden */
  41835. export class _OcclusionDataStorage {
  41836. /** @hidden */
  41837. occlusionInternalRetryCounter: number;
  41838. /** @hidden */
  41839. isOcclusionQueryInProgress: boolean;
  41840. /** @hidden */
  41841. isOccluded: boolean;
  41842. /** @hidden */
  41843. occlusionRetryCount: number;
  41844. /** @hidden */
  41845. occlusionType: number;
  41846. /** @hidden */
  41847. occlusionQueryAlgorithmType: number;
  41848. }
  41849. interface Engine {
  41850. /**
  41851. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41852. * @return the new query
  41853. */
  41854. createQuery(): WebGLQuery;
  41855. /**
  41856. * Delete and release a webGL query
  41857. * @param query defines the query to delete
  41858. * @return the current engine
  41859. */
  41860. deleteQuery(query: WebGLQuery): Engine;
  41861. /**
  41862. * Check if a given query has resolved and got its value
  41863. * @param query defines the query to check
  41864. * @returns true if the query got its value
  41865. */
  41866. isQueryResultAvailable(query: WebGLQuery): boolean;
  41867. /**
  41868. * Gets the value of a given query
  41869. * @param query defines the query to check
  41870. * @returns the value of the query
  41871. */
  41872. getQueryResult(query: WebGLQuery): number;
  41873. /**
  41874. * Initiates an occlusion query
  41875. * @param algorithmType defines the algorithm to use
  41876. * @param query defines the query to use
  41877. * @returns the current engine
  41878. * @see http://doc.babylonjs.com/features/occlusionquery
  41879. */
  41880. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41881. /**
  41882. * Ends an occlusion query
  41883. * @see http://doc.babylonjs.com/features/occlusionquery
  41884. * @param algorithmType defines the algorithm to use
  41885. * @returns the current engine
  41886. */
  41887. endOcclusionQuery(algorithmType: number): Engine;
  41888. /**
  41889. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41890. * Please note that only one query can be issued at a time
  41891. * @returns a time token used to track the time span
  41892. */
  41893. startTimeQuery(): Nullable<_TimeToken>;
  41894. /**
  41895. * Ends a time query
  41896. * @param token defines the token used to measure the time span
  41897. * @returns the time spent (in ns)
  41898. */
  41899. endTimeQuery(token: _TimeToken): int;
  41900. /** @hidden */
  41901. _currentNonTimestampToken: Nullable<_TimeToken>;
  41902. /** @hidden */
  41903. _createTimeQuery(): WebGLQuery;
  41904. /** @hidden */
  41905. _deleteTimeQuery(query: WebGLQuery): void;
  41906. /** @hidden */
  41907. _getGlAlgorithmType(algorithmType: number): number;
  41908. /** @hidden */
  41909. _getTimeQueryResult(query: WebGLQuery): any;
  41910. /** @hidden */
  41911. _getTimeQueryAvailability(query: WebGLQuery): any;
  41912. }
  41913. interface AbstractMesh {
  41914. /**
  41915. * Backing filed
  41916. * @hidden
  41917. */
  41918. __occlusionDataStorage: _OcclusionDataStorage;
  41919. /**
  41920. * Access property
  41921. * @hidden
  41922. */
  41923. _occlusionDataStorage: _OcclusionDataStorage;
  41924. /**
  41925. * 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.
  41926. * The default value is -1 which means don't break the query and wait till the result
  41927. * @see http://doc.babylonjs.com/features/occlusionquery
  41928. */
  41929. occlusionRetryCount: number;
  41930. /**
  41931. * 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:
  41932. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41933. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41934. * * 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.
  41935. * @see http://doc.babylonjs.com/features/occlusionquery
  41936. */
  41937. occlusionType: number;
  41938. /**
  41939. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41940. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41941. * * 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.
  41942. * @see http://doc.babylonjs.com/features/occlusionquery
  41943. */
  41944. occlusionQueryAlgorithmType: number;
  41945. /**
  41946. * 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
  41947. * @see http://doc.babylonjs.com/features/occlusionquery
  41948. */
  41949. isOccluded: boolean;
  41950. /**
  41951. * Flag to check the progress status of the query
  41952. * @see http://doc.babylonjs.com/features/occlusionquery
  41953. */
  41954. isOcclusionQueryInProgress: boolean;
  41955. }
  41956. }
  41957. declare module BABYLON {
  41958. /** @hidden */
  41959. export var _forceTransformFeedbackToBundle: boolean;
  41960. interface Engine {
  41961. /**
  41962. * Creates a webGL transform feedback object
  41963. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41964. * @returns the webGL transform feedback object
  41965. */
  41966. createTransformFeedback(): WebGLTransformFeedback;
  41967. /**
  41968. * Delete a webGL transform feedback object
  41969. * @param value defines the webGL transform feedback object to delete
  41970. */
  41971. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41972. /**
  41973. * Bind a webGL transform feedback object to the webgl context
  41974. * @param value defines the webGL transform feedback object to bind
  41975. */
  41976. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41977. /**
  41978. * Begins a transform feedback operation
  41979. * @param usePoints defines if points or triangles must be used
  41980. */
  41981. beginTransformFeedback(usePoints: boolean): void;
  41982. /**
  41983. * Ends a transform feedback operation
  41984. */
  41985. endTransformFeedback(): void;
  41986. /**
  41987. * Specify the varyings to use with transform feedback
  41988. * @param program defines the associated webGL program
  41989. * @param value defines the list of strings representing the varying names
  41990. */
  41991. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41992. /**
  41993. * Bind a webGL buffer for a transform feedback operation
  41994. * @param value defines the webGL buffer to bind
  41995. */
  41996. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  41997. }
  41998. }
  41999. declare module BABYLON {
  42000. /**
  42001. * Creation options of the multi render target texture.
  42002. */
  42003. export interface IMultiRenderTargetOptions {
  42004. /**
  42005. * Define if the texture needs to create mip maps after render.
  42006. */
  42007. generateMipMaps?: boolean;
  42008. /**
  42009. * Define the types of all the draw buffers we want to create
  42010. */
  42011. types?: number[];
  42012. /**
  42013. * Define the sampling modes of all the draw buffers we want to create
  42014. */
  42015. samplingModes?: number[];
  42016. /**
  42017. * Define if a depth buffer is required
  42018. */
  42019. generateDepthBuffer?: boolean;
  42020. /**
  42021. * Define if a stencil buffer is required
  42022. */
  42023. generateStencilBuffer?: boolean;
  42024. /**
  42025. * Define if a depth texture is required instead of a depth buffer
  42026. */
  42027. generateDepthTexture?: boolean;
  42028. /**
  42029. * Define the number of desired draw buffers
  42030. */
  42031. textureCount?: number;
  42032. /**
  42033. * Define if aspect ratio should be adapted to the texture or stay the scene one
  42034. */
  42035. doNotChangeAspectRatio?: boolean;
  42036. /**
  42037. * Define the default type of the buffers we are creating
  42038. */
  42039. defaultType?: number;
  42040. }
  42041. /**
  42042. * A multi render target, like a render target provides the ability to render to a texture.
  42043. * Unlike the render target, it can render to several draw buffers in one draw.
  42044. * This is specially interesting in deferred rendering or for any effects requiring more than
  42045. * just one color from a single pass.
  42046. */
  42047. export class MultiRenderTarget extends RenderTargetTexture {
  42048. private _internalTextures;
  42049. private _textures;
  42050. private _multiRenderTargetOptions;
  42051. /**
  42052. * Get if draw buffers are currently supported by the used hardware and browser.
  42053. */
  42054. readonly isSupported: boolean;
  42055. /**
  42056. * Get the list of textures generated by the multi render target.
  42057. */
  42058. readonly textures: Texture[];
  42059. /**
  42060. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  42061. */
  42062. readonly depthTexture: Texture;
  42063. /**
  42064. * Set the wrapping mode on U of all the textures we are rendering to.
  42065. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42066. */
  42067. wrapU: number;
  42068. /**
  42069. * Set the wrapping mode on V of all the textures we are rendering to.
  42070. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42071. */
  42072. wrapV: number;
  42073. /**
  42074. * Instantiate a new multi render target texture.
  42075. * A multi render target, like a render target provides the ability to render to a texture.
  42076. * Unlike the render target, it can render to several draw buffers in one draw.
  42077. * This is specially interesting in deferred rendering or for any effects requiring more than
  42078. * just one color from a single pass.
  42079. * @param name Define the name of the texture
  42080. * @param size Define the size of the buffers to render to
  42081. * @param count Define the number of target we are rendering into
  42082. * @param scene Define the scene the texture belongs to
  42083. * @param options Define the options used to create the multi render target
  42084. */
  42085. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  42086. /** @hidden */
  42087. _rebuild(): void;
  42088. private _createInternalTextures;
  42089. private _createTextures;
  42090. /**
  42091. * Define the number of samples used if MSAA is enabled.
  42092. */
  42093. samples: number;
  42094. /**
  42095. * Resize all the textures in the multi render target.
  42096. * Be carrefull as it will recreate all the data in the new texture.
  42097. * @param size Define the new size
  42098. */
  42099. resize(size: any): void;
  42100. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  42101. /**
  42102. * Dispose the render targets and their associated resources
  42103. */
  42104. dispose(): void;
  42105. /**
  42106. * Release all the underlying texture used as draw buffers.
  42107. */
  42108. releaseInternalTextures(): void;
  42109. }
  42110. }
  42111. declare module BABYLON {
  42112. interface Engine {
  42113. /**
  42114. * Unbind a list of render target textures from the webGL context
  42115. * This is used only when drawBuffer extension or webGL2 are active
  42116. * @param textures defines the render target textures to unbind
  42117. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  42118. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  42119. */
  42120. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  42121. /**
  42122. * Create a multi render target texture
  42123. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  42124. * @param size defines the size of the texture
  42125. * @param options defines the creation options
  42126. * @returns the cube texture as an InternalTexture
  42127. */
  42128. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  42129. /**
  42130. * Update the sample count for a given multiple render target texture
  42131. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42132. * @param textures defines the textures to update
  42133. * @param samples defines the sample count to set
  42134. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42135. */
  42136. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  42137. }
  42138. }
  42139. declare module BABYLON {
  42140. /**
  42141. * Gather the list of clipboard event types as constants.
  42142. */
  42143. export class ClipboardEventTypes {
  42144. /**
  42145. * The clipboard event is fired when a copy command is active (pressed).
  42146. */
  42147. static readonly COPY: number;
  42148. /**
  42149. * The clipboard event is fired when a cut command is active (pressed).
  42150. */
  42151. static readonly CUT: number;
  42152. /**
  42153. * The clipboard event is fired when a paste command is active (pressed).
  42154. */
  42155. static readonly PASTE: number;
  42156. }
  42157. /**
  42158. * This class is used to store clipboard related info for the onClipboardObservable event.
  42159. */
  42160. export class ClipboardInfo {
  42161. /**
  42162. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42163. */
  42164. type: number;
  42165. /**
  42166. * Defines the related dom event
  42167. */
  42168. event: ClipboardEvent;
  42169. /**
  42170. *Creates an instance of ClipboardInfo.
  42171. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42172. * @param event Defines the related dom event
  42173. */
  42174. constructor(
  42175. /**
  42176. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42177. */
  42178. type: number,
  42179. /**
  42180. * Defines the related dom event
  42181. */
  42182. event: ClipboardEvent);
  42183. /**
  42184. * Get the clipboard event's type from the keycode.
  42185. * @param keyCode Defines the keyCode for the current keyboard event.
  42186. * @return {number}
  42187. */
  42188. static GetTypeFromCharacter(keyCode: number): number;
  42189. }
  42190. }
  42191. declare module BABYLON {
  42192. /**
  42193. * Class used to represent data loading progression
  42194. */
  42195. export class SceneLoaderProgressEvent {
  42196. /** defines if data length to load can be evaluated */
  42197. readonly lengthComputable: boolean;
  42198. /** defines the loaded data length */
  42199. readonly loaded: number;
  42200. /** defines the data length to load */
  42201. readonly total: number;
  42202. /**
  42203. * Create a new progress event
  42204. * @param lengthComputable defines if data length to load can be evaluated
  42205. * @param loaded defines the loaded data length
  42206. * @param total defines the data length to load
  42207. */
  42208. constructor(
  42209. /** defines if data length to load can be evaluated */
  42210. lengthComputable: boolean,
  42211. /** defines the loaded data length */
  42212. loaded: number,
  42213. /** defines the data length to load */
  42214. total: number);
  42215. /**
  42216. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42217. * @param event defines the source event
  42218. * @returns a new SceneLoaderProgressEvent
  42219. */
  42220. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42221. }
  42222. /**
  42223. * Interface used by SceneLoader plugins to define supported file extensions
  42224. */
  42225. export interface ISceneLoaderPluginExtensions {
  42226. /**
  42227. * Defines the list of supported extensions
  42228. */
  42229. [extension: string]: {
  42230. isBinary: boolean;
  42231. };
  42232. }
  42233. /**
  42234. * Interface used by SceneLoader plugin factory
  42235. */
  42236. export interface ISceneLoaderPluginFactory {
  42237. /**
  42238. * Defines the name of the factory
  42239. */
  42240. name: string;
  42241. /**
  42242. * Function called to create a new plugin
  42243. * @return the new plugin
  42244. */
  42245. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42246. /**
  42247. * Boolean indicating if the plugin can direct load specific data
  42248. */
  42249. canDirectLoad?: (data: string) => boolean;
  42250. }
  42251. /**
  42252. * Interface used to define a SceneLoader plugin
  42253. */
  42254. export interface ISceneLoaderPlugin {
  42255. /**
  42256. * The friendly name of this plugin.
  42257. */
  42258. name: string;
  42259. /**
  42260. * The file extensions supported by this plugin.
  42261. */
  42262. extensions: string | ISceneLoaderPluginExtensions;
  42263. /**
  42264. * Import meshes into a scene.
  42265. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42266. * @param scene The scene to import into
  42267. * @param data The data to import
  42268. * @param rootUrl The root url for scene and resources
  42269. * @param meshes The meshes array to import into
  42270. * @param particleSystems The particle systems array to import into
  42271. * @param skeletons The skeletons array to import into
  42272. * @param onError The callback when import fails
  42273. * @returns True if successful or false otherwise
  42274. */
  42275. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42276. /**
  42277. * Load into a scene.
  42278. * @param scene The scene to load into
  42279. * @param data The data to import
  42280. * @param rootUrl The root url for scene and resources
  42281. * @param onError The callback when import fails
  42282. * @returns true if successful or false otherwise
  42283. */
  42284. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42285. /**
  42286. * The callback that returns true if the data can be directly loaded.
  42287. */
  42288. canDirectLoad?: (data: string) => boolean;
  42289. /**
  42290. * The callback that allows custom handling of the root url based on the response url.
  42291. */
  42292. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42293. /**
  42294. * Load into an asset container.
  42295. * @param scene The scene to load into
  42296. * @param data The data to import
  42297. * @param rootUrl The root url for scene and resources
  42298. * @param onError The callback when import fails
  42299. * @returns The loaded asset container
  42300. */
  42301. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42302. }
  42303. /**
  42304. * Interface used to define an async SceneLoader plugin
  42305. */
  42306. export interface ISceneLoaderPluginAsync {
  42307. /**
  42308. * The friendly name of this plugin.
  42309. */
  42310. name: string;
  42311. /**
  42312. * The file extensions supported by this plugin.
  42313. */
  42314. extensions: string | ISceneLoaderPluginExtensions;
  42315. /**
  42316. * Import meshes into a scene.
  42317. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42318. * @param scene The scene to import into
  42319. * @param data The data to import
  42320. * @param rootUrl The root url for scene and resources
  42321. * @param onProgress The callback when the load progresses
  42322. * @param fileName Defines the name of the file to load
  42323. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42324. */
  42325. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42326. meshes: AbstractMesh[];
  42327. particleSystems: IParticleSystem[];
  42328. skeletons: Skeleton[];
  42329. animationGroups: AnimationGroup[];
  42330. }>;
  42331. /**
  42332. * Load into a scene.
  42333. * @param scene The scene to load into
  42334. * @param data The data to import
  42335. * @param rootUrl The root url for scene and resources
  42336. * @param onProgress The callback when the load progresses
  42337. * @param fileName Defines the name of the file to load
  42338. * @returns Nothing
  42339. */
  42340. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42341. /**
  42342. * The callback that returns true if the data can be directly loaded.
  42343. */
  42344. canDirectLoad?: (data: string) => boolean;
  42345. /**
  42346. * The callback that allows custom handling of the root url based on the response url.
  42347. */
  42348. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42349. /**
  42350. * Load into an asset container.
  42351. * @param scene The scene to load into
  42352. * @param data The data to import
  42353. * @param rootUrl The root url for scene and resources
  42354. * @param onProgress The callback when the load progresses
  42355. * @param fileName Defines the name of the file to load
  42356. * @returns The loaded asset container
  42357. */
  42358. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42359. }
  42360. /**
  42361. * Class used to load scene from various file formats using registered plugins
  42362. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42363. */
  42364. export class SceneLoader {
  42365. /**
  42366. * No logging while loading
  42367. */
  42368. static readonly NO_LOGGING: number;
  42369. /**
  42370. * Minimal logging while loading
  42371. */
  42372. static readonly MINIMAL_LOGGING: number;
  42373. /**
  42374. * Summary logging while loading
  42375. */
  42376. static readonly SUMMARY_LOGGING: number;
  42377. /**
  42378. * Detailled logging while loading
  42379. */
  42380. static readonly DETAILED_LOGGING: number;
  42381. /**
  42382. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42383. */
  42384. static ForceFullSceneLoadingForIncremental: boolean;
  42385. /**
  42386. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42387. */
  42388. static ShowLoadingScreen: boolean;
  42389. /**
  42390. * Defines the current logging level (while loading the scene)
  42391. * @ignorenaming
  42392. */
  42393. static loggingLevel: number;
  42394. /**
  42395. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42396. */
  42397. static CleanBoneMatrixWeights: boolean;
  42398. /**
  42399. * Event raised when a plugin is used to load a scene
  42400. */
  42401. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42402. private static _registeredPlugins;
  42403. private static _getDefaultPlugin;
  42404. private static _getPluginForExtension;
  42405. private static _getPluginForDirectLoad;
  42406. private static _getPluginForFilename;
  42407. private static _getDirectLoad;
  42408. private static _loadData;
  42409. private static _getFileInfo;
  42410. /**
  42411. * Gets a plugin that can load the given extension
  42412. * @param extension defines the extension to load
  42413. * @returns a plugin or null if none works
  42414. */
  42415. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42416. /**
  42417. * Gets a boolean indicating that the given extension can be loaded
  42418. * @param extension defines the extension to load
  42419. * @returns true if the extension is supported
  42420. */
  42421. static IsPluginForExtensionAvailable(extension: string): boolean;
  42422. /**
  42423. * Adds a new plugin to the list of registered plugins
  42424. * @param plugin defines the plugin to add
  42425. */
  42426. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42427. /**
  42428. * Import meshes into a scene
  42429. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42430. * @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)
  42431. * @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)
  42432. * @param scene the instance of BABYLON.Scene to append to
  42433. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42434. * @param onProgress a callback with a progress event for each file being loaded
  42435. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42436. * @param pluginExtension the extension used to determine the plugin
  42437. * @returns The loaded plugin
  42438. */
  42439. 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>;
  42440. /**
  42441. * Import meshes into a scene
  42442. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42443. * @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)
  42444. * @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)
  42445. * @param scene the instance of BABYLON.Scene to append to
  42446. * @param onProgress a callback with a progress event for each file being loaded
  42447. * @param pluginExtension the extension used to determine the plugin
  42448. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42449. */
  42450. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42451. meshes: AbstractMesh[];
  42452. particleSystems: IParticleSystem[];
  42453. skeletons: Skeleton[];
  42454. animationGroups: AnimationGroup[];
  42455. }>;
  42456. /**
  42457. * Load a scene
  42458. * @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)
  42459. * @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)
  42460. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42461. * @param onSuccess a callback with the scene when import succeeds
  42462. * @param onProgress a callback with a progress event for each file being loaded
  42463. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42464. * @param pluginExtension the extension used to determine the plugin
  42465. * @returns The loaded plugin
  42466. */
  42467. 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>;
  42468. /**
  42469. * Load a scene
  42470. * @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)
  42471. * @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)
  42472. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42473. * @param onProgress a callback with a progress event for each file being loaded
  42474. * @param pluginExtension the extension used to determine the plugin
  42475. * @returns The loaded scene
  42476. */
  42477. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42478. /**
  42479. * Append a scene
  42480. * @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)
  42481. * @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)
  42482. * @param scene is the instance of BABYLON.Scene to append to
  42483. * @param onSuccess a callback with the scene when import succeeds
  42484. * @param onProgress a callback with a progress event for each file being loaded
  42485. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42486. * @param pluginExtension the extension used to determine the plugin
  42487. * @returns The loaded plugin
  42488. */
  42489. 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>;
  42490. /**
  42491. * Append a scene
  42492. * @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)
  42493. * @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)
  42494. * @param scene is the instance of BABYLON.Scene to append to
  42495. * @param onProgress a callback with a progress event for each file being loaded
  42496. * @param pluginExtension the extension used to determine the plugin
  42497. * @returns The given scene
  42498. */
  42499. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42500. /**
  42501. * Load a scene into an asset container
  42502. * @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)
  42503. * @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)
  42504. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42505. * @param onSuccess a callback with the scene when import succeeds
  42506. * @param onProgress a callback with a progress event for each file being loaded
  42507. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42508. * @param pluginExtension the extension used to determine the plugin
  42509. * @returns The loaded plugin
  42510. */
  42511. 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>;
  42512. /**
  42513. * Load a scene into an asset container
  42514. * @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)
  42515. * @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)
  42516. * @param scene is the instance of Scene to append to
  42517. * @param onProgress a callback with a progress event for each file being loaded
  42518. * @param pluginExtension the extension used to determine the plugin
  42519. * @returns The loaded asset container
  42520. */
  42521. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42522. }
  42523. }
  42524. declare module BABYLON {
  42525. /**
  42526. * Google Daydream controller
  42527. */
  42528. export class DaydreamController extends WebVRController {
  42529. /**
  42530. * Base Url for the controller model.
  42531. */
  42532. static MODEL_BASE_URL: string;
  42533. /**
  42534. * File name for the controller model.
  42535. */
  42536. static MODEL_FILENAME: string;
  42537. /**
  42538. * Gamepad Id prefix used to identify Daydream Controller.
  42539. */
  42540. static readonly GAMEPAD_ID_PREFIX: string;
  42541. /**
  42542. * Creates a new DaydreamController from a gamepad
  42543. * @param vrGamepad the gamepad that the controller should be created from
  42544. */
  42545. constructor(vrGamepad: any);
  42546. /**
  42547. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42548. * @param scene scene in which to add meshes
  42549. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42550. */
  42551. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42552. /**
  42553. * Called once for each button that changed state since the last frame
  42554. * @param buttonIdx Which button index changed
  42555. * @param state New state of the button
  42556. * @param changes Which properties on the state changed since last frame
  42557. */
  42558. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42559. }
  42560. }
  42561. declare module BABYLON {
  42562. /**
  42563. * Gear VR Controller
  42564. */
  42565. export class GearVRController extends WebVRController {
  42566. /**
  42567. * Base Url for the controller model.
  42568. */
  42569. static MODEL_BASE_URL: string;
  42570. /**
  42571. * File name for the controller model.
  42572. */
  42573. static MODEL_FILENAME: string;
  42574. /**
  42575. * Gamepad Id prefix used to identify this controller.
  42576. */
  42577. static readonly GAMEPAD_ID_PREFIX: string;
  42578. private readonly _buttonIndexToObservableNameMap;
  42579. /**
  42580. * Creates a new GearVRController from a gamepad
  42581. * @param vrGamepad the gamepad that the controller should be created from
  42582. */
  42583. constructor(vrGamepad: any);
  42584. /**
  42585. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42586. * @param scene scene in which to add meshes
  42587. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42588. */
  42589. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42590. /**
  42591. * Called once for each button that changed state since the last frame
  42592. * @param buttonIdx Which button index changed
  42593. * @param state New state of the button
  42594. * @param changes Which properties on the state changed since last frame
  42595. */
  42596. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42597. }
  42598. }
  42599. declare module BABYLON {
  42600. /**
  42601. * Generic Controller
  42602. */
  42603. export class GenericController extends WebVRController {
  42604. /**
  42605. * Base Url for the controller model.
  42606. */
  42607. static readonly MODEL_BASE_URL: string;
  42608. /**
  42609. * File name for the controller model.
  42610. */
  42611. static readonly MODEL_FILENAME: string;
  42612. /**
  42613. * Creates a new GenericController from a gamepad
  42614. * @param vrGamepad the gamepad that the controller should be created from
  42615. */
  42616. constructor(vrGamepad: any);
  42617. /**
  42618. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42619. * @param scene scene in which to add meshes
  42620. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42621. */
  42622. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42623. /**
  42624. * Called once for each button that changed state since the last frame
  42625. * @param buttonIdx Which button index changed
  42626. * @param state New state of the button
  42627. * @param changes Which properties on the state changed since last frame
  42628. */
  42629. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42630. }
  42631. }
  42632. declare module BABYLON {
  42633. /**
  42634. * Oculus Touch Controller
  42635. */
  42636. export class OculusTouchController extends WebVRController {
  42637. /**
  42638. * Base Url for the controller model.
  42639. */
  42640. static MODEL_BASE_URL: string;
  42641. /**
  42642. * File name for the left controller model.
  42643. */
  42644. static MODEL_LEFT_FILENAME: string;
  42645. /**
  42646. * File name for the right controller model.
  42647. */
  42648. static MODEL_RIGHT_FILENAME: string;
  42649. /**
  42650. * Fired when the secondary trigger on this controller is modified
  42651. */
  42652. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42653. /**
  42654. * Fired when the thumb rest on this controller is modified
  42655. */
  42656. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42657. /**
  42658. * Creates a new OculusTouchController from a gamepad
  42659. * @param vrGamepad the gamepad that the controller should be created from
  42660. */
  42661. constructor(vrGamepad: any);
  42662. /**
  42663. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42664. * @param scene scene in which to add meshes
  42665. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42666. */
  42667. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42668. /**
  42669. * Fired when the A button on this controller is modified
  42670. */
  42671. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42672. /**
  42673. * Fired when the B button on this controller is modified
  42674. */
  42675. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42676. /**
  42677. * Fired when the X button on this controller is modified
  42678. */
  42679. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42680. /**
  42681. * Fired when the Y button on this controller is modified
  42682. */
  42683. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42684. /**
  42685. * Called once for each button that changed state since the last frame
  42686. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42687. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42688. * 2) secondary trigger (same)
  42689. * 3) A (right) X (left), touch, pressed = value
  42690. * 4) B / Y
  42691. * 5) thumb rest
  42692. * @param buttonIdx Which button index changed
  42693. * @param state New state of the button
  42694. * @param changes Which properties on the state changed since last frame
  42695. */
  42696. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42697. }
  42698. }
  42699. declare module BABYLON {
  42700. /**
  42701. * Vive Controller
  42702. */
  42703. export class ViveController extends WebVRController {
  42704. /**
  42705. * Base Url for the controller model.
  42706. */
  42707. static MODEL_BASE_URL: string;
  42708. /**
  42709. * File name for the controller model.
  42710. */
  42711. static MODEL_FILENAME: string;
  42712. /**
  42713. * Creates a new ViveController from a gamepad
  42714. * @param vrGamepad the gamepad that the controller should be created from
  42715. */
  42716. constructor(vrGamepad: any);
  42717. /**
  42718. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42719. * @param scene scene in which to add meshes
  42720. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42721. */
  42722. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42723. /**
  42724. * Fired when the left button on this controller is modified
  42725. */
  42726. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42727. /**
  42728. * Fired when the right button on this controller is modified
  42729. */
  42730. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42731. /**
  42732. * Fired when the menu button on this controller is modified
  42733. */
  42734. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42735. /**
  42736. * Called once for each button that changed state since the last frame
  42737. * Vive mapping:
  42738. * 0: touchpad
  42739. * 1: trigger
  42740. * 2: left AND right buttons
  42741. * 3: menu button
  42742. * @param buttonIdx Which button index changed
  42743. * @param state New state of the button
  42744. * @param changes Which properties on the state changed since last frame
  42745. */
  42746. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42747. }
  42748. }
  42749. declare module BABYLON {
  42750. /**
  42751. * Defines the WindowsMotionController object that the state of the windows motion controller
  42752. */
  42753. export class WindowsMotionController extends WebVRController {
  42754. /**
  42755. * The base url used to load the left and right controller models
  42756. */
  42757. static MODEL_BASE_URL: string;
  42758. /**
  42759. * The name of the left controller model file
  42760. */
  42761. static MODEL_LEFT_FILENAME: string;
  42762. /**
  42763. * The name of the right controller model file
  42764. */
  42765. static MODEL_RIGHT_FILENAME: string;
  42766. /**
  42767. * The controller name prefix for this controller type
  42768. */
  42769. static readonly GAMEPAD_ID_PREFIX: string;
  42770. /**
  42771. * The controller id pattern for this controller type
  42772. */
  42773. private static readonly GAMEPAD_ID_PATTERN;
  42774. private _loadedMeshInfo;
  42775. private readonly _mapping;
  42776. /**
  42777. * Fired when the trackpad on this controller is clicked
  42778. */
  42779. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42780. /**
  42781. * Fired when the trackpad on this controller is modified
  42782. */
  42783. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42784. /**
  42785. * The current x and y values of this controller's trackpad
  42786. */
  42787. trackpad: StickValues;
  42788. /**
  42789. * Creates a new WindowsMotionController from a gamepad
  42790. * @param vrGamepad the gamepad that the controller should be created from
  42791. */
  42792. constructor(vrGamepad: any);
  42793. /**
  42794. * Fired when the trigger on this controller is modified
  42795. */
  42796. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42797. /**
  42798. * Fired when the menu button on this controller is modified
  42799. */
  42800. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42801. /**
  42802. * Fired when the grip button on this controller is modified
  42803. */
  42804. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42805. /**
  42806. * Fired when the thumbstick button on this controller is modified
  42807. */
  42808. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42809. /**
  42810. * Fired when the touchpad button on this controller is modified
  42811. */
  42812. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42813. /**
  42814. * Fired when the touchpad values on this controller are modified
  42815. */
  42816. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42817. private _updateTrackpad;
  42818. /**
  42819. * Called once per frame by the engine.
  42820. */
  42821. update(): void;
  42822. /**
  42823. * Called once for each button that changed state since the last frame
  42824. * @param buttonIdx Which button index changed
  42825. * @param state New state of the button
  42826. * @param changes Which properties on the state changed since last frame
  42827. */
  42828. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42829. /**
  42830. * Moves the buttons on the controller mesh based on their current state
  42831. * @param buttonName the name of the button to move
  42832. * @param buttonValue the value of the button which determines the buttons new position
  42833. */
  42834. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42835. /**
  42836. * Moves the axis on the controller mesh based on its current state
  42837. * @param axis the index of the axis
  42838. * @param axisValue the value of the axis which determines the meshes new position
  42839. * @hidden
  42840. */
  42841. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42842. /**
  42843. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42844. * @param scene scene in which to add meshes
  42845. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42846. */
  42847. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42848. /**
  42849. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42850. * can be transformed by button presses and axes values, based on this._mapping.
  42851. *
  42852. * @param scene scene in which the meshes exist
  42853. * @param meshes list of meshes that make up the controller model to process
  42854. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42855. */
  42856. private processModel;
  42857. private createMeshInfo;
  42858. /**
  42859. * Gets the ray of the controller in the direction the controller is pointing
  42860. * @param length the length the resulting ray should be
  42861. * @returns a ray in the direction the controller is pointing
  42862. */
  42863. getForwardRay(length?: number): Ray;
  42864. /**
  42865. * Disposes of the controller
  42866. */
  42867. dispose(): void;
  42868. }
  42869. }
  42870. declare module BABYLON {
  42871. /**
  42872. * Class containing static functions to help procedurally build meshes
  42873. */
  42874. export class PolyhedronBuilder {
  42875. /**
  42876. * Creates a polyhedron mesh
  42877. * * 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
  42878. * * The parameter `size` (positive float, default 1) sets the polygon size
  42879. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42880. * * 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`
  42881. * * 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
  42882. * * 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)`)
  42883. * * 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
  42884. * * 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
  42885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42886. * * 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
  42887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42888. * @param name defines the name of the mesh
  42889. * @param options defines the options used to create the mesh
  42890. * @param scene defines the hosting scene
  42891. * @returns the polyhedron mesh
  42892. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42893. */
  42894. static CreatePolyhedron(name: string, options: {
  42895. type?: number;
  42896. size?: number;
  42897. sizeX?: number;
  42898. sizeY?: number;
  42899. sizeZ?: number;
  42900. custom?: any;
  42901. faceUV?: Vector4[];
  42902. faceColors?: Color4[];
  42903. flat?: boolean;
  42904. updatable?: boolean;
  42905. sideOrientation?: number;
  42906. frontUVs?: Vector4;
  42907. backUVs?: Vector4;
  42908. }, scene?: Nullable<Scene>): Mesh;
  42909. }
  42910. }
  42911. declare module BABYLON {
  42912. /**
  42913. * Gizmo that enables scaling a mesh along 3 axis
  42914. */
  42915. export class ScaleGizmo extends Gizmo {
  42916. /**
  42917. * Internal gizmo used for interactions on the x axis
  42918. */
  42919. xGizmo: AxisScaleGizmo;
  42920. /**
  42921. * Internal gizmo used for interactions on the y axis
  42922. */
  42923. yGizmo: AxisScaleGizmo;
  42924. /**
  42925. * Internal gizmo used for interactions on the z axis
  42926. */
  42927. zGizmo: AxisScaleGizmo;
  42928. /**
  42929. * Internal gizmo used to scale all axis equally
  42930. */
  42931. uniformScaleGizmo: AxisScaleGizmo;
  42932. private _meshAttached;
  42933. private _updateGizmoRotationToMatchAttachedMesh;
  42934. private _snapDistance;
  42935. private _scaleRatio;
  42936. private _uniformScalingMesh;
  42937. private _octahedron;
  42938. /** Fires an event when any of it's sub gizmos are dragged */
  42939. onDragStartObservable: Observable<{}>;
  42940. /** Fires an event when any of it's sub gizmos are released from dragging */
  42941. onDragEndObservable: Observable<{}>;
  42942. attachedMesh: Nullable<AbstractMesh>;
  42943. /**
  42944. * Creates a ScaleGizmo
  42945. * @param gizmoLayer The utility layer the gizmo will be added to
  42946. */
  42947. constructor(gizmoLayer?: UtilityLayerRenderer);
  42948. updateGizmoRotationToMatchAttachedMesh: boolean;
  42949. /**
  42950. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42951. */
  42952. snapDistance: number;
  42953. /**
  42954. * Ratio for the scale of the gizmo (Default: 1)
  42955. */
  42956. scaleRatio: number;
  42957. /**
  42958. * Disposes of the gizmo
  42959. */
  42960. dispose(): void;
  42961. }
  42962. }
  42963. declare module BABYLON {
  42964. /**
  42965. * Single axis scale gizmo
  42966. */
  42967. export class AxisScaleGizmo extends Gizmo {
  42968. /**
  42969. * Drag behavior responsible for the gizmos dragging interactions
  42970. */
  42971. dragBehavior: PointerDragBehavior;
  42972. private _pointerObserver;
  42973. /**
  42974. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42975. */
  42976. snapDistance: number;
  42977. /**
  42978. * Event that fires each time the gizmo snaps to a new location.
  42979. * * snapDistance is the the change in distance
  42980. */
  42981. onSnapObservable: Observable<{
  42982. snapDistance: number;
  42983. }>;
  42984. /**
  42985. * If the scaling operation should be done on all axis (default: false)
  42986. */
  42987. uniformScaling: boolean;
  42988. private _isEnabled;
  42989. private _parent;
  42990. private _arrow;
  42991. private _coloredMaterial;
  42992. private _hoverMaterial;
  42993. /**
  42994. * Creates an AxisScaleGizmo
  42995. * @param gizmoLayer The utility layer the gizmo will be added to
  42996. * @param dragAxis The axis which the gizmo will be able to scale on
  42997. * @param color The color of the gizmo
  42998. */
  42999. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43000. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43001. /**
  43002. * If the gizmo is enabled
  43003. */
  43004. isEnabled: boolean;
  43005. /**
  43006. * Disposes of the gizmo
  43007. */
  43008. dispose(): void;
  43009. /**
  43010. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43011. * @param mesh The mesh to replace the default mesh of the gizmo
  43012. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43013. */
  43014. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43015. }
  43016. }
  43017. declare module BABYLON {
  43018. /**
  43019. * Bounding box gizmo
  43020. */
  43021. export class BoundingBoxGizmo extends Gizmo {
  43022. private _lineBoundingBox;
  43023. private _rotateSpheresParent;
  43024. private _scaleBoxesParent;
  43025. private _boundingDimensions;
  43026. private _renderObserver;
  43027. private _pointerObserver;
  43028. private _scaleDragSpeed;
  43029. private _tmpQuaternion;
  43030. private _tmpVector;
  43031. private _tmpRotationMatrix;
  43032. /**
  43033. * 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)
  43034. */
  43035. ignoreChildren: boolean;
  43036. /**
  43037. * 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)
  43038. */
  43039. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43040. /**
  43041. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43042. */
  43043. rotationSphereSize: number;
  43044. /**
  43045. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43046. */
  43047. scaleBoxSize: number;
  43048. /**
  43049. * 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)
  43050. */
  43051. fixedDragMeshScreenSize: boolean;
  43052. /**
  43053. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43054. */
  43055. fixedDragMeshScreenSizeDistanceFactor: number;
  43056. /**
  43057. * Fired when a rotation sphere or scale box is dragged
  43058. */
  43059. onDragStartObservable: Observable<{}>;
  43060. /**
  43061. * Fired when a scale box is dragged
  43062. */
  43063. onScaleBoxDragObservable: Observable<{}>;
  43064. /**
  43065. * Fired when a scale box drag is ended
  43066. */
  43067. onScaleBoxDragEndObservable: Observable<{}>;
  43068. /**
  43069. * Fired when a rotation sphere is dragged
  43070. */
  43071. onRotationSphereDragObservable: Observable<{}>;
  43072. /**
  43073. * Fired when a rotation sphere drag is ended
  43074. */
  43075. onRotationSphereDragEndObservable: Observable<{}>;
  43076. /**
  43077. * 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)
  43078. */
  43079. scalePivot: Nullable<Vector3>;
  43080. /**
  43081. * Mesh used as a pivot to rotate the attached mesh
  43082. */
  43083. private _anchorMesh;
  43084. private _existingMeshScale;
  43085. private _dragMesh;
  43086. private pointerDragBehavior;
  43087. private coloredMaterial;
  43088. private hoverColoredMaterial;
  43089. /**
  43090. * Sets the color of the bounding box gizmo
  43091. * @param color the color to set
  43092. */
  43093. setColor(color: Color3): void;
  43094. /**
  43095. * Creates an BoundingBoxGizmo
  43096. * @param gizmoLayer The utility layer the gizmo will be added to
  43097. * @param color The color of the gizmo
  43098. */
  43099. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43100. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43101. private _selectNode;
  43102. /**
  43103. * Updates the bounding box information for the Gizmo
  43104. */
  43105. updateBoundingBox(): void;
  43106. private _updateRotationSpheres;
  43107. private _updateScaleBoxes;
  43108. /**
  43109. * Enables rotation on the specified axis and disables rotation on the others
  43110. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43111. */
  43112. setEnabledRotationAxis(axis: string): void;
  43113. /**
  43114. * Enables/disables scaling
  43115. * @param enable if scaling should be enabled
  43116. */
  43117. setEnabledScaling(enable: boolean): void;
  43118. private _updateDummy;
  43119. /**
  43120. * Enables a pointer drag behavior on the bounding box of the gizmo
  43121. */
  43122. enableDragBehavior(): void;
  43123. /**
  43124. * Disposes of the gizmo
  43125. */
  43126. dispose(): void;
  43127. /**
  43128. * 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)
  43129. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43130. * @returns the bounding box mesh with the passed in mesh as a child
  43131. */
  43132. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43133. /**
  43134. * CustomMeshes are not supported by this gizmo
  43135. * @param mesh The mesh to replace the default mesh of the gizmo
  43136. */
  43137. setCustomMesh(mesh: Mesh): void;
  43138. }
  43139. }
  43140. declare module BABYLON {
  43141. /**
  43142. * Single plane rotation gizmo
  43143. */
  43144. export class PlaneRotationGizmo extends Gizmo {
  43145. /**
  43146. * Drag behavior responsible for the gizmos dragging interactions
  43147. */
  43148. dragBehavior: PointerDragBehavior;
  43149. private _pointerObserver;
  43150. /**
  43151. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43152. */
  43153. snapDistance: number;
  43154. /**
  43155. * Event that fires each time the gizmo snaps to a new location.
  43156. * * snapDistance is the the change in distance
  43157. */
  43158. onSnapObservable: Observable<{
  43159. snapDistance: number;
  43160. }>;
  43161. private _isEnabled;
  43162. private _parent;
  43163. /**
  43164. * Creates a PlaneRotationGizmo
  43165. * @param gizmoLayer The utility layer the gizmo will be added to
  43166. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43167. * @param color The color of the gizmo
  43168. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43169. */
  43170. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  43171. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43172. /**
  43173. * If the gizmo is enabled
  43174. */
  43175. isEnabled: boolean;
  43176. /**
  43177. * Disposes of the gizmo
  43178. */
  43179. dispose(): void;
  43180. }
  43181. }
  43182. declare module BABYLON {
  43183. /**
  43184. * Gizmo that enables rotating a mesh along 3 axis
  43185. */
  43186. export class RotationGizmo extends Gizmo {
  43187. /**
  43188. * Internal gizmo used for interactions on the x axis
  43189. */
  43190. xGizmo: PlaneRotationGizmo;
  43191. /**
  43192. * Internal gizmo used for interactions on the y axis
  43193. */
  43194. yGizmo: PlaneRotationGizmo;
  43195. /**
  43196. * Internal gizmo used for interactions on the z axis
  43197. */
  43198. zGizmo: PlaneRotationGizmo;
  43199. /** Fires an event when any of it's sub gizmos are dragged */
  43200. onDragStartObservable: Observable<{}>;
  43201. /** Fires an event when any of it's sub gizmos are released from dragging */
  43202. onDragEndObservable: Observable<{}>;
  43203. private _meshAttached;
  43204. attachedMesh: Nullable<AbstractMesh>;
  43205. /**
  43206. * Creates a RotationGizmo
  43207. * @param gizmoLayer The utility layer the gizmo will be added to
  43208. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43209. */
  43210. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43211. updateGizmoRotationToMatchAttachedMesh: boolean;
  43212. /**
  43213. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43214. */
  43215. snapDistance: number;
  43216. /**
  43217. * Ratio for the scale of the gizmo (Default: 1)
  43218. */
  43219. scaleRatio: number;
  43220. /**
  43221. * Disposes of the gizmo
  43222. */
  43223. dispose(): void;
  43224. /**
  43225. * CustomMeshes are not supported by this gizmo
  43226. * @param mesh The mesh to replace the default mesh of the gizmo
  43227. */
  43228. setCustomMesh(mesh: Mesh): void;
  43229. }
  43230. }
  43231. declare module BABYLON {
  43232. /**
  43233. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43234. */
  43235. export class GizmoManager implements IDisposable {
  43236. private scene;
  43237. /**
  43238. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43239. */
  43240. gizmos: {
  43241. positionGizmo: Nullable<PositionGizmo>;
  43242. rotationGizmo: Nullable<RotationGizmo>;
  43243. scaleGizmo: Nullable<ScaleGizmo>;
  43244. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43245. };
  43246. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43247. clearGizmoOnEmptyPointerEvent: boolean;
  43248. /** Fires an event when the manager is attached to a mesh */
  43249. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43250. private _gizmosEnabled;
  43251. private _pointerObserver;
  43252. private _attachedMesh;
  43253. private _boundingBoxColor;
  43254. private _defaultUtilityLayer;
  43255. private _defaultKeepDepthUtilityLayer;
  43256. /**
  43257. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43258. */
  43259. boundingBoxDragBehavior: SixDofDragBehavior;
  43260. /**
  43261. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43262. */
  43263. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43264. /**
  43265. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43266. */
  43267. usePointerToAttachGizmos: boolean;
  43268. /**
  43269. * Instatiates a gizmo manager
  43270. * @param scene the scene to overlay the gizmos on top of
  43271. */
  43272. constructor(scene: Scene);
  43273. /**
  43274. * Attaches a set of gizmos to the specified mesh
  43275. * @param mesh The mesh the gizmo's should be attached to
  43276. */
  43277. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43278. /**
  43279. * If the position gizmo is enabled
  43280. */
  43281. positionGizmoEnabled: boolean;
  43282. /**
  43283. * If the rotation gizmo is enabled
  43284. */
  43285. rotationGizmoEnabled: boolean;
  43286. /**
  43287. * If the scale gizmo is enabled
  43288. */
  43289. scaleGizmoEnabled: boolean;
  43290. /**
  43291. * If the boundingBox gizmo is enabled
  43292. */
  43293. boundingBoxGizmoEnabled: boolean;
  43294. /**
  43295. * Disposes of the gizmo manager
  43296. */
  43297. dispose(): void;
  43298. }
  43299. }
  43300. declare module BABYLON {
  43301. /**
  43302. * A directional light is defined by a direction (what a surprise!).
  43303. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43304. * 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.
  43305. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43306. */
  43307. export class DirectionalLight extends ShadowLight {
  43308. private _shadowFrustumSize;
  43309. /**
  43310. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43311. */
  43312. /**
  43313. * Specifies a fix frustum size for the shadow generation.
  43314. */
  43315. shadowFrustumSize: number;
  43316. private _shadowOrthoScale;
  43317. /**
  43318. * Gets the shadow projection scale against the optimal computed one.
  43319. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43320. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43321. */
  43322. /**
  43323. * Sets the shadow projection scale against the optimal computed one.
  43324. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43325. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43326. */
  43327. shadowOrthoScale: number;
  43328. /**
  43329. * Automatically compute the projection matrix to best fit (including all the casters)
  43330. * on each frame.
  43331. */
  43332. autoUpdateExtends: boolean;
  43333. private _orthoLeft;
  43334. private _orthoRight;
  43335. private _orthoTop;
  43336. private _orthoBottom;
  43337. /**
  43338. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43339. * The directional light is emitted from everywhere in the given direction.
  43340. * It can cast shadows.
  43341. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43342. * @param name The friendly name of the light
  43343. * @param direction The direction of the light
  43344. * @param scene The scene the light belongs to
  43345. */
  43346. constructor(name: string, direction: Vector3, scene: Scene);
  43347. /**
  43348. * Returns the string "DirectionalLight".
  43349. * @return The class name
  43350. */
  43351. getClassName(): string;
  43352. /**
  43353. * Returns the integer 1.
  43354. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43355. */
  43356. getTypeID(): number;
  43357. /**
  43358. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43359. * Returns the DirectionalLight Shadow projection matrix.
  43360. */
  43361. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43362. /**
  43363. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43364. * Returns the DirectionalLight Shadow projection matrix.
  43365. */
  43366. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43367. /**
  43368. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43369. * Returns the DirectionalLight Shadow projection matrix.
  43370. */
  43371. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43372. protected _buildUniformLayout(): void;
  43373. /**
  43374. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43375. * @param effect The effect to update
  43376. * @param lightIndex The index of the light in the effect to update
  43377. * @returns The directional light
  43378. */
  43379. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43380. /**
  43381. * Gets the minZ used for shadow according to both the scene and the light.
  43382. *
  43383. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43384. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43385. * @param activeCamera The camera we are returning the min for
  43386. * @returns the depth min z
  43387. */
  43388. getDepthMinZ(activeCamera: Camera): number;
  43389. /**
  43390. * Gets the maxZ used for shadow according to both the scene and the light.
  43391. *
  43392. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43393. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43394. * @param activeCamera The camera we are returning the max for
  43395. * @returns the depth max z
  43396. */
  43397. getDepthMaxZ(activeCamera: Camera): number;
  43398. /**
  43399. * Prepares the list of defines specific to the light type.
  43400. * @param defines the list of defines
  43401. * @param lightIndex defines the index of the light for the effect
  43402. */
  43403. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43404. }
  43405. }
  43406. declare module BABYLON {
  43407. /**
  43408. * Class containing static functions to help procedurally build meshes
  43409. */
  43410. export class HemisphereBuilder {
  43411. /**
  43412. * Creates a hemisphere mesh
  43413. * @param name defines the name of the mesh
  43414. * @param options defines the options used to create the mesh
  43415. * @param scene defines the hosting scene
  43416. * @returns the hemisphere mesh
  43417. */
  43418. static CreateHemisphere(name: string, options: {
  43419. segments?: number;
  43420. diameter?: number;
  43421. sideOrientation?: number;
  43422. }, scene: any): Mesh;
  43423. }
  43424. }
  43425. declare module BABYLON {
  43426. /**
  43427. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43428. * These values define a cone of light starting from the position, emitting toward the direction.
  43429. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43430. * and the exponent defines the speed of the decay of the light with distance (reach).
  43431. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43432. */
  43433. export class SpotLight extends ShadowLight {
  43434. private _angle;
  43435. private _innerAngle;
  43436. private _cosHalfAngle;
  43437. private _lightAngleScale;
  43438. private _lightAngleOffset;
  43439. /**
  43440. * Gets the cone angle of the spot light in Radians.
  43441. */
  43442. /**
  43443. * Sets the cone angle of the spot light in Radians.
  43444. */
  43445. angle: number;
  43446. /**
  43447. * Only used in gltf falloff mode, this defines the angle where
  43448. * the directional falloff will start before cutting at angle which could be seen
  43449. * as outer angle.
  43450. */
  43451. /**
  43452. * Only used in gltf falloff mode, this defines the angle where
  43453. * the directional falloff will start before cutting at angle which could be seen
  43454. * as outer angle.
  43455. */
  43456. innerAngle: number;
  43457. private _shadowAngleScale;
  43458. /**
  43459. * Allows scaling the angle of the light for shadow generation only.
  43460. */
  43461. /**
  43462. * Allows scaling the angle of the light for shadow generation only.
  43463. */
  43464. shadowAngleScale: number;
  43465. /**
  43466. * The light decay speed with the distance from the emission spot.
  43467. */
  43468. exponent: number;
  43469. private _projectionTextureMatrix;
  43470. /**
  43471. * Allows reading the projecton texture
  43472. */
  43473. readonly projectionTextureMatrix: Matrix;
  43474. protected _projectionTextureLightNear: number;
  43475. /**
  43476. * Gets the near clip of the Spotlight for texture projection.
  43477. */
  43478. /**
  43479. * Sets the near clip of the Spotlight for texture projection.
  43480. */
  43481. projectionTextureLightNear: number;
  43482. protected _projectionTextureLightFar: number;
  43483. /**
  43484. * Gets the far clip of the Spotlight for texture projection.
  43485. */
  43486. /**
  43487. * Sets the far clip of the Spotlight for texture projection.
  43488. */
  43489. projectionTextureLightFar: number;
  43490. protected _projectionTextureUpDirection: Vector3;
  43491. /**
  43492. * Gets the Up vector of the Spotlight for texture projection.
  43493. */
  43494. /**
  43495. * Sets the Up vector of the Spotlight for texture projection.
  43496. */
  43497. projectionTextureUpDirection: Vector3;
  43498. private _projectionTexture;
  43499. /**
  43500. * Gets the projection texture of the light.
  43501. */
  43502. /**
  43503. * Sets the projection texture of the light.
  43504. */
  43505. projectionTexture: Nullable<BaseTexture>;
  43506. private _projectionTextureViewLightDirty;
  43507. private _projectionTextureProjectionLightDirty;
  43508. private _projectionTextureDirty;
  43509. private _projectionTextureViewTargetVector;
  43510. private _projectionTextureViewLightMatrix;
  43511. private _projectionTextureProjectionLightMatrix;
  43512. private _projectionTextureScalingMatrix;
  43513. /**
  43514. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43515. * It can cast shadows.
  43516. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43517. * @param name The light friendly name
  43518. * @param position The position of the spot light in the scene
  43519. * @param direction The direction of the light in the scene
  43520. * @param angle The cone angle of the light in Radians
  43521. * @param exponent The light decay speed with the distance from the emission spot
  43522. * @param scene The scene the lights belongs to
  43523. */
  43524. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43525. /**
  43526. * Returns the string "SpotLight".
  43527. * @returns the class name
  43528. */
  43529. getClassName(): string;
  43530. /**
  43531. * Returns the integer 2.
  43532. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43533. */
  43534. getTypeID(): number;
  43535. /**
  43536. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43537. */
  43538. protected _setDirection(value: Vector3): void;
  43539. /**
  43540. * Overrides the position setter to recompute the projection texture view light Matrix.
  43541. */
  43542. protected _setPosition(value: Vector3): void;
  43543. /**
  43544. * 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.
  43545. * Returns the SpotLight.
  43546. */
  43547. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43548. protected _computeProjectionTextureViewLightMatrix(): void;
  43549. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43550. /**
  43551. * Main function for light texture projection matrix computing.
  43552. */
  43553. protected _computeProjectionTextureMatrix(): void;
  43554. protected _buildUniformLayout(): void;
  43555. private _computeAngleValues;
  43556. /**
  43557. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43558. * @param effect The effect to update
  43559. * @param lightIndex The index of the light in the effect to update
  43560. * @returns The spot light
  43561. */
  43562. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43563. /**
  43564. * Disposes the light and the associated resources.
  43565. */
  43566. dispose(): void;
  43567. /**
  43568. * Prepares the list of defines specific to the light type.
  43569. * @param defines the list of defines
  43570. * @param lightIndex defines the index of the light for the effect
  43571. */
  43572. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43573. }
  43574. }
  43575. declare module BABYLON {
  43576. /**
  43577. * Gizmo that enables viewing a light
  43578. */
  43579. export class LightGizmo extends Gizmo {
  43580. private _lightMesh;
  43581. private _material;
  43582. private cachedPosition;
  43583. private cachedForward;
  43584. /**
  43585. * Creates a LightGizmo
  43586. * @param gizmoLayer The utility layer the gizmo will be added to
  43587. */
  43588. constructor(gizmoLayer?: UtilityLayerRenderer);
  43589. private _light;
  43590. /**
  43591. * The light that the gizmo is attached to
  43592. */
  43593. light: Nullable<Light>;
  43594. /**
  43595. * @hidden
  43596. * Updates the gizmo to match the attached mesh's position/rotation
  43597. */
  43598. protected _update(): void;
  43599. private static _Scale;
  43600. /**
  43601. * Creates the lines for a light mesh
  43602. */
  43603. private static _createLightLines;
  43604. /**
  43605. * Disposes of the light gizmo
  43606. */
  43607. dispose(): void;
  43608. private static _CreateHemisphericLightMesh;
  43609. private static _CreatePointLightMesh;
  43610. private static _CreateSpotLightMesh;
  43611. private static _CreateDirectionalLightMesh;
  43612. }
  43613. }
  43614. declare module BABYLON {
  43615. /** @hidden */
  43616. export var backgroundFragmentDeclaration: {
  43617. name: string;
  43618. shader: string;
  43619. };
  43620. }
  43621. declare module BABYLON {
  43622. /** @hidden */
  43623. export var backgroundUboDeclaration: {
  43624. name: string;
  43625. shader: string;
  43626. };
  43627. }
  43628. declare module BABYLON {
  43629. /** @hidden */
  43630. export var backgroundPixelShader: {
  43631. name: string;
  43632. shader: string;
  43633. };
  43634. }
  43635. declare module BABYLON {
  43636. /** @hidden */
  43637. export var backgroundVertexDeclaration: {
  43638. name: string;
  43639. shader: string;
  43640. };
  43641. }
  43642. declare module BABYLON {
  43643. /** @hidden */
  43644. export var backgroundVertexShader: {
  43645. name: string;
  43646. shader: string;
  43647. };
  43648. }
  43649. declare module BABYLON {
  43650. /**
  43651. * Background material used to create an efficient environement around your scene.
  43652. */
  43653. export class BackgroundMaterial extends PushMaterial {
  43654. /**
  43655. * Standard reflectance value at parallel view angle.
  43656. */
  43657. static StandardReflectance0: number;
  43658. /**
  43659. * Standard reflectance value at grazing angle.
  43660. */
  43661. static StandardReflectance90: number;
  43662. protected _primaryColor: Color3;
  43663. /**
  43664. * Key light Color (multiply against the environement texture)
  43665. */
  43666. primaryColor: Color3;
  43667. protected __perceptualColor: Nullable<Color3>;
  43668. /**
  43669. * Experimental Internal Use Only.
  43670. *
  43671. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43672. * This acts as a helper to set the primary color to a more "human friendly" value.
  43673. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43674. * output color as close as possible from the chosen value.
  43675. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43676. * part of lighting setup.)
  43677. */
  43678. _perceptualColor: Nullable<Color3>;
  43679. protected _primaryColorShadowLevel: float;
  43680. /**
  43681. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43682. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43683. */
  43684. primaryColorShadowLevel: float;
  43685. protected _primaryColorHighlightLevel: float;
  43686. /**
  43687. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43688. * The primary color is used at the level chosen to define what the white area would look.
  43689. */
  43690. primaryColorHighlightLevel: float;
  43691. protected _reflectionTexture: Nullable<BaseTexture>;
  43692. /**
  43693. * Reflection Texture used in the material.
  43694. * Should be author in a specific way for the best result (refer to the documentation).
  43695. */
  43696. reflectionTexture: Nullable<BaseTexture>;
  43697. protected _reflectionBlur: float;
  43698. /**
  43699. * Reflection Texture level of blur.
  43700. *
  43701. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43702. * texture twice.
  43703. */
  43704. reflectionBlur: float;
  43705. protected _diffuseTexture: Nullable<BaseTexture>;
  43706. /**
  43707. * Diffuse Texture used in the material.
  43708. * Should be author in a specific way for the best result (refer to the documentation).
  43709. */
  43710. diffuseTexture: Nullable<BaseTexture>;
  43711. protected _shadowLights: Nullable<IShadowLight[]>;
  43712. /**
  43713. * Specify the list of lights casting shadow on the material.
  43714. * All scene shadow lights will be included if null.
  43715. */
  43716. shadowLights: Nullable<IShadowLight[]>;
  43717. protected _shadowLevel: float;
  43718. /**
  43719. * Helps adjusting the shadow to a softer level if required.
  43720. * 0 means black shadows and 1 means no shadows.
  43721. */
  43722. shadowLevel: float;
  43723. protected _sceneCenter: Vector3;
  43724. /**
  43725. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43726. * It is usually zero but might be interesting to modify according to your setup.
  43727. */
  43728. sceneCenter: Vector3;
  43729. protected _opacityFresnel: boolean;
  43730. /**
  43731. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43732. * This helps ensuring a nice transition when the camera goes under the ground.
  43733. */
  43734. opacityFresnel: boolean;
  43735. protected _reflectionFresnel: boolean;
  43736. /**
  43737. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43738. * This helps adding a mirror texture on the ground.
  43739. */
  43740. reflectionFresnel: boolean;
  43741. protected _reflectionFalloffDistance: number;
  43742. /**
  43743. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43744. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43745. */
  43746. reflectionFalloffDistance: number;
  43747. protected _reflectionAmount: number;
  43748. /**
  43749. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43750. */
  43751. reflectionAmount: number;
  43752. protected _reflectionReflectance0: number;
  43753. /**
  43754. * This specifies the weight of the reflection at grazing angle.
  43755. */
  43756. reflectionReflectance0: number;
  43757. protected _reflectionReflectance90: number;
  43758. /**
  43759. * This specifies the weight of the reflection at a perpendicular point of view.
  43760. */
  43761. reflectionReflectance90: number;
  43762. /**
  43763. * Sets the reflection reflectance fresnel values according to the default standard
  43764. * empirically know to work well :-)
  43765. */
  43766. reflectionStandardFresnelWeight: number;
  43767. protected _useRGBColor: boolean;
  43768. /**
  43769. * Helps to directly use the maps channels instead of their level.
  43770. */
  43771. useRGBColor: boolean;
  43772. protected _enableNoise: boolean;
  43773. /**
  43774. * This helps reducing the banding effect that could occur on the background.
  43775. */
  43776. enableNoise: boolean;
  43777. /**
  43778. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43779. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43780. * Recommended to be keep at 1.0 except for special cases.
  43781. */
  43782. fovMultiplier: number;
  43783. private _fovMultiplier;
  43784. /**
  43785. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43786. */
  43787. useEquirectangularFOV: boolean;
  43788. private _maxSimultaneousLights;
  43789. /**
  43790. * Number of Simultaneous lights allowed on the material.
  43791. */
  43792. maxSimultaneousLights: int;
  43793. /**
  43794. * Default configuration related to image processing available in the Background Material.
  43795. */
  43796. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43797. /**
  43798. * Keep track of the image processing observer to allow dispose and replace.
  43799. */
  43800. private _imageProcessingObserver;
  43801. /**
  43802. * Attaches a new image processing configuration to the PBR Material.
  43803. * @param configuration (if null the scene configuration will be use)
  43804. */
  43805. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43806. /**
  43807. * Gets the image processing configuration used either in this material.
  43808. */
  43809. /**
  43810. * Sets the Default image processing configuration used either in the this material.
  43811. *
  43812. * If sets to null, the scene one is in use.
  43813. */
  43814. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43815. /**
  43816. * Gets wether the color curves effect is enabled.
  43817. */
  43818. /**
  43819. * Sets wether the color curves effect is enabled.
  43820. */
  43821. cameraColorCurvesEnabled: boolean;
  43822. /**
  43823. * Gets wether the color grading effect is enabled.
  43824. */
  43825. /**
  43826. * Gets wether the color grading effect is enabled.
  43827. */
  43828. cameraColorGradingEnabled: boolean;
  43829. /**
  43830. * Gets wether tonemapping is enabled or not.
  43831. */
  43832. /**
  43833. * Sets wether tonemapping is enabled or not
  43834. */
  43835. cameraToneMappingEnabled: boolean;
  43836. /**
  43837. * The camera exposure used on this material.
  43838. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43839. * This corresponds to a photographic exposure.
  43840. */
  43841. /**
  43842. * The camera exposure used on this material.
  43843. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43844. * This corresponds to a photographic exposure.
  43845. */
  43846. cameraExposure: float;
  43847. /**
  43848. * Gets The camera contrast used on this material.
  43849. */
  43850. /**
  43851. * Sets The camera contrast used on this material.
  43852. */
  43853. cameraContrast: float;
  43854. /**
  43855. * Gets the Color Grading 2D Lookup Texture.
  43856. */
  43857. /**
  43858. * Sets the Color Grading 2D Lookup Texture.
  43859. */
  43860. cameraColorGradingTexture: Nullable<BaseTexture>;
  43861. /**
  43862. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43863. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43864. * 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;
  43865. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43866. */
  43867. /**
  43868. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43869. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43870. * 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;
  43871. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43872. */
  43873. cameraColorCurves: Nullable<ColorCurves>;
  43874. /**
  43875. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43876. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43877. */
  43878. switchToBGR: boolean;
  43879. private _renderTargets;
  43880. private _reflectionControls;
  43881. private _white;
  43882. private _primaryShadowColor;
  43883. private _primaryHighlightColor;
  43884. /**
  43885. * Instantiates a Background Material in the given scene
  43886. * @param name The friendly name of the material
  43887. * @param scene The scene to add the material to
  43888. */
  43889. constructor(name: string, scene: Scene);
  43890. /**
  43891. * Gets a boolean indicating that current material needs to register RTT
  43892. */
  43893. readonly hasRenderTargetTextures: boolean;
  43894. /**
  43895. * The entire material has been created in order to prevent overdraw.
  43896. * @returns false
  43897. */
  43898. needAlphaTesting(): boolean;
  43899. /**
  43900. * The entire material has been created in order to prevent overdraw.
  43901. * @returns true if blending is enable
  43902. */
  43903. needAlphaBlending(): boolean;
  43904. /**
  43905. * Checks wether the material is ready to be rendered for a given mesh.
  43906. * @param mesh The mesh to render
  43907. * @param subMesh The submesh to check against
  43908. * @param useInstances Specify wether or not the material is used with instances
  43909. * @returns true if all the dependencies are ready (Textures, Effects...)
  43910. */
  43911. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43912. /**
  43913. * Compute the primary color according to the chosen perceptual color.
  43914. */
  43915. private _computePrimaryColorFromPerceptualColor;
  43916. /**
  43917. * Compute the highlights and shadow colors according to their chosen levels.
  43918. */
  43919. private _computePrimaryColors;
  43920. /**
  43921. * Build the uniform buffer used in the material.
  43922. */
  43923. buildUniformLayout(): void;
  43924. /**
  43925. * Unbind the material.
  43926. */
  43927. unbind(): void;
  43928. /**
  43929. * Bind only the world matrix to the material.
  43930. * @param world The world matrix to bind.
  43931. */
  43932. bindOnlyWorldMatrix(world: Matrix): void;
  43933. /**
  43934. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43935. * @param world The world matrix to bind.
  43936. * @param subMesh The submesh to bind for.
  43937. */
  43938. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43939. /**
  43940. * Dispose the material.
  43941. * @param forceDisposeEffect Force disposal of the associated effect.
  43942. * @param forceDisposeTextures Force disposal of the associated textures.
  43943. */
  43944. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43945. /**
  43946. * Clones the material.
  43947. * @param name The cloned name.
  43948. * @returns The cloned material.
  43949. */
  43950. clone(name: string): BackgroundMaterial;
  43951. /**
  43952. * Serializes the current material to its JSON representation.
  43953. * @returns The JSON representation.
  43954. */
  43955. serialize(): any;
  43956. /**
  43957. * Gets the class name of the material
  43958. * @returns "BackgroundMaterial"
  43959. */
  43960. getClassName(): string;
  43961. /**
  43962. * Parse a JSON input to create back a background material.
  43963. * @param source The JSON data to parse
  43964. * @param scene The scene to create the parsed material in
  43965. * @param rootUrl The root url of the assets the material depends upon
  43966. * @returns the instantiated BackgroundMaterial.
  43967. */
  43968. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43969. }
  43970. }
  43971. declare module BABYLON {
  43972. /**
  43973. * Represents the different options available during the creation of
  43974. * a Environment helper.
  43975. *
  43976. * This can control the default ground, skybox and image processing setup of your scene.
  43977. */
  43978. export interface IEnvironmentHelperOptions {
  43979. /**
  43980. * Specifies wether or not to create a ground.
  43981. * True by default.
  43982. */
  43983. createGround: boolean;
  43984. /**
  43985. * Specifies the ground size.
  43986. * 15 by default.
  43987. */
  43988. groundSize: number;
  43989. /**
  43990. * The texture used on the ground for the main color.
  43991. * Comes from the BabylonJS CDN by default.
  43992. *
  43993. * Remarks: Can be either a texture or a url.
  43994. */
  43995. groundTexture: string | BaseTexture;
  43996. /**
  43997. * The color mixed in the ground texture by default.
  43998. * BabylonJS clearColor by default.
  43999. */
  44000. groundColor: Color3;
  44001. /**
  44002. * Specifies the ground opacity.
  44003. * 1 by default.
  44004. */
  44005. groundOpacity: number;
  44006. /**
  44007. * Enables the ground to receive shadows.
  44008. * True by default.
  44009. */
  44010. enableGroundShadow: boolean;
  44011. /**
  44012. * Helps preventing the shadow to be fully black on the ground.
  44013. * 0.5 by default.
  44014. */
  44015. groundShadowLevel: number;
  44016. /**
  44017. * Creates a mirror texture attach to the ground.
  44018. * false by default.
  44019. */
  44020. enableGroundMirror: boolean;
  44021. /**
  44022. * Specifies the ground mirror size ratio.
  44023. * 0.3 by default as the default kernel is 64.
  44024. */
  44025. groundMirrorSizeRatio: number;
  44026. /**
  44027. * Specifies the ground mirror blur kernel size.
  44028. * 64 by default.
  44029. */
  44030. groundMirrorBlurKernel: number;
  44031. /**
  44032. * Specifies the ground mirror visibility amount.
  44033. * 1 by default
  44034. */
  44035. groundMirrorAmount: number;
  44036. /**
  44037. * Specifies the ground mirror reflectance weight.
  44038. * This uses the standard weight of the background material to setup the fresnel effect
  44039. * of the mirror.
  44040. * 1 by default.
  44041. */
  44042. groundMirrorFresnelWeight: number;
  44043. /**
  44044. * Specifies the ground mirror Falloff distance.
  44045. * This can helps reducing the size of the reflection.
  44046. * 0 by Default.
  44047. */
  44048. groundMirrorFallOffDistance: number;
  44049. /**
  44050. * Specifies the ground mirror texture type.
  44051. * Unsigned Int by Default.
  44052. */
  44053. groundMirrorTextureType: number;
  44054. /**
  44055. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44056. * the shown objects.
  44057. */
  44058. groundYBias: number;
  44059. /**
  44060. * Specifies wether or not to create a skybox.
  44061. * True by default.
  44062. */
  44063. createSkybox: boolean;
  44064. /**
  44065. * Specifies the skybox size.
  44066. * 20 by default.
  44067. */
  44068. skyboxSize: number;
  44069. /**
  44070. * The texture used on the skybox for the main color.
  44071. * Comes from the BabylonJS CDN by default.
  44072. *
  44073. * Remarks: Can be either a texture or a url.
  44074. */
  44075. skyboxTexture: string | BaseTexture;
  44076. /**
  44077. * The color mixed in the skybox texture by default.
  44078. * BabylonJS clearColor by default.
  44079. */
  44080. skyboxColor: Color3;
  44081. /**
  44082. * The background rotation around the Y axis of the scene.
  44083. * This helps aligning the key lights of your scene with the background.
  44084. * 0 by default.
  44085. */
  44086. backgroundYRotation: number;
  44087. /**
  44088. * Compute automatically the size of the elements to best fit with the scene.
  44089. */
  44090. sizeAuto: boolean;
  44091. /**
  44092. * Default position of the rootMesh if autoSize is not true.
  44093. */
  44094. rootPosition: Vector3;
  44095. /**
  44096. * Sets up the image processing in the scene.
  44097. * true by default.
  44098. */
  44099. setupImageProcessing: boolean;
  44100. /**
  44101. * The texture used as your environment texture in the scene.
  44102. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44103. *
  44104. * Remarks: Can be either a texture or a url.
  44105. */
  44106. environmentTexture: string | BaseTexture;
  44107. /**
  44108. * The value of the exposure to apply to the scene.
  44109. * 0.6 by default if setupImageProcessing is true.
  44110. */
  44111. cameraExposure: number;
  44112. /**
  44113. * The value of the contrast to apply to the scene.
  44114. * 1.6 by default if setupImageProcessing is true.
  44115. */
  44116. cameraContrast: number;
  44117. /**
  44118. * Specifies wether or not tonemapping should be enabled in the scene.
  44119. * true by default if setupImageProcessing is true.
  44120. */
  44121. toneMappingEnabled: boolean;
  44122. }
  44123. /**
  44124. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44125. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44126. * It also helps with the default setup of your imageProcessing configuration.
  44127. */
  44128. export class EnvironmentHelper {
  44129. /**
  44130. * Default ground texture URL.
  44131. */
  44132. private static _groundTextureCDNUrl;
  44133. /**
  44134. * Default skybox texture URL.
  44135. */
  44136. private static _skyboxTextureCDNUrl;
  44137. /**
  44138. * Default environment texture URL.
  44139. */
  44140. private static _environmentTextureCDNUrl;
  44141. /**
  44142. * Creates the default options for the helper.
  44143. */
  44144. private static _getDefaultOptions;
  44145. private _rootMesh;
  44146. /**
  44147. * Gets the root mesh created by the helper.
  44148. */
  44149. readonly rootMesh: Mesh;
  44150. private _skybox;
  44151. /**
  44152. * Gets the skybox created by the helper.
  44153. */
  44154. readonly skybox: Nullable<Mesh>;
  44155. private _skyboxTexture;
  44156. /**
  44157. * Gets the skybox texture created by the helper.
  44158. */
  44159. readonly skyboxTexture: Nullable<BaseTexture>;
  44160. private _skyboxMaterial;
  44161. /**
  44162. * Gets the skybox material created by the helper.
  44163. */
  44164. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44165. private _ground;
  44166. /**
  44167. * Gets the ground mesh created by the helper.
  44168. */
  44169. readonly ground: Nullable<Mesh>;
  44170. private _groundTexture;
  44171. /**
  44172. * Gets the ground texture created by the helper.
  44173. */
  44174. readonly groundTexture: Nullable<BaseTexture>;
  44175. private _groundMirror;
  44176. /**
  44177. * Gets the ground mirror created by the helper.
  44178. */
  44179. readonly groundMirror: Nullable<MirrorTexture>;
  44180. /**
  44181. * Gets the ground mirror render list to helps pushing the meshes
  44182. * you wish in the ground reflection.
  44183. */
  44184. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44185. private _groundMaterial;
  44186. /**
  44187. * Gets the ground material created by the helper.
  44188. */
  44189. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44190. /**
  44191. * Stores the creation options.
  44192. */
  44193. private readonly _scene;
  44194. private _options;
  44195. /**
  44196. * This observable will be notified with any error during the creation of the environment,
  44197. * mainly texture creation errors.
  44198. */
  44199. onErrorObservable: Observable<{
  44200. message?: string;
  44201. exception?: any;
  44202. }>;
  44203. /**
  44204. * constructor
  44205. * @param options Defines the options we want to customize the helper
  44206. * @param scene The scene to add the material to
  44207. */
  44208. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44209. /**
  44210. * Updates the background according to the new options
  44211. * @param options
  44212. */
  44213. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44214. /**
  44215. * Sets the primary color of all the available elements.
  44216. * @param color the main color to affect to the ground and the background
  44217. */
  44218. setMainColor(color: Color3): void;
  44219. /**
  44220. * Setup the image processing according to the specified options.
  44221. */
  44222. private _setupImageProcessing;
  44223. /**
  44224. * Setup the environment texture according to the specified options.
  44225. */
  44226. private _setupEnvironmentTexture;
  44227. /**
  44228. * Setup the background according to the specified options.
  44229. */
  44230. private _setupBackground;
  44231. /**
  44232. * Get the scene sizes according to the setup.
  44233. */
  44234. private _getSceneSize;
  44235. /**
  44236. * Setup the ground according to the specified options.
  44237. */
  44238. private _setupGround;
  44239. /**
  44240. * Setup the ground material according to the specified options.
  44241. */
  44242. private _setupGroundMaterial;
  44243. /**
  44244. * Setup the ground diffuse texture according to the specified options.
  44245. */
  44246. private _setupGroundDiffuseTexture;
  44247. /**
  44248. * Setup the ground mirror texture according to the specified options.
  44249. */
  44250. private _setupGroundMirrorTexture;
  44251. /**
  44252. * Setup the ground to receive the mirror texture.
  44253. */
  44254. private _setupMirrorInGroundMaterial;
  44255. /**
  44256. * Setup the skybox according to the specified options.
  44257. */
  44258. private _setupSkybox;
  44259. /**
  44260. * Setup the skybox material according to the specified options.
  44261. */
  44262. private _setupSkyboxMaterial;
  44263. /**
  44264. * Setup the skybox reflection texture according to the specified options.
  44265. */
  44266. private _setupSkyboxReflectionTexture;
  44267. private _errorHandler;
  44268. /**
  44269. * Dispose all the elements created by the Helper.
  44270. */
  44271. dispose(): void;
  44272. }
  44273. }
  44274. declare module BABYLON {
  44275. /**
  44276. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44277. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44278. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44279. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44280. */
  44281. export class PhotoDome extends TransformNode {
  44282. /**
  44283. * Define the image as a Monoscopic panoramic 360 image.
  44284. */
  44285. static readonly MODE_MONOSCOPIC: number;
  44286. /**
  44287. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44288. */
  44289. static readonly MODE_TOPBOTTOM: number;
  44290. /**
  44291. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44292. */
  44293. static readonly MODE_SIDEBYSIDE: number;
  44294. private _useDirectMapping;
  44295. /**
  44296. * The texture being displayed on the sphere
  44297. */
  44298. protected _photoTexture: Texture;
  44299. /**
  44300. * Gets or sets the texture being displayed on the sphere
  44301. */
  44302. photoTexture: Texture;
  44303. /**
  44304. * Observable raised when an error occured while loading the 360 image
  44305. */
  44306. onLoadErrorObservable: Observable<string>;
  44307. /**
  44308. * The skybox material
  44309. */
  44310. protected _material: BackgroundMaterial;
  44311. /**
  44312. * The surface used for the skybox
  44313. */
  44314. protected _mesh: Mesh;
  44315. /**
  44316. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44317. * Also see the options.resolution property.
  44318. */
  44319. fovMultiplier: number;
  44320. private _imageMode;
  44321. /**
  44322. * Gets or set the current video mode for the video. It can be:
  44323. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  44324. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44325. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44326. */
  44327. imageMode: number;
  44328. /**
  44329. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44330. * @param name Element's name, child elements will append suffixes for their own names.
  44331. * @param urlsOfPhoto defines the url of the photo to display
  44332. * @param options defines an object containing optional or exposed sub element properties
  44333. * @param onError defines a callback called when an error occured while loading the texture
  44334. */
  44335. constructor(name: string, urlOfPhoto: string, options: {
  44336. resolution?: number;
  44337. size?: number;
  44338. useDirectMapping?: boolean;
  44339. faceForward?: boolean;
  44340. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44341. private _onBeforeCameraRenderObserver;
  44342. private _changeImageMode;
  44343. /**
  44344. * Releases resources associated with this node.
  44345. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44346. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44347. */
  44348. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44349. }
  44350. }
  44351. declare module BABYLON {
  44352. /** @hidden */
  44353. export var rgbdDecodePixelShader: {
  44354. name: string;
  44355. shader: string;
  44356. };
  44357. }
  44358. declare module BABYLON {
  44359. /**
  44360. * Class used to host texture specific utilities
  44361. */
  44362. export class BRDFTextureTools {
  44363. /**
  44364. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44365. * @param texture the texture to expand.
  44366. */
  44367. private static _ExpandDefaultBRDFTexture;
  44368. /**
  44369. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44370. * @param scene defines the hosting scene
  44371. * @returns the environment BRDF texture
  44372. */
  44373. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44374. private static _environmentBRDFBase64Texture;
  44375. }
  44376. }
  44377. declare module BABYLON {
  44378. /**
  44379. * @hidden
  44380. */
  44381. export interface IMaterialClearCoatDefines {
  44382. CLEARCOAT: boolean;
  44383. CLEARCOAT_DEFAULTIOR: boolean;
  44384. CLEARCOAT_TEXTURE: boolean;
  44385. CLEARCOAT_TEXTUREDIRECTUV: number;
  44386. CLEARCOAT_BUMP: boolean;
  44387. CLEARCOAT_BUMPDIRECTUV: number;
  44388. CLEARCOAT_TINT: boolean;
  44389. CLEARCOAT_TINT_TEXTURE: boolean;
  44390. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44391. /** @hidden */
  44392. _areTexturesDirty: boolean;
  44393. }
  44394. /**
  44395. * Define the code related to the clear coat parameters of the pbr material.
  44396. */
  44397. export class PBRClearCoatConfiguration {
  44398. /**
  44399. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44400. * The default fits with a polyurethane material.
  44401. */
  44402. private static readonly _DefaultIndiceOfRefraction;
  44403. private _isEnabled;
  44404. /**
  44405. * Defines if the clear coat is enabled in the material.
  44406. */
  44407. isEnabled: boolean;
  44408. /**
  44409. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44410. */
  44411. intensity: number;
  44412. /**
  44413. * Defines the clear coat layer roughness.
  44414. */
  44415. roughness: number;
  44416. private _indiceOfRefraction;
  44417. /**
  44418. * Defines the indice of refraction of the clear coat.
  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. * Changing the default value is more performance intensive.
  44422. */
  44423. indiceOfRefraction: number;
  44424. private _texture;
  44425. /**
  44426. * Stores the clear coat values in a texture.
  44427. */
  44428. texture: Nullable<BaseTexture>;
  44429. private _bumpTexture;
  44430. /**
  44431. * Define the clear coat specific bump texture.
  44432. */
  44433. bumpTexture: Nullable<BaseTexture>;
  44434. private _isTintEnabled;
  44435. /**
  44436. * Defines if the clear coat tint is enabled in the material.
  44437. */
  44438. isTintEnabled: boolean;
  44439. /**
  44440. * Defines the clear coat tint of the material.
  44441. * This is only use if tint is enabled
  44442. */
  44443. tintColor: Color3;
  44444. /**
  44445. * Defines the distance at which the tint color should be found in the
  44446. * clear coat media.
  44447. * This is only use if tint is enabled
  44448. */
  44449. tintColorAtDistance: number;
  44450. /**
  44451. * Defines the clear coat layer thickness.
  44452. * This is only use if tint is enabled
  44453. */
  44454. tintThickness: number;
  44455. private _tintTexture;
  44456. /**
  44457. * Stores the clear tint values in a texture.
  44458. * rgb is tint
  44459. * a is a thickness factor
  44460. */
  44461. tintTexture: Nullable<BaseTexture>;
  44462. /** @hidden */
  44463. private _internalMarkAllSubMeshesAsTexturesDirty;
  44464. /** @hidden */
  44465. _markAllSubMeshesAsTexturesDirty(): void;
  44466. /**
  44467. * Instantiate a new istance of clear coat configuration.
  44468. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44469. */
  44470. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44471. /**
  44472. * Gets wehter the submesh is ready to be used or not.
  44473. * @param defines the list of "defines" to update.
  44474. * @param scene defines the scene the material belongs to.
  44475. * @param engine defines the engine the material belongs to.
  44476. * @param disableBumpMap defines wether the material disables bump or not.
  44477. * @returns - boolean indicating that the submesh is ready or not.
  44478. */
  44479. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44480. /**
  44481. * Checks to see if a texture is used in the material.
  44482. * @param defines the list of "defines" to update.
  44483. * @param scene defines the scene to the material belongs to.
  44484. */
  44485. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44486. /**
  44487. * Binds the material data.
  44488. * @param uniformBuffer defines the Uniform buffer to fill in.
  44489. * @param scene defines the scene the material belongs to.
  44490. * @param engine defines the engine the material belongs to.
  44491. * @param disableBumpMap defines wether the material disables bump or not.
  44492. * @param isFrozen defines wether the material is frozen or not.
  44493. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44494. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44495. */
  44496. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44497. /**
  44498. * Checks to see if a texture is used in the material.
  44499. * @param texture - Base texture to use.
  44500. * @returns - Boolean specifying if a texture is used in the material.
  44501. */
  44502. hasTexture(texture: BaseTexture): boolean;
  44503. /**
  44504. * Returns an array of the actively used textures.
  44505. * @param activeTextures Array of BaseTextures
  44506. */
  44507. getActiveTextures(activeTextures: BaseTexture[]): void;
  44508. /**
  44509. * Returns the animatable textures.
  44510. * @param animatables Array of animatable textures.
  44511. */
  44512. getAnimatables(animatables: IAnimatable[]): void;
  44513. /**
  44514. * Disposes the resources of the material.
  44515. * @param forceDisposeTextures - Forces the disposal of all textures.
  44516. */
  44517. dispose(forceDisposeTextures?: boolean): void;
  44518. /**
  44519. * Get the current class name of the texture useful for serialization or dynamic coding.
  44520. * @returns "PBRClearCoatConfiguration"
  44521. */
  44522. getClassName(): string;
  44523. /**
  44524. * Add fallbacks to the effect fallbacks list.
  44525. * @param defines defines the Base texture to use.
  44526. * @param fallbacks defines the current fallback list.
  44527. * @param currentRank defines the current fallback rank.
  44528. * @returns the new fallback rank.
  44529. */
  44530. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44531. /**
  44532. * Add the required uniforms to the current list.
  44533. * @param uniforms defines the current uniform list.
  44534. */
  44535. static AddUniforms(uniforms: string[]): void;
  44536. /**
  44537. * Add the required samplers to the current list.
  44538. * @param samplers defines the current sampler list.
  44539. */
  44540. static AddSamplers(samplers: string[]): void;
  44541. /**
  44542. * Add the required uniforms to the current buffer.
  44543. * @param uniformBuffer defines the current uniform buffer.
  44544. */
  44545. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44546. /**
  44547. * Makes a duplicate of the current configuration into another one.
  44548. * @param clearCoatConfiguration define the config where to copy the info
  44549. */
  44550. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44551. /**
  44552. * Serializes this clear coat configuration.
  44553. * @returns - An object with the serialized config.
  44554. */
  44555. serialize(): any;
  44556. /**
  44557. * Parses a Clear Coat Configuration from a serialized object.
  44558. * @param source - Serialized object.
  44559. */
  44560. parse(source: any): void;
  44561. }
  44562. }
  44563. declare module BABYLON {
  44564. /**
  44565. * @hidden
  44566. */
  44567. export interface IMaterialAnisotropicDefines {
  44568. ANISOTROPIC: boolean;
  44569. ANISOTROPIC_TEXTURE: boolean;
  44570. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44571. MAINUV1: boolean;
  44572. _areTexturesDirty: boolean;
  44573. _needUVs: boolean;
  44574. }
  44575. /**
  44576. * Define the code related to the anisotropic parameters of the pbr material.
  44577. */
  44578. export class PBRAnisotropicConfiguration {
  44579. private _isEnabled;
  44580. /**
  44581. * Defines if the anisotropy is enabled in the material.
  44582. */
  44583. isEnabled: boolean;
  44584. /**
  44585. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44586. */
  44587. intensity: number;
  44588. /**
  44589. * Defines if the effect is along the tangents, bitangents or in between.
  44590. * By default, the effect is "strectching" the highlights along the tangents.
  44591. */
  44592. direction: Vector2;
  44593. private _texture;
  44594. /**
  44595. * Stores the anisotropy values in a texture.
  44596. * rg is direction (like normal from -1 to 1)
  44597. * b is a intensity
  44598. */
  44599. texture: Nullable<BaseTexture>;
  44600. /** @hidden */
  44601. private _internalMarkAllSubMeshesAsTexturesDirty;
  44602. /** @hidden */
  44603. _markAllSubMeshesAsTexturesDirty(): void;
  44604. /**
  44605. * Instantiate a new istance of anisotropy configuration.
  44606. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44607. */
  44608. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44609. /**
  44610. * Specifies that the submesh is ready to be used.
  44611. * @param defines the list of "defines" to update.
  44612. * @param scene defines the scene the material belongs to.
  44613. * @returns - boolean indicating that the submesh is ready or not.
  44614. */
  44615. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44616. /**
  44617. * Checks to see if a texture is used in the material.
  44618. * @param defines the list of "defines" to update.
  44619. * @param mesh the mesh we are preparing the defines for.
  44620. * @param scene defines the scene the material belongs to.
  44621. */
  44622. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44623. /**
  44624. * Binds the material data.
  44625. * @param uniformBuffer defines the Uniform buffer to fill in.
  44626. * @param scene defines the scene the material belongs to.
  44627. * @param isFrozen defines wether the material is frozen or not.
  44628. */
  44629. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44630. /**
  44631. * Checks to see if a texture is used in the material.
  44632. * @param texture - Base texture to use.
  44633. * @returns - Boolean specifying if a texture is used in the material.
  44634. */
  44635. hasTexture(texture: BaseTexture): boolean;
  44636. /**
  44637. * Returns an array of the actively used textures.
  44638. * @param activeTextures Array of BaseTextures
  44639. */
  44640. getActiveTextures(activeTextures: BaseTexture[]): void;
  44641. /**
  44642. * Returns the animatable textures.
  44643. * @param animatables Array of animatable textures.
  44644. */
  44645. getAnimatables(animatables: IAnimatable[]): void;
  44646. /**
  44647. * Disposes the resources of the material.
  44648. * @param forceDisposeTextures - Forces the disposal of all textures.
  44649. */
  44650. dispose(forceDisposeTextures?: boolean): void;
  44651. /**
  44652. * Get the current class name of the texture useful for serialization or dynamic coding.
  44653. * @returns "PBRAnisotropicConfiguration"
  44654. */
  44655. getClassName(): string;
  44656. /**
  44657. * Add fallbacks to the effect fallbacks list.
  44658. * @param defines defines the Base texture to use.
  44659. * @param fallbacks defines the current fallback list.
  44660. * @param currentRank defines the current fallback rank.
  44661. * @returns the new fallback rank.
  44662. */
  44663. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44664. /**
  44665. * Add the required uniforms to the current list.
  44666. * @param uniforms defines the current uniform list.
  44667. */
  44668. static AddUniforms(uniforms: string[]): void;
  44669. /**
  44670. * Add the required uniforms to the current buffer.
  44671. * @param uniformBuffer defines the current uniform buffer.
  44672. */
  44673. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44674. /**
  44675. * Add the required samplers to the current list.
  44676. * @param samplers defines the current sampler list.
  44677. */
  44678. static AddSamplers(samplers: string[]): void;
  44679. /**
  44680. * Makes a duplicate of the current configuration into another one.
  44681. * @param anisotropicConfiguration define the config where to copy the info
  44682. */
  44683. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44684. /**
  44685. * Serializes this anisotropy configuration.
  44686. * @returns - An object with the serialized config.
  44687. */
  44688. serialize(): any;
  44689. /**
  44690. * Parses a anisotropy Configuration from a serialized object.
  44691. * @param source - Serialized object.
  44692. */
  44693. parse(source: any): void;
  44694. }
  44695. }
  44696. declare module BABYLON {
  44697. /**
  44698. * @hidden
  44699. */
  44700. export interface IMaterialBRDFDefines {
  44701. BRDF_V_HEIGHT_CORRELATED: boolean;
  44702. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44703. SPHERICAL_HARMONICS: boolean;
  44704. /** @hidden */
  44705. _areMiscDirty: boolean;
  44706. }
  44707. /**
  44708. * Define the code related to the BRDF parameters of the pbr material.
  44709. */
  44710. export class PBRBRDFConfiguration {
  44711. /**
  44712. * Default value used for the energy conservation.
  44713. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44714. */
  44715. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44716. /**
  44717. * Default value used for the Smith Visibility Height Correlated mode.
  44718. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44719. */
  44720. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44721. /**
  44722. * Default value used for the IBL diffuse part.
  44723. * This can help switching back to the polynomials mode globally which is a tiny bit
  44724. * less GPU intensive at the drawback of a lower quality.
  44725. */
  44726. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44727. private _useEnergyConservation;
  44728. /**
  44729. * Defines if the material uses energy conservation.
  44730. */
  44731. useEnergyConservation: boolean;
  44732. private _useSmithVisibilityHeightCorrelated;
  44733. /**
  44734. * LEGACY Mode set to false
  44735. * Defines if the material uses height smith correlated visibility term.
  44736. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44737. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44738. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44739. * Not relying on height correlated will also disable energy conservation.
  44740. */
  44741. useSmithVisibilityHeightCorrelated: boolean;
  44742. private _useSphericalHarmonics;
  44743. /**
  44744. * LEGACY Mode set to false
  44745. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  44746. * diffuse part of the IBL.
  44747. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  44748. * to the ground truth.
  44749. */
  44750. useSphericalHarmonics: boolean;
  44751. /** @hidden */
  44752. private _internalMarkAllSubMeshesAsMiscDirty;
  44753. /** @hidden */
  44754. _markAllSubMeshesAsMiscDirty(): void;
  44755. /**
  44756. * Instantiate a new istance of clear coat configuration.
  44757. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44758. */
  44759. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44760. /**
  44761. * Checks to see if a texture is used in the material.
  44762. * @param defines the list of "defines" to update.
  44763. */
  44764. prepareDefines(defines: IMaterialBRDFDefines): void;
  44765. /**
  44766. * Get the current class name of the texture useful for serialization or dynamic coding.
  44767. * @returns "PBRClearCoatConfiguration"
  44768. */
  44769. getClassName(): string;
  44770. /**
  44771. * Makes a duplicate of the current configuration into another one.
  44772. * @param brdfConfiguration define the config where to copy the info
  44773. */
  44774. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44775. /**
  44776. * Serializes this BRDF configuration.
  44777. * @returns - An object with the serialized config.
  44778. */
  44779. serialize(): any;
  44780. /**
  44781. * Parses a BRDF Configuration from a serialized object.
  44782. * @param source - Serialized object.
  44783. */
  44784. parse(source: any): void;
  44785. }
  44786. }
  44787. declare module BABYLON {
  44788. /**
  44789. * @hidden
  44790. */
  44791. export interface IMaterialSheenDefines {
  44792. SHEEN: boolean;
  44793. SHEEN_TEXTURE: boolean;
  44794. SHEEN_TEXTUREDIRECTUV: number;
  44795. SHEEN_LINKWITHALBEDO: boolean;
  44796. /** @hidden */
  44797. _areTexturesDirty: boolean;
  44798. }
  44799. /**
  44800. * Define the code related to the Sheen parameters of the pbr material.
  44801. */
  44802. export class PBRSheenConfiguration {
  44803. private _isEnabled;
  44804. /**
  44805. * Defines if the material uses sheen.
  44806. */
  44807. isEnabled: boolean;
  44808. private _linkSheenWithAlbedo;
  44809. /**
  44810. * Defines if the sheen is linked to the sheen color.
  44811. */
  44812. linkSheenWithAlbedo: boolean;
  44813. /**
  44814. * Defines the sheen intensity.
  44815. */
  44816. intensity: number;
  44817. /**
  44818. * Defines the sheen color.
  44819. */
  44820. color: Color3;
  44821. private _texture;
  44822. /**
  44823. * Stores the sheen tint values in a texture.
  44824. * rgb is tint
  44825. * a is a intensity
  44826. */
  44827. texture: Nullable<BaseTexture>;
  44828. /** @hidden */
  44829. private _internalMarkAllSubMeshesAsTexturesDirty;
  44830. /** @hidden */
  44831. _markAllSubMeshesAsTexturesDirty(): void;
  44832. /**
  44833. * Instantiate a new istance of clear coat configuration.
  44834. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44835. */
  44836. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44837. /**
  44838. * Specifies that the submesh is ready to be used.
  44839. * @param defines the list of "defines" to update.
  44840. * @param scene defines the scene the material belongs to.
  44841. * @returns - boolean indicating that the submesh is ready or not.
  44842. */
  44843. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44844. /**
  44845. * Checks to see if a texture is used in the material.
  44846. * @param defines the list of "defines" to update.
  44847. * @param scene defines the scene the material belongs to.
  44848. */
  44849. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44850. /**
  44851. * Binds the material data.
  44852. * @param uniformBuffer defines the Uniform buffer to fill in.
  44853. * @param scene defines the scene the material belongs to.
  44854. * @param isFrozen defines wether the material is frozen or not.
  44855. */
  44856. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44857. /**
  44858. * Checks to see if a texture is used in the material.
  44859. * @param texture - Base texture to use.
  44860. * @returns - Boolean specifying if a texture is used in the material.
  44861. */
  44862. hasTexture(texture: BaseTexture): boolean;
  44863. /**
  44864. * Returns an array of the actively used textures.
  44865. * @param activeTextures Array of BaseTextures
  44866. */
  44867. getActiveTextures(activeTextures: BaseTexture[]): void;
  44868. /**
  44869. * Returns the animatable textures.
  44870. * @param animatables Array of animatable textures.
  44871. */
  44872. getAnimatables(animatables: IAnimatable[]): void;
  44873. /**
  44874. * Disposes the resources of the material.
  44875. * @param forceDisposeTextures - Forces the disposal of all textures.
  44876. */
  44877. dispose(forceDisposeTextures?: boolean): void;
  44878. /**
  44879. * Get the current class name of the texture useful for serialization or dynamic coding.
  44880. * @returns "PBRSheenConfiguration"
  44881. */
  44882. getClassName(): string;
  44883. /**
  44884. * Add fallbacks to the effect fallbacks list.
  44885. * @param defines defines the Base texture to use.
  44886. * @param fallbacks defines the current fallback list.
  44887. * @param currentRank defines the current fallback rank.
  44888. * @returns the new fallback rank.
  44889. */
  44890. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44891. /**
  44892. * Add the required uniforms to the current list.
  44893. * @param uniforms defines the current uniform list.
  44894. */
  44895. static AddUniforms(uniforms: string[]): void;
  44896. /**
  44897. * Add the required uniforms to the current buffer.
  44898. * @param uniformBuffer defines the current uniform buffer.
  44899. */
  44900. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44901. /**
  44902. * Add the required samplers to the current list.
  44903. * @param samplers defines the current sampler list.
  44904. */
  44905. static AddSamplers(samplers: string[]): void;
  44906. /**
  44907. * Makes a duplicate of the current configuration into another one.
  44908. * @param sheenConfiguration define the config where to copy the info
  44909. */
  44910. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44911. /**
  44912. * Serializes this BRDF configuration.
  44913. * @returns - An object with the serialized config.
  44914. */
  44915. serialize(): any;
  44916. /**
  44917. * Parses a Sheen Configuration from a serialized object.
  44918. * @param source - Serialized object.
  44919. */
  44920. parse(source: any): void;
  44921. }
  44922. }
  44923. declare module BABYLON {
  44924. /**
  44925. * @hidden
  44926. */
  44927. export interface IMaterialSubSurfaceDefines {
  44928. SUBSURFACE: boolean;
  44929. SS_REFRACTION: boolean;
  44930. SS_TRANSLUCENCY: boolean;
  44931. SS_SCATERRING: boolean;
  44932. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44933. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44934. SS_REFRACTIONMAP_3D: boolean;
  44935. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44936. SS_LODINREFRACTIONALPHA: boolean;
  44937. SS_GAMMAREFRACTION: boolean;
  44938. SS_RGBDREFRACTION: boolean;
  44939. SS_LINEARSPECULARREFRACTION: boolean;
  44940. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44941. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44942. /** @hidden */
  44943. _areTexturesDirty: boolean;
  44944. }
  44945. /**
  44946. * Define the code related to the sub surface parameters of the pbr material.
  44947. */
  44948. export class PBRSubSurfaceConfiguration {
  44949. private _isRefractionEnabled;
  44950. /**
  44951. * Defines if the refraction is enabled in the material.
  44952. */
  44953. isRefractionEnabled: boolean;
  44954. private _isTranslucencyEnabled;
  44955. /**
  44956. * Defines if the translucency is enabled in the material.
  44957. */
  44958. isTranslucencyEnabled: boolean;
  44959. private _isScatteringEnabled;
  44960. /**
  44961. * Defines the refraction intensity of the material.
  44962. * The refraction when enabled replaces the Diffuse part of the material.
  44963. * The intensity helps transitionning between diffuse and refraction.
  44964. */
  44965. refractionIntensity: number;
  44966. /**
  44967. * Defines the translucency intensity of the material.
  44968. * When translucency has been enabled, this defines how much of the "translucency"
  44969. * is addded to the diffuse part of the material.
  44970. */
  44971. translucencyIntensity: number;
  44972. /**
  44973. * Defines the scattering intensity of the material.
  44974. * When scattering has been enabled, this defines how much of the "scattered light"
  44975. * is addded to the diffuse part of the material.
  44976. */
  44977. scatteringIntensity: number;
  44978. private _thicknessTexture;
  44979. /**
  44980. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  44981. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  44982. * 0 would mean minimumThickness
  44983. * 1 would mean maximumThickness
  44984. * The other channels might be use as a mask to vary the different effects intensity.
  44985. */
  44986. thicknessTexture: Nullable<BaseTexture>;
  44987. private _refractionTexture;
  44988. /**
  44989. * Defines the texture to use for refraction.
  44990. */
  44991. refractionTexture: Nullable<BaseTexture>;
  44992. private _indexOfRefraction;
  44993. /**
  44994. * Defines the indice of refraction used in the material.
  44995. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  44996. */
  44997. indexOfRefraction: number;
  44998. private _invertRefractionY;
  44999. /**
  45000. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45001. */
  45002. invertRefractionY: boolean;
  45003. private _linkRefractionWithTransparency;
  45004. /**
  45005. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45006. * Materials half opaque for instance using refraction could benefit from this control.
  45007. */
  45008. linkRefractionWithTransparency: boolean;
  45009. /**
  45010. * Defines the minimum thickness stored in the thickness map.
  45011. * If no thickness map is defined, this value will be used to simulate thickness.
  45012. */
  45013. minimumThickness: number;
  45014. /**
  45015. * Defines the maximum thickness stored in the thickness map.
  45016. */
  45017. maximumThickness: number;
  45018. /**
  45019. * Defines the volume tint of the material.
  45020. * This is used for both translucency and scattering.
  45021. */
  45022. tintColor: Color3;
  45023. /**
  45024. * Defines the distance at which the tint color should be found in the media.
  45025. * This is used for refraction only.
  45026. */
  45027. tintColorAtDistance: number;
  45028. /**
  45029. * Defines how far each channel transmit through the media.
  45030. * It is defined as a color to simplify it selection.
  45031. */
  45032. diffusionDistance: Color3;
  45033. private _useMaskFromThicknessTexture;
  45034. /**
  45035. * Stores the intensity of the different subsurface effects in the thickness texture.
  45036. * * the green channel is the translucency intensity.
  45037. * * the blue channel is the scattering intensity.
  45038. * * the alpha channel is the refraction intensity.
  45039. */
  45040. useMaskFromThicknessTexture: boolean;
  45041. /** @hidden */
  45042. private _internalMarkAllSubMeshesAsTexturesDirty;
  45043. /** @hidden */
  45044. _markAllSubMeshesAsTexturesDirty(): void;
  45045. /**
  45046. * Instantiate a new istance of sub surface configuration.
  45047. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45048. */
  45049. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45050. /**
  45051. * Gets wehter the submesh is ready to be used or not.
  45052. * @param defines the list of "defines" to update.
  45053. * @param scene defines the scene the material belongs to.
  45054. * @returns - boolean indicating that the submesh is ready or not.
  45055. */
  45056. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45057. /**
  45058. * Checks to see if a texture is used in the material.
  45059. * @param defines the list of "defines" to update.
  45060. * @param scene defines the scene to the material belongs to.
  45061. */
  45062. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45063. /**
  45064. * Binds the material data.
  45065. * @param uniformBuffer defines the Uniform buffer to fill in.
  45066. * @param scene defines the scene the material belongs to.
  45067. * @param engine defines the engine the material belongs to.
  45068. * @param isFrozen defines wether the material is frozen or not.
  45069. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45070. */
  45071. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45072. /**
  45073. * Unbinds the material from the mesh.
  45074. * @param activeEffect defines the effect that should be unbound from.
  45075. * @returns true if unbound, otherwise false
  45076. */
  45077. unbind(activeEffect: Effect): boolean;
  45078. /**
  45079. * Returns the texture used for refraction or null if none is used.
  45080. * @param scene defines the scene the material belongs to.
  45081. * @returns - Refraction texture if present. If no refraction texture and refraction
  45082. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45083. */
  45084. private _getRefractionTexture;
  45085. /**
  45086. * Returns true if alpha blending should be disabled.
  45087. */
  45088. readonly disableAlphaBlending: boolean;
  45089. /**
  45090. * Fills the list of render target textures.
  45091. * @param renderTargets the list of render targets to update
  45092. */
  45093. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  45094. /**
  45095. * Checks to see if a texture is used in the material.
  45096. * @param texture - Base texture to use.
  45097. * @returns - Boolean specifying if a texture is used in the material.
  45098. */
  45099. hasTexture(texture: BaseTexture): boolean;
  45100. /**
  45101. * Gets a boolean indicating that current material needs to register RTT
  45102. * @returns true if this uses a render target otherwise false.
  45103. */
  45104. hasRenderTargetTextures(): boolean;
  45105. /**
  45106. * Returns an array of the actively used textures.
  45107. * @param activeTextures Array of BaseTextures
  45108. */
  45109. getActiveTextures(activeTextures: BaseTexture[]): void;
  45110. /**
  45111. * Returns the animatable textures.
  45112. * @param animatables Array of animatable textures.
  45113. */
  45114. getAnimatables(animatables: IAnimatable[]): void;
  45115. /**
  45116. * Disposes the resources of the material.
  45117. * @param forceDisposeTextures - Forces the disposal of all textures.
  45118. */
  45119. dispose(forceDisposeTextures?: boolean): void;
  45120. /**
  45121. * Get the current class name of the texture useful for serialization or dynamic coding.
  45122. * @returns "PBRSubSurfaceConfiguration"
  45123. */
  45124. getClassName(): string;
  45125. /**
  45126. * Add fallbacks to the effect fallbacks list.
  45127. * @param defines defines the Base texture to use.
  45128. * @param fallbacks defines the current fallback list.
  45129. * @param currentRank defines the current fallback rank.
  45130. * @returns the new fallback rank.
  45131. */
  45132. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45133. /**
  45134. * Add the required uniforms to the current list.
  45135. * @param uniforms defines the current uniform list.
  45136. */
  45137. static AddUniforms(uniforms: string[]): void;
  45138. /**
  45139. * Add the required samplers to the current list.
  45140. * @param samplers defines the current sampler list.
  45141. */
  45142. static AddSamplers(samplers: string[]): void;
  45143. /**
  45144. * Add the required uniforms to the current buffer.
  45145. * @param uniformBuffer defines the current uniform buffer.
  45146. */
  45147. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45148. /**
  45149. * Makes a duplicate of the current configuration into another one.
  45150. * @param configuration define the config where to copy the info
  45151. */
  45152. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  45153. /**
  45154. * Serializes this Sub Surface configuration.
  45155. * @returns - An object with the serialized config.
  45156. */
  45157. serialize(): any;
  45158. /**
  45159. * Parses a Sub Surface Configuration from a serialized object.
  45160. * @param source - Serialized object.
  45161. */
  45162. parse(source: any): void;
  45163. }
  45164. }
  45165. declare module BABYLON {
  45166. /** @hidden */
  45167. export var pbrFragmentDeclaration: {
  45168. name: string;
  45169. shader: string;
  45170. };
  45171. }
  45172. declare module BABYLON {
  45173. /** @hidden */
  45174. export var pbrUboDeclaration: {
  45175. name: string;
  45176. shader: string;
  45177. };
  45178. }
  45179. declare module BABYLON {
  45180. /** @hidden */
  45181. export var pbrFragmentExtraDeclaration: {
  45182. name: string;
  45183. shader: string;
  45184. };
  45185. }
  45186. declare module BABYLON {
  45187. /** @hidden */
  45188. export var pbrFragmentSamplersDeclaration: {
  45189. name: string;
  45190. shader: string;
  45191. };
  45192. }
  45193. declare module BABYLON {
  45194. /** @hidden */
  45195. export var pbrHelperFunctions: {
  45196. name: string;
  45197. shader: string;
  45198. };
  45199. }
  45200. declare module BABYLON {
  45201. /** @hidden */
  45202. export var harmonicsFunctions: {
  45203. name: string;
  45204. shader: string;
  45205. };
  45206. }
  45207. declare module BABYLON {
  45208. /** @hidden */
  45209. export var pbrDirectLightingSetupFunctions: {
  45210. name: string;
  45211. shader: string;
  45212. };
  45213. }
  45214. declare module BABYLON {
  45215. /** @hidden */
  45216. export var pbrDirectLightingFalloffFunctions: {
  45217. name: string;
  45218. shader: string;
  45219. };
  45220. }
  45221. declare module BABYLON {
  45222. /** @hidden */
  45223. export var pbrBRDFFunctions: {
  45224. name: string;
  45225. shader: string;
  45226. };
  45227. }
  45228. declare module BABYLON {
  45229. /** @hidden */
  45230. export var pbrDirectLightingFunctions: {
  45231. name: string;
  45232. shader: string;
  45233. };
  45234. }
  45235. declare module BABYLON {
  45236. /** @hidden */
  45237. export var pbrIBLFunctions: {
  45238. name: string;
  45239. shader: string;
  45240. };
  45241. }
  45242. declare module BABYLON {
  45243. /** @hidden */
  45244. export var pbrDebug: {
  45245. name: string;
  45246. shader: string;
  45247. };
  45248. }
  45249. declare module BABYLON {
  45250. /** @hidden */
  45251. export var pbrPixelShader: {
  45252. name: string;
  45253. shader: string;
  45254. };
  45255. }
  45256. declare module BABYLON {
  45257. /** @hidden */
  45258. export var pbrVertexDeclaration: {
  45259. name: string;
  45260. shader: string;
  45261. };
  45262. }
  45263. declare module BABYLON {
  45264. /** @hidden */
  45265. export var pbrVertexShader: {
  45266. name: string;
  45267. shader: string;
  45268. };
  45269. }
  45270. declare module BABYLON {
  45271. /**
  45272. * Manages the defines for the PBR Material.
  45273. * @hidden
  45274. */
  45275. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  45276. PBR: boolean;
  45277. MAINUV1: boolean;
  45278. MAINUV2: boolean;
  45279. UV1: boolean;
  45280. UV2: boolean;
  45281. ALBEDO: boolean;
  45282. ALBEDODIRECTUV: number;
  45283. VERTEXCOLOR: boolean;
  45284. AMBIENT: boolean;
  45285. AMBIENTDIRECTUV: number;
  45286. AMBIENTINGRAYSCALE: boolean;
  45287. OPACITY: boolean;
  45288. VERTEXALPHA: boolean;
  45289. OPACITYDIRECTUV: number;
  45290. OPACITYRGB: boolean;
  45291. ALPHATEST: boolean;
  45292. DEPTHPREPASS: boolean;
  45293. ALPHABLEND: boolean;
  45294. ALPHAFROMALBEDO: boolean;
  45295. ALPHATESTVALUE: string;
  45296. SPECULAROVERALPHA: boolean;
  45297. RADIANCEOVERALPHA: boolean;
  45298. ALPHAFRESNEL: boolean;
  45299. LINEARALPHAFRESNEL: boolean;
  45300. PREMULTIPLYALPHA: boolean;
  45301. EMISSIVE: boolean;
  45302. EMISSIVEDIRECTUV: number;
  45303. REFLECTIVITY: boolean;
  45304. REFLECTIVITYDIRECTUV: number;
  45305. SPECULARTERM: boolean;
  45306. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  45307. MICROSURFACEAUTOMATIC: boolean;
  45308. LODBASEDMICROSFURACE: boolean;
  45309. MICROSURFACEMAP: boolean;
  45310. MICROSURFACEMAPDIRECTUV: number;
  45311. METALLICWORKFLOW: boolean;
  45312. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  45313. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  45314. METALLNESSSTOREINMETALMAPBLUE: boolean;
  45315. AOSTOREINMETALMAPRED: boolean;
  45316. ENVIRONMENTBRDF: boolean;
  45317. ENVIRONMENTBRDF_RGBD: boolean;
  45318. NORMAL: boolean;
  45319. TANGENT: boolean;
  45320. BUMP: boolean;
  45321. BUMPDIRECTUV: number;
  45322. OBJECTSPACE_NORMALMAP: boolean;
  45323. PARALLAX: boolean;
  45324. PARALLAXOCCLUSION: boolean;
  45325. NORMALXYSCALE: boolean;
  45326. LIGHTMAP: boolean;
  45327. LIGHTMAPDIRECTUV: number;
  45328. USELIGHTMAPASSHADOWMAP: boolean;
  45329. GAMMALIGHTMAP: boolean;
  45330. REFLECTION: boolean;
  45331. REFLECTIONMAP_3D: boolean;
  45332. REFLECTIONMAP_SPHERICAL: boolean;
  45333. REFLECTIONMAP_PLANAR: boolean;
  45334. REFLECTIONMAP_CUBIC: boolean;
  45335. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  45336. REFLECTIONMAP_PROJECTION: boolean;
  45337. REFLECTIONMAP_SKYBOX: boolean;
  45338. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  45339. REFLECTIONMAP_EXPLICIT: boolean;
  45340. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  45341. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  45342. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  45343. INVERTCUBICMAP: boolean;
  45344. USESPHERICALFROMREFLECTIONMAP: boolean;
  45345. USEIRRADIANCEMAP: boolean;
  45346. SPHERICAL_HARMONICS: boolean;
  45347. USESPHERICALINVERTEX: boolean;
  45348. REFLECTIONMAP_OPPOSITEZ: boolean;
  45349. LODINREFLECTIONALPHA: boolean;
  45350. GAMMAREFLECTION: boolean;
  45351. RGBDREFLECTION: boolean;
  45352. LINEARSPECULARREFLECTION: boolean;
  45353. RADIANCEOCCLUSION: boolean;
  45354. HORIZONOCCLUSION: boolean;
  45355. INSTANCES: boolean;
  45356. NUM_BONE_INFLUENCERS: number;
  45357. BonesPerMesh: number;
  45358. BONETEXTURE: boolean;
  45359. NONUNIFORMSCALING: boolean;
  45360. MORPHTARGETS: boolean;
  45361. MORPHTARGETS_NORMAL: boolean;
  45362. MORPHTARGETS_TANGENT: boolean;
  45363. NUM_MORPH_INFLUENCERS: number;
  45364. IMAGEPROCESSING: boolean;
  45365. VIGNETTE: boolean;
  45366. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45367. VIGNETTEBLENDMODEOPAQUE: boolean;
  45368. TONEMAPPING: boolean;
  45369. TONEMAPPING_ACES: boolean;
  45370. CONTRAST: boolean;
  45371. COLORCURVES: boolean;
  45372. COLORGRADING: boolean;
  45373. COLORGRADING3D: boolean;
  45374. SAMPLER3DGREENDEPTH: boolean;
  45375. SAMPLER3DBGRMAP: boolean;
  45376. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45377. EXPOSURE: boolean;
  45378. MULTIVIEW: boolean;
  45379. USEPHYSICALLIGHTFALLOFF: boolean;
  45380. USEGLTFLIGHTFALLOFF: boolean;
  45381. TWOSIDEDLIGHTING: boolean;
  45382. SHADOWFLOAT: boolean;
  45383. CLIPPLANE: boolean;
  45384. CLIPPLANE2: boolean;
  45385. CLIPPLANE3: boolean;
  45386. CLIPPLANE4: boolean;
  45387. POINTSIZE: boolean;
  45388. FOG: boolean;
  45389. LOGARITHMICDEPTH: boolean;
  45390. FORCENORMALFORWARD: boolean;
  45391. SPECULARAA: boolean;
  45392. CLEARCOAT: boolean;
  45393. CLEARCOAT_DEFAULTIOR: boolean;
  45394. CLEARCOAT_TEXTURE: boolean;
  45395. CLEARCOAT_TEXTUREDIRECTUV: number;
  45396. CLEARCOAT_BUMP: boolean;
  45397. CLEARCOAT_BUMPDIRECTUV: number;
  45398. CLEARCOAT_TINT: boolean;
  45399. CLEARCOAT_TINT_TEXTURE: boolean;
  45400. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45401. ANISOTROPIC: boolean;
  45402. ANISOTROPIC_TEXTURE: boolean;
  45403. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45404. BRDF_V_HEIGHT_CORRELATED: boolean;
  45405. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45406. SHEEN: boolean;
  45407. SHEEN_TEXTURE: boolean;
  45408. SHEEN_TEXTUREDIRECTUV: number;
  45409. SHEEN_LINKWITHALBEDO: boolean;
  45410. SUBSURFACE: boolean;
  45411. SS_REFRACTION: boolean;
  45412. SS_TRANSLUCENCY: boolean;
  45413. SS_SCATERRING: boolean;
  45414. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45415. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45416. SS_REFRACTIONMAP_3D: boolean;
  45417. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45418. SS_LODINREFRACTIONALPHA: boolean;
  45419. SS_GAMMAREFRACTION: boolean;
  45420. SS_RGBDREFRACTION: boolean;
  45421. SS_LINEARSPECULARREFRACTION: boolean;
  45422. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45423. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45424. UNLIT: boolean;
  45425. DEBUGMODE: number;
  45426. /**
  45427. * Initializes the PBR Material defines.
  45428. */
  45429. constructor();
  45430. /**
  45431. * Resets the PBR Material defines.
  45432. */
  45433. reset(): void;
  45434. }
  45435. /**
  45436. * The Physically based material base class of BJS.
  45437. *
  45438. * This offers the main features of a standard PBR material.
  45439. * For more information, please refer to the documentation :
  45440. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45441. */
  45442. export abstract class PBRBaseMaterial extends PushMaterial {
  45443. /**
  45444. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45445. */
  45446. static readonly PBRMATERIAL_OPAQUE: number;
  45447. /**
  45448. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45449. */
  45450. static readonly PBRMATERIAL_ALPHATEST: number;
  45451. /**
  45452. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45453. */
  45454. static readonly PBRMATERIAL_ALPHABLEND: number;
  45455. /**
  45456. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45457. * They are also discarded below the alpha cutoff threshold to improve performances.
  45458. */
  45459. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45460. /**
  45461. * Defines the default value of how much AO map is occluding the analytical lights
  45462. * (point spot...).
  45463. */
  45464. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45465. /**
  45466. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45467. */
  45468. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45469. /**
  45470. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45471. * to enhance interoperability with other engines.
  45472. */
  45473. static readonly LIGHTFALLOFF_GLTF: number;
  45474. /**
  45475. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45476. * to enhance interoperability with other materials.
  45477. */
  45478. static readonly LIGHTFALLOFF_STANDARD: number;
  45479. /**
  45480. * Intensity of the direct lights e.g. the four lights available in your scene.
  45481. * This impacts both the direct diffuse and specular highlights.
  45482. */
  45483. protected _directIntensity: number;
  45484. /**
  45485. * Intensity of the emissive part of the material.
  45486. * This helps controlling the emissive effect without modifying the emissive color.
  45487. */
  45488. protected _emissiveIntensity: number;
  45489. /**
  45490. * Intensity of the environment e.g. how much the environment will light the object
  45491. * either through harmonics for rough material or through the refelction for shiny ones.
  45492. */
  45493. protected _environmentIntensity: number;
  45494. /**
  45495. * This is a special control allowing the reduction of the specular highlights coming from the
  45496. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45497. */
  45498. protected _specularIntensity: number;
  45499. /**
  45500. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45501. */
  45502. private _lightingInfos;
  45503. /**
  45504. * Debug Control allowing disabling the bump map on this material.
  45505. */
  45506. protected _disableBumpMap: boolean;
  45507. /**
  45508. * AKA Diffuse Texture in standard nomenclature.
  45509. */
  45510. protected _albedoTexture: Nullable<BaseTexture>;
  45511. /**
  45512. * AKA Occlusion Texture in other nomenclature.
  45513. */
  45514. protected _ambientTexture: Nullable<BaseTexture>;
  45515. /**
  45516. * AKA Occlusion Texture Intensity in other nomenclature.
  45517. */
  45518. protected _ambientTextureStrength: number;
  45519. /**
  45520. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45521. * 1 means it completely occludes it
  45522. * 0 mean it has no impact
  45523. */
  45524. protected _ambientTextureImpactOnAnalyticalLights: number;
  45525. /**
  45526. * Stores the alpha values in a texture.
  45527. */
  45528. protected _opacityTexture: Nullable<BaseTexture>;
  45529. /**
  45530. * Stores the reflection values in a texture.
  45531. */
  45532. protected _reflectionTexture: Nullable<BaseTexture>;
  45533. /**
  45534. * Stores the emissive values in a texture.
  45535. */
  45536. protected _emissiveTexture: Nullable<BaseTexture>;
  45537. /**
  45538. * AKA Specular texture in other nomenclature.
  45539. */
  45540. protected _reflectivityTexture: Nullable<BaseTexture>;
  45541. /**
  45542. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45543. */
  45544. protected _metallicTexture: Nullable<BaseTexture>;
  45545. /**
  45546. * Specifies the metallic scalar of the metallic/roughness workflow.
  45547. * Can also be used to scale the metalness values of the metallic texture.
  45548. */
  45549. protected _metallic: Nullable<number>;
  45550. /**
  45551. * Specifies the roughness scalar of the metallic/roughness workflow.
  45552. * Can also be used to scale the roughness values of the metallic texture.
  45553. */
  45554. protected _roughness: Nullable<number>;
  45555. /**
  45556. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45557. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45558. */
  45559. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45560. /**
  45561. * Stores surface normal data used to displace a mesh in a texture.
  45562. */
  45563. protected _bumpTexture: Nullable<BaseTexture>;
  45564. /**
  45565. * Stores the pre-calculated light information of a mesh in a texture.
  45566. */
  45567. protected _lightmapTexture: Nullable<BaseTexture>;
  45568. /**
  45569. * The color of a material in ambient lighting.
  45570. */
  45571. protected _ambientColor: Color3;
  45572. /**
  45573. * AKA Diffuse Color in other nomenclature.
  45574. */
  45575. protected _albedoColor: Color3;
  45576. /**
  45577. * AKA Specular Color in other nomenclature.
  45578. */
  45579. protected _reflectivityColor: Color3;
  45580. /**
  45581. * The color applied when light is reflected from a material.
  45582. */
  45583. protected _reflectionColor: Color3;
  45584. /**
  45585. * The color applied when light is emitted from a material.
  45586. */
  45587. protected _emissiveColor: Color3;
  45588. /**
  45589. * AKA Glossiness in other nomenclature.
  45590. */
  45591. protected _microSurface: number;
  45592. /**
  45593. * Specifies that the material will use the light map as a show map.
  45594. */
  45595. protected _useLightmapAsShadowmap: boolean;
  45596. /**
  45597. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45598. * makes the reflect vector face the model (under horizon).
  45599. */
  45600. protected _useHorizonOcclusion: boolean;
  45601. /**
  45602. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45603. * too much the area relying on ambient texture to define their ambient occlusion.
  45604. */
  45605. protected _useRadianceOcclusion: boolean;
  45606. /**
  45607. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45608. */
  45609. protected _useAlphaFromAlbedoTexture: boolean;
  45610. /**
  45611. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45612. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45613. */
  45614. protected _useSpecularOverAlpha: boolean;
  45615. /**
  45616. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45617. */
  45618. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45619. /**
  45620. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45621. */
  45622. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45623. /**
  45624. * Specifies if the metallic texture contains the roughness information in its green channel.
  45625. */
  45626. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45627. /**
  45628. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45629. */
  45630. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45631. /**
  45632. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45633. */
  45634. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45635. /**
  45636. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45637. */
  45638. protected _useAmbientInGrayScale: boolean;
  45639. /**
  45640. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45641. * The material will try to infer what glossiness each pixel should be.
  45642. */
  45643. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45644. /**
  45645. * Defines the falloff type used in this material.
  45646. * It by default is Physical.
  45647. */
  45648. protected _lightFalloff: number;
  45649. /**
  45650. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45651. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45652. */
  45653. protected _useRadianceOverAlpha: boolean;
  45654. /**
  45655. * Allows using an object space normal map (instead of tangent space).
  45656. */
  45657. protected _useObjectSpaceNormalMap: boolean;
  45658. /**
  45659. * Allows using the bump map in parallax mode.
  45660. */
  45661. protected _useParallax: boolean;
  45662. /**
  45663. * Allows using the bump map in parallax occlusion mode.
  45664. */
  45665. protected _useParallaxOcclusion: boolean;
  45666. /**
  45667. * Controls the scale bias of the parallax mode.
  45668. */
  45669. protected _parallaxScaleBias: number;
  45670. /**
  45671. * If sets to true, disables all the lights affecting the material.
  45672. */
  45673. protected _disableLighting: boolean;
  45674. /**
  45675. * Number of Simultaneous lights allowed on the material.
  45676. */
  45677. protected _maxSimultaneousLights: number;
  45678. /**
  45679. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45680. */
  45681. protected _invertNormalMapX: boolean;
  45682. /**
  45683. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45684. */
  45685. protected _invertNormalMapY: boolean;
  45686. /**
  45687. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45688. */
  45689. protected _twoSidedLighting: boolean;
  45690. /**
  45691. * Defines the alpha limits in alpha test mode.
  45692. */
  45693. protected _alphaCutOff: number;
  45694. /**
  45695. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45696. */
  45697. protected _forceAlphaTest: boolean;
  45698. /**
  45699. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45700. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45701. */
  45702. protected _useAlphaFresnel: boolean;
  45703. /**
  45704. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45705. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45706. */
  45707. protected _useLinearAlphaFresnel: boolean;
  45708. /**
  45709. * The transparency mode of the material.
  45710. */
  45711. protected _transparencyMode: Nullable<number>;
  45712. /**
  45713. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45714. * from cos thetav and roughness:
  45715. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45716. */
  45717. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45718. /**
  45719. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45720. */
  45721. protected _forceIrradianceInFragment: boolean;
  45722. /**
  45723. * Force normal to face away from face.
  45724. */
  45725. protected _forceNormalForward: boolean;
  45726. /**
  45727. * Enables specular anti aliasing in the PBR shader.
  45728. * It will both interacts on the Geometry for analytical and IBL lighting.
  45729. * It also prefilter the roughness map based on the bump values.
  45730. */
  45731. protected _enableSpecularAntiAliasing: boolean;
  45732. /**
  45733. * Default configuration related to image processing available in the PBR Material.
  45734. */
  45735. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45736. /**
  45737. * Keep track of the image processing observer to allow dispose and replace.
  45738. */
  45739. private _imageProcessingObserver;
  45740. /**
  45741. * Attaches a new image processing configuration to the PBR Material.
  45742. * @param configuration
  45743. */
  45744. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45745. /**
  45746. * Stores the available render targets.
  45747. */
  45748. private _renderTargets;
  45749. /**
  45750. * Sets the global ambient color for the material used in lighting calculations.
  45751. */
  45752. private _globalAmbientColor;
  45753. /**
  45754. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45755. */
  45756. private _useLogarithmicDepth;
  45757. /**
  45758. * If set to true, no lighting calculations will be applied.
  45759. */
  45760. private _unlit;
  45761. private _debugMode;
  45762. /**
  45763. * @hidden
  45764. * This is reserved for the inspector.
  45765. * Defines the material debug mode.
  45766. * It helps seeing only some components of the material while troubleshooting.
  45767. */
  45768. debugMode: number;
  45769. /**
  45770. * @hidden
  45771. * This is reserved for the inspector.
  45772. * Specify from where on screen the debug mode should start.
  45773. * The value goes from -1 (full screen) to 1 (not visible)
  45774. * It helps with side by side comparison against the final render
  45775. * This defaults to -1
  45776. */
  45777. private debugLimit;
  45778. /**
  45779. * @hidden
  45780. * This is reserved for the inspector.
  45781. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45782. * You can use the factor to better multiply the final value.
  45783. */
  45784. private debugFactor;
  45785. /**
  45786. * Defines the clear coat layer parameters for the material.
  45787. */
  45788. readonly clearCoat: PBRClearCoatConfiguration;
  45789. /**
  45790. * Defines the anisotropic parameters for the material.
  45791. */
  45792. readonly anisotropy: PBRAnisotropicConfiguration;
  45793. /**
  45794. * Defines the BRDF parameters for the material.
  45795. */
  45796. readonly brdf: PBRBRDFConfiguration;
  45797. /**
  45798. * Defines the Sheen parameters for the material.
  45799. */
  45800. readonly sheen: PBRSheenConfiguration;
  45801. /**
  45802. * Defines the SubSurface parameters for the material.
  45803. */
  45804. readonly subSurface: PBRSubSurfaceConfiguration;
  45805. /**
  45806. * Custom callback helping to override the default shader used in the material.
  45807. */
  45808. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  45809. /**
  45810. * Instantiates a new PBRMaterial instance.
  45811. *
  45812. * @param name The material name
  45813. * @param scene The scene the material will be use in.
  45814. */
  45815. constructor(name: string, scene: Scene);
  45816. /**
  45817. * Gets a boolean indicating that current material needs to register RTT
  45818. */
  45819. readonly hasRenderTargetTextures: boolean;
  45820. /**
  45821. * Gets the name of the material class.
  45822. */
  45823. getClassName(): string;
  45824. /**
  45825. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45826. */
  45827. /**
  45828. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45829. */
  45830. useLogarithmicDepth: boolean;
  45831. /**
  45832. * Gets the current transparency mode.
  45833. */
  45834. /**
  45835. * Sets the transparency mode of the material.
  45836. *
  45837. * | Value | Type | Description |
  45838. * | ----- | ----------------------------------- | ----------- |
  45839. * | 0 | OPAQUE | |
  45840. * | 1 | ALPHATEST | |
  45841. * | 2 | ALPHABLEND | |
  45842. * | 3 | ALPHATESTANDBLEND | |
  45843. *
  45844. */
  45845. transparencyMode: Nullable<number>;
  45846. /**
  45847. * Returns true if alpha blending should be disabled.
  45848. */
  45849. private readonly _disableAlphaBlending;
  45850. /**
  45851. * Specifies whether or not this material should be rendered in alpha blend mode.
  45852. */
  45853. needAlphaBlending(): boolean;
  45854. /**
  45855. * Specifies if the mesh will require alpha blending.
  45856. * @param mesh - BJS mesh.
  45857. */
  45858. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45859. /**
  45860. * Specifies whether or not this material should be rendered in alpha test mode.
  45861. */
  45862. needAlphaTesting(): boolean;
  45863. /**
  45864. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45865. */
  45866. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45867. /**
  45868. * Gets the texture used for the alpha test.
  45869. */
  45870. getAlphaTestTexture(): Nullable<BaseTexture>;
  45871. /**
  45872. * Specifies that the submesh is ready to be used.
  45873. * @param mesh - BJS mesh.
  45874. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45875. * @param useInstances - Specifies that instances should be used.
  45876. * @returns - boolean indicating that the submesh is ready or not.
  45877. */
  45878. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45879. /**
  45880. * Specifies if the material uses metallic roughness workflow.
  45881. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45882. */
  45883. isMetallicWorkflow(): boolean;
  45884. private _prepareEffect;
  45885. private _prepareDefines;
  45886. /**
  45887. * Force shader compilation
  45888. */
  45889. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45890. clipPlane: boolean;
  45891. }>): void;
  45892. /**
  45893. * Initializes the uniform buffer layout for the shader.
  45894. */
  45895. buildUniformLayout(): void;
  45896. /**
  45897. * Unbinds the material from the mesh
  45898. */
  45899. unbind(): void;
  45900. /**
  45901. * Binds the submesh data.
  45902. * @param world - The world matrix.
  45903. * @param mesh - The BJS mesh.
  45904. * @param subMesh - A submesh of the BJS mesh.
  45905. */
  45906. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45907. /**
  45908. * Returns the animatable textures.
  45909. * @returns - Array of animatable textures.
  45910. */
  45911. getAnimatables(): IAnimatable[];
  45912. /**
  45913. * Returns the texture used for reflections.
  45914. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45915. */
  45916. private _getReflectionTexture;
  45917. /**
  45918. * Returns an array of the actively used textures.
  45919. * @returns - Array of BaseTextures
  45920. */
  45921. getActiveTextures(): BaseTexture[];
  45922. /**
  45923. * Checks to see if a texture is used in the material.
  45924. * @param texture - Base texture to use.
  45925. * @returns - Boolean specifying if a texture is used in the material.
  45926. */
  45927. hasTexture(texture: BaseTexture): boolean;
  45928. /**
  45929. * Disposes the resources of the material.
  45930. * @param forceDisposeEffect - Forces the disposal of effects.
  45931. * @param forceDisposeTextures - Forces the disposal of all textures.
  45932. */
  45933. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45934. }
  45935. }
  45936. declare module BABYLON {
  45937. /**
  45938. * The Physically based material of BJS.
  45939. *
  45940. * This offers the main features of a standard PBR material.
  45941. * For more information, please refer to the documentation :
  45942. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45943. */
  45944. export class PBRMaterial extends PBRBaseMaterial {
  45945. /**
  45946. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45947. */
  45948. static readonly PBRMATERIAL_OPAQUE: number;
  45949. /**
  45950. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45951. */
  45952. static readonly PBRMATERIAL_ALPHATEST: number;
  45953. /**
  45954. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45955. */
  45956. static readonly PBRMATERIAL_ALPHABLEND: number;
  45957. /**
  45958. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45959. * They are also discarded below the alpha cutoff threshold to improve performances.
  45960. */
  45961. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45962. /**
  45963. * Defines the default value of how much AO map is occluding the analytical lights
  45964. * (point spot...).
  45965. */
  45966. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45967. /**
  45968. * Intensity of the direct lights e.g. the four lights available in your scene.
  45969. * This impacts both the direct diffuse and specular highlights.
  45970. */
  45971. directIntensity: number;
  45972. /**
  45973. * Intensity of the emissive part of the material.
  45974. * This helps controlling the emissive effect without modifying the emissive color.
  45975. */
  45976. emissiveIntensity: number;
  45977. /**
  45978. * Intensity of the environment e.g. how much the environment will light the object
  45979. * either through harmonics for rough material or through the refelction for shiny ones.
  45980. */
  45981. environmentIntensity: number;
  45982. /**
  45983. * This is a special control allowing the reduction of the specular highlights coming from the
  45984. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45985. */
  45986. specularIntensity: number;
  45987. /**
  45988. * Debug Control allowing disabling the bump map on this material.
  45989. */
  45990. disableBumpMap: boolean;
  45991. /**
  45992. * AKA Diffuse Texture in standard nomenclature.
  45993. */
  45994. albedoTexture: BaseTexture;
  45995. /**
  45996. * AKA Occlusion Texture in other nomenclature.
  45997. */
  45998. ambientTexture: BaseTexture;
  45999. /**
  46000. * AKA Occlusion Texture Intensity in other nomenclature.
  46001. */
  46002. ambientTextureStrength: number;
  46003. /**
  46004. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46005. * 1 means it completely occludes it
  46006. * 0 mean it has no impact
  46007. */
  46008. ambientTextureImpactOnAnalyticalLights: number;
  46009. /**
  46010. * Stores the alpha values in a texture.
  46011. */
  46012. opacityTexture: BaseTexture;
  46013. /**
  46014. * Stores the reflection values in a texture.
  46015. */
  46016. reflectionTexture: Nullable<BaseTexture>;
  46017. /**
  46018. * Stores the emissive values in a texture.
  46019. */
  46020. emissiveTexture: BaseTexture;
  46021. /**
  46022. * AKA Specular texture in other nomenclature.
  46023. */
  46024. reflectivityTexture: BaseTexture;
  46025. /**
  46026. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46027. */
  46028. metallicTexture: BaseTexture;
  46029. /**
  46030. * Specifies the metallic scalar of the metallic/roughness workflow.
  46031. * Can also be used to scale the metalness values of the metallic texture.
  46032. */
  46033. metallic: Nullable<number>;
  46034. /**
  46035. * Specifies the roughness scalar of the metallic/roughness workflow.
  46036. * Can also be used to scale the roughness values of the metallic texture.
  46037. */
  46038. roughness: Nullable<number>;
  46039. /**
  46040. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46041. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46042. */
  46043. microSurfaceTexture: BaseTexture;
  46044. /**
  46045. * Stores surface normal data used to displace a mesh in a texture.
  46046. */
  46047. bumpTexture: BaseTexture;
  46048. /**
  46049. * Stores the pre-calculated light information of a mesh in a texture.
  46050. */
  46051. lightmapTexture: BaseTexture;
  46052. /**
  46053. * Stores the refracted light information in a texture.
  46054. */
  46055. refractionTexture: Nullable<BaseTexture>;
  46056. /**
  46057. * The color of a material in ambient lighting.
  46058. */
  46059. ambientColor: Color3;
  46060. /**
  46061. * AKA Diffuse Color in other nomenclature.
  46062. */
  46063. albedoColor: Color3;
  46064. /**
  46065. * AKA Specular Color in other nomenclature.
  46066. */
  46067. reflectivityColor: Color3;
  46068. /**
  46069. * The color reflected from the material.
  46070. */
  46071. reflectionColor: Color3;
  46072. /**
  46073. * The color emitted from the material.
  46074. */
  46075. emissiveColor: Color3;
  46076. /**
  46077. * AKA Glossiness in other nomenclature.
  46078. */
  46079. microSurface: number;
  46080. /**
  46081. * source material index of refraction (IOR)' / 'destination material IOR.
  46082. */
  46083. indexOfRefraction: number;
  46084. /**
  46085. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46086. */
  46087. invertRefractionY: boolean;
  46088. /**
  46089. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46090. * Materials half opaque for instance using refraction could benefit from this control.
  46091. */
  46092. linkRefractionWithTransparency: boolean;
  46093. /**
  46094. * If true, the light map contains occlusion information instead of lighting info.
  46095. */
  46096. useLightmapAsShadowmap: boolean;
  46097. /**
  46098. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46099. */
  46100. useAlphaFromAlbedoTexture: boolean;
  46101. /**
  46102. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46103. */
  46104. forceAlphaTest: boolean;
  46105. /**
  46106. * Defines the alpha limits in alpha test mode.
  46107. */
  46108. alphaCutOff: number;
  46109. /**
  46110. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46111. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46112. */
  46113. useSpecularOverAlpha: boolean;
  46114. /**
  46115. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46116. */
  46117. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46118. /**
  46119. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46120. */
  46121. useRoughnessFromMetallicTextureAlpha: boolean;
  46122. /**
  46123. * Specifies if the metallic texture contains the roughness information in its green channel.
  46124. */
  46125. useRoughnessFromMetallicTextureGreen: boolean;
  46126. /**
  46127. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46128. */
  46129. useMetallnessFromMetallicTextureBlue: boolean;
  46130. /**
  46131. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46132. */
  46133. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46134. /**
  46135. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46136. */
  46137. useAmbientInGrayScale: boolean;
  46138. /**
  46139. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46140. * The material will try to infer what glossiness each pixel should be.
  46141. */
  46142. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46143. /**
  46144. * BJS is using an harcoded light falloff based on a manually sets up range.
  46145. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46146. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46147. */
  46148. /**
  46149. * BJS is using an harcoded light falloff based on a manually sets up range.
  46150. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46151. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46152. */
  46153. usePhysicalLightFalloff: boolean;
  46154. /**
  46155. * In order to support the falloff compatibility with gltf, a special mode has been added
  46156. * to reproduce the gltf light falloff.
  46157. */
  46158. /**
  46159. * In order to support the falloff compatibility with gltf, a special mode has been added
  46160. * to reproduce the gltf light falloff.
  46161. */
  46162. useGLTFLightFalloff: boolean;
  46163. /**
  46164. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46165. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46166. */
  46167. useRadianceOverAlpha: boolean;
  46168. /**
  46169. * Allows using an object space normal map (instead of tangent space).
  46170. */
  46171. useObjectSpaceNormalMap: boolean;
  46172. /**
  46173. * Allows using the bump map in parallax mode.
  46174. */
  46175. useParallax: boolean;
  46176. /**
  46177. * Allows using the bump map in parallax occlusion mode.
  46178. */
  46179. useParallaxOcclusion: boolean;
  46180. /**
  46181. * Controls the scale bias of the parallax mode.
  46182. */
  46183. parallaxScaleBias: number;
  46184. /**
  46185. * If sets to true, disables all the lights affecting the material.
  46186. */
  46187. disableLighting: boolean;
  46188. /**
  46189. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46190. */
  46191. forceIrradianceInFragment: boolean;
  46192. /**
  46193. * Number of Simultaneous lights allowed on the material.
  46194. */
  46195. maxSimultaneousLights: number;
  46196. /**
  46197. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46198. */
  46199. invertNormalMapX: boolean;
  46200. /**
  46201. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46202. */
  46203. invertNormalMapY: boolean;
  46204. /**
  46205. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46206. */
  46207. twoSidedLighting: boolean;
  46208. /**
  46209. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46210. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46211. */
  46212. useAlphaFresnel: boolean;
  46213. /**
  46214. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46215. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46216. */
  46217. useLinearAlphaFresnel: boolean;
  46218. /**
  46219. * Let user defines the brdf lookup texture used for IBL.
  46220. * A default 8bit version is embedded but you could point at :
  46221. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  46222. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46223. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46224. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46225. */
  46226. environmentBRDFTexture: Nullable<BaseTexture>;
  46227. /**
  46228. * Force normal to face away from face.
  46229. */
  46230. forceNormalForward: boolean;
  46231. /**
  46232. * Enables specular anti aliasing in the PBR shader.
  46233. * It will both interacts on the Geometry for analytical and IBL lighting.
  46234. * It also prefilter the roughness map based on the bump values.
  46235. */
  46236. enableSpecularAntiAliasing: boolean;
  46237. /**
  46238. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46239. * makes the reflect vector face the model (under horizon).
  46240. */
  46241. useHorizonOcclusion: boolean;
  46242. /**
  46243. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46244. * too much the area relying on ambient texture to define their ambient occlusion.
  46245. */
  46246. useRadianceOcclusion: boolean;
  46247. /**
  46248. * If set to true, no lighting calculations will be applied.
  46249. */
  46250. unlit: boolean;
  46251. /**
  46252. * Gets the image processing configuration used either in this material.
  46253. */
  46254. /**
  46255. * Sets the Default image processing configuration used either in the this material.
  46256. *
  46257. * If sets to null, the scene one is in use.
  46258. */
  46259. imageProcessingConfiguration: ImageProcessingConfiguration;
  46260. /**
  46261. * Gets wether the color curves effect is enabled.
  46262. */
  46263. /**
  46264. * Sets wether the color curves effect is enabled.
  46265. */
  46266. cameraColorCurvesEnabled: boolean;
  46267. /**
  46268. * Gets wether the color grading effect is enabled.
  46269. */
  46270. /**
  46271. * Gets wether the color grading effect is enabled.
  46272. */
  46273. cameraColorGradingEnabled: boolean;
  46274. /**
  46275. * Gets wether tonemapping is enabled or not.
  46276. */
  46277. /**
  46278. * Sets wether tonemapping is enabled or not
  46279. */
  46280. cameraToneMappingEnabled: boolean;
  46281. /**
  46282. * The camera exposure used on this material.
  46283. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46284. * This corresponds to a photographic exposure.
  46285. */
  46286. /**
  46287. * The camera exposure used on this material.
  46288. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46289. * This corresponds to a photographic exposure.
  46290. */
  46291. cameraExposure: number;
  46292. /**
  46293. * Gets The camera contrast used on this material.
  46294. */
  46295. /**
  46296. * Sets The camera contrast used on this material.
  46297. */
  46298. cameraContrast: number;
  46299. /**
  46300. * Gets the Color Grading 2D Lookup Texture.
  46301. */
  46302. /**
  46303. * Sets the Color Grading 2D Lookup Texture.
  46304. */
  46305. cameraColorGradingTexture: Nullable<BaseTexture>;
  46306. /**
  46307. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46308. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46309. * 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;
  46310. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46311. */
  46312. /**
  46313. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46314. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46315. * 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;
  46316. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46317. */
  46318. cameraColorCurves: Nullable<ColorCurves>;
  46319. /**
  46320. * Instantiates a new PBRMaterial instance.
  46321. *
  46322. * @param name The material name
  46323. * @param scene The scene the material will be use in.
  46324. */
  46325. constructor(name: string, scene: Scene);
  46326. /**
  46327. * Returns the name of this material class.
  46328. */
  46329. getClassName(): string;
  46330. /**
  46331. * Makes a duplicate of the current material.
  46332. * @param name - name to use for the new material.
  46333. */
  46334. clone(name: string): PBRMaterial;
  46335. /**
  46336. * Serializes this PBR Material.
  46337. * @returns - An object with the serialized material.
  46338. */
  46339. serialize(): any;
  46340. /**
  46341. * Parses a PBR Material from a serialized object.
  46342. * @param source - Serialized object.
  46343. * @param scene - BJS scene instance.
  46344. * @param rootUrl - url for the scene object
  46345. * @returns - PBRMaterial
  46346. */
  46347. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46348. }
  46349. }
  46350. declare module BABYLON {
  46351. /**
  46352. * Direct draw surface info
  46353. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46354. */
  46355. export interface DDSInfo {
  46356. /**
  46357. * Width of the texture
  46358. */
  46359. width: number;
  46360. /**
  46361. * Width of the texture
  46362. */
  46363. height: number;
  46364. /**
  46365. * Number of Mipmaps for the texture
  46366. * @see https://en.wikipedia.org/wiki/Mipmap
  46367. */
  46368. mipmapCount: number;
  46369. /**
  46370. * If the textures format is a known fourCC format
  46371. * @see https://www.fourcc.org/
  46372. */
  46373. isFourCC: boolean;
  46374. /**
  46375. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46376. */
  46377. isRGB: boolean;
  46378. /**
  46379. * If the texture is a lumincance format
  46380. */
  46381. isLuminance: boolean;
  46382. /**
  46383. * If this is a cube texture
  46384. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46385. */
  46386. isCube: boolean;
  46387. /**
  46388. * If the texture is a compressed format eg. FOURCC_DXT1
  46389. */
  46390. isCompressed: boolean;
  46391. /**
  46392. * The dxgiFormat of the texture
  46393. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46394. */
  46395. dxgiFormat: number;
  46396. /**
  46397. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46398. */
  46399. textureType: number;
  46400. /**
  46401. * Sphericle polynomial created for the dds texture
  46402. */
  46403. sphericalPolynomial?: SphericalPolynomial;
  46404. }
  46405. /**
  46406. * Class used to provide DDS decompression tools
  46407. */
  46408. export class DDSTools {
  46409. /**
  46410. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46411. */
  46412. static StoreLODInAlphaChannel: boolean;
  46413. /**
  46414. * Gets DDS information from an array buffer
  46415. * @param arrayBuffer defines the array buffer to read data from
  46416. * @returns the DDS information
  46417. */
  46418. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46419. private static _FloatView;
  46420. private static _Int32View;
  46421. private static _ToHalfFloat;
  46422. private static _FromHalfFloat;
  46423. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46424. private static _GetHalfFloatRGBAArrayBuffer;
  46425. private static _GetFloatRGBAArrayBuffer;
  46426. private static _GetFloatAsUIntRGBAArrayBuffer;
  46427. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46428. private static _GetRGBAArrayBuffer;
  46429. private static _ExtractLongWordOrder;
  46430. private static _GetRGBArrayBuffer;
  46431. private static _GetLuminanceArrayBuffer;
  46432. /**
  46433. * Uploads DDS Levels to a Babylon Texture
  46434. * @hidden
  46435. */
  46436. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46437. }
  46438. interface Engine {
  46439. /**
  46440. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46441. * @param rootUrl defines the url where the file to load is located
  46442. * @param scene defines the current scene
  46443. * @param lodScale defines scale to apply to the mip map selection
  46444. * @param lodOffset defines offset to apply to the mip map selection
  46445. * @param onLoad defines an optional callback raised when the texture is loaded
  46446. * @param onError defines an optional callback raised if there is an issue to load the texture
  46447. * @param format defines the format of the data
  46448. * @param forcedExtension defines the extension to use to pick the right loader
  46449. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46450. * @returns the cube texture as an InternalTexture
  46451. */
  46452. 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;
  46453. }
  46454. }
  46455. declare module BABYLON {
  46456. /**
  46457. * Implementation of the DDS Texture Loader.
  46458. * @hidden
  46459. */
  46460. export class _DDSTextureLoader implements IInternalTextureLoader {
  46461. /**
  46462. * Defines wether the loader supports cascade loading the different faces.
  46463. */
  46464. readonly supportCascades: boolean;
  46465. /**
  46466. * This returns if the loader support the current file information.
  46467. * @param extension defines the file extension of the file being loaded
  46468. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46469. * @param fallback defines the fallback internal texture if any
  46470. * @param isBase64 defines whether the texture is encoded as a base64
  46471. * @param isBuffer defines whether the texture data are stored as a buffer
  46472. * @returns true if the loader can load the specified file
  46473. */
  46474. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46475. /**
  46476. * Transform the url before loading if required.
  46477. * @param rootUrl the url of the texture
  46478. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46479. * @returns the transformed texture
  46480. */
  46481. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46482. /**
  46483. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46484. * @param rootUrl the url of the texture
  46485. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46486. * @returns the fallback texture
  46487. */
  46488. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46489. /**
  46490. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46491. * @param data contains the texture data
  46492. * @param texture defines the BabylonJS internal texture
  46493. * @param createPolynomials will be true if polynomials have been requested
  46494. * @param onLoad defines the callback to trigger once the texture is ready
  46495. * @param onError defines the callback to trigger in case of error
  46496. */
  46497. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46498. /**
  46499. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46500. * @param data contains the texture data
  46501. * @param texture defines the BabylonJS internal texture
  46502. * @param callback defines the method to call once ready to upload
  46503. */
  46504. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46505. }
  46506. }
  46507. declare module BABYLON {
  46508. /** @hidden */
  46509. export var rgbdEncodePixelShader: {
  46510. name: string;
  46511. shader: string;
  46512. };
  46513. }
  46514. declare module BABYLON {
  46515. /**
  46516. * Raw texture data and descriptor sufficient for WebGL texture upload
  46517. */
  46518. export interface EnvironmentTextureInfo {
  46519. /**
  46520. * Version of the environment map
  46521. */
  46522. version: number;
  46523. /**
  46524. * Width of image
  46525. */
  46526. width: number;
  46527. /**
  46528. * Irradiance information stored in the file.
  46529. */
  46530. irradiance: any;
  46531. /**
  46532. * Specular information stored in the file.
  46533. */
  46534. specular: any;
  46535. }
  46536. /**
  46537. * Sets of helpers addressing the serialization and deserialization of environment texture
  46538. * stored in a BabylonJS env file.
  46539. * Those files are usually stored as .env files.
  46540. */
  46541. export class EnvironmentTextureTools {
  46542. /**
  46543. * Magic number identifying the env file.
  46544. */
  46545. private static _MagicBytes;
  46546. /**
  46547. * Gets the environment info from an env file.
  46548. * @param data The array buffer containing the .env bytes.
  46549. * @returns the environment file info (the json header) if successfully parsed.
  46550. */
  46551. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46552. /**
  46553. * Creates an environment texture from a loaded cube texture.
  46554. * @param texture defines the cube texture to convert in env file
  46555. * @return a promise containing the environment data if succesfull.
  46556. */
  46557. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46558. /**
  46559. * Creates a JSON representation of the spherical data.
  46560. * @param texture defines the texture containing the polynomials
  46561. * @return the JSON representation of the spherical info
  46562. */
  46563. private static _CreateEnvTextureIrradiance;
  46564. /**
  46565. * Uploads the texture info contained in the env file to the GPU.
  46566. * @param texture defines the internal texture to upload to
  46567. * @param arrayBuffer defines the buffer cotaining the data to load
  46568. * @param info defines the texture info retrieved through the GetEnvInfo method
  46569. * @returns a promise
  46570. */
  46571. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46572. /**
  46573. * Uploads the levels of image data to the GPU.
  46574. * @param texture defines the internal texture to upload to
  46575. * @param imageData defines the array buffer views of image data [mipmap][face]
  46576. * @returns a promise
  46577. */
  46578. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46579. /**
  46580. * Uploads spherical polynomials information to the texture.
  46581. * @param texture defines the texture we are trying to upload the information to
  46582. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46583. */
  46584. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46585. /** @hidden */
  46586. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46587. }
  46588. }
  46589. declare module BABYLON {
  46590. /**
  46591. * Implementation of the ENV Texture Loader.
  46592. * @hidden
  46593. */
  46594. export class _ENVTextureLoader implements IInternalTextureLoader {
  46595. /**
  46596. * Defines wether the loader supports cascade loading the different faces.
  46597. */
  46598. readonly supportCascades: boolean;
  46599. /**
  46600. * This returns if the loader support the current file information.
  46601. * @param extension defines the file extension of the file being loaded
  46602. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46603. * @param fallback defines the fallback internal texture if any
  46604. * @param isBase64 defines whether the texture is encoded as a base64
  46605. * @param isBuffer defines whether the texture data are stored as a buffer
  46606. * @returns true if the loader can load the specified file
  46607. */
  46608. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46609. /**
  46610. * Transform the url before loading if required.
  46611. * @param rootUrl the url of the texture
  46612. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46613. * @returns the transformed texture
  46614. */
  46615. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46616. /**
  46617. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46618. * @param rootUrl the url of the texture
  46619. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46620. * @returns the fallback texture
  46621. */
  46622. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46623. /**
  46624. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46625. * @param data contains the texture data
  46626. * @param texture defines the BabylonJS internal texture
  46627. * @param createPolynomials will be true if polynomials have been requested
  46628. * @param onLoad defines the callback to trigger once the texture is ready
  46629. * @param onError defines the callback to trigger in case of error
  46630. */
  46631. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46632. /**
  46633. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46634. * @param data contains the texture data
  46635. * @param texture defines the BabylonJS internal texture
  46636. * @param callback defines the method to call once ready to upload
  46637. */
  46638. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46639. }
  46640. }
  46641. declare module BABYLON {
  46642. /**
  46643. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46644. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46645. */
  46646. export class KhronosTextureContainer {
  46647. /** contents of the KTX container file */
  46648. arrayBuffer: any;
  46649. private static HEADER_LEN;
  46650. private static COMPRESSED_2D;
  46651. private static COMPRESSED_3D;
  46652. private static TEX_2D;
  46653. private static TEX_3D;
  46654. /**
  46655. * Gets the openGL type
  46656. */
  46657. glType: number;
  46658. /**
  46659. * Gets the openGL type size
  46660. */
  46661. glTypeSize: number;
  46662. /**
  46663. * Gets the openGL format
  46664. */
  46665. glFormat: number;
  46666. /**
  46667. * Gets the openGL internal format
  46668. */
  46669. glInternalFormat: number;
  46670. /**
  46671. * Gets the base internal format
  46672. */
  46673. glBaseInternalFormat: number;
  46674. /**
  46675. * Gets image width in pixel
  46676. */
  46677. pixelWidth: number;
  46678. /**
  46679. * Gets image height in pixel
  46680. */
  46681. pixelHeight: number;
  46682. /**
  46683. * Gets image depth in pixels
  46684. */
  46685. pixelDepth: number;
  46686. /**
  46687. * Gets the number of array elements
  46688. */
  46689. numberOfArrayElements: number;
  46690. /**
  46691. * Gets the number of faces
  46692. */
  46693. numberOfFaces: number;
  46694. /**
  46695. * Gets the number of mipmap levels
  46696. */
  46697. numberOfMipmapLevels: number;
  46698. /**
  46699. * Gets the bytes of key value data
  46700. */
  46701. bytesOfKeyValueData: number;
  46702. /**
  46703. * Gets the load type
  46704. */
  46705. loadType: number;
  46706. /**
  46707. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46708. */
  46709. isInvalid: boolean;
  46710. /**
  46711. * Creates a new KhronosTextureContainer
  46712. * @param arrayBuffer contents of the KTX container file
  46713. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46714. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46715. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46716. */
  46717. constructor(
  46718. /** contents of the KTX container file */
  46719. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46720. /**
  46721. * Uploads KTX content to a Babylon Texture.
  46722. * It is assumed that the texture has already been created & is currently bound
  46723. * @hidden
  46724. */
  46725. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46726. private _upload2DCompressedLevels;
  46727. }
  46728. }
  46729. declare module BABYLON {
  46730. /**
  46731. * Implementation of the KTX Texture Loader.
  46732. * @hidden
  46733. */
  46734. export class _KTXTextureLoader implements IInternalTextureLoader {
  46735. /**
  46736. * Defines wether the loader supports cascade loading the different faces.
  46737. */
  46738. readonly supportCascades: boolean;
  46739. /**
  46740. * This returns if the loader support the current file information.
  46741. * @param extension defines the file extension of the file being loaded
  46742. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46743. * @param fallback defines the fallback internal texture if any
  46744. * @param isBase64 defines whether the texture is encoded as a base64
  46745. * @param isBuffer defines whether the texture data are stored as a buffer
  46746. * @returns true if the loader can load the specified file
  46747. */
  46748. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46749. /**
  46750. * Transform the url before loading if required.
  46751. * @param rootUrl the url of the texture
  46752. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46753. * @returns the transformed texture
  46754. */
  46755. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46756. /**
  46757. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46758. * @param rootUrl the url of the texture
  46759. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46760. * @returns the fallback texture
  46761. */
  46762. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46763. /**
  46764. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46765. * @param data contains the texture data
  46766. * @param texture defines the BabylonJS internal texture
  46767. * @param createPolynomials will be true if polynomials have been requested
  46768. * @param onLoad defines the callback to trigger once the texture is ready
  46769. * @param onError defines the callback to trigger in case of error
  46770. */
  46771. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46772. /**
  46773. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46774. * @param data contains the texture data
  46775. * @param texture defines the BabylonJS internal texture
  46776. * @param callback defines the method to call once ready to upload
  46777. */
  46778. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46779. }
  46780. }
  46781. declare module BABYLON {
  46782. /** @hidden */
  46783. export var _forceSceneHelpersToBundle: boolean;
  46784. interface Scene {
  46785. /**
  46786. * Creates a default light for the scene.
  46787. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46788. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46789. */
  46790. createDefaultLight(replace?: boolean): void;
  46791. /**
  46792. * Creates a default camera for the scene.
  46793. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46794. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46795. * @param replace has default false, when true replaces the active camera in the scene
  46796. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46797. */
  46798. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46799. /**
  46800. * Creates a default camera and a default light.
  46801. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46802. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46803. * @param replace has the default false, when true replaces the active camera/light in the scene
  46804. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46805. */
  46806. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46807. /**
  46808. * Creates a new sky box
  46809. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46810. * @param environmentTexture defines the texture to use as environment texture
  46811. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46812. * @param scale defines the overall scale of the skybox
  46813. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46814. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46815. * @returns a new mesh holding the sky box
  46816. */
  46817. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46818. /**
  46819. * Creates a new environment
  46820. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46821. * @param options defines the options you can use to configure the environment
  46822. * @returns the new EnvironmentHelper
  46823. */
  46824. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46825. /**
  46826. * Creates a new VREXperienceHelper
  46827. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46828. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46829. * @returns a new VREXperienceHelper
  46830. */
  46831. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46832. /**
  46833. * Creates a new XREXperienceHelper
  46834. * @see http://doc.babylonjs.com/how_to/webxr
  46835. * @returns a promise for a new XREXperienceHelper
  46836. */
  46837. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46838. }
  46839. }
  46840. declare module BABYLON {
  46841. /**
  46842. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46843. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46844. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46845. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46846. */
  46847. export class VideoDome extends TransformNode {
  46848. /**
  46849. * Define the video source as a Monoscopic panoramic 360 video.
  46850. */
  46851. static readonly MODE_MONOSCOPIC: number;
  46852. /**
  46853. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46854. */
  46855. static readonly MODE_TOPBOTTOM: number;
  46856. /**
  46857. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46858. */
  46859. static readonly MODE_SIDEBYSIDE: number;
  46860. private _useDirectMapping;
  46861. /**
  46862. * The video texture being displayed on the sphere
  46863. */
  46864. protected _videoTexture: VideoTexture;
  46865. /**
  46866. * Gets the video texture being displayed on the sphere
  46867. */
  46868. readonly videoTexture: VideoTexture;
  46869. /**
  46870. * The skybox material
  46871. */
  46872. protected _material: BackgroundMaterial;
  46873. /**
  46874. * The surface used for the skybox
  46875. */
  46876. protected _mesh: Mesh;
  46877. /**
  46878. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46879. * Also see the options.resolution property.
  46880. */
  46881. fovMultiplier: number;
  46882. private _videoMode;
  46883. /**
  46884. * Gets or set the current video mode for the video. It can be:
  46885. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46886. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46887. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46888. */
  46889. videoMode: number;
  46890. /**
  46891. * Oberserver used in Stereoscopic VR Mode.
  46892. */
  46893. private _onBeforeCameraRenderObserver;
  46894. /**
  46895. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46896. * @param name Element's name, child elements will append suffixes for their own names.
  46897. * @param urlsOrVideo defines the url(s) or the video element to use
  46898. * @param options An object containing optional or exposed sub element properties
  46899. */
  46900. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46901. resolution?: number;
  46902. clickToPlay?: boolean;
  46903. autoPlay?: boolean;
  46904. loop?: boolean;
  46905. size?: number;
  46906. poster?: string;
  46907. faceForward?: boolean;
  46908. useDirectMapping?: boolean;
  46909. }, scene: Scene);
  46910. private _changeVideoMode;
  46911. /**
  46912. * Releases resources associated with this node.
  46913. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46914. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46915. */
  46916. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46917. }
  46918. }
  46919. declare module BABYLON {
  46920. /**
  46921. * This class can be used to get instrumentation data from a Babylon engine
  46922. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46923. */
  46924. export class EngineInstrumentation implements IDisposable {
  46925. /**
  46926. * Define the instrumented engine.
  46927. */
  46928. engine: Engine;
  46929. private _captureGPUFrameTime;
  46930. private _gpuFrameTimeToken;
  46931. private _gpuFrameTime;
  46932. private _captureShaderCompilationTime;
  46933. private _shaderCompilationTime;
  46934. private _onBeginFrameObserver;
  46935. private _onEndFrameObserver;
  46936. private _onBeforeShaderCompilationObserver;
  46937. private _onAfterShaderCompilationObserver;
  46938. /**
  46939. * Gets the perf counter used for GPU frame time
  46940. */
  46941. readonly gpuFrameTimeCounter: PerfCounter;
  46942. /**
  46943. * Gets the GPU frame time capture status
  46944. */
  46945. /**
  46946. * Enable or disable the GPU frame time capture
  46947. */
  46948. captureGPUFrameTime: boolean;
  46949. /**
  46950. * Gets the perf counter used for shader compilation time
  46951. */
  46952. readonly shaderCompilationTimeCounter: PerfCounter;
  46953. /**
  46954. * Gets the shader compilation time capture status
  46955. */
  46956. /**
  46957. * Enable or disable the shader compilation time capture
  46958. */
  46959. captureShaderCompilationTime: boolean;
  46960. /**
  46961. * Instantiates a new engine instrumentation.
  46962. * This class can be used to get instrumentation data from a Babylon engine
  46963. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46964. * @param engine Defines the engine to instrument
  46965. */
  46966. constructor(
  46967. /**
  46968. * Define the instrumented engine.
  46969. */
  46970. engine: Engine);
  46971. /**
  46972. * Dispose and release associated resources.
  46973. */
  46974. dispose(): void;
  46975. }
  46976. }
  46977. declare module BABYLON {
  46978. /**
  46979. * This class can be used to get instrumentation data from a Babylon engine
  46980. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46981. */
  46982. export class SceneInstrumentation implements IDisposable {
  46983. /**
  46984. * Defines the scene to instrument
  46985. */
  46986. scene: Scene;
  46987. private _captureActiveMeshesEvaluationTime;
  46988. private _activeMeshesEvaluationTime;
  46989. private _captureRenderTargetsRenderTime;
  46990. private _renderTargetsRenderTime;
  46991. private _captureFrameTime;
  46992. private _frameTime;
  46993. private _captureRenderTime;
  46994. private _renderTime;
  46995. private _captureInterFrameTime;
  46996. private _interFrameTime;
  46997. private _captureParticlesRenderTime;
  46998. private _particlesRenderTime;
  46999. private _captureSpritesRenderTime;
  47000. private _spritesRenderTime;
  47001. private _capturePhysicsTime;
  47002. private _physicsTime;
  47003. private _captureAnimationsTime;
  47004. private _animationsTime;
  47005. private _captureCameraRenderTime;
  47006. private _cameraRenderTime;
  47007. private _onBeforeActiveMeshesEvaluationObserver;
  47008. private _onAfterActiveMeshesEvaluationObserver;
  47009. private _onBeforeRenderTargetsRenderObserver;
  47010. private _onAfterRenderTargetsRenderObserver;
  47011. private _onAfterRenderObserver;
  47012. private _onBeforeDrawPhaseObserver;
  47013. private _onAfterDrawPhaseObserver;
  47014. private _onBeforeAnimationsObserver;
  47015. private _onBeforeParticlesRenderingObserver;
  47016. private _onAfterParticlesRenderingObserver;
  47017. private _onBeforeSpritesRenderingObserver;
  47018. private _onAfterSpritesRenderingObserver;
  47019. private _onBeforePhysicsObserver;
  47020. private _onAfterPhysicsObserver;
  47021. private _onAfterAnimationsObserver;
  47022. private _onBeforeCameraRenderObserver;
  47023. private _onAfterCameraRenderObserver;
  47024. /**
  47025. * Gets the perf counter used for active meshes evaluation time
  47026. */
  47027. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47028. /**
  47029. * Gets the active meshes evaluation time capture status
  47030. */
  47031. /**
  47032. * Enable or disable the active meshes evaluation time capture
  47033. */
  47034. captureActiveMeshesEvaluationTime: boolean;
  47035. /**
  47036. * Gets the perf counter used for render targets render time
  47037. */
  47038. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47039. /**
  47040. * Gets the render targets render time capture status
  47041. */
  47042. /**
  47043. * Enable or disable the render targets render time capture
  47044. */
  47045. captureRenderTargetsRenderTime: boolean;
  47046. /**
  47047. * Gets the perf counter used for particles render time
  47048. */
  47049. readonly particlesRenderTimeCounter: PerfCounter;
  47050. /**
  47051. * Gets the particles render time capture status
  47052. */
  47053. /**
  47054. * Enable or disable the particles render time capture
  47055. */
  47056. captureParticlesRenderTime: boolean;
  47057. /**
  47058. * Gets the perf counter used for sprites render time
  47059. */
  47060. readonly spritesRenderTimeCounter: PerfCounter;
  47061. /**
  47062. * Gets the sprites render time capture status
  47063. */
  47064. /**
  47065. * Enable or disable the sprites render time capture
  47066. */
  47067. captureSpritesRenderTime: boolean;
  47068. /**
  47069. * Gets the perf counter used for physics time
  47070. */
  47071. readonly physicsTimeCounter: PerfCounter;
  47072. /**
  47073. * Gets the physics time capture status
  47074. */
  47075. /**
  47076. * Enable or disable the physics time capture
  47077. */
  47078. capturePhysicsTime: boolean;
  47079. /**
  47080. * Gets the perf counter used for animations time
  47081. */
  47082. readonly animationsTimeCounter: PerfCounter;
  47083. /**
  47084. * Gets the animations time capture status
  47085. */
  47086. /**
  47087. * Enable or disable the animations time capture
  47088. */
  47089. captureAnimationsTime: boolean;
  47090. /**
  47091. * Gets the perf counter used for frame time capture
  47092. */
  47093. readonly frameTimeCounter: PerfCounter;
  47094. /**
  47095. * Gets the frame time capture status
  47096. */
  47097. /**
  47098. * Enable or disable the frame time capture
  47099. */
  47100. captureFrameTime: boolean;
  47101. /**
  47102. * Gets the perf counter used for inter-frames time capture
  47103. */
  47104. readonly interFrameTimeCounter: PerfCounter;
  47105. /**
  47106. * Gets the inter-frames time capture status
  47107. */
  47108. /**
  47109. * Enable or disable the inter-frames time capture
  47110. */
  47111. captureInterFrameTime: boolean;
  47112. /**
  47113. * Gets the perf counter used for render time capture
  47114. */
  47115. readonly renderTimeCounter: PerfCounter;
  47116. /**
  47117. * Gets the render time capture status
  47118. */
  47119. /**
  47120. * Enable or disable the render time capture
  47121. */
  47122. captureRenderTime: boolean;
  47123. /**
  47124. * Gets the perf counter used for camera render time capture
  47125. */
  47126. readonly cameraRenderTimeCounter: PerfCounter;
  47127. /**
  47128. * Gets the camera render time capture status
  47129. */
  47130. /**
  47131. * Enable or disable the camera render time capture
  47132. */
  47133. captureCameraRenderTime: boolean;
  47134. /**
  47135. * Gets the perf counter used for draw calls
  47136. */
  47137. readonly drawCallsCounter: PerfCounter;
  47138. /**
  47139. * Instantiates a new scene instrumentation.
  47140. * This class can be used to get instrumentation data from a Babylon engine
  47141. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47142. * @param scene Defines the scene to instrument
  47143. */
  47144. constructor(
  47145. /**
  47146. * Defines the scene to instrument
  47147. */
  47148. scene: Scene);
  47149. /**
  47150. * Dispose and release associated resources.
  47151. */
  47152. dispose(): void;
  47153. }
  47154. }
  47155. declare module BABYLON {
  47156. /** @hidden */
  47157. export var glowMapGenerationPixelShader: {
  47158. name: string;
  47159. shader: string;
  47160. };
  47161. }
  47162. declare module BABYLON {
  47163. /** @hidden */
  47164. export var glowMapGenerationVertexShader: {
  47165. name: string;
  47166. shader: string;
  47167. };
  47168. }
  47169. declare module BABYLON {
  47170. /**
  47171. * Effect layer options. This helps customizing the behaviour
  47172. * of the effect layer.
  47173. */
  47174. export interface IEffectLayerOptions {
  47175. /**
  47176. * Multiplication factor apply to the canvas size to compute the render target size
  47177. * used to generated the objects (the smaller the faster).
  47178. */
  47179. mainTextureRatio: number;
  47180. /**
  47181. * Enforces a fixed size texture to ensure effect stability across devices.
  47182. */
  47183. mainTextureFixedSize?: number;
  47184. /**
  47185. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47186. */
  47187. alphaBlendingMode: number;
  47188. /**
  47189. * The camera attached to the layer.
  47190. */
  47191. camera: Nullable<Camera>;
  47192. /**
  47193. * The rendering group to draw the layer in.
  47194. */
  47195. renderingGroupId: number;
  47196. }
  47197. /**
  47198. * The effect layer Helps adding post process effect blended with the main pass.
  47199. *
  47200. * This can be for instance use to generate glow or higlight effects on the scene.
  47201. *
  47202. * The effect layer class can not be used directly and is intented to inherited from to be
  47203. * customized per effects.
  47204. */
  47205. export abstract class EffectLayer {
  47206. private _vertexBuffers;
  47207. private _indexBuffer;
  47208. private _cachedDefines;
  47209. private _effectLayerMapGenerationEffect;
  47210. private _effectLayerOptions;
  47211. private _mergeEffect;
  47212. protected _scene: Scene;
  47213. protected _engine: Engine;
  47214. protected _maxSize: number;
  47215. protected _mainTextureDesiredSize: ISize;
  47216. protected _mainTexture: RenderTargetTexture;
  47217. protected _shouldRender: boolean;
  47218. protected _postProcesses: PostProcess[];
  47219. protected _textures: BaseTexture[];
  47220. protected _emissiveTextureAndColor: {
  47221. texture: Nullable<BaseTexture>;
  47222. color: Color4;
  47223. };
  47224. /**
  47225. * The name of the layer
  47226. */
  47227. name: string;
  47228. /**
  47229. * The clear color of the texture used to generate the glow map.
  47230. */
  47231. neutralColor: Color4;
  47232. /**
  47233. * Specifies wether the highlight layer is enabled or not.
  47234. */
  47235. isEnabled: boolean;
  47236. /**
  47237. * Gets the camera attached to the layer.
  47238. */
  47239. readonly camera: Nullable<Camera>;
  47240. /**
  47241. * Gets the rendering group id the layer should render in.
  47242. */
  47243. readonly renderingGroupId: number;
  47244. /**
  47245. * An event triggered when the effect layer has been disposed.
  47246. */
  47247. onDisposeObservable: Observable<EffectLayer>;
  47248. /**
  47249. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47250. */
  47251. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47252. /**
  47253. * An event triggered when the generated texture is being merged in the scene.
  47254. */
  47255. onBeforeComposeObservable: Observable<EffectLayer>;
  47256. /**
  47257. * An event triggered when the generated texture has been merged in the scene.
  47258. */
  47259. onAfterComposeObservable: Observable<EffectLayer>;
  47260. /**
  47261. * An event triggered when the efffect layer changes its size.
  47262. */
  47263. onSizeChangedObservable: Observable<EffectLayer>;
  47264. /** @hidden */
  47265. static _SceneComponentInitialization: (scene: Scene) => void;
  47266. /**
  47267. * Instantiates a new effect Layer and references it in the scene.
  47268. * @param name The name of the layer
  47269. * @param scene The scene to use the layer in
  47270. */
  47271. constructor(
  47272. /** The Friendly of the effect in the scene */
  47273. name: string, scene: Scene);
  47274. /**
  47275. * Get the effect name of the layer.
  47276. * @return The effect name
  47277. */
  47278. abstract getEffectName(): string;
  47279. /**
  47280. * Checks for the readiness of the element composing the layer.
  47281. * @param subMesh the mesh to check for
  47282. * @param useInstances specify wether or not to use instances to render the mesh
  47283. * @return true if ready otherwise, false
  47284. */
  47285. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47286. /**
  47287. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47288. * @returns true if the effect requires stencil during the main canvas render pass.
  47289. */
  47290. abstract needStencil(): boolean;
  47291. /**
  47292. * Create the merge effect. This is the shader use to blit the information back
  47293. * to the main canvas at the end of the scene rendering.
  47294. * @returns The effect containing the shader used to merge the effect on the main canvas
  47295. */
  47296. protected abstract _createMergeEffect(): Effect;
  47297. /**
  47298. * Creates the render target textures and post processes used in the effect layer.
  47299. */
  47300. protected abstract _createTextureAndPostProcesses(): void;
  47301. /**
  47302. * Implementation specific of rendering the generating effect on the main canvas.
  47303. * @param effect The effect used to render through
  47304. */
  47305. protected abstract _internalRender(effect: Effect): void;
  47306. /**
  47307. * Sets the required values for both the emissive texture and and the main color.
  47308. */
  47309. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47310. /**
  47311. * Free any resources and references associated to a mesh.
  47312. * Internal use
  47313. * @param mesh The mesh to free.
  47314. */
  47315. abstract _disposeMesh(mesh: Mesh): void;
  47316. /**
  47317. * Serializes this layer (Glow or Highlight for example)
  47318. * @returns a serialized layer object
  47319. */
  47320. abstract serialize?(): any;
  47321. /**
  47322. * Initializes the effect layer with the required options.
  47323. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47324. */
  47325. protected _init(options: Partial<IEffectLayerOptions>): void;
  47326. /**
  47327. * Generates the index buffer of the full screen quad blending to the main canvas.
  47328. */
  47329. private _generateIndexBuffer;
  47330. /**
  47331. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47332. */
  47333. private _generateVertexBuffer;
  47334. /**
  47335. * Sets the main texture desired size which is the closest power of two
  47336. * of the engine canvas size.
  47337. */
  47338. private _setMainTextureSize;
  47339. /**
  47340. * Creates the main texture for the effect layer.
  47341. */
  47342. protected _createMainTexture(): void;
  47343. /**
  47344. * Adds specific effects defines.
  47345. * @param defines The defines to add specifics to.
  47346. */
  47347. protected _addCustomEffectDefines(defines: string[]): void;
  47348. /**
  47349. * Checks for the readiness of the element composing the layer.
  47350. * @param subMesh the mesh to check for
  47351. * @param useInstances specify wether or not to use instances to render the mesh
  47352. * @param emissiveTexture the associated emissive texture used to generate the glow
  47353. * @return true if ready otherwise, false
  47354. */
  47355. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47356. /**
  47357. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47358. */
  47359. render(): void;
  47360. /**
  47361. * Determine if a given mesh will be used in the current effect.
  47362. * @param mesh mesh to test
  47363. * @returns true if the mesh will be used
  47364. */
  47365. hasMesh(mesh: AbstractMesh): boolean;
  47366. /**
  47367. * Returns true if the layer contains information to display, otherwise false.
  47368. * @returns true if the glow layer should be rendered
  47369. */
  47370. shouldRender(): boolean;
  47371. /**
  47372. * Returns true if the mesh should render, otherwise false.
  47373. * @param mesh The mesh to render
  47374. * @returns true if it should render otherwise false
  47375. */
  47376. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47377. /**
  47378. * Returns true if the mesh can be rendered, otherwise false.
  47379. * @param mesh The mesh to render
  47380. * @param material The material used on the mesh
  47381. * @returns true if it can be rendered otherwise false
  47382. */
  47383. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47384. /**
  47385. * Returns true if the mesh should render, otherwise false.
  47386. * @param mesh The mesh to render
  47387. * @returns true if it should render otherwise false
  47388. */
  47389. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47390. /**
  47391. * Renders the submesh passed in parameter to the generation map.
  47392. */
  47393. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47394. /**
  47395. * Rebuild the required buffers.
  47396. * @hidden Internal use only.
  47397. */
  47398. _rebuild(): void;
  47399. /**
  47400. * Dispose only the render target textures and post process.
  47401. */
  47402. private _disposeTextureAndPostProcesses;
  47403. /**
  47404. * Dispose the highlight layer and free resources.
  47405. */
  47406. dispose(): void;
  47407. /**
  47408. * Gets the class name of the effect layer
  47409. * @returns the string with the class name of the effect layer
  47410. */
  47411. getClassName(): string;
  47412. /**
  47413. * Creates an effect layer from parsed effect layer data
  47414. * @param parsedEffectLayer defines effect layer data
  47415. * @param scene defines the current scene
  47416. * @param rootUrl defines the root URL containing the effect layer information
  47417. * @returns a parsed effect Layer
  47418. */
  47419. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47420. }
  47421. }
  47422. declare module BABYLON {
  47423. interface AbstractScene {
  47424. /**
  47425. * The list of effect layers (highlights/glow) added to the scene
  47426. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47427. * @see http://doc.babylonjs.com/how_to/glow_layer
  47428. */
  47429. effectLayers: Array<EffectLayer>;
  47430. /**
  47431. * Removes the given effect layer from this scene.
  47432. * @param toRemove defines the effect layer to remove
  47433. * @returns the index of the removed effect layer
  47434. */
  47435. removeEffectLayer(toRemove: EffectLayer): number;
  47436. /**
  47437. * Adds the given effect layer to this scene
  47438. * @param newEffectLayer defines the effect layer to add
  47439. */
  47440. addEffectLayer(newEffectLayer: EffectLayer): void;
  47441. }
  47442. /**
  47443. * Defines the layer scene component responsible to manage any effect layers
  47444. * in a given scene.
  47445. */
  47446. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47447. /**
  47448. * The component name helpfull to identify the component in the list of scene components.
  47449. */
  47450. readonly name: string;
  47451. /**
  47452. * The scene the component belongs to.
  47453. */
  47454. scene: Scene;
  47455. private _engine;
  47456. private _renderEffects;
  47457. private _needStencil;
  47458. private _previousStencilState;
  47459. /**
  47460. * Creates a new instance of the component for the given scene
  47461. * @param scene Defines the scene to register the component in
  47462. */
  47463. constructor(scene: Scene);
  47464. /**
  47465. * Registers the component in a given scene
  47466. */
  47467. register(): void;
  47468. /**
  47469. * Rebuilds the elements related to this component in case of
  47470. * context lost for instance.
  47471. */
  47472. rebuild(): void;
  47473. /**
  47474. * Serializes the component data to the specified json object
  47475. * @param serializationObject The object to serialize to
  47476. */
  47477. serialize(serializationObject: any): void;
  47478. /**
  47479. * Adds all the elements from the container to the scene
  47480. * @param container the container holding the elements
  47481. */
  47482. addFromContainer(container: AbstractScene): void;
  47483. /**
  47484. * Removes all the elements in the container from the scene
  47485. * @param container contains the elements to remove
  47486. * @param dispose if the removed element should be disposed (default: false)
  47487. */
  47488. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47489. /**
  47490. * Disposes the component and the associated ressources.
  47491. */
  47492. dispose(): void;
  47493. private _isReadyForMesh;
  47494. private _renderMainTexture;
  47495. private _setStencil;
  47496. private _setStencilBack;
  47497. private _draw;
  47498. private _drawCamera;
  47499. private _drawRenderingGroup;
  47500. }
  47501. }
  47502. declare module BABYLON {
  47503. /** @hidden */
  47504. export var glowMapMergePixelShader: {
  47505. name: string;
  47506. shader: string;
  47507. };
  47508. }
  47509. declare module BABYLON {
  47510. /** @hidden */
  47511. export var glowMapMergeVertexShader: {
  47512. name: string;
  47513. shader: string;
  47514. };
  47515. }
  47516. declare module BABYLON {
  47517. interface AbstractScene {
  47518. /**
  47519. * Return a the first highlight layer of the scene with a given name.
  47520. * @param name The name of the highlight layer to look for.
  47521. * @return The highlight layer if found otherwise null.
  47522. */
  47523. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47524. }
  47525. /**
  47526. * Glow layer options. This helps customizing the behaviour
  47527. * of the glow layer.
  47528. */
  47529. export interface IGlowLayerOptions {
  47530. /**
  47531. * Multiplication factor apply to the canvas size to compute the render target size
  47532. * used to generated the glowing objects (the smaller the faster).
  47533. */
  47534. mainTextureRatio: number;
  47535. /**
  47536. * Enforces a fixed size texture to ensure resize independant blur.
  47537. */
  47538. mainTextureFixedSize?: number;
  47539. /**
  47540. * How big is the kernel of the blur texture.
  47541. */
  47542. blurKernelSize: number;
  47543. /**
  47544. * The camera attached to the layer.
  47545. */
  47546. camera: Nullable<Camera>;
  47547. /**
  47548. * Enable MSAA by chosing the number of samples.
  47549. */
  47550. mainTextureSamples?: number;
  47551. /**
  47552. * The rendering group to draw the layer in.
  47553. */
  47554. renderingGroupId: number;
  47555. }
  47556. /**
  47557. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47558. *
  47559. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47560. * glowy meshes to your scene.
  47561. *
  47562. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47563. */
  47564. export class GlowLayer extends EffectLayer {
  47565. /**
  47566. * Effect Name of the layer.
  47567. */
  47568. static readonly EffectName: string;
  47569. /**
  47570. * The default blur kernel size used for the glow.
  47571. */
  47572. static DefaultBlurKernelSize: number;
  47573. /**
  47574. * The default texture size ratio used for the glow.
  47575. */
  47576. static DefaultTextureRatio: number;
  47577. /**
  47578. * Sets the kernel size of the blur.
  47579. */
  47580. /**
  47581. * Gets the kernel size of the blur.
  47582. */
  47583. blurKernelSize: number;
  47584. /**
  47585. * Sets the glow intensity.
  47586. */
  47587. /**
  47588. * Gets the glow intensity.
  47589. */
  47590. intensity: number;
  47591. private _options;
  47592. private _intensity;
  47593. private _horizontalBlurPostprocess1;
  47594. private _verticalBlurPostprocess1;
  47595. private _horizontalBlurPostprocess2;
  47596. private _verticalBlurPostprocess2;
  47597. private _blurTexture1;
  47598. private _blurTexture2;
  47599. private _postProcesses1;
  47600. private _postProcesses2;
  47601. private _includedOnlyMeshes;
  47602. private _excludedMeshes;
  47603. /**
  47604. * Callback used to let the user override the color selection on a per mesh basis
  47605. */
  47606. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47607. /**
  47608. * Callback used to let the user override the texture selection on a per mesh basis
  47609. */
  47610. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47611. /**
  47612. * Instantiates a new glow Layer and references it to the scene.
  47613. * @param name The name of the layer
  47614. * @param scene The scene to use the layer in
  47615. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47616. */
  47617. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47618. /**
  47619. * Get the effect name of the layer.
  47620. * @return The effect name
  47621. */
  47622. getEffectName(): string;
  47623. /**
  47624. * Create the merge effect. This is the shader use to blit the information back
  47625. * to the main canvas at the end of the scene rendering.
  47626. */
  47627. protected _createMergeEffect(): Effect;
  47628. /**
  47629. * Creates the render target textures and post processes used in the glow layer.
  47630. */
  47631. protected _createTextureAndPostProcesses(): void;
  47632. /**
  47633. * Checks for the readiness of the element composing the layer.
  47634. * @param subMesh the mesh to check for
  47635. * @param useInstances specify wether or not to use instances to render the mesh
  47636. * @param emissiveTexture the associated emissive texture used to generate the glow
  47637. * @return true if ready otherwise, false
  47638. */
  47639. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47640. /**
  47641. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47642. */
  47643. needStencil(): boolean;
  47644. /**
  47645. * Returns true if the mesh can be rendered, otherwise false.
  47646. * @param mesh The mesh to render
  47647. * @param material The material used on the mesh
  47648. * @returns true if it can be rendered otherwise false
  47649. */
  47650. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47651. /**
  47652. * Implementation specific of rendering the generating effect on the main canvas.
  47653. * @param effect The effect used to render through
  47654. */
  47655. protected _internalRender(effect: Effect): void;
  47656. /**
  47657. * Sets the required values for both the emissive texture and and the main color.
  47658. */
  47659. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47660. /**
  47661. * Returns true if the mesh should render, otherwise false.
  47662. * @param mesh The mesh to render
  47663. * @returns true if it should render otherwise false
  47664. */
  47665. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47666. /**
  47667. * Adds specific effects defines.
  47668. * @param defines The defines to add specifics to.
  47669. */
  47670. protected _addCustomEffectDefines(defines: string[]): void;
  47671. /**
  47672. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47673. * @param mesh The mesh to exclude from the glow layer
  47674. */
  47675. addExcludedMesh(mesh: Mesh): void;
  47676. /**
  47677. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47678. * @param mesh The mesh to remove
  47679. */
  47680. removeExcludedMesh(mesh: Mesh): void;
  47681. /**
  47682. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47683. * @param mesh The mesh to include in the glow layer
  47684. */
  47685. addIncludedOnlyMesh(mesh: Mesh): void;
  47686. /**
  47687. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47688. * @param mesh The mesh to remove
  47689. */
  47690. removeIncludedOnlyMesh(mesh: Mesh): void;
  47691. /**
  47692. * Determine if a given mesh will be used in the glow layer
  47693. * @param mesh The mesh to test
  47694. * @returns true if the mesh will be highlighted by the current glow layer
  47695. */
  47696. hasMesh(mesh: AbstractMesh): boolean;
  47697. /**
  47698. * Free any resources and references associated to a mesh.
  47699. * Internal use
  47700. * @param mesh The mesh to free.
  47701. * @hidden
  47702. */
  47703. _disposeMesh(mesh: Mesh): void;
  47704. /**
  47705. * Gets the class name of the effect layer
  47706. * @returns the string with the class name of the effect layer
  47707. */
  47708. getClassName(): string;
  47709. /**
  47710. * Serializes this glow layer
  47711. * @returns a serialized glow layer object
  47712. */
  47713. serialize(): any;
  47714. /**
  47715. * Creates a Glow Layer from parsed glow layer data
  47716. * @param parsedGlowLayer defines glow layer data
  47717. * @param scene defines the current scene
  47718. * @param rootUrl defines the root URL containing the glow layer information
  47719. * @returns a parsed Glow Layer
  47720. */
  47721. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47722. }
  47723. }
  47724. declare module BABYLON {
  47725. /** @hidden */
  47726. export var glowBlurPostProcessPixelShader: {
  47727. name: string;
  47728. shader: string;
  47729. };
  47730. }
  47731. declare module BABYLON {
  47732. interface AbstractScene {
  47733. /**
  47734. * Return a the first highlight layer of the scene with a given name.
  47735. * @param name The name of the highlight layer to look for.
  47736. * @return The highlight layer if found otherwise null.
  47737. */
  47738. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47739. }
  47740. /**
  47741. * Highlight layer options. This helps customizing the behaviour
  47742. * of the highlight layer.
  47743. */
  47744. export interface IHighlightLayerOptions {
  47745. /**
  47746. * Multiplication factor apply to the canvas size to compute the render target size
  47747. * used to generated the glowing objects (the smaller the faster).
  47748. */
  47749. mainTextureRatio: number;
  47750. /**
  47751. * Enforces a fixed size texture to ensure resize independant blur.
  47752. */
  47753. mainTextureFixedSize?: number;
  47754. /**
  47755. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47756. * of the picture to blur (the smaller the faster).
  47757. */
  47758. blurTextureSizeRatio: number;
  47759. /**
  47760. * How big in texel of the blur texture is the vertical blur.
  47761. */
  47762. blurVerticalSize: number;
  47763. /**
  47764. * How big in texel of the blur texture is the horizontal blur.
  47765. */
  47766. blurHorizontalSize: number;
  47767. /**
  47768. * Alpha blending mode used to apply the blur. Default is combine.
  47769. */
  47770. alphaBlendingMode: number;
  47771. /**
  47772. * The camera attached to the layer.
  47773. */
  47774. camera: Nullable<Camera>;
  47775. /**
  47776. * Should we display highlight as a solid stroke?
  47777. */
  47778. isStroke?: boolean;
  47779. /**
  47780. * The rendering group to draw the layer in.
  47781. */
  47782. renderingGroupId: number;
  47783. }
  47784. /**
  47785. * The highlight layer Helps adding a glow effect around a mesh.
  47786. *
  47787. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47788. * glowy meshes to your scene.
  47789. *
  47790. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47791. */
  47792. export class HighlightLayer extends EffectLayer {
  47793. name: string;
  47794. /**
  47795. * Effect Name of the highlight layer.
  47796. */
  47797. static readonly EffectName: string;
  47798. /**
  47799. * The neutral color used during the preparation of the glow effect.
  47800. * This is black by default as the blend operation is a blend operation.
  47801. */
  47802. static NeutralColor: Color4;
  47803. /**
  47804. * Stencil value used for glowing meshes.
  47805. */
  47806. static GlowingMeshStencilReference: number;
  47807. /**
  47808. * Stencil value used for the other meshes in the scene.
  47809. */
  47810. static NormalMeshStencilReference: number;
  47811. /**
  47812. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47813. */
  47814. innerGlow: boolean;
  47815. /**
  47816. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47817. */
  47818. outerGlow: boolean;
  47819. /**
  47820. * Specifies the horizontal size of the blur.
  47821. */
  47822. /**
  47823. * Gets the horizontal size of the blur.
  47824. */
  47825. blurHorizontalSize: number;
  47826. /**
  47827. * Specifies the vertical size of the blur.
  47828. */
  47829. /**
  47830. * Gets the vertical size of the blur.
  47831. */
  47832. blurVerticalSize: number;
  47833. /**
  47834. * An event triggered when the highlight layer is being blurred.
  47835. */
  47836. onBeforeBlurObservable: Observable<HighlightLayer>;
  47837. /**
  47838. * An event triggered when the highlight layer has been blurred.
  47839. */
  47840. onAfterBlurObservable: Observable<HighlightLayer>;
  47841. private _instanceGlowingMeshStencilReference;
  47842. private _options;
  47843. private _downSamplePostprocess;
  47844. private _horizontalBlurPostprocess;
  47845. private _verticalBlurPostprocess;
  47846. private _blurTexture;
  47847. private _meshes;
  47848. private _excludedMeshes;
  47849. /**
  47850. * Instantiates a new highlight Layer and references it to the scene..
  47851. * @param name The name of the layer
  47852. * @param scene The scene to use the layer in
  47853. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47854. */
  47855. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47856. /**
  47857. * Get the effect name of the layer.
  47858. * @return The effect name
  47859. */
  47860. getEffectName(): string;
  47861. /**
  47862. * Create the merge effect. This is the shader use to blit the information back
  47863. * to the main canvas at the end of the scene rendering.
  47864. */
  47865. protected _createMergeEffect(): Effect;
  47866. /**
  47867. * Creates the render target textures and post processes used in the highlight layer.
  47868. */
  47869. protected _createTextureAndPostProcesses(): void;
  47870. /**
  47871. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47872. */
  47873. needStencil(): boolean;
  47874. /**
  47875. * Checks for the readiness of the element composing the layer.
  47876. * @param subMesh the mesh to check for
  47877. * @param useInstances specify wether or not to use instances to render the mesh
  47878. * @param emissiveTexture the associated emissive texture used to generate the glow
  47879. * @return true if ready otherwise, false
  47880. */
  47881. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47882. /**
  47883. * Implementation specific of rendering the generating effect on the main canvas.
  47884. * @param effect The effect used to render through
  47885. */
  47886. protected _internalRender(effect: Effect): void;
  47887. /**
  47888. * Returns true if the layer contains information to display, otherwise false.
  47889. */
  47890. shouldRender(): boolean;
  47891. /**
  47892. * Returns true if the mesh should render, otherwise false.
  47893. * @param mesh The mesh to render
  47894. * @returns true if it should render otherwise false
  47895. */
  47896. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47897. /**
  47898. * Sets the required values for both the emissive texture and and the main color.
  47899. */
  47900. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47901. /**
  47902. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47903. * @param mesh The mesh to exclude from the highlight layer
  47904. */
  47905. addExcludedMesh(mesh: Mesh): void;
  47906. /**
  47907. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47908. * @param mesh The mesh to highlight
  47909. */
  47910. removeExcludedMesh(mesh: Mesh): void;
  47911. /**
  47912. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47913. * @param mesh mesh to test
  47914. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47915. */
  47916. hasMesh(mesh: AbstractMesh): boolean;
  47917. /**
  47918. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47919. * @param mesh The mesh to highlight
  47920. * @param color The color of the highlight
  47921. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47922. */
  47923. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47924. /**
  47925. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47926. * @param mesh The mesh to highlight
  47927. */
  47928. removeMesh(mesh: Mesh): void;
  47929. /**
  47930. * Force the stencil to the normal expected value for none glowing parts
  47931. */
  47932. private _defaultStencilReference;
  47933. /**
  47934. * Free any resources and references associated to a mesh.
  47935. * Internal use
  47936. * @param mesh The mesh to free.
  47937. * @hidden
  47938. */
  47939. _disposeMesh(mesh: Mesh): void;
  47940. /**
  47941. * Dispose the highlight layer and free resources.
  47942. */
  47943. dispose(): void;
  47944. /**
  47945. * Gets the class name of the effect layer
  47946. * @returns the string with the class name of the effect layer
  47947. */
  47948. getClassName(): string;
  47949. /**
  47950. * Serializes this Highlight layer
  47951. * @returns a serialized Highlight layer object
  47952. */
  47953. serialize(): any;
  47954. /**
  47955. * Creates a Highlight layer from parsed Highlight layer data
  47956. * @param parsedHightlightLayer defines the Highlight layer data
  47957. * @param scene defines the current scene
  47958. * @param rootUrl defines the root URL containing the Highlight layer information
  47959. * @returns a parsed Highlight layer
  47960. */
  47961. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47962. }
  47963. }
  47964. declare module BABYLON {
  47965. interface AbstractScene {
  47966. /**
  47967. * The list of layers (background and foreground) of the scene
  47968. */
  47969. layers: Array<Layer>;
  47970. }
  47971. /**
  47972. * Defines the layer scene component responsible to manage any layers
  47973. * in a given scene.
  47974. */
  47975. export class LayerSceneComponent implements ISceneComponent {
  47976. /**
  47977. * The component name helpfull to identify the component in the list of scene components.
  47978. */
  47979. readonly name: string;
  47980. /**
  47981. * The scene the component belongs to.
  47982. */
  47983. scene: Scene;
  47984. private _engine;
  47985. /**
  47986. * Creates a new instance of the component for the given scene
  47987. * @param scene Defines the scene to register the component in
  47988. */
  47989. constructor(scene: Scene);
  47990. /**
  47991. * Registers the component in a given scene
  47992. */
  47993. register(): void;
  47994. /**
  47995. * Rebuilds the elements related to this component in case of
  47996. * context lost for instance.
  47997. */
  47998. rebuild(): void;
  47999. /**
  48000. * Disposes the component and the associated ressources.
  48001. */
  48002. dispose(): void;
  48003. private _draw;
  48004. private _drawCameraPredicate;
  48005. private _drawCameraBackground;
  48006. private _drawCameraForeground;
  48007. private _drawRenderTargetPredicate;
  48008. private _drawRenderTargetBackground;
  48009. private _drawRenderTargetForeground;
  48010. /**
  48011. * Adds all the elements from the container to the scene
  48012. * @param container the container holding the elements
  48013. */
  48014. addFromContainer(container: AbstractScene): void;
  48015. /**
  48016. * Removes all the elements in the container from the scene
  48017. * @param container contains the elements to remove
  48018. * @param dispose if the removed element should be disposed (default: false)
  48019. */
  48020. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48021. }
  48022. }
  48023. declare module BABYLON {
  48024. /** @hidden */
  48025. export var layerPixelShader: {
  48026. name: string;
  48027. shader: string;
  48028. };
  48029. }
  48030. declare module BABYLON {
  48031. /** @hidden */
  48032. export var layerVertexShader: {
  48033. name: string;
  48034. shader: string;
  48035. };
  48036. }
  48037. declare module BABYLON {
  48038. /**
  48039. * This represents a full screen 2d layer.
  48040. * This can be useful to display a picture in the background of your scene for instance.
  48041. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48042. */
  48043. export class Layer {
  48044. /**
  48045. * Define the name of the layer.
  48046. */
  48047. name: string;
  48048. /**
  48049. * Define the texture the layer should display.
  48050. */
  48051. texture: Nullable<Texture>;
  48052. /**
  48053. * Is the layer in background or foreground.
  48054. */
  48055. isBackground: boolean;
  48056. /**
  48057. * Define the color of the layer (instead of texture).
  48058. */
  48059. color: Color4;
  48060. /**
  48061. * Define the scale of the layer in order to zoom in out of the texture.
  48062. */
  48063. scale: Vector2;
  48064. /**
  48065. * Define an offset for the layer in order to shift the texture.
  48066. */
  48067. offset: Vector2;
  48068. /**
  48069. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48070. */
  48071. alphaBlendingMode: number;
  48072. /**
  48073. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48074. * Alpha test will not mix with the background color in case of transparency.
  48075. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48076. */
  48077. alphaTest: boolean;
  48078. /**
  48079. * Define a mask to restrict the layer to only some of the scene cameras.
  48080. */
  48081. layerMask: number;
  48082. /**
  48083. * Define the list of render target the layer is visible into.
  48084. */
  48085. renderTargetTextures: RenderTargetTexture[];
  48086. /**
  48087. * Define if the layer is only used in renderTarget or if it also
  48088. * renders in the main frame buffer of the canvas.
  48089. */
  48090. renderOnlyInRenderTargetTextures: boolean;
  48091. private _scene;
  48092. private _vertexBuffers;
  48093. private _indexBuffer;
  48094. private _effect;
  48095. private _alphaTestEffect;
  48096. /**
  48097. * An event triggered when the layer is disposed.
  48098. */
  48099. onDisposeObservable: Observable<Layer>;
  48100. private _onDisposeObserver;
  48101. /**
  48102. * Back compatibility with callback before the onDisposeObservable existed.
  48103. * The set callback will be triggered when the layer has been disposed.
  48104. */
  48105. onDispose: () => void;
  48106. /**
  48107. * An event triggered before rendering the scene
  48108. */
  48109. onBeforeRenderObservable: Observable<Layer>;
  48110. private _onBeforeRenderObserver;
  48111. /**
  48112. * Back compatibility with callback before the onBeforeRenderObservable existed.
  48113. * The set callback will be triggered just before rendering the layer.
  48114. */
  48115. onBeforeRender: () => void;
  48116. /**
  48117. * An event triggered after rendering the scene
  48118. */
  48119. onAfterRenderObservable: Observable<Layer>;
  48120. private _onAfterRenderObserver;
  48121. /**
  48122. * Back compatibility with callback before the onAfterRenderObservable existed.
  48123. * The set callback will be triggered just after rendering the layer.
  48124. */
  48125. onAfterRender: () => void;
  48126. /**
  48127. * Instantiates a new layer.
  48128. * This represents a full screen 2d layer.
  48129. * This can be useful to display a picture in the background of your scene for instance.
  48130. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48131. * @param name Define the name of the layer in the scene
  48132. * @param imgUrl Define the url of the texture to display in the layer
  48133. * @param scene Define the scene the layer belongs to
  48134. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  48135. * @param color Defines a color for the layer
  48136. */
  48137. constructor(
  48138. /**
  48139. * Define the name of the layer.
  48140. */
  48141. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  48142. private _createIndexBuffer;
  48143. /** @hidden */
  48144. _rebuild(): void;
  48145. /**
  48146. * Renders the layer in the scene.
  48147. */
  48148. render(): void;
  48149. /**
  48150. * Disposes and releases the associated ressources.
  48151. */
  48152. dispose(): void;
  48153. }
  48154. }
  48155. declare module BABYLON {
  48156. /** @hidden */
  48157. export var lensFlarePixelShader: {
  48158. name: string;
  48159. shader: string;
  48160. };
  48161. }
  48162. declare module BABYLON {
  48163. /** @hidden */
  48164. export var lensFlareVertexShader: {
  48165. name: string;
  48166. shader: string;
  48167. };
  48168. }
  48169. declare module BABYLON {
  48170. /**
  48171. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48172. * It is usually composed of several `lensFlare`.
  48173. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48174. */
  48175. export class LensFlareSystem {
  48176. /**
  48177. * Define the name of the lens flare system
  48178. */
  48179. name: string;
  48180. /**
  48181. * List of lens flares used in this system.
  48182. */
  48183. lensFlares: LensFlare[];
  48184. /**
  48185. * Define a limit from the border the lens flare can be visible.
  48186. */
  48187. borderLimit: number;
  48188. /**
  48189. * Define a viewport border we do not want to see the lens flare in.
  48190. */
  48191. viewportBorder: number;
  48192. /**
  48193. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48194. */
  48195. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48196. /**
  48197. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48198. */
  48199. layerMask: number;
  48200. /**
  48201. * Define the id of the lens flare system in the scene.
  48202. * (equal to name by default)
  48203. */
  48204. id: string;
  48205. private _scene;
  48206. private _emitter;
  48207. private _vertexBuffers;
  48208. private _indexBuffer;
  48209. private _effect;
  48210. private _positionX;
  48211. private _positionY;
  48212. private _isEnabled;
  48213. /** @hidden */
  48214. static _SceneComponentInitialization: (scene: Scene) => void;
  48215. /**
  48216. * Instantiates a lens flare system.
  48217. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48218. * It is usually composed of several `lensFlare`.
  48219. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48220. * @param name Define the name of the lens flare system in the scene
  48221. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48222. * @param scene Define the scene the lens flare system belongs to
  48223. */
  48224. constructor(
  48225. /**
  48226. * Define the name of the lens flare system
  48227. */
  48228. name: string, emitter: any, scene: Scene);
  48229. /**
  48230. * Define if the lens flare system is enabled.
  48231. */
  48232. isEnabled: boolean;
  48233. /**
  48234. * Get the scene the effects belongs to.
  48235. * @returns the scene holding the lens flare system
  48236. */
  48237. getScene(): Scene;
  48238. /**
  48239. * Get the emitter of the lens flare system.
  48240. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48241. * @returns the emitter of the lens flare system
  48242. */
  48243. getEmitter(): any;
  48244. /**
  48245. * Set the emitter of the lens flare system.
  48246. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48247. * @param newEmitter Define the new emitter of the system
  48248. */
  48249. setEmitter(newEmitter: any): void;
  48250. /**
  48251. * Get the lens flare system emitter position.
  48252. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48253. * @returns the position
  48254. */
  48255. getEmitterPosition(): Vector3;
  48256. /**
  48257. * @hidden
  48258. */
  48259. computeEffectivePosition(globalViewport: Viewport): boolean;
  48260. /** @hidden */
  48261. _isVisible(): boolean;
  48262. /**
  48263. * @hidden
  48264. */
  48265. render(): boolean;
  48266. /**
  48267. * Dispose and release the lens flare with its associated resources.
  48268. */
  48269. dispose(): void;
  48270. /**
  48271. * Parse a lens flare system from a JSON repressentation
  48272. * @param parsedLensFlareSystem Define the JSON to parse
  48273. * @param scene Define the scene the parsed system should be instantiated in
  48274. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48275. * @returns the parsed system
  48276. */
  48277. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48278. /**
  48279. * Serialize the current Lens Flare System into a JSON representation.
  48280. * @returns the serialized JSON
  48281. */
  48282. serialize(): any;
  48283. }
  48284. }
  48285. declare module BABYLON {
  48286. /**
  48287. * This represents one of the lens effect in a `lensFlareSystem`.
  48288. * It controls one of the indiviual texture used in the effect.
  48289. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48290. */
  48291. export class LensFlare {
  48292. /**
  48293. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48294. */
  48295. size: number;
  48296. /**
  48297. * 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.
  48298. */
  48299. position: number;
  48300. /**
  48301. * Define the lens color.
  48302. */
  48303. color: Color3;
  48304. /**
  48305. * Define the lens texture.
  48306. */
  48307. texture: Nullable<Texture>;
  48308. /**
  48309. * Define the alpha mode to render this particular lens.
  48310. */
  48311. alphaMode: number;
  48312. private _system;
  48313. /**
  48314. * Creates a new Lens Flare.
  48315. * This represents one of the lens effect in a `lensFlareSystem`.
  48316. * It controls one of the indiviual texture used in the effect.
  48317. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48318. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48319. * @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.
  48320. * @param color Define the lens color
  48321. * @param imgUrl Define the lens texture url
  48322. * @param system Define the `lensFlareSystem` this flare is part of
  48323. * @returns The newly created Lens Flare
  48324. */
  48325. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48326. /**
  48327. * Instantiates a new Lens Flare.
  48328. * This represents one of the lens effect in a `lensFlareSystem`.
  48329. * It controls one of the indiviual texture used in the effect.
  48330. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48331. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48332. * @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.
  48333. * @param color Define the lens color
  48334. * @param imgUrl Define the lens texture url
  48335. * @param system Define the `lensFlareSystem` this flare is part of
  48336. */
  48337. constructor(
  48338. /**
  48339. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48340. */
  48341. size: number,
  48342. /**
  48343. * 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.
  48344. */
  48345. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48346. /**
  48347. * Dispose and release the lens flare with its associated resources.
  48348. */
  48349. dispose(): void;
  48350. }
  48351. }
  48352. declare module BABYLON {
  48353. interface AbstractScene {
  48354. /**
  48355. * The list of lens flare system added to the scene
  48356. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48357. */
  48358. lensFlareSystems: Array<LensFlareSystem>;
  48359. /**
  48360. * Removes the given lens flare system from this scene.
  48361. * @param toRemove The lens flare system to remove
  48362. * @returns The index of the removed lens flare system
  48363. */
  48364. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48365. /**
  48366. * Adds the given lens flare system to this scene
  48367. * @param newLensFlareSystem The lens flare system to add
  48368. */
  48369. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48370. /**
  48371. * Gets a lens flare system using its name
  48372. * @param name defines the name to look for
  48373. * @returns the lens flare system or null if not found
  48374. */
  48375. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48376. /**
  48377. * Gets a lens flare system using its id
  48378. * @param id defines the id to look for
  48379. * @returns the lens flare system or null if not found
  48380. */
  48381. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48382. }
  48383. /**
  48384. * Defines the lens flare scene component responsible to manage any lens flares
  48385. * in a given scene.
  48386. */
  48387. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48388. /**
  48389. * The component name helpfull to identify the component in the list of scene components.
  48390. */
  48391. readonly name: string;
  48392. /**
  48393. * The scene the component belongs to.
  48394. */
  48395. scene: Scene;
  48396. /**
  48397. * Creates a new instance of the component for the given scene
  48398. * @param scene Defines the scene to register the component in
  48399. */
  48400. constructor(scene: Scene);
  48401. /**
  48402. * Registers the component in a given scene
  48403. */
  48404. register(): void;
  48405. /**
  48406. * Rebuilds the elements related to this component in case of
  48407. * context lost for instance.
  48408. */
  48409. rebuild(): void;
  48410. /**
  48411. * Adds all the elements from the container to the scene
  48412. * @param container the container holding the elements
  48413. */
  48414. addFromContainer(container: AbstractScene): void;
  48415. /**
  48416. * Removes all the elements in the container from the scene
  48417. * @param container contains the elements to remove
  48418. * @param dispose if the removed element should be disposed (default: false)
  48419. */
  48420. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48421. /**
  48422. * Serializes the component data to the specified json object
  48423. * @param serializationObject The object to serialize to
  48424. */
  48425. serialize(serializationObject: any): void;
  48426. /**
  48427. * Disposes the component and the associated ressources.
  48428. */
  48429. dispose(): void;
  48430. private _draw;
  48431. }
  48432. }
  48433. declare module BABYLON {
  48434. /**
  48435. * Defines the shadow generator component responsible to manage any shadow generators
  48436. * in a given scene.
  48437. */
  48438. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48439. /**
  48440. * The component name helpfull to identify the component in the list of scene components.
  48441. */
  48442. readonly name: string;
  48443. /**
  48444. * The scene the component belongs to.
  48445. */
  48446. scene: Scene;
  48447. /**
  48448. * Creates a new instance of the component for the given scene
  48449. * @param scene Defines the scene to register the component in
  48450. */
  48451. constructor(scene: Scene);
  48452. /**
  48453. * Registers the component in a given scene
  48454. */
  48455. register(): void;
  48456. /**
  48457. * Rebuilds the elements related to this component in case of
  48458. * context lost for instance.
  48459. */
  48460. rebuild(): void;
  48461. /**
  48462. * Serializes the component data to the specified json object
  48463. * @param serializationObject The object to serialize to
  48464. */
  48465. serialize(serializationObject: any): void;
  48466. /**
  48467. * Adds all the elements from the container to the scene
  48468. * @param container the container holding the elements
  48469. */
  48470. addFromContainer(container: AbstractScene): void;
  48471. /**
  48472. * Removes all the elements in the container from the scene
  48473. * @param container contains the elements to remove
  48474. * @param dispose if the removed element should be disposed (default: false)
  48475. */
  48476. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48477. /**
  48478. * Rebuilds the elements related to this component in case of
  48479. * context lost for instance.
  48480. */
  48481. dispose(): void;
  48482. private _gatherRenderTargets;
  48483. }
  48484. }
  48485. declare module BABYLON {
  48486. /**
  48487. * A point light is a light defined by an unique point in world space.
  48488. * The light is emitted in every direction from this point.
  48489. * A good example of a point light is a standard light bulb.
  48490. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48491. */
  48492. export class PointLight extends ShadowLight {
  48493. private _shadowAngle;
  48494. /**
  48495. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48496. * This specifies what angle the shadow will use to be created.
  48497. *
  48498. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48499. */
  48500. /**
  48501. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48502. * This specifies what angle the shadow will use to be created.
  48503. *
  48504. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48505. */
  48506. shadowAngle: number;
  48507. /**
  48508. * Gets the direction if it has been set.
  48509. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48510. */
  48511. /**
  48512. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48513. */
  48514. direction: Vector3;
  48515. /**
  48516. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48517. * A PointLight emits the light in every direction.
  48518. * It can cast shadows.
  48519. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48520. * ```javascript
  48521. * var pointLight = new PointLight("pl", camera.position, scene);
  48522. * ```
  48523. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48524. * @param name The light friendly name
  48525. * @param position The position of the point light in the scene
  48526. * @param scene The scene the lights belongs to
  48527. */
  48528. constructor(name: string, position: Vector3, scene: Scene);
  48529. /**
  48530. * Returns the string "PointLight"
  48531. * @returns the class name
  48532. */
  48533. getClassName(): string;
  48534. /**
  48535. * Returns the integer 0.
  48536. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48537. */
  48538. getTypeID(): number;
  48539. /**
  48540. * Specifies wether or not the shadowmap should be a cube texture.
  48541. * @returns true if the shadowmap needs to be a cube texture.
  48542. */
  48543. needCube(): boolean;
  48544. /**
  48545. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48546. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48547. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48548. */
  48549. getShadowDirection(faceIndex?: number): Vector3;
  48550. /**
  48551. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48552. * - fov = PI / 2
  48553. * - aspect ratio : 1.0
  48554. * - z-near and far equal to the active camera minZ and maxZ.
  48555. * Returns the PointLight.
  48556. */
  48557. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48558. protected _buildUniformLayout(): void;
  48559. /**
  48560. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48561. * @param effect The effect to update
  48562. * @param lightIndex The index of the light in the effect to update
  48563. * @returns The point light
  48564. */
  48565. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48566. /**
  48567. * Prepares the list of defines specific to the light type.
  48568. * @param defines the list of defines
  48569. * @param lightIndex defines the index of the light for the effect
  48570. */
  48571. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48572. }
  48573. }
  48574. declare module BABYLON {
  48575. /**
  48576. * Header information of HDR texture files.
  48577. */
  48578. export interface HDRInfo {
  48579. /**
  48580. * The height of the texture in pixels.
  48581. */
  48582. height: number;
  48583. /**
  48584. * The width of the texture in pixels.
  48585. */
  48586. width: number;
  48587. /**
  48588. * The index of the beginning of the data in the binary file.
  48589. */
  48590. dataPosition: number;
  48591. }
  48592. /**
  48593. * This groups tools to convert HDR texture to native colors array.
  48594. */
  48595. export class HDRTools {
  48596. private static Ldexp;
  48597. private static Rgbe2float;
  48598. private static readStringLine;
  48599. /**
  48600. * Reads header information from an RGBE texture stored in a native array.
  48601. * More information on this format are available here:
  48602. * https://en.wikipedia.org/wiki/RGBE_image_format
  48603. *
  48604. * @param uint8array The binary file stored in native array.
  48605. * @return The header information.
  48606. */
  48607. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48608. /**
  48609. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48610. * This RGBE texture needs to store the information as a panorama.
  48611. *
  48612. * More information on this format are available here:
  48613. * https://en.wikipedia.org/wiki/RGBE_image_format
  48614. *
  48615. * @param buffer The binary file stored in an array buffer.
  48616. * @param size The expected size of the extracted cubemap.
  48617. * @return The Cube Map information.
  48618. */
  48619. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48620. /**
  48621. * Returns the pixels data extracted from an RGBE texture.
  48622. * This pixels will be stored left to right up to down in the R G B order in one array.
  48623. *
  48624. * More information on this format are available here:
  48625. * https://en.wikipedia.org/wiki/RGBE_image_format
  48626. *
  48627. * @param uint8array The binary file stored in an array buffer.
  48628. * @param hdrInfo The header information of the file.
  48629. * @return The pixels data in RGB right to left up to down order.
  48630. */
  48631. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48632. private static RGBE_ReadPixels_RLE;
  48633. }
  48634. }
  48635. declare module BABYLON {
  48636. /**
  48637. * This represents a texture coming from an HDR input.
  48638. *
  48639. * The only supported format is currently panorama picture stored in RGBE format.
  48640. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48641. */
  48642. export class HDRCubeTexture extends BaseTexture {
  48643. private static _facesMapping;
  48644. private _generateHarmonics;
  48645. private _noMipmap;
  48646. private _textureMatrix;
  48647. private _size;
  48648. private _onLoad;
  48649. private _onError;
  48650. /**
  48651. * The texture URL.
  48652. */
  48653. url: string;
  48654. /**
  48655. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48656. */
  48657. coordinatesMode: number;
  48658. protected _isBlocking: boolean;
  48659. /**
  48660. * Sets wether or not the texture is blocking during loading.
  48661. */
  48662. /**
  48663. * Gets wether or not the texture is blocking during loading.
  48664. */
  48665. isBlocking: boolean;
  48666. protected _rotationY: number;
  48667. /**
  48668. * Sets texture matrix rotation angle around Y axis in radians.
  48669. */
  48670. /**
  48671. * Gets texture matrix rotation angle around Y axis radians.
  48672. */
  48673. rotationY: number;
  48674. /**
  48675. * Gets or sets the center of the bounding box associated with the cube texture
  48676. * It must define where the camera used to render the texture was set
  48677. */
  48678. boundingBoxPosition: Vector3;
  48679. private _boundingBoxSize;
  48680. /**
  48681. * Gets or sets the size of the bounding box associated with the cube texture
  48682. * When defined, the cubemap will switch to local mode
  48683. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48684. * @example https://www.babylonjs-playground.com/#RNASML
  48685. */
  48686. boundingBoxSize: Vector3;
  48687. /**
  48688. * Instantiates an HDRTexture from the following parameters.
  48689. *
  48690. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48691. * @param scene The scene the texture will be used in
  48692. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48693. * @param noMipmap Forces to not generate the mipmap if true
  48694. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48695. * @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)
  48696. * @param reserved Reserved flag for internal use.
  48697. */
  48698. 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>);
  48699. /**
  48700. * Get the current class name of the texture useful for serialization or dynamic coding.
  48701. * @returns "HDRCubeTexture"
  48702. */
  48703. getClassName(): string;
  48704. /**
  48705. * Occurs when the file is raw .hdr file.
  48706. */
  48707. private loadTexture;
  48708. clone(): HDRCubeTexture;
  48709. delayLoad(): void;
  48710. /**
  48711. * Get the texture reflection matrix used to rotate/transform the reflection.
  48712. * @returns the reflection matrix
  48713. */
  48714. getReflectionTextureMatrix(): Matrix;
  48715. /**
  48716. * Set the texture reflection matrix used to rotate/transform the reflection.
  48717. * @param value Define the reflection matrix to set
  48718. */
  48719. setReflectionTextureMatrix(value: Matrix): void;
  48720. /**
  48721. * Parses a JSON representation of an HDR Texture in order to create the texture
  48722. * @param parsedTexture Define the JSON representation
  48723. * @param scene Define the scene the texture should be created in
  48724. * @param rootUrl Define the root url in case we need to load relative dependencies
  48725. * @returns the newly created texture after parsing
  48726. */
  48727. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48728. serialize(): any;
  48729. }
  48730. }
  48731. declare module BABYLON {
  48732. /**
  48733. * Class used to control physics engine
  48734. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48735. */
  48736. export class PhysicsEngine implements IPhysicsEngine {
  48737. private _physicsPlugin;
  48738. /**
  48739. * Global value used to control the smallest number supported by the simulation
  48740. */
  48741. static Epsilon: number;
  48742. private _impostors;
  48743. private _joints;
  48744. /**
  48745. * Gets the gravity vector used by the simulation
  48746. */
  48747. gravity: Vector3;
  48748. /**
  48749. * Factory used to create the default physics plugin.
  48750. * @returns The default physics plugin
  48751. */
  48752. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48753. /**
  48754. * Creates a new Physics Engine
  48755. * @param gravity defines the gravity vector used by the simulation
  48756. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48757. */
  48758. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48759. /**
  48760. * Sets the gravity vector used by the simulation
  48761. * @param gravity defines the gravity vector to use
  48762. */
  48763. setGravity(gravity: Vector3): void;
  48764. /**
  48765. * Set the time step of the physics engine.
  48766. * Default is 1/60.
  48767. * To slow it down, enter 1/600 for example.
  48768. * To speed it up, 1/30
  48769. * @param newTimeStep defines the new timestep to apply to this world.
  48770. */
  48771. setTimeStep(newTimeStep?: number): void;
  48772. /**
  48773. * Get the time step of the physics engine.
  48774. * @returns the current time step
  48775. */
  48776. getTimeStep(): number;
  48777. /**
  48778. * Release all resources
  48779. */
  48780. dispose(): void;
  48781. /**
  48782. * Gets the name of the current physics plugin
  48783. * @returns the name of the plugin
  48784. */
  48785. getPhysicsPluginName(): string;
  48786. /**
  48787. * Adding a new impostor for the impostor tracking.
  48788. * This will be done by the impostor itself.
  48789. * @param impostor the impostor to add
  48790. */
  48791. addImpostor(impostor: PhysicsImpostor): void;
  48792. /**
  48793. * Remove an impostor from the engine.
  48794. * This impostor and its mesh will not longer be updated by the physics engine.
  48795. * @param impostor the impostor to remove
  48796. */
  48797. removeImpostor(impostor: PhysicsImpostor): void;
  48798. /**
  48799. * Add a joint to the physics engine
  48800. * @param mainImpostor defines the main impostor to which the joint is added.
  48801. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48802. * @param joint defines the joint that will connect both impostors.
  48803. */
  48804. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48805. /**
  48806. * Removes a joint from the simulation
  48807. * @param mainImpostor defines the impostor used with the joint
  48808. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48809. * @param joint defines the joint to remove
  48810. */
  48811. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48812. /**
  48813. * Called by the scene. No need to call it.
  48814. * @param delta defines the timespam between frames
  48815. */
  48816. _step(delta: number): void;
  48817. /**
  48818. * Gets the current plugin used to run the simulation
  48819. * @returns current plugin
  48820. */
  48821. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48822. /**
  48823. * Gets the list of physic impostors
  48824. * @returns an array of PhysicsImpostor
  48825. */
  48826. getImpostors(): Array<PhysicsImpostor>;
  48827. /**
  48828. * Gets the impostor for a physics enabled object
  48829. * @param object defines the object impersonated by the impostor
  48830. * @returns the PhysicsImpostor or null if not found
  48831. */
  48832. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48833. /**
  48834. * Gets the impostor for a physics body object
  48835. * @param body defines physics body used by the impostor
  48836. * @returns the PhysicsImpostor or null if not found
  48837. */
  48838. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48839. /**
  48840. * Does a raycast in the physics world
  48841. * @param from when should the ray start?
  48842. * @param to when should the ray end?
  48843. * @returns PhysicsRaycastResult
  48844. */
  48845. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48846. }
  48847. }
  48848. declare module BABYLON {
  48849. /** @hidden */
  48850. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48851. private _useDeltaForWorldStep;
  48852. world: any;
  48853. name: string;
  48854. private _physicsMaterials;
  48855. private _fixedTimeStep;
  48856. private _cannonRaycastResult;
  48857. private _raycastResult;
  48858. private _removeAfterStep;
  48859. BJSCANNON: any;
  48860. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48861. setGravity(gravity: Vector3): void;
  48862. setTimeStep(timeStep: number): void;
  48863. getTimeStep(): number;
  48864. executeStep(delta: number): void;
  48865. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48866. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48867. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48868. private _processChildMeshes;
  48869. removePhysicsBody(impostor: PhysicsImpostor): void;
  48870. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48871. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48872. private _addMaterial;
  48873. private _checkWithEpsilon;
  48874. private _createShape;
  48875. private _createHeightmap;
  48876. private _minus90X;
  48877. private _plus90X;
  48878. private _tmpPosition;
  48879. private _tmpDeltaPosition;
  48880. private _tmpUnityRotation;
  48881. private _updatePhysicsBodyTransformation;
  48882. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48883. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48884. isSupported(): boolean;
  48885. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48886. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48887. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48888. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48889. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48890. getBodyMass(impostor: PhysicsImpostor): number;
  48891. getBodyFriction(impostor: PhysicsImpostor): number;
  48892. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48893. getBodyRestitution(impostor: PhysicsImpostor): number;
  48894. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48895. sleepBody(impostor: PhysicsImpostor): void;
  48896. wakeUpBody(impostor: PhysicsImpostor): void;
  48897. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48898. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48899. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48900. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48901. getRadius(impostor: PhysicsImpostor): number;
  48902. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48903. dispose(): void;
  48904. private _extendNamespace;
  48905. /**
  48906. * Does a raycast in the physics world
  48907. * @param from when should the ray start?
  48908. * @param to when should the ray end?
  48909. * @returns PhysicsRaycastResult
  48910. */
  48911. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48912. }
  48913. }
  48914. declare module BABYLON {
  48915. /** @hidden */
  48916. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48917. world: any;
  48918. name: string;
  48919. BJSOIMO: any;
  48920. private _raycastResult;
  48921. constructor(iterations?: number, oimoInjection?: any);
  48922. setGravity(gravity: Vector3): void;
  48923. setTimeStep(timeStep: number): void;
  48924. getTimeStep(): number;
  48925. private _tmpImpostorsArray;
  48926. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48927. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48928. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48929. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48930. private _tmpPositionVector;
  48931. removePhysicsBody(impostor: PhysicsImpostor): void;
  48932. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48933. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48934. isSupported(): boolean;
  48935. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48936. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48937. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48938. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48939. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48940. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48941. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48942. getBodyMass(impostor: PhysicsImpostor): number;
  48943. getBodyFriction(impostor: PhysicsImpostor): number;
  48944. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48945. getBodyRestitution(impostor: PhysicsImpostor): number;
  48946. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48947. sleepBody(impostor: PhysicsImpostor): void;
  48948. wakeUpBody(impostor: PhysicsImpostor): void;
  48949. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48950. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48951. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48952. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48953. getRadius(impostor: PhysicsImpostor): number;
  48954. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48955. dispose(): void;
  48956. /**
  48957. * Does a raycast in the physics world
  48958. * @param from when should the ray start?
  48959. * @param to when should the ray end?
  48960. * @returns PhysicsRaycastResult
  48961. */
  48962. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48963. }
  48964. }
  48965. declare module BABYLON {
  48966. /**
  48967. * Class containing static functions to help procedurally build meshes
  48968. */
  48969. export class RibbonBuilder {
  48970. /**
  48971. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48972. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48973. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48974. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48975. * * 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
  48976. * * 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
  48977. * * 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
  48978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48979. * * 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
  48980. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48981. * * 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
  48982. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48983. * * 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
  48984. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48986. * @param name defines the name of the mesh
  48987. * @param options defines the options used to create the mesh
  48988. * @param scene defines the hosting scene
  48989. * @returns the ribbon mesh
  48990. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48991. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48992. */
  48993. static CreateRibbon(name: string, options: {
  48994. pathArray: Vector3[][];
  48995. closeArray?: boolean;
  48996. closePath?: boolean;
  48997. offset?: number;
  48998. updatable?: boolean;
  48999. sideOrientation?: number;
  49000. frontUVs?: Vector4;
  49001. backUVs?: Vector4;
  49002. instance?: Mesh;
  49003. invertUV?: boolean;
  49004. uvs?: Vector2[];
  49005. colors?: Color4[];
  49006. }, scene?: Nullable<Scene>): Mesh;
  49007. }
  49008. }
  49009. declare module BABYLON {
  49010. /**
  49011. * Class containing static functions to help procedurally build meshes
  49012. */
  49013. export class ShapeBuilder {
  49014. /**
  49015. * 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.
  49016. * * 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.
  49017. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49018. * * 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.
  49019. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49020. * * 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
  49021. * * 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
  49022. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49024. * * 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
  49025. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49027. * @param name defines the name of the mesh
  49028. * @param options defines the options used to create the mesh
  49029. * @param scene defines the hosting scene
  49030. * @returns the extruded shape mesh
  49031. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49032. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49033. */
  49034. static ExtrudeShape(name: string, options: {
  49035. shape: Vector3[];
  49036. path: Vector3[];
  49037. scale?: number;
  49038. rotation?: number;
  49039. cap?: number;
  49040. updatable?: boolean;
  49041. sideOrientation?: number;
  49042. frontUVs?: Vector4;
  49043. backUVs?: Vector4;
  49044. instance?: Mesh;
  49045. invertUV?: boolean;
  49046. }, scene?: Nullable<Scene>): Mesh;
  49047. /**
  49048. * Creates an custom extruded shape mesh.
  49049. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49050. * * 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.
  49051. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49052. * * 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
  49053. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49054. * * 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
  49055. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49056. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49057. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49058. * * 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
  49059. * * 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
  49060. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49062. * * 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
  49063. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49065. * @param name defines the name of the mesh
  49066. * @param options defines the options used to create the mesh
  49067. * @param scene defines the hosting scene
  49068. * @returns the custom extruded shape mesh
  49069. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49070. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49071. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49072. */
  49073. static ExtrudeShapeCustom(name: string, options: {
  49074. shape: Vector3[];
  49075. path: Vector3[];
  49076. scaleFunction?: any;
  49077. rotationFunction?: any;
  49078. ribbonCloseArray?: boolean;
  49079. ribbonClosePath?: boolean;
  49080. cap?: number;
  49081. updatable?: boolean;
  49082. sideOrientation?: number;
  49083. frontUVs?: Vector4;
  49084. backUVs?: Vector4;
  49085. instance?: Mesh;
  49086. invertUV?: boolean;
  49087. }, scene?: Nullable<Scene>): Mesh;
  49088. private static _ExtrudeShapeGeneric;
  49089. }
  49090. }
  49091. declare module BABYLON {
  49092. /**
  49093. * AmmoJS Physics plugin
  49094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49095. * @see https://github.com/kripken/ammo.js/
  49096. */
  49097. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49098. private _useDeltaForWorldStep;
  49099. /**
  49100. * Reference to the Ammo library
  49101. */
  49102. bjsAMMO: any;
  49103. /**
  49104. * Created ammoJS world which physics bodies are added to
  49105. */
  49106. world: any;
  49107. /**
  49108. * Name of the plugin
  49109. */
  49110. name: string;
  49111. private _timeStep;
  49112. private _fixedTimeStep;
  49113. private _maxSteps;
  49114. private _tmpQuaternion;
  49115. private _tmpAmmoTransform;
  49116. private _tmpAmmoQuaternion;
  49117. private _tmpAmmoConcreteContactResultCallback;
  49118. private _collisionConfiguration;
  49119. private _dispatcher;
  49120. private _overlappingPairCache;
  49121. private _solver;
  49122. private _softBodySolver;
  49123. private _tmpAmmoVectorA;
  49124. private _tmpAmmoVectorB;
  49125. private _tmpAmmoVectorC;
  49126. private _tmpAmmoVectorD;
  49127. private _tmpContactCallbackResult;
  49128. private _tmpAmmoVectorRCA;
  49129. private _tmpAmmoVectorRCB;
  49130. private _raycastResult;
  49131. private static readonly DISABLE_COLLISION_FLAG;
  49132. private static readonly KINEMATIC_FLAG;
  49133. private static readonly DISABLE_DEACTIVATION_FLAG;
  49134. /**
  49135. * Initializes the ammoJS plugin
  49136. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49137. * @param ammoInjection can be used to inject your own ammo reference
  49138. */
  49139. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  49140. /**
  49141. * Sets the gravity of the physics world (m/(s^2))
  49142. * @param gravity Gravity to set
  49143. */
  49144. setGravity(gravity: Vector3): void;
  49145. /**
  49146. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49147. * @param timeStep timestep to use in seconds
  49148. */
  49149. setTimeStep(timeStep: number): void;
  49150. /**
  49151. * 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)
  49152. * @param fixedTimeStep fixedTimeStep to use in seconds
  49153. */
  49154. setFixedTimeStep(fixedTimeStep: number): void;
  49155. /**
  49156. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49157. * @param maxSteps the maximum number of steps by the physics engine per frame
  49158. */
  49159. setMaxSteps(maxSteps: number): void;
  49160. /**
  49161. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49162. * @returns the current timestep in seconds
  49163. */
  49164. getTimeStep(): number;
  49165. private _isImpostorInContact;
  49166. private _isImpostorPairInContact;
  49167. private _stepSimulation;
  49168. /**
  49169. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49170. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49171. * After the step the babylon meshes are set to the position of the physics imposters
  49172. * @param delta amount of time to step forward
  49173. * @param impostors array of imposters to update before/after the step
  49174. */
  49175. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49176. /**
  49177. * Update babylon mesh to match physics world object
  49178. * @param impostor imposter to match
  49179. */
  49180. private _afterSoftStep;
  49181. /**
  49182. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49183. * @param impostor imposter to match
  49184. */
  49185. private _ropeStep;
  49186. /**
  49187. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49188. * @param impostor imposter to match
  49189. */
  49190. private _softbodyOrClothStep;
  49191. private _tmpVector;
  49192. private _tmpMatrix;
  49193. /**
  49194. * Applies an impulse on the imposter
  49195. * @param impostor imposter to apply impulse to
  49196. * @param force amount of force to be applied to the imposter
  49197. * @param contactPoint the location to apply the impulse on the imposter
  49198. */
  49199. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49200. /**
  49201. * Applies a force on the imposter
  49202. * @param impostor imposter to apply force
  49203. * @param force amount of force to be applied to the imposter
  49204. * @param contactPoint the location to apply the force on the imposter
  49205. */
  49206. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49207. /**
  49208. * Creates a physics body using the plugin
  49209. * @param impostor the imposter to create the physics body on
  49210. */
  49211. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49212. /**
  49213. * Removes the physics body from the imposter and disposes of the body's memory
  49214. * @param impostor imposter to remove the physics body from
  49215. */
  49216. removePhysicsBody(impostor: PhysicsImpostor): void;
  49217. /**
  49218. * Generates a joint
  49219. * @param impostorJoint the imposter joint to create the joint with
  49220. */
  49221. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49222. /**
  49223. * Removes a joint
  49224. * @param impostorJoint the imposter joint to remove the joint from
  49225. */
  49226. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49227. private _addMeshVerts;
  49228. /**
  49229. * Initialise the soft body vertices to match its object's (mesh) vertices
  49230. * Softbody vertices (nodes) are in world space and to match this
  49231. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  49232. * @param impostor to create the softbody for
  49233. */
  49234. private _softVertexData;
  49235. /**
  49236. * Create an impostor's soft body
  49237. * @param impostor to create the softbody for
  49238. */
  49239. private _createSoftbody;
  49240. /**
  49241. * Create cloth for an impostor
  49242. * @param impostor to create the softbody for
  49243. */
  49244. private _createCloth;
  49245. /**
  49246. * Create rope for an impostor
  49247. * @param impostor to create the softbody for
  49248. */
  49249. private _createRope;
  49250. private _addHullVerts;
  49251. private _createShape;
  49252. /**
  49253. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49254. * @param impostor imposter containing the physics body and babylon object
  49255. */
  49256. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49257. /**
  49258. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49259. * @param impostor imposter containing the physics body and babylon object
  49260. * @param newPosition new position
  49261. * @param newRotation new rotation
  49262. */
  49263. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49264. /**
  49265. * If this plugin is supported
  49266. * @returns true if its supported
  49267. */
  49268. isSupported(): boolean;
  49269. /**
  49270. * Sets the linear velocity of the physics body
  49271. * @param impostor imposter to set the velocity on
  49272. * @param velocity velocity to set
  49273. */
  49274. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49275. /**
  49276. * Sets the angular velocity of the physics body
  49277. * @param impostor imposter to set the velocity on
  49278. * @param velocity velocity to set
  49279. */
  49280. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49281. /**
  49282. * gets the linear velocity
  49283. * @param impostor imposter to get linear velocity from
  49284. * @returns linear velocity
  49285. */
  49286. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49287. /**
  49288. * gets the angular velocity
  49289. * @param impostor imposter to get angular velocity from
  49290. * @returns angular velocity
  49291. */
  49292. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49293. /**
  49294. * Sets the mass of physics body
  49295. * @param impostor imposter to set the mass on
  49296. * @param mass mass to set
  49297. */
  49298. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49299. /**
  49300. * Gets the mass of the physics body
  49301. * @param impostor imposter to get the mass from
  49302. * @returns mass
  49303. */
  49304. getBodyMass(impostor: PhysicsImpostor): number;
  49305. /**
  49306. * Gets friction of the impostor
  49307. * @param impostor impostor to get friction from
  49308. * @returns friction value
  49309. */
  49310. getBodyFriction(impostor: PhysicsImpostor): number;
  49311. /**
  49312. * Sets friction of the impostor
  49313. * @param impostor impostor to set friction on
  49314. * @param friction friction value
  49315. */
  49316. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49317. /**
  49318. * Gets restitution of the impostor
  49319. * @param impostor impostor to get restitution from
  49320. * @returns restitution value
  49321. */
  49322. getBodyRestitution(impostor: PhysicsImpostor): number;
  49323. /**
  49324. * Sets resitution of the impostor
  49325. * @param impostor impostor to set resitution on
  49326. * @param restitution resitution value
  49327. */
  49328. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49329. /**
  49330. * Gets pressure inside the impostor
  49331. * @param impostor impostor to get pressure from
  49332. * @returns pressure value
  49333. */
  49334. getBodyPressure(impostor: PhysicsImpostor): number;
  49335. /**
  49336. * Sets pressure inside a soft body impostor
  49337. * Cloth and rope must remain 0 pressure
  49338. * @param impostor impostor to set pressure on
  49339. * @param pressure pressure value
  49340. */
  49341. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  49342. /**
  49343. * Gets stiffness of the impostor
  49344. * @param impostor impostor to get stiffness from
  49345. * @returns pressure value
  49346. */
  49347. getBodyStiffness(impostor: PhysicsImpostor): number;
  49348. /**
  49349. * Sets stiffness of the impostor
  49350. * @param impostor impostor to set stiffness on
  49351. * @param stiffness stiffness value from 0 to 1
  49352. */
  49353. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  49354. /**
  49355. * Gets velocityIterations of the impostor
  49356. * @param impostor impostor to get velocity iterations from
  49357. * @returns velocityIterations value
  49358. */
  49359. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  49360. /**
  49361. * Sets velocityIterations of the impostor
  49362. * @param impostor impostor to set velocity iterations on
  49363. * @param velocityIterations velocityIterations value
  49364. */
  49365. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  49366. /**
  49367. * Gets positionIterations of the impostor
  49368. * @param impostor impostor to get position iterations from
  49369. * @returns positionIterations value
  49370. */
  49371. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  49372. /**
  49373. * Sets positionIterations of the impostor
  49374. * @param impostor impostor to set position on
  49375. * @param positionIterations positionIterations value
  49376. */
  49377. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  49378. /**
  49379. * Append an anchor to a cloth object
  49380. * @param impostor is the cloth impostor to add anchor to
  49381. * @param otherImpostor is the rigid impostor to anchor to
  49382. * @param width ratio across width from 0 to 1
  49383. * @param height ratio up height from 0 to 1
  49384. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  49385. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49386. */
  49387. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49388. /**
  49389. * Append an hook to a rope object
  49390. * @param impostor is the rope impostor to add hook to
  49391. * @param otherImpostor is the rigid impostor to hook to
  49392. * @param length ratio along the rope from 0 to 1
  49393. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  49394. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49395. */
  49396. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49397. /**
  49398. * Sleeps the physics body and stops it from being active
  49399. * @param impostor impostor to sleep
  49400. */
  49401. sleepBody(impostor: PhysicsImpostor): void;
  49402. /**
  49403. * Activates the physics body
  49404. * @param impostor impostor to activate
  49405. */
  49406. wakeUpBody(impostor: PhysicsImpostor): void;
  49407. /**
  49408. * Updates the distance parameters of the joint
  49409. * @param joint joint to update
  49410. * @param maxDistance maximum distance of the joint
  49411. * @param minDistance minimum distance of the joint
  49412. */
  49413. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49414. /**
  49415. * Sets a motor on the joint
  49416. * @param joint joint to set motor on
  49417. * @param speed speed of the motor
  49418. * @param maxForce maximum force of the motor
  49419. * @param motorIndex index of the motor
  49420. */
  49421. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49422. /**
  49423. * Sets the motors limit
  49424. * @param joint joint to set limit on
  49425. * @param upperLimit upper limit
  49426. * @param lowerLimit lower limit
  49427. */
  49428. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49429. /**
  49430. * Syncs the position and rotation of a mesh with the impostor
  49431. * @param mesh mesh to sync
  49432. * @param impostor impostor to update the mesh with
  49433. */
  49434. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49435. /**
  49436. * Gets the radius of the impostor
  49437. * @param impostor impostor to get radius from
  49438. * @returns the radius
  49439. */
  49440. getRadius(impostor: PhysicsImpostor): number;
  49441. /**
  49442. * Gets the box size of the impostor
  49443. * @param impostor impostor to get box size from
  49444. * @param result the resulting box size
  49445. */
  49446. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49447. /**
  49448. * Disposes of the impostor
  49449. */
  49450. dispose(): void;
  49451. /**
  49452. * Does a raycast in the physics world
  49453. * @param from when should the ray start?
  49454. * @param to when should the ray end?
  49455. * @returns PhysicsRaycastResult
  49456. */
  49457. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49458. }
  49459. }
  49460. declare module BABYLON {
  49461. interface AbstractScene {
  49462. /**
  49463. * The list of reflection probes added to the scene
  49464. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49465. */
  49466. reflectionProbes: Array<ReflectionProbe>;
  49467. /**
  49468. * Removes the given reflection probe from this scene.
  49469. * @param toRemove The reflection probe to remove
  49470. * @returns The index of the removed reflection probe
  49471. */
  49472. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49473. /**
  49474. * Adds the given reflection probe to this scene.
  49475. * @param newReflectionProbe The reflection probe to add
  49476. */
  49477. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49478. }
  49479. /**
  49480. * Class used to generate realtime reflection / refraction cube textures
  49481. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49482. */
  49483. export class ReflectionProbe {
  49484. /** defines the name of the probe */
  49485. name: string;
  49486. private _scene;
  49487. private _renderTargetTexture;
  49488. private _projectionMatrix;
  49489. private _viewMatrix;
  49490. private _target;
  49491. private _add;
  49492. private _attachedMesh;
  49493. private _invertYAxis;
  49494. /** Gets or sets probe position (center of the cube map) */
  49495. position: Vector3;
  49496. /**
  49497. * Creates a new reflection probe
  49498. * @param name defines the name of the probe
  49499. * @param size defines the texture resolution (for each face)
  49500. * @param scene defines the hosting scene
  49501. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49502. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49503. */
  49504. constructor(
  49505. /** defines the name of the probe */
  49506. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49507. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49508. samples: number;
  49509. /** Gets or sets the refresh rate to use (on every frame by default) */
  49510. refreshRate: number;
  49511. /**
  49512. * Gets the hosting scene
  49513. * @returns a Scene
  49514. */
  49515. getScene(): Scene;
  49516. /** Gets the internal CubeTexture used to render to */
  49517. readonly cubeTexture: RenderTargetTexture;
  49518. /** Gets the list of meshes to render */
  49519. readonly renderList: Nullable<AbstractMesh[]>;
  49520. /**
  49521. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49522. * @param mesh defines the mesh to attach to
  49523. */
  49524. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49525. /**
  49526. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49527. * @param renderingGroupId The rendering group id corresponding to its index
  49528. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49529. */
  49530. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49531. /**
  49532. * Clean all associated resources
  49533. */
  49534. dispose(): void;
  49535. /**
  49536. * Converts the reflection probe information to a readable string for debug purpose.
  49537. * @param fullDetails Supports for multiple levels of logging within scene loading
  49538. * @returns the human readable reflection probe info
  49539. */
  49540. toString(fullDetails?: boolean): string;
  49541. /**
  49542. * Get the class name of the relfection probe.
  49543. * @returns "ReflectionProbe"
  49544. */
  49545. getClassName(): string;
  49546. /**
  49547. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49548. * @returns The JSON representation of the texture
  49549. */
  49550. serialize(): any;
  49551. /**
  49552. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49553. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49554. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49555. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49556. * @returns The parsed reflection probe if successful
  49557. */
  49558. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49559. }
  49560. }
  49561. declare module BABYLON {
  49562. /** @hidden */
  49563. export var _BabylonLoaderRegistered: boolean;
  49564. }
  49565. declare module BABYLON {
  49566. /**
  49567. * The Physically based simple base material of BJS.
  49568. *
  49569. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49570. * It is used as the base class for both the specGloss and metalRough conventions.
  49571. */
  49572. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49573. /**
  49574. * Number of Simultaneous lights allowed on the material.
  49575. */
  49576. maxSimultaneousLights: number;
  49577. /**
  49578. * If sets to true, disables all the lights affecting the material.
  49579. */
  49580. disableLighting: boolean;
  49581. /**
  49582. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49583. */
  49584. environmentTexture: BaseTexture;
  49585. /**
  49586. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49587. */
  49588. invertNormalMapX: boolean;
  49589. /**
  49590. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49591. */
  49592. invertNormalMapY: boolean;
  49593. /**
  49594. * Normal map used in the model.
  49595. */
  49596. normalTexture: BaseTexture;
  49597. /**
  49598. * Emissivie color used to self-illuminate the model.
  49599. */
  49600. emissiveColor: Color3;
  49601. /**
  49602. * Emissivie texture used to self-illuminate the model.
  49603. */
  49604. emissiveTexture: BaseTexture;
  49605. /**
  49606. * Occlusion Channel Strenght.
  49607. */
  49608. occlusionStrength: number;
  49609. /**
  49610. * Occlusion Texture of the material (adding extra occlusion effects).
  49611. */
  49612. occlusionTexture: BaseTexture;
  49613. /**
  49614. * Defines the alpha limits in alpha test mode.
  49615. */
  49616. alphaCutOff: number;
  49617. /**
  49618. * Gets the current double sided mode.
  49619. */
  49620. /**
  49621. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49622. */
  49623. doubleSided: boolean;
  49624. /**
  49625. * Stores the pre-calculated light information of a mesh in a texture.
  49626. */
  49627. lightmapTexture: BaseTexture;
  49628. /**
  49629. * If true, the light map contains occlusion information instead of lighting info.
  49630. */
  49631. useLightmapAsShadowmap: boolean;
  49632. /**
  49633. * Instantiates a new PBRMaterial instance.
  49634. *
  49635. * @param name The material name
  49636. * @param scene The scene the material will be use in.
  49637. */
  49638. constructor(name: string, scene: Scene);
  49639. getClassName(): string;
  49640. }
  49641. }
  49642. declare module BABYLON {
  49643. /**
  49644. * The PBR material of BJS following the metal roughness convention.
  49645. *
  49646. * This fits to the PBR convention in the GLTF definition:
  49647. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49648. */
  49649. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49650. /**
  49651. * The base color has two different interpretations depending on the value of metalness.
  49652. * When the material is a metal, the base color is the specific measured reflectance value
  49653. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49654. * of the material.
  49655. */
  49656. baseColor: Color3;
  49657. /**
  49658. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49659. * well as opacity information in the alpha channel.
  49660. */
  49661. baseTexture: BaseTexture;
  49662. /**
  49663. * Specifies the metallic scalar value of the material.
  49664. * Can also be used to scale the metalness values of the metallic texture.
  49665. */
  49666. metallic: number;
  49667. /**
  49668. * Specifies the roughness scalar value of the material.
  49669. * Can also be used to scale the roughness values of the metallic texture.
  49670. */
  49671. roughness: number;
  49672. /**
  49673. * Texture containing both the metallic value in the B channel and the
  49674. * roughness value in the G channel to keep better precision.
  49675. */
  49676. metallicRoughnessTexture: BaseTexture;
  49677. /**
  49678. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49679. *
  49680. * @param name The material name
  49681. * @param scene The scene the material will be use in.
  49682. */
  49683. constructor(name: string, scene: Scene);
  49684. /**
  49685. * Return the currrent class name of the material.
  49686. */
  49687. getClassName(): string;
  49688. /**
  49689. * Makes a duplicate of the current material.
  49690. * @param name - name to use for the new material.
  49691. */
  49692. clone(name: string): PBRMetallicRoughnessMaterial;
  49693. /**
  49694. * Serialize the material to a parsable JSON object.
  49695. */
  49696. serialize(): any;
  49697. /**
  49698. * Parses a JSON object correponding to the serialize function.
  49699. */
  49700. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49701. }
  49702. }
  49703. declare module BABYLON {
  49704. /**
  49705. * The PBR material of BJS following the specular glossiness convention.
  49706. *
  49707. * This fits to the PBR convention in the GLTF definition:
  49708. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49709. */
  49710. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49711. /**
  49712. * Specifies the diffuse color of the material.
  49713. */
  49714. diffuseColor: Color3;
  49715. /**
  49716. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49717. * channel.
  49718. */
  49719. diffuseTexture: BaseTexture;
  49720. /**
  49721. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49722. */
  49723. specularColor: Color3;
  49724. /**
  49725. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49726. */
  49727. glossiness: number;
  49728. /**
  49729. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49730. */
  49731. specularGlossinessTexture: BaseTexture;
  49732. /**
  49733. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49734. *
  49735. * @param name The material name
  49736. * @param scene The scene the material will be use in.
  49737. */
  49738. constructor(name: string, scene: Scene);
  49739. /**
  49740. * Return the currrent class name of the material.
  49741. */
  49742. getClassName(): string;
  49743. /**
  49744. * Makes a duplicate of the current material.
  49745. * @param name - name to use for the new material.
  49746. */
  49747. clone(name: string): PBRSpecularGlossinessMaterial;
  49748. /**
  49749. * Serialize the material to a parsable JSON object.
  49750. */
  49751. serialize(): any;
  49752. /**
  49753. * Parses a JSON object correponding to the serialize function.
  49754. */
  49755. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49756. }
  49757. }
  49758. declare module BABYLON {
  49759. /**
  49760. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49761. * It can help converting any input color in a desired output one. This can then be used to create effects
  49762. * from sepia, black and white to sixties or futuristic rendering...
  49763. *
  49764. * The only supported format is currently 3dl.
  49765. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49766. */
  49767. export class ColorGradingTexture extends BaseTexture {
  49768. /**
  49769. * The current texture matrix. (will always be identity in color grading texture)
  49770. */
  49771. private _textureMatrix;
  49772. /**
  49773. * The texture URL.
  49774. */
  49775. url: string;
  49776. /**
  49777. * Empty line regex stored for GC.
  49778. */
  49779. private static _noneEmptyLineRegex;
  49780. private _engine;
  49781. /**
  49782. * Instantiates a ColorGradingTexture from the following parameters.
  49783. *
  49784. * @param url The location of the color gradind data (currently only supporting 3dl)
  49785. * @param scene The scene the texture will be used in
  49786. */
  49787. constructor(url: string, scene: Scene);
  49788. /**
  49789. * Returns the texture matrix used in most of the material.
  49790. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49791. */
  49792. getTextureMatrix(): Matrix;
  49793. /**
  49794. * Occurs when the file being loaded is a .3dl LUT file.
  49795. */
  49796. private load3dlTexture;
  49797. /**
  49798. * Starts the loading process of the texture.
  49799. */
  49800. private loadTexture;
  49801. /**
  49802. * Clones the color gradind texture.
  49803. */
  49804. clone(): ColorGradingTexture;
  49805. /**
  49806. * Called during delayed load for textures.
  49807. */
  49808. delayLoad(): void;
  49809. /**
  49810. * Parses a color grading texture serialized by Babylon.
  49811. * @param parsedTexture The texture information being parsedTexture
  49812. * @param scene The scene to load the texture in
  49813. * @param rootUrl The root url of the data assets to load
  49814. * @return A color gradind texture
  49815. */
  49816. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49817. /**
  49818. * Serializes the LUT texture to json format.
  49819. */
  49820. serialize(): any;
  49821. }
  49822. }
  49823. declare module BABYLON {
  49824. /**
  49825. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49826. */
  49827. export class EquiRectangularCubeTexture extends BaseTexture {
  49828. /** The six faces of the cube. */
  49829. private static _FacesMapping;
  49830. private _noMipmap;
  49831. private _onLoad;
  49832. private _onError;
  49833. /** The size of the cubemap. */
  49834. private _size;
  49835. /** The buffer of the image. */
  49836. private _buffer;
  49837. /** The width of the input image. */
  49838. private _width;
  49839. /** The height of the input image. */
  49840. private _height;
  49841. /** The URL to the image. */
  49842. url: string;
  49843. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49844. coordinatesMode: number;
  49845. /**
  49846. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49847. * @param url The location of the image
  49848. * @param scene The scene the texture will be used in
  49849. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49850. * @param noMipmap Forces to not generate the mipmap if true
  49851. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49852. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49853. * @param onLoad — defines a callback called when texture is loaded
  49854. * @param onError — defines a callback called if there is an error
  49855. */
  49856. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49857. /**
  49858. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49859. */
  49860. private loadImage;
  49861. /**
  49862. * Convert the image buffer into a cubemap and create a CubeTexture.
  49863. */
  49864. private loadTexture;
  49865. /**
  49866. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49867. * @param buffer The ArrayBuffer that should be converted.
  49868. * @returns The buffer as Float32Array.
  49869. */
  49870. private getFloat32ArrayFromArrayBuffer;
  49871. /**
  49872. * Get the current class name of the texture useful for serialization or dynamic coding.
  49873. * @returns "EquiRectangularCubeTexture"
  49874. */
  49875. getClassName(): string;
  49876. /**
  49877. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49878. * @returns A clone of the current EquiRectangularCubeTexture.
  49879. */
  49880. clone(): EquiRectangularCubeTexture;
  49881. }
  49882. }
  49883. declare module BABYLON {
  49884. /**
  49885. * Based on jsTGALoader - Javascript loader for TGA file
  49886. * By Vincent Thibault
  49887. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49888. */
  49889. export class TGATools {
  49890. private static _TYPE_INDEXED;
  49891. private static _TYPE_RGB;
  49892. private static _TYPE_GREY;
  49893. private static _TYPE_RLE_INDEXED;
  49894. private static _TYPE_RLE_RGB;
  49895. private static _TYPE_RLE_GREY;
  49896. private static _ORIGIN_MASK;
  49897. private static _ORIGIN_SHIFT;
  49898. private static _ORIGIN_BL;
  49899. private static _ORIGIN_BR;
  49900. private static _ORIGIN_UL;
  49901. private static _ORIGIN_UR;
  49902. /**
  49903. * Gets the header of a TGA file
  49904. * @param data defines the TGA data
  49905. * @returns the header
  49906. */
  49907. static GetTGAHeader(data: Uint8Array): any;
  49908. /**
  49909. * Uploads TGA content to a Babylon Texture
  49910. * @hidden
  49911. */
  49912. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49913. /** @hidden */
  49914. 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;
  49915. /** @hidden */
  49916. 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;
  49917. /** @hidden */
  49918. 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;
  49919. /** @hidden */
  49920. 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;
  49921. /** @hidden */
  49922. 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;
  49923. /** @hidden */
  49924. 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;
  49925. }
  49926. }
  49927. declare module BABYLON {
  49928. /**
  49929. * Implementation of the TGA Texture Loader.
  49930. * @hidden
  49931. */
  49932. export class _TGATextureLoader implements IInternalTextureLoader {
  49933. /**
  49934. * Defines wether the loader supports cascade loading the different faces.
  49935. */
  49936. readonly supportCascades: boolean;
  49937. /**
  49938. * This returns if the loader support the current file information.
  49939. * @param extension defines the file extension of the file being loaded
  49940. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49941. * @param fallback defines the fallback internal texture if any
  49942. * @param isBase64 defines whether the texture is encoded as a base64
  49943. * @param isBuffer defines whether the texture data are stored as a buffer
  49944. * @returns true if the loader can load the specified file
  49945. */
  49946. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49947. /**
  49948. * Transform the url before loading if required.
  49949. * @param rootUrl the url of the texture
  49950. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49951. * @returns the transformed texture
  49952. */
  49953. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49954. /**
  49955. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49956. * @param rootUrl the url of the texture
  49957. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49958. * @returns the fallback texture
  49959. */
  49960. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49961. /**
  49962. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49963. * @param data contains the texture data
  49964. * @param texture defines the BabylonJS internal texture
  49965. * @param createPolynomials will be true if polynomials have been requested
  49966. * @param onLoad defines the callback to trigger once the texture is ready
  49967. * @param onError defines the callback to trigger in case of error
  49968. */
  49969. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49970. /**
  49971. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49972. * @param data contains the texture data
  49973. * @param texture defines the BabylonJS internal texture
  49974. * @param callback defines the method to call once ready to upload
  49975. */
  49976. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49977. }
  49978. }
  49979. declare module BABYLON {
  49980. /**
  49981. * 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.
  49982. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49983. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49984. */
  49985. export class CustomProceduralTexture extends ProceduralTexture {
  49986. private _animate;
  49987. private _time;
  49988. private _config;
  49989. private _texturePath;
  49990. /**
  49991. * Instantiates a new Custom Procedural Texture.
  49992. * 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.
  49993. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49994. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49995. * @param name Define the name of the texture
  49996. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49997. * @param size Define the size of the texture to create
  49998. * @param scene Define the scene the texture belongs to
  49999. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50000. * @param generateMipMaps Define if the texture should creates mip maps or not
  50001. */
  50002. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50003. private _loadJson;
  50004. /**
  50005. * Is the texture ready to be used ? (rendered at least once)
  50006. * @returns true if ready, otherwise, false.
  50007. */
  50008. isReady(): boolean;
  50009. /**
  50010. * Render the texture to its associated render target.
  50011. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50012. */
  50013. render(useCameraPostProcess?: boolean): void;
  50014. /**
  50015. * Update the list of dependant textures samplers in the shader.
  50016. */
  50017. updateTextures(): void;
  50018. /**
  50019. * Update the uniform values of the procedural texture in the shader.
  50020. */
  50021. updateShaderUniforms(): void;
  50022. /**
  50023. * Define if the texture animates or not.
  50024. */
  50025. animate: boolean;
  50026. }
  50027. }
  50028. declare module BABYLON {
  50029. /** @hidden */
  50030. export var noisePixelShader: {
  50031. name: string;
  50032. shader: string;
  50033. };
  50034. }
  50035. declare module BABYLON {
  50036. /**
  50037. * Class used to generate noise procedural textures
  50038. */
  50039. export class NoiseProceduralTexture extends ProceduralTexture {
  50040. private _time;
  50041. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50042. brightness: number;
  50043. /** Defines the number of octaves to process */
  50044. octaves: number;
  50045. /** Defines the level of persistence (0.8 by default) */
  50046. persistence: number;
  50047. /** Gets or sets animation speed factor (default is 1) */
  50048. animationSpeedFactor: number;
  50049. /**
  50050. * Creates a new NoiseProceduralTexture
  50051. * @param name defines the name fo the texture
  50052. * @param size defines the size of the texture (default is 256)
  50053. * @param scene defines the hosting scene
  50054. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50055. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50056. */
  50057. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50058. private _updateShaderUniforms;
  50059. protected _getDefines(): string;
  50060. /** Generate the current state of the procedural texture */
  50061. render(useCameraPostProcess?: boolean): void;
  50062. /**
  50063. * Serializes this noise procedural texture
  50064. * @returns a serialized noise procedural texture object
  50065. */
  50066. serialize(): any;
  50067. /**
  50068. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50069. * @param parsedTexture defines parsed texture data
  50070. * @param scene defines the current scene
  50071. * @param rootUrl defines the root URL containing noise procedural texture information
  50072. * @returns a parsed NoiseProceduralTexture
  50073. */
  50074. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50075. }
  50076. }
  50077. declare module BABYLON {
  50078. /**
  50079. * Raw cube texture where the raw buffers are passed in
  50080. */
  50081. export class RawCubeTexture extends CubeTexture {
  50082. /**
  50083. * Creates a cube texture where the raw buffers are passed in.
  50084. * @param scene defines the scene the texture is attached to
  50085. * @param data defines the array of data to use to create each face
  50086. * @param size defines the size of the textures
  50087. * @param format defines the format of the data
  50088. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50089. * @param generateMipMaps defines if the engine should generate the mip levels
  50090. * @param invertY defines if data must be stored with Y axis inverted
  50091. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50092. * @param compression defines the compression used (null by default)
  50093. */
  50094. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50095. /**
  50096. * Updates the raw cube texture.
  50097. * @param data defines the data to store
  50098. * @param format defines the data format
  50099. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50100. * @param invertY defines if data must be stored with Y axis inverted
  50101. * @param compression defines the compression used (null by default)
  50102. * @param level defines which level of the texture to update
  50103. */
  50104. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50105. /**
  50106. * Updates a raw cube texture with RGBD encoded data.
  50107. * @param data defines the array of data [mipmap][face] to use to create each face
  50108. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50109. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50110. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50111. * @returns a promsie that resolves when the operation is complete
  50112. */
  50113. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50114. /**
  50115. * Clones the raw cube texture.
  50116. * @return a new cube texture
  50117. */
  50118. clone(): CubeTexture;
  50119. /** @hidden */
  50120. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50121. }
  50122. }
  50123. declare module BABYLON {
  50124. /**
  50125. * Class used to store 3D textures containing user data
  50126. */
  50127. export class RawTexture3D extends Texture {
  50128. /** Gets or sets the texture format to use */
  50129. format: number;
  50130. private _engine;
  50131. /**
  50132. * Create a new RawTexture3D
  50133. * @param data defines the data of the texture
  50134. * @param width defines the width of the texture
  50135. * @param height defines the height of the texture
  50136. * @param depth defines the depth of the texture
  50137. * @param format defines the texture format to use
  50138. * @param scene defines the hosting scene
  50139. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  50140. * @param invertY defines if texture must be stored with Y axis inverted
  50141. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  50142. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  50143. */
  50144. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  50145. /** Gets or sets the texture format to use */
  50146. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  50147. /**
  50148. * Update the texture with new data
  50149. * @param data defines the data to store in the texture
  50150. */
  50151. update(data: ArrayBufferView): void;
  50152. }
  50153. }
  50154. declare module BABYLON {
  50155. /**
  50156. * Creates a refraction texture used by refraction channel of the standard material.
  50157. * It is like a mirror but to see through a material.
  50158. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50159. */
  50160. export class RefractionTexture extends RenderTargetTexture {
  50161. /**
  50162. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  50163. * 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.
  50164. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50165. */
  50166. refractionPlane: Plane;
  50167. /**
  50168. * Define how deep under the surface we should see.
  50169. */
  50170. depth: number;
  50171. /**
  50172. * Creates a refraction texture used by refraction channel of the standard material.
  50173. * It is like a mirror but to see through a material.
  50174. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50175. * @param name Define the texture name
  50176. * @param size Define the size of the underlying texture
  50177. * @param scene Define the scene the refraction belongs to
  50178. * @param generateMipMaps Define if we need to generate mips level for the refraction
  50179. */
  50180. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  50181. /**
  50182. * Clone the refraction texture.
  50183. * @returns the cloned texture
  50184. */
  50185. clone(): RefractionTexture;
  50186. /**
  50187. * Serialize the texture to a JSON representation you could use in Parse later on
  50188. * @returns the serialized JSON representation
  50189. */
  50190. serialize(): any;
  50191. }
  50192. }
  50193. declare module BABYLON {
  50194. /**
  50195. * Defines the options related to the creation of an HtmlElementTexture
  50196. */
  50197. export interface IHtmlElementTextureOptions {
  50198. /**
  50199. * Defines wether mip maps should be created or not.
  50200. */
  50201. generateMipMaps?: boolean;
  50202. /**
  50203. * Defines the sampling mode of the texture.
  50204. */
  50205. samplingMode?: number;
  50206. /**
  50207. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  50208. */
  50209. engine: Nullable<Engine>;
  50210. /**
  50211. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  50212. */
  50213. scene: Nullable<Scene>;
  50214. }
  50215. /**
  50216. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  50217. * To be as efficient as possible depending on your constraints nothing aside the first upload
  50218. * is automatically managed.
  50219. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  50220. * in your application.
  50221. *
  50222. * As the update is not automatic, you need to call them manually.
  50223. */
  50224. export class HtmlElementTexture extends BaseTexture {
  50225. /**
  50226. * The texture URL.
  50227. */
  50228. element: HTMLVideoElement | HTMLCanvasElement;
  50229. private static readonly DefaultOptions;
  50230. private _textureMatrix;
  50231. private _engine;
  50232. private _isVideo;
  50233. private _generateMipMaps;
  50234. private _samplingMode;
  50235. /**
  50236. * Instantiates a HtmlElementTexture from the following parameters.
  50237. *
  50238. * @param name Defines the name of the texture
  50239. * @param element Defines the video or canvas the texture is filled with
  50240. * @param options Defines the other none mandatory texture creation options
  50241. */
  50242. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  50243. private _createInternalTexture;
  50244. /**
  50245. * Returns the texture matrix used in most of the material.
  50246. */
  50247. getTextureMatrix(): Matrix;
  50248. /**
  50249. * Updates the content of the texture.
  50250. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  50251. */
  50252. update(invertY?: Nullable<boolean>): void;
  50253. }
  50254. }
  50255. declare module BABYLON {
  50256. /**
  50257. * Enum used to define the target of a block
  50258. */
  50259. export enum NodeMaterialBlockTargets {
  50260. /** Vertex shader */
  50261. Vertex = 1,
  50262. /** Fragment shader */
  50263. Fragment = 2,
  50264. /** Vertex and Fragment */
  50265. VertexAndFragment = 3
  50266. }
  50267. }
  50268. declare module BABYLON {
  50269. /**
  50270. * Defines the kind of connection point for node based material
  50271. */
  50272. export enum NodeMaterialBlockConnectionPointTypes {
  50273. /** Float */
  50274. Float = 1,
  50275. /** Int */
  50276. Int = 2,
  50277. /** Vector2 */
  50278. Vector2 = 4,
  50279. /** Vector3 */
  50280. Vector3 = 8,
  50281. /** Vector4 */
  50282. Vector4 = 16,
  50283. /** Color3 */
  50284. Color3 = 32,
  50285. /** Color4 */
  50286. Color4 = 64,
  50287. /** Matrix */
  50288. Matrix = 128,
  50289. /** Texture */
  50290. Texture = 256,
  50291. /** Texture3D */
  50292. Texture3D = 512,
  50293. /** Vector3 or Color3 */
  50294. Vector3OrColor3 = 40,
  50295. /** Vector3 or Vector4 */
  50296. Vector3OrVector4 = 24,
  50297. /** Vector4 or Color4 */
  50298. Vector4OrColor4 = 80,
  50299. /** Color3 or Color4 */
  50300. Color3OrColor4 = 96,
  50301. /** Vector3 or Color3 */
  50302. Vector3OrColor3OrVector4OrColor4 = 120
  50303. }
  50304. }
  50305. declare module BABYLON {
  50306. /**
  50307. * Enum used to define well known values e.g. values automatically provided by the system
  50308. */
  50309. export enum NodeMaterialWellKnownValues {
  50310. /** World */
  50311. World = 1,
  50312. /** View */
  50313. View = 2,
  50314. /** Projection */
  50315. Projection = 3,
  50316. /** ViewProjection */
  50317. ViewProjection = 4,
  50318. /** WorldView */
  50319. WorldView = 5,
  50320. /** WorldViewProjection */
  50321. WorldViewProjection = 6,
  50322. /** Will be filled by the block itself */
  50323. Automatic = 7
  50324. }
  50325. }
  50326. declare module BABYLON {
  50327. /**
  50328. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  50329. */
  50330. export enum NodeMaterialBlockConnectionPointMode {
  50331. /** Value is an uniform */
  50332. Uniform = 0,
  50333. /** Value is a mesh attribute */
  50334. Attribute = 1,
  50335. /** Value is a varying between vertex and fragment shaders */
  50336. Varying = 2,
  50337. /** Mode is undefined */
  50338. Undefined = 3
  50339. }
  50340. }
  50341. declare module BABYLON {
  50342. /**
  50343. * Class used to store shared data between 2 NodeMaterialBuildState
  50344. */
  50345. export class NodeMaterialBuildStateSharedData {
  50346. /**
  50347. * Gets the list of emitted varyings
  50348. */
  50349. varyings: string[];
  50350. /**
  50351. * Gets the varying declaration string
  50352. */
  50353. varyingDeclaration: string;
  50354. /**
  50355. * Uniform connection points
  50356. */
  50357. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  50358. /**
  50359. * Bindable blocks (Blocks that need to set data to the effect)
  50360. */
  50361. bindableBlocks: NodeMaterialBlock[];
  50362. /**
  50363. * List of blocks that can provide a compilation fallback
  50364. */
  50365. blocksWithFallbacks: NodeMaterialBlock[];
  50366. /**
  50367. * List of blocks that can provide a define update
  50368. */
  50369. blocksWithDefines: NodeMaterialBlock[];
  50370. /**
  50371. * List of blocks that can provide a repeatable content
  50372. */
  50373. repeatableContentBlocks: NodeMaterialBlock[];
  50374. /**
  50375. * List of blocks that can block the isReady function for the material
  50376. */
  50377. blockingBlocks: NodeMaterialBlock[];
  50378. /**
  50379. * Build Id used to avoid multiple recompilations
  50380. */
  50381. buildId: number;
  50382. /** List of emitted variables */
  50383. variableNames: {
  50384. [key: string]: number;
  50385. };
  50386. /** List of emitted defines */
  50387. defineNames: {
  50388. [key: string]: number;
  50389. };
  50390. /** Should emit comments? */
  50391. emitComments: boolean;
  50392. /** Emit build activity */
  50393. verbose: boolean;
  50394. /**
  50395. * Gets the compilation hints emitted at compilation time
  50396. */
  50397. hints: {
  50398. needWorldViewMatrix: boolean;
  50399. needWorldViewProjectionMatrix: boolean;
  50400. needAlphaBlending: boolean;
  50401. needAlphaTesting: boolean;
  50402. };
  50403. /**
  50404. * List of compilation checks
  50405. */
  50406. checks: {
  50407. emitVertex: boolean;
  50408. emitFragment: boolean;
  50409. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  50410. };
  50411. /** Creates a new shared data */
  50412. constructor();
  50413. /**
  50414. * Emits console errors and exceptions if there is a failing check
  50415. */
  50416. emitErrors(): void;
  50417. }
  50418. }
  50419. declare module BABYLON {
  50420. /**
  50421. * Class used to store node based material build state
  50422. */
  50423. export class NodeMaterialBuildState {
  50424. /**
  50425. * Gets the list of emitted attributes
  50426. */
  50427. attributes: string[];
  50428. /**
  50429. * Gets the list of emitted uniforms
  50430. */
  50431. uniforms: string[];
  50432. /**
  50433. * Gets the list of emitted samplers
  50434. */
  50435. samplers: string[];
  50436. /**
  50437. * Gets the list of emitted functions
  50438. */
  50439. functions: {
  50440. [key: string]: string;
  50441. };
  50442. /**
  50443. * Gets the target of the compilation state
  50444. */
  50445. target: NodeMaterialBlockTargets;
  50446. /**
  50447. * Shared data between multiple NodeMaterialBuildState instances
  50448. */
  50449. sharedData: NodeMaterialBuildStateSharedData;
  50450. /** @hidden */
  50451. _vertexState: NodeMaterialBuildState;
  50452. private _attributeDeclaration;
  50453. private _uniformDeclaration;
  50454. private _samplerDeclaration;
  50455. private _varyingTransfer;
  50456. private _repeatableContentAnchorIndex;
  50457. /** @hidden */
  50458. _builtCompilationString: string;
  50459. /**
  50460. * Gets the emitted compilation strings
  50461. */
  50462. compilationString: string;
  50463. /**
  50464. * Finalize the compilation strings
  50465. * @param state defines the current compilation state
  50466. */
  50467. finalize(state: NodeMaterialBuildState): void;
  50468. /** @hidden */
  50469. readonly _repeatableContentAnchor: string;
  50470. /** @hidden */
  50471. _getFreeVariableName(prefix: string): string;
  50472. /** @hidden */
  50473. _getFreeDefineName(prefix: string): string;
  50474. /** @hidden */
  50475. _excludeVariableName(name: string): void;
  50476. /** @hidden */
  50477. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  50478. /** @hidden */
  50479. _emitFunction(name: string, code: string, comments: string): void;
  50480. /** @hidden */
  50481. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  50482. replaceStrings?: {
  50483. search: RegExp;
  50484. replace: string;
  50485. }[];
  50486. }): string;
  50487. /** @hidden */
  50488. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  50489. repeatKey?: string;
  50490. removeAttributes?: boolean;
  50491. removeUniforms?: boolean;
  50492. removeVaryings?: boolean;
  50493. removeIfDef?: boolean;
  50494. replaceStrings?: {
  50495. search: RegExp;
  50496. replace: string;
  50497. }[];
  50498. }): void;
  50499. /** @hidden */
  50500. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  50501. private _emitDefine;
  50502. /** @hidden */
  50503. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  50504. }
  50505. }
  50506. declare module BABYLON {
  50507. /**
  50508. * Root class for all node material optimizers
  50509. */
  50510. export class NodeMaterialOptimizer {
  50511. /**
  50512. * Function used to optimize a NodeMaterial graph
  50513. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  50514. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  50515. */
  50516. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  50517. }
  50518. }
  50519. declare module BABYLON {
  50520. /**
  50521. * Interface used to configure the node material editor
  50522. */
  50523. export interface INodeMaterialEditorOptions {
  50524. /** Define the URl to load node editor script */
  50525. editorURL?: string;
  50526. }
  50527. /** @hidden */
  50528. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  50529. /** BONES */
  50530. NUM_BONE_INFLUENCERS: number;
  50531. BonesPerMesh: number;
  50532. BONETEXTURE: boolean;
  50533. /** MORPH TARGETS */
  50534. MORPHTARGETS: boolean;
  50535. MORPHTARGETS_NORMAL: boolean;
  50536. MORPHTARGETS_TANGENT: boolean;
  50537. NUM_MORPH_INFLUENCERS: number;
  50538. /** IMAGE PROCESSING */
  50539. IMAGEPROCESSING: boolean;
  50540. VIGNETTE: boolean;
  50541. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50542. VIGNETTEBLENDMODEOPAQUE: boolean;
  50543. TONEMAPPING: boolean;
  50544. TONEMAPPING_ACES: boolean;
  50545. CONTRAST: boolean;
  50546. EXPOSURE: boolean;
  50547. COLORCURVES: boolean;
  50548. COLORGRADING: boolean;
  50549. COLORGRADING3D: boolean;
  50550. SAMPLER3DGREENDEPTH: boolean;
  50551. SAMPLER3DBGRMAP: boolean;
  50552. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50553. constructor();
  50554. setValue(name: string, value: boolean): void;
  50555. }
  50556. /**
  50557. * Class used to configure NodeMaterial
  50558. */
  50559. export interface INodeMaterialOptions {
  50560. /**
  50561. * Defines if blocks should emit comments
  50562. */
  50563. emitComments: boolean;
  50564. }
  50565. /**
  50566. * Class used to create a node based material built by assembling shader blocks
  50567. */
  50568. export class NodeMaterial extends PushMaterial {
  50569. private _options;
  50570. private _vertexCompilationState;
  50571. private _fragmentCompilationState;
  50572. private _sharedData;
  50573. private _buildId;
  50574. private _buildWasSuccessful;
  50575. private _cachedWorldViewMatrix;
  50576. private _cachedWorldViewProjectionMatrix;
  50577. private _textureConnectionPoints;
  50578. private _optimizers;
  50579. /** Define the URl to load node editor script */
  50580. static EditorURL: string;
  50581. private BJSNODEMATERIALEDITOR;
  50582. /** Get the inspector from bundle or global */
  50583. private _getGlobalNodeMaterialEditor;
  50584. /**
  50585. * Defines the maximum number of lights that can be used in the material
  50586. */
  50587. maxSimultaneousLights: number;
  50588. /**
  50589. * Observable raised when the material is built
  50590. */
  50591. onBuildObservable: Observable<NodeMaterial>;
  50592. /**
  50593. * Gets or sets the root nodes of the material vertex shader
  50594. */
  50595. _vertexOutputNodes: NodeMaterialBlock[];
  50596. /**
  50597. * Gets or sets the root nodes of the material fragment (pixel) shader
  50598. */
  50599. _fragmentOutputNodes: NodeMaterialBlock[];
  50600. /** Gets or sets options to control the node material overall behavior */
  50601. options: INodeMaterialOptions;
  50602. /**
  50603. * Default configuration related to image processing available in the standard Material.
  50604. */
  50605. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50606. /**
  50607. * Gets the image processing configuration used either in this material.
  50608. */
  50609. /**
  50610. * Sets the Default image processing configuration used either in the this material.
  50611. *
  50612. * If sets to null, the scene one is in use.
  50613. */
  50614. imageProcessingConfiguration: ImageProcessingConfiguration;
  50615. /**
  50616. * Create a new node based material
  50617. * @param name defines the material name
  50618. * @param scene defines the hosting scene
  50619. * @param options defines creation option
  50620. */
  50621. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  50622. /**
  50623. * Gets the current class name of the material e.g. "NodeMaterial"
  50624. * @returns the class name
  50625. */
  50626. getClassName(): string;
  50627. /**
  50628. * Keep track of the image processing observer to allow dispose and replace.
  50629. */
  50630. private _imageProcessingObserver;
  50631. /**
  50632. * Attaches a new image processing configuration to the Standard Material.
  50633. * @param configuration
  50634. */
  50635. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50636. /**
  50637. * Adds a new optimizer to the list of optimizers
  50638. * @param optimizer defines the optimizers to add
  50639. * @returns the current material
  50640. */
  50641. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  50642. /**
  50643. * Remove an optimizer from the list of optimizers
  50644. * @param optimizer defines the optimizers to remove
  50645. * @returns the current material
  50646. */
  50647. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  50648. /**
  50649. * Add a new block to the list of output nodes
  50650. * @param node defines the node to add
  50651. * @returns the current material
  50652. */
  50653. addOutputNode(node: NodeMaterialBlock): this;
  50654. /**
  50655. * Remove a block from the list of root nodes
  50656. * @param node defines the node to remove
  50657. * @returns the current material
  50658. */
  50659. removeOutputNode(node: NodeMaterialBlock): this;
  50660. private _addVertexOutputNode;
  50661. private _removeVertexOutputNode;
  50662. private _addFragmentOutputNode;
  50663. private _removeFragmentOutputNode;
  50664. /**
  50665. * Specifies if the material will require alpha blending
  50666. * @returns a boolean specifying if alpha blending is needed
  50667. */
  50668. needAlphaBlending(): boolean;
  50669. /**
  50670. * Specifies if this material should be rendered in alpha test mode
  50671. * @returns a boolean specifying if an alpha test is needed.
  50672. */
  50673. needAlphaTesting(): boolean;
  50674. private _initializeBlock;
  50675. private _resetDualBlocks;
  50676. /**
  50677. * Build the material and generates the inner effect
  50678. * @param verbose defines if the build should log activity
  50679. */
  50680. build(verbose?: boolean): void;
  50681. /**
  50682. * Runs an otpimization phase to try to improve the shader code
  50683. */
  50684. optimize(): void;
  50685. private _prepareDefinesForAttributes;
  50686. /**
  50687. * Get if the submesh is ready to be used and all its information available.
  50688. * Child classes can use it to update shaders
  50689. * @param mesh defines the mesh to check
  50690. * @param subMesh defines which submesh to check
  50691. * @param useInstances specifies that instances should be used
  50692. * @returns a boolean indicating that the submesh is ready or not
  50693. */
  50694. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50695. /**
  50696. * Binds the world matrix to the material
  50697. * @param world defines the world transformation matrix
  50698. */
  50699. bindOnlyWorldMatrix(world: Matrix): void;
  50700. /**
  50701. * Binds the submesh to this material by preparing the effect and shader to draw
  50702. * @param world defines the world transformation matrix
  50703. * @param mesh defines the mesh containing the submesh
  50704. * @param subMesh defines the submesh to bind the material to
  50705. */
  50706. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50707. /**
  50708. * Gets the active textures from the material
  50709. * @returns an array of textures
  50710. */
  50711. getActiveTextures(): BaseTexture[];
  50712. /**
  50713. * Specifies if the material uses a texture
  50714. * @param texture defines the texture to check against the material
  50715. * @returns a boolean specifying if the material uses the texture
  50716. */
  50717. hasTexture(texture: BaseTexture): boolean;
  50718. /**
  50719. * Disposes the material
  50720. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  50721. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  50722. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  50723. */
  50724. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  50725. /** Creates the node editor window. */
  50726. private _createNodeEditor;
  50727. /**
  50728. * Launch the node material editor
  50729. * @param config Define the configuration of the editor
  50730. * @return a promise fulfilled when the node editor is visible
  50731. */
  50732. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  50733. }
  50734. }
  50735. declare module BABYLON {
  50736. /**
  50737. * Defines a block that can be used inside a node based material
  50738. */
  50739. export class NodeMaterialBlock {
  50740. private _buildId;
  50741. private _target;
  50742. private _isFinalMerger;
  50743. /** @hidden */
  50744. _inputs: NodeMaterialConnectionPoint[];
  50745. /** @hidden */
  50746. _outputs: NodeMaterialConnectionPoint[];
  50747. /**
  50748. * Gets or sets the name of the block
  50749. */
  50750. name: string;
  50751. /**
  50752. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  50753. */
  50754. readonly isFinalMerger: boolean;
  50755. /**
  50756. * Gets or sets the build Id
  50757. */
  50758. buildId: number;
  50759. /**
  50760. * Gets or sets the target of the block
  50761. */
  50762. target: NodeMaterialBlockTargets;
  50763. /**
  50764. * Gets the list of input points
  50765. */
  50766. readonly inputs: NodeMaterialConnectionPoint[];
  50767. /** Gets the list of output points */
  50768. readonly outputs: NodeMaterialConnectionPoint[];
  50769. /**
  50770. * Find an input by its name
  50771. * @param name defines the name of the input to look for
  50772. * @returns the input or null if not found
  50773. */
  50774. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  50775. /**
  50776. * Find an output by its name
  50777. * @param name defines the name of the outputto look for
  50778. * @returns the output or null if not found
  50779. */
  50780. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  50781. /**
  50782. * Creates a new NodeMaterialBlock
  50783. * @param name defines the block name
  50784. * @param target defines the target of that block (Vertex by default)
  50785. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  50786. */
  50787. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  50788. /**
  50789. * Initialize the block and prepare the context for build
  50790. * @param state defines the state that will be used for the build
  50791. */
  50792. initialize(state: NodeMaterialBuildState): void;
  50793. /**
  50794. * Bind data to effect. Will only be called for blocks with isBindable === true
  50795. * @param effect defines the effect to bind data to
  50796. * @param nodeMaterial defines the hosting NodeMaterial
  50797. * @param mesh defines the mesh that will be rendered
  50798. */
  50799. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50800. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  50801. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  50802. protected _writeFloat(value: number): string;
  50803. /**
  50804. * Gets the current class name e.g. "NodeMaterialBlock"
  50805. * @returns the class name
  50806. */
  50807. getClassName(): string;
  50808. /**
  50809. * Register a new input. Must be called inside a block constructor
  50810. * @param name defines the connection point name
  50811. * @param type defines the connection point type
  50812. * @param isOptional defines a boolean indicating that this input can be omitted
  50813. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  50814. * @returns the current block
  50815. */
  50816. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  50817. /**
  50818. * Register a new output. Must be called inside a block constructor
  50819. * @param name defines the connection point name
  50820. * @param type defines the connection point type
  50821. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  50822. * @returns the current block
  50823. */
  50824. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  50825. /**
  50826. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  50827. * @param forOutput defines an optional connection point to check compatibility with
  50828. * @returns the first available input or null
  50829. */
  50830. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  50831. /**
  50832. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  50833. * @param forBlock defines an optional block to check compatibility with
  50834. * @returns the first available input or null
  50835. */
  50836. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  50837. /**
  50838. * Connect current block with another block
  50839. * @param other defines the block to connect with
  50840. * @param options define the various options to help pick the right connections
  50841. * @returns the current block
  50842. */
  50843. connectTo(other: NodeMaterialBlock, options?: {
  50844. input?: string;
  50845. output?: string;
  50846. outputSwizzle?: string;
  50847. }): this | undefined;
  50848. protected _buildBlock(state: NodeMaterialBuildState): void;
  50849. /**
  50850. * Add potential fallbacks if shader compilation fails
  50851. * @param mesh defines the mesh to be rendered
  50852. * @param fallbacks defines the current prioritized list of fallbacks
  50853. */
  50854. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  50855. /**
  50856. * Update defines for shader compilation
  50857. * @param mesh defines the mesh to be rendered
  50858. * @param nodeMaterial defines the node material requesting the update
  50859. * @param defines defines the material defines to update
  50860. * @param useInstances specifies that instances should be used
  50861. */
  50862. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  50863. /**
  50864. * Lets the block try to connect some inputs automatically
  50865. */
  50866. autoConfigure(): void;
  50867. /**
  50868. * Function called when a block is declared as repeatable content generator
  50869. * @param vertexShaderState defines the current compilation state for the vertex shader
  50870. * @param fragmentShaderState defines the current compilation state for the fragment shader
  50871. * @param mesh defines the mesh to be rendered
  50872. * @param defines defines the material defines to update
  50873. */
  50874. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  50875. /**
  50876. * Checks if the block is ready
  50877. * @param mesh defines the mesh to be rendered
  50878. * @param nodeMaterial defines the node material requesting the update
  50879. * @param defines defines the material defines to update
  50880. * @param useInstances specifies that instances should be used
  50881. * @returns true if the block is ready
  50882. */
  50883. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  50884. /**
  50885. * Compile the current node and generate the shader code
  50886. * @param state defines the current compilation state (uniforms, samplers, current string)
  50887. * @returns the current block
  50888. */
  50889. build(state: NodeMaterialBuildState): this | undefined;
  50890. }
  50891. }
  50892. declare module BABYLON {
  50893. /**
  50894. * Defines a connection point for a block
  50895. */
  50896. export class NodeMaterialConnectionPoint {
  50897. /** @hidden */
  50898. _ownerBlock: NodeMaterialBlock;
  50899. /** @hidden */
  50900. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  50901. private _associatedVariableName;
  50902. private _endpoints;
  50903. private _storedValue;
  50904. private _valueCallback;
  50905. private _mode;
  50906. /** @hidden */
  50907. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  50908. /**
  50909. * Gets or sets the connection point type (default is float)
  50910. */
  50911. type: NodeMaterialBlockConnectionPointTypes;
  50912. /**
  50913. * Gets or sets the connection point name
  50914. */
  50915. name: string;
  50916. /**
  50917. * Gets or sets the swizzle to apply to this connection point when reading or writing
  50918. */
  50919. swizzle: string;
  50920. /**
  50921. * Gets or sets a boolean indicating that this connection point can be omitted
  50922. */
  50923. isOptional: boolean;
  50924. /**
  50925. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  50926. */
  50927. define: string;
  50928. /** Gets or sets the target of that connection point */
  50929. target: NodeMaterialBlockTargets;
  50930. /**
  50931. * Gets or sets the value of that point.
  50932. * Please note that this value will be ignored if valueCallback is defined
  50933. */
  50934. value: any;
  50935. /**
  50936. * Gets or sets a callback used to get the value of that point.
  50937. * Please note that setting this value will force the connection point to ignore the value property
  50938. */
  50939. valueCallback: () => any;
  50940. /**
  50941. * Gets or sets the associated variable name in the shader
  50942. */
  50943. associatedVariableName: string;
  50944. /**
  50945. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  50946. * In this case the connection point name must be the name of the uniform to use.
  50947. * Can only be set on inputs
  50948. */
  50949. isUniform: boolean;
  50950. /**
  50951. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  50952. * In this case the connection point name must be the name of the attribute to use
  50953. * Can only be set on inputs
  50954. */
  50955. isAttribute: boolean;
  50956. /**
  50957. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  50958. * Can only be set on exit points
  50959. */
  50960. isVarying: boolean;
  50961. /** Get the other side of the connection (if any) */
  50962. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  50963. /** Get the block that owns this connection point */
  50964. readonly ownerBlock: NodeMaterialBlock;
  50965. /** Get the block connected on the other side of this connection (if any) */
  50966. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  50967. /** Get the block connected on the endpoints of this connection (if any) */
  50968. readonly connectedBlocks: Array<NodeMaterialBlock>;
  50969. /**
  50970. * Creates a new connection point
  50971. * @param name defines the connection point name
  50972. * @param ownerBlock defines the block hosting this connection point
  50973. */
  50974. constructor(name: string, ownerBlock: NodeMaterialBlock);
  50975. /**
  50976. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  50977. * @returns the class name
  50978. */
  50979. getClassName(): string;
  50980. /**
  50981. * Set the source of this connection point to a vertex attribute
  50982. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  50983. * @returns the current connection point
  50984. */
  50985. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  50986. /**
  50987. * Set the source of this connection point to a well known value
  50988. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  50989. * @returns the current connection point
  50990. */
  50991. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  50992. /**
  50993. * Gets a boolean indicating that the current connection point is a well known value
  50994. */
  50995. readonly isWellKnownValue: boolean;
  50996. /**
  50997. * Gets or sets the current well known value or null if not defined as well know value
  50998. */
  50999. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51000. private _getTypeLength;
  51001. /**
  51002. * Connect this point to another connection point
  51003. * @param connectionPoint defines the other connection point
  51004. * @returns the current connection point
  51005. */
  51006. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51007. /**
  51008. * Disconnect this point from one of his endpoint
  51009. * @param endpoint defines the other connection point
  51010. * @returns the current connection point
  51011. */
  51012. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51013. /**
  51014. * When connection point is an uniform, this function will send its value to the effect
  51015. * @param effect defines the effect to transmit value to
  51016. * @param world defines the world matrix
  51017. * @param worldView defines the worldxview matrix
  51018. * @param worldViewProjection defines the worldxviewxprojection matrix
  51019. */
  51020. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  51021. /**
  51022. * When connection point is an uniform, this function will send its value to the effect
  51023. * @param effect defines the effect to transmit value to
  51024. * @param scene defines the hosting scene
  51025. */
  51026. transmit(effect: Effect, scene: Scene): void;
  51027. }
  51028. }
  51029. declare module BABYLON {
  51030. /**
  51031. * Block used to output the vertex position
  51032. */
  51033. export class VertexOutputBlock extends NodeMaterialBlock {
  51034. /**
  51035. * Creates a new VertexOutputBlock
  51036. * @param name defines the block name
  51037. */
  51038. constructor(name: string);
  51039. /**
  51040. * Gets the current class name
  51041. * @returns the class name
  51042. */
  51043. getClassName(): string;
  51044. /**
  51045. * Gets the vector input component
  51046. */
  51047. readonly vector: NodeMaterialConnectionPoint;
  51048. protected _buildBlock(state: NodeMaterialBuildState): this;
  51049. }
  51050. }
  51051. declare module BABYLON {
  51052. /**
  51053. * Block used to add support for vertex skinning (bones)
  51054. */
  51055. export class BonesBlock extends NodeMaterialBlock {
  51056. /**
  51057. * Creates a new BonesBlock
  51058. * @param name defines the block name
  51059. */
  51060. constructor(name: string);
  51061. /**
  51062. * Initialize the block and prepare the context for build
  51063. * @param state defines the state that will be used for the build
  51064. */
  51065. initialize(state: NodeMaterialBuildState): void;
  51066. /**
  51067. * Gets the current class name
  51068. * @returns the class name
  51069. */
  51070. getClassName(): string;
  51071. /**
  51072. * Gets the matrix indices input component
  51073. */
  51074. readonly matricesIndices: NodeMaterialConnectionPoint;
  51075. /**
  51076. * Gets the matrix weights input component
  51077. */
  51078. readonly matricesWeights: NodeMaterialConnectionPoint;
  51079. /**
  51080. * Gets the extra matrix indices input component
  51081. */
  51082. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  51083. /**
  51084. * Gets the extra matrix weights input component
  51085. */
  51086. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  51087. /**
  51088. * Gets the world input component
  51089. */
  51090. readonly world: NodeMaterialConnectionPoint;
  51091. autoConfigure(): void;
  51092. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51093. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51094. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51095. protected _buildBlock(state: NodeMaterialBuildState): this;
  51096. }
  51097. }
  51098. declare module BABYLON {
  51099. /**
  51100. * Block used to add support for instances
  51101. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  51102. */
  51103. export class InstancesBlock extends NodeMaterialBlock {
  51104. /**
  51105. * Creates a new InstancesBlock
  51106. * @param name defines the block name
  51107. */
  51108. constructor(name: string);
  51109. /**
  51110. * Gets the current class name
  51111. * @returns the class name
  51112. */
  51113. getClassName(): string;
  51114. /**
  51115. * Gets the first world row input component
  51116. */
  51117. readonly world0: NodeMaterialConnectionPoint;
  51118. /**
  51119. * Gets the second world row input component
  51120. */
  51121. readonly world1: NodeMaterialConnectionPoint;
  51122. /**
  51123. * Gets the third world row input component
  51124. */
  51125. readonly world2: NodeMaterialConnectionPoint;
  51126. /**
  51127. * Gets the forth world row input component
  51128. */
  51129. readonly world3: NodeMaterialConnectionPoint;
  51130. /**
  51131. * Gets the world input component
  51132. */
  51133. readonly world: NodeMaterialConnectionPoint;
  51134. /**
  51135. * Gets the output component
  51136. */
  51137. readonly output: NodeMaterialConnectionPoint;
  51138. autoConfigure(): void;
  51139. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51140. protected _buildBlock(state: NodeMaterialBuildState): this;
  51141. }
  51142. }
  51143. declare module BABYLON {
  51144. /**
  51145. * Block used to add morph targets support to vertex shader
  51146. */
  51147. export class MorphTargetsBlock extends NodeMaterialBlock {
  51148. private _repeatableContentAnchor;
  51149. private _repeatebleContentGenerated;
  51150. /**
  51151. * Create a new MorphTargetsBlock
  51152. * @param name defines the block name
  51153. */
  51154. constructor(name: string);
  51155. /**
  51156. * Gets the current class name
  51157. * @returns the class name
  51158. */
  51159. getClassName(): string;
  51160. /**
  51161. * Gets the position input component
  51162. */
  51163. readonly position: NodeMaterialConnectionPoint;
  51164. /**
  51165. * Gets the normal input component
  51166. */
  51167. readonly normal: NodeMaterialConnectionPoint;
  51168. /**
  51169. * Gets the tangent input component
  51170. */
  51171. readonly tangent: NodeMaterialConnectionPoint;
  51172. /**
  51173. * Gets the position output component
  51174. */
  51175. readonly positionOutput: NodeMaterialConnectionPoint;
  51176. /**
  51177. * Gets the normal output component
  51178. */
  51179. readonly normalOutput: NodeMaterialConnectionPoint;
  51180. /**
  51181. * Gets the tangent output component
  51182. */
  51183. readonly tangentOutput: NodeMaterialConnectionPoint;
  51184. initialize(state: NodeMaterialBuildState): void;
  51185. autoConfigure(): void;
  51186. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51187. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51188. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51189. protected _buildBlock(state: NodeMaterialBuildState): this;
  51190. }
  51191. }
  51192. declare module BABYLON {
  51193. /**
  51194. * Block used to output the final color
  51195. */
  51196. export class FragmentOutputBlock extends NodeMaterialBlock {
  51197. /**
  51198. * Gets or sets a boolean indicating if this block will output an alpha value
  51199. */
  51200. alphaBlendingEnabled: boolean;
  51201. /**
  51202. * Create a new FragmentOutputBlock
  51203. * @param name defines the block name
  51204. */
  51205. constructor(name: string);
  51206. /**
  51207. * Gets the current class name
  51208. * @returns the class name
  51209. */
  51210. getClassName(): string;
  51211. /**
  51212. * Gets the color input component
  51213. */
  51214. readonly color: NodeMaterialConnectionPoint;
  51215. protected _buildBlock(state: NodeMaterialBuildState): this;
  51216. }
  51217. }
  51218. declare module BABYLON {
  51219. /**
  51220. * Block used to add an alpha test in the fragment shader
  51221. */
  51222. export class AlphaTestBlock extends NodeMaterialBlock {
  51223. /**
  51224. * Gets or sets the alpha value where alpha testing happens
  51225. */
  51226. alphaCutOff: number;
  51227. /**
  51228. * Create a new AlphaTestBlock
  51229. * @param name defines the block name
  51230. */
  51231. constructor(name: string);
  51232. /**
  51233. * Gets the current class name
  51234. * @returns the class name
  51235. */
  51236. getClassName(): string;
  51237. /**
  51238. * Gets the color input component
  51239. */
  51240. readonly color: NodeMaterialConnectionPoint;
  51241. protected _buildBlock(state: NodeMaterialBuildState): this;
  51242. }
  51243. }
  51244. declare module BABYLON {
  51245. /**
  51246. * Block used to create a Color4 out of 4 inputs (one for each component)
  51247. */
  51248. export class RGBAMergerBlock extends NodeMaterialBlock {
  51249. /**
  51250. * Create a new RGBAMergerBlock
  51251. * @param name defines the block name
  51252. */
  51253. constructor(name: string);
  51254. /**
  51255. * Gets the current class name
  51256. * @returns the class name
  51257. */
  51258. getClassName(): string;
  51259. /**
  51260. * Gets the R input component
  51261. */
  51262. readonly r: NodeMaterialConnectionPoint;
  51263. /**
  51264. * Gets the G input component
  51265. */
  51266. readonly g: NodeMaterialConnectionPoint;
  51267. /**
  51268. * Gets the B input component
  51269. */
  51270. readonly b: NodeMaterialConnectionPoint;
  51271. /**
  51272. * Gets the RGB input component
  51273. */
  51274. readonly rgb: NodeMaterialConnectionPoint;
  51275. /**
  51276. * Gets the R input component
  51277. */
  51278. readonly a: NodeMaterialConnectionPoint;
  51279. protected _buildBlock(state: NodeMaterialBuildState): this;
  51280. }
  51281. }
  51282. declare module BABYLON {
  51283. /**
  51284. * Block used to create a Color3 out of 3 inputs (one for each component)
  51285. */
  51286. export class RGBMergerBlock extends NodeMaterialBlock {
  51287. /**
  51288. * Create a new RGBMergerBlock
  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 R component input
  51299. */
  51300. readonly r: NodeMaterialConnectionPoint;
  51301. /**
  51302. * Gets the G component input
  51303. */
  51304. readonly g: NodeMaterialConnectionPoint;
  51305. /**
  51306. * Gets the B component input
  51307. */
  51308. readonly b: NodeMaterialConnectionPoint;
  51309. protected _buildBlock(state: NodeMaterialBuildState): this;
  51310. }
  51311. }
  51312. declare module BABYLON {
  51313. /**
  51314. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  51315. */
  51316. export class RGBASplitterBlock extends NodeMaterialBlock {
  51317. /**
  51318. * Create a new RGBASplitterBlock
  51319. * @param name defines the block name
  51320. */
  51321. constructor(name: string);
  51322. /**
  51323. * Gets the current class name
  51324. * @returns the class name
  51325. */
  51326. getClassName(): string;
  51327. /**
  51328. * Gets the input component
  51329. */
  51330. readonly input: NodeMaterialConnectionPoint;
  51331. protected _buildBlock(state: NodeMaterialBuildState): this;
  51332. }
  51333. }
  51334. declare module BABYLON {
  51335. /**
  51336. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  51337. */
  51338. export class RGBSplitterBlock extends NodeMaterialBlock {
  51339. /**
  51340. * Create a new RGBSplitterBlock
  51341. * @param name defines the block name
  51342. */
  51343. constructor(name: string);
  51344. /**
  51345. * Gets the current class name
  51346. * @returns the class name
  51347. */
  51348. getClassName(): string;
  51349. /**
  51350. * Gets the input component
  51351. */
  51352. readonly input: NodeMaterialConnectionPoint;
  51353. protected _buildBlock(state: NodeMaterialBuildState): this;
  51354. }
  51355. }
  51356. declare module BABYLON {
  51357. /**
  51358. * Block used to read a texture from a sampler
  51359. */
  51360. export class TextureBlock extends NodeMaterialBlock {
  51361. private _defineName;
  51362. /**
  51363. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  51364. */
  51365. autoConnectTextureMatrix: boolean;
  51366. /**
  51367. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  51368. */
  51369. autoSelectUV: boolean;
  51370. /**
  51371. * Create a new TextureBlock
  51372. * @param name defines the block name
  51373. */
  51374. constructor(name: string);
  51375. /**
  51376. * Gets the current class name
  51377. * @returns the class name
  51378. */
  51379. getClassName(): string;
  51380. /**
  51381. * Gets the uv input component
  51382. */
  51383. readonly uv: NodeMaterialConnectionPoint;
  51384. /**
  51385. * Gets the texture information input component
  51386. */
  51387. readonly textureInfo: NodeMaterialConnectionPoint;
  51388. /**
  51389. * Gets the transformed uv input component
  51390. */
  51391. readonly transformedUV: NodeMaterialConnectionPoint;
  51392. /**
  51393. * Gets the texture input component
  51394. */
  51395. readonly texture: NodeMaterialConnectionPoint;
  51396. /**
  51397. * Gets the texture transform input component
  51398. */
  51399. readonly textureTransform: NodeMaterialConnectionPoint;
  51400. autoConfigure(): void;
  51401. initialize(state: NodeMaterialBuildState): void;
  51402. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51403. isReady(): boolean;
  51404. private _injectVertexCode;
  51405. protected _buildBlock(state: NodeMaterialBuildState): this;
  51406. }
  51407. }
  51408. declare module BABYLON {
  51409. /**
  51410. * Block used to add image processing support to fragment shader
  51411. */
  51412. export class ImageProcessingBlock extends NodeMaterialBlock {
  51413. /**
  51414. * Create a new ImageProcessingBlock
  51415. * @param name defines the block name
  51416. */
  51417. constructor(name: string);
  51418. /**
  51419. * Gets the current class name
  51420. * @returns the class name
  51421. */
  51422. getClassName(): string;
  51423. /**
  51424. * Gets the color input component
  51425. */
  51426. readonly color: NodeMaterialConnectionPoint;
  51427. /**
  51428. * Initialize the block and prepare the context for build
  51429. * @param state defines the state that will be used for the build
  51430. */
  51431. initialize(state: NodeMaterialBuildState): void;
  51432. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  51433. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51434. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51435. protected _buildBlock(state: NodeMaterialBuildState): this;
  51436. }
  51437. }
  51438. declare module BABYLON {
  51439. /**
  51440. * Block used to add support for scene fog
  51441. */
  51442. export class FogBlock extends NodeMaterialBlock {
  51443. /**
  51444. * Create a new FogBlock
  51445. * @param name defines the block name
  51446. */
  51447. constructor(name: string);
  51448. /**
  51449. * Gets the current class name
  51450. * @returns the class name
  51451. */
  51452. getClassName(): string;
  51453. /**
  51454. * Gets the world position input component
  51455. */
  51456. readonly worldPosition: NodeMaterialConnectionPoint;
  51457. /**
  51458. * Gets the view input component
  51459. */
  51460. readonly view: NodeMaterialConnectionPoint;
  51461. /**
  51462. * Gets the color input component
  51463. */
  51464. readonly color: NodeMaterialConnectionPoint;
  51465. /**
  51466. * Gets the fog color input component
  51467. */
  51468. readonly fogColor: NodeMaterialConnectionPoint;
  51469. /**
  51470. * Gets the for parameter input component
  51471. */
  51472. readonly fogParameters: NodeMaterialConnectionPoint;
  51473. autoConfigure(): void;
  51474. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51475. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51476. protected _buildBlock(state: NodeMaterialBuildState): this;
  51477. }
  51478. }
  51479. declare module BABYLON {
  51480. /**
  51481. * Block used to multiply 2 vector4
  51482. */
  51483. export class MultiplyBlock extends NodeMaterialBlock {
  51484. /**
  51485. * Creates a new MultiplyBlock
  51486. * @param name defines the block name
  51487. */
  51488. constructor(name: string);
  51489. /**
  51490. * Gets the current class name
  51491. * @returns the class name
  51492. */
  51493. getClassName(): string;
  51494. /**
  51495. * Gets the left operand input component
  51496. */
  51497. readonly left: NodeMaterialConnectionPoint;
  51498. /**
  51499. * Gets the right operand input component
  51500. */
  51501. readonly right: NodeMaterialConnectionPoint;
  51502. protected _buildBlock(state: NodeMaterialBuildState): this;
  51503. }
  51504. }
  51505. declare module BABYLON {
  51506. /**
  51507. * Block used to add 2 vector4
  51508. */
  51509. export class AddBlock extends NodeMaterialBlock {
  51510. /**
  51511. * Creates a new AddBlock
  51512. * @param name defines the block name
  51513. */
  51514. constructor(name: string);
  51515. /**
  51516. * Gets the current class name
  51517. * @returns the class name
  51518. */
  51519. getClassName(): string;
  51520. /**
  51521. * Gets the left operand input component
  51522. */
  51523. readonly left: NodeMaterialConnectionPoint;
  51524. /**
  51525. * Gets the right operand input component
  51526. */
  51527. readonly right: NodeMaterialConnectionPoint;
  51528. protected _buildBlock(state: NodeMaterialBuildState): this;
  51529. }
  51530. }
  51531. declare module BABYLON {
  51532. /**
  51533. * Block used to clamp a float
  51534. */
  51535. export class ClampBlock extends NodeMaterialBlock {
  51536. /** Gets or sets the minimum range */
  51537. minimum: number;
  51538. /** Gets or sets the maximum range */
  51539. maximum: number;
  51540. /**
  51541. * Creates a new ClampBlock
  51542. * @param name defines the block name
  51543. */
  51544. constructor(name: string);
  51545. /**
  51546. * Gets the current class name
  51547. * @returns the class name
  51548. */
  51549. getClassName(): string;
  51550. /**
  51551. * Gets the value input component
  51552. */
  51553. readonly value: NodeMaterialConnectionPoint;
  51554. protected _buildBlock(state: NodeMaterialBuildState): this;
  51555. }
  51556. }
  51557. declare module BABYLON {
  51558. /**
  51559. * Block used to transform a vector2 with a matrix
  51560. */
  51561. export class Vector2TransformBlock extends NodeMaterialBlock {
  51562. /**
  51563. * Defines the value to use to complement Vector2 to transform it to a Vector4
  51564. */
  51565. complementZ: number;
  51566. /**
  51567. * Defines the value to use to complement Vector2 to transform it to a Vector4
  51568. */
  51569. complementW: number;
  51570. /**
  51571. * Creates a new Vector2TransformBlock
  51572. * @param name defines the block name
  51573. */
  51574. constructor(name: string);
  51575. /**
  51576. * Gets the vector input
  51577. */
  51578. readonly vector: NodeMaterialConnectionPoint;
  51579. /**
  51580. * Gets the matrix transform input
  51581. */
  51582. readonly transform: NodeMaterialConnectionPoint;
  51583. /**
  51584. * Gets the current class name
  51585. * @returns the class name
  51586. */
  51587. getClassName(): string;
  51588. protected _buildBlock(state: NodeMaterialBuildState): this;
  51589. }
  51590. }
  51591. declare module BABYLON {
  51592. /**
  51593. * Block used to transform a vector3 with a matrix
  51594. */
  51595. export class Vector3TransformBlock extends NodeMaterialBlock {
  51596. /**
  51597. * Defines the value to use to complement Vector3 to transform it to a Vector4
  51598. */
  51599. complement: number;
  51600. /**
  51601. * Creates a new Vector3TransformBlock
  51602. * @param name defines the block name
  51603. */
  51604. constructor(name: string);
  51605. /**
  51606. * Gets the vector input
  51607. */
  51608. readonly vector: NodeMaterialConnectionPoint;
  51609. /**
  51610. * Gets the matrix transform input
  51611. */
  51612. readonly transform: NodeMaterialConnectionPoint;
  51613. /**
  51614. * Gets the current class name
  51615. * @returns the class name
  51616. */
  51617. getClassName(): string;
  51618. protected _buildBlock(state: NodeMaterialBuildState): this;
  51619. }
  51620. }
  51621. declare module BABYLON {
  51622. /**
  51623. * Block used to transform a vector4 with a matrix
  51624. */
  51625. export class Vector4TransformBlock extends NodeMaterialBlock {
  51626. /**
  51627. * Defines the value to use to complement Vector3 to transform it to a Vector4
  51628. */
  51629. complementW: number;
  51630. /**
  51631. * Creates a new Vector4TransformBlock
  51632. * @param name defines the block name
  51633. */
  51634. constructor(name: string);
  51635. /**
  51636. * Gets the current class name
  51637. * @returns the class name
  51638. */
  51639. getClassName(): string;
  51640. /**
  51641. * Gets the vector input
  51642. */
  51643. readonly vector: NodeMaterialConnectionPoint;
  51644. /**
  51645. * Gets the matrix transform input
  51646. */
  51647. readonly transform: NodeMaterialConnectionPoint;
  51648. protected _buildBlock(state: NodeMaterialBuildState): this;
  51649. }
  51650. }
  51651. declare module BABYLON {
  51652. /**
  51653. * Block used to multiply two matrices
  51654. */
  51655. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  51656. /**
  51657. * Creates a new MatrixMultiplicationBlock
  51658. * @param name defines the block name
  51659. */
  51660. constructor(name: string);
  51661. /**
  51662. * Gets the left operand
  51663. */
  51664. readonly left: NodeMaterialConnectionPoint;
  51665. /**
  51666. * Gets the right operand
  51667. */
  51668. readonly right: NodeMaterialConnectionPoint;
  51669. /**
  51670. * Gets the current class name
  51671. * @returns the class name
  51672. */
  51673. getClassName(): string;
  51674. protected _buildBlock(state: NodeMaterialBuildState): this;
  51675. }
  51676. }
  51677. declare module BABYLON {
  51678. /**
  51679. * Helper class to push actions to a pool of workers.
  51680. */
  51681. export class WorkerPool implements IDisposable {
  51682. private _workerInfos;
  51683. private _pendingActions;
  51684. /**
  51685. * Constructor
  51686. * @param workers Array of workers to use for actions
  51687. */
  51688. constructor(workers: Array<Worker>);
  51689. /**
  51690. * Terminates all workers and clears any pending actions.
  51691. */
  51692. dispose(): void;
  51693. /**
  51694. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51695. * pended until a worker has completed its action.
  51696. * @param action The action to perform. Call onComplete when the action is complete.
  51697. */
  51698. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51699. private _execute;
  51700. }
  51701. }
  51702. declare module BABYLON {
  51703. /**
  51704. * Configuration for Draco compression
  51705. */
  51706. export interface IDracoCompressionConfiguration {
  51707. /**
  51708. * Configuration for the decoder.
  51709. */
  51710. decoder: {
  51711. /**
  51712. * The url to the WebAssembly module.
  51713. */
  51714. wasmUrl?: string;
  51715. /**
  51716. * The url to the WebAssembly binary.
  51717. */
  51718. wasmBinaryUrl?: string;
  51719. /**
  51720. * The url to the fallback JavaScript module.
  51721. */
  51722. fallbackUrl?: string;
  51723. };
  51724. }
  51725. /**
  51726. * Draco compression (https://google.github.io/draco/)
  51727. *
  51728. * This class wraps the Draco module.
  51729. *
  51730. * **Encoder**
  51731. *
  51732. * The encoder is not currently implemented.
  51733. *
  51734. * **Decoder**
  51735. *
  51736. * 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.
  51737. *
  51738. * To update the configuration, use the following code:
  51739. * ```javascript
  51740. * DracoCompression.Configuration = {
  51741. * decoder: {
  51742. * wasmUrl: "<url to the WebAssembly library>",
  51743. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51744. * fallbackUrl: "<url to the fallback JavaScript library>",
  51745. * }
  51746. * };
  51747. * ```
  51748. *
  51749. * 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.
  51750. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51751. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  51752. *
  51753. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  51754. * ```javascript
  51755. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  51756. * ```
  51757. *
  51758. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51759. */
  51760. export class DracoCompression implements IDisposable {
  51761. private _workerPoolPromise?;
  51762. private _decoderModulePromise?;
  51763. /**
  51764. * The configuration. Defaults to the following urls:
  51765. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51766. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51767. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51768. */
  51769. static Configuration: IDracoCompressionConfiguration;
  51770. /**
  51771. * Returns true if the decoder configuration is available.
  51772. */
  51773. static readonly DecoderAvailable: boolean;
  51774. /**
  51775. * Default number of workers to create when creating the draco compression object.
  51776. */
  51777. static DefaultNumWorkers: number;
  51778. private static GetDefaultNumWorkers;
  51779. private static _Default;
  51780. /**
  51781. * Default instance for the draco compression object.
  51782. */
  51783. static readonly Default: DracoCompression;
  51784. /**
  51785. * Constructor
  51786. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  51787. */
  51788. constructor(numWorkers?: number);
  51789. /**
  51790. * Stop all async operations and release resources.
  51791. */
  51792. dispose(): void;
  51793. /**
  51794. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  51795. * @returns a promise that resolves when ready
  51796. */
  51797. whenReadyAsync(): Promise<void>;
  51798. /**
  51799. * Decode Draco compressed mesh data to vertex data.
  51800. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51801. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51802. * @returns A promise that resolves with the decoded vertex data
  51803. */
  51804. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  51805. [kind: string]: number;
  51806. }): Promise<VertexData>;
  51807. }
  51808. }
  51809. declare module BABYLON {
  51810. /**
  51811. * Class for building Constructive Solid Geometry
  51812. */
  51813. export class CSG {
  51814. private polygons;
  51815. /**
  51816. * The world matrix
  51817. */
  51818. matrix: Matrix;
  51819. /**
  51820. * Stores the position
  51821. */
  51822. position: Vector3;
  51823. /**
  51824. * Stores the rotation
  51825. */
  51826. rotation: Vector3;
  51827. /**
  51828. * Stores the rotation quaternion
  51829. */
  51830. rotationQuaternion: Nullable<Quaternion>;
  51831. /**
  51832. * Stores the scaling vector
  51833. */
  51834. scaling: Vector3;
  51835. /**
  51836. * Convert the Mesh to CSG
  51837. * @param mesh The Mesh to convert to CSG
  51838. * @returns A new CSG from the Mesh
  51839. */
  51840. static FromMesh(mesh: Mesh): CSG;
  51841. /**
  51842. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  51843. * @param polygons Polygons used to construct a CSG solid
  51844. */
  51845. private static FromPolygons;
  51846. /**
  51847. * Clones, or makes a deep copy, of the CSG
  51848. * @returns A new CSG
  51849. */
  51850. clone(): CSG;
  51851. /**
  51852. * Unions this CSG with another CSG
  51853. * @param csg The CSG to union against this CSG
  51854. * @returns The unioned CSG
  51855. */
  51856. union(csg: CSG): CSG;
  51857. /**
  51858. * Unions this CSG with another CSG in place
  51859. * @param csg The CSG to union against this CSG
  51860. */
  51861. unionInPlace(csg: CSG): void;
  51862. /**
  51863. * Subtracts this CSG with another CSG
  51864. * @param csg The CSG to subtract against this CSG
  51865. * @returns A new CSG
  51866. */
  51867. subtract(csg: CSG): CSG;
  51868. /**
  51869. * Subtracts this CSG with another CSG in place
  51870. * @param csg The CSG to subtact against this CSG
  51871. */
  51872. subtractInPlace(csg: CSG): void;
  51873. /**
  51874. * Intersect this CSG with another CSG
  51875. * @param csg The CSG to intersect against this CSG
  51876. * @returns A new CSG
  51877. */
  51878. intersect(csg: CSG): CSG;
  51879. /**
  51880. * Intersects this CSG with another CSG in place
  51881. * @param csg The CSG to intersect against this CSG
  51882. */
  51883. intersectInPlace(csg: CSG): void;
  51884. /**
  51885. * Return a new CSG solid with solid and empty space switched. This solid is
  51886. * not modified.
  51887. * @returns A new CSG solid with solid and empty space switched
  51888. */
  51889. inverse(): CSG;
  51890. /**
  51891. * Inverses the CSG in place
  51892. */
  51893. inverseInPlace(): void;
  51894. /**
  51895. * This is used to keep meshes transformations so they can be restored
  51896. * when we build back a Babylon Mesh
  51897. * NB : All CSG operations are performed in world coordinates
  51898. * @param csg The CSG to copy the transform attributes from
  51899. * @returns This CSG
  51900. */
  51901. copyTransformAttributes(csg: CSG): CSG;
  51902. /**
  51903. * Build Raw mesh from CSG
  51904. * Coordinates here are in world space
  51905. * @param name The name of the mesh geometry
  51906. * @param scene The Scene
  51907. * @param keepSubMeshes Specifies if the submeshes should be kept
  51908. * @returns A new Mesh
  51909. */
  51910. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  51911. /**
  51912. * Build Mesh from CSG taking material and transforms into account
  51913. * @param name The name of the Mesh
  51914. * @param material The material of the Mesh
  51915. * @param scene The Scene
  51916. * @param keepSubMeshes Specifies if submeshes should be kept
  51917. * @returns The new Mesh
  51918. */
  51919. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  51920. }
  51921. }
  51922. declare module BABYLON {
  51923. /**
  51924. * Class used to create a trail following a mesh
  51925. */
  51926. export class TrailMesh extends Mesh {
  51927. private _generator;
  51928. private _autoStart;
  51929. private _running;
  51930. private _diameter;
  51931. private _length;
  51932. private _sectionPolygonPointsCount;
  51933. private _sectionVectors;
  51934. private _sectionNormalVectors;
  51935. private _beforeRenderObserver;
  51936. /**
  51937. * @constructor
  51938. * @param name The value used by scene.getMeshByName() to do a lookup.
  51939. * @param generator The mesh to generate a trail.
  51940. * @param scene The scene to add this mesh to.
  51941. * @param diameter Diameter of trailing mesh. Default is 1.
  51942. * @param length Length of trailing mesh. Default is 60.
  51943. * @param autoStart Automatically start trailing mesh. Default true.
  51944. */
  51945. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  51946. /**
  51947. * "TrailMesh"
  51948. * @returns "TrailMesh"
  51949. */
  51950. getClassName(): string;
  51951. private _createMesh;
  51952. /**
  51953. * Start trailing mesh.
  51954. */
  51955. start(): void;
  51956. /**
  51957. * Stop trailing mesh.
  51958. */
  51959. stop(): void;
  51960. /**
  51961. * Update trailing mesh geometry.
  51962. */
  51963. update(): void;
  51964. /**
  51965. * Returns a new TrailMesh object.
  51966. * @param name is a string, the name given to the new mesh
  51967. * @param newGenerator use new generator object for cloned trail mesh
  51968. * @returns a new mesh
  51969. */
  51970. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  51971. /**
  51972. * Serializes this trail mesh
  51973. * @param serializationObject object to write serialization to
  51974. */
  51975. serialize(serializationObject: any): void;
  51976. /**
  51977. * Parses a serialized trail mesh
  51978. * @param parsedMesh the serialized mesh
  51979. * @param scene the scene to create the trail mesh in
  51980. * @returns the created trail mesh
  51981. */
  51982. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  51983. }
  51984. }
  51985. declare module BABYLON {
  51986. /**
  51987. * Class containing static functions to help procedurally build meshes
  51988. */
  51989. export class TiledBoxBuilder {
  51990. /**
  51991. * Creates a box mesh
  51992. * 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)
  51993. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51995. * * 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
  51996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51997. * @param name defines the name of the mesh
  51998. * @param options defines the options used to create the mesh
  51999. * @param scene defines the hosting scene
  52000. * @returns the box mesh
  52001. */
  52002. static CreateTiledBox(name: string, options: {
  52003. pattern?: number;
  52004. width?: number;
  52005. height?: number;
  52006. depth?: number;
  52007. tileSize?: number;
  52008. tileWidth?: number;
  52009. tileHeight?: number;
  52010. alignHorizontal?: number;
  52011. alignVertical?: number;
  52012. faceUV?: Vector4[];
  52013. faceColors?: Color4[];
  52014. sideOrientation?: number;
  52015. updatable?: boolean;
  52016. }, scene?: Nullable<Scene>): Mesh;
  52017. }
  52018. }
  52019. declare module BABYLON {
  52020. /**
  52021. * Class containing static functions to help procedurally build meshes
  52022. */
  52023. export class TorusKnotBuilder {
  52024. /**
  52025. * Creates a torus knot mesh
  52026. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52027. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52028. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52029. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52031. * * 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
  52032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52033. * @param name defines the name of the mesh
  52034. * @param options defines the options used to create the mesh
  52035. * @param scene defines the hosting scene
  52036. * @returns the torus knot mesh
  52037. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52038. */
  52039. static CreateTorusKnot(name: string, options: {
  52040. radius?: number;
  52041. tube?: number;
  52042. radialSegments?: number;
  52043. tubularSegments?: number;
  52044. p?: number;
  52045. q?: number;
  52046. updatable?: boolean;
  52047. sideOrientation?: number;
  52048. frontUVs?: Vector4;
  52049. backUVs?: Vector4;
  52050. }, scene: any): Mesh;
  52051. }
  52052. }
  52053. declare module BABYLON {
  52054. /**
  52055. * Polygon
  52056. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52057. */
  52058. export class Polygon {
  52059. /**
  52060. * Creates a rectangle
  52061. * @param xmin bottom X coord
  52062. * @param ymin bottom Y coord
  52063. * @param xmax top X coord
  52064. * @param ymax top Y coord
  52065. * @returns points that make the resulting rectation
  52066. */
  52067. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52068. /**
  52069. * Creates a circle
  52070. * @param radius radius of circle
  52071. * @param cx scale in x
  52072. * @param cy scale in y
  52073. * @param numberOfSides number of sides that make up the circle
  52074. * @returns points that make the resulting circle
  52075. */
  52076. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52077. /**
  52078. * Creates a polygon from input string
  52079. * @param input Input polygon data
  52080. * @returns the parsed points
  52081. */
  52082. static Parse(input: string): Vector2[];
  52083. /**
  52084. * Starts building a polygon from x and y coordinates
  52085. * @param x x coordinate
  52086. * @param y y coordinate
  52087. * @returns the started path2
  52088. */
  52089. static StartingAt(x: number, y: number): Path2;
  52090. }
  52091. /**
  52092. * Builds a polygon
  52093. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52094. */
  52095. export class PolygonMeshBuilder {
  52096. private _points;
  52097. private _outlinepoints;
  52098. private _holes;
  52099. private _name;
  52100. private _scene;
  52101. private _epoints;
  52102. private _eholes;
  52103. private _addToepoint;
  52104. /**
  52105. * Babylon reference to the earcut plugin.
  52106. */
  52107. bjsEarcut: any;
  52108. /**
  52109. * Creates a PolygonMeshBuilder
  52110. * @param name name of the builder
  52111. * @param contours Path of the polygon
  52112. * @param scene scene to add to when creating the mesh
  52113. * @param earcutInjection can be used to inject your own earcut reference
  52114. */
  52115. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52116. /**
  52117. * Adds a whole within the polygon
  52118. * @param hole Array of points defining the hole
  52119. * @returns this
  52120. */
  52121. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52122. /**
  52123. * Creates the polygon
  52124. * @param updatable If the mesh should be updatable
  52125. * @param depth The depth of the mesh created
  52126. * @returns the created mesh
  52127. */
  52128. build(updatable?: boolean, depth?: number): Mesh;
  52129. /**
  52130. * Creates the polygon
  52131. * @param depth The depth of the mesh created
  52132. * @returns the created VertexData
  52133. */
  52134. buildVertexData(depth?: number): VertexData;
  52135. /**
  52136. * Adds a side to the polygon
  52137. * @param positions points that make the polygon
  52138. * @param normals normals of the polygon
  52139. * @param uvs uvs of the polygon
  52140. * @param indices indices of the polygon
  52141. * @param bounds bounds of the polygon
  52142. * @param points points of the polygon
  52143. * @param depth depth of the polygon
  52144. * @param flip flip of the polygon
  52145. */
  52146. private addSide;
  52147. }
  52148. }
  52149. declare module BABYLON {
  52150. /**
  52151. * Class containing static functions to help procedurally build meshes
  52152. */
  52153. export class PolygonBuilder {
  52154. /**
  52155. * Creates a polygon mesh
  52156. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52157. * * 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
  52158. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52160. * * 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)
  52161. * * Remember you can only change the shape positions, not their number when updating a polygon
  52162. * @param name defines the name of the mesh
  52163. * @param options defines the options used to create the mesh
  52164. * @param scene defines the hosting scene
  52165. * @param earcutInjection can be used to inject your own earcut reference
  52166. * @returns the polygon mesh
  52167. */
  52168. static CreatePolygon(name: string, options: {
  52169. shape: Vector3[];
  52170. holes?: Vector3[][];
  52171. depth?: number;
  52172. faceUV?: Vector4[];
  52173. faceColors?: Color4[];
  52174. updatable?: boolean;
  52175. sideOrientation?: number;
  52176. frontUVs?: Vector4;
  52177. backUVs?: Vector4;
  52178. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52179. /**
  52180. * Creates an extruded polygon mesh, with depth in the Y direction.
  52181. * * 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)
  52182. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52183. * @param name defines the name of the mesh
  52184. * @param options defines the options used to create the mesh
  52185. * @param scene defines the hosting scene
  52186. * @param earcutInjection can be used to inject your own earcut reference
  52187. * @returns the polygon mesh
  52188. */
  52189. static ExtrudePolygon(name: string, options: {
  52190. shape: Vector3[];
  52191. holes?: Vector3[][];
  52192. depth?: number;
  52193. faceUV?: Vector4[];
  52194. faceColors?: Color4[];
  52195. updatable?: boolean;
  52196. sideOrientation?: number;
  52197. frontUVs?: Vector4;
  52198. backUVs?: Vector4;
  52199. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52200. }
  52201. }
  52202. declare module BABYLON {
  52203. /**
  52204. * Class containing static functions to help procedurally build meshes
  52205. */
  52206. export class LatheBuilder {
  52207. /**
  52208. * Creates lathe mesh.
  52209. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52210. * * 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
  52211. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52212. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52213. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52214. * * 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
  52215. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52216. * * 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
  52217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52218. * * 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
  52219. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52221. * @param name defines the name of the mesh
  52222. * @param options defines the options used to create the mesh
  52223. * @param scene defines the hosting scene
  52224. * @returns the lathe mesh
  52225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52226. */
  52227. static CreateLathe(name: string, options: {
  52228. shape: Vector3[];
  52229. radius?: number;
  52230. tessellation?: number;
  52231. clip?: number;
  52232. arc?: number;
  52233. closed?: boolean;
  52234. updatable?: boolean;
  52235. sideOrientation?: number;
  52236. frontUVs?: Vector4;
  52237. backUVs?: Vector4;
  52238. cap?: number;
  52239. invertUV?: boolean;
  52240. }, scene?: Nullable<Scene>): Mesh;
  52241. }
  52242. }
  52243. declare module BABYLON {
  52244. /**
  52245. * Class containing static functions to help procedurally build meshes
  52246. */
  52247. export class TiledPlaneBuilder {
  52248. /**
  52249. * Creates a tiled plane mesh
  52250. * * The parameter `pattern` will, depending on value, do nothing or
  52251. * * * flip (reflect about central vertical) alternate tiles across and up
  52252. * * * flip every tile on alternate rows
  52253. * * * rotate (180 degs) alternate tiles across and up
  52254. * * * rotate every tile on alternate rows
  52255. * * * flip and rotate alternate tiles across and up
  52256. * * * flip and rotate every tile on alternate rows
  52257. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  52258. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  52259. * * 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
  52260. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52261. * * 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)
  52262. * * 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)
  52263. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52264. * @param name defines the name of the mesh
  52265. * @param options defines the options used to create the mesh
  52266. * @param scene defines the hosting scene
  52267. * @returns the box mesh
  52268. */
  52269. static CreateTiledPlane(name: string, options: {
  52270. pattern?: number;
  52271. tileSize?: number;
  52272. tileWidth?: number;
  52273. tileHeight?: number;
  52274. size?: number;
  52275. width?: number;
  52276. height?: number;
  52277. alignHorizontal?: number;
  52278. alignVertical?: number;
  52279. sideOrientation?: number;
  52280. frontUVs?: Vector4;
  52281. backUVs?: Vector4;
  52282. updatable?: boolean;
  52283. }, scene?: Nullable<Scene>): Mesh;
  52284. }
  52285. }
  52286. declare module BABYLON {
  52287. /**
  52288. * Class containing static functions to help procedurally build meshes
  52289. */
  52290. export class TubeBuilder {
  52291. /**
  52292. * Creates a tube mesh.
  52293. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52294. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52295. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52296. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52297. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52298. * * 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)
  52299. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52300. * * 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
  52301. * * 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
  52302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52303. * * 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
  52304. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52306. * @param name defines the name of the mesh
  52307. * @param options defines the options used to create the mesh
  52308. * @param scene defines the hosting scene
  52309. * @returns the tube mesh
  52310. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52311. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52312. */
  52313. static CreateTube(name: string, options: {
  52314. path: Vector3[];
  52315. radius?: number;
  52316. tessellation?: number;
  52317. radiusFunction?: {
  52318. (i: number, distance: number): number;
  52319. };
  52320. cap?: number;
  52321. arc?: number;
  52322. updatable?: boolean;
  52323. sideOrientation?: number;
  52324. frontUVs?: Vector4;
  52325. backUVs?: Vector4;
  52326. instance?: Mesh;
  52327. invertUV?: boolean;
  52328. }, scene?: Nullable<Scene>): Mesh;
  52329. }
  52330. }
  52331. declare module BABYLON {
  52332. /**
  52333. * Class containing static functions to help procedurally build meshes
  52334. */
  52335. export class IcoSphereBuilder {
  52336. /**
  52337. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52338. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52339. * * 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`)
  52340. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52341. * * 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
  52342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52343. * * 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
  52344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52345. * @param name defines the name of the mesh
  52346. * @param options defines the options used to create the mesh
  52347. * @param scene defines the hosting scene
  52348. * @returns the icosahedron mesh
  52349. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52350. */
  52351. static CreateIcoSphere(name: string, options: {
  52352. radius?: number;
  52353. radiusX?: number;
  52354. radiusY?: number;
  52355. radiusZ?: number;
  52356. flat?: boolean;
  52357. subdivisions?: number;
  52358. sideOrientation?: number;
  52359. frontUVs?: Vector4;
  52360. backUVs?: Vector4;
  52361. updatable?: boolean;
  52362. }, scene?: Nullable<Scene>): Mesh;
  52363. }
  52364. }
  52365. declare module BABYLON {
  52366. /**
  52367. * Class containing static functions to help procedurally build meshes
  52368. */
  52369. export class DecalBuilder {
  52370. /**
  52371. * Creates a decal mesh.
  52372. * 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
  52373. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52374. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52375. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52376. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52377. * @param name defines the name of the mesh
  52378. * @param sourceMesh defines the mesh where the decal must be applied
  52379. * @param options defines the options used to create the mesh
  52380. * @param scene defines the hosting scene
  52381. * @returns the decal mesh
  52382. * @see https://doc.babylonjs.com/how_to/decals
  52383. */
  52384. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52385. position?: Vector3;
  52386. normal?: Vector3;
  52387. size?: Vector3;
  52388. angle?: number;
  52389. }): Mesh;
  52390. }
  52391. }
  52392. declare module BABYLON {
  52393. /**
  52394. * Class containing static functions to help procedurally build meshes
  52395. */
  52396. export class MeshBuilder {
  52397. /**
  52398. * Creates a box mesh
  52399. * * The parameter `size` sets the size (float) of each box side (default 1)
  52400. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52401. * * 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)
  52402. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52404. * * 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
  52405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52406. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52407. * @param name defines the name of the mesh
  52408. * @param options defines the options used to create the mesh
  52409. * @param scene defines the hosting scene
  52410. * @returns the box mesh
  52411. */
  52412. static CreateBox(name: string, options: {
  52413. size?: number;
  52414. width?: number;
  52415. height?: number;
  52416. depth?: number;
  52417. faceUV?: Vector4[];
  52418. faceColors?: Color4[];
  52419. sideOrientation?: number;
  52420. frontUVs?: Vector4;
  52421. backUVs?: Vector4;
  52422. updatable?: boolean;
  52423. }, scene?: Nullable<Scene>): Mesh;
  52424. /**
  52425. * Creates a tiled box mesh
  52426. * * faceTiles sets the pattern, tile size and number of tiles for a face
  52427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52428. * @param name defines the name of the mesh
  52429. * @param options defines the options used to create the mesh
  52430. * @param scene defines the hosting scene
  52431. * @returns the tiled box mesh
  52432. */
  52433. static CreateTiledBox(name: string, options: {
  52434. pattern?: number;
  52435. size?: number;
  52436. width?: number;
  52437. height?: number;
  52438. depth: number;
  52439. tileSize?: number;
  52440. tileWidth?: number;
  52441. tileHeight?: number;
  52442. faceUV?: Vector4[];
  52443. faceColors?: Color4[];
  52444. alignHorizontal?: number;
  52445. alignVertical?: number;
  52446. sideOrientation?: number;
  52447. updatable?: boolean;
  52448. }, scene?: Nullable<Scene>): Mesh;
  52449. /**
  52450. * Creates a sphere mesh
  52451. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52452. * * 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`)
  52453. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52454. * * 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
  52455. * * 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)
  52456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52457. * * 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
  52458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52459. * @param name defines the name of the mesh
  52460. * @param options defines the options used to create the mesh
  52461. * @param scene defines the hosting scene
  52462. * @returns the sphere mesh
  52463. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52464. */
  52465. static CreateSphere(name: string, options: {
  52466. segments?: number;
  52467. diameter?: number;
  52468. diameterX?: number;
  52469. diameterY?: number;
  52470. diameterZ?: number;
  52471. arc?: number;
  52472. slice?: number;
  52473. sideOrientation?: number;
  52474. frontUVs?: Vector4;
  52475. backUVs?: Vector4;
  52476. updatable?: boolean;
  52477. }, scene?: Nullable<Scene>): Mesh;
  52478. /**
  52479. * Creates a plane polygonal mesh. By default, this is a disc
  52480. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52481. * * 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
  52482. * * 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
  52483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52484. * * 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
  52485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52486. * @param name defines the name of the mesh
  52487. * @param options defines the options used to create the mesh
  52488. * @param scene defines the hosting scene
  52489. * @returns the plane polygonal mesh
  52490. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52491. */
  52492. static CreateDisc(name: string, options: {
  52493. radius?: number;
  52494. tessellation?: number;
  52495. arc?: number;
  52496. updatable?: boolean;
  52497. sideOrientation?: number;
  52498. frontUVs?: Vector4;
  52499. backUVs?: Vector4;
  52500. }, scene?: Nullable<Scene>): Mesh;
  52501. /**
  52502. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52503. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52504. * * 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`)
  52505. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52506. * * 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
  52507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52508. * * 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
  52509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52510. * @param name defines the name of the mesh
  52511. * @param options defines the options used to create the mesh
  52512. * @param scene defines the hosting scene
  52513. * @returns the icosahedron mesh
  52514. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52515. */
  52516. static CreateIcoSphere(name: string, options: {
  52517. radius?: number;
  52518. radiusX?: number;
  52519. radiusY?: number;
  52520. radiusZ?: number;
  52521. flat?: boolean;
  52522. subdivisions?: number;
  52523. sideOrientation?: number;
  52524. frontUVs?: Vector4;
  52525. backUVs?: Vector4;
  52526. updatable?: boolean;
  52527. }, scene?: Nullable<Scene>): Mesh;
  52528. /**
  52529. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52530. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52531. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52532. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52533. * * 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
  52534. * * 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
  52535. * * 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
  52536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52537. * * 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
  52538. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52539. * * 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
  52540. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52541. * * 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
  52542. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52544. * @param name defines the name of the mesh
  52545. * @param options defines the options used to create the mesh
  52546. * @param scene defines the hosting scene
  52547. * @returns the ribbon mesh
  52548. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52549. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52550. */
  52551. static CreateRibbon(name: string, options: {
  52552. pathArray: Vector3[][];
  52553. closeArray?: boolean;
  52554. closePath?: boolean;
  52555. offset?: number;
  52556. updatable?: boolean;
  52557. sideOrientation?: number;
  52558. frontUVs?: Vector4;
  52559. backUVs?: Vector4;
  52560. instance?: Mesh;
  52561. invertUV?: boolean;
  52562. uvs?: Vector2[];
  52563. colors?: Color4[];
  52564. }, scene?: Nullable<Scene>): Mesh;
  52565. /**
  52566. * Creates a cylinder or a cone mesh
  52567. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52568. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52569. * * 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.
  52570. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52571. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52572. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52573. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52574. * * 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).
  52575. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52576. * * 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).
  52577. * * 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
  52578. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52579. * * 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
  52580. * * 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.
  52581. * * If `enclose` is false, a ring surface is one element.
  52582. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52583. * * 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
  52584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52587. * @param name defines the name of the mesh
  52588. * @param options defines the options used to create the mesh
  52589. * @param scene defines the hosting scene
  52590. * @returns the cylinder mesh
  52591. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52592. */
  52593. static CreateCylinder(name: string, options: {
  52594. height?: number;
  52595. diameterTop?: number;
  52596. diameterBottom?: number;
  52597. diameter?: number;
  52598. tessellation?: number;
  52599. subdivisions?: number;
  52600. arc?: number;
  52601. faceColors?: Color4[];
  52602. faceUV?: Vector4[];
  52603. updatable?: boolean;
  52604. hasRings?: boolean;
  52605. enclose?: boolean;
  52606. cap?: number;
  52607. sideOrientation?: number;
  52608. frontUVs?: Vector4;
  52609. backUVs?: Vector4;
  52610. }, scene?: Nullable<Scene>): Mesh;
  52611. /**
  52612. * Creates a torus mesh
  52613. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52614. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52615. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52617. * * 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
  52618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52619. * @param name defines the name of the mesh
  52620. * @param options defines the options used to create the mesh
  52621. * @param scene defines the hosting scene
  52622. * @returns the torus mesh
  52623. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52624. */
  52625. static CreateTorus(name: string, options: {
  52626. diameter?: number;
  52627. thickness?: number;
  52628. tessellation?: number;
  52629. updatable?: boolean;
  52630. sideOrientation?: number;
  52631. frontUVs?: Vector4;
  52632. backUVs?: Vector4;
  52633. }, scene?: Nullable<Scene>): Mesh;
  52634. /**
  52635. * Creates a torus knot mesh
  52636. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52637. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52638. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52639. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52641. * * 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
  52642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52643. * @param name defines the name of the mesh
  52644. * @param options defines the options used to create the mesh
  52645. * @param scene defines the hosting scene
  52646. * @returns the torus knot mesh
  52647. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52648. */
  52649. static CreateTorusKnot(name: string, options: {
  52650. radius?: number;
  52651. tube?: number;
  52652. radialSegments?: number;
  52653. tubularSegments?: number;
  52654. p?: number;
  52655. q?: number;
  52656. updatable?: boolean;
  52657. sideOrientation?: number;
  52658. frontUVs?: Vector4;
  52659. backUVs?: Vector4;
  52660. }, scene?: Nullable<Scene>): Mesh;
  52661. /**
  52662. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52663. * * 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
  52664. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52665. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52666. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52667. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52668. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52669. * * 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
  52670. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52672. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52673. * @param name defines the name of the new line system
  52674. * @param options defines the options used to create the line system
  52675. * @param scene defines the hosting scene
  52676. * @returns a new line system mesh
  52677. */
  52678. static CreateLineSystem(name: string, options: {
  52679. lines: Vector3[][];
  52680. updatable?: boolean;
  52681. instance?: Nullable<LinesMesh>;
  52682. colors?: Nullable<Color4[][]>;
  52683. useVertexAlpha?: boolean;
  52684. }, scene: Nullable<Scene>): LinesMesh;
  52685. /**
  52686. * Creates a line mesh
  52687. * 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
  52688. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52689. * * The parameter `points` is an array successive Vector3
  52690. * * 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
  52691. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52692. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52693. * * When updating an instance, remember that only point positions can change, not the number of points
  52694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52695. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52696. * @param name defines the name of the new line system
  52697. * @param options defines the options used to create the line system
  52698. * @param scene defines the hosting scene
  52699. * @returns a new line mesh
  52700. */
  52701. static CreateLines(name: string, options: {
  52702. points: Vector3[];
  52703. updatable?: boolean;
  52704. instance?: Nullable<LinesMesh>;
  52705. colors?: Color4[];
  52706. useVertexAlpha?: boolean;
  52707. }, scene?: Nullable<Scene>): LinesMesh;
  52708. /**
  52709. * Creates a dashed line mesh
  52710. * * 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
  52711. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52712. * * The parameter `points` is an array successive Vector3
  52713. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52714. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52715. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52716. * * 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
  52717. * * When updating an instance, remember that only point positions can change, not the number of points
  52718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52719. * @param name defines the name of the mesh
  52720. * @param options defines the options used to create the mesh
  52721. * @param scene defines the hosting scene
  52722. * @returns the dashed line mesh
  52723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52724. */
  52725. static CreateDashedLines(name: string, options: {
  52726. points: Vector3[];
  52727. dashSize?: number;
  52728. gapSize?: number;
  52729. dashNb?: number;
  52730. updatable?: boolean;
  52731. instance?: LinesMesh;
  52732. }, scene?: Nullable<Scene>): LinesMesh;
  52733. /**
  52734. * 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.
  52735. * * 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.
  52736. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52737. * * 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.
  52738. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52739. * * 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
  52740. * * 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
  52741. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52743. * * 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
  52744. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52746. * @param name defines the name of the mesh
  52747. * @param options defines the options used to create the mesh
  52748. * @param scene defines the hosting scene
  52749. * @returns the extruded shape mesh
  52750. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52751. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52752. */
  52753. static ExtrudeShape(name: string, options: {
  52754. shape: Vector3[];
  52755. path: Vector3[];
  52756. scale?: number;
  52757. rotation?: number;
  52758. cap?: number;
  52759. updatable?: boolean;
  52760. sideOrientation?: number;
  52761. frontUVs?: Vector4;
  52762. backUVs?: Vector4;
  52763. instance?: Mesh;
  52764. invertUV?: boolean;
  52765. }, scene?: Nullable<Scene>): Mesh;
  52766. /**
  52767. * Creates an custom extruded shape mesh.
  52768. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52769. * * 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.
  52770. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52771. * * 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
  52772. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52773. * * 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
  52774. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52775. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52776. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52777. * * 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
  52778. * * 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
  52779. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52781. * * 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
  52782. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52784. * @param name defines the name of the mesh
  52785. * @param options defines the options used to create the mesh
  52786. * @param scene defines the hosting scene
  52787. * @returns the custom extruded shape mesh
  52788. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52789. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52790. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52791. */
  52792. static ExtrudeShapeCustom(name: string, options: {
  52793. shape: Vector3[];
  52794. path: Vector3[];
  52795. scaleFunction?: any;
  52796. rotationFunction?: any;
  52797. ribbonCloseArray?: boolean;
  52798. ribbonClosePath?: boolean;
  52799. cap?: number;
  52800. updatable?: boolean;
  52801. sideOrientation?: number;
  52802. frontUVs?: Vector4;
  52803. backUVs?: Vector4;
  52804. instance?: Mesh;
  52805. invertUV?: boolean;
  52806. }, scene?: Nullable<Scene>): Mesh;
  52807. /**
  52808. * Creates lathe mesh.
  52809. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52810. * * 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
  52811. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52812. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52813. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52814. * * 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
  52815. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52816. * * 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
  52817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52818. * * 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
  52819. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52821. * @param name defines the name of the mesh
  52822. * @param options defines the options used to create the mesh
  52823. * @param scene defines the hosting scene
  52824. * @returns the lathe mesh
  52825. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52826. */
  52827. static CreateLathe(name: string, options: {
  52828. shape: Vector3[];
  52829. radius?: number;
  52830. tessellation?: number;
  52831. clip?: number;
  52832. arc?: number;
  52833. closed?: boolean;
  52834. updatable?: boolean;
  52835. sideOrientation?: number;
  52836. frontUVs?: Vector4;
  52837. backUVs?: Vector4;
  52838. cap?: number;
  52839. invertUV?: boolean;
  52840. }, scene?: Nullable<Scene>): Mesh;
  52841. /**
  52842. * Creates a tiled plane mesh
  52843. * * You can set a limited pattern arrangement with the tiles
  52844. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52845. * * 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
  52846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52847. * @param name defines the name of the mesh
  52848. * @param options defines the options used to create the mesh
  52849. * @param scene defines the hosting scene
  52850. * @returns the plane mesh
  52851. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52852. */
  52853. static CreateTiledPlane(name: string, options: {
  52854. pattern?: number;
  52855. tileSize?: number;
  52856. tileWidth?: number;
  52857. tileHeight?: number;
  52858. size?: number;
  52859. width?: number;
  52860. height?: number;
  52861. alignHorizontal?: number;
  52862. alignVertical?: number;
  52863. sideOrientation?: number;
  52864. frontUVs?: Vector4;
  52865. backUVs?: Vector4;
  52866. updatable?: boolean;
  52867. }, scene?: Nullable<Scene>): Mesh;
  52868. /**
  52869. * Creates a plane mesh
  52870. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52871. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52872. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52874. * * 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
  52875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52876. * @param name defines the name of the mesh
  52877. * @param options defines the options used to create the mesh
  52878. * @param scene defines the hosting scene
  52879. * @returns the plane mesh
  52880. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52881. */
  52882. static CreatePlane(name: string, options: {
  52883. size?: number;
  52884. width?: number;
  52885. height?: number;
  52886. sideOrientation?: number;
  52887. frontUVs?: Vector4;
  52888. backUVs?: Vector4;
  52889. updatable?: boolean;
  52890. sourcePlane?: Plane;
  52891. }, scene?: Nullable<Scene>): Mesh;
  52892. /**
  52893. * Creates a ground mesh
  52894. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52895. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52897. * @param name defines the name of the mesh
  52898. * @param options defines the options used to create the mesh
  52899. * @param scene defines the hosting scene
  52900. * @returns the ground mesh
  52901. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52902. */
  52903. static CreateGround(name: string, options: {
  52904. width?: number;
  52905. height?: number;
  52906. subdivisions?: number;
  52907. subdivisionsX?: number;
  52908. subdivisionsY?: number;
  52909. updatable?: boolean;
  52910. }, scene?: Nullable<Scene>): Mesh;
  52911. /**
  52912. * Creates a tiled ground mesh
  52913. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52914. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52915. * * 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
  52916. * * 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
  52917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52918. * @param name defines the name of the mesh
  52919. * @param options defines the options used to create the mesh
  52920. * @param scene defines the hosting scene
  52921. * @returns the tiled ground mesh
  52922. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52923. */
  52924. static CreateTiledGround(name: string, options: {
  52925. xmin: number;
  52926. zmin: number;
  52927. xmax: number;
  52928. zmax: number;
  52929. subdivisions?: {
  52930. w: number;
  52931. h: number;
  52932. };
  52933. precision?: {
  52934. w: number;
  52935. h: number;
  52936. };
  52937. updatable?: boolean;
  52938. }, scene?: Nullable<Scene>): Mesh;
  52939. /**
  52940. * Creates a ground mesh from a height map
  52941. * * The parameter `url` sets the URL of the height map image resource.
  52942. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52943. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52944. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52945. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52946. * * 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.
  52947. * * 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).
  52948. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52950. * @param name defines the name of the mesh
  52951. * @param url defines the url to the height map
  52952. * @param options defines the options used to create the mesh
  52953. * @param scene defines the hosting scene
  52954. * @returns the ground mesh
  52955. * @see https://doc.babylonjs.com/babylon101/height_map
  52956. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52957. */
  52958. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52959. width?: number;
  52960. height?: number;
  52961. subdivisions?: number;
  52962. minHeight?: number;
  52963. maxHeight?: number;
  52964. colorFilter?: Color3;
  52965. alphaFilter?: number;
  52966. updatable?: boolean;
  52967. onReady?: (mesh: GroundMesh) => void;
  52968. }, scene?: Nullable<Scene>): GroundMesh;
  52969. /**
  52970. * Creates a polygon mesh
  52971. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52972. * * 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
  52973. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52975. * * 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)
  52976. * * Remember you can only change the shape positions, not their number when updating a polygon
  52977. * @param name defines the name of the mesh
  52978. * @param options defines the options used to create the mesh
  52979. * @param scene defines the hosting scene
  52980. * @param earcutInjection can be used to inject your own earcut reference
  52981. * @returns the polygon mesh
  52982. */
  52983. static CreatePolygon(name: string, options: {
  52984. shape: Vector3[];
  52985. holes?: Vector3[][];
  52986. depth?: number;
  52987. faceUV?: Vector4[];
  52988. faceColors?: Color4[];
  52989. updatable?: boolean;
  52990. sideOrientation?: number;
  52991. frontUVs?: Vector4;
  52992. backUVs?: Vector4;
  52993. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52994. /**
  52995. * Creates an extruded polygon mesh, with depth in the Y direction.
  52996. * * 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)
  52997. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52998. * @param name defines the name of the mesh
  52999. * @param options defines the options used to create the mesh
  53000. * @param scene defines the hosting scene
  53001. * @param earcutInjection can be used to inject your own earcut reference
  53002. * @returns the polygon mesh
  53003. */
  53004. static ExtrudePolygon(name: string, options: {
  53005. shape: Vector3[];
  53006. holes?: Vector3[][];
  53007. depth?: number;
  53008. faceUV?: Vector4[];
  53009. faceColors?: Color4[];
  53010. updatable?: boolean;
  53011. sideOrientation?: number;
  53012. frontUVs?: Vector4;
  53013. backUVs?: Vector4;
  53014. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53015. /**
  53016. * Creates a tube mesh.
  53017. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53018. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53019. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53020. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53021. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53022. * * 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)
  53023. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53024. * * 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
  53025. * * 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
  53026. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53027. * * 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
  53028. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53030. * @param name defines the name of the mesh
  53031. * @param options defines the options used to create the mesh
  53032. * @param scene defines the hosting scene
  53033. * @returns the tube mesh
  53034. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53035. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53036. */
  53037. static CreateTube(name: string, options: {
  53038. path: Vector3[];
  53039. radius?: number;
  53040. tessellation?: number;
  53041. radiusFunction?: {
  53042. (i: number, distance: number): number;
  53043. };
  53044. cap?: number;
  53045. arc?: number;
  53046. updatable?: boolean;
  53047. sideOrientation?: number;
  53048. frontUVs?: Vector4;
  53049. backUVs?: Vector4;
  53050. instance?: Mesh;
  53051. invertUV?: boolean;
  53052. }, scene?: Nullable<Scene>): Mesh;
  53053. /**
  53054. * Creates a polyhedron mesh
  53055. * * 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
  53056. * * The parameter `size` (positive float, default 1) sets the polygon size
  53057. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53058. * * 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`
  53059. * * 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
  53060. * * 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)`)
  53061. * * 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
  53062. * * 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
  53063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53064. * * 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
  53065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53066. * @param name defines the name of the mesh
  53067. * @param options defines the options used to create the mesh
  53068. * @param scene defines the hosting scene
  53069. * @returns the polyhedron mesh
  53070. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53071. */
  53072. static CreatePolyhedron(name: string, options: {
  53073. type?: number;
  53074. size?: number;
  53075. sizeX?: number;
  53076. sizeY?: number;
  53077. sizeZ?: number;
  53078. custom?: any;
  53079. faceUV?: Vector4[];
  53080. faceColors?: Color4[];
  53081. flat?: boolean;
  53082. updatable?: boolean;
  53083. sideOrientation?: number;
  53084. frontUVs?: Vector4;
  53085. backUVs?: Vector4;
  53086. }, scene?: Nullable<Scene>): Mesh;
  53087. /**
  53088. * Creates a decal mesh.
  53089. * 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
  53090. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53091. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53092. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53093. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53094. * @param name defines the name of the mesh
  53095. * @param sourceMesh defines the mesh where the decal must be applied
  53096. * @param options defines the options used to create the mesh
  53097. * @param scene defines the hosting scene
  53098. * @returns the decal mesh
  53099. * @see https://doc.babylonjs.com/how_to/decals
  53100. */
  53101. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53102. position?: Vector3;
  53103. normal?: Vector3;
  53104. size?: Vector3;
  53105. angle?: number;
  53106. }): Mesh;
  53107. }
  53108. }
  53109. declare module BABYLON {
  53110. /**
  53111. * A simplifier interface for future simplification implementations
  53112. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53113. */
  53114. export interface ISimplifier {
  53115. /**
  53116. * Simplification of a given mesh according to the given settings.
  53117. * Since this requires computation, it is assumed that the function runs async.
  53118. * @param settings The settings of the simplification, including quality and distance
  53119. * @param successCallback A callback that will be called after the mesh was simplified.
  53120. * @param errorCallback in case of an error, this callback will be called. optional.
  53121. */
  53122. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53123. }
  53124. /**
  53125. * Expected simplification settings.
  53126. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53127. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53128. */
  53129. export interface ISimplificationSettings {
  53130. /**
  53131. * Gets or sets the expected quality
  53132. */
  53133. quality: number;
  53134. /**
  53135. * Gets or sets the distance when this optimized version should be used
  53136. */
  53137. distance: number;
  53138. /**
  53139. * Gets an already optimized mesh
  53140. */
  53141. optimizeMesh?: boolean;
  53142. }
  53143. /**
  53144. * Class used to specify simplification options
  53145. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53146. */
  53147. export class SimplificationSettings implements ISimplificationSettings {
  53148. /** expected quality */
  53149. quality: number;
  53150. /** distance when this optimized version should be used */
  53151. distance: number;
  53152. /** already optimized mesh */
  53153. optimizeMesh?: boolean | undefined;
  53154. /**
  53155. * Creates a SimplificationSettings
  53156. * @param quality expected quality
  53157. * @param distance distance when this optimized version should be used
  53158. * @param optimizeMesh already optimized mesh
  53159. */
  53160. constructor(
  53161. /** expected quality */
  53162. quality: number,
  53163. /** distance when this optimized version should be used */
  53164. distance: number,
  53165. /** already optimized mesh */
  53166. optimizeMesh?: boolean | undefined);
  53167. }
  53168. /**
  53169. * Interface used to define a simplification task
  53170. */
  53171. export interface ISimplificationTask {
  53172. /**
  53173. * Array of settings
  53174. */
  53175. settings: Array<ISimplificationSettings>;
  53176. /**
  53177. * Simplification type
  53178. */
  53179. simplificationType: SimplificationType;
  53180. /**
  53181. * Mesh to simplify
  53182. */
  53183. mesh: Mesh;
  53184. /**
  53185. * Callback called on success
  53186. */
  53187. successCallback?: () => void;
  53188. /**
  53189. * Defines if parallel processing can be used
  53190. */
  53191. parallelProcessing: boolean;
  53192. }
  53193. /**
  53194. * Queue used to order the simplification tasks
  53195. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53196. */
  53197. export class SimplificationQueue {
  53198. private _simplificationArray;
  53199. /**
  53200. * Gets a boolean indicating that the process is still running
  53201. */
  53202. running: boolean;
  53203. /**
  53204. * Creates a new queue
  53205. */
  53206. constructor();
  53207. /**
  53208. * Adds a new simplification task
  53209. * @param task defines a task to add
  53210. */
  53211. addTask(task: ISimplificationTask): void;
  53212. /**
  53213. * Execute next task
  53214. */
  53215. executeNext(): void;
  53216. /**
  53217. * Execute a simplification task
  53218. * @param task defines the task to run
  53219. */
  53220. runSimplification(task: ISimplificationTask): void;
  53221. private getSimplifier;
  53222. }
  53223. /**
  53224. * The implemented types of simplification
  53225. * At the moment only Quadratic Error Decimation is implemented
  53226. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53227. */
  53228. export enum SimplificationType {
  53229. /** Quadratic error decimation */
  53230. QUADRATIC = 0
  53231. }
  53232. }
  53233. declare module BABYLON {
  53234. interface Scene {
  53235. /** @hidden (Backing field) */
  53236. _simplificationQueue: SimplificationQueue;
  53237. /**
  53238. * Gets or sets the simplification queue attached to the scene
  53239. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53240. */
  53241. simplificationQueue: SimplificationQueue;
  53242. }
  53243. interface Mesh {
  53244. /**
  53245. * Simplify the mesh according to the given array of settings.
  53246. * Function will return immediately and will simplify async
  53247. * @param settings a collection of simplification settings
  53248. * @param parallelProcessing should all levels calculate parallel or one after the other
  53249. * @param simplificationType the type of simplification to run
  53250. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53251. * @returns the current mesh
  53252. */
  53253. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53254. }
  53255. /**
  53256. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53257. * created in a scene
  53258. */
  53259. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53260. /**
  53261. * The component name helpfull to identify the component in the list of scene components.
  53262. */
  53263. readonly name: string;
  53264. /**
  53265. * The scene the component belongs to.
  53266. */
  53267. scene: Scene;
  53268. /**
  53269. * Creates a new instance of the component for the given scene
  53270. * @param scene Defines the scene to register the component in
  53271. */
  53272. constructor(scene: Scene);
  53273. /**
  53274. * Registers the component in a given scene
  53275. */
  53276. register(): void;
  53277. /**
  53278. * Rebuilds the elements related to this component in case of
  53279. * context lost for instance.
  53280. */
  53281. rebuild(): void;
  53282. /**
  53283. * Disposes the component and the associated ressources
  53284. */
  53285. dispose(): void;
  53286. private _beforeCameraUpdate;
  53287. }
  53288. }
  53289. declare module BABYLON {
  53290. /**
  53291. * Class used to enable access to IndexedDB
  53292. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53293. */
  53294. export class Database implements IOfflineProvider {
  53295. private _callbackManifestChecked;
  53296. private _currentSceneUrl;
  53297. private _db;
  53298. private _enableSceneOffline;
  53299. private _enableTexturesOffline;
  53300. private _manifestVersionFound;
  53301. private _mustUpdateRessources;
  53302. private _hasReachedQuota;
  53303. private _isSupported;
  53304. private _idbFactory;
  53305. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53306. private static IsUASupportingBlobStorage;
  53307. /**
  53308. * Gets a boolean indicating if Database storate is enabled (off by default)
  53309. */
  53310. static IDBStorageEnabled: boolean;
  53311. /**
  53312. * Gets a boolean indicating if scene must be saved in the database
  53313. */
  53314. readonly enableSceneOffline: boolean;
  53315. /**
  53316. * Gets a boolean indicating if textures must be saved in the database
  53317. */
  53318. readonly enableTexturesOffline: boolean;
  53319. /**
  53320. * Creates a new Database
  53321. * @param urlToScene defines the url to load the scene
  53322. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53323. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53324. */
  53325. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53326. private static _ParseURL;
  53327. private static _ReturnFullUrlLocation;
  53328. private _checkManifestFile;
  53329. /**
  53330. * Open the database and make it available
  53331. * @param successCallback defines the callback to call on success
  53332. * @param errorCallback defines the callback to call on error
  53333. */
  53334. open(successCallback: () => void, errorCallback: () => void): void;
  53335. /**
  53336. * Loads an image from the database
  53337. * @param url defines the url to load from
  53338. * @param image defines the target DOM image
  53339. */
  53340. loadImage(url: string, image: HTMLImageElement): void;
  53341. private _loadImageFromDBAsync;
  53342. private _saveImageIntoDBAsync;
  53343. private _checkVersionFromDB;
  53344. private _loadVersionFromDBAsync;
  53345. private _saveVersionIntoDBAsync;
  53346. /**
  53347. * Loads a file from database
  53348. * @param url defines the URL to load from
  53349. * @param sceneLoaded defines a callback to call on success
  53350. * @param progressCallBack defines a callback to call when progress changed
  53351. * @param errorCallback defines a callback to call on error
  53352. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53353. */
  53354. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53355. private _loadFileAsync;
  53356. private _saveFileAsync;
  53357. /**
  53358. * Validates if xhr data is correct
  53359. * @param xhr defines the request to validate
  53360. * @param dataType defines the expected data type
  53361. * @returns true if data is correct
  53362. */
  53363. private static _ValidateXHRData;
  53364. }
  53365. }
  53366. declare module BABYLON {
  53367. /** @hidden */
  53368. export var gpuUpdateParticlesPixelShader: {
  53369. name: string;
  53370. shader: string;
  53371. };
  53372. }
  53373. declare module BABYLON {
  53374. /** @hidden */
  53375. export var gpuUpdateParticlesVertexShader: {
  53376. name: string;
  53377. shader: string;
  53378. };
  53379. }
  53380. declare module BABYLON {
  53381. /** @hidden */
  53382. export var clipPlaneFragmentDeclaration2: {
  53383. name: string;
  53384. shader: string;
  53385. };
  53386. }
  53387. declare module BABYLON {
  53388. /** @hidden */
  53389. export var gpuRenderParticlesPixelShader: {
  53390. name: string;
  53391. shader: string;
  53392. };
  53393. }
  53394. declare module BABYLON {
  53395. /** @hidden */
  53396. export var clipPlaneVertexDeclaration2: {
  53397. name: string;
  53398. shader: string;
  53399. };
  53400. }
  53401. declare module BABYLON {
  53402. /** @hidden */
  53403. export var gpuRenderParticlesVertexShader: {
  53404. name: string;
  53405. shader: string;
  53406. };
  53407. }
  53408. declare module BABYLON {
  53409. /**
  53410. * This represents a GPU particle system in Babylon
  53411. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53412. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53413. */
  53414. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53415. /**
  53416. * The layer mask we are rendering the particles through.
  53417. */
  53418. layerMask: number;
  53419. private _capacity;
  53420. private _activeCount;
  53421. private _currentActiveCount;
  53422. private _accumulatedCount;
  53423. private _renderEffect;
  53424. private _updateEffect;
  53425. private _buffer0;
  53426. private _buffer1;
  53427. private _spriteBuffer;
  53428. private _updateVAO;
  53429. private _renderVAO;
  53430. private _targetIndex;
  53431. private _sourceBuffer;
  53432. private _targetBuffer;
  53433. private _engine;
  53434. private _currentRenderId;
  53435. private _started;
  53436. private _stopped;
  53437. private _timeDelta;
  53438. private _randomTexture;
  53439. private _randomTexture2;
  53440. private _attributesStrideSize;
  53441. private _updateEffectOptions;
  53442. private _randomTextureSize;
  53443. private _actualFrame;
  53444. private readonly _rawTextureWidth;
  53445. /**
  53446. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53447. */
  53448. static readonly IsSupported: boolean;
  53449. /**
  53450. * An event triggered when the system is disposed.
  53451. */
  53452. onDisposeObservable: Observable<GPUParticleSystem>;
  53453. /**
  53454. * Gets the maximum number of particles active at the same time.
  53455. * @returns The max number of active particles.
  53456. */
  53457. getCapacity(): number;
  53458. /**
  53459. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53460. * to override the particles.
  53461. */
  53462. forceDepthWrite: boolean;
  53463. /**
  53464. * Gets or set the number of active particles
  53465. */
  53466. activeParticleCount: number;
  53467. private _preWarmDone;
  53468. /**
  53469. * Is this system ready to be used/rendered
  53470. * @return true if the system is ready
  53471. */
  53472. isReady(): boolean;
  53473. /**
  53474. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53475. * @returns True if it has been started, otherwise false.
  53476. */
  53477. isStarted(): boolean;
  53478. /**
  53479. * Starts the particle system and begins to emit
  53480. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53481. */
  53482. start(delay?: number): void;
  53483. /**
  53484. * Stops the particle system.
  53485. */
  53486. stop(): void;
  53487. /**
  53488. * Remove all active particles
  53489. */
  53490. reset(): void;
  53491. /**
  53492. * Returns the string "GPUParticleSystem"
  53493. * @returns a string containing the class name
  53494. */
  53495. getClassName(): string;
  53496. private _colorGradientsTexture;
  53497. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53498. /**
  53499. * Adds a new color gradient
  53500. * @param gradient defines the gradient to use (between 0 and 1)
  53501. * @param color1 defines the color to affect to the specified gradient
  53502. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53503. * @returns the current particle system
  53504. */
  53505. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53506. /**
  53507. * Remove a specific color gradient
  53508. * @param gradient defines the gradient to remove
  53509. * @returns the current particle system
  53510. */
  53511. removeColorGradient(gradient: number): GPUParticleSystem;
  53512. private _angularSpeedGradientsTexture;
  53513. private _sizeGradientsTexture;
  53514. private _velocityGradientsTexture;
  53515. private _limitVelocityGradientsTexture;
  53516. private _dragGradientsTexture;
  53517. private _addFactorGradient;
  53518. /**
  53519. * Adds a new size gradient
  53520. * @param gradient defines the gradient to use (between 0 and 1)
  53521. * @param factor defines the size factor to affect to the specified gradient
  53522. * @returns the current particle system
  53523. */
  53524. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53525. /**
  53526. * Remove a specific size gradient
  53527. * @param gradient defines the gradient to remove
  53528. * @returns the current particle system
  53529. */
  53530. removeSizeGradient(gradient: number): GPUParticleSystem;
  53531. /**
  53532. * Adds a new angular speed gradient
  53533. * @param gradient defines the gradient to use (between 0 and 1)
  53534. * @param factor defines the angular speed to affect to the specified gradient
  53535. * @returns the current particle system
  53536. */
  53537. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53538. /**
  53539. * Remove a specific angular speed gradient
  53540. * @param gradient defines the gradient to remove
  53541. * @returns the current particle system
  53542. */
  53543. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53544. /**
  53545. * Adds a new velocity gradient
  53546. * @param gradient defines the gradient to use (between 0 and 1)
  53547. * @param factor defines the velocity to affect to the specified gradient
  53548. * @returns the current particle system
  53549. */
  53550. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53551. /**
  53552. * Remove a specific velocity gradient
  53553. * @param gradient defines the gradient to remove
  53554. * @returns the current particle system
  53555. */
  53556. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53557. /**
  53558. * Adds a new limit velocity gradient
  53559. * @param gradient defines the gradient to use (between 0 and 1)
  53560. * @param factor defines the limit velocity value to affect to the specified gradient
  53561. * @returns the current particle system
  53562. */
  53563. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53564. /**
  53565. * Remove a specific limit velocity gradient
  53566. * @param gradient defines the gradient to remove
  53567. * @returns the current particle system
  53568. */
  53569. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53570. /**
  53571. * Adds a new drag gradient
  53572. * @param gradient defines the gradient to use (between 0 and 1)
  53573. * @param factor defines the drag value to affect to the specified gradient
  53574. * @returns the current particle system
  53575. */
  53576. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53577. /**
  53578. * Remove a specific drag gradient
  53579. * @param gradient defines the gradient to remove
  53580. * @returns the current particle system
  53581. */
  53582. removeDragGradient(gradient: number): GPUParticleSystem;
  53583. /**
  53584. * Not supported by GPUParticleSystem
  53585. * @param gradient defines the gradient to use (between 0 and 1)
  53586. * @param factor defines the emit rate value to affect to the specified gradient
  53587. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53588. * @returns the current particle system
  53589. */
  53590. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53591. /**
  53592. * Not supported by GPUParticleSystem
  53593. * @param gradient defines the gradient to remove
  53594. * @returns the current particle system
  53595. */
  53596. removeEmitRateGradient(gradient: number): IParticleSystem;
  53597. /**
  53598. * Not supported by GPUParticleSystem
  53599. * @param gradient defines the gradient to use (between 0 and 1)
  53600. * @param factor defines the start size value to affect to the specified gradient
  53601. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53602. * @returns the current particle system
  53603. */
  53604. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53605. /**
  53606. * Not supported by GPUParticleSystem
  53607. * @param gradient defines the gradient to remove
  53608. * @returns the current particle system
  53609. */
  53610. removeStartSizeGradient(gradient: number): IParticleSystem;
  53611. /**
  53612. * Not supported by GPUParticleSystem
  53613. * @param gradient defines the gradient to use (between 0 and 1)
  53614. * @param min defines the color remap minimal range
  53615. * @param max defines the color remap maximal range
  53616. * @returns the current particle system
  53617. */
  53618. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53619. /**
  53620. * Not supported by GPUParticleSystem
  53621. * @param gradient defines the gradient to remove
  53622. * @returns the current particle system
  53623. */
  53624. removeColorRemapGradient(): IParticleSystem;
  53625. /**
  53626. * Not supported by GPUParticleSystem
  53627. * @param gradient defines the gradient to use (between 0 and 1)
  53628. * @param min defines the alpha remap minimal range
  53629. * @param max defines the alpha remap maximal range
  53630. * @returns the current particle system
  53631. */
  53632. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53633. /**
  53634. * Not supported by GPUParticleSystem
  53635. * @param gradient defines the gradient to remove
  53636. * @returns the current particle system
  53637. */
  53638. removeAlphaRemapGradient(): IParticleSystem;
  53639. /**
  53640. * Not supported by GPUParticleSystem
  53641. * @param gradient defines the gradient to use (between 0 and 1)
  53642. * @param color defines the color to affect to the specified gradient
  53643. * @returns the current particle system
  53644. */
  53645. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53646. /**
  53647. * Not supported by GPUParticleSystem
  53648. * @param gradient defines the gradient to remove
  53649. * @returns the current particle system
  53650. */
  53651. removeRampGradient(): IParticleSystem;
  53652. /**
  53653. * Not supported by GPUParticleSystem
  53654. * @returns the list of ramp gradients
  53655. */
  53656. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53657. /**
  53658. * Not supported by GPUParticleSystem
  53659. * Gets or sets a boolean indicating that ramp gradients must be used
  53660. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53661. */
  53662. useRampGradients: boolean;
  53663. /**
  53664. * Not supported by GPUParticleSystem
  53665. * @param gradient defines the gradient to use (between 0 and 1)
  53666. * @param factor defines the life time factor to affect to the specified gradient
  53667. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53668. * @returns the current particle system
  53669. */
  53670. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53671. /**
  53672. * Not supported by GPUParticleSystem
  53673. * @param gradient defines the gradient to remove
  53674. * @returns the current particle system
  53675. */
  53676. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53677. /**
  53678. * Instantiates a GPU particle system.
  53679. * 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.
  53680. * @param name The name of the particle system
  53681. * @param options The options used to create the system
  53682. * @param scene The scene the particle system belongs to
  53683. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53684. */
  53685. constructor(name: string, options: Partial<{
  53686. capacity: number;
  53687. randomTextureSize: number;
  53688. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53689. protected _reset(): void;
  53690. private _createUpdateVAO;
  53691. private _createRenderVAO;
  53692. private _initialize;
  53693. /** @hidden */
  53694. _recreateUpdateEffect(): void;
  53695. /** @hidden */
  53696. _recreateRenderEffect(): void;
  53697. /**
  53698. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53699. * @param preWarm defines if we are in the pre-warmimg phase
  53700. */
  53701. animate(preWarm?: boolean): void;
  53702. private _createFactorGradientTexture;
  53703. private _createSizeGradientTexture;
  53704. private _createAngularSpeedGradientTexture;
  53705. private _createVelocityGradientTexture;
  53706. private _createLimitVelocityGradientTexture;
  53707. private _createDragGradientTexture;
  53708. private _createColorGradientTexture;
  53709. /**
  53710. * Renders the particle system in its current state
  53711. * @param preWarm defines if the system should only update the particles but not render them
  53712. * @returns the current number of particles
  53713. */
  53714. render(preWarm?: boolean): number;
  53715. /**
  53716. * Rebuilds the particle system
  53717. */
  53718. rebuild(): void;
  53719. private _releaseBuffers;
  53720. private _releaseVAOs;
  53721. /**
  53722. * Disposes the particle system and free the associated resources
  53723. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53724. */
  53725. dispose(disposeTexture?: boolean): void;
  53726. /**
  53727. * Clones the particle system.
  53728. * @param name The name of the cloned object
  53729. * @param newEmitter The new emitter to use
  53730. * @returns the cloned particle system
  53731. */
  53732. clone(name: string, newEmitter: any): GPUParticleSystem;
  53733. /**
  53734. * Serializes the particle system to a JSON object.
  53735. * @returns the JSON object
  53736. */
  53737. serialize(): any;
  53738. /**
  53739. * Parses a JSON object to create a GPU particle system.
  53740. * @param parsedParticleSystem The JSON object to parse
  53741. * @param scene The scene to create the particle system in
  53742. * @param rootUrl The root url to use to load external dependencies like texture
  53743. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53744. * @returns the parsed GPU particle system
  53745. */
  53746. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53747. }
  53748. }
  53749. declare module BABYLON {
  53750. /**
  53751. * Represents a set of particle systems working together to create a specific effect
  53752. */
  53753. export class ParticleSystemSet implements IDisposable {
  53754. private _emitterCreationOptions;
  53755. private _emitterNode;
  53756. /**
  53757. * Gets the particle system list
  53758. */
  53759. systems: IParticleSystem[];
  53760. /**
  53761. * Gets the emitter node used with this set
  53762. */
  53763. readonly emitterNode: Nullable<TransformNode>;
  53764. /**
  53765. * Creates a new emitter mesh as a sphere
  53766. * @param options defines the options used to create the sphere
  53767. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53768. * @param scene defines the hosting scene
  53769. */
  53770. setEmitterAsSphere(options: {
  53771. diameter: number;
  53772. segments: number;
  53773. color: Color3;
  53774. }, renderingGroupId: number, scene: Scene): void;
  53775. /**
  53776. * Starts all particle systems of the set
  53777. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53778. */
  53779. start(emitter?: AbstractMesh): void;
  53780. /**
  53781. * Release all associated resources
  53782. */
  53783. dispose(): void;
  53784. /**
  53785. * Serialize the set into a JSON compatible object
  53786. * @returns a JSON compatible representation of the set
  53787. */
  53788. serialize(): any;
  53789. /**
  53790. * Parse a new ParticleSystemSet from a serialized source
  53791. * @param data defines a JSON compatible representation of the set
  53792. * @param scene defines the hosting scene
  53793. * @param gpu defines if we want GPU particles or CPU particles
  53794. * @returns a new ParticleSystemSet
  53795. */
  53796. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53797. }
  53798. }
  53799. declare module BABYLON {
  53800. /**
  53801. * This class is made for on one-liner static method to help creating particle system set.
  53802. */
  53803. export class ParticleHelper {
  53804. /**
  53805. * Gets or sets base Assets URL
  53806. */
  53807. static BaseAssetsUrl: string;
  53808. /**
  53809. * Create a default particle system that you can tweak
  53810. * @param emitter defines the emitter to use
  53811. * @param capacity defines the system capacity (default is 500 particles)
  53812. * @param scene defines the hosting scene
  53813. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  53814. * @returns the new Particle system
  53815. */
  53816. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  53817. /**
  53818. * This is the main static method (one-liner) of this helper to create different particle systems
  53819. * @param type This string represents the type to the particle system to create
  53820. * @param scene The scene where the particle system should live
  53821. * @param gpu If the system will use gpu
  53822. * @returns the ParticleSystemSet created
  53823. */
  53824. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  53825. /**
  53826. * Static function used to export a particle system to a ParticleSystemSet variable.
  53827. * Please note that the emitter shape is not exported
  53828. * @param systems defines the particle systems to export
  53829. * @returns the created particle system set
  53830. */
  53831. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  53832. }
  53833. }
  53834. declare module BABYLON {
  53835. interface Engine {
  53836. /**
  53837. * Create an effect to use with particle systems.
  53838. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  53839. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  53840. * @param uniformsNames defines a list of attribute names
  53841. * @param samplers defines an array of string used to represent textures
  53842. * @param defines defines the string containing the defines to use to compile the shaders
  53843. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  53844. * @param onCompiled defines a function to call when the effect creation is successful
  53845. * @param onError defines a function to call when the effect creation has failed
  53846. * @returns the new Effect
  53847. */
  53848. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  53849. }
  53850. interface Mesh {
  53851. /**
  53852. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  53853. * @returns an array of IParticleSystem
  53854. */
  53855. getEmittedParticleSystems(): IParticleSystem[];
  53856. /**
  53857. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  53858. * @returns an array of IParticleSystem
  53859. */
  53860. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  53861. }
  53862. /**
  53863. * @hidden
  53864. */
  53865. export var _IDoNeedToBeInTheBuild: number;
  53866. }
  53867. declare module BABYLON {
  53868. interface Scene {
  53869. /** @hidden (Backing field) */
  53870. _physicsEngine: Nullable<IPhysicsEngine>;
  53871. /**
  53872. * Gets the current physics engine
  53873. * @returns a IPhysicsEngine or null if none attached
  53874. */
  53875. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  53876. /**
  53877. * Enables physics to the current scene
  53878. * @param gravity defines the scene's gravity for the physics engine
  53879. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  53880. * @return a boolean indicating if the physics engine was initialized
  53881. */
  53882. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  53883. /**
  53884. * Disables and disposes the physics engine associated with the scene
  53885. */
  53886. disablePhysicsEngine(): void;
  53887. /**
  53888. * Gets a boolean indicating if there is an active physics engine
  53889. * @returns a boolean indicating if there is an active physics engine
  53890. */
  53891. isPhysicsEnabled(): boolean;
  53892. /**
  53893. * Deletes a physics compound impostor
  53894. * @param compound defines the compound to delete
  53895. */
  53896. deleteCompoundImpostor(compound: any): void;
  53897. /**
  53898. * An event triggered when physic simulation is about to be run
  53899. */
  53900. onBeforePhysicsObservable: Observable<Scene>;
  53901. /**
  53902. * An event triggered when physic simulation has been done
  53903. */
  53904. onAfterPhysicsObservable: Observable<Scene>;
  53905. }
  53906. interface AbstractMesh {
  53907. /** @hidden */
  53908. _physicsImpostor: Nullable<PhysicsImpostor>;
  53909. /**
  53910. * Gets or sets impostor used for physic simulation
  53911. * @see http://doc.babylonjs.com/features/physics_engine
  53912. */
  53913. physicsImpostor: Nullable<PhysicsImpostor>;
  53914. /**
  53915. * Gets the current physics impostor
  53916. * @see http://doc.babylonjs.com/features/physics_engine
  53917. * @returns a physics impostor or null
  53918. */
  53919. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  53920. /** Apply a physic impulse to the mesh
  53921. * @param force defines the force to apply
  53922. * @param contactPoint defines where to apply the force
  53923. * @returns the current mesh
  53924. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53925. */
  53926. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  53927. /**
  53928. * Creates a physic joint between two meshes
  53929. * @param otherMesh defines the other mesh to use
  53930. * @param pivot1 defines the pivot to use on this mesh
  53931. * @param pivot2 defines the pivot to use on the other mesh
  53932. * @param options defines additional options (can be plugin dependent)
  53933. * @returns the current mesh
  53934. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  53935. */
  53936. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  53937. /** @hidden */
  53938. _disposePhysicsObserver: Nullable<Observer<Node>>;
  53939. }
  53940. /**
  53941. * Defines the physics engine scene component responsible to manage a physics engine
  53942. */
  53943. export class PhysicsEngineSceneComponent implements ISceneComponent {
  53944. /**
  53945. * The component name helpful to identify the component in the list of scene components.
  53946. */
  53947. readonly name: string;
  53948. /**
  53949. * The scene the component belongs to.
  53950. */
  53951. scene: Scene;
  53952. /**
  53953. * Creates a new instance of the component for the given scene
  53954. * @param scene Defines the scene to register the component in
  53955. */
  53956. constructor(scene: Scene);
  53957. /**
  53958. * Registers the component in a given scene
  53959. */
  53960. register(): void;
  53961. /**
  53962. * Rebuilds the elements related to this component in case of
  53963. * context lost for instance.
  53964. */
  53965. rebuild(): void;
  53966. /**
  53967. * Disposes the component and the associated ressources
  53968. */
  53969. dispose(): void;
  53970. }
  53971. }
  53972. declare module BABYLON {
  53973. /**
  53974. * A helper for physics simulations
  53975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53976. */
  53977. export class PhysicsHelper {
  53978. private _scene;
  53979. private _physicsEngine;
  53980. /**
  53981. * Initializes the Physics helper
  53982. * @param scene Babylon.js scene
  53983. */
  53984. constructor(scene: Scene);
  53985. /**
  53986. * Applies a radial explosion impulse
  53987. * @param origin the origin of the explosion
  53988. * @param radiusOrEventOptions the radius or the options of radial explosion
  53989. * @param strength the explosion strength
  53990. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53991. * @returns A physics radial explosion event, or null
  53992. */
  53993. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53994. /**
  53995. * Applies a radial explosion force
  53996. * @param origin the origin of the explosion
  53997. * @param radiusOrEventOptions the radius or the options of radial explosion
  53998. * @param strength the explosion strength
  53999. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54000. * @returns A physics radial explosion event, or null
  54001. */
  54002. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54003. /**
  54004. * Creates a gravitational field
  54005. * @param origin the origin of the explosion
  54006. * @param radiusOrEventOptions the radius or the options of radial explosion
  54007. * @param strength the explosion strength
  54008. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54009. * @returns A physics gravitational field event, or null
  54010. */
  54011. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54012. /**
  54013. * Creates a physics updraft event
  54014. * @param origin the origin of the updraft
  54015. * @param radiusOrEventOptions the radius or the options of the updraft
  54016. * @param strength the strength of the updraft
  54017. * @param height the height of the updraft
  54018. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54019. * @returns A physics updraft event, or null
  54020. */
  54021. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54022. /**
  54023. * Creates a physics vortex event
  54024. * @param origin the of the vortex
  54025. * @param radiusOrEventOptions the radius or the options of the vortex
  54026. * @param strength the strength of the vortex
  54027. * @param height the height of the vortex
  54028. * @returns a Physics vortex event, or null
  54029. * A physics vortex event or null
  54030. */
  54031. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54032. }
  54033. /**
  54034. * Represents a physics radial explosion event
  54035. */
  54036. class PhysicsRadialExplosionEvent {
  54037. private _scene;
  54038. private _options;
  54039. private _sphere;
  54040. private _dataFetched;
  54041. /**
  54042. * Initializes a radial explosioin event
  54043. * @param _scene BabylonJS scene
  54044. * @param _options The options for the vortex event
  54045. */
  54046. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54047. /**
  54048. * Returns the data related to the radial explosion event (sphere).
  54049. * @returns The radial explosion event data
  54050. */
  54051. getData(): PhysicsRadialExplosionEventData;
  54052. /**
  54053. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54054. * @param impostor A physics imposter
  54055. * @param origin the origin of the explosion
  54056. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54057. */
  54058. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54059. /**
  54060. * Triggers affecterd impostors callbacks
  54061. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54062. */
  54063. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54064. /**
  54065. * Disposes the sphere.
  54066. * @param force Specifies if the sphere should be disposed by force
  54067. */
  54068. dispose(force?: boolean): void;
  54069. /*** Helpers ***/
  54070. private _prepareSphere;
  54071. private _intersectsWithSphere;
  54072. }
  54073. /**
  54074. * Represents a gravitational field event
  54075. */
  54076. class PhysicsGravitationalFieldEvent {
  54077. private _physicsHelper;
  54078. private _scene;
  54079. private _origin;
  54080. private _options;
  54081. private _tickCallback;
  54082. private _sphere;
  54083. private _dataFetched;
  54084. /**
  54085. * Initializes the physics gravitational field event
  54086. * @param _physicsHelper A physics helper
  54087. * @param _scene BabylonJS scene
  54088. * @param _origin The origin position of the gravitational field event
  54089. * @param _options The options for the vortex event
  54090. */
  54091. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54092. /**
  54093. * Returns the data related to the gravitational field event (sphere).
  54094. * @returns A gravitational field event
  54095. */
  54096. getData(): PhysicsGravitationalFieldEventData;
  54097. /**
  54098. * Enables the gravitational field.
  54099. */
  54100. enable(): void;
  54101. /**
  54102. * Disables the gravitational field.
  54103. */
  54104. disable(): void;
  54105. /**
  54106. * Disposes the sphere.
  54107. * @param force The force to dispose from the gravitational field event
  54108. */
  54109. dispose(force?: boolean): void;
  54110. private _tick;
  54111. }
  54112. /**
  54113. * Represents a physics updraft event
  54114. */
  54115. class PhysicsUpdraftEvent {
  54116. private _scene;
  54117. private _origin;
  54118. private _options;
  54119. private _physicsEngine;
  54120. private _originTop;
  54121. private _originDirection;
  54122. private _tickCallback;
  54123. private _cylinder;
  54124. private _cylinderPosition;
  54125. private _dataFetched;
  54126. /**
  54127. * Initializes the physics updraft event
  54128. * @param _scene BabylonJS scene
  54129. * @param _origin The origin position of the updraft
  54130. * @param _options The options for the updraft event
  54131. */
  54132. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54133. /**
  54134. * Returns the data related to the updraft event (cylinder).
  54135. * @returns A physics updraft event
  54136. */
  54137. getData(): PhysicsUpdraftEventData;
  54138. /**
  54139. * Enables the updraft.
  54140. */
  54141. enable(): void;
  54142. /**
  54143. * Disables the updraft.
  54144. */
  54145. disable(): void;
  54146. /**
  54147. * Disposes the cylinder.
  54148. * @param force Specifies if the updraft should be disposed by force
  54149. */
  54150. dispose(force?: boolean): void;
  54151. private getImpostorHitData;
  54152. private _tick;
  54153. /*** Helpers ***/
  54154. private _prepareCylinder;
  54155. private _intersectsWithCylinder;
  54156. }
  54157. /**
  54158. * Represents a physics vortex event
  54159. */
  54160. class PhysicsVortexEvent {
  54161. private _scene;
  54162. private _origin;
  54163. private _options;
  54164. private _physicsEngine;
  54165. private _originTop;
  54166. private _tickCallback;
  54167. private _cylinder;
  54168. private _cylinderPosition;
  54169. private _dataFetched;
  54170. /**
  54171. * Initializes the physics vortex event
  54172. * @param _scene The BabylonJS scene
  54173. * @param _origin The origin position of the vortex
  54174. * @param _options The options for the vortex event
  54175. */
  54176. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54177. /**
  54178. * Returns the data related to the vortex event (cylinder).
  54179. * @returns The physics vortex event data
  54180. */
  54181. getData(): PhysicsVortexEventData;
  54182. /**
  54183. * Enables the vortex.
  54184. */
  54185. enable(): void;
  54186. /**
  54187. * Disables the cortex.
  54188. */
  54189. disable(): void;
  54190. /**
  54191. * Disposes the sphere.
  54192. * @param force
  54193. */
  54194. dispose(force?: boolean): void;
  54195. private getImpostorHitData;
  54196. private _tick;
  54197. /*** Helpers ***/
  54198. private _prepareCylinder;
  54199. private _intersectsWithCylinder;
  54200. }
  54201. /**
  54202. * Options fot the radial explosion event
  54203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54204. */
  54205. export class PhysicsRadialExplosionEventOptions {
  54206. /**
  54207. * The radius of the sphere for the radial explosion.
  54208. */
  54209. radius: number;
  54210. /**
  54211. * The strenth of the explosion.
  54212. */
  54213. strength: number;
  54214. /**
  54215. * The strenght of the force in correspondence to the distance of the affected object
  54216. */
  54217. falloff: PhysicsRadialImpulseFalloff;
  54218. /**
  54219. * Sphere options for the radial explosion.
  54220. */
  54221. sphere: {
  54222. segments: number;
  54223. diameter: number;
  54224. };
  54225. /**
  54226. * Sphere options for the radial explosion.
  54227. */
  54228. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54229. }
  54230. /**
  54231. * Options fot the updraft event
  54232. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54233. */
  54234. export class PhysicsUpdraftEventOptions {
  54235. /**
  54236. * The radius of the cylinder for the vortex
  54237. */
  54238. radius: number;
  54239. /**
  54240. * The strenth of the updraft.
  54241. */
  54242. strength: number;
  54243. /**
  54244. * The height of the cylinder for the updraft.
  54245. */
  54246. height: number;
  54247. /**
  54248. * The mode for the the updraft.
  54249. */
  54250. updraftMode: PhysicsUpdraftMode;
  54251. }
  54252. /**
  54253. * Options fot the vortex event
  54254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54255. */
  54256. export class PhysicsVortexEventOptions {
  54257. /**
  54258. * The radius of the cylinder for the vortex
  54259. */
  54260. radius: number;
  54261. /**
  54262. * The strenth of the vortex.
  54263. */
  54264. strength: number;
  54265. /**
  54266. * The height of the cylinder for the vortex.
  54267. */
  54268. height: number;
  54269. /**
  54270. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54271. */
  54272. centripetalForceThreshold: number;
  54273. /**
  54274. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54275. */
  54276. centripetalForceMultiplier: number;
  54277. /**
  54278. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54279. */
  54280. centrifugalForceMultiplier: number;
  54281. /**
  54282. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54283. */
  54284. updraftForceMultiplier: number;
  54285. }
  54286. /**
  54287. * The strenght of the force in correspondence to the distance of the affected object
  54288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54289. */
  54290. export enum PhysicsRadialImpulseFalloff {
  54291. /** Defines that impulse is constant in strength across it's whole radius */
  54292. Constant = 0,
  54293. /** Defines that impulse gets weaker if it's further from the origin */
  54294. Linear = 1
  54295. }
  54296. /**
  54297. * The strength of the force in correspondence to the distance of the affected object
  54298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54299. */
  54300. export enum PhysicsUpdraftMode {
  54301. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54302. Center = 0,
  54303. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54304. Perpendicular = 1
  54305. }
  54306. /**
  54307. * Interface for a physics hit data
  54308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54309. */
  54310. export interface PhysicsHitData {
  54311. /**
  54312. * The force applied at the contact point
  54313. */
  54314. force: Vector3;
  54315. /**
  54316. * The contact point
  54317. */
  54318. contactPoint: Vector3;
  54319. /**
  54320. * The distance from the origin to the contact point
  54321. */
  54322. distanceFromOrigin: number;
  54323. }
  54324. /**
  54325. * Interface for radial explosion event data
  54326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54327. */
  54328. export interface PhysicsRadialExplosionEventData {
  54329. /**
  54330. * A sphere used for the radial explosion event
  54331. */
  54332. sphere: Mesh;
  54333. }
  54334. /**
  54335. * Interface for gravitational field event data
  54336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54337. */
  54338. export interface PhysicsGravitationalFieldEventData {
  54339. /**
  54340. * A sphere mesh used for the gravitational field event
  54341. */
  54342. sphere: Mesh;
  54343. }
  54344. /**
  54345. * Interface for updraft event data
  54346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54347. */
  54348. export interface PhysicsUpdraftEventData {
  54349. /**
  54350. * A cylinder used for the updraft event
  54351. */
  54352. cylinder: Mesh;
  54353. }
  54354. /**
  54355. * Interface for vortex event data
  54356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54357. */
  54358. export interface PhysicsVortexEventData {
  54359. /**
  54360. * A cylinder used for the vortex event
  54361. */
  54362. cylinder: Mesh;
  54363. }
  54364. /**
  54365. * Interface for an affected physics impostor
  54366. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54367. */
  54368. export interface PhysicsAffectedImpostorWithData {
  54369. /**
  54370. * The impostor affected by the effect
  54371. */
  54372. impostor: PhysicsImpostor;
  54373. /**
  54374. * The data about the hit/horce from the explosion
  54375. */
  54376. hitData: PhysicsHitData;
  54377. }
  54378. }
  54379. declare module BABYLON {
  54380. /** @hidden */
  54381. export var blackAndWhitePixelShader: {
  54382. name: string;
  54383. shader: string;
  54384. };
  54385. }
  54386. declare module BABYLON {
  54387. /**
  54388. * Post process used to render in black and white
  54389. */
  54390. export class BlackAndWhitePostProcess extends PostProcess {
  54391. /**
  54392. * Linear about to convert he result to black and white (default: 1)
  54393. */
  54394. degree: number;
  54395. /**
  54396. * Creates a black and white post process
  54397. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54398. * @param name The name of the effect.
  54399. * @param options The required width/height ratio to downsize to before computing the render pass.
  54400. * @param camera The camera to apply the render pass to.
  54401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54402. * @param engine The engine which the post process will be applied. (default: current engine)
  54403. * @param reusable If the post process can be reused on the same frame. (default: false)
  54404. */
  54405. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54406. }
  54407. }
  54408. declare module BABYLON {
  54409. /**
  54410. * This represents a set of one or more post processes in Babylon.
  54411. * A post process can be used to apply a shader to a texture after it is rendered.
  54412. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54413. */
  54414. export class PostProcessRenderEffect {
  54415. private _postProcesses;
  54416. private _getPostProcesses;
  54417. private _singleInstance;
  54418. private _cameras;
  54419. private _indicesForCamera;
  54420. /**
  54421. * Name of the effect
  54422. * @hidden
  54423. */
  54424. _name: string;
  54425. /**
  54426. * Instantiates a post process render effect.
  54427. * A post process can be used to apply a shader to a texture after it is rendered.
  54428. * @param engine The engine the effect is tied to
  54429. * @param name The name of the effect
  54430. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54431. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54432. */
  54433. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54434. /**
  54435. * Checks if all the post processes in the effect are supported.
  54436. */
  54437. readonly isSupported: boolean;
  54438. /**
  54439. * Updates the current state of the effect
  54440. * @hidden
  54441. */
  54442. _update(): void;
  54443. /**
  54444. * Attaches the effect on cameras
  54445. * @param cameras The camera to attach to.
  54446. * @hidden
  54447. */
  54448. _attachCameras(cameras: Camera): void;
  54449. /**
  54450. * Attaches the effect on cameras
  54451. * @param cameras The camera to attach to.
  54452. * @hidden
  54453. */
  54454. _attachCameras(cameras: Camera[]): void;
  54455. /**
  54456. * Detaches the effect on cameras
  54457. * @param cameras The camera to detatch from.
  54458. * @hidden
  54459. */
  54460. _detachCameras(cameras: Camera): void;
  54461. /**
  54462. * Detatches the effect on cameras
  54463. * @param cameras The camera to detatch from.
  54464. * @hidden
  54465. */
  54466. _detachCameras(cameras: Camera[]): void;
  54467. /**
  54468. * Enables the effect on given cameras
  54469. * @param cameras The camera to enable.
  54470. * @hidden
  54471. */
  54472. _enable(cameras: Camera): void;
  54473. /**
  54474. * Enables the effect on given cameras
  54475. * @param cameras The camera to enable.
  54476. * @hidden
  54477. */
  54478. _enable(cameras: Nullable<Camera[]>): void;
  54479. /**
  54480. * Disables the effect on the given cameras
  54481. * @param cameras The camera to disable.
  54482. * @hidden
  54483. */
  54484. _disable(cameras: Camera): void;
  54485. /**
  54486. * Disables the effect on the given cameras
  54487. * @param cameras The camera to disable.
  54488. * @hidden
  54489. */
  54490. _disable(cameras: Nullable<Camera[]>): void;
  54491. /**
  54492. * Gets a list of the post processes contained in the effect.
  54493. * @param camera The camera to get the post processes on.
  54494. * @returns The list of the post processes in the effect.
  54495. */
  54496. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54497. }
  54498. }
  54499. declare module BABYLON {
  54500. /** @hidden */
  54501. export var extractHighlightsPixelShader: {
  54502. name: string;
  54503. shader: string;
  54504. };
  54505. }
  54506. declare module BABYLON {
  54507. /**
  54508. * 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.
  54509. */
  54510. export class ExtractHighlightsPostProcess extends PostProcess {
  54511. /**
  54512. * The luminance threshold, pixels below this value will be set to black.
  54513. */
  54514. threshold: number;
  54515. /** @hidden */
  54516. _exposure: number;
  54517. /**
  54518. * Post process which has the input texture to be used when performing highlight extraction
  54519. * @hidden
  54520. */
  54521. _inputPostProcess: Nullable<PostProcess>;
  54522. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54523. }
  54524. }
  54525. declare module BABYLON {
  54526. /** @hidden */
  54527. export var bloomMergePixelShader: {
  54528. name: string;
  54529. shader: string;
  54530. };
  54531. }
  54532. declare module BABYLON {
  54533. /**
  54534. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54535. */
  54536. export class BloomMergePostProcess extends PostProcess {
  54537. /** Weight of the bloom to be added to the original input. */
  54538. weight: number;
  54539. /**
  54540. * Creates a new instance of @see BloomMergePostProcess
  54541. * @param name The name of the effect.
  54542. * @param originalFromInput Post process which's input will be used for the merge.
  54543. * @param blurred Blurred highlights post process which's output will be used.
  54544. * @param weight Weight of the bloom to be added to the original input.
  54545. * @param options The required width/height ratio to downsize to before computing the render pass.
  54546. * @param camera The camera to apply the render pass to.
  54547. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54548. * @param engine The engine which the post process will be applied. (default: current engine)
  54549. * @param reusable If the post process can be reused on the same frame. (default: false)
  54550. * @param textureType Type of textures used when performing the post process. (default: 0)
  54551. * @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)
  54552. */
  54553. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54554. /** Weight of the bloom to be added to the original input. */
  54555. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54556. }
  54557. }
  54558. declare module BABYLON {
  54559. /**
  54560. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54561. */
  54562. export class BloomEffect extends PostProcessRenderEffect {
  54563. private bloomScale;
  54564. /**
  54565. * @hidden Internal
  54566. */
  54567. _effects: Array<PostProcess>;
  54568. /**
  54569. * @hidden Internal
  54570. */
  54571. _downscale: ExtractHighlightsPostProcess;
  54572. private _blurX;
  54573. private _blurY;
  54574. private _merge;
  54575. /**
  54576. * The luminance threshold to find bright areas of the image to bloom.
  54577. */
  54578. threshold: number;
  54579. /**
  54580. * The strength of the bloom.
  54581. */
  54582. weight: number;
  54583. /**
  54584. * Specifies the size of the bloom blur kernel, relative to the final output size
  54585. */
  54586. kernel: number;
  54587. /**
  54588. * Creates a new instance of @see BloomEffect
  54589. * @param scene The scene the effect belongs to.
  54590. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54591. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54592. * @param bloomWeight The the strength of bloom.
  54593. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54594. * @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)
  54595. */
  54596. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54597. /**
  54598. * Disposes each of the internal effects for a given camera.
  54599. * @param camera The camera to dispose the effect on.
  54600. */
  54601. disposeEffects(camera: Camera): void;
  54602. /**
  54603. * @hidden Internal
  54604. */
  54605. _updateEffects(): void;
  54606. /**
  54607. * Internal
  54608. * @returns if all the contained post processes are ready.
  54609. * @hidden
  54610. */
  54611. _isReady(): boolean;
  54612. }
  54613. }
  54614. declare module BABYLON {
  54615. /** @hidden */
  54616. export var chromaticAberrationPixelShader: {
  54617. name: string;
  54618. shader: string;
  54619. };
  54620. }
  54621. declare module BABYLON {
  54622. /**
  54623. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54624. */
  54625. export class ChromaticAberrationPostProcess extends PostProcess {
  54626. /**
  54627. * The amount of seperation of rgb channels (default: 30)
  54628. */
  54629. aberrationAmount: number;
  54630. /**
  54631. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54632. */
  54633. radialIntensity: number;
  54634. /**
  54635. * 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))
  54636. */
  54637. direction: Vector2;
  54638. /**
  54639. * 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))
  54640. */
  54641. centerPosition: Vector2;
  54642. /**
  54643. * Creates a new instance ChromaticAberrationPostProcess
  54644. * @param name The name of the effect.
  54645. * @param screenWidth The width of the screen to apply the effect on.
  54646. * @param screenHeight The height of the screen to apply the effect on.
  54647. * @param options The required width/height ratio to downsize to before computing the render pass.
  54648. * @param camera The camera to apply the render pass to.
  54649. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54650. * @param engine The engine which the post process will be applied. (default: current engine)
  54651. * @param reusable If the post process can be reused on the same frame. (default: false)
  54652. * @param textureType Type of textures used when performing the post process. (default: 0)
  54653. * @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)
  54654. */
  54655. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54656. }
  54657. }
  54658. declare module BABYLON {
  54659. /** @hidden */
  54660. export var circleOfConfusionPixelShader: {
  54661. name: string;
  54662. shader: string;
  54663. };
  54664. }
  54665. declare module BABYLON {
  54666. /**
  54667. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54668. */
  54669. export class CircleOfConfusionPostProcess extends PostProcess {
  54670. /**
  54671. * 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.
  54672. */
  54673. lensSize: number;
  54674. /**
  54675. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54676. */
  54677. fStop: number;
  54678. /**
  54679. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54680. */
  54681. focusDistance: number;
  54682. /**
  54683. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54684. */
  54685. focalLength: number;
  54686. private _depthTexture;
  54687. /**
  54688. * Creates a new instance CircleOfConfusionPostProcess
  54689. * @param name The name of the effect.
  54690. * @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.
  54691. * @param options The required width/height ratio to downsize to before computing the render pass.
  54692. * @param camera The camera to apply the render pass to.
  54693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54694. * @param engine The engine which the post process will be applied. (default: current engine)
  54695. * @param reusable If the post process can be reused on the same frame. (default: false)
  54696. * @param textureType Type of textures used when performing the post process. (default: 0)
  54697. * @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)
  54698. */
  54699. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54700. /**
  54701. * 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.
  54702. */
  54703. depthTexture: RenderTargetTexture;
  54704. }
  54705. }
  54706. declare module BABYLON {
  54707. /** @hidden */
  54708. export var colorCorrectionPixelShader: {
  54709. name: string;
  54710. shader: string;
  54711. };
  54712. }
  54713. declare module BABYLON {
  54714. /**
  54715. *
  54716. * This post-process allows the modification of rendered colors by using
  54717. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54718. *
  54719. * The object needs to be provided an url to a texture containing the color
  54720. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54721. * Use an image editing software to tweak the LUT to match your needs.
  54722. *
  54723. * For an example of a color LUT, see here:
  54724. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54725. * For explanations on color grading, see here:
  54726. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54727. *
  54728. */
  54729. export class ColorCorrectionPostProcess extends PostProcess {
  54730. private _colorTableTexture;
  54731. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54732. }
  54733. }
  54734. declare module BABYLON {
  54735. /** @hidden */
  54736. export var convolutionPixelShader: {
  54737. name: string;
  54738. shader: string;
  54739. };
  54740. }
  54741. declare module BABYLON {
  54742. /**
  54743. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54744. * input texture to perform effects such as edge detection or sharpening
  54745. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54746. */
  54747. export class ConvolutionPostProcess extends PostProcess {
  54748. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54749. kernel: number[];
  54750. /**
  54751. * Creates a new instance ConvolutionPostProcess
  54752. * @param name The name of the effect.
  54753. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  54754. * @param options The required width/height ratio to downsize to before computing the render pass.
  54755. * @param camera The camera to apply the render pass to.
  54756. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54757. * @param engine The engine which the post process will be applied. (default: current engine)
  54758. * @param reusable If the post process can be reused on the same frame. (default: false)
  54759. * @param textureType Type of textures used when performing the post process. (default: 0)
  54760. */
  54761. constructor(name: string,
  54762. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54763. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54764. /**
  54765. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54766. */
  54767. static EdgeDetect0Kernel: number[];
  54768. /**
  54769. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54770. */
  54771. static EdgeDetect1Kernel: number[];
  54772. /**
  54773. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54774. */
  54775. static EdgeDetect2Kernel: number[];
  54776. /**
  54777. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54778. */
  54779. static SharpenKernel: number[];
  54780. /**
  54781. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54782. */
  54783. static EmbossKernel: number[];
  54784. /**
  54785. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54786. */
  54787. static GaussianKernel: number[];
  54788. }
  54789. }
  54790. declare module BABYLON {
  54791. /**
  54792. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  54793. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  54794. * based on samples that have a large difference in distance than the center pixel.
  54795. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  54796. */
  54797. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  54798. direction: Vector2;
  54799. /**
  54800. * Creates a new instance CircleOfConfusionPostProcess
  54801. * @param name The name of the effect.
  54802. * @param scene The scene the effect belongs to.
  54803. * @param direction The direction the blur should be applied.
  54804. * @param kernel The size of the kernel used to blur.
  54805. * @param options The required width/height ratio to downsize to before computing the render pass.
  54806. * @param camera The camera to apply the render pass to.
  54807. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  54808. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  54809. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54810. * @param engine The engine which the post process will be applied. (default: current engine)
  54811. * @param reusable If the post process can be reused on the same frame. (default: false)
  54812. * @param textureType Type of textures used when performing the post process. (default: 0)
  54813. * @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)
  54814. */
  54815. 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);
  54816. }
  54817. }
  54818. declare module BABYLON {
  54819. /** @hidden */
  54820. export var depthOfFieldMergePixelShader: {
  54821. name: string;
  54822. shader: string;
  54823. };
  54824. }
  54825. declare module BABYLON {
  54826. /**
  54827. * Options to be set when merging outputs from the default pipeline.
  54828. */
  54829. export class DepthOfFieldMergePostProcessOptions {
  54830. /**
  54831. * The original image to merge on top of
  54832. */
  54833. originalFromInput: PostProcess;
  54834. /**
  54835. * Parameters to perform the merge of the depth of field effect
  54836. */
  54837. depthOfField?: {
  54838. circleOfConfusion: PostProcess;
  54839. blurSteps: Array<PostProcess>;
  54840. };
  54841. /**
  54842. * Parameters to perform the merge of bloom effect
  54843. */
  54844. bloom?: {
  54845. blurred: PostProcess;
  54846. weight: number;
  54847. };
  54848. }
  54849. /**
  54850. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54851. */
  54852. export class DepthOfFieldMergePostProcess extends PostProcess {
  54853. private blurSteps;
  54854. /**
  54855. * Creates a new instance of DepthOfFieldMergePostProcess
  54856. * @param name The name of the effect.
  54857. * @param originalFromInput Post process which's input will be used for the merge.
  54858. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54859. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54860. * @param options The required width/height ratio to downsize to before computing the render pass.
  54861. * @param camera The camera to apply the render pass to.
  54862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54863. * @param engine The engine which the post process will be applied. (default: current engine)
  54864. * @param reusable If the post process can be reused on the same frame. (default: false)
  54865. * @param textureType Type of textures used when performing the post process. (default: 0)
  54866. * @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)
  54867. */
  54868. 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);
  54869. /**
  54870. * Updates the effect with the current post process compile time values and recompiles the shader.
  54871. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54872. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54873. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54874. * @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
  54875. * @param onCompiled Called when the shader has been compiled.
  54876. * @param onError Called if there is an error when compiling a shader.
  54877. */
  54878. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54879. }
  54880. }
  54881. declare module BABYLON {
  54882. /**
  54883. * Specifies the level of max blur that should be applied when using the depth of field effect
  54884. */
  54885. export enum DepthOfFieldEffectBlurLevel {
  54886. /**
  54887. * Subtle blur
  54888. */
  54889. Low = 0,
  54890. /**
  54891. * Medium blur
  54892. */
  54893. Medium = 1,
  54894. /**
  54895. * Large blur
  54896. */
  54897. High = 2
  54898. }
  54899. /**
  54900. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54901. */
  54902. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54903. private _circleOfConfusion;
  54904. /**
  54905. * @hidden Internal, blurs from high to low
  54906. */
  54907. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54908. private _depthOfFieldBlurY;
  54909. private _dofMerge;
  54910. /**
  54911. * @hidden Internal post processes in depth of field effect
  54912. */
  54913. _effects: Array<PostProcess>;
  54914. /**
  54915. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54916. */
  54917. focalLength: number;
  54918. /**
  54919. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54920. */
  54921. fStop: number;
  54922. /**
  54923. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54924. */
  54925. focusDistance: number;
  54926. /**
  54927. * 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.
  54928. */
  54929. lensSize: number;
  54930. /**
  54931. * Creates a new instance DepthOfFieldEffect
  54932. * @param scene The scene the effect belongs to.
  54933. * @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.
  54934. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54935. * @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)
  54936. */
  54937. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  54938. /**
  54939. * Get the current class name of the current effet
  54940. * @returns "DepthOfFieldEffect"
  54941. */
  54942. getClassName(): string;
  54943. /**
  54944. * 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.
  54945. */
  54946. depthTexture: RenderTargetTexture;
  54947. /**
  54948. * Disposes each of the internal effects for a given camera.
  54949. * @param camera The camera to dispose the effect on.
  54950. */
  54951. disposeEffects(camera: Camera): void;
  54952. /**
  54953. * @hidden Internal
  54954. */
  54955. _updateEffects(): void;
  54956. /**
  54957. * Internal
  54958. * @returns if all the contained post processes are ready.
  54959. * @hidden
  54960. */
  54961. _isReady(): boolean;
  54962. }
  54963. }
  54964. declare module BABYLON {
  54965. /** @hidden */
  54966. export var displayPassPixelShader: {
  54967. name: string;
  54968. shader: string;
  54969. };
  54970. }
  54971. declare module BABYLON {
  54972. /**
  54973. * DisplayPassPostProcess which produces an output the same as it's input
  54974. */
  54975. export class DisplayPassPostProcess extends PostProcess {
  54976. /**
  54977. * Creates the DisplayPassPostProcess
  54978. * @param name The name of the effect.
  54979. * @param options The required width/height ratio to downsize to before computing the render pass.
  54980. * @param camera The camera to apply the render pass to.
  54981. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54982. * @param engine The engine which the post process will be applied. (default: current engine)
  54983. * @param reusable If the post process can be reused on the same frame. (default: false)
  54984. */
  54985. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54986. }
  54987. }
  54988. declare module BABYLON {
  54989. /** @hidden */
  54990. export var filterPixelShader: {
  54991. name: string;
  54992. shader: string;
  54993. };
  54994. }
  54995. declare module BABYLON {
  54996. /**
  54997. * Applies a kernel filter to the image
  54998. */
  54999. export class FilterPostProcess extends PostProcess {
  55000. /** The matrix to be applied to the image */
  55001. kernelMatrix: Matrix;
  55002. /**
  55003. *
  55004. * @param name The name of the effect.
  55005. * @param kernelMatrix The matrix to be applied to the image
  55006. * @param options The required width/height ratio to downsize to before computing the render pass.
  55007. * @param camera The camera to apply the render pass to.
  55008. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55009. * @param engine The engine which the post process will be applied. (default: current engine)
  55010. * @param reusable If the post process can be reused on the same frame. (default: false)
  55011. */
  55012. constructor(name: string,
  55013. /** The matrix to be applied to the image */
  55014. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55015. }
  55016. }
  55017. declare module BABYLON {
  55018. /** @hidden */
  55019. export var fxaaPixelShader: {
  55020. name: string;
  55021. shader: string;
  55022. };
  55023. }
  55024. declare module BABYLON {
  55025. /** @hidden */
  55026. export var fxaaVertexShader: {
  55027. name: string;
  55028. shader: string;
  55029. };
  55030. }
  55031. declare module BABYLON {
  55032. /**
  55033. * Fxaa post process
  55034. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55035. */
  55036. export class FxaaPostProcess extends PostProcess {
  55037. /** @hidden */
  55038. texelWidth: number;
  55039. /** @hidden */
  55040. texelHeight: number;
  55041. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55042. private _getDefines;
  55043. }
  55044. }
  55045. declare module BABYLON {
  55046. /** @hidden */
  55047. export var grainPixelShader: {
  55048. name: string;
  55049. shader: string;
  55050. };
  55051. }
  55052. declare module BABYLON {
  55053. /**
  55054. * The GrainPostProcess adds noise to the image at mid luminance levels
  55055. */
  55056. export class GrainPostProcess extends PostProcess {
  55057. /**
  55058. * The intensity of the grain added (default: 30)
  55059. */
  55060. intensity: number;
  55061. /**
  55062. * If the grain should be randomized on every frame
  55063. */
  55064. animated: boolean;
  55065. /**
  55066. * Creates a new instance of @see GrainPostProcess
  55067. * @param name The name of the effect.
  55068. * @param options The required width/height ratio to downsize to before computing the render pass.
  55069. * @param camera The camera to apply the render pass to.
  55070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55071. * @param engine The engine which the post process will be applied. (default: current engine)
  55072. * @param reusable If the post process can be reused on the same frame. (default: false)
  55073. * @param textureType Type of textures used when performing the post process. (default: 0)
  55074. * @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)
  55075. */
  55076. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55077. }
  55078. }
  55079. declare module BABYLON {
  55080. /** @hidden */
  55081. export var highlightsPixelShader: {
  55082. name: string;
  55083. shader: string;
  55084. };
  55085. }
  55086. declare module BABYLON {
  55087. /**
  55088. * Extracts highlights from the image
  55089. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55090. */
  55091. export class HighlightsPostProcess extends PostProcess {
  55092. /**
  55093. * Extracts highlights from the image
  55094. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55095. * @param name The name of the effect.
  55096. * @param options The required width/height ratio to downsize to before computing the render pass.
  55097. * @param camera The camera to apply the render pass to.
  55098. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55099. * @param engine The engine which the post process will be applied. (default: current engine)
  55100. * @param reusable If the post process can be reused on the same frame. (default: false)
  55101. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55102. */
  55103. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55104. }
  55105. }
  55106. declare module BABYLON {
  55107. /** @hidden */
  55108. export var mrtFragmentDeclaration: {
  55109. name: string;
  55110. shader: string;
  55111. };
  55112. }
  55113. declare module BABYLON {
  55114. /** @hidden */
  55115. export var geometryPixelShader: {
  55116. name: string;
  55117. shader: string;
  55118. };
  55119. }
  55120. declare module BABYLON {
  55121. /** @hidden */
  55122. export var geometryVertexShader: {
  55123. name: string;
  55124. shader: string;
  55125. };
  55126. }
  55127. declare module BABYLON {
  55128. /** @hidden */
  55129. interface ISavedTransformationMatrix {
  55130. world: Matrix;
  55131. viewProjection: Matrix;
  55132. }
  55133. /**
  55134. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55135. */
  55136. export class GeometryBufferRenderer {
  55137. /**
  55138. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55139. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55140. */
  55141. static readonly POSITION_TEXTURE_TYPE: number;
  55142. /**
  55143. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55144. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55145. */
  55146. static readonly VELOCITY_TEXTURE_TYPE: number;
  55147. /**
  55148. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55149. * in order to compute objects velocities when enableVelocity is set to "true"
  55150. * @hidden
  55151. */
  55152. _previousTransformationMatrices: {
  55153. [index: number]: ISavedTransformationMatrix;
  55154. };
  55155. /**
  55156. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  55157. * in order to compute objects velocities when enableVelocity is set to "true"
  55158. * @hidden
  55159. */
  55160. _previousBonesTransformationMatrices: {
  55161. [index: number]: Float32Array;
  55162. };
  55163. /**
  55164. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  55165. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  55166. */
  55167. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  55168. private _scene;
  55169. private _multiRenderTarget;
  55170. private _ratio;
  55171. private _enablePosition;
  55172. private _enableVelocity;
  55173. private _positionIndex;
  55174. private _velocityIndex;
  55175. protected _effect: Effect;
  55176. protected _cachedDefines: string;
  55177. /**
  55178. * Set the render list (meshes to be rendered) used in the G buffer.
  55179. */
  55180. renderList: Mesh[];
  55181. /**
  55182. * Gets wether or not G buffer are supported by the running hardware.
  55183. * This requires draw buffer supports
  55184. */
  55185. readonly isSupported: boolean;
  55186. /**
  55187. * Returns the index of the given texture type in the G-Buffer textures array
  55188. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55189. * @returns the index of the given texture type in the G-Buffer textures array
  55190. */
  55191. getTextureIndex(textureType: number): number;
  55192. /**
  55193. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55194. */
  55195. /**
  55196. * Sets whether or not objects positions are enabled for the G buffer.
  55197. */
  55198. enablePosition: boolean;
  55199. /**
  55200. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55201. */
  55202. /**
  55203. * Sets wether or not objects velocities are enabled for the G buffer.
  55204. */
  55205. enableVelocity: boolean;
  55206. /**
  55207. * Gets the scene associated with the buffer.
  55208. */
  55209. readonly scene: Scene;
  55210. /**
  55211. * Gets the ratio used by the buffer during its creation.
  55212. * How big is the buffer related to the main canvas.
  55213. */
  55214. readonly ratio: number;
  55215. /** @hidden */
  55216. static _SceneComponentInitialization: (scene: Scene) => void;
  55217. /**
  55218. * Creates a new G Buffer for the scene
  55219. * @param scene The scene the buffer belongs to
  55220. * @param ratio How big is the buffer related to the main canvas.
  55221. */
  55222. constructor(scene: Scene, ratio?: number);
  55223. /**
  55224. * Checks wether everything is ready to render a submesh to the G buffer.
  55225. * @param subMesh the submesh to check readiness for
  55226. * @param useInstances is the mesh drawn using instance or not
  55227. * @returns true if ready otherwise false
  55228. */
  55229. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55230. /**
  55231. * Gets the current underlying G Buffer.
  55232. * @returns the buffer
  55233. */
  55234. getGBuffer(): MultiRenderTarget;
  55235. /**
  55236. * Gets the number of samples used to render the buffer (anti aliasing).
  55237. */
  55238. /**
  55239. * Sets the number of samples used to render the buffer (anti aliasing).
  55240. */
  55241. samples: number;
  55242. /**
  55243. * Disposes the renderer and frees up associated resources.
  55244. */
  55245. dispose(): void;
  55246. protected _createRenderTargets(): void;
  55247. private _copyBonesTransformationMatrices;
  55248. }
  55249. }
  55250. declare module BABYLON {
  55251. interface Scene {
  55252. /** @hidden (Backing field) */
  55253. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55254. /**
  55255. * Gets or Sets the current geometry buffer associated to the scene.
  55256. */
  55257. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55258. /**
  55259. * Enables a GeometryBufferRender and associates it with the scene
  55260. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55261. * @returns the GeometryBufferRenderer
  55262. */
  55263. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55264. /**
  55265. * Disables the GeometryBufferRender associated with the scene
  55266. */
  55267. disableGeometryBufferRenderer(): void;
  55268. }
  55269. /**
  55270. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55271. * in several rendering techniques.
  55272. */
  55273. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55274. /**
  55275. * The component name helpful to identify the component in the list of scene components.
  55276. */
  55277. readonly name: string;
  55278. /**
  55279. * The scene the component belongs to.
  55280. */
  55281. scene: Scene;
  55282. /**
  55283. * Creates a new instance of the component for the given scene
  55284. * @param scene Defines the scene to register the component in
  55285. */
  55286. constructor(scene: Scene);
  55287. /**
  55288. * Registers the component in a given scene
  55289. */
  55290. register(): void;
  55291. /**
  55292. * Rebuilds the elements related to this component in case of
  55293. * context lost for instance.
  55294. */
  55295. rebuild(): void;
  55296. /**
  55297. * Disposes the component and the associated ressources
  55298. */
  55299. dispose(): void;
  55300. private _gatherRenderTargets;
  55301. }
  55302. }
  55303. declare module BABYLON {
  55304. /** @hidden */
  55305. export var motionBlurPixelShader: {
  55306. name: string;
  55307. shader: string;
  55308. };
  55309. }
  55310. declare module BABYLON {
  55311. /**
  55312. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55313. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55314. * As an example, all you have to do is to create the post-process:
  55315. * var mb = new BABYLON.MotionBlurPostProcess(
  55316. * 'mb', // The name of the effect.
  55317. * scene, // The scene containing the objects to blur according to their velocity.
  55318. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55319. * camera // The camera to apply the render pass to.
  55320. * );
  55321. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55322. */
  55323. export class MotionBlurPostProcess extends PostProcess {
  55324. /**
  55325. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55326. */
  55327. motionStrength: number;
  55328. /**
  55329. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55330. */
  55331. /**
  55332. * Sets the number of iterations to be used for motion blur quality
  55333. */
  55334. motionBlurSamples: number;
  55335. private _motionBlurSamples;
  55336. private _geometryBufferRenderer;
  55337. /**
  55338. * Creates a new instance MotionBlurPostProcess
  55339. * @param name The name of the effect.
  55340. * @param scene The scene containing the objects to blur according to their velocity.
  55341. * @param options The required width/height ratio to downsize to before computing the render pass.
  55342. * @param camera The camera to apply the render pass to.
  55343. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55344. * @param engine The engine which the post process will be applied. (default: current engine)
  55345. * @param reusable If the post process can be reused on the same frame. (default: false)
  55346. * @param textureType Type of textures used when performing the post process. (default: 0)
  55347. * @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)
  55348. */
  55349. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55350. /**
  55351. * Excludes the given skinned mesh from computing bones velocities.
  55352. * 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.
  55353. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  55354. */
  55355. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55356. /**
  55357. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  55358. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  55359. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  55360. */
  55361. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55362. /**
  55363. * Disposes the post process.
  55364. * @param camera The camera to dispose the post process on.
  55365. */
  55366. dispose(camera?: Camera): void;
  55367. }
  55368. }
  55369. declare module BABYLON {
  55370. /** @hidden */
  55371. export var refractionPixelShader: {
  55372. name: string;
  55373. shader: string;
  55374. };
  55375. }
  55376. declare module BABYLON {
  55377. /**
  55378. * Post process which applies a refractin texture
  55379. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55380. */
  55381. export class RefractionPostProcess extends PostProcess {
  55382. /** the base color of the refraction (used to taint the rendering) */
  55383. color: Color3;
  55384. /** simulated refraction depth */
  55385. depth: number;
  55386. /** the coefficient of the base color (0 to remove base color tainting) */
  55387. colorLevel: number;
  55388. private _refTexture;
  55389. private _ownRefractionTexture;
  55390. /**
  55391. * Gets or sets the refraction texture
  55392. * Please note that you are responsible for disposing the texture if you set it manually
  55393. */
  55394. refractionTexture: Texture;
  55395. /**
  55396. * Initializes the RefractionPostProcess
  55397. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55398. * @param name The name of the effect.
  55399. * @param refractionTextureUrl Url of the refraction texture to use
  55400. * @param color the base color of the refraction (used to taint the rendering)
  55401. * @param depth simulated refraction depth
  55402. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55403. * @param camera The camera to apply the render pass to.
  55404. * @param options The required width/height ratio to downsize to before computing the render pass.
  55405. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55406. * @param engine The engine which the post process will be applied. (default: current engine)
  55407. * @param reusable If the post process can be reused on the same frame. (default: false)
  55408. */
  55409. constructor(name: string, refractionTextureUrl: string,
  55410. /** the base color of the refraction (used to taint the rendering) */
  55411. color: Color3,
  55412. /** simulated refraction depth */
  55413. depth: number,
  55414. /** the coefficient of the base color (0 to remove base color tainting) */
  55415. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55416. /**
  55417. * Disposes of the post process
  55418. * @param camera Camera to dispose post process on
  55419. */
  55420. dispose(camera: Camera): void;
  55421. }
  55422. }
  55423. declare module BABYLON {
  55424. /** @hidden */
  55425. export var sharpenPixelShader: {
  55426. name: string;
  55427. shader: string;
  55428. };
  55429. }
  55430. declare module BABYLON {
  55431. /**
  55432. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55433. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55434. */
  55435. export class SharpenPostProcess extends PostProcess {
  55436. /**
  55437. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55438. */
  55439. colorAmount: number;
  55440. /**
  55441. * How much sharpness should be applied (default: 0.3)
  55442. */
  55443. edgeAmount: number;
  55444. /**
  55445. * Creates a new instance ConvolutionPostProcess
  55446. * @param name The name of the effect.
  55447. * @param options The required width/height ratio to downsize to before computing the render pass.
  55448. * @param camera The camera to apply the render pass to.
  55449. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55450. * @param engine The engine which the post process will be applied. (default: current engine)
  55451. * @param reusable If the post process can be reused on the same frame. (default: false)
  55452. * @param textureType Type of textures used when performing the post process. (default: 0)
  55453. * @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)
  55454. */
  55455. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55456. }
  55457. }
  55458. declare module BABYLON {
  55459. /**
  55460. * PostProcessRenderPipeline
  55461. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55462. */
  55463. export class PostProcessRenderPipeline {
  55464. private engine;
  55465. private _renderEffects;
  55466. private _renderEffectsForIsolatedPass;
  55467. /**
  55468. * List of inspectable custom properties (used by the Inspector)
  55469. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55470. */
  55471. inspectableCustomProperties: IInspectable[];
  55472. /**
  55473. * @hidden
  55474. */
  55475. protected _cameras: Camera[];
  55476. /** @hidden */
  55477. _name: string;
  55478. /**
  55479. * Gets pipeline name
  55480. */
  55481. readonly name: string;
  55482. /**
  55483. * Initializes a PostProcessRenderPipeline
  55484. * @param engine engine to add the pipeline to
  55485. * @param name name of the pipeline
  55486. */
  55487. constructor(engine: Engine, name: string);
  55488. /**
  55489. * Gets the class name
  55490. * @returns "PostProcessRenderPipeline"
  55491. */
  55492. getClassName(): string;
  55493. /**
  55494. * If all the render effects in the pipeline are supported
  55495. */
  55496. readonly isSupported: boolean;
  55497. /**
  55498. * Adds an effect to the pipeline
  55499. * @param renderEffect the effect to add
  55500. */
  55501. addEffect(renderEffect: PostProcessRenderEffect): void;
  55502. /** @hidden */
  55503. _rebuild(): void;
  55504. /** @hidden */
  55505. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55506. /** @hidden */
  55507. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55508. /** @hidden */
  55509. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55510. /** @hidden */
  55511. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55512. /** @hidden */
  55513. _attachCameras(cameras: Camera, unique: boolean): void;
  55514. /** @hidden */
  55515. _attachCameras(cameras: Camera[], unique: boolean): void;
  55516. /** @hidden */
  55517. _detachCameras(cameras: Camera): void;
  55518. /** @hidden */
  55519. _detachCameras(cameras: Nullable<Camera[]>): void;
  55520. /** @hidden */
  55521. _update(): void;
  55522. /** @hidden */
  55523. _reset(): void;
  55524. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55525. /**
  55526. * Disposes of the pipeline
  55527. */
  55528. dispose(): void;
  55529. }
  55530. }
  55531. declare module BABYLON {
  55532. /**
  55533. * PostProcessRenderPipelineManager class
  55534. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55535. */
  55536. export class PostProcessRenderPipelineManager {
  55537. private _renderPipelines;
  55538. /**
  55539. * Initializes a PostProcessRenderPipelineManager
  55540. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55541. */
  55542. constructor();
  55543. /**
  55544. * Gets the list of supported render pipelines
  55545. */
  55546. readonly supportedPipelines: PostProcessRenderPipeline[];
  55547. /**
  55548. * Adds a pipeline to the manager
  55549. * @param renderPipeline The pipeline to add
  55550. */
  55551. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55552. /**
  55553. * Attaches a camera to the pipeline
  55554. * @param renderPipelineName The name of the pipeline to attach to
  55555. * @param cameras the camera to attach
  55556. * @param unique if the camera can be attached multiple times to the pipeline
  55557. */
  55558. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55559. /**
  55560. * Detaches a camera from the pipeline
  55561. * @param renderPipelineName The name of the pipeline to detach from
  55562. * @param cameras the camera to detach
  55563. */
  55564. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55565. /**
  55566. * Enables an effect by name on a pipeline
  55567. * @param renderPipelineName the name of the pipeline to enable the effect in
  55568. * @param renderEffectName the name of the effect to enable
  55569. * @param cameras the cameras that the effect should be enabled on
  55570. */
  55571. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55572. /**
  55573. * Disables an effect by name on a pipeline
  55574. * @param renderPipelineName the name of the pipeline to disable the effect in
  55575. * @param renderEffectName the name of the effect to disable
  55576. * @param cameras the cameras that the effect should be disabled on
  55577. */
  55578. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55579. /**
  55580. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55581. */
  55582. update(): void;
  55583. /** @hidden */
  55584. _rebuild(): void;
  55585. /**
  55586. * Disposes of the manager and pipelines
  55587. */
  55588. dispose(): void;
  55589. }
  55590. }
  55591. declare module BABYLON {
  55592. interface Scene {
  55593. /** @hidden (Backing field) */
  55594. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55595. /**
  55596. * Gets the postprocess render pipeline manager
  55597. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55598. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55599. */
  55600. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55601. }
  55602. /**
  55603. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55604. */
  55605. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55606. /**
  55607. * The component name helpfull to identify the component in the list of scene components.
  55608. */
  55609. readonly name: string;
  55610. /**
  55611. * The scene the component belongs to.
  55612. */
  55613. scene: Scene;
  55614. /**
  55615. * Creates a new instance of the component for the given scene
  55616. * @param scene Defines the scene to register the component in
  55617. */
  55618. constructor(scene: Scene);
  55619. /**
  55620. * Registers the component in a given scene
  55621. */
  55622. register(): void;
  55623. /**
  55624. * Rebuilds the elements related to this component in case of
  55625. * context lost for instance.
  55626. */
  55627. rebuild(): void;
  55628. /**
  55629. * Disposes the component and the associated ressources
  55630. */
  55631. dispose(): void;
  55632. private _gatherRenderTargets;
  55633. }
  55634. }
  55635. declare module BABYLON {
  55636. /**
  55637. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55638. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55639. */
  55640. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55641. private _scene;
  55642. private _camerasToBeAttached;
  55643. /**
  55644. * ID of the sharpen post process,
  55645. */
  55646. private readonly SharpenPostProcessId;
  55647. /**
  55648. * @ignore
  55649. * ID of the image processing post process;
  55650. */
  55651. readonly ImageProcessingPostProcessId: string;
  55652. /**
  55653. * @ignore
  55654. * ID of the Fast Approximate Anti-Aliasing post process;
  55655. */
  55656. readonly FxaaPostProcessId: string;
  55657. /**
  55658. * ID of the chromatic aberration post process,
  55659. */
  55660. private readonly ChromaticAberrationPostProcessId;
  55661. /**
  55662. * ID of the grain post process
  55663. */
  55664. private readonly GrainPostProcessId;
  55665. /**
  55666. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55667. */
  55668. sharpen: SharpenPostProcess;
  55669. private _sharpenEffect;
  55670. private bloom;
  55671. /**
  55672. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55673. */
  55674. depthOfField: DepthOfFieldEffect;
  55675. /**
  55676. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55677. */
  55678. fxaa: FxaaPostProcess;
  55679. /**
  55680. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55681. */
  55682. imageProcessing: ImageProcessingPostProcess;
  55683. /**
  55684. * Chromatic aberration post process which will shift rgb colors in the image
  55685. */
  55686. chromaticAberration: ChromaticAberrationPostProcess;
  55687. private _chromaticAberrationEffect;
  55688. /**
  55689. * Grain post process which add noise to the image
  55690. */
  55691. grain: GrainPostProcess;
  55692. private _grainEffect;
  55693. /**
  55694. * Glow post process which adds a glow to emissive areas of the image
  55695. */
  55696. private _glowLayer;
  55697. /**
  55698. * Animations which can be used to tweak settings over a period of time
  55699. */
  55700. animations: Animation[];
  55701. private _imageProcessingConfigurationObserver;
  55702. private _sharpenEnabled;
  55703. private _bloomEnabled;
  55704. private _depthOfFieldEnabled;
  55705. private _depthOfFieldBlurLevel;
  55706. private _fxaaEnabled;
  55707. private _imageProcessingEnabled;
  55708. private _defaultPipelineTextureType;
  55709. private _bloomScale;
  55710. private _chromaticAberrationEnabled;
  55711. private _grainEnabled;
  55712. private _buildAllowed;
  55713. /**
  55714. * Gets active scene
  55715. */
  55716. readonly scene: Scene;
  55717. /**
  55718. * Enable or disable the sharpen process from the pipeline
  55719. */
  55720. sharpenEnabled: boolean;
  55721. private _resizeObserver;
  55722. private _hardwareScaleLevel;
  55723. private _bloomKernel;
  55724. /**
  55725. * Specifies the size of the bloom blur kernel, relative to the final output size
  55726. */
  55727. bloomKernel: number;
  55728. /**
  55729. * Specifies the weight of the bloom in the final rendering
  55730. */
  55731. private _bloomWeight;
  55732. /**
  55733. * Specifies the luma threshold for the area that will be blurred by the bloom
  55734. */
  55735. private _bloomThreshold;
  55736. private _hdr;
  55737. /**
  55738. * The strength of the bloom.
  55739. */
  55740. bloomWeight: number;
  55741. /**
  55742. * The strength of the bloom.
  55743. */
  55744. bloomThreshold: number;
  55745. /**
  55746. * The scale of the bloom, lower value will provide better performance.
  55747. */
  55748. bloomScale: number;
  55749. /**
  55750. * Enable or disable the bloom from the pipeline
  55751. */
  55752. bloomEnabled: boolean;
  55753. private _rebuildBloom;
  55754. /**
  55755. * If the depth of field is enabled.
  55756. */
  55757. depthOfFieldEnabled: boolean;
  55758. /**
  55759. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55760. */
  55761. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55762. /**
  55763. * If the anti aliasing is enabled.
  55764. */
  55765. fxaaEnabled: boolean;
  55766. private _samples;
  55767. /**
  55768. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55769. */
  55770. samples: number;
  55771. /**
  55772. * If image processing is enabled.
  55773. */
  55774. imageProcessingEnabled: boolean;
  55775. /**
  55776. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  55777. */
  55778. glowLayerEnabled: boolean;
  55779. /**
  55780. * Gets the glow layer (or null if not defined)
  55781. */
  55782. readonly glowLayer: Nullable<GlowLayer>;
  55783. /**
  55784. * Enable or disable the chromaticAberration process from the pipeline
  55785. */
  55786. chromaticAberrationEnabled: boolean;
  55787. /**
  55788. * Enable or disable the grain process from the pipeline
  55789. */
  55790. grainEnabled: boolean;
  55791. /**
  55792. * @constructor
  55793. * @param name - The rendering pipeline name (default: "")
  55794. * @param hdr - If high dynamic range textures should be used (default: true)
  55795. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55796. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55797. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55798. */
  55799. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55800. /**
  55801. * Get the class name
  55802. * @returns "DefaultRenderingPipeline"
  55803. */
  55804. getClassName(): string;
  55805. /**
  55806. * Force the compilation of the entire pipeline.
  55807. */
  55808. prepare(): void;
  55809. private _hasCleared;
  55810. private _prevPostProcess;
  55811. private _prevPrevPostProcess;
  55812. private _setAutoClearAndTextureSharing;
  55813. private _depthOfFieldSceneObserver;
  55814. private _buildPipeline;
  55815. private _disposePostProcesses;
  55816. /**
  55817. * Adds a camera to the pipeline
  55818. * @param camera the camera to be added
  55819. */
  55820. addCamera(camera: Camera): void;
  55821. /**
  55822. * Removes a camera from the pipeline
  55823. * @param camera the camera to remove
  55824. */
  55825. removeCamera(camera: Camera): void;
  55826. /**
  55827. * Dispose of the pipeline and stop all post processes
  55828. */
  55829. dispose(): void;
  55830. /**
  55831. * Serialize the rendering pipeline (Used when exporting)
  55832. * @returns the serialized object
  55833. */
  55834. serialize(): any;
  55835. /**
  55836. * Parse the serialized pipeline
  55837. * @param source Source pipeline.
  55838. * @param scene The scene to load the pipeline to.
  55839. * @param rootUrl The URL of the serialized pipeline.
  55840. * @returns An instantiated pipeline from the serialized object.
  55841. */
  55842. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55843. }
  55844. }
  55845. declare module BABYLON {
  55846. /** @hidden */
  55847. export var lensHighlightsPixelShader: {
  55848. name: string;
  55849. shader: string;
  55850. };
  55851. }
  55852. declare module BABYLON {
  55853. /** @hidden */
  55854. export var depthOfFieldPixelShader: {
  55855. name: string;
  55856. shader: string;
  55857. };
  55858. }
  55859. declare module BABYLON {
  55860. /**
  55861. * BABYLON.JS Chromatic Aberration GLSL Shader
  55862. * Author: Olivier Guyot
  55863. * Separates very slightly R, G and B colors on the edges of the screen
  55864. * Inspired by Francois Tarlier & Martins Upitis
  55865. */
  55866. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  55867. /**
  55868. * @ignore
  55869. * The chromatic aberration PostProcess id in the pipeline
  55870. */
  55871. LensChromaticAberrationEffect: string;
  55872. /**
  55873. * @ignore
  55874. * The highlights enhancing PostProcess id in the pipeline
  55875. */
  55876. HighlightsEnhancingEffect: string;
  55877. /**
  55878. * @ignore
  55879. * The depth-of-field PostProcess id in the pipeline
  55880. */
  55881. LensDepthOfFieldEffect: string;
  55882. private _scene;
  55883. private _depthTexture;
  55884. private _grainTexture;
  55885. private _chromaticAberrationPostProcess;
  55886. private _highlightsPostProcess;
  55887. private _depthOfFieldPostProcess;
  55888. private _edgeBlur;
  55889. private _grainAmount;
  55890. private _chromaticAberration;
  55891. private _distortion;
  55892. private _highlightsGain;
  55893. private _highlightsThreshold;
  55894. private _dofDistance;
  55895. private _dofAperture;
  55896. private _dofDarken;
  55897. private _dofPentagon;
  55898. private _blurNoise;
  55899. /**
  55900. * @constructor
  55901. *
  55902. * Effect parameters are as follow:
  55903. * {
  55904. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55905. * edge_blur: number; // from 0 to x (1 for realism)
  55906. * distortion: number; // from 0 to x (1 for realism)
  55907. * grain_amount: number; // from 0 to 1
  55908. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55909. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55910. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55911. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55912. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55913. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55914. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55915. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55916. * }
  55917. * Note: if an effect parameter is unset, effect is disabled
  55918. *
  55919. * @param name The rendering pipeline name
  55920. * @param parameters - An object containing all parameters (see above)
  55921. * @param scene The scene linked to this pipeline
  55922. * @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)
  55923. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55924. */
  55925. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55926. /**
  55927. * Get the class name
  55928. * @returns "LensRenderingPipeline"
  55929. */
  55930. getClassName(): string;
  55931. /**
  55932. * Gets associated scene
  55933. */
  55934. readonly scene: Scene;
  55935. /**
  55936. * Gets or sets the edge blur
  55937. */
  55938. edgeBlur: number;
  55939. /**
  55940. * Gets or sets the grain amount
  55941. */
  55942. grainAmount: number;
  55943. /**
  55944. * Gets or sets the chromatic aberration amount
  55945. */
  55946. chromaticAberration: number;
  55947. /**
  55948. * Gets or sets the depth of field aperture
  55949. */
  55950. dofAperture: number;
  55951. /**
  55952. * Gets or sets the edge distortion
  55953. */
  55954. edgeDistortion: number;
  55955. /**
  55956. * Gets or sets the depth of field distortion
  55957. */
  55958. dofDistortion: number;
  55959. /**
  55960. * Gets or sets the darken out of focus amount
  55961. */
  55962. darkenOutOfFocus: number;
  55963. /**
  55964. * Gets or sets a boolean indicating if blur noise is enabled
  55965. */
  55966. blurNoise: boolean;
  55967. /**
  55968. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55969. */
  55970. pentagonBokeh: boolean;
  55971. /**
  55972. * Gets or sets the highlight grain amount
  55973. */
  55974. highlightsGain: number;
  55975. /**
  55976. * Gets or sets the highlight threshold
  55977. */
  55978. highlightsThreshold: number;
  55979. /**
  55980. * Sets the amount of blur at the edges
  55981. * @param amount blur amount
  55982. */
  55983. setEdgeBlur(amount: number): void;
  55984. /**
  55985. * Sets edge blur to 0
  55986. */
  55987. disableEdgeBlur(): void;
  55988. /**
  55989. * Sets the amout of grain
  55990. * @param amount Amount of grain
  55991. */
  55992. setGrainAmount(amount: number): void;
  55993. /**
  55994. * Set grain amount to 0
  55995. */
  55996. disableGrain(): void;
  55997. /**
  55998. * Sets the chromatic aberration amount
  55999. * @param amount amount of chromatic aberration
  56000. */
  56001. setChromaticAberration(amount: number): void;
  56002. /**
  56003. * Sets chromatic aberration amount to 0
  56004. */
  56005. disableChromaticAberration(): void;
  56006. /**
  56007. * Sets the EdgeDistortion amount
  56008. * @param amount amount of EdgeDistortion
  56009. */
  56010. setEdgeDistortion(amount: number): void;
  56011. /**
  56012. * Sets edge distortion to 0
  56013. */
  56014. disableEdgeDistortion(): void;
  56015. /**
  56016. * Sets the FocusDistance amount
  56017. * @param amount amount of FocusDistance
  56018. */
  56019. setFocusDistance(amount: number): void;
  56020. /**
  56021. * Disables depth of field
  56022. */
  56023. disableDepthOfField(): void;
  56024. /**
  56025. * Sets the Aperture amount
  56026. * @param amount amount of Aperture
  56027. */
  56028. setAperture(amount: number): void;
  56029. /**
  56030. * Sets the DarkenOutOfFocus amount
  56031. * @param amount amount of DarkenOutOfFocus
  56032. */
  56033. setDarkenOutOfFocus(amount: number): void;
  56034. private _pentagonBokehIsEnabled;
  56035. /**
  56036. * Creates a pentagon bokeh effect
  56037. */
  56038. enablePentagonBokeh(): void;
  56039. /**
  56040. * Disables the pentagon bokeh effect
  56041. */
  56042. disablePentagonBokeh(): void;
  56043. /**
  56044. * Enables noise blur
  56045. */
  56046. enableNoiseBlur(): void;
  56047. /**
  56048. * Disables noise blur
  56049. */
  56050. disableNoiseBlur(): void;
  56051. /**
  56052. * Sets the HighlightsGain amount
  56053. * @param amount amount of HighlightsGain
  56054. */
  56055. setHighlightsGain(amount: number): void;
  56056. /**
  56057. * Sets the HighlightsThreshold amount
  56058. * @param amount amount of HighlightsThreshold
  56059. */
  56060. setHighlightsThreshold(amount: number): void;
  56061. /**
  56062. * Disables highlights
  56063. */
  56064. disableHighlights(): void;
  56065. /**
  56066. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56067. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56068. */
  56069. dispose(disableDepthRender?: boolean): void;
  56070. private _createChromaticAberrationPostProcess;
  56071. private _createHighlightsPostProcess;
  56072. private _createDepthOfFieldPostProcess;
  56073. private _createGrainTexture;
  56074. }
  56075. }
  56076. declare module BABYLON {
  56077. /** @hidden */
  56078. export var ssao2PixelShader: {
  56079. name: string;
  56080. shader: string;
  56081. };
  56082. }
  56083. declare module BABYLON {
  56084. /** @hidden */
  56085. export var ssaoCombinePixelShader: {
  56086. name: string;
  56087. shader: string;
  56088. };
  56089. }
  56090. declare module BABYLON {
  56091. /**
  56092. * Render pipeline to produce ssao effect
  56093. */
  56094. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56095. /**
  56096. * @ignore
  56097. * The PassPostProcess id in the pipeline that contains the original scene color
  56098. */
  56099. SSAOOriginalSceneColorEffect: string;
  56100. /**
  56101. * @ignore
  56102. * The SSAO PostProcess id in the pipeline
  56103. */
  56104. SSAORenderEffect: string;
  56105. /**
  56106. * @ignore
  56107. * The horizontal blur PostProcess id in the pipeline
  56108. */
  56109. SSAOBlurHRenderEffect: string;
  56110. /**
  56111. * @ignore
  56112. * The vertical blur PostProcess id in the pipeline
  56113. */
  56114. SSAOBlurVRenderEffect: string;
  56115. /**
  56116. * @ignore
  56117. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56118. */
  56119. SSAOCombineRenderEffect: string;
  56120. /**
  56121. * The output strength of the SSAO post-process. Default value is 1.0.
  56122. */
  56123. totalStrength: number;
  56124. /**
  56125. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56126. */
  56127. maxZ: number;
  56128. /**
  56129. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56130. */
  56131. minZAspect: number;
  56132. private _samples;
  56133. /**
  56134. * Number of samples used for the SSAO calculations. Default value is 8
  56135. */
  56136. samples: number;
  56137. private _textureSamples;
  56138. /**
  56139. * Number of samples to use for antialiasing
  56140. */
  56141. textureSamples: number;
  56142. /**
  56143. * Ratio object used for SSAO ratio and blur ratio
  56144. */
  56145. private _ratio;
  56146. /**
  56147. * Dynamically generated sphere sampler.
  56148. */
  56149. private _sampleSphere;
  56150. /**
  56151. * Blur filter offsets
  56152. */
  56153. private _samplerOffsets;
  56154. private _expensiveBlur;
  56155. /**
  56156. * If bilateral blur should be used
  56157. */
  56158. expensiveBlur: boolean;
  56159. /**
  56160. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56161. */
  56162. radius: number;
  56163. /**
  56164. * The base color of the SSAO post-process
  56165. * The final result is "base + ssao" between [0, 1]
  56166. */
  56167. base: number;
  56168. /**
  56169. * Support test.
  56170. */
  56171. static readonly IsSupported: boolean;
  56172. private _scene;
  56173. private _depthTexture;
  56174. private _normalTexture;
  56175. private _randomTexture;
  56176. private _originalColorPostProcess;
  56177. private _ssaoPostProcess;
  56178. private _blurHPostProcess;
  56179. private _blurVPostProcess;
  56180. private _ssaoCombinePostProcess;
  56181. private _firstUpdate;
  56182. /**
  56183. * Gets active scene
  56184. */
  56185. readonly scene: Scene;
  56186. /**
  56187. * @constructor
  56188. * @param name The rendering pipeline name
  56189. * @param scene The scene linked to this pipeline
  56190. * @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 }
  56191. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56192. */
  56193. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56194. /**
  56195. * Get the class name
  56196. * @returns "SSAO2RenderingPipeline"
  56197. */
  56198. getClassName(): string;
  56199. /**
  56200. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56201. */
  56202. dispose(disableGeometryBufferRenderer?: boolean): void;
  56203. private _createBlurPostProcess;
  56204. /** @hidden */
  56205. _rebuild(): void;
  56206. private _bits;
  56207. private _radicalInverse_VdC;
  56208. private _hammersley;
  56209. private _hemisphereSample_uniform;
  56210. private _generateHemisphere;
  56211. private _createSSAOPostProcess;
  56212. private _createSSAOCombinePostProcess;
  56213. private _createRandomTexture;
  56214. /**
  56215. * Serialize the rendering pipeline (Used when exporting)
  56216. * @returns the serialized object
  56217. */
  56218. serialize(): any;
  56219. /**
  56220. * Parse the serialized pipeline
  56221. * @param source Source pipeline.
  56222. * @param scene The scene to load the pipeline to.
  56223. * @param rootUrl The URL of the serialized pipeline.
  56224. * @returns An instantiated pipeline from the serialized object.
  56225. */
  56226. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56227. }
  56228. }
  56229. declare module BABYLON {
  56230. /** @hidden */
  56231. export var ssaoPixelShader: {
  56232. name: string;
  56233. shader: string;
  56234. };
  56235. }
  56236. declare module BABYLON {
  56237. /**
  56238. * Render pipeline to produce ssao effect
  56239. */
  56240. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56241. /**
  56242. * @ignore
  56243. * The PassPostProcess id in the pipeline that contains the original scene color
  56244. */
  56245. SSAOOriginalSceneColorEffect: string;
  56246. /**
  56247. * @ignore
  56248. * The SSAO PostProcess id in the pipeline
  56249. */
  56250. SSAORenderEffect: string;
  56251. /**
  56252. * @ignore
  56253. * The horizontal blur PostProcess id in the pipeline
  56254. */
  56255. SSAOBlurHRenderEffect: string;
  56256. /**
  56257. * @ignore
  56258. * The vertical blur PostProcess id in the pipeline
  56259. */
  56260. SSAOBlurVRenderEffect: string;
  56261. /**
  56262. * @ignore
  56263. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56264. */
  56265. SSAOCombineRenderEffect: string;
  56266. /**
  56267. * The output strength of the SSAO post-process. Default value is 1.0.
  56268. */
  56269. totalStrength: number;
  56270. /**
  56271. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56272. */
  56273. radius: number;
  56274. /**
  56275. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56276. * Must not be equal to fallOff and superior to fallOff.
  56277. * Default value is 0.0075
  56278. */
  56279. area: number;
  56280. /**
  56281. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56282. * Must not be equal to area and inferior to area.
  56283. * Default value is 0.000001
  56284. */
  56285. fallOff: number;
  56286. /**
  56287. * The base color of the SSAO post-process
  56288. * The final result is "base + ssao" between [0, 1]
  56289. */
  56290. base: number;
  56291. private _scene;
  56292. private _depthTexture;
  56293. private _randomTexture;
  56294. private _originalColorPostProcess;
  56295. private _ssaoPostProcess;
  56296. private _blurHPostProcess;
  56297. private _blurVPostProcess;
  56298. private _ssaoCombinePostProcess;
  56299. private _firstUpdate;
  56300. /**
  56301. * Gets active scene
  56302. */
  56303. readonly scene: Scene;
  56304. /**
  56305. * @constructor
  56306. * @param name - The rendering pipeline name
  56307. * @param scene - The scene linked to this pipeline
  56308. * @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 }
  56309. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56310. */
  56311. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56312. /**
  56313. * Get the class name
  56314. * @returns "SSAORenderingPipeline"
  56315. */
  56316. getClassName(): string;
  56317. /**
  56318. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56319. */
  56320. dispose(disableDepthRender?: boolean): void;
  56321. private _createBlurPostProcess;
  56322. /** @hidden */
  56323. _rebuild(): void;
  56324. private _createSSAOPostProcess;
  56325. private _createSSAOCombinePostProcess;
  56326. private _createRandomTexture;
  56327. }
  56328. }
  56329. declare module BABYLON {
  56330. /** @hidden */
  56331. export var standardPixelShader: {
  56332. name: string;
  56333. shader: string;
  56334. };
  56335. }
  56336. declare module BABYLON {
  56337. /**
  56338. * Standard rendering pipeline
  56339. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56340. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56341. */
  56342. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56343. /**
  56344. * Public members
  56345. */
  56346. /**
  56347. * Post-process which contains the original scene color before the pipeline applies all the effects
  56348. */
  56349. originalPostProcess: Nullable<PostProcess>;
  56350. /**
  56351. * Post-process used to down scale an image x4
  56352. */
  56353. downSampleX4PostProcess: Nullable<PostProcess>;
  56354. /**
  56355. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56356. */
  56357. brightPassPostProcess: Nullable<PostProcess>;
  56358. /**
  56359. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56360. */
  56361. blurHPostProcesses: PostProcess[];
  56362. /**
  56363. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56364. */
  56365. blurVPostProcesses: PostProcess[];
  56366. /**
  56367. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56368. */
  56369. textureAdderPostProcess: Nullable<PostProcess>;
  56370. /**
  56371. * Post-process used to create volumetric lighting effect
  56372. */
  56373. volumetricLightPostProcess: Nullable<PostProcess>;
  56374. /**
  56375. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56376. */
  56377. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56378. /**
  56379. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56380. */
  56381. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56382. /**
  56383. * Post-process used to merge the volumetric light effect and the real scene color
  56384. */
  56385. volumetricLightMergePostProces: Nullable<PostProcess>;
  56386. /**
  56387. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56388. */
  56389. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56390. /**
  56391. * Base post-process used to calculate the average luminance of the final image for HDR
  56392. */
  56393. luminancePostProcess: Nullable<PostProcess>;
  56394. /**
  56395. * Post-processes used to create down sample post-processes in order to get
  56396. * the average luminance of the final image for HDR
  56397. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56398. */
  56399. luminanceDownSamplePostProcesses: PostProcess[];
  56400. /**
  56401. * Post-process used to create a HDR effect (light adaptation)
  56402. */
  56403. hdrPostProcess: Nullable<PostProcess>;
  56404. /**
  56405. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56406. */
  56407. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56408. /**
  56409. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56410. */
  56411. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56412. /**
  56413. * Post-process used to merge the final HDR post-process and the real scene color
  56414. */
  56415. hdrFinalPostProcess: Nullable<PostProcess>;
  56416. /**
  56417. * Post-process used to create a lens flare effect
  56418. */
  56419. lensFlarePostProcess: Nullable<PostProcess>;
  56420. /**
  56421. * Post-process that merges the result of the lens flare post-process and the real scene color
  56422. */
  56423. lensFlareComposePostProcess: Nullable<PostProcess>;
  56424. /**
  56425. * Post-process used to create a motion blur effect
  56426. */
  56427. motionBlurPostProcess: Nullable<PostProcess>;
  56428. /**
  56429. * Post-process used to create a depth of field effect
  56430. */
  56431. depthOfFieldPostProcess: Nullable<PostProcess>;
  56432. /**
  56433. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56434. */
  56435. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56436. /**
  56437. * Represents the brightness threshold in order to configure the illuminated surfaces
  56438. */
  56439. brightThreshold: number;
  56440. /**
  56441. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56442. */
  56443. blurWidth: number;
  56444. /**
  56445. * Sets if the blur for highlighted surfaces must be only horizontal
  56446. */
  56447. horizontalBlur: boolean;
  56448. /**
  56449. * Gets the overall exposure used by the pipeline
  56450. */
  56451. /**
  56452. * Sets the overall exposure used by the pipeline
  56453. */
  56454. exposure: number;
  56455. /**
  56456. * Texture used typically to simulate "dirty" on camera lens
  56457. */
  56458. lensTexture: Nullable<Texture>;
  56459. /**
  56460. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56461. */
  56462. volumetricLightCoefficient: number;
  56463. /**
  56464. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56465. */
  56466. volumetricLightPower: number;
  56467. /**
  56468. * Used the set the blur intensity to smooth the volumetric lights
  56469. */
  56470. volumetricLightBlurScale: number;
  56471. /**
  56472. * Light (spot or directional) used to generate the volumetric lights rays
  56473. * The source light must have a shadow generate so the pipeline can get its
  56474. * depth map
  56475. */
  56476. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56477. /**
  56478. * For eye adaptation, represents the minimum luminance the eye can see
  56479. */
  56480. hdrMinimumLuminance: number;
  56481. /**
  56482. * For eye adaptation, represents the decrease luminance speed
  56483. */
  56484. hdrDecreaseRate: number;
  56485. /**
  56486. * For eye adaptation, represents the increase luminance speed
  56487. */
  56488. hdrIncreaseRate: number;
  56489. /**
  56490. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56491. */
  56492. /**
  56493. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56494. */
  56495. hdrAutoExposure: boolean;
  56496. /**
  56497. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56498. */
  56499. lensColorTexture: Nullable<Texture>;
  56500. /**
  56501. * The overall strengh for the lens flare effect
  56502. */
  56503. lensFlareStrength: number;
  56504. /**
  56505. * Dispersion coefficient for lens flare ghosts
  56506. */
  56507. lensFlareGhostDispersal: number;
  56508. /**
  56509. * Main lens flare halo width
  56510. */
  56511. lensFlareHaloWidth: number;
  56512. /**
  56513. * Based on the lens distortion effect, defines how much the lens flare result
  56514. * is distorted
  56515. */
  56516. lensFlareDistortionStrength: number;
  56517. /**
  56518. * Lens star texture must be used to simulate rays on the flares and is available
  56519. * in the documentation
  56520. */
  56521. lensStarTexture: Nullable<Texture>;
  56522. /**
  56523. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56524. * flare effect by taking account of the dirt texture
  56525. */
  56526. lensFlareDirtTexture: Nullable<Texture>;
  56527. /**
  56528. * Represents the focal length for the depth of field effect
  56529. */
  56530. depthOfFieldDistance: number;
  56531. /**
  56532. * Represents the blur intensity for the blurred part of the depth of field effect
  56533. */
  56534. depthOfFieldBlurWidth: number;
  56535. /**
  56536. * Gets how much the image is blurred by the movement while using the motion blur post-process
  56537. */
  56538. /**
  56539. * Sets how much the image is blurred by the movement while using the motion blur post-process
  56540. */
  56541. motionStrength: number;
  56542. /**
  56543. * Gets wether or not the motion blur post-process is object based or screen based.
  56544. */
  56545. /**
  56546. * Sets wether or not the motion blur post-process should be object based or screen based
  56547. */
  56548. objectBasedMotionBlur: boolean;
  56549. /**
  56550. * List of animations for the pipeline (IAnimatable implementation)
  56551. */
  56552. animations: Animation[];
  56553. /**
  56554. * Private members
  56555. */
  56556. private _scene;
  56557. private _currentDepthOfFieldSource;
  56558. private _basePostProcess;
  56559. private _fixedExposure;
  56560. private _currentExposure;
  56561. private _hdrAutoExposure;
  56562. private _hdrCurrentLuminance;
  56563. private _motionStrength;
  56564. private _isObjectBasedMotionBlur;
  56565. private _floatTextureType;
  56566. private _ratio;
  56567. private _bloomEnabled;
  56568. private _depthOfFieldEnabled;
  56569. private _vlsEnabled;
  56570. private _lensFlareEnabled;
  56571. private _hdrEnabled;
  56572. private _motionBlurEnabled;
  56573. private _fxaaEnabled;
  56574. private _motionBlurSamples;
  56575. private _volumetricLightStepsCount;
  56576. private _samples;
  56577. /**
  56578. * @ignore
  56579. * Specifies if the bloom pipeline is enabled
  56580. */
  56581. BloomEnabled: boolean;
  56582. /**
  56583. * @ignore
  56584. * Specifies if the depth of field pipeline is enabed
  56585. */
  56586. DepthOfFieldEnabled: boolean;
  56587. /**
  56588. * @ignore
  56589. * Specifies if the lens flare pipeline is enabed
  56590. */
  56591. LensFlareEnabled: boolean;
  56592. /**
  56593. * @ignore
  56594. * Specifies if the HDR pipeline is enabled
  56595. */
  56596. HDREnabled: boolean;
  56597. /**
  56598. * @ignore
  56599. * Specifies if the volumetric lights scattering effect is enabled
  56600. */
  56601. VLSEnabled: boolean;
  56602. /**
  56603. * @ignore
  56604. * Specifies if the motion blur effect is enabled
  56605. */
  56606. MotionBlurEnabled: boolean;
  56607. /**
  56608. * Specifies if anti-aliasing is enabled
  56609. */
  56610. fxaaEnabled: boolean;
  56611. /**
  56612. * Specifies the number of steps used to calculate the volumetric lights
  56613. * Typically in interval [50, 200]
  56614. */
  56615. volumetricLightStepsCount: number;
  56616. /**
  56617. * Specifies the number of samples used for the motion blur effect
  56618. * Typically in interval [16, 64]
  56619. */
  56620. motionBlurSamples: number;
  56621. /**
  56622. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56623. */
  56624. samples: number;
  56625. /**
  56626. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56627. * @constructor
  56628. * @param name The rendering pipeline name
  56629. * @param scene The scene linked to this pipeline
  56630. * @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)
  56631. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56632. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56633. */
  56634. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56635. private _buildPipeline;
  56636. private _createDownSampleX4PostProcess;
  56637. private _createBrightPassPostProcess;
  56638. private _createBlurPostProcesses;
  56639. private _createTextureAdderPostProcess;
  56640. private _createVolumetricLightPostProcess;
  56641. private _createLuminancePostProcesses;
  56642. private _createHdrPostProcess;
  56643. private _createLensFlarePostProcess;
  56644. private _createDepthOfFieldPostProcess;
  56645. private _createMotionBlurPostProcess;
  56646. private _getDepthTexture;
  56647. private _disposePostProcesses;
  56648. /**
  56649. * Dispose of the pipeline and stop all post processes
  56650. */
  56651. dispose(): void;
  56652. /**
  56653. * Serialize the rendering pipeline (Used when exporting)
  56654. * @returns the serialized object
  56655. */
  56656. serialize(): any;
  56657. /**
  56658. * Parse the serialized pipeline
  56659. * @param source Source pipeline.
  56660. * @param scene The scene to load the pipeline to.
  56661. * @param rootUrl The URL of the serialized pipeline.
  56662. * @returns An instantiated pipeline from the serialized object.
  56663. */
  56664. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56665. /**
  56666. * Luminance steps
  56667. */
  56668. static LuminanceSteps: number;
  56669. }
  56670. }
  56671. declare module BABYLON {
  56672. /** @hidden */
  56673. export var tonemapPixelShader: {
  56674. name: string;
  56675. shader: string;
  56676. };
  56677. }
  56678. declare module BABYLON {
  56679. /** Defines operator used for tonemapping */
  56680. export enum TonemappingOperator {
  56681. /** Hable */
  56682. Hable = 0,
  56683. /** Reinhard */
  56684. Reinhard = 1,
  56685. /** HejiDawson */
  56686. HejiDawson = 2,
  56687. /** Photographic */
  56688. Photographic = 3
  56689. }
  56690. /**
  56691. * Defines a post process to apply tone mapping
  56692. */
  56693. export class TonemapPostProcess extends PostProcess {
  56694. private _operator;
  56695. /** Defines the required exposure adjustement */
  56696. exposureAdjustment: number;
  56697. /**
  56698. * Creates a new TonemapPostProcess
  56699. * @param name defines the name of the postprocess
  56700. * @param _operator defines the operator to use
  56701. * @param exposureAdjustment defines the required exposure adjustement
  56702. * @param camera defines the camera to use (can be null)
  56703. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56704. * @param engine defines the hosting engine (can be ignore if camera is set)
  56705. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56706. */
  56707. constructor(name: string, _operator: TonemappingOperator,
  56708. /** Defines the required exposure adjustement */
  56709. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56710. }
  56711. }
  56712. declare module BABYLON {
  56713. /** @hidden */
  56714. export var depthVertexShader: {
  56715. name: string;
  56716. shader: string;
  56717. };
  56718. }
  56719. declare module BABYLON {
  56720. /** @hidden */
  56721. export var volumetricLightScatteringPixelShader: {
  56722. name: string;
  56723. shader: string;
  56724. };
  56725. }
  56726. declare module BABYLON {
  56727. /** @hidden */
  56728. export var volumetricLightScatteringPassPixelShader: {
  56729. name: string;
  56730. shader: string;
  56731. };
  56732. }
  56733. declare module BABYLON {
  56734. /**
  56735. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  56736. */
  56737. export class VolumetricLightScatteringPostProcess extends PostProcess {
  56738. private _volumetricLightScatteringPass;
  56739. private _volumetricLightScatteringRTT;
  56740. private _viewPort;
  56741. private _screenCoordinates;
  56742. private _cachedDefines;
  56743. /**
  56744. * If not undefined, the mesh position is computed from the attached node position
  56745. */
  56746. attachedNode: {
  56747. position: Vector3;
  56748. };
  56749. /**
  56750. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56751. */
  56752. customMeshPosition: Vector3;
  56753. /**
  56754. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56755. */
  56756. useCustomMeshPosition: boolean;
  56757. /**
  56758. * If the post-process should inverse the light scattering direction
  56759. */
  56760. invert: boolean;
  56761. /**
  56762. * The internal mesh used by the post-process
  56763. */
  56764. mesh: Mesh;
  56765. /**
  56766. * @hidden
  56767. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56768. */
  56769. useDiffuseColor: boolean;
  56770. /**
  56771. * Array containing the excluded meshes not rendered in the internal pass
  56772. */
  56773. excludedMeshes: AbstractMesh[];
  56774. /**
  56775. * Controls the overall intensity of the post-process
  56776. */
  56777. exposure: number;
  56778. /**
  56779. * Dissipates each sample's contribution in range [0, 1]
  56780. */
  56781. decay: number;
  56782. /**
  56783. * Controls the overall intensity of each sample
  56784. */
  56785. weight: number;
  56786. /**
  56787. * Controls the density of each sample
  56788. */
  56789. density: number;
  56790. /**
  56791. * @constructor
  56792. * @param name The post-process name
  56793. * @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)
  56794. * @param camera The camera that the post-process will be attached to
  56795. * @param mesh The mesh used to create the light scattering
  56796. * @param samples The post-process quality, default 100
  56797. * @param samplingModeThe post-process filtering mode
  56798. * @param engine The babylon engine
  56799. * @param reusable If the post-process is reusable
  56800. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56801. */
  56802. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56803. /**
  56804. * Returns the string "VolumetricLightScatteringPostProcess"
  56805. * @returns "VolumetricLightScatteringPostProcess"
  56806. */
  56807. getClassName(): string;
  56808. private _isReady;
  56809. /**
  56810. * Sets the new light position for light scattering effect
  56811. * @param position The new custom light position
  56812. */
  56813. setCustomMeshPosition(position: Vector3): void;
  56814. /**
  56815. * Returns the light position for light scattering effect
  56816. * @return Vector3 The custom light position
  56817. */
  56818. getCustomMeshPosition(): Vector3;
  56819. /**
  56820. * Disposes the internal assets and detaches the post-process from the camera
  56821. */
  56822. dispose(camera: Camera): void;
  56823. /**
  56824. * Returns the render target texture used by the post-process
  56825. * @return the render target texture used by the post-process
  56826. */
  56827. getPass(): RenderTargetTexture;
  56828. private _meshExcluded;
  56829. private _createPass;
  56830. private _updateMeshScreenCoordinates;
  56831. /**
  56832. * Creates a default mesh for the Volumeric Light Scattering post-process
  56833. * @param name The mesh name
  56834. * @param scene The scene where to create the mesh
  56835. * @return the default mesh
  56836. */
  56837. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  56838. }
  56839. }
  56840. declare module BABYLON {
  56841. interface Scene {
  56842. /** @hidden (Backing field) */
  56843. _boundingBoxRenderer: BoundingBoxRenderer;
  56844. /** @hidden (Backing field) */
  56845. _forceShowBoundingBoxes: boolean;
  56846. /**
  56847. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56848. */
  56849. forceShowBoundingBoxes: boolean;
  56850. /**
  56851. * Gets the bounding box renderer associated with the scene
  56852. * @returns a BoundingBoxRenderer
  56853. */
  56854. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56855. }
  56856. interface AbstractMesh {
  56857. /** @hidden (Backing field) */
  56858. _showBoundingBox: boolean;
  56859. /**
  56860. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56861. */
  56862. showBoundingBox: boolean;
  56863. }
  56864. /**
  56865. * Component responsible of rendering the bounding box of the meshes in a scene.
  56866. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56867. */
  56868. export class BoundingBoxRenderer implements ISceneComponent {
  56869. /**
  56870. * The component name helpfull to identify the component in the list of scene components.
  56871. */
  56872. readonly name: string;
  56873. /**
  56874. * The scene the component belongs to.
  56875. */
  56876. scene: Scene;
  56877. /**
  56878. * Color of the bounding box lines placed in front of an object
  56879. */
  56880. frontColor: Color3;
  56881. /**
  56882. * Color of the bounding box lines placed behind an object
  56883. */
  56884. backColor: Color3;
  56885. /**
  56886. * Defines if the renderer should show the back lines or not
  56887. */
  56888. showBackLines: boolean;
  56889. /**
  56890. * @hidden
  56891. */
  56892. renderList: SmartArray<BoundingBox>;
  56893. private _colorShader;
  56894. private _vertexBuffers;
  56895. private _indexBuffer;
  56896. /**
  56897. * Instantiates a new bounding box renderer in a scene.
  56898. * @param scene the scene the renderer renders in
  56899. */
  56900. constructor(scene: Scene);
  56901. /**
  56902. * Registers the component in a given scene
  56903. */
  56904. register(): void;
  56905. private _evaluateSubMesh;
  56906. private _activeMesh;
  56907. private _prepareRessources;
  56908. private _createIndexBuffer;
  56909. /**
  56910. * Rebuilds the elements related to this component in case of
  56911. * context lost for instance.
  56912. */
  56913. rebuild(): void;
  56914. /**
  56915. * @hidden
  56916. */
  56917. reset(): void;
  56918. /**
  56919. * Render the bounding boxes of a specific rendering group
  56920. * @param renderingGroupId defines the rendering group to render
  56921. */
  56922. render(renderingGroupId: number): void;
  56923. /**
  56924. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56925. * @param mesh Define the mesh to render the occlusion bounding box for
  56926. */
  56927. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56928. /**
  56929. * Dispose and release the resources attached to this renderer.
  56930. */
  56931. dispose(): void;
  56932. }
  56933. }
  56934. declare module BABYLON {
  56935. /** @hidden */
  56936. export var depthPixelShader: {
  56937. name: string;
  56938. shader: string;
  56939. };
  56940. }
  56941. declare module BABYLON {
  56942. /**
  56943. * This represents a depth renderer in Babylon.
  56944. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56945. */
  56946. export class DepthRenderer {
  56947. private _scene;
  56948. private _depthMap;
  56949. private _effect;
  56950. private _cachedDefines;
  56951. private _camera;
  56952. /**
  56953. * Specifiess that the depth renderer will only be used within
  56954. * the camera it is created for.
  56955. * This can help forcing its rendering during the camera processing.
  56956. */
  56957. useOnlyInActiveCamera: boolean;
  56958. /** @hidden */
  56959. static _SceneComponentInitialization: (scene: Scene) => void;
  56960. /**
  56961. * Instantiates a depth renderer
  56962. * @param scene The scene the renderer belongs to
  56963. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56964. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56965. */
  56966. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56967. /**
  56968. * Creates the depth rendering effect and checks if the effect is ready.
  56969. * @param subMesh The submesh to be used to render the depth map of
  56970. * @param useInstances If multiple world instances should be used
  56971. * @returns if the depth renderer is ready to render the depth map
  56972. */
  56973. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56974. /**
  56975. * Gets the texture which the depth map will be written to.
  56976. * @returns The depth map texture
  56977. */
  56978. getDepthMap(): RenderTargetTexture;
  56979. /**
  56980. * Disposes of the depth renderer.
  56981. */
  56982. dispose(): void;
  56983. }
  56984. }
  56985. declare module BABYLON {
  56986. interface Scene {
  56987. /** @hidden (Backing field) */
  56988. _depthRenderer: {
  56989. [id: string]: DepthRenderer;
  56990. };
  56991. /**
  56992. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56993. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56994. * @returns the created depth renderer
  56995. */
  56996. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56997. /**
  56998. * Disables a depth renderer for a given camera
  56999. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57000. */
  57001. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57002. }
  57003. /**
  57004. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57005. * in several rendering techniques.
  57006. */
  57007. export class DepthRendererSceneComponent implements ISceneComponent {
  57008. /**
  57009. * The component name helpfull to identify the component in the list of scene components.
  57010. */
  57011. readonly name: string;
  57012. /**
  57013. * The scene the component belongs to.
  57014. */
  57015. scene: Scene;
  57016. /**
  57017. * Creates a new instance of the component for the given scene
  57018. * @param scene Defines the scene to register the component in
  57019. */
  57020. constructor(scene: Scene);
  57021. /**
  57022. * Registers the component in a given scene
  57023. */
  57024. register(): void;
  57025. /**
  57026. * Rebuilds the elements related to this component in case of
  57027. * context lost for instance.
  57028. */
  57029. rebuild(): void;
  57030. /**
  57031. * Disposes the component and the associated ressources
  57032. */
  57033. dispose(): void;
  57034. private _gatherRenderTargets;
  57035. private _gatherActiveCameraRenderTargets;
  57036. }
  57037. }
  57038. declare module BABYLON {
  57039. /** @hidden */
  57040. export var outlinePixelShader: {
  57041. name: string;
  57042. shader: string;
  57043. };
  57044. }
  57045. declare module BABYLON {
  57046. /** @hidden */
  57047. export var outlineVertexShader: {
  57048. name: string;
  57049. shader: string;
  57050. };
  57051. }
  57052. declare module BABYLON {
  57053. interface Scene {
  57054. /** @hidden */
  57055. _outlineRenderer: OutlineRenderer;
  57056. /**
  57057. * Gets the outline renderer associated with the scene
  57058. * @returns a OutlineRenderer
  57059. */
  57060. getOutlineRenderer(): OutlineRenderer;
  57061. }
  57062. interface AbstractMesh {
  57063. /** @hidden (Backing field) */
  57064. _renderOutline: boolean;
  57065. /**
  57066. * Gets or sets a boolean indicating if the outline must be rendered as well
  57067. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57068. */
  57069. renderOutline: boolean;
  57070. /** @hidden (Backing field) */
  57071. _renderOverlay: boolean;
  57072. /**
  57073. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57074. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57075. */
  57076. renderOverlay: boolean;
  57077. }
  57078. /**
  57079. * This class is responsible to draw bothe outline/overlay of meshes.
  57080. * It should not be used directly but through the available method on mesh.
  57081. */
  57082. export class OutlineRenderer implements ISceneComponent {
  57083. /**
  57084. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57085. */
  57086. private static _StencilReference;
  57087. /**
  57088. * The name of the component. Each component must have a unique name.
  57089. */
  57090. name: string;
  57091. /**
  57092. * The scene the component belongs to.
  57093. */
  57094. scene: Scene;
  57095. /**
  57096. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57097. */
  57098. zOffset: number;
  57099. private _engine;
  57100. private _effect;
  57101. private _cachedDefines;
  57102. private _savedDepthWrite;
  57103. /**
  57104. * Instantiates a new outline renderer. (There could be only one per scene).
  57105. * @param scene Defines the scene it belongs to
  57106. */
  57107. constructor(scene: Scene);
  57108. /**
  57109. * Register the component to one instance of a scene.
  57110. */
  57111. register(): void;
  57112. /**
  57113. * Rebuilds the elements related to this component in case of
  57114. * context lost for instance.
  57115. */
  57116. rebuild(): void;
  57117. /**
  57118. * Disposes the component and the associated ressources.
  57119. */
  57120. dispose(): void;
  57121. /**
  57122. * Renders the outline in the canvas.
  57123. * @param subMesh Defines the sumesh to render
  57124. * @param batch Defines the batch of meshes in case of instances
  57125. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57126. */
  57127. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57128. /**
  57129. * Returns whether or not the outline renderer is ready for a given submesh.
  57130. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57131. * @param subMesh Defines the submesh to check readyness for
  57132. * @param useInstances Defines wheter wee are trying to render instances or not
  57133. * @returns true if ready otherwise false
  57134. */
  57135. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57136. private _beforeRenderingMesh;
  57137. private _afterRenderingMesh;
  57138. }
  57139. }
  57140. declare module BABYLON {
  57141. /**
  57142. * Defines the list of states available for a task inside a AssetsManager
  57143. */
  57144. export enum AssetTaskState {
  57145. /**
  57146. * Initialization
  57147. */
  57148. INIT = 0,
  57149. /**
  57150. * Running
  57151. */
  57152. RUNNING = 1,
  57153. /**
  57154. * Done
  57155. */
  57156. DONE = 2,
  57157. /**
  57158. * Error
  57159. */
  57160. ERROR = 3
  57161. }
  57162. /**
  57163. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57164. */
  57165. export abstract class AbstractAssetTask {
  57166. /**
  57167. * Task name
  57168. */ name: string;
  57169. /**
  57170. * Callback called when the task is successful
  57171. */
  57172. onSuccess: (task: any) => void;
  57173. /**
  57174. * Callback called when the task is not successful
  57175. */
  57176. onError: (task: any, message?: string, exception?: any) => void;
  57177. /**
  57178. * Creates a new AssetsManager
  57179. * @param name defines the name of the task
  57180. */
  57181. constructor(
  57182. /**
  57183. * Task name
  57184. */ name: string);
  57185. private _isCompleted;
  57186. private _taskState;
  57187. private _errorObject;
  57188. /**
  57189. * Get if the task is completed
  57190. */
  57191. readonly isCompleted: boolean;
  57192. /**
  57193. * Gets the current state of the task
  57194. */
  57195. readonly taskState: AssetTaskState;
  57196. /**
  57197. * Gets the current error object (if task is in error)
  57198. */
  57199. readonly errorObject: {
  57200. message?: string;
  57201. exception?: any;
  57202. };
  57203. /**
  57204. * Internal only
  57205. * @hidden
  57206. */
  57207. _setErrorObject(message?: string, exception?: any): void;
  57208. /**
  57209. * Execute the current task
  57210. * @param scene defines the scene where you want your assets to be loaded
  57211. * @param onSuccess is a callback called when the task is successfully executed
  57212. * @param onError is a callback called if an error occurs
  57213. */
  57214. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57215. /**
  57216. * Execute the current task
  57217. * @param scene defines the scene where you want your assets to be loaded
  57218. * @param onSuccess is a callback called when the task is successfully executed
  57219. * @param onError is a callback called if an error occurs
  57220. */
  57221. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57222. /**
  57223. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57224. * This can be used with failed tasks that have the reason for failure fixed.
  57225. */
  57226. reset(): void;
  57227. private onErrorCallback;
  57228. private onDoneCallback;
  57229. }
  57230. /**
  57231. * Define the interface used by progress events raised during assets loading
  57232. */
  57233. export interface IAssetsProgressEvent {
  57234. /**
  57235. * Defines the number of remaining tasks to process
  57236. */
  57237. remainingCount: number;
  57238. /**
  57239. * Defines the total number of tasks
  57240. */
  57241. totalCount: number;
  57242. /**
  57243. * Defines the task that was just processed
  57244. */
  57245. task: AbstractAssetTask;
  57246. }
  57247. /**
  57248. * Class used to share progress information about assets loading
  57249. */
  57250. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57251. /**
  57252. * Defines the number of remaining tasks to process
  57253. */
  57254. remainingCount: number;
  57255. /**
  57256. * Defines the total number of tasks
  57257. */
  57258. totalCount: number;
  57259. /**
  57260. * Defines the task that was just processed
  57261. */
  57262. task: AbstractAssetTask;
  57263. /**
  57264. * Creates a AssetsProgressEvent
  57265. * @param remainingCount defines the number of remaining tasks to process
  57266. * @param totalCount defines the total number of tasks
  57267. * @param task defines the task that was just processed
  57268. */
  57269. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57270. }
  57271. /**
  57272. * Define a task used by AssetsManager to load meshes
  57273. */
  57274. export class MeshAssetTask extends AbstractAssetTask {
  57275. /**
  57276. * Defines the name of the task
  57277. */
  57278. name: string;
  57279. /**
  57280. * Defines the list of mesh's names you want to load
  57281. */
  57282. meshesNames: any;
  57283. /**
  57284. * Defines the root url to use as a base to load your meshes and associated resources
  57285. */
  57286. rootUrl: string;
  57287. /**
  57288. * Defines the filename of the scene to load from
  57289. */
  57290. sceneFilename: string;
  57291. /**
  57292. * Gets the list of loaded meshes
  57293. */
  57294. loadedMeshes: Array<AbstractMesh>;
  57295. /**
  57296. * Gets the list of loaded particle systems
  57297. */
  57298. loadedParticleSystems: Array<IParticleSystem>;
  57299. /**
  57300. * Gets the list of loaded skeletons
  57301. */
  57302. loadedSkeletons: Array<Skeleton>;
  57303. /**
  57304. * Gets the list of loaded animation groups
  57305. */
  57306. loadedAnimationGroups: Array<AnimationGroup>;
  57307. /**
  57308. * Callback called when the task is successful
  57309. */
  57310. onSuccess: (task: MeshAssetTask) => void;
  57311. /**
  57312. * Callback called when the task is successful
  57313. */
  57314. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57315. /**
  57316. * Creates a new MeshAssetTask
  57317. * @param name defines the name of the task
  57318. * @param meshesNames defines the list of mesh's names you want to load
  57319. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57320. * @param sceneFilename defines the filename of the scene to load from
  57321. */
  57322. constructor(
  57323. /**
  57324. * Defines the name of the task
  57325. */
  57326. name: string,
  57327. /**
  57328. * Defines the list of mesh's names you want to load
  57329. */
  57330. meshesNames: any,
  57331. /**
  57332. * Defines the root url to use as a base to load your meshes and associated resources
  57333. */
  57334. rootUrl: string,
  57335. /**
  57336. * Defines the filename of the scene to load from
  57337. */
  57338. sceneFilename: string);
  57339. /**
  57340. * Execute the current task
  57341. * @param scene defines the scene where you want your assets to be loaded
  57342. * @param onSuccess is a callback called when the task is successfully executed
  57343. * @param onError is a callback called if an error occurs
  57344. */
  57345. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57346. }
  57347. /**
  57348. * Define a task used by AssetsManager to load text content
  57349. */
  57350. export class TextFileAssetTask extends AbstractAssetTask {
  57351. /**
  57352. * Defines the name of the task
  57353. */
  57354. name: string;
  57355. /**
  57356. * Defines the location of the file to load
  57357. */
  57358. url: string;
  57359. /**
  57360. * Gets the loaded text string
  57361. */
  57362. text: string;
  57363. /**
  57364. * Callback called when the task is successful
  57365. */
  57366. onSuccess: (task: TextFileAssetTask) => void;
  57367. /**
  57368. * Callback called when the task is successful
  57369. */
  57370. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57371. /**
  57372. * Creates a new TextFileAssetTask object
  57373. * @param name defines the name of the task
  57374. * @param url defines the location of the file to load
  57375. */
  57376. constructor(
  57377. /**
  57378. * Defines the name of the task
  57379. */
  57380. name: string,
  57381. /**
  57382. * Defines the location of the file to load
  57383. */
  57384. url: string);
  57385. /**
  57386. * Execute the current task
  57387. * @param scene defines the scene where you want your assets to be loaded
  57388. * @param onSuccess is a callback called when the task is successfully executed
  57389. * @param onError is a callback called if an error occurs
  57390. */
  57391. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57392. }
  57393. /**
  57394. * Define a task used by AssetsManager to load binary data
  57395. */
  57396. export class BinaryFileAssetTask extends AbstractAssetTask {
  57397. /**
  57398. * Defines the name of the task
  57399. */
  57400. name: string;
  57401. /**
  57402. * Defines the location of the file to load
  57403. */
  57404. url: string;
  57405. /**
  57406. * Gets the lodaded data (as an array buffer)
  57407. */
  57408. data: ArrayBuffer;
  57409. /**
  57410. * Callback called when the task is successful
  57411. */
  57412. onSuccess: (task: BinaryFileAssetTask) => void;
  57413. /**
  57414. * Callback called when the task is successful
  57415. */
  57416. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57417. /**
  57418. * Creates a new BinaryFileAssetTask object
  57419. * @param name defines the name of the new task
  57420. * @param url defines the location of the file to load
  57421. */
  57422. constructor(
  57423. /**
  57424. * Defines the name of the task
  57425. */
  57426. name: string,
  57427. /**
  57428. * Defines the location of the file to load
  57429. */
  57430. url: string);
  57431. /**
  57432. * Execute the current task
  57433. * @param scene defines the scene where you want your assets to be loaded
  57434. * @param onSuccess is a callback called when the task is successfully executed
  57435. * @param onError is a callback called if an error occurs
  57436. */
  57437. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57438. }
  57439. /**
  57440. * Define a task used by AssetsManager to load images
  57441. */
  57442. export class ImageAssetTask extends AbstractAssetTask {
  57443. /**
  57444. * Defines the name of the task
  57445. */
  57446. name: string;
  57447. /**
  57448. * Defines the location of the image to load
  57449. */
  57450. url: string;
  57451. /**
  57452. * Gets the loaded images
  57453. */
  57454. image: HTMLImageElement;
  57455. /**
  57456. * Callback called when the task is successful
  57457. */
  57458. onSuccess: (task: ImageAssetTask) => void;
  57459. /**
  57460. * Callback called when the task is successful
  57461. */
  57462. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57463. /**
  57464. * Creates a new ImageAssetTask
  57465. * @param name defines the name of the task
  57466. * @param url defines the location of the image to load
  57467. */
  57468. constructor(
  57469. /**
  57470. * Defines the name of the task
  57471. */
  57472. name: string,
  57473. /**
  57474. * Defines the location of the image to load
  57475. */
  57476. url: string);
  57477. /**
  57478. * Execute the current task
  57479. * @param scene defines the scene where you want your assets to be loaded
  57480. * @param onSuccess is a callback called when the task is successfully executed
  57481. * @param onError is a callback called if an error occurs
  57482. */
  57483. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57484. }
  57485. /**
  57486. * Defines the interface used by texture loading tasks
  57487. */
  57488. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57489. /**
  57490. * Gets the loaded texture
  57491. */
  57492. texture: TEX;
  57493. }
  57494. /**
  57495. * Define a task used by AssetsManager to load 2D textures
  57496. */
  57497. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57498. /**
  57499. * Defines the name of the task
  57500. */
  57501. name: string;
  57502. /**
  57503. * Defines the location of the file to load
  57504. */
  57505. url: string;
  57506. /**
  57507. * Defines if mipmap should not be generated (default is false)
  57508. */
  57509. noMipmap?: boolean | undefined;
  57510. /**
  57511. * Defines if texture must be inverted on Y axis (default is false)
  57512. */
  57513. invertY?: boolean | undefined;
  57514. /**
  57515. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57516. */
  57517. samplingMode: number;
  57518. /**
  57519. * Gets the loaded texture
  57520. */
  57521. texture: Texture;
  57522. /**
  57523. * Callback called when the task is successful
  57524. */
  57525. onSuccess: (task: TextureAssetTask) => void;
  57526. /**
  57527. * Callback called when the task is successful
  57528. */
  57529. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57530. /**
  57531. * Creates a new TextureAssetTask object
  57532. * @param name defines the name of the task
  57533. * @param url defines the location of the file to load
  57534. * @param noMipmap defines if mipmap should not be generated (default is false)
  57535. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57536. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57537. */
  57538. constructor(
  57539. /**
  57540. * Defines the name of the task
  57541. */
  57542. name: string,
  57543. /**
  57544. * Defines the location of the file to load
  57545. */
  57546. url: string,
  57547. /**
  57548. * Defines if mipmap should not be generated (default is false)
  57549. */
  57550. noMipmap?: boolean | undefined,
  57551. /**
  57552. * Defines if texture must be inverted on Y axis (default is false)
  57553. */
  57554. invertY?: boolean | undefined,
  57555. /**
  57556. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57557. */
  57558. samplingMode?: number);
  57559. /**
  57560. * Execute the current task
  57561. * @param scene defines the scene where you want your assets to be loaded
  57562. * @param onSuccess is a callback called when the task is successfully executed
  57563. * @param onError is a callback called if an error occurs
  57564. */
  57565. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57566. }
  57567. /**
  57568. * Define a task used by AssetsManager to load cube textures
  57569. */
  57570. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57571. /**
  57572. * Defines the name of the task
  57573. */
  57574. name: string;
  57575. /**
  57576. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57577. */
  57578. url: string;
  57579. /**
  57580. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57581. */
  57582. extensions?: string[] | undefined;
  57583. /**
  57584. * Defines if mipmaps should not be generated (default is false)
  57585. */
  57586. noMipmap?: boolean | undefined;
  57587. /**
  57588. * Defines the explicit list of files (undefined by default)
  57589. */
  57590. files?: string[] | undefined;
  57591. /**
  57592. * Gets the loaded texture
  57593. */
  57594. texture: CubeTexture;
  57595. /**
  57596. * Callback called when the task is successful
  57597. */
  57598. onSuccess: (task: CubeTextureAssetTask) => void;
  57599. /**
  57600. * Callback called when the task is successful
  57601. */
  57602. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57603. /**
  57604. * Creates a new CubeTextureAssetTask
  57605. * @param name defines the name of the task
  57606. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57607. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57608. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57609. * @param files defines the explicit list of files (undefined by default)
  57610. */
  57611. constructor(
  57612. /**
  57613. * Defines the name of the task
  57614. */
  57615. name: string,
  57616. /**
  57617. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57618. */
  57619. url: string,
  57620. /**
  57621. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57622. */
  57623. extensions?: string[] | undefined,
  57624. /**
  57625. * Defines if mipmaps should not be generated (default is false)
  57626. */
  57627. noMipmap?: boolean | undefined,
  57628. /**
  57629. * Defines the explicit list of files (undefined by default)
  57630. */
  57631. files?: string[] | undefined);
  57632. /**
  57633. * Execute the current task
  57634. * @param scene defines the scene where you want your assets to be loaded
  57635. * @param onSuccess is a callback called when the task is successfully executed
  57636. * @param onError is a callback called if an error occurs
  57637. */
  57638. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57639. }
  57640. /**
  57641. * Define a task used by AssetsManager to load HDR cube textures
  57642. */
  57643. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57644. /**
  57645. * Defines the name of the task
  57646. */
  57647. name: string;
  57648. /**
  57649. * Defines the location of the file to load
  57650. */
  57651. url: string;
  57652. /**
  57653. * Defines the desired size (the more it increases the longer the generation will be)
  57654. */
  57655. size: number;
  57656. /**
  57657. * Defines if mipmaps should not be generated (default is false)
  57658. */
  57659. noMipmap: boolean;
  57660. /**
  57661. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57662. */
  57663. generateHarmonics: boolean;
  57664. /**
  57665. * 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)
  57666. */
  57667. gammaSpace: boolean;
  57668. /**
  57669. * Internal Use Only
  57670. */
  57671. reserved: boolean;
  57672. /**
  57673. * Gets the loaded texture
  57674. */
  57675. texture: HDRCubeTexture;
  57676. /**
  57677. * Callback called when the task is successful
  57678. */
  57679. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57680. /**
  57681. * Callback called when the task is successful
  57682. */
  57683. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57684. /**
  57685. * Creates a new HDRCubeTextureAssetTask object
  57686. * @param name defines the name of the task
  57687. * @param url defines the location of the file to load
  57688. * @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.
  57689. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57690. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57691. * @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)
  57692. * @param reserved Internal use only
  57693. */
  57694. constructor(
  57695. /**
  57696. * Defines the name of the task
  57697. */
  57698. name: string,
  57699. /**
  57700. * Defines the location of the file to load
  57701. */
  57702. url: string,
  57703. /**
  57704. * Defines the desired size (the more it increases the longer the generation will be)
  57705. */
  57706. size: number,
  57707. /**
  57708. * Defines if mipmaps should not be generated (default is false)
  57709. */
  57710. noMipmap?: boolean,
  57711. /**
  57712. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57713. */
  57714. generateHarmonics?: boolean,
  57715. /**
  57716. * 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)
  57717. */
  57718. gammaSpace?: boolean,
  57719. /**
  57720. * Internal Use Only
  57721. */
  57722. reserved?: boolean);
  57723. /**
  57724. * Execute the current task
  57725. * @param scene defines the scene where you want your assets to be loaded
  57726. * @param onSuccess is a callback called when the task is successfully executed
  57727. * @param onError is a callback called if an error occurs
  57728. */
  57729. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57730. }
  57731. /**
  57732. * Define a task used by AssetsManager to load Equirectangular cube textures
  57733. */
  57734. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  57735. /**
  57736. * Defines the name of the task
  57737. */
  57738. name: string;
  57739. /**
  57740. * Defines the location of the file to load
  57741. */
  57742. url: string;
  57743. /**
  57744. * Defines the desired size (the more it increases the longer the generation will be)
  57745. */
  57746. size: number;
  57747. /**
  57748. * Defines if mipmaps should not be generated (default is false)
  57749. */
  57750. noMipmap: boolean;
  57751. /**
  57752. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57753. * but the standard material would require them in Gamma space) (default is true)
  57754. */
  57755. gammaSpace: boolean;
  57756. /**
  57757. * Gets the loaded texture
  57758. */
  57759. texture: EquiRectangularCubeTexture;
  57760. /**
  57761. * Callback called when the task is successful
  57762. */
  57763. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  57764. /**
  57765. * Callback called when the task is successful
  57766. */
  57767. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  57768. /**
  57769. * Creates a new EquiRectangularCubeTextureAssetTask object
  57770. * @param name defines the name of the task
  57771. * @param url defines the location of the file to load
  57772. * @param size defines the desired size (the more it increases the longer the generation will be)
  57773. * If the size is omitted this implies you are using a preprocessed cubemap.
  57774. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57775. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  57776. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  57777. * (default is true)
  57778. */
  57779. constructor(
  57780. /**
  57781. * Defines the name of the task
  57782. */
  57783. name: string,
  57784. /**
  57785. * Defines the location of the file to load
  57786. */
  57787. url: string,
  57788. /**
  57789. * Defines the desired size (the more it increases the longer the generation will be)
  57790. */
  57791. size: number,
  57792. /**
  57793. * Defines if mipmaps should not be generated (default is false)
  57794. */
  57795. noMipmap?: boolean,
  57796. /**
  57797. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57798. * but the standard material would require them in Gamma space) (default is true)
  57799. */
  57800. gammaSpace?: boolean);
  57801. /**
  57802. * Execute the current task
  57803. * @param scene defines the scene where you want your assets to be loaded
  57804. * @param onSuccess is a callback called when the task is successfully executed
  57805. * @param onError is a callback called if an error occurs
  57806. */
  57807. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57808. }
  57809. /**
  57810. * This class can be used to easily import assets into a scene
  57811. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  57812. */
  57813. export class AssetsManager {
  57814. private _scene;
  57815. private _isLoading;
  57816. protected _tasks: AbstractAssetTask[];
  57817. protected _waitingTasksCount: number;
  57818. protected _totalTasksCount: number;
  57819. /**
  57820. * Callback called when all tasks are processed
  57821. */
  57822. onFinish: (tasks: AbstractAssetTask[]) => void;
  57823. /**
  57824. * Callback called when a task is successful
  57825. */
  57826. onTaskSuccess: (task: AbstractAssetTask) => void;
  57827. /**
  57828. * Callback called when a task had an error
  57829. */
  57830. onTaskError: (task: AbstractAssetTask) => void;
  57831. /**
  57832. * Callback called when a task is done (whatever the result is)
  57833. */
  57834. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  57835. /**
  57836. * Observable called when all tasks are processed
  57837. */
  57838. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  57839. /**
  57840. * Observable called when a task had an error
  57841. */
  57842. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57843. /**
  57844. * Observable called when all tasks were executed
  57845. */
  57846. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57847. /**
  57848. * Observable called when a task is done (whatever the result is)
  57849. */
  57850. onProgressObservable: Observable<IAssetsProgressEvent>;
  57851. /**
  57852. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57853. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57854. */
  57855. useDefaultLoadingScreen: boolean;
  57856. /**
  57857. * Creates a new AssetsManager
  57858. * @param scene defines the scene to work on
  57859. */
  57860. constructor(scene: Scene);
  57861. /**
  57862. * Add a MeshAssetTask to the list of active tasks
  57863. * @param taskName defines the name of the new task
  57864. * @param meshesNames defines the name of meshes to load
  57865. * @param rootUrl defines the root url to use to locate files
  57866. * @param sceneFilename defines the filename of the scene file
  57867. * @returns a new MeshAssetTask object
  57868. */
  57869. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57870. /**
  57871. * Add a TextFileAssetTask to the list of active tasks
  57872. * @param taskName defines the name of the new task
  57873. * @param url defines the url of the file to load
  57874. * @returns a new TextFileAssetTask object
  57875. */
  57876. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57877. /**
  57878. * Add a BinaryFileAssetTask to the list of active tasks
  57879. * @param taskName defines the name of the new task
  57880. * @param url defines the url of the file to load
  57881. * @returns a new BinaryFileAssetTask object
  57882. */
  57883. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57884. /**
  57885. * Add a ImageAssetTask to the list of active tasks
  57886. * @param taskName defines the name of the new task
  57887. * @param url defines the url of the file to load
  57888. * @returns a new ImageAssetTask object
  57889. */
  57890. addImageTask(taskName: string, url: string): ImageAssetTask;
  57891. /**
  57892. * Add a TextureAssetTask to the list of active tasks
  57893. * @param taskName defines the name of the new task
  57894. * @param url defines the url of the file to load
  57895. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57896. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57897. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57898. * @returns a new TextureAssetTask object
  57899. */
  57900. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57901. /**
  57902. * Add a CubeTextureAssetTask to the list of active tasks
  57903. * @param taskName defines the name of the new task
  57904. * @param url defines the url of the file to load
  57905. * @param extensions defines the extension to use to load the cube map (can be null)
  57906. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57907. * @param files defines the list of files to load (can be null)
  57908. * @returns a new CubeTextureAssetTask object
  57909. */
  57910. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57911. /**
  57912. *
  57913. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57914. * @param taskName defines the name of the new task
  57915. * @param url defines the url of the file to load
  57916. * @param size defines the size you want for the cubemap (can be null)
  57917. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57918. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57919. * @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)
  57920. * @param reserved Internal use only
  57921. * @returns a new HDRCubeTextureAssetTask object
  57922. */
  57923. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57924. /**
  57925. *
  57926. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  57927. * @param taskName defines the name of the new task
  57928. * @param url defines the url of the file to load
  57929. * @param size defines the size you want for the cubemap (can be null)
  57930. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57931. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  57932. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  57933. * @returns a new EquiRectangularCubeTextureAssetTask object
  57934. */
  57935. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  57936. /**
  57937. * Remove a task from the assets manager.
  57938. * @param task the task to remove
  57939. */
  57940. removeTask(task: AbstractAssetTask): void;
  57941. private _decreaseWaitingTasksCount;
  57942. private _runTask;
  57943. /**
  57944. * Reset the AssetsManager and remove all tasks
  57945. * @return the current instance of the AssetsManager
  57946. */
  57947. reset(): AssetsManager;
  57948. /**
  57949. * Start the loading process
  57950. * @return the current instance of the AssetsManager
  57951. */
  57952. load(): AssetsManager;
  57953. /**
  57954. * Start the loading process as an async operation
  57955. * @return a promise returning the list of failed tasks
  57956. */
  57957. loadAsync(): Promise<void>;
  57958. }
  57959. }
  57960. declare module BABYLON {
  57961. /**
  57962. * Wrapper class for promise with external resolve and reject.
  57963. */
  57964. export class Deferred<T> {
  57965. /**
  57966. * The promise associated with this deferred object.
  57967. */
  57968. readonly promise: Promise<T>;
  57969. private _resolve;
  57970. private _reject;
  57971. /**
  57972. * The resolve method of the promise associated with this deferred object.
  57973. */
  57974. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  57975. /**
  57976. * The reject method of the promise associated with this deferred object.
  57977. */
  57978. readonly reject: (reason?: any) => void;
  57979. /**
  57980. * Constructor for this deferred object.
  57981. */
  57982. constructor();
  57983. }
  57984. }
  57985. declare module BABYLON {
  57986. /**
  57987. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  57988. */
  57989. export class MeshExploder {
  57990. private _centerMesh;
  57991. private _meshes;
  57992. private _meshesOrigins;
  57993. private _toCenterVectors;
  57994. private _scaledDirection;
  57995. private _newPosition;
  57996. private _centerPosition;
  57997. /**
  57998. * Explodes meshes from a center mesh.
  57999. * @param meshes The meshes to explode.
  58000. * @param centerMesh The mesh to be center of explosion.
  58001. */
  58002. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58003. private _setCenterMesh;
  58004. /**
  58005. * Get class name
  58006. * @returns "MeshExploder"
  58007. */
  58008. getClassName(): string;
  58009. /**
  58010. * "Exploded meshes"
  58011. * @returns Array of meshes with the centerMesh at index 0.
  58012. */
  58013. getMeshes(): Array<Mesh>;
  58014. /**
  58015. * Explodes meshes giving a specific direction
  58016. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58017. */
  58018. explode(direction?: number): void;
  58019. }
  58020. }
  58021. declare module BABYLON {
  58022. /**
  58023. * Class used to help managing file picking and drag'n'drop
  58024. */
  58025. export class FilesInput {
  58026. /**
  58027. * List of files ready to be loaded
  58028. */
  58029. static readonly FilesToLoad: {
  58030. [key: string]: File;
  58031. };
  58032. /**
  58033. * Callback called when a file is processed
  58034. */
  58035. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58036. private _engine;
  58037. private _currentScene;
  58038. private _sceneLoadedCallback;
  58039. private _progressCallback;
  58040. private _additionalRenderLoopLogicCallback;
  58041. private _textureLoadingCallback;
  58042. private _startingProcessingFilesCallback;
  58043. private _onReloadCallback;
  58044. private _errorCallback;
  58045. private _elementToMonitor;
  58046. private _sceneFileToLoad;
  58047. private _filesToLoad;
  58048. /**
  58049. * Creates a new FilesInput
  58050. * @param engine defines the rendering engine
  58051. * @param scene defines the hosting scene
  58052. * @param sceneLoadedCallback callback called when scene is loaded
  58053. * @param progressCallback callback called to track progress
  58054. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58055. * @param textureLoadingCallback callback called when a texture is loading
  58056. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58057. * @param onReloadCallback callback called when a reload is requested
  58058. * @param errorCallback callback call if an error occurs
  58059. */
  58060. 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);
  58061. private _dragEnterHandler;
  58062. private _dragOverHandler;
  58063. private _dropHandler;
  58064. /**
  58065. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58066. * @param elementToMonitor defines the DOM element to track
  58067. */
  58068. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58069. /**
  58070. * Release all associated resources
  58071. */
  58072. dispose(): void;
  58073. private renderFunction;
  58074. private drag;
  58075. private drop;
  58076. private _traverseFolder;
  58077. private _processFiles;
  58078. /**
  58079. * Load files from a drop event
  58080. * @param event defines the drop event to use as source
  58081. */
  58082. loadFiles(event: any): void;
  58083. private _processReload;
  58084. /**
  58085. * Reload the current scene from the loaded files
  58086. */
  58087. reload(): void;
  58088. }
  58089. }
  58090. declare module BABYLON {
  58091. /**
  58092. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58093. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58094. */
  58095. export class SceneOptimization {
  58096. /**
  58097. * Defines the priority of this optimization (0 by default which means first in the list)
  58098. */
  58099. priority: number;
  58100. /**
  58101. * Gets a string describing the action executed by the current optimization
  58102. * @returns description string
  58103. */
  58104. getDescription(): string;
  58105. /**
  58106. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58107. * @param scene defines the current scene where to apply this optimization
  58108. * @param optimizer defines the current optimizer
  58109. * @returns true if everything that can be done was applied
  58110. */
  58111. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58112. /**
  58113. * Creates the SceneOptimization object
  58114. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58115. * @param desc defines the description associated with the optimization
  58116. */
  58117. constructor(
  58118. /**
  58119. * Defines the priority of this optimization (0 by default which means first in the list)
  58120. */
  58121. priority?: number);
  58122. }
  58123. /**
  58124. * Defines an optimization used to reduce the size of render target textures
  58125. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58126. */
  58127. export class TextureOptimization extends SceneOptimization {
  58128. /**
  58129. * Defines the priority of this optimization (0 by default which means first in the list)
  58130. */
  58131. priority: number;
  58132. /**
  58133. * 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
  58134. */
  58135. maximumSize: number;
  58136. /**
  58137. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58138. */
  58139. step: number;
  58140. /**
  58141. * Gets a string describing the action executed by the current optimization
  58142. * @returns description string
  58143. */
  58144. getDescription(): string;
  58145. /**
  58146. * Creates the TextureOptimization object
  58147. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58148. * @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
  58149. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58150. */
  58151. constructor(
  58152. /**
  58153. * Defines the priority of this optimization (0 by default which means first in the list)
  58154. */
  58155. priority?: number,
  58156. /**
  58157. * 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
  58158. */
  58159. maximumSize?: number,
  58160. /**
  58161. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58162. */
  58163. step?: number);
  58164. /**
  58165. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58166. * @param scene defines the current scene where to apply this optimization
  58167. * @param optimizer defines the current optimizer
  58168. * @returns true if everything that can be done was applied
  58169. */
  58170. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58171. }
  58172. /**
  58173. * Defines an optimization used to increase or decrease the rendering resolution
  58174. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58175. */
  58176. export class HardwareScalingOptimization extends SceneOptimization {
  58177. /**
  58178. * Defines the priority of this optimization (0 by default which means first in the list)
  58179. */
  58180. priority: number;
  58181. /**
  58182. * Defines the maximum scale to use (2 by default)
  58183. */
  58184. maximumScale: number;
  58185. /**
  58186. * Defines the step to use between two passes (0.5 by default)
  58187. */
  58188. step: number;
  58189. private _currentScale;
  58190. private _directionOffset;
  58191. /**
  58192. * Gets a string describing the action executed by the current optimization
  58193. * @return description string
  58194. */
  58195. getDescription(): string;
  58196. /**
  58197. * Creates the HardwareScalingOptimization object
  58198. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58199. * @param maximumScale defines the maximum scale to use (2 by default)
  58200. * @param step defines the step to use between two passes (0.5 by default)
  58201. */
  58202. constructor(
  58203. /**
  58204. * Defines the priority of this optimization (0 by default which means first in the list)
  58205. */
  58206. priority?: number,
  58207. /**
  58208. * Defines the maximum scale to use (2 by default)
  58209. */
  58210. maximumScale?: number,
  58211. /**
  58212. * Defines the step to use between two passes (0.5 by default)
  58213. */
  58214. step?: number);
  58215. /**
  58216. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58217. * @param scene defines the current scene where to apply this optimization
  58218. * @param optimizer defines the current optimizer
  58219. * @returns true if everything that can be done was applied
  58220. */
  58221. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58222. }
  58223. /**
  58224. * Defines an optimization used to remove shadows
  58225. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58226. */
  58227. export class ShadowsOptimization extends SceneOptimization {
  58228. /**
  58229. * Gets a string describing the action executed by the current optimization
  58230. * @return description string
  58231. */
  58232. getDescription(): string;
  58233. /**
  58234. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58235. * @param scene defines the current scene where to apply this optimization
  58236. * @param optimizer defines the current optimizer
  58237. * @returns true if everything that can be done was applied
  58238. */
  58239. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58240. }
  58241. /**
  58242. * Defines an optimization used to turn post-processes off
  58243. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58244. */
  58245. export class PostProcessesOptimization extends SceneOptimization {
  58246. /**
  58247. * Gets a string describing the action executed by the current optimization
  58248. * @return description string
  58249. */
  58250. getDescription(): string;
  58251. /**
  58252. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58253. * @param scene defines the current scene where to apply this optimization
  58254. * @param optimizer defines the current optimizer
  58255. * @returns true if everything that can be done was applied
  58256. */
  58257. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58258. }
  58259. /**
  58260. * Defines an optimization used to turn lens flares off
  58261. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58262. */
  58263. export class LensFlaresOptimization extends SceneOptimization {
  58264. /**
  58265. * Gets a string describing the action executed by the current optimization
  58266. * @return description string
  58267. */
  58268. getDescription(): string;
  58269. /**
  58270. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58271. * @param scene defines the current scene where to apply this optimization
  58272. * @param optimizer defines the current optimizer
  58273. * @returns true if everything that can be done was applied
  58274. */
  58275. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58276. }
  58277. /**
  58278. * Defines an optimization based on user defined callback.
  58279. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58280. */
  58281. export class CustomOptimization extends SceneOptimization {
  58282. /**
  58283. * Callback called to apply the custom optimization.
  58284. */
  58285. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58286. /**
  58287. * Callback called to get custom description
  58288. */
  58289. onGetDescription: () => string;
  58290. /**
  58291. * Gets a string describing the action executed by the current optimization
  58292. * @returns description string
  58293. */
  58294. getDescription(): string;
  58295. /**
  58296. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58297. * @param scene defines the current scene where to apply this optimization
  58298. * @param optimizer defines the current optimizer
  58299. * @returns true if everything that can be done was applied
  58300. */
  58301. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58302. }
  58303. /**
  58304. * Defines an optimization used to turn particles off
  58305. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58306. */
  58307. export class ParticlesOptimization extends SceneOptimization {
  58308. /**
  58309. * Gets a string describing the action executed by the current optimization
  58310. * @return description string
  58311. */
  58312. getDescription(): string;
  58313. /**
  58314. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58315. * @param scene defines the current scene where to apply this optimization
  58316. * @param optimizer defines the current optimizer
  58317. * @returns true if everything that can be done was applied
  58318. */
  58319. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58320. }
  58321. /**
  58322. * Defines an optimization used to turn render targets off
  58323. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58324. */
  58325. export class RenderTargetsOptimization extends SceneOptimization {
  58326. /**
  58327. * Gets a string describing the action executed by the current optimization
  58328. * @return description string
  58329. */
  58330. getDescription(): string;
  58331. /**
  58332. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58333. * @param scene defines the current scene where to apply this optimization
  58334. * @param optimizer defines the current optimizer
  58335. * @returns true if everything that can be done was applied
  58336. */
  58337. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58338. }
  58339. /**
  58340. * Defines an optimization used to merge meshes with compatible materials
  58341. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58342. */
  58343. export class MergeMeshesOptimization extends SceneOptimization {
  58344. private static _UpdateSelectionTree;
  58345. /**
  58346. * Gets or sets a boolean which defines if optimization octree has to be updated
  58347. */
  58348. /**
  58349. * Gets or sets a boolean which defines if optimization octree has to be updated
  58350. */
  58351. static UpdateSelectionTree: boolean;
  58352. /**
  58353. * Gets a string describing the action executed by the current optimization
  58354. * @return description string
  58355. */
  58356. getDescription(): string;
  58357. private _canBeMerged;
  58358. /**
  58359. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58360. * @param scene defines the current scene where to apply this optimization
  58361. * @param optimizer defines the current optimizer
  58362. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58363. * @returns true if everything that can be done was applied
  58364. */
  58365. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58366. }
  58367. /**
  58368. * Defines a list of options used by SceneOptimizer
  58369. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58370. */
  58371. export class SceneOptimizerOptions {
  58372. /**
  58373. * Defines the target frame rate to reach (60 by default)
  58374. */
  58375. targetFrameRate: number;
  58376. /**
  58377. * Defines the interval between two checkes (2000ms by default)
  58378. */
  58379. trackerDuration: number;
  58380. /**
  58381. * Gets the list of optimizations to apply
  58382. */
  58383. optimizations: SceneOptimization[];
  58384. /**
  58385. * Creates a new list of options used by SceneOptimizer
  58386. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58387. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58388. */
  58389. constructor(
  58390. /**
  58391. * Defines the target frame rate to reach (60 by default)
  58392. */
  58393. targetFrameRate?: number,
  58394. /**
  58395. * Defines the interval between two checkes (2000ms by default)
  58396. */
  58397. trackerDuration?: number);
  58398. /**
  58399. * Add a new optimization
  58400. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58401. * @returns the current SceneOptimizerOptions
  58402. */
  58403. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58404. /**
  58405. * Add a new custom optimization
  58406. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58407. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58408. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58409. * @returns the current SceneOptimizerOptions
  58410. */
  58411. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58412. /**
  58413. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58414. * @param targetFrameRate defines the target frame rate (60 by default)
  58415. * @returns a SceneOptimizerOptions object
  58416. */
  58417. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58418. /**
  58419. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58420. * @param targetFrameRate defines the target frame rate (60 by default)
  58421. * @returns a SceneOptimizerOptions object
  58422. */
  58423. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58424. /**
  58425. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58426. * @param targetFrameRate defines the target frame rate (60 by default)
  58427. * @returns a SceneOptimizerOptions object
  58428. */
  58429. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58430. }
  58431. /**
  58432. * Class used to run optimizations in order to reach a target frame rate
  58433. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58434. */
  58435. export class SceneOptimizer implements IDisposable {
  58436. private _isRunning;
  58437. private _options;
  58438. private _scene;
  58439. private _currentPriorityLevel;
  58440. private _targetFrameRate;
  58441. private _trackerDuration;
  58442. private _currentFrameRate;
  58443. private _sceneDisposeObserver;
  58444. private _improvementMode;
  58445. /**
  58446. * Defines an observable called when the optimizer reaches the target frame rate
  58447. */
  58448. onSuccessObservable: Observable<SceneOptimizer>;
  58449. /**
  58450. * Defines an observable called when the optimizer enables an optimization
  58451. */
  58452. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58453. /**
  58454. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58455. */
  58456. onFailureObservable: Observable<SceneOptimizer>;
  58457. /**
  58458. * Gets a boolean indicating if the optimizer is in improvement mode
  58459. */
  58460. readonly isInImprovementMode: boolean;
  58461. /**
  58462. * Gets the current priority level (0 at start)
  58463. */
  58464. readonly currentPriorityLevel: number;
  58465. /**
  58466. * Gets the current frame rate checked by the SceneOptimizer
  58467. */
  58468. readonly currentFrameRate: number;
  58469. /**
  58470. * Gets or sets the current target frame rate (60 by default)
  58471. */
  58472. /**
  58473. * Gets or sets the current target frame rate (60 by default)
  58474. */
  58475. targetFrameRate: number;
  58476. /**
  58477. * Gets or sets the current interval between two checks (every 2000ms by default)
  58478. */
  58479. /**
  58480. * Gets or sets the current interval between two checks (every 2000ms by default)
  58481. */
  58482. trackerDuration: number;
  58483. /**
  58484. * Gets the list of active optimizations
  58485. */
  58486. readonly optimizations: SceneOptimization[];
  58487. /**
  58488. * Creates a new SceneOptimizer
  58489. * @param scene defines the scene to work on
  58490. * @param options defines the options to use with the SceneOptimizer
  58491. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58492. * @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)
  58493. */
  58494. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58495. /**
  58496. * Stops the current optimizer
  58497. */
  58498. stop(): void;
  58499. /**
  58500. * Reset the optimizer to initial step (current priority level = 0)
  58501. */
  58502. reset(): void;
  58503. /**
  58504. * Start the optimizer. By default it will try to reach a specific framerate
  58505. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58506. */
  58507. start(): void;
  58508. private _checkCurrentState;
  58509. /**
  58510. * Release all resources
  58511. */
  58512. dispose(): void;
  58513. /**
  58514. * Helper function to create a SceneOptimizer with one single line of code
  58515. * @param scene defines the scene to work on
  58516. * @param options defines the options to use with the SceneOptimizer
  58517. * @param onSuccess defines a callback to call on success
  58518. * @param onFailure defines a callback to call on failure
  58519. * @returns the new SceneOptimizer object
  58520. */
  58521. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58522. }
  58523. }
  58524. declare module BABYLON {
  58525. /**
  58526. * Class used to serialize a scene into a string
  58527. */
  58528. export class SceneSerializer {
  58529. /**
  58530. * Clear cache used by a previous serialization
  58531. */
  58532. static ClearCache(): void;
  58533. /**
  58534. * Serialize a scene into a JSON compatible object
  58535. * @param scene defines the scene to serialize
  58536. * @returns a JSON compatible object
  58537. */
  58538. static Serialize(scene: Scene): any;
  58539. /**
  58540. * Serialize a mesh into a JSON compatible object
  58541. * @param toSerialize defines the mesh to serialize
  58542. * @param withParents defines if parents must be serialized as well
  58543. * @param withChildren defines if children must be serialized as well
  58544. * @returns a JSON compatible object
  58545. */
  58546. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58547. }
  58548. }
  58549. declare module BABYLON {
  58550. /**
  58551. * Class used to host texture specific utilities
  58552. */
  58553. export class TextureTools {
  58554. /**
  58555. * Uses the GPU to create a copy texture rescaled at a given size
  58556. * @param texture Texture to copy from
  58557. * @param width defines the desired width
  58558. * @param height defines the desired height
  58559. * @param useBilinearMode defines if bilinear mode has to be used
  58560. * @return the generated texture
  58561. */
  58562. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58563. }
  58564. }
  58565. declare module BABYLON {
  58566. /**
  58567. * This represents the different options avilable for the video capture.
  58568. */
  58569. export interface VideoRecorderOptions {
  58570. /** Defines the mime type of the video */
  58571. mimeType: string;
  58572. /** Defines the video the video should be recorded at */
  58573. fps: number;
  58574. /** Defines the chunk size for the recording data */
  58575. recordChunckSize: number;
  58576. /** The audio tracks to attach to the record */
  58577. audioTracks?: MediaStreamTrack[];
  58578. }
  58579. /**
  58580. * This can helps recording videos from BabylonJS.
  58581. * This is based on the available WebRTC functionalities of the browser.
  58582. *
  58583. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58584. */
  58585. export class VideoRecorder {
  58586. private static readonly _defaultOptions;
  58587. /**
  58588. * Returns wehther or not the VideoRecorder is available in your browser.
  58589. * @param engine Defines the Babylon Engine to check the support for
  58590. * @returns true if supported otherwise false
  58591. */
  58592. static IsSupported(engine: Engine): boolean;
  58593. private readonly _options;
  58594. private _canvas;
  58595. private _mediaRecorder;
  58596. private _recordedChunks;
  58597. private _fileName;
  58598. private _resolve;
  58599. private _reject;
  58600. /**
  58601. * True wether a recording is already in progress.
  58602. */
  58603. readonly isRecording: boolean;
  58604. /**
  58605. * Create a new VideoCapture object which can help converting what you see in Babylon to
  58606. * a video file.
  58607. * @param engine Defines the BabylonJS Engine you wish to record
  58608. * @param options Defines options that can be used to customized the capture
  58609. */
  58610. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  58611. /**
  58612. * Stops the current recording before the default capture timeout passed in the startRecording
  58613. * functions.
  58614. */
  58615. stopRecording(): void;
  58616. /**
  58617. * Starts recording the canvas for a max duration specified in parameters.
  58618. * @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.
  58619. * @param maxDuration Defines the maximum recording time in seconds.
  58620. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  58621. * @return a promise callback at the end of the recording with the video data in Blob.
  58622. */
  58623. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  58624. /**
  58625. * Releases internal resources used during the recording.
  58626. */
  58627. dispose(): void;
  58628. private _handleDataAvailable;
  58629. private _handleError;
  58630. private _handleStop;
  58631. }
  58632. }
  58633. declare module BABYLON {
  58634. /**
  58635. * Class containing a set of static utilities functions for screenshots
  58636. */
  58637. export class ScreenshotTools {
  58638. /**
  58639. * Captures a screenshot of the current rendering
  58640. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58641. * @param engine defines the rendering engine
  58642. * @param camera defines the source camera
  58643. * @param size This parameter can be set to a single number or to an object with the
  58644. * following (optional) properties: precision, width, height. If a single number is passed,
  58645. * it will be used for both width and height. If an object is passed, the screenshot size
  58646. * will be derived from the parameters. The precision property is a multiplier allowing
  58647. * rendering at a higher or lower resolution
  58648. * @param successCallback defines the callback receives a single parameter which contains the
  58649. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58650. * src parameter of an <img> to display it
  58651. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  58652. * Check your browser for supported MIME types
  58653. */
  58654. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  58655. /**
  58656. * Generates an image screenshot from the specified camera.
  58657. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58658. * @param engine The engine to use for rendering
  58659. * @param camera The camera to use for rendering
  58660. * @param size This parameter can be set to a single number or to an object with the
  58661. * following (optional) properties: precision, width, height. If a single number is passed,
  58662. * it will be used for both width and height. If an object is passed, the screenshot size
  58663. * will be derived from the parameters. The precision property is a multiplier allowing
  58664. * rendering at a higher or lower resolution
  58665. * @param successCallback The callback receives a single parameter which contains the
  58666. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58667. * src parameter of an <img> to display it
  58668. * @param mimeType The MIME type of the screenshot image (default: image/png).
  58669. * Check your browser for supported MIME types
  58670. * @param samples Texture samples (default: 1)
  58671. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  58672. * @param fileName A name for for the downloaded file.
  58673. */
  58674. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  58675. }
  58676. }
  58677. declare module BABYLON {
  58678. /**
  58679. * A cursor which tracks a point on a path
  58680. */
  58681. export class PathCursor {
  58682. private path;
  58683. /**
  58684. * Stores path cursor callbacks for when an onchange event is triggered
  58685. */
  58686. private _onchange;
  58687. /**
  58688. * The value of the path cursor
  58689. */
  58690. value: number;
  58691. /**
  58692. * The animation array of the path cursor
  58693. */
  58694. animations: Animation[];
  58695. /**
  58696. * Initializes the path cursor
  58697. * @param path The path to track
  58698. */
  58699. constructor(path: Path2);
  58700. /**
  58701. * Gets the cursor point on the path
  58702. * @returns A point on the path cursor at the cursor location
  58703. */
  58704. getPoint(): Vector3;
  58705. /**
  58706. * Moves the cursor ahead by the step amount
  58707. * @param step The amount to move the cursor forward
  58708. * @returns This path cursor
  58709. */
  58710. moveAhead(step?: number): PathCursor;
  58711. /**
  58712. * Moves the cursor behind by the step amount
  58713. * @param step The amount to move the cursor back
  58714. * @returns This path cursor
  58715. */
  58716. moveBack(step?: number): PathCursor;
  58717. /**
  58718. * Moves the cursor by the step amount
  58719. * If the step amount is greater than one, an exception is thrown
  58720. * @param step The amount to move the cursor
  58721. * @returns This path cursor
  58722. */
  58723. move(step: number): PathCursor;
  58724. /**
  58725. * Ensures that the value is limited between zero and one
  58726. * @returns This path cursor
  58727. */
  58728. private ensureLimits;
  58729. /**
  58730. * Runs onchange callbacks on change (used by the animation engine)
  58731. * @returns This path cursor
  58732. */
  58733. private raiseOnChange;
  58734. /**
  58735. * Executes a function on change
  58736. * @param f A path cursor onchange callback
  58737. * @returns This path cursor
  58738. */
  58739. onchange(f: (cursor: PathCursor) => void): PathCursor;
  58740. }
  58741. }
  58742. declare module BABYLON {
  58743. /** @hidden */
  58744. export var blurPixelShader: {
  58745. name: string;
  58746. shader: string;
  58747. };
  58748. }
  58749. declare module BABYLON {
  58750. /** @hidden */
  58751. export var bones300Declaration: {
  58752. name: string;
  58753. shader: string;
  58754. };
  58755. }
  58756. declare module BABYLON {
  58757. /** @hidden */
  58758. export var instances300Declaration: {
  58759. name: string;
  58760. shader: string;
  58761. };
  58762. }
  58763. declare module BABYLON {
  58764. /** @hidden */
  58765. export var pointCloudVertexDeclaration: {
  58766. name: string;
  58767. shader: string;
  58768. };
  58769. }
  58770. // Mixins
  58771. interface Window {
  58772. mozIndexedDB: IDBFactory;
  58773. webkitIndexedDB: IDBFactory;
  58774. msIndexedDB: IDBFactory;
  58775. webkitURL: typeof URL;
  58776. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58777. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58778. WebGLRenderingContext: WebGLRenderingContext;
  58779. MSGesture: MSGesture;
  58780. CANNON: any;
  58781. AudioContext: AudioContext;
  58782. webkitAudioContext: AudioContext;
  58783. PointerEvent: any;
  58784. Math: Math;
  58785. Uint8Array: Uint8ArrayConstructor;
  58786. Float32Array: Float32ArrayConstructor;
  58787. mozURL: typeof URL;
  58788. msURL: typeof URL;
  58789. VRFrameData: any; // WebVR, from specs 1.1
  58790. DracoDecoderModule: any;
  58791. setImmediate(handler: (...args: any[]) => void): number;
  58792. }
  58793. interface HTMLCanvasElement {
  58794. requestPointerLock(): void;
  58795. msRequestPointerLock?(): void;
  58796. mozRequestPointerLock?(): void;
  58797. webkitRequestPointerLock?(): void;
  58798. /** Track wether a record is in progress */
  58799. isRecording: boolean;
  58800. /** Capture Stream method defined by some browsers */
  58801. captureStream(fps?: number): MediaStream;
  58802. }
  58803. interface CanvasRenderingContext2D {
  58804. msImageSmoothingEnabled: boolean;
  58805. }
  58806. interface MouseEvent {
  58807. mozMovementX: number;
  58808. mozMovementY: number;
  58809. webkitMovementX: number;
  58810. webkitMovementY: number;
  58811. msMovementX: number;
  58812. msMovementY: number;
  58813. }
  58814. interface Navigator {
  58815. mozGetVRDevices: (any: any) => any;
  58816. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58817. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58818. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58819. webkitGetGamepads(): Gamepad[];
  58820. msGetGamepads(): Gamepad[];
  58821. webkitGamepads(): Gamepad[];
  58822. }
  58823. interface HTMLVideoElement {
  58824. mozSrcObject: any;
  58825. }
  58826. interface Math {
  58827. fround(x: number): number;
  58828. imul(a: number, b: number): number;
  58829. }
  58830. interface WebGLRenderingContext {
  58831. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  58832. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  58833. vertexAttribDivisor(index: number, divisor: number): void;
  58834. createVertexArray(): any;
  58835. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  58836. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  58837. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  58838. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  58839. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  58840. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58841. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  58842. // Queries
  58843. createQuery(): WebGLQuery;
  58844. deleteQuery(query: WebGLQuery): void;
  58845. beginQuery(target: number, query: WebGLQuery): void;
  58846. endQuery(target: number): void;
  58847. getQueryParameter(query: WebGLQuery, pname: number): any;
  58848. getQuery(target: number, pname: number): any;
  58849. MAX_SAMPLES: number;
  58850. RGBA8: number;
  58851. READ_FRAMEBUFFER: number;
  58852. DRAW_FRAMEBUFFER: number;
  58853. UNIFORM_BUFFER: number;
  58854. HALF_FLOAT_OES: number;
  58855. RGBA16F: number;
  58856. RGBA32F: number;
  58857. R32F: number;
  58858. RG32F: number;
  58859. RGB32F: number;
  58860. R16F: number;
  58861. RG16F: number;
  58862. RGB16F: number;
  58863. RED: number;
  58864. RG: number;
  58865. R8: number;
  58866. RG8: number;
  58867. UNSIGNED_INT_24_8: number;
  58868. DEPTH24_STENCIL8: number;
  58869. /* Multiple Render Targets */
  58870. drawBuffers(buffers: number[]): void;
  58871. readBuffer(src: number): void;
  58872. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  58873. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  58874. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  58875. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  58876. // Occlusion Query
  58877. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  58878. ANY_SAMPLES_PASSED: number;
  58879. QUERY_RESULT_AVAILABLE: number;
  58880. QUERY_RESULT: number;
  58881. }
  58882. interface WebGLProgram {
  58883. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  58884. }
  58885. interface EXT_disjoint_timer_query {
  58886. QUERY_COUNTER_BITS_EXT: number;
  58887. TIME_ELAPSED_EXT: number;
  58888. TIMESTAMP_EXT: number;
  58889. GPU_DISJOINT_EXT: number;
  58890. QUERY_RESULT_EXT: number;
  58891. QUERY_RESULT_AVAILABLE_EXT: number;
  58892. queryCounterEXT(query: WebGLQuery, target: number): void;
  58893. createQueryEXT(): WebGLQuery;
  58894. beginQueryEXT(target: number, query: WebGLQuery): void;
  58895. endQueryEXT(target: number): void;
  58896. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  58897. deleteQueryEXT(query: WebGLQuery): void;
  58898. }
  58899. interface WebGLUniformLocation {
  58900. _currentState: any;
  58901. }
  58902. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  58903. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  58904. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  58905. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58906. interface WebGLRenderingContext {
  58907. readonly RASTERIZER_DISCARD: number;
  58908. readonly DEPTH_COMPONENT24: number;
  58909. readonly TEXTURE_3D: number;
  58910. readonly TEXTURE_2D_ARRAY: number;
  58911. readonly TEXTURE_COMPARE_FUNC: number;
  58912. readonly TEXTURE_COMPARE_MODE: number;
  58913. readonly COMPARE_REF_TO_TEXTURE: number;
  58914. readonly TEXTURE_WRAP_R: number;
  58915. readonly HALF_FLOAT: number;
  58916. readonly RGB8: number;
  58917. readonly RED_INTEGER: number;
  58918. readonly RG_INTEGER: number;
  58919. readonly RGB_INTEGER: number;
  58920. readonly RGBA_INTEGER: number;
  58921. readonly R8_SNORM: number;
  58922. readonly RG8_SNORM: number;
  58923. readonly RGB8_SNORM: number;
  58924. readonly RGBA8_SNORM: number;
  58925. readonly R8I: number;
  58926. readonly RG8I: number;
  58927. readonly RGB8I: number;
  58928. readonly RGBA8I: number;
  58929. readonly R8UI: number;
  58930. readonly RG8UI: number;
  58931. readonly RGB8UI: number;
  58932. readonly RGBA8UI: number;
  58933. readonly R16I: number;
  58934. readonly RG16I: number;
  58935. readonly RGB16I: number;
  58936. readonly RGBA16I: number;
  58937. readonly R16UI: number;
  58938. readonly RG16UI: number;
  58939. readonly RGB16UI: number;
  58940. readonly RGBA16UI: number;
  58941. readonly R32I: number;
  58942. readonly RG32I: number;
  58943. readonly RGB32I: number;
  58944. readonly RGBA32I: number;
  58945. readonly R32UI: number;
  58946. readonly RG32UI: number;
  58947. readonly RGB32UI: number;
  58948. readonly RGBA32UI: number;
  58949. readonly RGB10_A2UI: number;
  58950. readonly R11F_G11F_B10F: number;
  58951. readonly RGB9_E5: number;
  58952. readonly RGB10_A2: number;
  58953. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  58954. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  58955. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  58956. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  58957. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  58958. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  58959. 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;
  58960. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  58961. readonly TRANSFORM_FEEDBACK: number;
  58962. readonly INTERLEAVED_ATTRIBS: number;
  58963. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  58964. createTransformFeedback(): WebGLTransformFeedback;
  58965. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  58966. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  58967. beginTransformFeedback(primitiveMode: number): void;
  58968. endTransformFeedback(): void;
  58969. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  58970. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58971. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58972. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58973. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  58974. }
  58975. interface ImageBitmap {
  58976. readonly width: number;
  58977. readonly height: number;
  58978. close(): void;
  58979. }
  58980. interface WebGLQuery extends WebGLObject {
  58981. }
  58982. declare var WebGLQuery: {
  58983. prototype: WebGLQuery;
  58984. new(): WebGLQuery;
  58985. };
  58986. interface WebGLSampler extends WebGLObject {
  58987. }
  58988. declare var WebGLSampler: {
  58989. prototype: WebGLSampler;
  58990. new(): WebGLSampler;
  58991. };
  58992. interface WebGLSync extends WebGLObject {
  58993. }
  58994. declare var WebGLSync: {
  58995. prototype: WebGLSync;
  58996. new(): WebGLSync;
  58997. };
  58998. interface WebGLTransformFeedback extends WebGLObject {
  58999. }
  59000. declare var WebGLTransformFeedback: {
  59001. prototype: WebGLTransformFeedback;
  59002. new(): WebGLTransformFeedback;
  59003. };
  59004. interface WebGLVertexArrayObject extends WebGLObject {
  59005. }
  59006. declare var WebGLVertexArrayObject: {
  59007. prototype: WebGLVertexArrayObject;
  59008. new(): WebGLVertexArrayObject;
  59009. };
  59010. // Type definitions for WebVR API
  59011. // Project: https://w3c.github.io/webvr/
  59012. // Definitions by: six a <https://github.com/lostfictions>
  59013. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59014. interface VRDisplay extends EventTarget {
  59015. /**
  59016. * Dictionary of capabilities describing the VRDisplay.
  59017. */
  59018. readonly capabilities: VRDisplayCapabilities;
  59019. /**
  59020. * z-depth defining the far plane of the eye view frustum
  59021. * enables mapping of values in the render target depth
  59022. * attachment to scene coordinates. Initially set to 10000.0.
  59023. */
  59024. depthFar: number;
  59025. /**
  59026. * z-depth defining the near plane of the eye view frustum
  59027. * enables mapping of values in the render target depth
  59028. * attachment to scene coordinates. Initially set to 0.01.
  59029. */
  59030. depthNear: number;
  59031. /**
  59032. * An identifier for this distinct VRDisplay. Used as an
  59033. * association point in the Gamepad API.
  59034. */
  59035. readonly displayId: number;
  59036. /**
  59037. * A display name, a user-readable name identifying it.
  59038. */
  59039. readonly displayName: string;
  59040. readonly isConnected: boolean;
  59041. readonly isPresenting: boolean;
  59042. /**
  59043. * If this VRDisplay supports room-scale experiences, the optional
  59044. * stage attribute contains details on the room-scale parameters.
  59045. */
  59046. readonly stageParameters: VRStageParameters | null;
  59047. /**
  59048. * Passing the value returned by `requestAnimationFrame` to
  59049. * `cancelAnimationFrame` will unregister the callback.
  59050. * @param handle Define the hanle of the request to cancel
  59051. */
  59052. cancelAnimationFrame(handle: number): void;
  59053. /**
  59054. * Stops presenting to the VRDisplay.
  59055. * @returns a promise to know when it stopped
  59056. */
  59057. exitPresent(): Promise<void>;
  59058. /**
  59059. * Return the current VREyeParameters for the given eye.
  59060. * @param whichEye Define the eye we want the parameter for
  59061. * @returns the eye parameters
  59062. */
  59063. getEyeParameters(whichEye: string): VREyeParameters;
  59064. /**
  59065. * Populates the passed VRFrameData with the information required to render
  59066. * the current frame.
  59067. * @param frameData Define the data structure to populate
  59068. * @returns true if ok otherwise false
  59069. */
  59070. getFrameData(frameData: VRFrameData): boolean;
  59071. /**
  59072. * Get the layers currently being presented.
  59073. * @returns the list of VR layers
  59074. */
  59075. getLayers(): VRLayer[];
  59076. /**
  59077. * Return a VRPose containing the future predicted pose of the VRDisplay
  59078. * when the current frame will be presented. The value returned will not
  59079. * change until JavaScript has returned control to the browser.
  59080. *
  59081. * The VRPose will contain the position, orientation, velocity,
  59082. * and acceleration of each of these properties.
  59083. * @returns the pose object
  59084. */
  59085. getPose(): VRPose;
  59086. /**
  59087. * Return the current instantaneous pose of the VRDisplay, with no
  59088. * prediction applied.
  59089. * @returns the current instantaneous pose
  59090. */
  59091. getImmediatePose(): VRPose;
  59092. /**
  59093. * The callback passed to `requestAnimationFrame` will be called
  59094. * any time a new frame should be rendered. When the VRDisplay is
  59095. * presenting the callback will be called at the native refresh
  59096. * rate of the HMD. When not presenting this function acts
  59097. * identically to how window.requestAnimationFrame acts. Content should
  59098. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59099. * asynchronously from other displays and at differing refresh rates.
  59100. * @param callback Define the eaction to run next frame
  59101. * @returns the request handle it
  59102. */
  59103. requestAnimationFrame(callback: FrameRequestCallback): number;
  59104. /**
  59105. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59106. * Repeat calls while already presenting will update the VRLayers being displayed.
  59107. * @param layers Define the list of layer to present
  59108. * @returns a promise to know when the request has been fulfilled
  59109. */
  59110. requestPresent(layers: VRLayer[]): Promise<void>;
  59111. /**
  59112. * Reset the pose for this display, treating its current position and
  59113. * orientation as the "origin/zero" values. VRPose.position,
  59114. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59115. * updated when calling resetPose(). This should be called in only
  59116. * sitting-space experiences.
  59117. */
  59118. resetPose(): void;
  59119. /**
  59120. * The VRLayer provided to the VRDisplay will be captured and presented
  59121. * in the HMD. Calling this function has the same effect on the source
  59122. * canvas as any other operation that uses its source image, and canvases
  59123. * created without preserveDrawingBuffer set to true will be cleared.
  59124. * @param pose Define the pose to submit
  59125. */
  59126. submitFrame(pose?: VRPose): void;
  59127. }
  59128. declare var VRDisplay: {
  59129. prototype: VRDisplay;
  59130. new(): VRDisplay;
  59131. };
  59132. interface VRLayer {
  59133. leftBounds?: number[] | Float32Array | null;
  59134. rightBounds?: number[] | Float32Array | null;
  59135. source?: HTMLCanvasElement | null;
  59136. }
  59137. interface VRDisplayCapabilities {
  59138. readonly canPresent: boolean;
  59139. readonly hasExternalDisplay: boolean;
  59140. readonly hasOrientation: boolean;
  59141. readonly hasPosition: boolean;
  59142. readonly maxLayers: number;
  59143. }
  59144. interface VREyeParameters {
  59145. /** @deprecated */
  59146. readonly fieldOfView: VRFieldOfView;
  59147. readonly offset: Float32Array;
  59148. readonly renderHeight: number;
  59149. readonly renderWidth: number;
  59150. }
  59151. interface VRFieldOfView {
  59152. readonly downDegrees: number;
  59153. readonly leftDegrees: number;
  59154. readonly rightDegrees: number;
  59155. readonly upDegrees: number;
  59156. }
  59157. interface VRFrameData {
  59158. readonly leftProjectionMatrix: Float32Array;
  59159. readonly leftViewMatrix: Float32Array;
  59160. readonly pose: VRPose;
  59161. readonly rightProjectionMatrix: Float32Array;
  59162. readonly rightViewMatrix: Float32Array;
  59163. readonly timestamp: number;
  59164. }
  59165. interface VRPose {
  59166. readonly angularAcceleration: Float32Array | null;
  59167. readonly angularVelocity: Float32Array | null;
  59168. readonly linearAcceleration: Float32Array | null;
  59169. readonly linearVelocity: Float32Array | null;
  59170. readonly orientation: Float32Array | null;
  59171. readonly position: Float32Array | null;
  59172. readonly timestamp: number;
  59173. }
  59174. interface VRStageParameters {
  59175. sittingToStandingTransform?: Float32Array;
  59176. sizeX?: number;
  59177. sizeY?: number;
  59178. }
  59179. interface Navigator {
  59180. getVRDisplays(): Promise<VRDisplay[]>;
  59181. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59182. }
  59183. interface Window {
  59184. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59185. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59186. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59187. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59188. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59189. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59190. }
  59191. interface Gamepad {
  59192. readonly displayId: number;
  59193. }
  59194. interface XRDevice {
  59195. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59196. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59197. }
  59198. interface XRSession {
  59199. getInputSources(): Array<any>;
  59200. baseLayer: XRWebGLLayer;
  59201. requestFrameOfReference(type: string): Promise<void>;
  59202. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59203. end(): Promise<void>;
  59204. requestAnimationFrame: Function;
  59205. addEventListener: Function;
  59206. }
  59207. interface XRSessionCreationOptions {
  59208. outputContext?: WebGLRenderingContext | null;
  59209. immersive?: boolean;
  59210. environmentIntegration?: boolean;
  59211. }
  59212. interface XRLayer {
  59213. getViewport: Function;
  59214. framebufferWidth: number;
  59215. framebufferHeight: number;
  59216. }
  59217. interface XRView {
  59218. projectionMatrix: Float32Array;
  59219. }
  59220. interface XRFrame {
  59221. getDevicePose: Function;
  59222. getInputPose: Function;
  59223. views: Array<XRView>;
  59224. baseLayer: XRLayer;
  59225. }
  59226. interface XRFrameOfReference {
  59227. }
  59228. interface XRWebGLLayer extends XRLayer {
  59229. framebuffer: WebGLFramebuffer;
  59230. }
  59231. declare var XRWebGLLayer: {
  59232. prototype: XRWebGLLayer;
  59233. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59234. };
  59235. declare module BABYLON.GUI {
  59236. /**
  59237. * Class used to specific a value and its associated unit
  59238. */
  59239. export class ValueAndUnit {
  59240. /** defines the unit to store */
  59241. unit: number;
  59242. /** defines a boolean indicating if the value can be negative */
  59243. negativeValueAllowed: boolean;
  59244. private _value;
  59245. private _originalUnit;
  59246. /**
  59247. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  59248. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59249. */
  59250. ignoreAdaptiveScaling: boolean;
  59251. /**
  59252. * Creates a new ValueAndUnit
  59253. * @param value defines the value to store
  59254. * @param unit defines the unit to store
  59255. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  59256. */
  59257. constructor(value: number,
  59258. /** defines the unit to store */
  59259. unit?: number,
  59260. /** defines a boolean indicating if the value can be negative */
  59261. negativeValueAllowed?: boolean);
  59262. /** Gets a boolean indicating if the value is a percentage */
  59263. readonly isPercentage: boolean;
  59264. /** Gets a boolean indicating if the value is store as pixel */
  59265. readonly isPixel: boolean;
  59266. /** Gets direct internal value */
  59267. readonly internalValue: number;
  59268. /**
  59269. * Gets value as pixel
  59270. * @param host defines the root host
  59271. * @param refValue defines the reference value for percentages
  59272. * @returns the value as pixel
  59273. */
  59274. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  59275. /**
  59276. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  59277. * @param value defines the value to store
  59278. * @param unit defines the unit to store
  59279. * @returns the current ValueAndUnit
  59280. */
  59281. updateInPlace(value: number, unit?: number): ValueAndUnit;
  59282. /**
  59283. * Gets the value accordingly to its unit
  59284. * @param host defines the root host
  59285. * @returns the value
  59286. */
  59287. getValue(host: AdvancedDynamicTexture): number;
  59288. /**
  59289. * Gets a string representation of the value
  59290. * @param host defines the root host
  59291. * @param decimals defines an optional number of decimals to display
  59292. * @returns a string
  59293. */
  59294. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  59295. /**
  59296. * Store a value parsed from a string
  59297. * @param source defines the source string
  59298. * @returns true if the value was successfully parsed
  59299. */
  59300. fromString(source: string | number): boolean;
  59301. private static _Regex;
  59302. private static _UNITMODE_PERCENTAGE;
  59303. private static _UNITMODE_PIXEL;
  59304. /** UNITMODE_PERCENTAGE */
  59305. static readonly UNITMODE_PERCENTAGE: number;
  59306. /** UNITMODE_PIXEL */
  59307. static readonly UNITMODE_PIXEL: number;
  59308. }
  59309. }
  59310. declare module BABYLON.GUI {
  59311. /**
  59312. * Define a style used by control to automatically setup properties based on a template.
  59313. * Only support font related properties so far
  59314. */
  59315. export class Style implements BABYLON.IDisposable {
  59316. private _fontFamily;
  59317. private _fontStyle;
  59318. private _fontWeight;
  59319. /** @hidden */
  59320. _host: AdvancedDynamicTexture;
  59321. /** @hidden */
  59322. _fontSize: ValueAndUnit;
  59323. /**
  59324. * BABYLON.Observable raised when the style values are changed
  59325. */
  59326. onChangedObservable: BABYLON.Observable<Style>;
  59327. /**
  59328. * Creates a new style object
  59329. * @param host defines the AdvancedDynamicTexture which hosts this style
  59330. */
  59331. constructor(host: AdvancedDynamicTexture);
  59332. /**
  59333. * Gets or sets the font size
  59334. */
  59335. fontSize: string | number;
  59336. /**
  59337. * Gets or sets the font family
  59338. */
  59339. fontFamily: string;
  59340. /**
  59341. * Gets or sets the font style
  59342. */
  59343. fontStyle: string;
  59344. /** Gets or sets font weight */
  59345. fontWeight: string;
  59346. /** Dispose all associated resources */
  59347. dispose(): void;
  59348. }
  59349. }
  59350. declare module BABYLON.GUI {
  59351. /**
  59352. * Class used to transport BABYLON.Vector2 information for pointer events
  59353. */
  59354. export class Vector2WithInfo extends BABYLON.Vector2 {
  59355. /** defines the current mouse button index */
  59356. buttonIndex: number;
  59357. /**
  59358. * Creates a new Vector2WithInfo
  59359. * @param source defines the vector2 data to transport
  59360. * @param buttonIndex defines the current mouse button index
  59361. */
  59362. constructor(source: BABYLON.Vector2,
  59363. /** defines the current mouse button index */
  59364. buttonIndex?: number);
  59365. }
  59366. /** Class used to provide 2D matrix features */
  59367. export class Matrix2D {
  59368. /** Gets the internal array of 6 floats used to store matrix data */
  59369. m: Float32Array;
  59370. /**
  59371. * Creates a new matrix
  59372. * @param m00 defines value for (0, 0)
  59373. * @param m01 defines value for (0, 1)
  59374. * @param m10 defines value for (1, 0)
  59375. * @param m11 defines value for (1, 1)
  59376. * @param m20 defines value for (2, 0)
  59377. * @param m21 defines value for (2, 1)
  59378. */
  59379. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  59380. /**
  59381. * Fills the matrix from direct values
  59382. * @param m00 defines value for (0, 0)
  59383. * @param m01 defines value for (0, 1)
  59384. * @param m10 defines value for (1, 0)
  59385. * @param m11 defines value for (1, 1)
  59386. * @param m20 defines value for (2, 0)
  59387. * @param m21 defines value for (2, 1)
  59388. * @returns the current modified matrix
  59389. */
  59390. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  59391. /**
  59392. * Gets matrix determinant
  59393. * @returns the determinant
  59394. */
  59395. determinant(): number;
  59396. /**
  59397. * Inverses the matrix and stores it in a target matrix
  59398. * @param result defines the target matrix
  59399. * @returns the current matrix
  59400. */
  59401. invertToRef(result: Matrix2D): Matrix2D;
  59402. /**
  59403. * Multiplies the current matrix with another one
  59404. * @param other defines the second operand
  59405. * @param result defines the target matrix
  59406. * @returns the current matrix
  59407. */
  59408. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  59409. /**
  59410. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  59411. * @param x defines the x coordinate to transform
  59412. * @param y defines the x coordinate to transform
  59413. * @param result defines the target vector2
  59414. * @returns the current matrix
  59415. */
  59416. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  59417. /**
  59418. * Creates an identity matrix
  59419. * @returns a new matrix
  59420. */
  59421. static Identity(): Matrix2D;
  59422. /**
  59423. * Creates a translation matrix and stores it in a target matrix
  59424. * @param x defines the x coordinate of the translation
  59425. * @param y defines the y coordinate of the translation
  59426. * @param result defines the target matrix
  59427. */
  59428. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  59429. /**
  59430. * Creates a scaling matrix and stores it in a target matrix
  59431. * @param x defines the x coordinate of the scaling
  59432. * @param y defines the y coordinate of the scaling
  59433. * @param result defines the target matrix
  59434. */
  59435. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  59436. /**
  59437. * Creates a rotation matrix and stores it in a target matrix
  59438. * @param angle defines the rotation angle
  59439. * @param result defines the target matrix
  59440. */
  59441. static RotationToRef(angle: number, result: Matrix2D): void;
  59442. private static _TempPreTranslationMatrix;
  59443. private static _TempPostTranslationMatrix;
  59444. private static _TempRotationMatrix;
  59445. private static _TempScalingMatrix;
  59446. private static _TempCompose0;
  59447. private static _TempCompose1;
  59448. private static _TempCompose2;
  59449. /**
  59450. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  59451. * @param tx defines the x coordinate of the translation
  59452. * @param ty defines the y coordinate of the translation
  59453. * @param angle defines the rotation angle
  59454. * @param scaleX defines the x coordinate of the scaling
  59455. * @param scaleY defines the y coordinate of the scaling
  59456. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  59457. * @param result defines the target matrix
  59458. */
  59459. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  59460. }
  59461. }
  59462. declare module BABYLON.GUI {
  59463. /**
  59464. * Class used to store 2D control sizes
  59465. */
  59466. export class Measure {
  59467. /** defines left coordinate */
  59468. left: number;
  59469. /** defines top coordinate */
  59470. top: number;
  59471. /** defines width dimension */
  59472. width: number;
  59473. /** defines height dimension */
  59474. height: number;
  59475. /**
  59476. * Creates a new measure
  59477. * @param left defines left coordinate
  59478. * @param top defines top coordinate
  59479. * @param width defines width dimension
  59480. * @param height defines height dimension
  59481. */
  59482. constructor(
  59483. /** defines left coordinate */
  59484. left: number,
  59485. /** defines top coordinate */
  59486. top: number,
  59487. /** defines width dimension */
  59488. width: number,
  59489. /** defines height dimension */
  59490. height: number);
  59491. /**
  59492. * Copy from another measure
  59493. * @param other defines the other measure to copy from
  59494. */
  59495. copyFrom(other: Measure): void;
  59496. /**
  59497. * Copy from a group of 4 floats
  59498. * @param left defines left coordinate
  59499. * @param top defines top coordinate
  59500. * @param width defines width dimension
  59501. * @param height defines height dimension
  59502. */
  59503. copyFromFloats(left: number, top: number, width: number, height: number): void;
  59504. /**
  59505. * Computes the axis aligned bounding box measure for two given measures
  59506. * @param a Input measure
  59507. * @param b Input measure
  59508. * @param result the resulting bounding measure
  59509. */
  59510. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  59511. /**
  59512. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  59513. * @param transform the matrix to transform the measure before computing the AABB
  59514. * @param result the resulting AABB
  59515. */
  59516. transformToRef(transform: Matrix2D, result: Measure): void;
  59517. /**
  59518. * Check equality between this measure and another one
  59519. * @param other defines the other measures
  59520. * @returns true if both measures are equals
  59521. */
  59522. isEqualsTo(other: Measure): boolean;
  59523. /**
  59524. * Creates an empty measure
  59525. * @returns a new measure
  59526. */
  59527. static Empty(): Measure;
  59528. }
  59529. }
  59530. declare module BABYLON.GUI {
  59531. /**
  59532. * Interface used to define a control that can receive focus
  59533. */
  59534. export interface IFocusableControl {
  59535. /**
  59536. * Function called when the control receives the focus
  59537. */
  59538. onFocus(): void;
  59539. /**
  59540. * Function called when the control loses the focus
  59541. */
  59542. onBlur(): void;
  59543. /**
  59544. * Function called to let the control handle keyboard events
  59545. * @param evt defines the current keyboard event
  59546. */
  59547. processKeyboard(evt: KeyboardEvent): void;
  59548. /**
  59549. * Function called to get the list of controls that should not steal the focus from this control
  59550. * @returns an array of controls
  59551. */
  59552. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  59553. }
  59554. /**
  59555. * Class used to create texture to support 2D GUI elements
  59556. * @see http://doc.babylonjs.com/how_to/gui
  59557. */
  59558. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  59559. private _isDirty;
  59560. private _renderObserver;
  59561. private _resizeObserver;
  59562. private _preKeyboardObserver;
  59563. private _pointerMoveObserver;
  59564. private _pointerObserver;
  59565. private _canvasPointerOutObserver;
  59566. private _background;
  59567. /** @hidden */
  59568. _rootContainer: Container;
  59569. /** @hidden */
  59570. _lastPickedControl: Control;
  59571. /** @hidden */
  59572. _lastControlOver: {
  59573. [pointerId: number]: Control;
  59574. };
  59575. /** @hidden */
  59576. _lastControlDown: {
  59577. [pointerId: number]: Control;
  59578. };
  59579. /** @hidden */
  59580. _capturingControl: {
  59581. [pointerId: number]: Control;
  59582. };
  59583. /** @hidden */
  59584. _shouldBlockPointer: boolean;
  59585. /** @hidden */
  59586. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  59587. /** @hidden */
  59588. _linkedControls: Control[];
  59589. private _isFullscreen;
  59590. private _fullscreenViewport;
  59591. private _idealWidth;
  59592. private _idealHeight;
  59593. private _useSmallestIdeal;
  59594. private _renderAtIdealSize;
  59595. private _focusedControl;
  59596. private _blockNextFocusCheck;
  59597. private _renderScale;
  59598. private _rootCanvas;
  59599. private _cursorChanged;
  59600. /**
  59601. * Define type to string to ensure compatibility across browsers
  59602. * Safari doesn't support DataTransfer constructor
  59603. */
  59604. private _clipboardData;
  59605. /**
  59606. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  59607. */
  59608. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  59609. /**
  59610. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  59611. */
  59612. onControlPickedObservable: BABYLON.Observable<Control>;
  59613. /**
  59614. * BABYLON.Observable event triggered before layout is evaluated
  59615. */
  59616. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59617. /**
  59618. * BABYLON.Observable event triggered after the layout was evaluated
  59619. */
  59620. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59621. /**
  59622. * BABYLON.Observable event triggered before the texture is rendered
  59623. */
  59624. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59625. /**
  59626. * BABYLON.Observable event triggered after the texture was rendered
  59627. */
  59628. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59629. /**
  59630. * Gets or sets a boolean defining if alpha is stored as premultiplied
  59631. */
  59632. premulAlpha: boolean;
  59633. /**
  59634. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  59635. * Useful when you want more antialiasing
  59636. */
  59637. renderScale: number;
  59638. /** Gets or sets the background color */
  59639. background: string;
  59640. /**
  59641. * Gets or sets the ideal width used to design controls.
  59642. * The GUI will then rescale everything accordingly
  59643. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59644. */
  59645. idealWidth: number;
  59646. /**
  59647. * Gets or sets the ideal height used to design controls.
  59648. * The GUI will then rescale everything accordingly
  59649. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59650. */
  59651. idealHeight: number;
  59652. /**
  59653. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  59654. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59655. */
  59656. useSmallestIdeal: boolean;
  59657. /**
  59658. * Gets or sets a boolean indicating if adaptive scaling must be used
  59659. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59660. */
  59661. renderAtIdealSize: boolean;
  59662. /**
  59663. * Gets the underlying layer used to render the texture when in fullscreen mode
  59664. */
  59665. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  59666. /**
  59667. * Gets the root container control
  59668. */
  59669. readonly rootContainer: Container;
  59670. /**
  59671. * Returns an array containing the root container.
  59672. * This is mostly used to let the Inspector introspects the ADT
  59673. * @returns an array containing the rootContainer
  59674. */
  59675. getChildren(): Array<Container>;
  59676. /**
  59677. * Will return all controls that are inside this texture
  59678. * @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
  59679. * @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
  59680. * @return all child controls
  59681. */
  59682. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  59683. /**
  59684. * Gets or sets the current focused control
  59685. */
  59686. focusedControl: BABYLON.Nullable<IFocusableControl>;
  59687. /**
  59688. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  59689. */
  59690. isForeground: boolean;
  59691. /**
  59692. * Gets or set information about clipboardData
  59693. */
  59694. clipboardData: string;
  59695. /**
  59696. * Creates a new AdvancedDynamicTexture
  59697. * @param name defines the name of the texture
  59698. * @param width defines the width of the texture
  59699. * @param height defines the height of the texture
  59700. * @param scene defines the hosting scene
  59701. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  59702. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  59703. */
  59704. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  59705. /**
  59706. * Get the current class name of the texture useful for serialization or dynamic coding.
  59707. * @returns "AdvancedDynamicTexture"
  59708. */
  59709. getClassName(): string;
  59710. /**
  59711. * Function used to execute a function on all controls
  59712. * @param func defines the function to execute
  59713. * @param container defines the container where controls belong. If null the root container will be used
  59714. */
  59715. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  59716. private _useInvalidateRectOptimization;
  59717. /**
  59718. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  59719. */
  59720. useInvalidateRectOptimization: boolean;
  59721. private _invalidatedRectangle;
  59722. /**
  59723. * Invalidates a rectangle area on the gui texture
  59724. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  59725. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  59726. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  59727. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  59728. */
  59729. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  59730. /**
  59731. * Marks the texture as dirty forcing a complete update
  59732. */
  59733. markAsDirty(): void;
  59734. /**
  59735. * Helper function used to create a new style
  59736. * @returns a new style
  59737. * @see http://doc.babylonjs.com/how_to/gui#styles
  59738. */
  59739. createStyle(): Style;
  59740. /**
  59741. * Adds a new control to the root container
  59742. * @param control defines the control to add
  59743. * @returns the current texture
  59744. */
  59745. addControl(control: Control): AdvancedDynamicTexture;
  59746. /**
  59747. * Removes a control from the root container
  59748. * @param control defines the control to remove
  59749. * @returns the current texture
  59750. */
  59751. removeControl(control: Control): AdvancedDynamicTexture;
  59752. /**
  59753. * Release all resources
  59754. */
  59755. dispose(): void;
  59756. private _onResize;
  59757. /** @hidden */
  59758. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  59759. /**
  59760. * Get screen coordinates for a vector3
  59761. * @param position defines the position to project
  59762. * @param worldMatrix defines the world matrix to use
  59763. * @returns the projected position
  59764. */
  59765. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  59766. private _checkUpdate;
  59767. private _clearMeasure;
  59768. private _render;
  59769. /** @hidden */
  59770. _changeCursor(cursor: string): void;
  59771. /** @hidden */
  59772. _registerLastControlDown(control: Control, pointerId: number): void;
  59773. private _doPicking;
  59774. /** @hidden */
  59775. _cleanControlAfterRemovalFromList(list: {
  59776. [pointerId: number]: Control;
  59777. }, control: Control): void;
  59778. /** @hidden */
  59779. _cleanControlAfterRemoval(control: Control): void;
  59780. /** Attach to all scene events required to support pointer events */
  59781. attach(): void;
  59782. /** @hidden */
  59783. private onClipboardCopy;
  59784. /** @hidden */
  59785. private onClipboardCut;
  59786. /** @hidden */
  59787. private onClipboardPaste;
  59788. /**
  59789. * Register the clipboard Events onto the canvas
  59790. */
  59791. registerClipboardEvents(): void;
  59792. /**
  59793. * Unregister the clipboard Events from the canvas
  59794. */
  59795. unRegisterClipboardEvents(): void;
  59796. /**
  59797. * Connect the texture to a hosting mesh to enable interactions
  59798. * @param mesh defines the mesh to attach to
  59799. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  59800. */
  59801. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  59802. /**
  59803. * Move the focus to a specific control
  59804. * @param control defines the control which will receive the focus
  59805. */
  59806. moveFocusToControl(control: IFocusableControl): void;
  59807. private _manageFocus;
  59808. private _attachToOnPointerOut;
  59809. /**
  59810. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  59811. * @param mesh defines the mesh which will receive the texture
  59812. * @param width defines the texture width (1024 by default)
  59813. * @param height defines the texture height (1024 by default)
  59814. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  59815. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  59816. * @returns a new AdvancedDynamicTexture
  59817. */
  59818. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  59819. /**
  59820. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  59821. * In this mode the texture will rely on a layer for its rendering.
  59822. * This allows it to be treated like any other layer.
  59823. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  59824. * LayerMask is set through advancedTexture.layer.layerMask
  59825. * @param name defines name for the texture
  59826. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  59827. * @param scene defines the hsoting scene
  59828. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  59829. * @returns a new AdvancedDynamicTexture
  59830. */
  59831. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  59832. }
  59833. }
  59834. declare module BABYLON.GUI {
  59835. /**
  59836. * Root class used for all 2D controls
  59837. * @see http://doc.babylonjs.com/how_to/gui#controls
  59838. */
  59839. export class Control {
  59840. /** defines the name of the control */
  59841. name?: string | undefined;
  59842. /**
  59843. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  59844. */
  59845. static AllowAlphaInheritance: boolean;
  59846. private _alpha;
  59847. private _alphaSet;
  59848. private _zIndex;
  59849. /** @hidden */
  59850. _host: AdvancedDynamicTexture;
  59851. /** Gets or sets the control parent */
  59852. parent: BABYLON.Nullable<Container>;
  59853. /** @hidden */
  59854. _currentMeasure: Measure;
  59855. private _fontFamily;
  59856. private _fontStyle;
  59857. private _fontWeight;
  59858. private _fontSize;
  59859. private _font;
  59860. /** @hidden */
  59861. _width: ValueAndUnit;
  59862. /** @hidden */
  59863. _height: ValueAndUnit;
  59864. /** @hidden */
  59865. protected _fontOffset: {
  59866. ascent: number;
  59867. height: number;
  59868. descent: number;
  59869. };
  59870. private _color;
  59871. private _style;
  59872. private _styleObserver;
  59873. /** @hidden */
  59874. protected _horizontalAlignment: number;
  59875. /** @hidden */
  59876. protected _verticalAlignment: number;
  59877. /** @hidden */
  59878. protected _isDirty: boolean;
  59879. /** @hidden */
  59880. protected _wasDirty: boolean;
  59881. /** @hidden */
  59882. _tempParentMeasure: Measure;
  59883. /** @hidden */
  59884. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  59885. /** @hidden */
  59886. protected _cachedParentMeasure: Measure;
  59887. private _paddingLeft;
  59888. private _paddingRight;
  59889. private _paddingTop;
  59890. private _paddingBottom;
  59891. /** @hidden */
  59892. _left: ValueAndUnit;
  59893. /** @hidden */
  59894. _top: ValueAndUnit;
  59895. private _scaleX;
  59896. private _scaleY;
  59897. private _rotation;
  59898. private _transformCenterX;
  59899. private _transformCenterY;
  59900. /** @hidden */
  59901. _transformMatrix: Matrix2D;
  59902. /** @hidden */
  59903. protected _invertTransformMatrix: Matrix2D;
  59904. /** @hidden */
  59905. protected _transformedPosition: BABYLON.Vector2;
  59906. private _isMatrixDirty;
  59907. private _cachedOffsetX;
  59908. private _cachedOffsetY;
  59909. private _isVisible;
  59910. private _isHighlighted;
  59911. /** @hidden */
  59912. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  59913. private _fontSet;
  59914. private _dummyVector2;
  59915. private _downCount;
  59916. private _enterCount;
  59917. private _doNotRender;
  59918. private _downPointerIds;
  59919. protected _isEnabled: boolean;
  59920. protected _disabledColor: string;
  59921. /** @hidden */
  59922. protected _rebuildLayout: boolean;
  59923. /** @hidden */
  59924. _isClipped: boolean;
  59925. /** @hidden */
  59926. _tag: any;
  59927. /**
  59928. * 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
  59929. */
  59930. uniqueId: number;
  59931. /**
  59932. * Gets or sets an object used to store user defined information for the node
  59933. */
  59934. metadata: any;
  59935. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  59936. isHitTestVisible: boolean;
  59937. /** Gets or sets a boolean indicating if the control can block pointer events */
  59938. isPointerBlocker: boolean;
  59939. /** Gets or sets a boolean indicating if the control can be focusable */
  59940. isFocusInvisible: boolean;
  59941. /**
  59942. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  59943. * 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
  59944. */
  59945. clipChildren: boolean;
  59946. /**
  59947. * Gets or sets a boolean indicating that control content must be clipped
  59948. * 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
  59949. */
  59950. clipContent: boolean;
  59951. /**
  59952. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  59953. */
  59954. useBitmapCache: boolean;
  59955. private _cacheData;
  59956. private _shadowOffsetX;
  59957. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  59958. shadowOffsetX: number;
  59959. private _shadowOffsetY;
  59960. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  59961. shadowOffsetY: number;
  59962. private _shadowBlur;
  59963. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  59964. shadowBlur: number;
  59965. private _shadowColor;
  59966. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  59967. shadowColor: string;
  59968. /** Gets or sets the cursor to use when the control is hovered */
  59969. hoverCursor: string;
  59970. /** @hidden */
  59971. protected _linkOffsetX: ValueAndUnit;
  59972. /** @hidden */
  59973. protected _linkOffsetY: ValueAndUnit;
  59974. /** Gets the control type name */
  59975. readonly typeName: string;
  59976. /**
  59977. * Get the current class name of the control.
  59978. * @returns current class name
  59979. */
  59980. getClassName(): string;
  59981. /**
  59982. * An event triggered when the pointer move over the control.
  59983. */
  59984. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  59985. /**
  59986. * An event triggered when the pointer move out of the control.
  59987. */
  59988. onPointerOutObservable: BABYLON.Observable<Control>;
  59989. /**
  59990. * An event triggered when the pointer taps the control
  59991. */
  59992. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  59993. /**
  59994. * An event triggered when pointer up
  59995. */
  59996. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  59997. /**
  59998. * An event triggered when a control is clicked on
  59999. */
  60000. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  60001. /**
  60002. * An event triggered when pointer enters the control
  60003. */
  60004. onPointerEnterObservable: BABYLON.Observable<Control>;
  60005. /**
  60006. * An event triggered when the control is marked as dirty
  60007. */
  60008. onDirtyObservable: BABYLON.Observable<Control>;
  60009. /**
  60010. * An event triggered before drawing the control
  60011. */
  60012. onBeforeDrawObservable: BABYLON.Observable<Control>;
  60013. /**
  60014. * An event triggered after the control was drawn
  60015. */
  60016. onAfterDrawObservable: BABYLON.Observable<Control>;
  60017. /**
  60018. * Get the hosting AdvancedDynamicTexture
  60019. */
  60020. readonly host: AdvancedDynamicTexture;
  60021. /** Gets or set information about font offsets (used to render and align text) */
  60022. fontOffset: {
  60023. ascent: number;
  60024. height: number;
  60025. descent: number;
  60026. };
  60027. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  60028. alpha: number;
  60029. /**
  60030. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  60031. */
  60032. isHighlighted: boolean;
  60033. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  60034. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60035. */
  60036. scaleX: number;
  60037. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  60038. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60039. */
  60040. scaleY: number;
  60041. /** Gets or sets the rotation angle (0 by default)
  60042. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60043. */
  60044. rotation: number;
  60045. /** Gets or sets the transformation center on Y axis (0 by default)
  60046. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60047. */
  60048. transformCenterY: number;
  60049. /** Gets or sets the transformation center on X axis (0 by default)
  60050. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60051. */
  60052. transformCenterX: number;
  60053. /**
  60054. * Gets or sets the horizontal alignment
  60055. * @see http://doc.babylonjs.com/how_to/gui#alignments
  60056. */
  60057. horizontalAlignment: number;
  60058. /**
  60059. * Gets or sets the vertical alignment
  60060. * @see http://doc.babylonjs.com/how_to/gui#alignments
  60061. */
  60062. verticalAlignment: number;
  60063. /**
  60064. * Gets or sets control width
  60065. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60066. */
  60067. width: string | number;
  60068. /**
  60069. * Gets or sets the control width in pixel
  60070. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60071. */
  60072. widthInPixels: number;
  60073. /**
  60074. * Gets or sets control height
  60075. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60076. */
  60077. height: string | number;
  60078. /**
  60079. * Gets or sets control height in pixel
  60080. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60081. */
  60082. heightInPixels: number;
  60083. /** Gets or set font family */
  60084. fontFamily: string;
  60085. /** Gets or sets font style */
  60086. fontStyle: string;
  60087. /** Gets or sets font weight */
  60088. fontWeight: string;
  60089. /**
  60090. * Gets or sets style
  60091. * @see http://doc.babylonjs.com/how_to/gui#styles
  60092. */
  60093. style: BABYLON.Nullable<Style>;
  60094. /** @hidden */
  60095. readonly _isFontSizeInPercentage: boolean;
  60096. /** Gets or sets font size in pixels */
  60097. fontSizeInPixels: number;
  60098. /** Gets or sets font size */
  60099. fontSize: string | number;
  60100. /** Gets or sets foreground color */
  60101. color: string;
  60102. /** Gets or sets z index which is used to reorder controls on the z axis */
  60103. zIndex: number;
  60104. /** Gets or sets a boolean indicating if the control can be rendered */
  60105. notRenderable: boolean;
  60106. /** Gets or sets a boolean indicating if the control is visible */
  60107. isVisible: boolean;
  60108. /** Gets a boolean indicating that the control needs to update its rendering */
  60109. readonly isDirty: boolean;
  60110. /**
  60111. * Gets the current linked mesh (or null if none)
  60112. */
  60113. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  60114. /**
  60115. * Gets or sets a value indicating the padding to use on the left of the control
  60116. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60117. */
  60118. paddingLeft: string | number;
  60119. /**
  60120. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  60121. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60122. */
  60123. paddingLeftInPixels: number;
  60124. /**
  60125. * Gets or sets a value indicating the padding to use on the right of the control
  60126. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60127. */
  60128. paddingRight: string | number;
  60129. /**
  60130. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  60131. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60132. */
  60133. paddingRightInPixels: number;
  60134. /**
  60135. * Gets or sets a value indicating the padding to use on the top of the control
  60136. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60137. */
  60138. paddingTop: string | number;
  60139. /**
  60140. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  60141. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60142. */
  60143. paddingTopInPixels: number;
  60144. /**
  60145. * Gets or sets a value indicating the padding to use on the bottom of the control
  60146. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60147. */
  60148. paddingBottom: string | number;
  60149. /**
  60150. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  60151. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60152. */
  60153. paddingBottomInPixels: number;
  60154. /**
  60155. * Gets or sets a value indicating the left coordinate of the control
  60156. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60157. */
  60158. left: string | number;
  60159. /**
  60160. * Gets or sets a value indicating the left coordinate in pixels of the control
  60161. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60162. */
  60163. leftInPixels: number;
  60164. /**
  60165. * Gets or sets a value indicating the top coordinate of the control
  60166. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60167. */
  60168. top: string | number;
  60169. /**
  60170. * Gets or sets a value indicating the top coordinate in pixels of the control
  60171. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60172. */
  60173. topInPixels: number;
  60174. /**
  60175. * Gets or sets a value indicating the offset on X axis to the linked mesh
  60176. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60177. */
  60178. linkOffsetX: string | number;
  60179. /**
  60180. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  60181. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60182. */
  60183. linkOffsetXInPixels: number;
  60184. /**
  60185. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  60186. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60187. */
  60188. linkOffsetY: string | number;
  60189. /**
  60190. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  60191. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60192. */
  60193. linkOffsetYInPixels: number;
  60194. /** Gets the center coordinate on X axis */
  60195. readonly centerX: number;
  60196. /** Gets the center coordinate on Y axis */
  60197. readonly centerY: number;
  60198. /** Gets or sets if control is Enabled*/
  60199. isEnabled: boolean;
  60200. /** Gets or sets background color of control if it's disabled*/
  60201. disabledColor: string;
  60202. /**
  60203. * Creates a new control
  60204. * @param name defines the name of the control
  60205. */
  60206. constructor(
  60207. /** defines the name of the control */
  60208. name?: string | undefined);
  60209. /** @hidden */
  60210. protected _getTypeName(): string;
  60211. /**
  60212. * Gets the first ascendant in the hierarchy of the given type
  60213. * @param className defines the required type
  60214. * @returns the ascendant or null if not found
  60215. */
  60216. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  60217. /** @hidden */
  60218. _resetFontCache(): void;
  60219. /**
  60220. * Determines if a container is an ascendant of the current control
  60221. * @param container defines the container to look for
  60222. * @returns true if the container is one of the ascendant of the control
  60223. */
  60224. isAscendant(container: Control): boolean;
  60225. /**
  60226. * Gets coordinates in local control space
  60227. * @param globalCoordinates defines the coordinates to transform
  60228. * @returns the new coordinates in local space
  60229. */
  60230. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  60231. /**
  60232. * Gets coordinates in local control space
  60233. * @param globalCoordinates defines the coordinates to transform
  60234. * @param result defines the target vector2 where to store the result
  60235. * @returns the current control
  60236. */
  60237. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  60238. /**
  60239. * Gets coordinates in parent local control space
  60240. * @param globalCoordinates defines the coordinates to transform
  60241. * @returns the new coordinates in parent local space
  60242. */
  60243. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  60244. /**
  60245. * Move the current control to a vector3 position projected onto the screen.
  60246. * @param position defines the target position
  60247. * @param scene defines the hosting scene
  60248. */
  60249. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  60250. /** @hidden */
  60251. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  60252. /**
  60253. * Will return all controls that have this control as ascendant
  60254. * @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
  60255. * @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
  60256. * @return all child controls
  60257. */
  60258. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  60259. /**
  60260. * Link current control with a target mesh
  60261. * @param mesh defines the mesh to link with
  60262. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60263. */
  60264. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  60265. /** @hidden */
  60266. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  60267. /** @hidden */
  60268. _offsetLeft(offset: number): void;
  60269. /** @hidden */
  60270. _offsetTop(offset: number): void;
  60271. /** @hidden */
  60272. _markMatrixAsDirty(): void;
  60273. /** @hidden */
  60274. _flagDescendantsAsMatrixDirty(): void;
  60275. /** @hidden */
  60276. _intersectsRect(rect: Measure): boolean;
  60277. /** @hidden */
  60278. protected invalidateRect(): void;
  60279. /** @hidden */
  60280. _markAsDirty(force?: boolean): void;
  60281. /** @hidden */
  60282. _markAllAsDirty(): void;
  60283. /** @hidden */
  60284. _link(host: AdvancedDynamicTexture): void;
  60285. /** @hidden */
  60286. protected _transform(context?: CanvasRenderingContext2D): void;
  60287. /** @hidden */
  60288. _renderHighlight(context: CanvasRenderingContext2D): void;
  60289. /** @hidden */
  60290. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  60291. /** @hidden */
  60292. protected _applyStates(context: CanvasRenderingContext2D): void;
  60293. /** @hidden */
  60294. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  60295. /** @hidden */
  60296. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60297. protected _evaluateClippingState(parentMeasure: Measure): void;
  60298. /** @hidden */
  60299. _measure(): void;
  60300. /** @hidden */
  60301. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60302. /** @hidden */
  60303. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60304. /** @hidden */
  60305. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60306. /** @hidden */
  60307. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60308. private static _ClipMeasure;
  60309. private _tmpMeasureA;
  60310. private _clip;
  60311. /** @hidden */
  60312. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  60313. /** @hidden */
  60314. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  60315. /**
  60316. * Tests if a given coordinates belong to the current control
  60317. * @param x defines x coordinate to test
  60318. * @param y defines y coordinate to test
  60319. * @returns true if the coordinates are inside the control
  60320. */
  60321. contains(x: number, y: number): boolean;
  60322. /** @hidden */
  60323. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60324. /** @hidden */
  60325. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  60326. /** @hidden */
  60327. _onPointerEnter(target: Control): boolean;
  60328. /** @hidden */
  60329. _onPointerOut(target: Control, force?: boolean): void;
  60330. /** @hidden */
  60331. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60332. /** @hidden */
  60333. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60334. /** @hidden */
  60335. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  60336. /** @hidden */
  60337. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  60338. private _prepareFont;
  60339. /** Releases associated resources */
  60340. dispose(): void;
  60341. private static _HORIZONTAL_ALIGNMENT_LEFT;
  60342. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  60343. private static _HORIZONTAL_ALIGNMENT_CENTER;
  60344. private static _VERTICAL_ALIGNMENT_TOP;
  60345. private static _VERTICAL_ALIGNMENT_BOTTOM;
  60346. private static _VERTICAL_ALIGNMENT_CENTER;
  60347. /** HORIZONTAL_ALIGNMENT_LEFT */
  60348. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  60349. /** HORIZONTAL_ALIGNMENT_RIGHT */
  60350. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  60351. /** HORIZONTAL_ALIGNMENT_CENTER */
  60352. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  60353. /** VERTICAL_ALIGNMENT_TOP */
  60354. static readonly VERTICAL_ALIGNMENT_TOP: number;
  60355. /** VERTICAL_ALIGNMENT_BOTTOM */
  60356. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  60357. /** VERTICAL_ALIGNMENT_CENTER */
  60358. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  60359. private static _FontHeightSizes;
  60360. /** @hidden */
  60361. static _GetFontOffset(font: string): {
  60362. ascent: number;
  60363. height: number;
  60364. descent: number;
  60365. };
  60366. /**
  60367. * Creates a stack panel that can be used to render headers
  60368. * @param control defines the control to associate with the header
  60369. * @param text defines the text of the header
  60370. * @param size defines the size of the header
  60371. * @param options defines options used to configure the header
  60372. * @returns a new StackPanel
  60373. * @ignore
  60374. * @hidden
  60375. */
  60376. static AddHeader: (control: Control, text: string, size: string | number, options: {
  60377. isHorizontal: boolean;
  60378. controlFirst: boolean;
  60379. }) => any;
  60380. /** @hidden */
  60381. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  60382. }
  60383. }
  60384. declare module BABYLON.GUI {
  60385. /**
  60386. * Root class for 2D containers
  60387. * @see http://doc.babylonjs.com/how_to/gui#containers
  60388. */
  60389. export class Container extends Control {
  60390. name?: string | undefined;
  60391. /** @hidden */
  60392. protected _children: Control[];
  60393. /** @hidden */
  60394. protected _measureForChildren: Measure;
  60395. /** @hidden */
  60396. protected _background: string;
  60397. /** @hidden */
  60398. protected _adaptWidthToChildren: boolean;
  60399. /** @hidden */
  60400. protected _adaptHeightToChildren: boolean;
  60401. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  60402. adaptHeightToChildren: boolean;
  60403. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  60404. adaptWidthToChildren: boolean;
  60405. /** Gets or sets background color */
  60406. background: string;
  60407. /** Gets the list of children */
  60408. readonly children: Control[];
  60409. /**
  60410. * Creates a new Container
  60411. * @param name defines the name of the container
  60412. */
  60413. constructor(name?: string | undefined);
  60414. protected _getTypeName(): string;
  60415. _flagDescendantsAsMatrixDirty(): void;
  60416. /**
  60417. * Gets a child using its name
  60418. * @param name defines the child name to look for
  60419. * @returns the child control if found
  60420. */
  60421. getChildByName(name: string): BABYLON.Nullable<Control>;
  60422. /**
  60423. * Gets a child using its type and its name
  60424. * @param name defines the child name to look for
  60425. * @param type defines the child type to look for
  60426. * @returns the child control if found
  60427. */
  60428. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  60429. /**
  60430. * Search for a specific control in children
  60431. * @param control defines the control to look for
  60432. * @returns true if the control is in child list
  60433. */
  60434. containsControl(control: Control): boolean;
  60435. /**
  60436. * Adds a new control to the current container
  60437. * @param control defines the control to add
  60438. * @returns the current container
  60439. */
  60440. addControl(control: BABYLON.Nullable<Control>): Container;
  60441. /**
  60442. * Removes all controls from the current container
  60443. * @returns the current container
  60444. */
  60445. clearControls(): Container;
  60446. /**
  60447. * Removes a control from the current container
  60448. * @param control defines the control to remove
  60449. * @returns the current container
  60450. */
  60451. removeControl(control: Control): Container;
  60452. /** @hidden */
  60453. _reOrderControl(control: Control): void;
  60454. /** @hidden */
  60455. _offsetLeft(offset: number): void;
  60456. /** @hidden */
  60457. _offsetTop(offset: number): void;
  60458. /** @hidden */
  60459. _markAllAsDirty(): void;
  60460. /** @hidden */
  60461. protected _localDraw(context: CanvasRenderingContext2D): void;
  60462. /** @hidden */
  60463. _link(host: AdvancedDynamicTexture): void;
  60464. /** @hidden */
  60465. protected _beforeLayout(): void;
  60466. /** @hidden */
  60467. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60468. /** @hidden */
  60469. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  60470. protected _postMeasure(): void;
  60471. /** @hidden */
  60472. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  60473. /** @hidden */
  60474. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  60475. /** @hidden */
  60476. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60477. /** @hidden */
  60478. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60479. /** Releases associated resources */
  60480. dispose(): void;
  60481. }
  60482. }
  60483. declare module BABYLON.GUI {
  60484. /** Class used to create rectangle container */
  60485. export class Rectangle extends Container {
  60486. name?: string | undefined;
  60487. private _thickness;
  60488. private _cornerRadius;
  60489. /** Gets or sets border thickness */
  60490. thickness: number;
  60491. /** Gets or sets the corner radius angle */
  60492. cornerRadius: number;
  60493. /**
  60494. * Creates a new Rectangle
  60495. * @param name defines the control name
  60496. */
  60497. constructor(name?: string | undefined);
  60498. protected _getTypeName(): string;
  60499. protected _localDraw(context: CanvasRenderingContext2D): void;
  60500. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60501. private _drawRoundedRect;
  60502. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60503. }
  60504. }
  60505. declare module BABYLON.GUI {
  60506. /**
  60507. * Enum that determines the text-wrapping mode to use.
  60508. */
  60509. export enum TextWrapping {
  60510. /**
  60511. * Clip the text when it's larger than Control.width; this is the default mode.
  60512. */
  60513. Clip = 0,
  60514. /**
  60515. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  60516. */
  60517. WordWrap = 1,
  60518. /**
  60519. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  60520. */
  60521. Ellipsis = 2
  60522. }
  60523. /**
  60524. * Class used to create text block control
  60525. */
  60526. export class TextBlock extends Control {
  60527. /**
  60528. * Defines the name of the control
  60529. */
  60530. name?: string | undefined;
  60531. private _text;
  60532. private _textWrapping;
  60533. private _textHorizontalAlignment;
  60534. private _textVerticalAlignment;
  60535. private _lines;
  60536. private _resizeToFit;
  60537. private _lineSpacing;
  60538. private _outlineWidth;
  60539. private _outlineColor;
  60540. /**
  60541. * An event triggered after the text is changed
  60542. */
  60543. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  60544. /**
  60545. * An event triggered after the text was broken up into lines
  60546. */
  60547. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  60548. /**
  60549. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  60550. */
  60551. readonly lines: any[];
  60552. /**
  60553. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  60554. */
  60555. /**
  60556. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  60557. */
  60558. resizeToFit: boolean;
  60559. /**
  60560. * Gets or sets a boolean indicating if text must be wrapped
  60561. */
  60562. /**
  60563. * Gets or sets a boolean indicating if text must be wrapped
  60564. */
  60565. textWrapping: TextWrapping | boolean;
  60566. /**
  60567. * Gets or sets text to display
  60568. */
  60569. /**
  60570. * Gets or sets text to display
  60571. */
  60572. text: string;
  60573. /**
  60574. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  60575. */
  60576. /**
  60577. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  60578. */
  60579. textHorizontalAlignment: number;
  60580. /**
  60581. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  60582. */
  60583. /**
  60584. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  60585. */
  60586. textVerticalAlignment: number;
  60587. /**
  60588. * Gets or sets line spacing value
  60589. */
  60590. /**
  60591. * Gets or sets line spacing value
  60592. */
  60593. lineSpacing: string | number;
  60594. /**
  60595. * Gets or sets outlineWidth of the text to display
  60596. */
  60597. /**
  60598. * Gets or sets outlineWidth of the text to display
  60599. */
  60600. outlineWidth: number;
  60601. /**
  60602. * Gets or sets outlineColor of the text to display
  60603. */
  60604. /**
  60605. * Gets or sets outlineColor of the text to display
  60606. */
  60607. outlineColor: string;
  60608. /**
  60609. * Creates a new TextBlock object
  60610. * @param name defines the name of the control
  60611. * @param text defines the text to display (emptry string by default)
  60612. */
  60613. constructor(
  60614. /**
  60615. * Defines the name of the control
  60616. */
  60617. name?: string | undefined, text?: string);
  60618. protected _getTypeName(): string;
  60619. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60620. private _drawText;
  60621. /** @hidden */
  60622. _draw(context: CanvasRenderingContext2D): void;
  60623. protected _applyStates(context: CanvasRenderingContext2D): void;
  60624. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  60625. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  60626. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  60627. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  60628. protected _renderLines(context: CanvasRenderingContext2D): void;
  60629. /**
  60630. * Given a width constraint applied on the text block, find the expected height
  60631. * @returns expected height
  60632. */
  60633. computeExpectedHeight(): number;
  60634. dispose(): void;
  60635. }
  60636. }
  60637. declare module BABYLON.GUI {
  60638. /**
  60639. * Class used to create 2D images
  60640. */
  60641. export class Image extends Control {
  60642. name?: string | undefined;
  60643. private static _WorkingCanvas;
  60644. private _domImage;
  60645. private _imageWidth;
  60646. private _imageHeight;
  60647. private _loaded;
  60648. private _stretch;
  60649. private _source;
  60650. private _autoScale;
  60651. private _sourceLeft;
  60652. private _sourceTop;
  60653. private _sourceWidth;
  60654. private _sourceHeight;
  60655. private _cellWidth;
  60656. private _cellHeight;
  60657. private _cellId;
  60658. private _populateNinePatchSlicesFromImage;
  60659. private _sliceLeft;
  60660. private _sliceRight;
  60661. private _sliceTop;
  60662. private _sliceBottom;
  60663. private _detectPointerOnOpaqueOnly;
  60664. /**
  60665. * BABYLON.Observable notified when the content is loaded
  60666. */
  60667. onImageLoadedObservable: BABYLON.Observable<Image>;
  60668. /**
  60669. * Gets a boolean indicating that the content is loaded
  60670. */
  60671. readonly isLoaded: boolean;
  60672. /**
  60673. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  60674. */
  60675. populateNinePatchSlicesFromImage: boolean;
  60676. /**
  60677. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  60678. * Beware using this as this will comsume more memory as the image has to be stored twice
  60679. */
  60680. detectPointerOnOpaqueOnly: boolean;
  60681. /**
  60682. * Gets or sets the left value for slicing (9-patch)
  60683. */
  60684. sliceLeft: number;
  60685. /**
  60686. * Gets or sets the right value for slicing (9-patch)
  60687. */
  60688. sliceRight: number;
  60689. /**
  60690. * Gets or sets the top value for slicing (9-patch)
  60691. */
  60692. sliceTop: number;
  60693. /**
  60694. * Gets or sets the bottom value for slicing (9-patch)
  60695. */
  60696. sliceBottom: number;
  60697. /**
  60698. * Gets or sets the left coordinate in the source image
  60699. */
  60700. sourceLeft: number;
  60701. /**
  60702. * Gets or sets the top coordinate in the source image
  60703. */
  60704. sourceTop: number;
  60705. /**
  60706. * Gets or sets the width to capture in the source image
  60707. */
  60708. sourceWidth: number;
  60709. /**
  60710. * Gets or sets the height to capture in the source image
  60711. */
  60712. sourceHeight: number;
  60713. /**
  60714. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  60715. * @see http://doc.babylonjs.com/how_to/gui#image
  60716. */
  60717. autoScale: boolean;
  60718. /** Gets or sets the streching mode used by the image */
  60719. stretch: number;
  60720. /**
  60721. * Gets or sets the internal DOM image used to render the control
  60722. */
  60723. domImage: HTMLImageElement;
  60724. private _onImageLoaded;
  60725. private _extractNinePatchSliceDataFromImage;
  60726. /**
  60727. * Gets or sets image source url
  60728. */
  60729. source: BABYLON.Nullable<string>;
  60730. /**
  60731. * Gets or sets the cell width to use when animation sheet is enabled
  60732. * @see http://doc.babylonjs.com/how_to/gui#image
  60733. */
  60734. cellWidth: number;
  60735. /**
  60736. * Gets or sets the cell height to use when animation sheet is enabled
  60737. * @see http://doc.babylonjs.com/how_to/gui#image
  60738. */
  60739. cellHeight: number;
  60740. /**
  60741. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  60742. * @see http://doc.babylonjs.com/how_to/gui#image
  60743. */
  60744. cellId: number;
  60745. /**
  60746. * Creates a new Image
  60747. * @param name defines the control name
  60748. * @param url defines the image url
  60749. */
  60750. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  60751. /**
  60752. * Tests if a given coordinates belong to the current control
  60753. * @param x defines x coordinate to test
  60754. * @param y defines y coordinate to test
  60755. * @returns true if the coordinates are inside the control
  60756. */
  60757. contains(x: number, y: number): boolean;
  60758. protected _getTypeName(): string;
  60759. /** Force the control to synchronize with its content */
  60760. synchronizeSizeWithContent(): void;
  60761. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60762. private _prepareWorkingCanvasForOpaqueDetection;
  60763. private _drawImage;
  60764. _draw(context: CanvasRenderingContext2D): void;
  60765. private _renderCornerPatch;
  60766. private _renderNinePatch;
  60767. dispose(): void;
  60768. /** STRETCH_NONE */
  60769. static readonly STRETCH_NONE: number;
  60770. /** STRETCH_FILL */
  60771. static readonly STRETCH_FILL: number;
  60772. /** STRETCH_UNIFORM */
  60773. static readonly STRETCH_UNIFORM: number;
  60774. /** STRETCH_EXTEND */
  60775. static readonly STRETCH_EXTEND: number;
  60776. /** NINE_PATCH */
  60777. static readonly STRETCH_NINE_PATCH: number;
  60778. }
  60779. }
  60780. declare module BABYLON.GUI {
  60781. /**
  60782. * Class used to create 2D buttons
  60783. */
  60784. export class Button extends Rectangle {
  60785. name?: string | undefined;
  60786. /**
  60787. * Function called to generate a pointer enter animation
  60788. */
  60789. pointerEnterAnimation: () => void;
  60790. /**
  60791. * Function called to generate a pointer out animation
  60792. */
  60793. pointerOutAnimation: () => void;
  60794. /**
  60795. * Function called to generate a pointer down animation
  60796. */
  60797. pointerDownAnimation: () => void;
  60798. /**
  60799. * Function called to generate a pointer up animation
  60800. */
  60801. pointerUpAnimation: () => void;
  60802. private _image;
  60803. /**
  60804. * Returns the image part of the button (if any)
  60805. */
  60806. readonly image: BABYLON.Nullable<Image>;
  60807. private _textBlock;
  60808. /**
  60809. * Returns the image part of the button (if any)
  60810. */
  60811. readonly textBlock: BABYLON.Nullable<TextBlock>;
  60812. /**
  60813. * Creates a new Button
  60814. * @param name defines the name of the button
  60815. */
  60816. constructor(name?: string | undefined);
  60817. protected _getTypeName(): string;
  60818. /** @hidden */
  60819. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60820. /** @hidden */
  60821. _onPointerEnter(target: Control): boolean;
  60822. /** @hidden */
  60823. _onPointerOut(target: Control, force?: boolean): void;
  60824. /** @hidden */
  60825. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60826. /** @hidden */
  60827. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60828. /**
  60829. * Creates a new button made with an image and a text
  60830. * @param name defines the name of the button
  60831. * @param text defines the text of the button
  60832. * @param imageUrl defines the url of the image
  60833. * @returns a new Button
  60834. */
  60835. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  60836. /**
  60837. * Creates a new button made with an image
  60838. * @param name defines the name of the button
  60839. * @param imageUrl defines the url of the image
  60840. * @returns a new Button
  60841. */
  60842. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  60843. /**
  60844. * Creates a new button made with a text
  60845. * @param name defines the name of the button
  60846. * @param text defines the text of the button
  60847. * @returns a new Button
  60848. */
  60849. static CreateSimpleButton(name: string, text: string): Button;
  60850. /**
  60851. * Creates a new button made with an image and a centered text
  60852. * @param name defines the name of the button
  60853. * @param text defines the text of the button
  60854. * @param imageUrl defines the url of the image
  60855. * @returns a new Button
  60856. */
  60857. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  60858. }
  60859. }
  60860. declare module BABYLON.GUI {
  60861. /**
  60862. * Class used to create a 2D stack panel container
  60863. */
  60864. export class StackPanel extends Container {
  60865. name?: string | undefined;
  60866. private _isVertical;
  60867. private _manualWidth;
  60868. private _manualHeight;
  60869. private _doNotTrackManualChanges;
  60870. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  60871. isVertical: boolean;
  60872. /**
  60873. * Gets or sets panel width.
  60874. * This value should not be set when in horizontal mode as it will be computed automatically
  60875. */
  60876. width: string | number;
  60877. /**
  60878. * Gets or sets panel height.
  60879. * This value should not be set when in vertical mode as it will be computed automatically
  60880. */
  60881. height: string | number;
  60882. /**
  60883. * Creates a new StackPanel
  60884. * @param name defines control name
  60885. */
  60886. constructor(name?: string | undefined);
  60887. protected _getTypeName(): string;
  60888. /** @hidden */
  60889. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60890. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60891. protected _postMeasure(): void;
  60892. }
  60893. }
  60894. declare module BABYLON.GUI {
  60895. /**
  60896. * Class used to represent a 2D checkbox
  60897. */
  60898. export class Checkbox extends Control {
  60899. name?: string | undefined;
  60900. private _isChecked;
  60901. private _background;
  60902. private _checkSizeRatio;
  60903. private _thickness;
  60904. /** Gets or sets border thickness */
  60905. thickness: number;
  60906. /**
  60907. * BABYLON.Observable raised when isChecked property changes
  60908. */
  60909. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  60910. /** Gets or sets a value indicating the ratio between overall size and check size */
  60911. checkSizeRatio: number;
  60912. /** Gets or sets background color */
  60913. background: string;
  60914. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  60915. isChecked: boolean;
  60916. /**
  60917. * Creates a new CheckBox
  60918. * @param name defines the control name
  60919. */
  60920. constructor(name?: string | undefined);
  60921. protected _getTypeName(): string;
  60922. /** @hidden */
  60923. _draw(context: CanvasRenderingContext2D): void;
  60924. /** @hidden */
  60925. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60926. /**
  60927. * Utility function to easily create a checkbox with a header
  60928. * @param title defines the label to use for the header
  60929. * @param onValueChanged defines the callback to call when value changes
  60930. * @returns a StackPanel containing the checkbox and a textBlock
  60931. */
  60932. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  60933. }
  60934. }
  60935. declare module BABYLON.GUI {
  60936. /**
  60937. * Class used to store key control properties
  60938. */
  60939. export class KeyPropertySet {
  60940. /** Width */
  60941. width?: string;
  60942. /** Height */
  60943. height?: string;
  60944. /** Left padding */
  60945. paddingLeft?: string;
  60946. /** Right padding */
  60947. paddingRight?: string;
  60948. /** Top padding */
  60949. paddingTop?: string;
  60950. /** Bottom padding */
  60951. paddingBottom?: string;
  60952. /** Foreground color */
  60953. color?: string;
  60954. /** Background color */
  60955. background?: string;
  60956. }
  60957. /**
  60958. * Class used to create virtual keyboard
  60959. */
  60960. export class VirtualKeyboard extends StackPanel {
  60961. /** BABYLON.Observable raised when a key is pressed */
  60962. onKeyPressObservable: BABYLON.Observable<string>;
  60963. /** Gets or sets default key button width */
  60964. defaultButtonWidth: string;
  60965. /** Gets or sets default key button height */
  60966. defaultButtonHeight: string;
  60967. /** Gets or sets default key button left padding */
  60968. defaultButtonPaddingLeft: string;
  60969. /** Gets or sets default key button right padding */
  60970. defaultButtonPaddingRight: string;
  60971. /** Gets or sets default key button top padding */
  60972. defaultButtonPaddingTop: string;
  60973. /** Gets or sets default key button bottom padding */
  60974. defaultButtonPaddingBottom: string;
  60975. /** Gets or sets default key button foreground color */
  60976. defaultButtonColor: string;
  60977. /** Gets or sets default key button background color */
  60978. defaultButtonBackground: string;
  60979. /** Gets or sets shift button foreground color */
  60980. shiftButtonColor: string;
  60981. /** Gets or sets shift button thickness*/
  60982. selectedShiftThickness: number;
  60983. /** Gets shift key state */
  60984. shiftState: number;
  60985. protected _getTypeName(): string;
  60986. private _createKey;
  60987. /**
  60988. * Adds a new row of keys
  60989. * @param keys defines the list of keys to add
  60990. * @param propertySets defines the associated property sets
  60991. */
  60992. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  60993. /**
  60994. * Set the shift key to a specific state
  60995. * @param shiftState defines the new shift state
  60996. */
  60997. applyShiftState(shiftState: number): void;
  60998. private _currentlyConnectedInputText;
  60999. private _connectedInputTexts;
  61000. private _onKeyPressObserver;
  61001. /** Gets the input text control currently attached to the keyboard */
  61002. readonly connectedInputText: BABYLON.Nullable<InputText>;
  61003. /**
  61004. * Connects the keyboard with an input text control
  61005. *
  61006. * @param input defines the target control
  61007. */
  61008. connect(input: InputText): void;
  61009. /**
  61010. * Disconnects the keyboard from connected InputText controls
  61011. *
  61012. * @param input optionally defines a target control, otherwise all are disconnected
  61013. */
  61014. disconnect(input?: InputText): void;
  61015. private _removeConnectedInputObservables;
  61016. /**
  61017. * Release all resources
  61018. */
  61019. dispose(): void;
  61020. /**
  61021. * Creates a new keyboard using a default layout
  61022. *
  61023. * @param name defines control name
  61024. * @returns a new VirtualKeyboard
  61025. */
  61026. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  61027. }
  61028. }
  61029. declare module BABYLON.GUI {
  61030. /**
  61031. * Class used to create input text control
  61032. */
  61033. export class InputText extends Control implements IFocusableControl {
  61034. name?: string | undefined;
  61035. private _text;
  61036. private _placeholderText;
  61037. private _background;
  61038. private _focusedBackground;
  61039. private _focusedColor;
  61040. private _placeholderColor;
  61041. private _thickness;
  61042. private _margin;
  61043. private _autoStretchWidth;
  61044. private _maxWidth;
  61045. private _isFocused;
  61046. private _blinkTimeout;
  61047. private _blinkIsEven;
  61048. private _cursorOffset;
  61049. private _scrollLeft;
  61050. private _textWidth;
  61051. private _clickedCoordinate;
  61052. private _deadKey;
  61053. private _addKey;
  61054. private _currentKey;
  61055. private _isTextHighlightOn;
  61056. private _textHighlightColor;
  61057. private _highligherOpacity;
  61058. private _highlightedText;
  61059. private _startHighlightIndex;
  61060. private _endHighlightIndex;
  61061. private _cursorIndex;
  61062. private _onFocusSelectAll;
  61063. private _isPointerDown;
  61064. private _onClipboardObserver;
  61065. private _onPointerDblTapObserver;
  61066. /** @hidden */
  61067. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  61068. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  61069. promptMessage: string;
  61070. /** BABYLON.Observable raised when the text changes */
  61071. onTextChangedObservable: BABYLON.Observable<InputText>;
  61072. /** BABYLON.Observable raised just before an entered character is to be added */
  61073. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  61074. /** BABYLON.Observable raised when the control gets the focus */
  61075. onFocusObservable: BABYLON.Observable<InputText>;
  61076. /** BABYLON.Observable raised when the control loses the focus */
  61077. onBlurObservable: BABYLON.Observable<InputText>;
  61078. /**Observable raised when the text is highlighted */
  61079. onTextHighlightObservable: BABYLON.Observable<InputText>;
  61080. /**Observable raised when copy event is triggered */
  61081. onTextCopyObservable: BABYLON.Observable<InputText>;
  61082. /** BABYLON.Observable raised when cut event is triggered */
  61083. onTextCutObservable: BABYLON.Observable<InputText>;
  61084. /** BABYLON.Observable raised when paste event is triggered */
  61085. onTextPasteObservable: BABYLON.Observable<InputText>;
  61086. /** BABYLON.Observable raised when a key event was processed */
  61087. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  61088. /** Gets or sets the maximum width allowed by the control */
  61089. maxWidth: string | number;
  61090. /** Gets the maximum width allowed by the control in pixels */
  61091. readonly maxWidthInPixels: number;
  61092. /** Gets or sets the text highlighter transparency; default: 0.4 */
  61093. highligherOpacity: number;
  61094. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  61095. onFocusSelectAll: boolean;
  61096. /** Gets or sets the text hightlight color */
  61097. textHighlightColor: string;
  61098. /** Gets or sets control margin */
  61099. margin: string;
  61100. /** Gets control margin in pixels */
  61101. readonly marginInPixels: number;
  61102. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  61103. autoStretchWidth: boolean;
  61104. /** Gets or sets border thickness */
  61105. thickness: number;
  61106. /** Gets or sets the background color when focused */
  61107. focusedBackground: string;
  61108. /** Gets or sets the background color when focused */
  61109. focusedColor: string;
  61110. /** Gets or sets the background color */
  61111. background: string;
  61112. /** Gets or sets the placeholder color */
  61113. placeholderColor: string;
  61114. /** Gets or sets the text displayed when the control is empty */
  61115. placeholderText: string;
  61116. /** Gets or sets the dead key flag */
  61117. deadKey: boolean;
  61118. /** Gets or sets the highlight text */
  61119. highlightedText: string;
  61120. /** Gets or sets if the current key should be added */
  61121. addKey: boolean;
  61122. /** Gets or sets the value of the current key being entered */
  61123. currentKey: string;
  61124. /** Gets or sets the text displayed in the control */
  61125. text: string;
  61126. /** Gets or sets control width */
  61127. width: string | number;
  61128. /**
  61129. * Creates a new InputText
  61130. * @param name defines the control name
  61131. * @param text defines the text of the control
  61132. */
  61133. constructor(name?: string | undefined, text?: string);
  61134. /** @hidden */
  61135. onBlur(): void;
  61136. /** @hidden */
  61137. onFocus(): void;
  61138. protected _getTypeName(): string;
  61139. /**
  61140. * Function called to get the list of controls that should not steal the focus from this control
  61141. * @returns an array of controls
  61142. */
  61143. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  61144. /** @hidden */
  61145. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  61146. /** @hidden */
  61147. private _updateValueFromCursorIndex;
  61148. /** @hidden */
  61149. private _processDblClick;
  61150. /** @hidden */
  61151. private _selectAllText;
  61152. /**
  61153. * Handles the keyboard event
  61154. * @param evt Defines the KeyboardEvent
  61155. */
  61156. processKeyboard(evt: KeyboardEvent): void;
  61157. /** @hidden */
  61158. private _onCopyText;
  61159. /** @hidden */
  61160. private _onCutText;
  61161. /** @hidden */
  61162. private _onPasteText;
  61163. _draw(context: CanvasRenderingContext2D): void;
  61164. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61165. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61166. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61167. protected _beforeRenderText(text: string): string;
  61168. dispose(): void;
  61169. }
  61170. }
  61171. declare module BABYLON.GUI {
  61172. /**
  61173. * Class used to create a 2D grid container
  61174. */
  61175. export class Grid extends Container {
  61176. name?: string | undefined;
  61177. private _rowDefinitions;
  61178. private _columnDefinitions;
  61179. private _cells;
  61180. private _childControls;
  61181. /**
  61182. * Gets the number of columns
  61183. */
  61184. readonly columnCount: number;
  61185. /**
  61186. * Gets the number of rows
  61187. */
  61188. readonly rowCount: number;
  61189. /** Gets the list of children */
  61190. readonly children: Control[];
  61191. /** Gets the list of cells (e.g. the containers) */
  61192. readonly cells: {
  61193. [key: string]: Container;
  61194. };
  61195. /**
  61196. * Gets the definition of a specific row
  61197. * @param index defines the index of the row
  61198. * @returns the row definition
  61199. */
  61200. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  61201. /**
  61202. * Gets the definition of a specific column
  61203. * @param index defines the index of the column
  61204. * @returns the column definition
  61205. */
  61206. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  61207. /**
  61208. * Adds a new row to the grid
  61209. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  61210. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  61211. * @returns the current grid
  61212. */
  61213. addRowDefinition(height: number, isPixel?: boolean): Grid;
  61214. /**
  61215. * Adds a new column to the grid
  61216. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  61217. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  61218. * @returns the current grid
  61219. */
  61220. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  61221. /**
  61222. * Update a row definition
  61223. * @param index defines the index of the row to update
  61224. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  61225. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  61226. * @returns the current grid
  61227. */
  61228. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  61229. /**
  61230. * Update a column definition
  61231. * @param index defines the index of the column to update
  61232. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  61233. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  61234. * @returns the current grid
  61235. */
  61236. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  61237. /**
  61238. * Gets the list of children stored in a specific cell
  61239. * @param row defines the row to check
  61240. * @param column defines the column to check
  61241. * @returns the list of controls
  61242. */
  61243. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  61244. /**
  61245. * Gets a string representing the child cell info (row x column)
  61246. * @param child defines the control to get info from
  61247. * @returns a string containing the child cell info (row x column)
  61248. */
  61249. getChildCellInfo(child: Control): string;
  61250. private _removeCell;
  61251. private _offsetCell;
  61252. /**
  61253. * Remove a column definition at specified index
  61254. * @param index defines the index of the column to remove
  61255. * @returns the current grid
  61256. */
  61257. removeColumnDefinition(index: number): Grid;
  61258. /**
  61259. * Remove a row definition at specified index
  61260. * @param index defines the index of the row to remove
  61261. * @returns the current grid
  61262. */
  61263. removeRowDefinition(index: number): Grid;
  61264. /**
  61265. * Adds a new control to the current grid
  61266. * @param control defines the control to add
  61267. * @param row defines the row where to add the control (0 by default)
  61268. * @param column defines the column where to add the control (0 by default)
  61269. * @returns the current grid
  61270. */
  61271. addControl(control: Control, row?: number, column?: number): Grid;
  61272. /**
  61273. * Removes a control from the current container
  61274. * @param control defines the control to remove
  61275. * @returns the current container
  61276. */
  61277. removeControl(control: Control): Container;
  61278. /**
  61279. * Creates a new Grid
  61280. * @param name defines control name
  61281. */
  61282. constructor(name?: string | undefined);
  61283. protected _getTypeName(): string;
  61284. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  61285. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61286. _flagDescendantsAsMatrixDirty(): void;
  61287. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61288. /** Releases associated resources */
  61289. dispose(): void;
  61290. }
  61291. }
  61292. declare module BABYLON.GUI {
  61293. /** Class used to create color pickers */
  61294. export class ColorPicker extends Control {
  61295. name?: string | undefined;
  61296. private static _Epsilon;
  61297. private _colorWheelCanvas;
  61298. private _value;
  61299. private _tmpColor;
  61300. private _pointerStartedOnSquare;
  61301. private _pointerStartedOnWheel;
  61302. private _squareLeft;
  61303. private _squareTop;
  61304. private _squareSize;
  61305. private _h;
  61306. private _s;
  61307. private _v;
  61308. private _lastPointerDownID;
  61309. /**
  61310. * BABYLON.Observable raised when the value changes
  61311. */
  61312. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  61313. /** Gets or sets the color of the color picker */
  61314. value: BABYLON.Color3;
  61315. /**
  61316. * Gets or sets control width
  61317. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61318. */
  61319. width: string | number;
  61320. /**
  61321. * Gets or sets control height
  61322. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61323. */
  61324. /** Gets or sets control height */
  61325. height: string | number;
  61326. /** Gets or sets control size */
  61327. size: string | number;
  61328. /**
  61329. * Creates a new ColorPicker
  61330. * @param name defines the control name
  61331. */
  61332. constructor(name?: string | undefined);
  61333. protected _getTypeName(): string;
  61334. /** @hidden */
  61335. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61336. private _updateSquareProps;
  61337. private _drawGradientSquare;
  61338. private _drawCircle;
  61339. private _createColorWheelCanvas;
  61340. /** @hidden */
  61341. _draw(context: CanvasRenderingContext2D): void;
  61342. private _pointerIsDown;
  61343. private _updateValueFromPointer;
  61344. private _isPointOnSquare;
  61345. private _isPointOnWheel;
  61346. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61347. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61348. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61349. /**
  61350. * This function expands the color picker by creating a color picker dialog with manual
  61351. * color value input and the ability to save colors into an array to be used later in
  61352. * subsequent launches of the dialogue.
  61353. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  61354. * @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.
  61355. * @returns picked color as a hex string and the saved colors array as hex strings.
  61356. */
  61357. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  61358. pickerWidth?: string;
  61359. pickerHeight?: string;
  61360. headerHeight?: string;
  61361. lastColor?: string;
  61362. swatchLimit?: number;
  61363. numSwatchesPerLine?: number;
  61364. savedColors?: Array<string>;
  61365. }): Promise<{
  61366. savedColors?: string[];
  61367. pickedColor: string;
  61368. }>;
  61369. }
  61370. }
  61371. declare module BABYLON.GUI {
  61372. /** Class used to create 2D ellipse containers */
  61373. export class Ellipse extends Container {
  61374. name?: string | undefined;
  61375. private _thickness;
  61376. /** Gets or sets border thickness */
  61377. thickness: number;
  61378. /**
  61379. * Creates a new Ellipse
  61380. * @param name defines the control name
  61381. */
  61382. constructor(name?: string | undefined);
  61383. protected _getTypeName(): string;
  61384. protected _localDraw(context: CanvasRenderingContext2D): void;
  61385. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61386. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61387. }
  61388. }
  61389. declare module BABYLON.GUI {
  61390. /**
  61391. * Class used to create a password control
  61392. */
  61393. export class InputPassword extends InputText {
  61394. protected _beforeRenderText(text: string): string;
  61395. }
  61396. }
  61397. declare module BABYLON.GUI {
  61398. /** Class used to render 2D lines */
  61399. export class Line extends Control {
  61400. name?: string | undefined;
  61401. private _lineWidth;
  61402. private _x1;
  61403. private _y1;
  61404. private _x2;
  61405. private _y2;
  61406. private _dash;
  61407. private _connectedControl;
  61408. private _connectedControlDirtyObserver;
  61409. /** Gets or sets the dash pattern */
  61410. dash: Array<number>;
  61411. /** Gets or sets the control connected with the line end */
  61412. connectedControl: Control;
  61413. /** Gets or sets start coordinates on X axis */
  61414. x1: string | number;
  61415. /** Gets or sets start coordinates on Y axis */
  61416. y1: string | number;
  61417. /** Gets or sets end coordinates on X axis */
  61418. x2: string | number;
  61419. /** Gets or sets end coordinates on Y axis */
  61420. y2: string | number;
  61421. /** Gets or sets line width */
  61422. lineWidth: number;
  61423. /** Gets or sets horizontal alignment */
  61424. horizontalAlignment: number;
  61425. /** Gets or sets vertical alignment */
  61426. verticalAlignment: number;
  61427. private readonly _effectiveX2;
  61428. private readonly _effectiveY2;
  61429. /**
  61430. * Creates a new Line
  61431. * @param name defines the control name
  61432. */
  61433. constructor(name?: string | undefined);
  61434. protected _getTypeName(): string;
  61435. _draw(context: CanvasRenderingContext2D): void;
  61436. _measure(): void;
  61437. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61438. /**
  61439. * Move one end of the line given 3D cartesian coordinates.
  61440. * @param position Targeted world position
  61441. * @param scene BABYLON.Scene
  61442. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  61443. */
  61444. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  61445. /**
  61446. * Move one end of the line to a position in screen absolute space.
  61447. * @param projectedPosition Position in screen absolute space (X, Y)
  61448. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  61449. */
  61450. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  61451. }
  61452. }
  61453. declare module BABYLON.GUI {
  61454. /**
  61455. * Class used to store a point for a MultiLine object.
  61456. * The point can be pure 2D coordinates, a mesh or a control
  61457. */
  61458. export class MultiLinePoint {
  61459. private _multiLine;
  61460. private _x;
  61461. private _y;
  61462. private _control;
  61463. private _mesh;
  61464. private _controlObserver;
  61465. private _meshObserver;
  61466. /** @hidden */
  61467. _point: BABYLON.Vector2;
  61468. /**
  61469. * Creates a new MultiLinePoint
  61470. * @param multiLine defines the source MultiLine object
  61471. */
  61472. constructor(multiLine: MultiLine);
  61473. /** Gets or sets x coordinate */
  61474. x: string | number;
  61475. /** Gets or sets y coordinate */
  61476. y: string | number;
  61477. /** Gets or sets the control associated with this point */
  61478. control: BABYLON.Nullable<Control>;
  61479. /** Gets or sets the mesh associated with this point */
  61480. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61481. /** Resets links */
  61482. resetLinks(): void;
  61483. /**
  61484. * Gets a translation vector
  61485. * @returns the translation vector
  61486. */
  61487. translate(): BABYLON.Vector2;
  61488. private _translatePoint;
  61489. /** Release associated resources */
  61490. dispose(): void;
  61491. }
  61492. }
  61493. declare module BABYLON.GUI {
  61494. /**
  61495. * Class used to create multi line control
  61496. */
  61497. export class MultiLine extends Control {
  61498. name?: string | undefined;
  61499. private _lineWidth;
  61500. private _dash;
  61501. private _points;
  61502. private _minX;
  61503. private _minY;
  61504. private _maxX;
  61505. private _maxY;
  61506. /**
  61507. * Creates a new MultiLine
  61508. * @param name defines the control name
  61509. */
  61510. constructor(name?: string | undefined);
  61511. /** Gets or sets dash pattern */
  61512. dash: Array<number>;
  61513. /**
  61514. * Gets point stored at specified index
  61515. * @param index defines the index to look for
  61516. * @returns the requested point if found
  61517. */
  61518. getAt(index: number): MultiLinePoint;
  61519. /** Function called when a point is updated */
  61520. onPointUpdate: () => void;
  61521. /**
  61522. * Adds new points to the point collection
  61523. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  61524. * @returns the list of created MultiLinePoint
  61525. */
  61526. add(...items: (AbstractMesh | Control | {
  61527. x: string | number;
  61528. y: string | number;
  61529. })[]): MultiLinePoint[];
  61530. /**
  61531. * Adds a new point to the point collection
  61532. * @param item defines the item (mesh, control or 2d coordiantes) to add
  61533. * @returns the created MultiLinePoint
  61534. */
  61535. push(item?: (AbstractMesh | Control | {
  61536. x: string | number;
  61537. y: string | number;
  61538. })): MultiLinePoint;
  61539. /**
  61540. * Remove a specific value or point from the active point collection
  61541. * @param value defines the value or point to remove
  61542. */
  61543. remove(value: number | MultiLinePoint): void;
  61544. /**
  61545. * Resets this object to initial state (no point)
  61546. */
  61547. reset(): void;
  61548. /**
  61549. * Resets all links
  61550. */
  61551. resetLinks(): void;
  61552. /** Gets or sets line width */
  61553. lineWidth: number;
  61554. horizontalAlignment: number;
  61555. verticalAlignment: number;
  61556. protected _getTypeName(): string;
  61557. _draw(context: CanvasRenderingContext2D): void;
  61558. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61559. _measure(): void;
  61560. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61561. dispose(): void;
  61562. }
  61563. }
  61564. declare module BABYLON.GUI {
  61565. /**
  61566. * Class used to create radio button controls
  61567. */
  61568. export class RadioButton extends Control {
  61569. name?: string | undefined;
  61570. private _isChecked;
  61571. private _background;
  61572. private _checkSizeRatio;
  61573. private _thickness;
  61574. /** Gets or sets border thickness */
  61575. thickness: number;
  61576. /** Gets or sets group name */
  61577. group: string;
  61578. /** BABYLON.Observable raised when isChecked is changed */
  61579. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  61580. /** Gets or sets a value indicating the ratio between overall size and check size */
  61581. checkSizeRatio: number;
  61582. /** Gets or sets background color */
  61583. background: string;
  61584. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  61585. isChecked: boolean;
  61586. /**
  61587. * Creates a new RadioButton
  61588. * @param name defines the control name
  61589. */
  61590. constructor(name?: string | undefined);
  61591. protected _getTypeName(): string;
  61592. _draw(context: CanvasRenderingContext2D): void;
  61593. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61594. /**
  61595. * Utility function to easily create a radio button with a header
  61596. * @param title defines the label to use for the header
  61597. * @param group defines the group to use for the radio button
  61598. * @param isChecked defines the initial state of the radio button
  61599. * @param onValueChanged defines the callback to call when value changes
  61600. * @returns a StackPanel containing the radio button and a textBlock
  61601. */
  61602. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  61603. }
  61604. }
  61605. declare module BABYLON.GUI {
  61606. /**
  61607. * Class used to create slider controls
  61608. */
  61609. export class BaseSlider extends Control {
  61610. name?: string | undefined;
  61611. protected _thumbWidth: ValueAndUnit;
  61612. private _minimum;
  61613. private _maximum;
  61614. private _value;
  61615. private _isVertical;
  61616. protected _barOffset: ValueAndUnit;
  61617. private _isThumbClamped;
  61618. protected _displayThumb: boolean;
  61619. private _step;
  61620. private _lastPointerDownID;
  61621. protected _effectiveBarOffset: number;
  61622. protected _renderLeft: number;
  61623. protected _renderTop: number;
  61624. protected _renderWidth: number;
  61625. protected _renderHeight: number;
  61626. protected _backgroundBoxLength: number;
  61627. protected _backgroundBoxThickness: number;
  61628. protected _effectiveThumbThickness: number;
  61629. /** BABYLON.Observable raised when the sldier value changes */
  61630. onValueChangedObservable: BABYLON.Observable<number>;
  61631. /** Gets or sets a boolean indicating if the thumb must be rendered */
  61632. displayThumb: boolean;
  61633. /** Gets or sets a step to apply to values (0 by default) */
  61634. step: number;
  61635. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  61636. barOffset: string | number;
  61637. /** Gets main bar offset in pixels*/
  61638. readonly barOffsetInPixels: number;
  61639. /** Gets or sets thumb width */
  61640. thumbWidth: string | number;
  61641. /** Gets thumb width in pixels */
  61642. readonly thumbWidthInPixels: number;
  61643. /** Gets or sets minimum value */
  61644. minimum: number;
  61645. /** Gets or sets maximum value */
  61646. maximum: number;
  61647. /** Gets or sets current value */
  61648. value: number;
  61649. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  61650. isVertical: boolean;
  61651. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  61652. isThumbClamped: boolean;
  61653. /**
  61654. * Creates a new BaseSlider
  61655. * @param name defines the control name
  61656. */
  61657. constructor(name?: string | undefined);
  61658. protected _getTypeName(): string;
  61659. protected _getThumbPosition(): number;
  61660. protected _getThumbThickness(type: string): number;
  61661. protected _prepareRenderingData(type: string): void;
  61662. private _pointerIsDown;
  61663. /** @hidden */
  61664. protected _updateValueFromPointer(x: number, y: number): void;
  61665. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61666. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61667. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61668. }
  61669. }
  61670. declare module BABYLON.GUI {
  61671. /**
  61672. * Class used to create slider controls
  61673. */
  61674. export class Slider extends BaseSlider {
  61675. name?: string | undefined;
  61676. private _background;
  61677. private _borderColor;
  61678. private _isThumbCircle;
  61679. protected _displayValueBar: boolean;
  61680. /** Gets or sets a boolean indicating if the value bar must be rendered */
  61681. displayValueBar: boolean;
  61682. /** Gets or sets border color */
  61683. borderColor: string;
  61684. /** Gets or sets background color */
  61685. background: string;
  61686. /** Gets or sets a boolean indicating if the thumb should be round or square */
  61687. isThumbCircle: boolean;
  61688. /**
  61689. * Creates a new Slider
  61690. * @param name defines the control name
  61691. */
  61692. constructor(name?: string | undefined);
  61693. protected _getTypeName(): string;
  61694. _draw(context: CanvasRenderingContext2D): void;
  61695. }
  61696. }
  61697. declare module BABYLON.GUI {
  61698. /** Class used to create a RadioGroup
  61699. * which contains groups of radio buttons
  61700. */
  61701. export class SelectorGroup {
  61702. /** name of SelectorGroup */
  61703. name: string;
  61704. private _groupPanel;
  61705. private _selectors;
  61706. private _groupHeader;
  61707. /**
  61708. * Creates a new SelectorGroup
  61709. * @param name of group, used as a group heading
  61710. */
  61711. constructor(
  61712. /** name of SelectorGroup */
  61713. name: string);
  61714. /** Gets the groupPanel of the SelectorGroup */
  61715. readonly groupPanel: StackPanel;
  61716. /** Gets the selectors array */
  61717. readonly selectors: StackPanel[];
  61718. /** Gets and sets the group header */
  61719. header: string;
  61720. /** @hidden */
  61721. private _addGroupHeader;
  61722. /** @hidden*/
  61723. _getSelector(selectorNb: number): StackPanel | undefined;
  61724. /** Removes the selector at the given position
  61725. * @param selectorNb the position of the selector within the group
  61726. */
  61727. removeSelector(selectorNb: number): void;
  61728. }
  61729. /** Class used to create a CheckboxGroup
  61730. * which contains groups of checkbox buttons
  61731. */
  61732. export class CheckboxGroup extends SelectorGroup {
  61733. /** Adds a checkbox as a control
  61734. * @param text is the label for the selector
  61735. * @param func is the function called when the Selector is checked
  61736. * @param checked is true when Selector is checked
  61737. */
  61738. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  61739. /** @hidden */
  61740. _setSelectorLabel(selectorNb: number, label: string): void;
  61741. /** @hidden */
  61742. _setSelectorLabelColor(selectorNb: number, color: string): void;
  61743. /** @hidden */
  61744. _setSelectorButtonColor(selectorNb: number, color: string): void;
  61745. /** @hidden */
  61746. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61747. }
  61748. /** Class used to create a RadioGroup
  61749. * which contains groups of radio buttons
  61750. */
  61751. export class RadioGroup extends SelectorGroup {
  61752. private _selectNb;
  61753. /** Adds a radio button as a control
  61754. * @param label is the label for the selector
  61755. * @param func is the function called when the Selector is checked
  61756. * @param checked is true when Selector is checked
  61757. */
  61758. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  61759. /** @hidden */
  61760. _setSelectorLabel(selectorNb: number, label: string): void;
  61761. /** @hidden */
  61762. _setSelectorLabelColor(selectorNb: number, color: string): void;
  61763. /** @hidden */
  61764. _setSelectorButtonColor(selectorNb: number, color: string): void;
  61765. /** @hidden */
  61766. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61767. }
  61768. /** Class used to create a SliderGroup
  61769. * which contains groups of slider buttons
  61770. */
  61771. export class SliderGroup extends SelectorGroup {
  61772. /**
  61773. * Adds a slider to the SelectorGroup
  61774. * @param label is the label for the SliderBar
  61775. * @param func is the function called when the Slider moves
  61776. * @param unit is a string describing the units used, eg degrees or metres
  61777. * @param min is the minimum value for the Slider
  61778. * @param max is the maximum value for the Slider
  61779. * @param value is the start value for the Slider between min and max
  61780. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  61781. */
  61782. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  61783. /** @hidden */
  61784. _setSelectorLabel(selectorNb: number, label: string): void;
  61785. /** @hidden */
  61786. _setSelectorLabelColor(selectorNb: number, color: string): void;
  61787. /** @hidden */
  61788. _setSelectorButtonColor(selectorNb: number, color: string): void;
  61789. /** @hidden */
  61790. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61791. }
  61792. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  61793. * @see http://doc.babylonjs.com/how_to/selector
  61794. */
  61795. export class SelectionPanel extends Rectangle {
  61796. /** name of SelectionPanel */
  61797. name: string;
  61798. /** an array of SelectionGroups */
  61799. groups: SelectorGroup[];
  61800. private _panel;
  61801. private _buttonColor;
  61802. private _buttonBackground;
  61803. private _headerColor;
  61804. private _barColor;
  61805. private _barHeight;
  61806. private _spacerHeight;
  61807. private _labelColor;
  61808. private _groups;
  61809. private _bars;
  61810. /**
  61811. * Creates a new SelectionPanel
  61812. * @param name of SelectionPanel
  61813. * @param groups is an array of SelectionGroups
  61814. */
  61815. constructor(
  61816. /** name of SelectionPanel */
  61817. name: string,
  61818. /** an array of SelectionGroups */
  61819. groups?: SelectorGroup[]);
  61820. protected _getTypeName(): string;
  61821. /** Gets or sets the headerColor */
  61822. headerColor: string;
  61823. private _setHeaderColor;
  61824. /** Gets or sets the button color */
  61825. buttonColor: string;
  61826. private _setbuttonColor;
  61827. /** Gets or sets the label color */
  61828. labelColor: string;
  61829. private _setLabelColor;
  61830. /** Gets or sets the button background */
  61831. buttonBackground: string;
  61832. private _setButtonBackground;
  61833. /** Gets or sets the color of separator bar */
  61834. barColor: string;
  61835. private _setBarColor;
  61836. /** Gets or sets the height of separator bar */
  61837. barHeight: string;
  61838. private _setBarHeight;
  61839. /** Gets or sets the height of spacers*/
  61840. spacerHeight: string;
  61841. private _setSpacerHeight;
  61842. /** Adds a bar between groups */
  61843. private _addSpacer;
  61844. /** Add a group to the selection panel
  61845. * @param group is the selector group to add
  61846. */
  61847. addGroup(group: SelectorGroup): void;
  61848. /** Remove the group from the given position
  61849. * @param groupNb is the position of the group in the list
  61850. */
  61851. removeGroup(groupNb: number): void;
  61852. /** Change a group header label
  61853. * @param label is the new group header label
  61854. * @param groupNb is the number of the group to relabel
  61855. * */
  61856. setHeaderName(label: string, groupNb: number): void;
  61857. /** Change selector label to the one given
  61858. * @param label is the new selector label
  61859. * @param groupNb is the number of the groupcontaining the selector
  61860. * @param selectorNb is the number of the selector within a group to relabel
  61861. * */
  61862. relabel(label: string, groupNb: number, selectorNb: number): void;
  61863. /** For a given group position remove the selector at the given position
  61864. * @param groupNb is the number of the group to remove the selector from
  61865. * @param selectorNb is the number of the selector within the group
  61866. */
  61867. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  61868. /** For a given group position of correct type add a checkbox button
  61869. * @param groupNb is the number of the group to remove the selector from
  61870. * @param label is the label for the selector
  61871. * @param func is the function called when the Selector is checked
  61872. * @param checked is true when Selector is checked
  61873. */
  61874. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  61875. /** For a given group position of correct type add a radio button
  61876. * @param groupNb is the number of the group to remove the selector from
  61877. * @param label is the label for the selector
  61878. * @param func is the function called when the Selector is checked
  61879. * @param checked is true when Selector is checked
  61880. */
  61881. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  61882. /**
  61883. * For a given slider group add a slider
  61884. * @param groupNb is the number of the group to add the slider to
  61885. * @param label is the label for the Slider
  61886. * @param func is the function called when the Slider moves
  61887. * @param unit is a string describing the units used, eg degrees or metres
  61888. * @param min is the minimum value for the Slider
  61889. * @param max is the maximum value for the Slider
  61890. * @param value is the start value for the Slider between min and max
  61891. * @param onVal is the function used to format the value displayed, eg radians to degrees
  61892. */
  61893. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  61894. }
  61895. }
  61896. declare module BABYLON.GUI {
  61897. /**
  61898. * Class used to hold a the container for ScrollViewer
  61899. * @hidden
  61900. */
  61901. export class _ScrollViewerWindow extends Container {
  61902. parentClientWidth: number;
  61903. parentClientHeight: number;
  61904. /**
  61905. * Creates a new ScrollViewerWindow
  61906. * @param name of ScrollViewerWindow
  61907. */
  61908. constructor(name?: string);
  61909. protected _getTypeName(): string;
  61910. /** @hidden */
  61911. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61912. protected _postMeasure(): void;
  61913. }
  61914. }
  61915. declare module BABYLON.GUI {
  61916. /**
  61917. * Class used to create slider controls
  61918. */
  61919. export class ScrollBar extends BaseSlider {
  61920. name?: string | undefined;
  61921. private _background;
  61922. private _borderColor;
  61923. private _thumbMeasure;
  61924. /** Gets or sets border color */
  61925. borderColor: string;
  61926. /** Gets or sets background color */
  61927. background: string;
  61928. /**
  61929. * Creates a new Slider
  61930. * @param name defines the control name
  61931. */
  61932. constructor(name?: string | undefined);
  61933. protected _getTypeName(): string;
  61934. protected _getThumbThickness(): number;
  61935. _draw(context: CanvasRenderingContext2D): void;
  61936. private _first;
  61937. private _originX;
  61938. private _originY;
  61939. /** @hidden */
  61940. protected _updateValueFromPointer(x: number, y: number): void;
  61941. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61942. }
  61943. }
  61944. declare module BABYLON.GUI {
  61945. /**
  61946. * Class used to hold a viewer window and sliders in a grid
  61947. */
  61948. export class ScrollViewer extends Rectangle {
  61949. private _grid;
  61950. private _horizontalBarSpace;
  61951. private _verticalBarSpace;
  61952. private _dragSpace;
  61953. private _horizontalBar;
  61954. private _verticalBar;
  61955. private _barColor;
  61956. private _barBackground;
  61957. private _barSize;
  61958. private _endLeft;
  61959. private _endTop;
  61960. private _window;
  61961. private _pointerIsOver;
  61962. private _wheelPrecision;
  61963. private _onPointerObserver;
  61964. private _clientWidth;
  61965. private _clientHeight;
  61966. /**
  61967. * Gets the horizontal scrollbar
  61968. */
  61969. readonly horizontalBar: ScrollBar;
  61970. /**
  61971. * Gets the vertical scrollbar
  61972. */
  61973. readonly verticalBar: ScrollBar;
  61974. /**
  61975. * Adds a new control to the current container
  61976. * @param control defines the control to add
  61977. * @returns the current container
  61978. */
  61979. addControl(control: BABYLON.Nullable<Control>): Container;
  61980. /**
  61981. * Removes a control from the current container
  61982. * @param control defines the control to remove
  61983. * @returns the current container
  61984. */
  61985. removeControl(control: Control): Container;
  61986. /** Gets the list of children */
  61987. readonly children: Control[];
  61988. _flagDescendantsAsMatrixDirty(): void;
  61989. /**
  61990. * Creates a new ScrollViewer
  61991. * @param name of ScrollViewer
  61992. */
  61993. constructor(name?: string);
  61994. /** Reset the scroll viewer window to initial size */
  61995. resetWindow(): void;
  61996. protected _getTypeName(): string;
  61997. private _buildClientSizes;
  61998. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61999. protected _postMeasure(): void;
  62000. /**
  62001. * Gets or sets the mouse wheel precision
  62002. * from 0 to 1 with a default value of 0.05
  62003. * */
  62004. wheelPrecision: number;
  62005. /** Gets or sets the bar color */
  62006. barColor: string;
  62007. /** Gets or sets the size of the bar */
  62008. barSize: number;
  62009. /** Gets or sets the bar background */
  62010. barBackground: string;
  62011. /** @hidden */
  62012. private _updateScroller;
  62013. _link(host: AdvancedDynamicTexture): void;
  62014. /** @hidden */
  62015. private _attachWheel;
  62016. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62017. /** Releases associated resources */
  62018. dispose(): void;
  62019. }
  62020. }
  62021. declare module BABYLON.GUI {
  62022. /** Class used to render a grid */
  62023. export class DisplayGrid extends Control {
  62024. name?: string | undefined;
  62025. private _cellWidth;
  62026. private _cellHeight;
  62027. private _minorLineTickness;
  62028. private _minorLineColor;
  62029. private _majorLineTickness;
  62030. private _majorLineColor;
  62031. private _majorLineFrequency;
  62032. private _background;
  62033. private _displayMajorLines;
  62034. private _displayMinorLines;
  62035. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  62036. displayMinorLines: boolean;
  62037. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  62038. displayMajorLines: boolean;
  62039. /** Gets or sets background color (Black by default) */
  62040. background: string;
  62041. /** Gets or sets the width of each cell (20 by default) */
  62042. cellWidth: number;
  62043. /** Gets or sets the height of each cell (20 by default) */
  62044. cellHeight: number;
  62045. /** Gets or sets the tickness of minor lines (1 by default) */
  62046. minorLineTickness: number;
  62047. /** Gets or sets the color of minor lines (DarkGray by default) */
  62048. minorLineColor: string;
  62049. /** Gets or sets the tickness of major lines (2 by default) */
  62050. majorLineTickness: number;
  62051. /** Gets or sets the color of major lines (White by default) */
  62052. majorLineColor: string;
  62053. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  62054. majorLineFrequency: number;
  62055. /**
  62056. * Creates a new GridDisplayRectangle
  62057. * @param name defines the control name
  62058. */
  62059. constructor(name?: string | undefined);
  62060. _draw(context: CanvasRenderingContext2D): void;
  62061. protected _getTypeName(): string;
  62062. }
  62063. }
  62064. declare module BABYLON.GUI {
  62065. /**
  62066. * Class used to create slider controls based on images
  62067. */
  62068. export class ImageBasedSlider extends BaseSlider {
  62069. name?: string | undefined;
  62070. private _backgroundImage;
  62071. private _thumbImage;
  62072. private _valueBarImage;
  62073. private _tempMeasure;
  62074. displayThumb: boolean;
  62075. /**
  62076. * Gets or sets the image used to render the background
  62077. */
  62078. backgroundImage: Image;
  62079. /**
  62080. * Gets or sets the image used to render the value bar
  62081. */
  62082. valueBarImage: Image;
  62083. /**
  62084. * Gets or sets the image used to render the thumb
  62085. */
  62086. thumbImage: Image;
  62087. /**
  62088. * Creates a new ImageBasedSlider
  62089. * @param name defines the control name
  62090. */
  62091. constructor(name?: string | undefined);
  62092. protected _getTypeName(): string;
  62093. _draw(context: CanvasRenderingContext2D): void;
  62094. }
  62095. }
  62096. declare module BABYLON.GUI {
  62097. /**
  62098. * Forcing an export so that this code will execute
  62099. * @hidden
  62100. */
  62101. const name = "Statics";
  62102. }
  62103. declare module BABYLON.GUI {
  62104. /**
  62105. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  62106. */
  62107. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  62108. /**
  62109. * Define the instrumented AdvancedDynamicTexture.
  62110. */
  62111. texture: AdvancedDynamicTexture;
  62112. private _captureRenderTime;
  62113. private _renderTime;
  62114. private _captureLayoutTime;
  62115. private _layoutTime;
  62116. private _onBeginRenderObserver;
  62117. private _onEndRenderObserver;
  62118. private _onBeginLayoutObserver;
  62119. private _onEndLayoutObserver;
  62120. /**
  62121. * Gets the perf counter used to capture render time
  62122. */
  62123. readonly renderTimeCounter: BABYLON.PerfCounter;
  62124. /**
  62125. * Gets the perf counter used to capture layout time
  62126. */
  62127. readonly layoutTimeCounter: BABYLON.PerfCounter;
  62128. /**
  62129. * Enable or disable the render time capture
  62130. */
  62131. captureRenderTime: boolean;
  62132. /**
  62133. * Enable or disable the layout time capture
  62134. */
  62135. captureLayoutTime: boolean;
  62136. /**
  62137. * Instantiates a new advanced dynamic texture instrumentation.
  62138. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  62139. * @param texture Defines the AdvancedDynamicTexture to instrument
  62140. */
  62141. constructor(
  62142. /**
  62143. * Define the instrumented AdvancedDynamicTexture.
  62144. */
  62145. texture: AdvancedDynamicTexture);
  62146. /**
  62147. * Dispose and release associated resources.
  62148. */
  62149. dispose(): void;
  62150. }
  62151. }
  62152. declare module BABYLON.GUI {
  62153. /**
  62154. * Class used to create containers for controls
  62155. */
  62156. export class Container3D extends Control3D {
  62157. private _blockLayout;
  62158. /**
  62159. * Gets the list of child controls
  62160. */
  62161. protected _children: Control3D[];
  62162. /**
  62163. * Gets the list of child controls
  62164. */
  62165. readonly children: Array<Control3D>;
  62166. /**
  62167. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  62168. * This is helpful to optimize layout operation when adding multiple children in a row
  62169. */
  62170. blockLayout: boolean;
  62171. /**
  62172. * Creates a new container
  62173. * @param name defines the container name
  62174. */
  62175. constructor(name?: string);
  62176. /**
  62177. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  62178. * @returns the current container
  62179. */
  62180. updateLayout(): Container3D;
  62181. /**
  62182. * Gets a boolean indicating if the given control is in the children of this control
  62183. * @param control defines the control to check
  62184. * @returns true if the control is in the child list
  62185. */
  62186. containsControl(control: Control3D): boolean;
  62187. /**
  62188. * Adds a control to the children of this control
  62189. * @param control defines the control to add
  62190. * @returns the current container
  62191. */
  62192. addControl(control: Control3D): Container3D;
  62193. /**
  62194. * This function will be called everytime a new control is added
  62195. */
  62196. protected _arrangeChildren(): void;
  62197. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  62198. /**
  62199. * Removes a control from the children of this control
  62200. * @param control defines the control to remove
  62201. * @returns the current container
  62202. */
  62203. removeControl(control: Control3D): Container3D;
  62204. protected _getTypeName(): string;
  62205. /**
  62206. * Releases all associated resources
  62207. */
  62208. dispose(): void;
  62209. /** Control rotation will remain unchanged */
  62210. static readonly UNSET_ORIENTATION: number;
  62211. /** Control will rotate to make it look at sphere central axis */
  62212. static readonly FACEORIGIN_ORIENTATION: number;
  62213. /** Control will rotate to make it look back at sphere central axis */
  62214. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  62215. /** Control will rotate to look at z axis (0, 0, 1) */
  62216. static readonly FACEFORWARD_ORIENTATION: number;
  62217. /** Control will rotate to look at negative z axis (0, 0, -1) */
  62218. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  62219. }
  62220. }
  62221. declare module BABYLON.GUI {
  62222. /**
  62223. * Class used to manage 3D user interface
  62224. * @see http://doc.babylonjs.com/how_to/gui3d
  62225. */
  62226. export class GUI3DManager implements BABYLON.IDisposable {
  62227. private _scene;
  62228. private _sceneDisposeObserver;
  62229. private _utilityLayer;
  62230. private _rootContainer;
  62231. private _pointerObserver;
  62232. private _pointerOutObserver;
  62233. /** @hidden */
  62234. _lastPickedControl: Control3D;
  62235. /** @hidden */
  62236. _lastControlOver: {
  62237. [pointerId: number]: Control3D;
  62238. };
  62239. /** @hidden */
  62240. _lastControlDown: {
  62241. [pointerId: number]: Control3D;
  62242. };
  62243. /**
  62244. * BABYLON.Observable raised when the point picked by the pointer events changed
  62245. */
  62246. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  62247. /** @hidden */
  62248. _sharedMaterials: {
  62249. [key: string]: BABYLON.Material;
  62250. };
  62251. /** Gets the hosting scene */
  62252. readonly scene: BABYLON.Scene;
  62253. /** Gets associated utility layer */
  62254. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  62255. /**
  62256. * Creates a new GUI3DManager
  62257. * @param scene
  62258. */
  62259. constructor(scene?: BABYLON.Scene);
  62260. private _handlePointerOut;
  62261. private _doPicking;
  62262. /**
  62263. * Gets the root container
  62264. */
  62265. readonly rootContainer: Container3D;
  62266. /**
  62267. * Gets a boolean indicating if the given control is in the root child list
  62268. * @param control defines the control to check
  62269. * @returns true if the control is in the root child list
  62270. */
  62271. containsControl(control: Control3D): boolean;
  62272. /**
  62273. * Adds a control to the root child list
  62274. * @param control defines the control to add
  62275. * @returns the current manager
  62276. */
  62277. addControl(control: Control3D): GUI3DManager;
  62278. /**
  62279. * Removes a control from the root child list
  62280. * @param control defines the control to remove
  62281. * @returns the current container
  62282. */
  62283. removeControl(control: Control3D): GUI3DManager;
  62284. /**
  62285. * Releases all associated resources
  62286. */
  62287. dispose(): void;
  62288. }
  62289. }
  62290. declare module BABYLON.GUI {
  62291. /**
  62292. * Class used to transport BABYLON.Vector3 information for pointer events
  62293. */
  62294. export class Vector3WithInfo extends BABYLON.Vector3 {
  62295. /** defines the current mouse button index */
  62296. buttonIndex: number;
  62297. /**
  62298. * Creates a new Vector3WithInfo
  62299. * @param source defines the vector3 data to transport
  62300. * @param buttonIndex defines the current mouse button index
  62301. */
  62302. constructor(source: BABYLON.Vector3,
  62303. /** defines the current mouse button index */
  62304. buttonIndex?: number);
  62305. }
  62306. }
  62307. declare module BABYLON.GUI {
  62308. /**
  62309. * Class used as base class for controls
  62310. */
  62311. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  62312. /** Defines the control name */
  62313. name?: string | undefined;
  62314. /** @hidden */
  62315. _host: GUI3DManager;
  62316. private _node;
  62317. private _downCount;
  62318. private _enterCount;
  62319. private _downPointerIds;
  62320. private _isVisible;
  62321. /** Gets or sets the control position in world space */
  62322. position: BABYLON.Vector3;
  62323. /** Gets or sets the control scaling in world space */
  62324. scaling: BABYLON.Vector3;
  62325. /** Callback used to start pointer enter animation */
  62326. pointerEnterAnimation: () => void;
  62327. /** Callback used to start pointer out animation */
  62328. pointerOutAnimation: () => void;
  62329. /** Callback used to start pointer down animation */
  62330. pointerDownAnimation: () => void;
  62331. /** Callback used to start pointer up animation */
  62332. pointerUpAnimation: () => void;
  62333. /**
  62334. * An event triggered when the pointer move over the control
  62335. */
  62336. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  62337. /**
  62338. * An event triggered when the pointer move out of the control
  62339. */
  62340. onPointerOutObservable: BABYLON.Observable<Control3D>;
  62341. /**
  62342. * An event triggered when the pointer taps the control
  62343. */
  62344. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  62345. /**
  62346. * An event triggered when pointer is up
  62347. */
  62348. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  62349. /**
  62350. * An event triggered when a control is clicked on (with a mouse)
  62351. */
  62352. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  62353. /**
  62354. * An event triggered when pointer enters the control
  62355. */
  62356. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  62357. /**
  62358. * Gets or sets the parent container
  62359. */
  62360. parent: BABYLON.Nullable<Container3D>;
  62361. private _behaviors;
  62362. /**
  62363. * Gets the list of attached behaviors
  62364. * @see http://doc.babylonjs.com/features/behaviour
  62365. */
  62366. readonly behaviors: BABYLON.Behavior<Control3D>[];
  62367. /**
  62368. * Attach a behavior to the control
  62369. * @see http://doc.babylonjs.com/features/behaviour
  62370. * @param behavior defines the behavior to attach
  62371. * @returns the current control
  62372. */
  62373. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62374. /**
  62375. * Remove an attached behavior
  62376. * @see http://doc.babylonjs.com/features/behaviour
  62377. * @param behavior defines the behavior to attach
  62378. * @returns the current control
  62379. */
  62380. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62381. /**
  62382. * Gets an attached behavior by name
  62383. * @param name defines the name of the behavior to look for
  62384. * @see http://doc.babylonjs.com/features/behaviour
  62385. * @returns null if behavior was not found else the requested behavior
  62386. */
  62387. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  62388. /** Gets or sets a boolean indicating if the control is visible */
  62389. isVisible: boolean;
  62390. /**
  62391. * Creates a new control
  62392. * @param name defines the control name
  62393. */
  62394. constructor(
  62395. /** Defines the control name */
  62396. name?: string | undefined);
  62397. /**
  62398. * Gets a string representing the class name
  62399. */
  62400. readonly typeName: string;
  62401. /**
  62402. * Get the current class name of the control.
  62403. * @returns current class name
  62404. */
  62405. getClassName(): string;
  62406. protected _getTypeName(): string;
  62407. /**
  62408. * Gets the transform node used by this control
  62409. */
  62410. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  62411. /**
  62412. * Gets the mesh used to render this control
  62413. */
  62414. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62415. /**
  62416. * Link the control as child of the given node
  62417. * @param node defines the node to link to. Use null to unlink the control
  62418. * @returns the current control
  62419. */
  62420. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  62421. /** @hidden **/
  62422. _prepareNode(scene: BABYLON.Scene): void;
  62423. /**
  62424. * Node creation.
  62425. * Can be overriden by children
  62426. * @param scene defines the scene where the node must be attached
  62427. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  62428. */
  62429. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  62430. /**
  62431. * Affect a material to the given mesh
  62432. * @param mesh defines the mesh which will represent the control
  62433. */
  62434. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62435. /** @hidden */
  62436. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  62437. /** @hidden */
  62438. _onPointerEnter(target: Control3D): boolean;
  62439. /** @hidden */
  62440. _onPointerOut(target: Control3D): void;
  62441. /** @hidden */
  62442. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  62443. /** @hidden */
  62444. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62445. /** @hidden */
  62446. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  62447. /** @hidden */
  62448. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  62449. /** @hidden */
  62450. _disposeNode(): void;
  62451. /**
  62452. * Releases all associated resources
  62453. */
  62454. dispose(): void;
  62455. }
  62456. }
  62457. declare module BABYLON.GUI {
  62458. /**
  62459. * Class used as a root to all buttons
  62460. */
  62461. export class AbstractButton3D extends Control3D {
  62462. /**
  62463. * Creates a new button
  62464. * @param name defines the control name
  62465. */
  62466. constructor(name?: string);
  62467. protected _getTypeName(): string;
  62468. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62469. }
  62470. }
  62471. declare module BABYLON.GUI {
  62472. /**
  62473. * Class used to create a button in 3D
  62474. */
  62475. export class Button3D extends AbstractButton3D {
  62476. /** @hidden */
  62477. protected _currentMaterial: BABYLON.Material;
  62478. private _facadeTexture;
  62479. private _content;
  62480. private _contentResolution;
  62481. private _contentScaleRatio;
  62482. /**
  62483. * Gets or sets the texture resolution used to render content (512 by default)
  62484. */
  62485. contentResolution: BABYLON.int;
  62486. /**
  62487. * Gets or sets the texture scale ratio used to render content (2 by default)
  62488. */
  62489. contentScaleRatio: number;
  62490. protected _disposeFacadeTexture(): void;
  62491. protected _resetContent(): void;
  62492. /**
  62493. * Creates a new button
  62494. * @param name defines the control name
  62495. */
  62496. constructor(name?: string);
  62497. /**
  62498. * Gets or sets the GUI 2D content used to display the button's facade
  62499. */
  62500. content: Control;
  62501. /**
  62502. * Apply the facade texture (created from the content property).
  62503. * This function can be overloaded by child classes
  62504. * @param facadeTexture defines the AdvancedDynamicTexture to use
  62505. */
  62506. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  62507. protected _getTypeName(): string;
  62508. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62509. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62510. /**
  62511. * Releases all associated resources
  62512. */
  62513. dispose(): void;
  62514. }
  62515. }
  62516. declare module BABYLON.GUI {
  62517. /**
  62518. * Abstract class used to create a container panel deployed on the surface of a volume
  62519. */
  62520. export abstract class VolumeBasedPanel extends Container3D {
  62521. private _columns;
  62522. private _rows;
  62523. private _rowThenColum;
  62524. private _orientation;
  62525. protected _cellWidth: number;
  62526. protected _cellHeight: number;
  62527. /**
  62528. * Gets or sets the distance between elements
  62529. */
  62530. margin: number;
  62531. /**
  62532. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  62533. * | Value | Type | Description |
  62534. * | ----- | ----------------------------------- | ----------- |
  62535. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  62536. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  62537. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  62538. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  62539. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  62540. */
  62541. orientation: number;
  62542. /**
  62543. * Gets or sets the number of columns requested (10 by default).
  62544. * The panel will automatically compute the number of rows based on number of child controls.
  62545. */
  62546. columns: BABYLON.int;
  62547. /**
  62548. * Gets or sets a the number of rows requested.
  62549. * The panel will automatically compute the number of columns based on number of child controls.
  62550. */
  62551. rows: BABYLON.int;
  62552. /**
  62553. * Creates new VolumeBasedPanel
  62554. */
  62555. constructor();
  62556. protected _arrangeChildren(): void;
  62557. /** Child classes must implement this function to provide correct control positioning */
  62558. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62559. /** Child classes can implement this function to provide additional processing */
  62560. protected _finalProcessing(): void;
  62561. }
  62562. }
  62563. declare module BABYLON.GUI {
  62564. /**
  62565. * Class used to create a container panel deployed on the surface of a cylinder
  62566. */
  62567. export class CylinderPanel extends VolumeBasedPanel {
  62568. private _radius;
  62569. /**
  62570. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  62571. */
  62572. radius: BABYLON.float;
  62573. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62574. private _cylindricalMapping;
  62575. }
  62576. }
  62577. declare module BABYLON.GUI {
  62578. /** @hidden */
  62579. export var fluentVertexShader: {
  62580. name: string;
  62581. shader: string;
  62582. };
  62583. }
  62584. declare module BABYLON.GUI {
  62585. /** @hidden */
  62586. export var fluentPixelShader: {
  62587. name: string;
  62588. shader: string;
  62589. };
  62590. }
  62591. declare module BABYLON.GUI {
  62592. /** @hidden */
  62593. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  62594. INNERGLOW: boolean;
  62595. BORDER: boolean;
  62596. HOVERLIGHT: boolean;
  62597. TEXTURE: boolean;
  62598. constructor();
  62599. }
  62600. /**
  62601. * Class used to render controls with fluent desgin
  62602. */
  62603. export class FluentMaterial extends BABYLON.PushMaterial {
  62604. /**
  62605. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  62606. */
  62607. innerGlowColorIntensity: number;
  62608. /**
  62609. * Gets or sets the inner glow color (white by default)
  62610. */
  62611. innerGlowColor: BABYLON.Color3;
  62612. /**
  62613. * Gets or sets alpha value (default is 1.0)
  62614. */
  62615. alpha: number;
  62616. /**
  62617. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  62618. */
  62619. albedoColor: BABYLON.Color3;
  62620. /**
  62621. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  62622. */
  62623. renderBorders: boolean;
  62624. /**
  62625. * Gets or sets border width (default is 0.5)
  62626. */
  62627. borderWidth: number;
  62628. /**
  62629. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  62630. */
  62631. edgeSmoothingValue: number;
  62632. /**
  62633. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  62634. */
  62635. borderMinValue: number;
  62636. /**
  62637. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  62638. */
  62639. renderHoverLight: boolean;
  62640. /**
  62641. * Gets or sets the radius used to render the hover light (default is 1.0)
  62642. */
  62643. hoverRadius: number;
  62644. /**
  62645. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  62646. */
  62647. hoverColor: BABYLON.Color4;
  62648. /**
  62649. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  62650. */
  62651. hoverPosition: BABYLON.Vector3;
  62652. private _albedoTexture;
  62653. /** Gets or sets the texture to use for albedo color */
  62654. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  62655. /**
  62656. * Creates a new Fluent material
  62657. * @param name defines the name of the material
  62658. * @param scene defines the hosting scene
  62659. */
  62660. constructor(name: string, scene: BABYLON.Scene);
  62661. needAlphaBlending(): boolean;
  62662. needAlphaTesting(): boolean;
  62663. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  62664. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  62665. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  62666. getActiveTextures(): BABYLON.BaseTexture[];
  62667. hasTexture(texture: BABYLON.BaseTexture): boolean;
  62668. dispose(forceDisposeEffect?: boolean): void;
  62669. clone(name: string): FluentMaterial;
  62670. serialize(): any;
  62671. getClassName(): string;
  62672. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  62673. }
  62674. }
  62675. declare module BABYLON.GUI {
  62676. /**
  62677. * Class used to create a holographic button in 3D
  62678. */
  62679. export class HolographicButton extends Button3D {
  62680. private _backPlate;
  62681. private _textPlate;
  62682. private _frontPlate;
  62683. private _text;
  62684. private _imageUrl;
  62685. private _shareMaterials;
  62686. private _frontMaterial;
  62687. private _backMaterial;
  62688. private _plateMaterial;
  62689. private _pickedPointObserver;
  62690. private _tooltipFade;
  62691. private _tooltipTextBlock;
  62692. private _tooltipTexture;
  62693. private _tooltipMesh;
  62694. private _tooltipHoverObserver;
  62695. private _tooltipOutObserver;
  62696. private _disposeTooltip;
  62697. /**
  62698. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  62699. */
  62700. tooltipText: BABYLON.Nullable<string>;
  62701. /**
  62702. * Gets or sets text for the button
  62703. */
  62704. text: string;
  62705. /**
  62706. * Gets or sets the image url for the button
  62707. */
  62708. imageUrl: string;
  62709. /**
  62710. * Gets the back material used by this button
  62711. */
  62712. readonly backMaterial: FluentMaterial;
  62713. /**
  62714. * Gets the front material used by this button
  62715. */
  62716. readonly frontMaterial: FluentMaterial;
  62717. /**
  62718. * Gets the plate material used by this button
  62719. */
  62720. readonly plateMaterial: BABYLON.StandardMaterial;
  62721. /**
  62722. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  62723. */
  62724. readonly shareMaterials: boolean;
  62725. /**
  62726. * Creates a new button
  62727. * @param name defines the control name
  62728. */
  62729. constructor(name?: string, shareMaterials?: boolean);
  62730. protected _getTypeName(): string;
  62731. private _rebuildContent;
  62732. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62733. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  62734. private _createBackMaterial;
  62735. private _createFrontMaterial;
  62736. private _createPlateMaterial;
  62737. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  62738. /**
  62739. * Releases all associated resources
  62740. */
  62741. dispose(): void;
  62742. }
  62743. }
  62744. declare module BABYLON.GUI {
  62745. /**
  62746. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  62747. */
  62748. export class MeshButton3D extends Button3D {
  62749. /** @hidden */
  62750. protected _currentMesh: BABYLON.Mesh;
  62751. /**
  62752. * Creates a new 3D button based on a mesh
  62753. * @param mesh mesh to become a 3D button
  62754. * @param name defines the control name
  62755. */
  62756. constructor(mesh: BABYLON.Mesh, name?: string);
  62757. protected _getTypeName(): string;
  62758. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62759. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62760. }
  62761. }
  62762. declare module BABYLON.GUI {
  62763. /**
  62764. * Class used to create a container panel deployed on the surface of a plane
  62765. */
  62766. export class PlanePanel extends VolumeBasedPanel {
  62767. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62768. }
  62769. }
  62770. declare module BABYLON.GUI {
  62771. /**
  62772. * Class used to create a container panel where items get randomized planar mapping
  62773. */
  62774. export class ScatterPanel extends VolumeBasedPanel {
  62775. private _iteration;
  62776. /**
  62777. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  62778. */
  62779. iteration: BABYLON.float;
  62780. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62781. private _scatterMapping;
  62782. protected _finalProcessing(): void;
  62783. }
  62784. }
  62785. declare module BABYLON.GUI {
  62786. /**
  62787. * Class used to create a container panel deployed on the surface of a sphere
  62788. */
  62789. export class SpherePanel extends VolumeBasedPanel {
  62790. private _radius;
  62791. /**
  62792. * Gets or sets the radius of the sphere where to project controls (5 by default)
  62793. */
  62794. radius: BABYLON.float;
  62795. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62796. private _sphericalMapping;
  62797. }
  62798. }
  62799. declare module BABYLON.GUI {
  62800. /**
  62801. * Class used to create a stack panel in 3D on XY plane
  62802. */
  62803. export class StackPanel3D extends Container3D {
  62804. private _isVertical;
  62805. /**
  62806. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  62807. */
  62808. isVertical: boolean;
  62809. /**
  62810. * Gets or sets the distance between elements
  62811. */
  62812. margin: number;
  62813. /**
  62814. * Creates new StackPanel
  62815. * @param isVertical
  62816. */
  62817. constructor(isVertical?: boolean);
  62818. protected _arrangeChildren(): void;
  62819. }
  62820. }
  62821. declare module BABYLON {
  62822. /**
  62823. * Mode that determines the coordinate system to use.
  62824. */
  62825. export enum GLTFLoaderCoordinateSystemMode {
  62826. /**
  62827. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  62828. */
  62829. AUTO = 0,
  62830. /**
  62831. * Sets the useRightHandedSystem flag on the scene.
  62832. */
  62833. FORCE_RIGHT_HANDED = 1
  62834. }
  62835. /**
  62836. * Mode that determines what animations will start.
  62837. */
  62838. export enum GLTFLoaderAnimationStartMode {
  62839. /**
  62840. * No animation will start.
  62841. */
  62842. NONE = 0,
  62843. /**
  62844. * The first animation will start.
  62845. */
  62846. FIRST = 1,
  62847. /**
  62848. * All animations will start.
  62849. */
  62850. ALL = 2
  62851. }
  62852. /**
  62853. * Interface that contains the data for the glTF asset.
  62854. */
  62855. export interface IGLTFLoaderData {
  62856. /**
  62857. * Object that represents the glTF JSON.
  62858. */
  62859. json: Object;
  62860. /**
  62861. * The BIN chunk of a binary glTF.
  62862. */
  62863. bin: Nullable<ArrayBufferView>;
  62864. }
  62865. /**
  62866. * Interface for extending the loader.
  62867. */
  62868. export interface IGLTFLoaderExtension {
  62869. /**
  62870. * The name of this extension.
  62871. */
  62872. readonly name: string;
  62873. /**
  62874. * Defines whether this extension is enabled.
  62875. */
  62876. enabled: boolean;
  62877. }
  62878. /**
  62879. * Loader state.
  62880. */
  62881. export enum GLTFLoaderState {
  62882. /**
  62883. * The asset is loading.
  62884. */
  62885. LOADING = 0,
  62886. /**
  62887. * The asset is ready for rendering.
  62888. */
  62889. READY = 1,
  62890. /**
  62891. * The asset is completely loaded.
  62892. */
  62893. COMPLETE = 2
  62894. }
  62895. /** @hidden */
  62896. export interface IGLTFLoader extends IDisposable {
  62897. readonly state: Nullable<GLTFLoaderState>;
  62898. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  62899. meshes: AbstractMesh[];
  62900. particleSystems: IParticleSystem[];
  62901. skeletons: Skeleton[];
  62902. animationGroups: AnimationGroup[];
  62903. }>;
  62904. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  62905. }
  62906. /**
  62907. * File loader for loading glTF files into a scene.
  62908. */
  62909. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  62910. /** @hidden */
  62911. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  62912. /** @hidden */
  62913. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  62914. /**
  62915. * Raised when the asset has been parsed
  62916. */
  62917. onParsedObservable: Observable<IGLTFLoaderData>;
  62918. private _onParsedObserver;
  62919. /**
  62920. * Raised when the asset has been parsed
  62921. */
  62922. onParsed: (loaderData: IGLTFLoaderData) => void;
  62923. /**
  62924. * 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.
  62925. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  62926. * Defaults to true.
  62927. * @hidden
  62928. */
  62929. static IncrementalLoading: boolean;
  62930. /**
  62931. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  62932. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  62933. * @hidden
  62934. */
  62935. static HomogeneousCoordinates: boolean;
  62936. /**
  62937. * The coordinate system mode. Defaults to AUTO.
  62938. */
  62939. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  62940. /**
  62941. * The animation start mode. Defaults to FIRST.
  62942. */
  62943. animationStartMode: GLTFLoaderAnimationStartMode;
  62944. /**
  62945. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  62946. */
  62947. compileMaterials: boolean;
  62948. /**
  62949. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  62950. */
  62951. useClipPlane: boolean;
  62952. /**
  62953. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  62954. */
  62955. compileShadowGenerators: boolean;
  62956. /**
  62957. * Defines if the Alpha blended materials are only applied as coverage.
  62958. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  62959. * If true, no extra effects are applied to transparent pixels.
  62960. */
  62961. transparencyAsCoverage: boolean;
  62962. /**
  62963. * Function called before loading a url referenced by the asset.
  62964. */
  62965. preprocessUrlAsync: (url: string) => Promise<string>;
  62966. /**
  62967. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  62968. */
  62969. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  62970. private _onMeshLoadedObserver;
  62971. /**
  62972. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  62973. */
  62974. onMeshLoaded: (mesh: AbstractMesh) => void;
  62975. /**
  62976. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  62977. */
  62978. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  62979. private _onTextureLoadedObserver;
  62980. /**
  62981. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  62982. */
  62983. onTextureLoaded: (texture: BaseTexture) => void;
  62984. /**
  62985. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  62986. */
  62987. readonly onMaterialLoadedObservable: Observable<Material>;
  62988. private _onMaterialLoadedObserver;
  62989. /**
  62990. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  62991. */
  62992. onMaterialLoaded: (material: Material) => void;
  62993. /**
  62994. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  62995. */
  62996. readonly onCameraLoadedObservable: Observable<Camera>;
  62997. private _onCameraLoadedObserver;
  62998. /**
  62999. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  63000. */
  63001. onCameraLoaded: (camera: Camera) => void;
  63002. /**
  63003. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  63004. * For assets with LODs, raised when all of the LODs are complete.
  63005. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63006. */
  63007. readonly onCompleteObservable: Observable<void>;
  63008. private _onCompleteObserver;
  63009. /**
  63010. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  63011. * For assets with LODs, raised when all of the LODs are complete.
  63012. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63013. */
  63014. onComplete: () => void;
  63015. /**
  63016. * Observable raised when an error occurs.
  63017. */
  63018. readonly onErrorObservable: Observable<any>;
  63019. private _onErrorObserver;
  63020. /**
  63021. * Callback raised when an error occurs.
  63022. */
  63023. onError: (reason: any) => void;
  63024. /**
  63025. * Observable raised after the loader is disposed.
  63026. */
  63027. readonly onDisposeObservable: Observable<void>;
  63028. private _onDisposeObserver;
  63029. /**
  63030. * Callback raised after the loader is disposed.
  63031. */
  63032. onDispose: () => void;
  63033. /**
  63034. * Observable raised after a loader extension is created.
  63035. * Set additional options for a loader extension in this event.
  63036. */
  63037. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  63038. private _onExtensionLoadedObserver;
  63039. /**
  63040. * Callback raised after a loader extension is created.
  63041. */
  63042. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  63043. /**
  63044. * Defines if the loader logging is enabled.
  63045. */
  63046. loggingEnabled: boolean;
  63047. /**
  63048. * Defines if the loader should capture performance counters.
  63049. */
  63050. capturePerformanceCounters: boolean;
  63051. /**
  63052. * Defines if the loader should validate the asset.
  63053. */
  63054. validate: boolean;
  63055. /**
  63056. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  63057. */
  63058. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  63059. private _onValidatedObserver;
  63060. /**
  63061. * Callback raised after a loader extension is created.
  63062. */
  63063. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  63064. private _loader;
  63065. /**
  63066. * Name of the loader ("gltf")
  63067. */
  63068. name: string;
  63069. /**
  63070. * Supported file extensions of the loader (.gltf, .glb)
  63071. */
  63072. extensions: ISceneLoaderPluginExtensions;
  63073. /**
  63074. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  63075. */
  63076. dispose(): void;
  63077. /** @hidden */
  63078. _clear(): void;
  63079. /**
  63080. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  63081. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  63082. * @param scene the scene the meshes should be added to
  63083. * @param data the glTF data to load
  63084. * @param rootUrl root url to load from
  63085. * @param onProgress event that fires when loading progress has occured
  63086. * @param fileName Defines the name of the file to load
  63087. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  63088. */
  63089. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  63090. meshes: AbstractMesh[];
  63091. particleSystems: IParticleSystem[];
  63092. skeletons: Skeleton[];
  63093. animationGroups: AnimationGroup[];
  63094. }>;
  63095. /**
  63096. * Imports all objects from the loaded glTF data and adds them to the scene
  63097. * @param scene the scene the objects should be added to
  63098. * @param data the glTF data to load
  63099. * @param rootUrl root url to load from
  63100. * @param onProgress event that fires when loading progress has occured
  63101. * @param fileName Defines the name of the file to load
  63102. * @returns a promise which completes when objects have been loaded to the scene
  63103. */
  63104. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  63105. /**
  63106. * Load into an asset container.
  63107. * @param scene The scene to load into
  63108. * @param data The data to import
  63109. * @param rootUrl The root url for scene and resources
  63110. * @param onProgress The callback when the load progresses
  63111. * @param fileName Defines the name of the file to load
  63112. * @returns The loaded asset container
  63113. */
  63114. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  63115. /**
  63116. * If the data string can be loaded directly.
  63117. * @param data string contianing the file data
  63118. * @returns if the data can be loaded directly
  63119. */
  63120. canDirectLoad(data: string): boolean;
  63121. /**
  63122. * Rewrites a url by combining a root url and response url.
  63123. */
  63124. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  63125. /**
  63126. * Instantiates a glTF file loader plugin.
  63127. * @returns the created plugin
  63128. */
  63129. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  63130. /**
  63131. * The loader state or null if the loader is not active.
  63132. */
  63133. readonly loaderState: Nullable<GLTFLoaderState>;
  63134. /**
  63135. * Returns a promise that resolves when the asset is completely loaded.
  63136. * @returns a promise that resolves when the asset is completely loaded.
  63137. */
  63138. whenCompleteAsync(): Promise<void>;
  63139. private _parseAsync;
  63140. private _validateAsync;
  63141. private _getLoader;
  63142. private _unpackBinary;
  63143. private _unpackBinaryV1;
  63144. private _unpackBinaryV2;
  63145. private static _parseVersion;
  63146. private static _compareVersion;
  63147. private static _decodeBufferToText;
  63148. private static readonly _logSpaces;
  63149. private _logIndentLevel;
  63150. private _loggingEnabled;
  63151. /** @hidden */
  63152. _log: (message: string) => void;
  63153. /** @hidden */
  63154. _logOpen(message: string): void;
  63155. /** @hidden */
  63156. _logClose(): void;
  63157. private _logEnabled;
  63158. private _logDisabled;
  63159. private _capturePerformanceCounters;
  63160. /** @hidden */
  63161. _startPerformanceCounter: (counterName: string) => void;
  63162. /** @hidden */
  63163. _endPerformanceCounter: (counterName: string) => void;
  63164. private _startPerformanceCounterEnabled;
  63165. private _startPerformanceCounterDisabled;
  63166. private _endPerformanceCounterEnabled;
  63167. private _endPerformanceCounterDisabled;
  63168. }
  63169. }
  63170. declare module BABYLON.GLTF1 {
  63171. /**
  63172. * Enums
  63173. * @hidden
  63174. */
  63175. export enum EComponentType {
  63176. BYTE = 5120,
  63177. UNSIGNED_BYTE = 5121,
  63178. SHORT = 5122,
  63179. UNSIGNED_SHORT = 5123,
  63180. FLOAT = 5126
  63181. }
  63182. /** @hidden */
  63183. export enum EShaderType {
  63184. FRAGMENT = 35632,
  63185. VERTEX = 35633
  63186. }
  63187. /** @hidden */
  63188. export enum EParameterType {
  63189. BYTE = 5120,
  63190. UNSIGNED_BYTE = 5121,
  63191. SHORT = 5122,
  63192. UNSIGNED_SHORT = 5123,
  63193. INT = 5124,
  63194. UNSIGNED_INT = 5125,
  63195. FLOAT = 5126,
  63196. FLOAT_VEC2 = 35664,
  63197. FLOAT_VEC3 = 35665,
  63198. FLOAT_VEC4 = 35666,
  63199. INT_VEC2 = 35667,
  63200. INT_VEC3 = 35668,
  63201. INT_VEC4 = 35669,
  63202. BOOL = 35670,
  63203. BOOL_VEC2 = 35671,
  63204. BOOL_VEC3 = 35672,
  63205. BOOL_VEC4 = 35673,
  63206. FLOAT_MAT2 = 35674,
  63207. FLOAT_MAT3 = 35675,
  63208. FLOAT_MAT4 = 35676,
  63209. SAMPLER_2D = 35678
  63210. }
  63211. /** @hidden */
  63212. export enum ETextureWrapMode {
  63213. CLAMP_TO_EDGE = 33071,
  63214. MIRRORED_REPEAT = 33648,
  63215. REPEAT = 10497
  63216. }
  63217. /** @hidden */
  63218. export enum ETextureFilterType {
  63219. NEAREST = 9728,
  63220. LINEAR = 9728,
  63221. NEAREST_MIPMAP_NEAREST = 9984,
  63222. LINEAR_MIPMAP_NEAREST = 9985,
  63223. NEAREST_MIPMAP_LINEAR = 9986,
  63224. LINEAR_MIPMAP_LINEAR = 9987
  63225. }
  63226. /** @hidden */
  63227. export enum ETextureFormat {
  63228. ALPHA = 6406,
  63229. RGB = 6407,
  63230. RGBA = 6408,
  63231. LUMINANCE = 6409,
  63232. LUMINANCE_ALPHA = 6410
  63233. }
  63234. /** @hidden */
  63235. export enum ECullingType {
  63236. FRONT = 1028,
  63237. BACK = 1029,
  63238. FRONT_AND_BACK = 1032
  63239. }
  63240. /** @hidden */
  63241. export enum EBlendingFunction {
  63242. ZERO = 0,
  63243. ONE = 1,
  63244. SRC_COLOR = 768,
  63245. ONE_MINUS_SRC_COLOR = 769,
  63246. DST_COLOR = 774,
  63247. ONE_MINUS_DST_COLOR = 775,
  63248. SRC_ALPHA = 770,
  63249. ONE_MINUS_SRC_ALPHA = 771,
  63250. DST_ALPHA = 772,
  63251. ONE_MINUS_DST_ALPHA = 773,
  63252. CONSTANT_COLOR = 32769,
  63253. ONE_MINUS_CONSTANT_COLOR = 32770,
  63254. CONSTANT_ALPHA = 32771,
  63255. ONE_MINUS_CONSTANT_ALPHA = 32772,
  63256. SRC_ALPHA_SATURATE = 776
  63257. }
  63258. /** @hidden */
  63259. export interface IGLTFProperty {
  63260. extensions?: {
  63261. [key: string]: any;
  63262. };
  63263. extras?: Object;
  63264. }
  63265. /** @hidden */
  63266. export interface IGLTFChildRootProperty extends IGLTFProperty {
  63267. name?: string;
  63268. }
  63269. /** @hidden */
  63270. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  63271. bufferView: string;
  63272. byteOffset: number;
  63273. byteStride: number;
  63274. count: number;
  63275. type: string;
  63276. componentType: EComponentType;
  63277. max?: number[];
  63278. min?: number[];
  63279. name?: string;
  63280. }
  63281. /** @hidden */
  63282. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  63283. buffer: string;
  63284. byteOffset: number;
  63285. byteLength: number;
  63286. byteStride: number;
  63287. target?: number;
  63288. }
  63289. /** @hidden */
  63290. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  63291. uri: string;
  63292. byteLength?: number;
  63293. type?: string;
  63294. }
  63295. /** @hidden */
  63296. export interface IGLTFShader extends IGLTFChildRootProperty {
  63297. uri: string;
  63298. type: EShaderType;
  63299. }
  63300. /** @hidden */
  63301. export interface IGLTFProgram extends IGLTFChildRootProperty {
  63302. attributes: string[];
  63303. fragmentShader: string;
  63304. vertexShader: string;
  63305. }
  63306. /** @hidden */
  63307. export interface IGLTFTechniqueParameter {
  63308. type: number;
  63309. count?: number;
  63310. semantic?: string;
  63311. node?: string;
  63312. value?: number | boolean | string | Array<any>;
  63313. source?: string;
  63314. babylonValue?: any;
  63315. }
  63316. /** @hidden */
  63317. export interface IGLTFTechniqueCommonProfile {
  63318. lightingModel: string;
  63319. texcoordBindings: Object;
  63320. parameters?: Array<any>;
  63321. }
  63322. /** @hidden */
  63323. export interface IGLTFTechniqueStatesFunctions {
  63324. blendColor?: number[];
  63325. blendEquationSeparate?: number[];
  63326. blendFuncSeparate?: number[];
  63327. colorMask: boolean[];
  63328. cullFace: number[];
  63329. }
  63330. /** @hidden */
  63331. export interface IGLTFTechniqueStates {
  63332. enable: number[];
  63333. functions: IGLTFTechniqueStatesFunctions;
  63334. }
  63335. /** @hidden */
  63336. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  63337. parameters: {
  63338. [key: string]: IGLTFTechniqueParameter;
  63339. };
  63340. program: string;
  63341. attributes: {
  63342. [key: string]: string;
  63343. };
  63344. uniforms: {
  63345. [key: string]: string;
  63346. };
  63347. states: IGLTFTechniqueStates;
  63348. }
  63349. /** @hidden */
  63350. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  63351. technique?: string;
  63352. values: string[];
  63353. }
  63354. /** @hidden */
  63355. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  63356. attributes: {
  63357. [key: string]: string;
  63358. };
  63359. indices: string;
  63360. material: string;
  63361. mode?: number;
  63362. }
  63363. /** @hidden */
  63364. export interface IGLTFMesh extends IGLTFChildRootProperty {
  63365. primitives: IGLTFMeshPrimitive[];
  63366. }
  63367. /** @hidden */
  63368. export interface IGLTFImage extends IGLTFChildRootProperty {
  63369. uri: string;
  63370. }
  63371. /** @hidden */
  63372. export interface IGLTFSampler extends IGLTFChildRootProperty {
  63373. magFilter?: number;
  63374. minFilter?: number;
  63375. wrapS?: number;
  63376. wrapT?: number;
  63377. }
  63378. /** @hidden */
  63379. export interface IGLTFTexture extends IGLTFChildRootProperty {
  63380. sampler: string;
  63381. source: string;
  63382. format?: ETextureFormat;
  63383. internalFormat?: ETextureFormat;
  63384. target?: number;
  63385. type?: number;
  63386. babylonTexture?: Texture;
  63387. }
  63388. /** @hidden */
  63389. export interface IGLTFAmbienLight {
  63390. color?: number[];
  63391. }
  63392. /** @hidden */
  63393. export interface IGLTFDirectionalLight {
  63394. color?: number[];
  63395. }
  63396. /** @hidden */
  63397. export interface IGLTFPointLight {
  63398. color?: number[];
  63399. constantAttenuation?: number;
  63400. linearAttenuation?: number;
  63401. quadraticAttenuation?: number;
  63402. }
  63403. /** @hidden */
  63404. export interface IGLTFSpotLight {
  63405. color?: number[];
  63406. constantAttenuation?: number;
  63407. fallOfAngle?: number;
  63408. fallOffExponent?: number;
  63409. linearAttenuation?: number;
  63410. quadraticAttenuation?: number;
  63411. }
  63412. /** @hidden */
  63413. export interface IGLTFLight extends IGLTFChildRootProperty {
  63414. type: string;
  63415. }
  63416. /** @hidden */
  63417. export interface IGLTFCameraOrthographic {
  63418. xmag: number;
  63419. ymag: number;
  63420. zfar: number;
  63421. znear: number;
  63422. }
  63423. /** @hidden */
  63424. export interface IGLTFCameraPerspective {
  63425. aspectRatio: number;
  63426. yfov: number;
  63427. zfar: number;
  63428. znear: number;
  63429. }
  63430. /** @hidden */
  63431. export interface IGLTFCamera extends IGLTFChildRootProperty {
  63432. type: string;
  63433. }
  63434. /** @hidden */
  63435. export interface IGLTFAnimationChannelTarget {
  63436. id: string;
  63437. path: string;
  63438. }
  63439. /** @hidden */
  63440. export interface IGLTFAnimationChannel {
  63441. sampler: string;
  63442. target: IGLTFAnimationChannelTarget;
  63443. }
  63444. /** @hidden */
  63445. export interface IGLTFAnimationSampler {
  63446. input: string;
  63447. output: string;
  63448. interpolation?: string;
  63449. }
  63450. /** @hidden */
  63451. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  63452. channels?: IGLTFAnimationChannel[];
  63453. parameters?: {
  63454. [key: string]: string;
  63455. };
  63456. samplers?: {
  63457. [key: string]: IGLTFAnimationSampler;
  63458. };
  63459. }
  63460. /** @hidden */
  63461. export interface IGLTFNodeInstanceSkin {
  63462. skeletons: string[];
  63463. skin: string;
  63464. meshes: string[];
  63465. }
  63466. /** @hidden */
  63467. export interface IGLTFSkins extends IGLTFChildRootProperty {
  63468. bindShapeMatrix: number[];
  63469. inverseBindMatrices: string;
  63470. jointNames: string[];
  63471. babylonSkeleton?: Skeleton;
  63472. }
  63473. /** @hidden */
  63474. export interface IGLTFNode extends IGLTFChildRootProperty {
  63475. camera?: string;
  63476. children: string[];
  63477. skin?: string;
  63478. jointName?: string;
  63479. light?: string;
  63480. matrix: number[];
  63481. mesh?: string;
  63482. meshes?: string[];
  63483. rotation?: number[];
  63484. scale?: number[];
  63485. translation?: number[];
  63486. babylonNode?: Node;
  63487. }
  63488. /** @hidden */
  63489. export interface IGLTFScene extends IGLTFChildRootProperty {
  63490. nodes: string[];
  63491. }
  63492. /** @hidden */
  63493. export interface IGLTFRuntime {
  63494. extensions: {
  63495. [key: string]: any;
  63496. };
  63497. accessors: {
  63498. [key: string]: IGLTFAccessor;
  63499. };
  63500. buffers: {
  63501. [key: string]: IGLTFBuffer;
  63502. };
  63503. bufferViews: {
  63504. [key: string]: IGLTFBufferView;
  63505. };
  63506. meshes: {
  63507. [key: string]: IGLTFMesh;
  63508. };
  63509. lights: {
  63510. [key: string]: IGLTFLight;
  63511. };
  63512. cameras: {
  63513. [key: string]: IGLTFCamera;
  63514. };
  63515. nodes: {
  63516. [key: string]: IGLTFNode;
  63517. };
  63518. images: {
  63519. [key: string]: IGLTFImage;
  63520. };
  63521. textures: {
  63522. [key: string]: IGLTFTexture;
  63523. };
  63524. shaders: {
  63525. [key: string]: IGLTFShader;
  63526. };
  63527. programs: {
  63528. [key: string]: IGLTFProgram;
  63529. };
  63530. samplers: {
  63531. [key: string]: IGLTFSampler;
  63532. };
  63533. techniques: {
  63534. [key: string]: IGLTFTechnique;
  63535. };
  63536. materials: {
  63537. [key: string]: IGLTFMaterial;
  63538. };
  63539. animations: {
  63540. [key: string]: IGLTFAnimation;
  63541. };
  63542. skins: {
  63543. [key: string]: IGLTFSkins;
  63544. };
  63545. currentScene?: Object;
  63546. scenes: {
  63547. [key: string]: IGLTFScene;
  63548. };
  63549. extensionsUsed: string[];
  63550. extensionsRequired?: string[];
  63551. buffersCount: number;
  63552. shaderscount: number;
  63553. scene: Scene;
  63554. rootUrl: string;
  63555. loadedBufferCount: number;
  63556. loadedBufferViews: {
  63557. [name: string]: ArrayBufferView;
  63558. };
  63559. loadedShaderCount: number;
  63560. importOnlyMeshes: boolean;
  63561. importMeshesNames?: string[];
  63562. dummyNodes: Node[];
  63563. }
  63564. /** @hidden */
  63565. export interface INodeToRoot {
  63566. bone: Bone;
  63567. node: IGLTFNode;
  63568. id: string;
  63569. }
  63570. /** @hidden */
  63571. export interface IJointNode {
  63572. node: IGLTFNode;
  63573. id: string;
  63574. }
  63575. }
  63576. declare module BABYLON.GLTF1 {
  63577. /**
  63578. * Utils functions for GLTF
  63579. * @hidden
  63580. */
  63581. export class GLTFUtils {
  63582. /**
  63583. * Sets the given "parameter" matrix
  63584. * @param scene: the Scene object
  63585. * @param source: the source node where to pick the matrix
  63586. * @param parameter: the GLTF technique parameter
  63587. * @param uniformName: the name of the shader's uniform
  63588. * @param shaderMaterial: the shader material
  63589. */
  63590. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  63591. /**
  63592. * Sets the given "parameter" matrix
  63593. * @param shaderMaterial: the shader material
  63594. * @param uniform: the name of the shader's uniform
  63595. * @param value: the value of the uniform
  63596. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  63597. */
  63598. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  63599. /**
  63600. * Returns the wrap mode of the texture
  63601. * @param mode: the mode value
  63602. */
  63603. static GetWrapMode(mode: number): number;
  63604. /**
  63605. * Returns the byte stride giving an accessor
  63606. * @param accessor: the GLTF accessor objet
  63607. */
  63608. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  63609. /**
  63610. * Returns the texture filter mode giving a mode value
  63611. * @param mode: the filter mode value
  63612. */
  63613. static GetTextureFilterMode(mode: number): ETextureFilterType;
  63614. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  63615. /**
  63616. * Returns a buffer from its accessor
  63617. * @param gltfRuntime: the GLTF runtime
  63618. * @param accessor: the GLTF accessor
  63619. */
  63620. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  63621. /**
  63622. * Decodes a buffer view into a string
  63623. * @param view: the buffer view
  63624. */
  63625. static DecodeBufferToText(view: ArrayBufferView): string;
  63626. /**
  63627. * Returns the default material of gltf. Related to
  63628. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  63629. * @param scene: the Babylon.js scene
  63630. */
  63631. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  63632. private static _DefaultMaterial;
  63633. }
  63634. }
  63635. declare module BABYLON.GLTF1 {
  63636. /**
  63637. * Implementation of the base glTF spec
  63638. * @hidden
  63639. */
  63640. export class GLTFLoaderBase {
  63641. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  63642. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  63643. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  63644. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  63645. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  63646. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  63647. }
  63648. /**
  63649. * glTF V1 Loader
  63650. * @hidden
  63651. */
  63652. export class GLTFLoader implements IGLTFLoader {
  63653. static Extensions: {
  63654. [name: string]: GLTFLoaderExtension;
  63655. };
  63656. static RegisterExtension(extension: GLTFLoaderExtension): void;
  63657. state: Nullable<GLTFLoaderState>;
  63658. dispose(): void;
  63659. private _importMeshAsync;
  63660. /**
  63661. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  63662. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  63663. * @param scene the scene the meshes should be added to
  63664. * @param data gltf data containing information of the meshes in a loaded file
  63665. * @param rootUrl root url to load from
  63666. * @param onProgress event that fires when loading progress has occured
  63667. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  63668. */
  63669. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  63670. meshes: AbstractMesh[];
  63671. particleSystems: IParticleSystem[];
  63672. skeletons: Skeleton[];
  63673. animationGroups: AnimationGroup[];
  63674. }>;
  63675. private _loadAsync;
  63676. /**
  63677. * Imports all objects from a loaded gltf file and adds them to the scene
  63678. * @param scene the scene the objects should be added to
  63679. * @param data gltf data containing information of the meshes in a loaded file
  63680. * @param rootUrl root url to load from
  63681. * @param onProgress event that fires when loading progress has occured
  63682. * @returns a promise which completes when objects have been loaded to the scene
  63683. */
  63684. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  63685. private _loadShadersAsync;
  63686. private _loadBuffersAsync;
  63687. private _createNodes;
  63688. }
  63689. /** @hidden */
  63690. export abstract class GLTFLoaderExtension {
  63691. private _name;
  63692. constructor(name: string);
  63693. readonly name: string;
  63694. /**
  63695. * Defines an override for loading the runtime
  63696. * Return true to stop further extensions from loading the runtime
  63697. */
  63698. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  63699. /**
  63700. * Defines an onverride for creating gltf runtime
  63701. * Return true to stop further extensions from creating the runtime
  63702. */
  63703. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  63704. /**
  63705. * Defines an override for loading buffers
  63706. * Return true to stop further extensions from loading this buffer
  63707. */
  63708. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  63709. /**
  63710. * Defines an override for loading texture buffers
  63711. * Return true to stop further extensions from loading this texture data
  63712. */
  63713. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63714. /**
  63715. * Defines an override for creating textures
  63716. * Return true to stop further extensions from loading this texture
  63717. */
  63718. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  63719. /**
  63720. * Defines an override for loading shader strings
  63721. * Return true to stop further extensions from loading this shader data
  63722. */
  63723. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  63724. /**
  63725. * Defines an override for loading materials
  63726. * Return true to stop further extensions from loading this material
  63727. */
  63728. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  63729. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  63730. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  63731. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  63732. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  63733. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  63734. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  63735. private static LoadTextureBufferAsync;
  63736. private static CreateTextureAsync;
  63737. private static ApplyExtensions;
  63738. }
  63739. }
  63740. declare module BABYLON.GLTF1 {
  63741. /** @hidden */
  63742. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  63743. private _bin;
  63744. constructor();
  63745. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  63746. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63747. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63748. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  63749. }
  63750. }
  63751. declare module BABYLON.GLTF1 {
  63752. /** @hidden */
  63753. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  63754. constructor();
  63755. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  63756. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  63757. private _loadTexture;
  63758. }
  63759. }
  63760. declare module BABYLON.GLTF2.Loader {
  63761. /**
  63762. * Loader interface with an index field.
  63763. */
  63764. export interface IArrayItem {
  63765. /**
  63766. * The index of this item in the array.
  63767. */
  63768. index: number;
  63769. }
  63770. /**
  63771. * Loader interface with additional members.
  63772. */
  63773. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  63774. /** @hidden */
  63775. _data?: Promise<ArrayBufferView>;
  63776. /** @hidden */
  63777. _babylonVertexBuffer?: Promise<VertexBuffer>;
  63778. }
  63779. /**
  63780. * Loader interface with additional members.
  63781. */
  63782. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  63783. }
  63784. /** @hidden */
  63785. export interface _IAnimationSamplerData {
  63786. input: Float32Array;
  63787. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  63788. output: Float32Array;
  63789. }
  63790. /**
  63791. * Loader interface with additional members.
  63792. */
  63793. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  63794. /** @hidden */
  63795. _data?: Promise<_IAnimationSamplerData>;
  63796. }
  63797. /**
  63798. * Loader interface with additional members.
  63799. */
  63800. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  63801. channels: IAnimationChannel[];
  63802. samplers: IAnimationSampler[];
  63803. /** @hidden */
  63804. _babylonAnimationGroup?: AnimationGroup;
  63805. }
  63806. /**
  63807. * Loader interface with additional members.
  63808. */
  63809. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  63810. /** @hidden */
  63811. _data?: Promise<ArrayBufferView>;
  63812. }
  63813. /**
  63814. * Loader interface with additional members.
  63815. */
  63816. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  63817. /** @hidden */
  63818. _data?: Promise<ArrayBufferView>;
  63819. /** @hidden */
  63820. _babylonBuffer?: Promise<Buffer>;
  63821. }
  63822. /**
  63823. * Loader interface with additional members.
  63824. */
  63825. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  63826. }
  63827. /**
  63828. * Loader interface with additional members.
  63829. */
  63830. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  63831. /** @hidden */
  63832. _data?: Promise<ArrayBufferView>;
  63833. }
  63834. /**
  63835. * Loader interface with additional members.
  63836. */
  63837. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  63838. }
  63839. /**
  63840. * Loader interface with additional members.
  63841. */
  63842. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  63843. }
  63844. /**
  63845. * Loader interface with additional members.
  63846. */
  63847. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  63848. baseColorTexture?: ITextureInfo;
  63849. metallicRoughnessTexture?: ITextureInfo;
  63850. }
  63851. /**
  63852. * Loader interface with additional members.
  63853. */
  63854. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  63855. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  63856. normalTexture?: IMaterialNormalTextureInfo;
  63857. occlusionTexture?: IMaterialOcclusionTextureInfo;
  63858. emissiveTexture?: ITextureInfo;
  63859. /** @hidden */
  63860. _data?: {
  63861. [babylonDrawMode: number]: {
  63862. babylonMaterial: Material;
  63863. babylonMeshes: AbstractMesh[];
  63864. promise: Promise<void>;
  63865. };
  63866. };
  63867. }
  63868. /**
  63869. * Loader interface with additional members.
  63870. */
  63871. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  63872. primitives: IMeshPrimitive[];
  63873. }
  63874. /**
  63875. * Loader interface with additional members.
  63876. */
  63877. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  63878. /** @hidden */
  63879. _instanceData?: {
  63880. babylonSourceMesh: Mesh;
  63881. promise: Promise<any>;
  63882. };
  63883. }
  63884. /**
  63885. * Loader interface with additional members.
  63886. */
  63887. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  63888. /**
  63889. * The parent glTF node.
  63890. */
  63891. parent?: INode;
  63892. /** @hidden */
  63893. _babylonTransformNode?: TransformNode;
  63894. /** @hidden */
  63895. _primitiveBabylonMeshes?: AbstractMesh[];
  63896. /** @hidden */
  63897. _babylonBones?: Bone[];
  63898. /** @hidden */
  63899. _numMorphTargets?: number;
  63900. }
  63901. /** @hidden */
  63902. export interface _ISamplerData {
  63903. noMipMaps: boolean;
  63904. samplingMode: number;
  63905. wrapU: number;
  63906. wrapV: number;
  63907. }
  63908. /**
  63909. * Loader interface with additional members.
  63910. */
  63911. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  63912. /** @hidden */
  63913. _data?: _ISamplerData;
  63914. }
  63915. /**
  63916. * Loader interface with additional members.
  63917. */
  63918. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  63919. }
  63920. /**
  63921. * Loader interface with additional members.
  63922. */
  63923. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  63924. /** @hidden */
  63925. _data?: {
  63926. babylonSkeleton: Skeleton;
  63927. promise: Promise<void>;
  63928. };
  63929. }
  63930. /**
  63931. * Loader interface with additional members.
  63932. */
  63933. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  63934. }
  63935. /**
  63936. * Loader interface with additional members.
  63937. */
  63938. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  63939. }
  63940. /**
  63941. * Loader interface with additional members.
  63942. */
  63943. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  63944. accessors?: IAccessor[];
  63945. animations?: IAnimation[];
  63946. buffers?: IBuffer[];
  63947. bufferViews?: IBufferView[];
  63948. cameras?: ICamera[];
  63949. images?: IImage[];
  63950. materials?: IMaterial[];
  63951. meshes?: IMesh[];
  63952. nodes?: INode[];
  63953. samplers?: ISampler[];
  63954. scenes?: IScene[];
  63955. skins?: ISkin[];
  63956. textures?: ITexture[];
  63957. }
  63958. }
  63959. declare module BABYLON.GLTF2 {
  63960. /**
  63961. * Interface for a glTF loader extension.
  63962. */
  63963. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  63964. /**
  63965. * Called after the loader state changes to LOADING.
  63966. */
  63967. onLoading?(): void;
  63968. /**
  63969. * Called after the loader state changes to READY.
  63970. */
  63971. onReady?(): void;
  63972. /**
  63973. * Define this method to modify the default behavior when loading scenes.
  63974. * @param context The context when loading the asset
  63975. * @param scene The glTF scene property
  63976. * @returns A promise that resolves when the load is complete or null if not handled
  63977. */
  63978. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  63979. /**
  63980. * Define this method to modify the default behavior when loading nodes.
  63981. * @param context The context when loading the asset
  63982. * @param node The glTF node property
  63983. * @param assign A function called synchronously after parsing the glTF properties
  63984. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  63985. */
  63986. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  63987. /**
  63988. * Define this method to modify the default behavior when loading cameras.
  63989. * @param context The context when loading the asset
  63990. * @param camera The glTF camera property
  63991. * @param assign A function called synchronously after parsing the glTF properties
  63992. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  63993. */
  63994. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  63995. /**
  63996. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  63997. * @param context The context when loading the asset
  63998. * @param primitive The glTF mesh primitive property
  63999. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  64000. */
  64001. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  64002. /**
  64003. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  64004. * @param context The context when loading the asset
  64005. * @param name The mesh name when loading the asset
  64006. * @param node The glTF node when loading the asset
  64007. * @param mesh The glTF mesh when loading the asset
  64008. * @param primitive The glTF mesh primitive property
  64009. * @param assign A function called synchronously after parsing the glTF properties
  64010. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  64011. */
  64012. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  64013. /**
  64014. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  64015. * @param context The context when loading the asset
  64016. * @param material The glTF material property
  64017. * @param assign A function called synchronously after parsing the glTF properties
  64018. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  64019. */
  64020. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  64021. /**
  64022. * Define this method to modify the default behavior when creating materials.
  64023. * @param context The context when loading the asset
  64024. * @param material The glTF material property
  64025. * @param babylonDrawMode The draw mode for the Babylon material
  64026. * @returns The Babylon material or null if not handled
  64027. */
  64028. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  64029. /**
  64030. * Define this method to modify the default behavior when loading material properties.
  64031. * @param context The context when loading the asset
  64032. * @param material The glTF material property
  64033. * @param babylonMaterial The Babylon material
  64034. * @returns A promise that resolves when the load is complete or null if not handled
  64035. */
  64036. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64037. /**
  64038. * Define this method to modify the default behavior when loading texture infos.
  64039. * @param context The context when loading the asset
  64040. * @param textureInfo The glTF texture info property
  64041. * @param assign A function called synchronously after parsing the glTF properties
  64042. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  64043. */
  64044. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  64045. /**
  64046. * Define this method to modify the default behavior when loading animations.
  64047. * @param context The context when loading the asset
  64048. * @param animation The glTF animation property
  64049. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  64050. */
  64051. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  64052. /**
  64053. * @hidden Define this method to modify the default behavior when loading skins.
  64054. * @param context The context when loading the asset
  64055. * @param node The glTF node property
  64056. * @param skin The glTF skin property
  64057. * @returns A promise that resolves when the load is complete or null if not handled
  64058. */
  64059. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  64060. /**
  64061. * @hidden Define this method to modify the default behavior when loading uris.
  64062. * @param context The context when loading the asset
  64063. * @param property The glTF property associated with the uri
  64064. * @param uri The uri to load
  64065. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  64066. */
  64067. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  64068. }
  64069. }
  64070. declare module BABYLON.GLTF2 {
  64071. /**
  64072. * Helper class for working with arrays when loading the glTF asset
  64073. */
  64074. export class ArrayItem {
  64075. /**
  64076. * Gets an item from the given array.
  64077. * @param context The context when loading the asset
  64078. * @param array The array to get the item from
  64079. * @param index The index to the array
  64080. * @returns The array item
  64081. */
  64082. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  64083. /**
  64084. * Assign an `index` field to each item of the given array.
  64085. * @param array The array of items
  64086. */
  64087. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  64088. }
  64089. /**
  64090. * The glTF 2.0 loader
  64091. */
  64092. export class GLTFLoader implements IGLTFLoader {
  64093. /** @hidden */
  64094. _completePromises: Promise<any>[];
  64095. private _disposed;
  64096. private _parent;
  64097. private _state;
  64098. private _extensions;
  64099. private _rootUrl;
  64100. private _fileName;
  64101. private _uniqueRootUrl;
  64102. private _gltf;
  64103. private _babylonScene;
  64104. private _rootBabylonMesh;
  64105. private _defaultBabylonMaterialData;
  64106. private _progressCallback?;
  64107. private _requests;
  64108. private static readonly _DefaultSampler;
  64109. private static _ExtensionNames;
  64110. private static _ExtensionFactories;
  64111. /**
  64112. * Registers a loader extension.
  64113. * @param name The name of the loader extension.
  64114. * @param factory The factory function that creates the loader extension.
  64115. */
  64116. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  64117. /**
  64118. * Unregisters a loader extension.
  64119. * @param name The name of the loader extenion.
  64120. * @returns A boolean indicating whether the extension has been unregistered
  64121. */
  64122. static UnregisterExtension(name: string): boolean;
  64123. /**
  64124. * Gets the loader state.
  64125. */
  64126. readonly state: Nullable<GLTFLoaderState>;
  64127. /**
  64128. * The glTF object parsed from the JSON.
  64129. */
  64130. readonly gltf: IGLTF;
  64131. /**
  64132. * The Babylon scene when loading the asset.
  64133. */
  64134. readonly babylonScene: Scene;
  64135. /**
  64136. * The root Babylon mesh when loading the asset.
  64137. */
  64138. readonly rootBabylonMesh: Mesh;
  64139. /** @hidden */
  64140. constructor(parent: GLTFFileLoader);
  64141. /** @hidden */
  64142. dispose(): void;
  64143. /** @hidden */
  64144. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64145. meshes: AbstractMesh[];
  64146. particleSystems: IParticleSystem[];
  64147. skeletons: Skeleton[];
  64148. animationGroups: AnimationGroup[];
  64149. }>;
  64150. /** @hidden */
  64151. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64152. private _loadAsync;
  64153. private _loadData;
  64154. private _setupData;
  64155. private _loadExtensions;
  64156. private _checkExtensions;
  64157. private _setState;
  64158. private _createRootNode;
  64159. /**
  64160. * Loads a glTF scene.
  64161. * @param context The context when loading the asset
  64162. * @param scene The glTF scene property
  64163. * @returns A promise that resolves when the load is complete
  64164. */
  64165. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  64166. private _forEachPrimitive;
  64167. private _getMeshes;
  64168. private _getSkeletons;
  64169. private _getAnimationGroups;
  64170. private _startAnimations;
  64171. /**
  64172. * Loads a glTF node.
  64173. * @param context The context when loading the asset
  64174. * @param node The glTF node property
  64175. * @param assign A function called synchronously after parsing the glTF properties
  64176. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  64177. */
  64178. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  64179. private _loadMeshAsync;
  64180. /**
  64181. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  64182. * @param context The context when loading the asset
  64183. * @param name The mesh name when loading the asset
  64184. * @param node The glTF node when loading the asset
  64185. * @param mesh The glTF mesh when loading the asset
  64186. * @param primitive The glTF mesh primitive property
  64187. * @param assign A function called synchronously after parsing the glTF properties
  64188. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  64189. */
  64190. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  64191. private _loadVertexDataAsync;
  64192. private _createMorphTargets;
  64193. private _loadMorphTargetsAsync;
  64194. private _loadMorphTargetVertexDataAsync;
  64195. private static _LoadTransform;
  64196. private _loadSkinAsync;
  64197. private _loadBones;
  64198. private _loadBone;
  64199. private _loadSkinInverseBindMatricesDataAsync;
  64200. private _updateBoneMatrices;
  64201. private _getNodeMatrix;
  64202. /**
  64203. * Loads a glTF camera.
  64204. * @param context The context when loading the asset
  64205. * @param camera The glTF camera property
  64206. * @param assign A function called synchronously after parsing the glTF properties
  64207. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  64208. */
  64209. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  64210. private _loadAnimationsAsync;
  64211. /**
  64212. * Loads a glTF animation.
  64213. * @param context The context when loading the asset
  64214. * @param animation The glTF animation property
  64215. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  64216. */
  64217. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  64218. /**
  64219. * @hidden Loads a glTF animation channel.
  64220. * @param context The context when loading the asset
  64221. * @param animationContext The context of the animation when loading the asset
  64222. * @param animation The glTF animation property
  64223. * @param channel The glTF animation channel property
  64224. * @param babylonAnimationGroup The babylon animation group property
  64225. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  64226. * @returns A void promise when the channel load is complete
  64227. */
  64228. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  64229. private _loadAnimationSamplerAsync;
  64230. private _loadBufferAsync;
  64231. /**
  64232. * Loads a glTF buffer view.
  64233. * @param context The context when loading the asset
  64234. * @param bufferView The glTF buffer view property
  64235. * @returns A promise that resolves with the loaded data when the load is complete
  64236. */
  64237. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  64238. private _loadIndicesAccessorAsync;
  64239. private _loadFloatAccessorAsync;
  64240. private _loadVertexBufferViewAsync;
  64241. private _loadVertexAccessorAsync;
  64242. private _loadMaterialMetallicRoughnessPropertiesAsync;
  64243. /** @hidden */
  64244. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  64245. private _createDefaultMaterial;
  64246. /**
  64247. * Creates a Babylon material from a glTF material.
  64248. * @param context The context when loading the asset
  64249. * @param material The glTF material property
  64250. * @param babylonDrawMode The draw mode for the Babylon material
  64251. * @returns The Babylon material
  64252. */
  64253. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  64254. /**
  64255. * Loads properties from a glTF material into a Babylon material.
  64256. * @param context The context when loading the asset
  64257. * @param material The glTF material property
  64258. * @param babylonMaterial The Babylon material
  64259. * @returns A promise that resolves when the load is complete
  64260. */
  64261. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  64262. /**
  64263. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  64264. * @param context The context when loading the asset
  64265. * @param material The glTF material property
  64266. * @param babylonMaterial The Babylon material
  64267. * @returns A promise that resolves when the load is complete
  64268. */
  64269. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  64270. /**
  64271. * Loads the alpha properties from a glTF material into a Babylon material.
  64272. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  64273. * @param context The context when loading the asset
  64274. * @param material The glTF material property
  64275. * @param babylonMaterial The Babylon material
  64276. */
  64277. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  64278. /**
  64279. * Loads a glTF texture info.
  64280. * @param context The context when loading the asset
  64281. * @param textureInfo The glTF texture info property
  64282. * @param assign A function called synchronously after parsing the glTF properties
  64283. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  64284. */
  64285. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  64286. private _loadTextureAsync;
  64287. private _loadSampler;
  64288. /**
  64289. * Loads a glTF image.
  64290. * @param context The context when loading the asset
  64291. * @param image The glTF image property
  64292. * @returns A promise that resolves with the loaded data when the load is complete
  64293. */
  64294. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  64295. /**
  64296. * Loads a glTF uri.
  64297. * @param context The context when loading the asset
  64298. * @param property The glTF property associated with the uri
  64299. * @param uri The base64 or relative uri
  64300. * @returns A promise that resolves with the loaded data when the load is complete
  64301. */
  64302. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  64303. private _onProgress;
  64304. /**
  64305. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  64306. * @param babylonObject the Babylon object with metadata
  64307. * @param pointer the JSON pointer
  64308. */
  64309. static AddPointerMetadata(babylonObject: {
  64310. metadata: any;
  64311. }, pointer: string): void;
  64312. private static _GetTextureWrapMode;
  64313. private static _GetTextureSamplingMode;
  64314. private static _GetTypedArray;
  64315. private static _GetNumComponents;
  64316. private static _ValidateUri;
  64317. private static _GetDrawMode;
  64318. private _compileMaterialsAsync;
  64319. private _compileShadowGeneratorsAsync;
  64320. private _forEachExtensions;
  64321. private _applyExtensions;
  64322. private _extensionsOnLoading;
  64323. private _extensionsOnReady;
  64324. private _extensionsLoadSceneAsync;
  64325. private _extensionsLoadNodeAsync;
  64326. private _extensionsLoadCameraAsync;
  64327. private _extensionsLoadVertexDataAsync;
  64328. private _extensionsLoadMeshPrimitiveAsync;
  64329. private _extensionsLoadMaterialAsync;
  64330. private _extensionsCreateMaterial;
  64331. private _extensionsLoadMaterialPropertiesAsync;
  64332. private _extensionsLoadTextureInfoAsync;
  64333. private _extensionsLoadAnimationAsync;
  64334. private _extensionsLoadSkinAsync;
  64335. private _extensionsLoadUriAsync;
  64336. /**
  64337. * Helper method called by a loader extension to load an glTF extension.
  64338. * @param context The context when loading the asset
  64339. * @param property The glTF property to load the extension from
  64340. * @param extensionName The name of the extension to load
  64341. * @param actionAsync The action to run
  64342. * @returns The promise returned by actionAsync or null if the extension does not exist
  64343. */
  64344. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  64345. /**
  64346. * Helper method called by a loader extension to load a glTF extra.
  64347. * @param context The context when loading the asset
  64348. * @param property The glTF property to load the extra from
  64349. * @param extensionName The name of the extension to load
  64350. * @param actionAsync The action to run
  64351. * @returns The promise returned by actionAsync or null if the extra does not exist
  64352. */
  64353. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  64354. /**
  64355. * Increments the indentation level and logs a message.
  64356. * @param message The message to log
  64357. */
  64358. logOpen(message: string): void;
  64359. /**
  64360. * Decrements the indentation level.
  64361. */
  64362. logClose(): void;
  64363. /**
  64364. * Logs a message
  64365. * @param message The message to log
  64366. */
  64367. log(message: string): void;
  64368. /**
  64369. * Starts a performance counter.
  64370. * @param counterName The name of the performance counter
  64371. */
  64372. startPerformanceCounter(counterName: string): void;
  64373. /**
  64374. * Ends a performance counter.
  64375. * @param counterName The name of the performance counter
  64376. */
  64377. endPerformanceCounter(counterName: string): void;
  64378. }
  64379. }
  64380. declare module BABYLON.GLTF2.Loader.Extensions {
  64381. /**
  64382. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  64383. */
  64384. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  64385. /** The name of this extension. */
  64386. readonly name: string;
  64387. /** Defines whether this extension is enabled. */
  64388. enabled: boolean;
  64389. private _loader;
  64390. private _lights?;
  64391. /** @hidden */
  64392. constructor(loader: GLTFLoader);
  64393. /** @hidden */
  64394. dispose(): void;
  64395. /** @hidden */
  64396. onLoading(): void;
  64397. /** @hidden */
  64398. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  64399. private _loadLightAsync;
  64400. }
  64401. }
  64402. declare module BABYLON.GLTF2.Loader.Extensions {
  64403. /**
  64404. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  64405. */
  64406. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  64407. /** The name of this extension. */
  64408. readonly name: string;
  64409. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  64410. dracoCompression?: DracoCompression;
  64411. /** Defines whether this extension is enabled. */
  64412. enabled: boolean;
  64413. private _loader;
  64414. /** @hidden */
  64415. constructor(loader: GLTFLoader);
  64416. /** @hidden */
  64417. dispose(): void;
  64418. /** @hidden */
  64419. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  64420. }
  64421. }
  64422. declare module BABYLON.GLTF2.Loader.Extensions {
  64423. /**
  64424. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  64425. */
  64426. export class KHR_lights implements IGLTFLoaderExtension {
  64427. /** The name of this extension. */
  64428. readonly name: string;
  64429. /** Defines whether this extension is enabled. */
  64430. enabled: boolean;
  64431. private _loader;
  64432. private _lights?;
  64433. /** @hidden */
  64434. constructor(loader: GLTFLoader);
  64435. /** @hidden */
  64436. dispose(): void;
  64437. /** @hidden */
  64438. onLoading(): void;
  64439. /** @hidden */
  64440. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64441. }
  64442. }
  64443. declare module BABYLON.GLTF2.Loader.Extensions {
  64444. /**
  64445. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  64446. */
  64447. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  64448. /** The name of this extension. */
  64449. readonly name: string;
  64450. /** Defines whether this extension is enabled. */
  64451. enabled: boolean;
  64452. private _loader;
  64453. /** @hidden */
  64454. constructor(loader: GLTFLoader);
  64455. /** @hidden */
  64456. dispose(): void;
  64457. /** @hidden */
  64458. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64459. private _loadSpecularGlossinessPropertiesAsync;
  64460. }
  64461. }
  64462. declare module BABYLON.GLTF2.Loader.Extensions {
  64463. /**
  64464. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  64465. */
  64466. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  64467. /** The name of this extension. */
  64468. readonly name: string;
  64469. /** Defines whether this extension is enabled. */
  64470. enabled: boolean;
  64471. private _loader;
  64472. /** @hidden */
  64473. constructor(loader: GLTFLoader);
  64474. /** @hidden */
  64475. dispose(): void;
  64476. /** @hidden */
  64477. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64478. private _loadUnlitPropertiesAsync;
  64479. }
  64480. }
  64481. declare module BABYLON.GLTF2.Loader.Extensions {
  64482. /**
  64483. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  64484. */
  64485. export class KHR_texture_transform implements IGLTFLoaderExtension {
  64486. /** The name of this extension. */
  64487. readonly name: string;
  64488. /** Defines whether this extension is enabled. */
  64489. enabled: boolean;
  64490. private _loader;
  64491. /** @hidden */
  64492. constructor(loader: GLTFLoader);
  64493. /** @hidden */
  64494. dispose(): void;
  64495. /** @hidden */
  64496. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  64497. }
  64498. }
  64499. declare module BABYLON.GLTF2.Loader.Extensions {
  64500. /**
  64501. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  64502. */
  64503. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  64504. /** The name of this extension. */
  64505. readonly name: string;
  64506. /** Defines whether this extension is enabled. */
  64507. enabled: boolean;
  64508. private _loader;
  64509. private _clips;
  64510. private _emitters;
  64511. /** @hidden */
  64512. constructor(loader: GLTFLoader);
  64513. /** @hidden */
  64514. dispose(): void;
  64515. /** @hidden */
  64516. onLoading(): void;
  64517. /** @hidden */
  64518. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  64519. /** @hidden */
  64520. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64521. /** @hidden */
  64522. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  64523. private _loadClipAsync;
  64524. private _loadEmitterAsync;
  64525. private _getEventAction;
  64526. private _loadAnimationEventAsync;
  64527. }
  64528. }
  64529. declare module BABYLON.GLTF2.Loader.Extensions {
  64530. /**
  64531. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  64532. */
  64533. export class MSFT_lod implements IGLTFLoaderExtension {
  64534. /** The name of this extension. */
  64535. readonly name: string;
  64536. /** Defines whether this extension is enabled. */
  64537. enabled: boolean;
  64538. /**
  64539. * Maximum number of LODs to load, starting from the lowest LOD.
  64540. */
  64541. maxLODsToLoad: number;
  64542. /**
  64543. * Observable raised when all node LODs of one level are loaded.
  64544. * The event data is the index of the loaded LOD starting from zero.
  64545. * Dispose the loader to cancel the loading of the next level of LODs.
  64546. */
  64547. onNodeLODsLoadedObservable: Observable<number>;
  64548. /**
  64549. * Observable raised when all material LODs of one level are loaded.
  64550. * The event data is the index of the loaded LOD starting from zero.
  64551. * Dispose the loader to cancel the loading of the next level of LODs.
  64552. */
  64553. onMaterialLODsLoadedObservable: Observable<number>;
  64554. private _loader;
  64555. private _nodeIndexLOD;
  64556. private _nodeSignalLODs;
  64557. private _nodePromiseLODs;
  64558. private _materialIndexLOD;
  64559. private _materialSignalLODs;
  64560. private _materialPromiseLODs;
  64561. /** @hidden */
  64562. constructor(loader: GLTFLoader);
  64563. /** @hidden */
  64564. dispose(): void;
  64565. /** @hidden */
  64566. onReady(): void;
  64567. /** @hidden */
  64568. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64569. /** @hidden */
  64570. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  64571. /** @hidden */
  64572. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  64573. /**
  64574. * Gets an array of LOD properties from lowest to highest.
  64575. */
  64576. private _getLODs;
  64577. private _disposeUnusedMaterials;
  64578. }
  64579. }
  64580. declare module BABYLON.GLTF2.Loader.Extensions {
  64581. /** @hidden */
  64582. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  64583. readonly name: string;
  64584. enabled: boolean;
  64585. private _loader;
  64586. constructor(loader: GLTFLoader);
  64587. dispose(): void;
  64588. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64589. }
  64590. }
  64591. declare module BABYLON.GLTF2.Loader.Extensions {
  64592. /** @hidden */
  64593. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  64594. readonly name: string;
  64595. enabled: boolean;
  64596. private _loader;
  64597. constructor(loader: GLTFLoader);
  64598. dispose(): void;
  64599. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64600. }
  64601. }
  64602. declare module BABYLON {
  64603. /**
  64604. * Class reading and parsing the MTL file bundled with the obj file.
  64605. */
  64606. export class MTLFileLoader {
  64607. /**
  64608. * All material loaded from the mtl will be set here
  64609. */
  64610. materials: StandardMaterial[];
  64611. /**
  64612. * This function will read the mtl file and create each material described inside
  64613. * This function could be improve by adding :
  64614. * -some component missing (Ni, Tf...)
  64615. * -including the specific options available
  64616. *
  64617. * @param scene defines the scene the material will be created in
  64618. * @param data defines the mtl data to parse
  64619. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  64620. */
  64621. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  64622. /**
  64623. * Gets the texture for the material.
  64624. *
  64625. * If the material is imported from input file,
  64626. * We sanitize the url to ensure it takes the textre from aside the material.
  64627. *
  64628. * @param rootUrl The root url to load from
  64629. * @param value The value stored in the mtl
  64630. * @return The Texture
  64631. */
  64632. private static _getTexture;
  64633. }
  64634. /**
  64635. * Options for loading OBJ/MTL files
  64636. */
  64637. type MeshLoadOptions = {
  64638. /**
  64639. * Defines if UVs are optimized by default during load.
  64640. */
  64641. OptimizeWithUV: boolean;
  64642. /**
  64643. * Defines custom scaling of UV coordinates of loaded meshes.
  64644. */
  64645. UVScaling: Vector2;
  64646. /**
  64647. * Invert model on y-axis (does a model scaling inversion)
  64648. */
  64649. InvertY: boolean;
  64650. /**
  64651. * Invert Y-Axis of referenced textures on load
  64652. */
  64653. InvertTextureY: boolean;
  64654. /**
  64655. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  64656. */
  64657. ImportVertexColors: boolean;
  64658. /**
  64659. * Compute the normals for the model, even if normals are present in the file.
  64660. */
  64661. ComputeNormals: boolean;
  64662. /**
  64663. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  64664. */
  64665. SkipMaterials: boolean;
  64666. /**
  64667. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  64668. */
  64669. MaterialLoadingFailsSilently: boolean;
  64670. };
  64671. /**
  64672. * OBJ file type loader.
  64673. * This is a babylon scene loader plugin.
  64674. */
  64675. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  64676. /**
  64677. * Defines if UVs are optimized by default during load.
  64678. */
  64679. static OPTIMIZE_WITH_UV: boolean;
  64680. /**
  64681. * Invert model on y-axis (does a model scaling inversion)
  64682. */
  64683. static INVERT_Y: boolean;
  64684. /**
  64685. * Invert Y-Axis of referenced textures on load
  64686. */
  64687. static INVERT_TEXTURE_Y: boolean;
  64688. /**
  64689. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  64690. */
  64691. static IMPORT_VERTEX_COLORS: boolean;
  64692. /**
  64693. * Compute the normals for the model, even if normals are present in the file.
  64694. */
  64695. static COMPUTE_NORMALS: boolean;
  64696. /**
  64697. * Defines custom scaling of UV coordinates of loaded meshes.
  64698. */
  64699. static UV_SCALING: Vector2;
  64700. /**
  64701. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  64702. */
  64703. static SKIP_MATERIALS: boolean;
  64704. /**
  64705. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  64706. *
  64707. * Defaults to true for backwards compatibility.
  64708. */
  64709. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  64710. /**
  64711. * Defines the name of the plugin.
  64712. */
  64713. name: string;
  64714. /**
  64715. * Defines the extension the plugin is able to load.
  64716. */
  64717. extensions: string;
  64718. /** @hidden */
  64719. obj: RegExp;
  64720. /** @hidden */
  64721. group: RegExp;
  64722. /** @hidden */
  64723. mtllib: RegExp;
  64724. /** @hidden */
  64725. usemtl: RegExp;
  64726. /** @hidden */
  64727. smooth: RegExp;
  64728. /** @hidden */
  64729. vertexPattern: RegExp;
  64730. /** @hidden */
  64731. normalPattern: RegExp;
  64732. /** @hidden */
  64733. uvPattern: RegExp;
  64734. /** @hidden */
  64735. facePattern1: RegExp;
  64736. /** @hidden */
  64737. facePattern2: RegExp;
  64738. /** @hidden */
  64739. facePattern3: RegExp;
  64740. /** @hidden */
  64741. facePattern4: RegExp;
  64742. /** @hidden */
  64743. facePattern5: RegExp;
  64744. private _meshLoadOptions;
  64745. /**
  64746. * Creates loader for .OBJ files
  64747. *
  64748. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  64749. */
  64750. constructor(meshLoadOptions?: MeshLoadOptions);
  64751. private static readonly currentMeshLoadOptions;
  64752. /**
  64753. * Calls synchronously the MTL file attached to this obj.
  64754. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  64755. * Without this function materials are not displayed in the first frame (but displayed after).
  64756. * In consequence it is impossible to get material information in your HTML file
  64757. *
  64758. * @param url The URL of the MTL file
  64759. * @param rootUrl
  64760. * @param onSuccess Callback function to be called when the MTL file is loaded
  64761. * @private
  64762. */
  64763. private _loadMTL;
  64764. /**
  64765. * Instantiates a OBJ file loader plugin.
  64766. * @returns the created plugin
  64767. */
  64768. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  64769. /**
  64770. * If the data string can be loaded directly.
  64771. *
  64772. * @param data string containing the file data
  64773. * @returns if the data can be loaded directly
  64774. */
  64775. canDirectLoad(data: string): boolean;
  64776. /**
  64777. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  64778. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64779. * @param scene the scene the meshes should be added to
  64780. * @param data the OBJ data to load
  64781. * @param rootUrl root url to load from
  64782. * @param onProgress event that fires when loading progress has occured
  64783. * @param fileName Defines the name of the file to load
  64784. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64785. */
  64786. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64787. meshes: AbstractMesh[];
  64788. particleSystems: IParticleSystem[];
  64789. skeletons: Skeleton[];
  64790. animationGroups: AnimationGroup[];
  64791. }>;
  64792. /**
  64793. * Imports all objects from the loaded OBJ data and adds them to the scene
  64794. * @param scene the scene the objects should be added to
  64795. * @param data the OBJ data to load
  64796. * @param rootUrl root url to load from
  64797. * @param onProgress event that fires when loading progress has occured
  64798. * @param fileName Defines the name of the file to load
  64799. * @returns a promise which completes when objects have been loaded to the scene
  64800. */
  64801. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64802. /**
  64803. * Load into an asset container.
  64804. * @param scene The scene to load into
  64805. * @param data The data to import
  64806. * @param rootUrl The root url for scene and resources
  64807. * @param onProgress The callback when the load progresses
  64808. * @param fileName Defines the name of the file to load
  64809. * @returns The loaded asset container
  64810. */
  64811. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  64812. /**
  64813. * Read the OBJ file and create an Array of meshes.
  64814. * Each mesh contains all information given by the OBJ and the MTL file.
  64815. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  64816. *
  64817. * @param meshesNames
  64818. * @param scene Scene The scene where are displayed the data
  64819. * @param data String The content of the obj file
  64820. * @param rootUrl String The path to the folder
  64821. * @returns Array<AbstractMesh>
  64822. * @private
  64823. */
  64824. private _parseSolid;
  64825. }
  64826. }
  64827. declare module BABYLON {
  64828. /**
  64829. * STL file type loader.
  64830. * This is a babylon scene loader plugin.
  64831. */
  64832. export class STLFileLoader implements ISceneLoaderPlugin {
  64833. /** @hidden */
  64834. solidPattern: RegExp;
  64835. /** @hidden */
  64836. facetsPattern: RegExp;
  64837. /** @hidden */
  64838. normalPattern: RegExp;
  64839. /** @hidden */
  64840. vertexPattern: RegExp;
  64841. /**
  64842. * Defines the name of the plugin.
  64843. */
  64844. name: string;
  64845. /**
  64846. * Defines the extensions the stl loader is able to load.
  64847. * force data to come in as an ArrayBuffer
  64848. * we'll convert to string if it looks like it's an ASCII .stl
  64849. */
  64850. extensions: ISceneLoaderPluginExtensions;
  64851. /**
  64852. * Import meshes into a scene.
  64853. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  64854. * @param scene The scene to import into
  64855. * @param data The data to import
  64856. * @param rootUrl The root url for scene and resources
  64857. * @param meshes The meshes array to import into
  64858. * @param particleSystems The particle systems array to import into
  64859. * @param skeletons The skeletons array to import into
  64860. * @param onError The callback when import fails
  64861. * @returns True if successful or false otherwise
  64862. */
  64863. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  64864. /**
  64865. * Load into a scene.
  64866. * @param scene The scene to load into
  64867. * @param data The data to import
  64868. * @param rootUrl The root url for scene and resources
  64869. * @param onError The callback when import fails
  64870. * @returns true if successful or false otherwise
  64871. */
  64872. load(scene: Scene, data: any, rootUrl: string): boolean;
  64873. /**
  64874. * Load into an asset container.
  64875. * @param scene The scene to load into
  64876. * @param data The data to import
  64877. * @param rootUrl The root url for scene and resources
  64878. * @param onError The callback when import fails
  64879. * @returns The loaded asset container
  64880. */
  64881. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  64882. private _isBinary;
  64883. private _parseBinary;
  64884. private _parseASCII;
  64885. }
  64886. }
  64887. declare module BABYLON {
  64888. /**
  64889. * Class for generating OBJ data from a Babylon scene.
  64890. */
  64891. export class OBJExport {
  64892. /**
  64893. * Exports the geometry of a Mesh array in .OBJ file format (text)
  64894. * @param mesh defines the list of meshes to serialize
  64895. * @param materials defines if materials should be exported
  64896. * @param matlibname defines the name of the associated mtl file
  64897. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  64898. * @returns the OBJ content
  64899. */
  64900. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  64901. /**
  64902. * Exports the material(s) of a mesh in .MTL file format (text)
  64903. * @param mesh defines the mesh to extract the material from
  64904. * @returns the mtl content
  64905. */
  64906. static MTL(mesh: Mesh): string;
  64907. }
  64908. }
  64909. declare module BABYLON {
  64910. /** @hidden */
  64911. export var __IGLTFExporterExtension: number;
  64912. /**
  64913. * Interface for extending the exporter
  64914. * @hidden
  64915. */
  64916. export interface IGLTFExporterExtension {
  64917. /**
  64918. * The name of this extension
  64919. */
  64920. readonly name: string;
  64921. /**
  64922. * Defines whether this extension is enabled
  64923. */
  64924. enabled: boolean;
  64925. /**
  64926. * Defines whether this extension is required
  64927. */
  64928. required: boolean;
  64929. }
  64930. }
  64931. declare module BABYLON.GLTF2.Exporter {
  64932. /** @hidden */
  64933. export var __IGLTFExporterExtensionV2: number;
  64934. /**
  64935. * Interface for a glTF exporter extension
  64936. * @hidden
  64937. */
  64938. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  64939. /**
  64940. * Define this method to modify the default behavior before exporting a texture
  64941. * @param context The context when loading the asset
  64942. * @param babylonTexture The glTF texture info property
  64943. * @param mimeType The mime-type of the generated image
  64944. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  64945. */
  64946. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  64947. /**
  64948. * Define this method to modify the default behavior when exporting texture info
  64949. * @param context The context when loading the asset
  64950. * @param meshPrimitive glTF mesh primitive
  64951. * @param babylonSubMesh Babylon submesh
  64952. * @param binaryWriter glTF serializer binary writer instance
  64953. * @returns nullable IMeshPrimitive promise
  64954. */
  64955. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  64956. /**
  64957. * Define this method to modify the default behavior when exporting a node
  64958. * @param context The context when exporting the node
  64959. * @param node glTF node
  64960. * @param babylonNode BabylonJS node
  64961. * @returns nullable INode promise
  64962. */
  64963. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  64964. /**
  64965. * Called after the exporter state changes to EXPORTING
  64966. */
  64967. onExporting?(): void;
  64968. }
  64969. }
  64970. declare module BABYLON.GLTF2.Exporter {
  64971. /**
  64972. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  64973. * @hidden
  64974. */
  64975. export class _GLTFMaterialExporter {
  64976. /**
  64977. * Represents the dielectric specular values for R, G and B
  64978. */
  64979. private static readonly _DielectricSpecular;
  64980. /**
  64981. * Allows the maximum specular power to be defined for material calculations
  64982. */
  64983. private static readonly _MaxSpecularPower;
  64984. /**
  64985. * Mapping to store textures
  64986. */
  64987. private _textureMap;
  64988. /**
  64989. * Numeric tolerance value
  64990. */
  64991. private static readonly _Epsilon;
  64992. /**
  64993. * Reference to the glTF Exporter
  64994. */
  64995. private _exporter;
  64996. constructor(exporter: _Exporter);
  64997. /**
  64998. * Specifies if two colors are approximately equal in value
  64999. * @param color1 first color to compare to
  65000. * @param color2 second color to compare to
  65001. * @param epsilon threshold value
  65002. */
  65003. private static FuzzyEquals;
  65004. /**
  65005. * Gets the materials from a Babylon scene and converts them to glTF materials
  65006. * @param scene babylonjs scene
  65007. * @param mimeType texture mime type
  65008. * @param images array of images
  65009. * @param textures array of textures
  65010. * @param materials array of materials
  65011. * @param imageData mapping of texture names to base64 textures
  65012. * @param hasTextureCoords specifies if texture coordinates are present on the material
  65013. */
  65014. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65015. /**
  65016. * Makes a copy of the glTF material without the texture parameters
  65017. * @param originalMaterial original glTF material
  65018. * @returns glTF material without texture parameters
  65019. */
  65020. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  65021. /**
  65022. * Specifies if the material has any texture parameters present
  65023. * @param material glTF Material
  65024. * @returns boolean specifying if texture parameters are present
  65025. */
  65026. _hasTexturesPresent(material: IMaterial): boolean;
  65027. /**
  65028. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  65029. * @param babylonStandardMaterial
  65030. * @returns glTF Metallic Roughness Material representation
  65031. */
  65032. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  65033. /**
  65034. * Computes the metallic factor
  65035. * @param diffuse diffused value
  65036. * @param specular specular value
  65037. * @param oneMinusSpecularStrength one minus the specular strength
  65038. * @returns metallic value
  65039. */
  65040. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  65041. /**
  65042. * Gets the glTF alpha mode from the Babylon Material
  65043. * @param babylonMaterial Babylon Material
  65044. * @returns The Babylon alpha mode value
  65045. */
  65046. _getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  65047. /**
  65048. * Converts a Babylon Standard Material to a glTF Material
  65049. * @param babylonStandardMaterial BJS Standard Material
  65050. * @param mimeType mime type to use for the textures
  65051. * @param images array of glTF image interfaces
  65052. * @param textures array of glTF texture interfaces
  65053. * @param materials array of glTF material interfaces
  65054. * @param imageData map of image file name to data
  65055. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65056. */
  65057. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65058. /**
  65059. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  65060. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  65061. * @param mimeType mime type to use for the textures
  65062. * @param images array of glTF image interfaces
  65063. * @param textures array of glTF texture interfaces
  65064. * @param materials array of glTF material interfaces
  65065. * @param imageData map of image file name to data
  65066. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65067. */
  65068. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65069. /**
  65070. * Converts an image typed array buffer to a base64 image
  65071. * @param buffer typed array buffer
  65072. * @param width width of the image
  65073. * @param height height of the image
  65074. * @param mimeType mimetype of the image
  65075. * @returns base64 image string
  65076. */
  65077. private _createBase64FromCanvasAsync;
  65078. /**
  65079. * Generates a white texture based on the specified width and height
  65080. * @param width width of the texture in pixels
  65081. * @param height height of the texture in pixels
  65082. * @param scene babylonjs scene
  65083. * @returns white texture
  65084. */
  65085. private _createWhiteTexture;
  65086. /**
  65087. * 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
  65088. * @param texture1 first texture to resize
  65089. * @param texture2 second texture to resize
  65090. * @param scene babylonjs scene
  65091. * @returns resized textures or null
  65092. */
  65093. private _resizeTexturesToSameDimensions;
  65094. /**
  65095. * Converts an array of pixels to a Float32Array
  65096. * Throws an error if the pixel format is not supported
  65097. * @param pixels - array buffer containing pixel values
  65098. * @returns Float32 of pixels
  65099. */
  65100. private _convertPixelArrayToFloat32;
  65101. /**
  65102. * Convert Specular Glossiness Textures to Metallic Roughness
  65103. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  65104. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  65105. * @param diffuseTexture texture used to store diffuse information
  65106. * @param specularGlossinessTexture texture used to store specular and glossiness information
  65107. * @param factors specular glossiness material factors
  65108. * @param mimeType the mime type to use for the texture
  65109. * @returns pbr metallic roughness interface or null
  65110. */
  65111. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  65112. /**
  65113. * Converts specular glossiness material properties to metallic roughness
  65114. * @param specularGlossiness interface with specular glossiness material properties
  65115. * @returns interface with metallic roughness material properties
  65116. */
  65117. private _convertSpecularGlossinessToMetallicRoughness;
  65118. /**
  65119. * Calculates the surface reflectance, independent of lighting conditions
  65120. * @param color Color source to calculate brightness from
  65121. * @returns number representing the perceived brightness, or zero if color is undefined
  65122. */
  65123. private _getPerceivedBrightness;
  65124. /**
  65125. * Returns the maximum color component value
  65126. * @param color
  65127. * @returns maximum color component value, or zero if color is null or undefined
  65128. */
  65129. private _getMaxComponent;
  65130. /**
  65131. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  65132. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65133. * @param mimeType mime type to use for the textures
  65134. * @param images array of glTF image interfaces
  65135. * @param textures array of glTF texture interfaces
  65136. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  65137. * @param imageData map of image file name to data
  65138. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65139. * @returns glTF PBR Metallic Roughness factors
  65140. */
  65141. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  65142. private _getGLTFTextureSampler;
  65143. private _getGLTFTextureWrapMode;
  65144. private _getGLTFTextureWrapModesSampler;
  65145. /**
  65146. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  65147. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65148. * @param mimeType mime type to use for the textures
  65149. * @param images array of glTF image interfaces
  65150. * @param textures array of glTF texture interfaces
  65151. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  65152. * @param imageData map of image file name to data
  65153. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65154. * @returns glTF PBR Metallic Roughness factors
  65155. */
  65156. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  65157. /**
  65158. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  65159. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65160. * @param mimeType mime type to use for the textures
  65161. * @param images array of glTF image interfaces
  65162. * @param textures array of glTF texture interfaces
  65163. * @param materials array of glTF material interfaces
  65164. * @param imageData map of image file name to data
  65165. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65166. */
  65167. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65168. private setMetallicRoughnessPbrMaterial;
  65169. private getPixelsFromTexture;
  65170. /**
  65171. * Extracts a texture from a Babylon texture into file data and glTF data
  65172. * @param babylonTexture Babylon texture to extract
  65173. * @param mimeType Mime Type of the babylonTexture
  65174. * @return glTF texture info, or null if the texture format is not supported
  65175. */
  65176. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  65177. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  65178. /**
  65179. * Builds a texture from base64 string
  65180. * @param base64Texture base64 texture string
  65181. * @param baseTextureName Name to use for the texture
  65182. * @param mimeType image mime type for the texture
  65183. * @param images array of images
  65184. * @param textures array of textures
  65185. * @param imageData map of image data
  65186. * @returns glTF texture info, or null if the texture format is not supported
  65187. */
  65188. private _getTextureInfoFromBase64;
  65189. }
  65190. }
  65191. declare module BABYLON {
  65192. /**
  65193. * Class for holding and downloading glTF file data
  65194. */
  65195. export class GLTFData {
  65196. /**
  65197. * Object which contains the file name as the key and its data as the value
  65198. */
  65199. glTFFiles: {
  65200. [fileName: string]: string | Blob;
  65201. };
  65202. /**
  65203. * Initializes the glTF file object
  65204. */
  65205. constructor();
  65206. /**
  65207. * Downloads the glTF data as files based on their names and data
  65208. */
  65209. downloadFiles(): void;
  65210. }
  65211. }
  65212. declare module BABYLON {
  65213. /**
  65214. * Holds a collection of exporter options and parameters
  65215. */
  65216. export interface IExportOptions {
  65217. /**
  65218. * Function which indicates whether a babylon node should be exported or not
  65219. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  65220. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  65221. */
  65222. shouldExportNode?(node: Node): boolean;
  65223. /**
  65224. * The sample rate to bake animation curves
  65225. */
  65226. animationSampleRate?: number;
  65227. /**
  65228. * Begin serialization without waiting for the scene to be ready
  65229. */
  65230. exportWithoutWaitingForScene?: boolean;
  65231. }
  65232. /**
  65233. * Class for generating glTF data from a Babylon scene.
  65234. */
  65235. export class GLTF2Export {
  65236. /**
  65237. * Exports the geometry of the scene to .gltf file format asynchronously
  65238. * @param scene Babylon scene with scene hierarchy information
  65239. * @param filePrefix File prefix to use when generating the glTF file
  65240. * @param options Exporter options
  65241. * @returns Returns an object with a .gltf file and associates texture names
  65242. * as keys and their data and paths as values
  65243. */
  65244. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  65245. private static _PreExportAsync;
  65246. private static _PostExportAsync;
  65247. /**
  65248. * Exports the geometry of the scene to .glb file format asychronously
  65249. * @param scene Babylon scene with scene hierarchy information
  65250. * @param filePrefix File prefix to use when generating glb file
  65251. * @param options Exporter options
  65252. * @returns Returns an object with a .glb filename as key and data as value
  65253. */
  65254. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  65255. }
  65256. }
  65257. declare module BABYLON.GLTF2.Exporter {
  65258. /**
  65259. * @hidden
  65260. */
  65261. export class _GLTFUtilities {
  65262. /**
  65263. * Creates a buffer view based on the supplied arguments
  65264. * @param bufferIndex index value of the specified buffer
  65265. * @param byteOffset byte offset value
  65266. * @param byteLength byte length of the bufferView
  65267. * @param byteStride byte distance between conequential elements
  65268. * @param name name of the buffer view
  65269. * @returns bufferView for glTF
  65270. */
  65271. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  65272. /**
  65273. * Creates an accessor based on the supplied arguments
  65274. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  65275. * @param name The name of the accessor
  65276. * @param type The type of the accessor
  65277. * @param componentType The datatype of components in the attribute
  65278. * @param count The number of attributes referenced by this accessor
  65279. * @param byteOffset The offset relative to the start of the bufferView in bytes
  65280. * @param min Minimum value of each component in this attribute
  65281. * @param max Maximum value of each component in this attribute
  65282. * @returns accessor for glTF
  65283. */
  65284. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  65285. /**
  65286. * Calculates the minimum and maximum values of an array of position floats
  65287. * @param positions Positions array of a mesh
  65288. * @param vertexStart Starting vertex offset to calculate min and max values
  65289. * @param vertexCount Number of vertices to check for min and max values
  65290. * @returns min number array and max number array
  65291. */
  65292. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  65293. min: number[];
  65294. max: number[];
  65295. };
  65296. /**
  65297. * Converts a new right-handed Vector3
  65298. * @param vector vector3 array
  65299. * @returns right-handed Vector3
  65300. */
  65301. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  65302. /**
  65303. * Converts a Vector3 to right-handed
  65304. * @param vector Vector3 to convert to right-handed
  65305. */
  65306. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  65307. /**
  65308. * Converts a three element number array to right-handed
  65309. * @param vector number array to convert to right-handed
  65310. */
  65311. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  65312. /**
  65313. * Converts a new right-handed Vector3
  65314. * @param vector vector3 array
  65315. * @returns right-handed Vector3
  65316. */
  65317. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  65318. /**
  65319. * Converts a Vector3 to right-handed
  65320. * @param vector Vector3 to convert to right-handed
  65321. */
  65322. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  65323. /**
  65324. * Converts a three element number array to right-handed
  65325. * @param vector number array to convert to right-handed
  65326. */
  65327. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  65328. /**
  65329. * Converts a Vector4 to right-handed
  65330. * @param vector Vector4 to convert to right-handed
  65331. */
  65332. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  65333. /**
  65334. * Converts a Vector4 to right-handed
  65335. * @param vector Vector4 to convert to right-handed
  65336. */
  65337. static _GetRightHandedArray4FromRef(vector: number[]): void;
  65338. /**
  65339. * Converts a Quaternion to right-handed
  65340. * @param quaternion Source quaternion to convert to right-handed
  65341. */
  65342. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  65343. /**
  65344. * Converts a Quaternion to right-handed
  65345. * @param quaternion Source quaternion to convert to right-handed
  65346. */
  65347. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  65348. static _NormalizeTangentFromRef(tangent: Vector4): void;
  65349. }
  65350. }
  65351. declare module BABYLON.GLTF2.Exporter {
  65352. /**
  65353. * Converts Babylon Scene into glTF 2.0.
  65354. * @hidden
  65355. */
  65356. export class _Exporter {
  65357. /**
  65358. * Stores the glTF to export
  65359. */
  65360. _glTF: IGLTF;
  65361. /**
  65362. * Stores all generated buffer views, which represents views into the main glTF buffer data
  65363. */
  65364. _bufferViews: IBufferView[];
  65365. /**
  65366. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  65367. */
  65368. _accessors: IAccessor[];
  65369. /**
  65370. * Stores all the generated nodes, which contains transform and/or mesh information per node
  65371. */
  65372. private _nodes;
  65373. /**
  65374. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  65375. */
  65376. private _scenes;
  65377. /**
  65378. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  65379. */
  65380. private _meshes;
  65381. /**
  65382. * Stores all the generated material information, which represents the appearance of each primitive
  65383. */
  65384. _materials: IMaterial[];
  65385. _materialMap: {
  65386. [materialID: number]: number;
  65387. };
  65388. /**
  65389. * Stores all the generated texture information, which is referenced by glTF materials
  65390. */
  65391. _textures: ITexture[];
  65392. /**
  65393. * Stores all the generated image information, which is referenced by glTF textures
  65394. */
  65395. _images: IImage[];
  65396. /**
  65397. * Stores all the texture samplers
  65398. */
  65399. _samplers: ISampler[];
  65400. /**
  65401. * Stores all the generated animation samplers, which is referenced by glTF animations
  65402. */
  65403. /**
  65404. * Stores the animations for glTF models
  65405. */
  65406. private _animations;
  65407. /**
  65408. * Stores the total amount of bytes stored in the glTF buffer
  65409. */
  65410. private _totalByteLength;
  65411. /**
  65412. * Stores a reference to the Babylon scene containing the source geometry and material information
  65413. */
  65414. _babylonScene: Scene;
  65415. /**
  65416. * Stores a map of the image data, where the key is the file name and the value
  65417. * is the image data
  65418. */
  65419. _imageData: {
  65420. [fileName: string]: {
  65421. data: Uint8Array;
  65422. mimeType: ImageMimeType;
  65423. };
  65424. };
  65425. /**
  65426. * Stores a map of the unique id of a node to its index in the node array
  65427. */
  65428. private _nodeMap;
  65429. /**
  65430. * Specifies if the Babylon scene should be converted to right-handed on export
  65431. */
  65432. _convertToRightHandedSystem: boolean;
  65433. /**
  65434. * Baked animation sample rate
  65435. */
  65436. private _animationSampleRate;
  65437. /**
  65438. * Callback which specifies if a node should be exported or not
  65439. */
  65440. private _shouldExportNode;
  65441. private _localEngine;
  65442. _glTFMaterialExporter: _GLTFMaterialExporter;
  65443. private _extensions;
  65444. private static _ExtensionNames;
  65445. private static _ExtensionFactories;
  65446. private _applyExtensions;
  65447. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  65448. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  65449. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65450. private _forEachExtensions;
  65451. private _extensionsOnExporting;
  65452. /**
  65453. * Load glTF serializer extensions
  65454. */
  65455. private _loadExtensions;
  65456. /**
  65457. * Creates a glTF Exporter instance, which can accept optional exporter options
  65458. * @param babylonScene Babylon scene object
  65459. * @param options Options to modify the behavior of the exporter
  65460. */
  65461. constructor(babylonScene: Scene, options?: IExportOptions);
  65462. /**
  65463. * Registers a glTF exporter extension
  65464. * @param name Name of the extension to export
  65465. * @param factory The factory function that creates the exporter extension
  65466. */
  65467. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  65468. /**
  65469. * Un-registers an exporter extension
  65470. * @param name The name fo the exporter extension
  65471. * @returns A boolean indicating whether the extension has been un-registered
  65472. */
  65473. static UnregisterExtension(name: string): boolean;
  65474. /**
  65475. * Lazy load a local engine with premultiplied alpha set to false
  65476. */
  65477. _getLocalEngine(): Engine;
  65478. private reorderIndicesBasedOnPrimitiveMode;
  65479. /**
  65480. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  65481. * clock-wise during export to glTF
  65482. * @param submesh BabylonJS submesh
  65483. * @param primitiveMode Primitive mode of the mesh
  65484. * @param sideOrientation the winding order of the submesh
  65485. * @param vertexBufferKind The type of vertex attribute
  65486. * @param meshAttributeArray The vertex attribute data
  65487. * @param byteOffset The offset to the binary data
  65488. * @param binaryWriter The binary data for the glTF file
  65489. */
  65490. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  65491. /**
  65492. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  65493. * clock-wise during export to glTF
  65494. * @param submesh BabylonJS submesh
  65495. * @param primitiveMode Primitive mode of the mesh
  65496. * @param sideOrientation the winding order of the submesh
  65497. * @param vertexBufferKind The type of vertex attribute
  65498. * @param meshAttributeArray The vertex attribute data
  65499. * @param byteOffset The offset to the binary data
  65500. * @param binaryWriter The binary data for the glTF file
  65501. */
  65502. private reorderTriangleFillMode;
  65503. /**
  65504. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  65505. * clock-wise during export to glTF
  65506. * @param submesh BabylonJS submesh
  65507. * @param primitiveMode Primitive mode of the mesh
  65508. * @param sideOrientation the winding order of the submesh
  65509. * @param vertexBufferKind The type of vertex attribute
  65510. * @param meshAttributeArray The vertex attribute data
  65511. * @param byteOffset The offset to the binary data
  65512. * @param binaryWriter The binary data for the glTF file
  65513. */
  65514. private reorderTriangleStripDrawMode;
  65515. /**
  65516. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  65517. * clock-wise during export to glTF
  65518. * @param submesh BabylonJS submesh
  65519. * @param primitiveMode Primitive mode of the mesh
  65520. * @param sideOrientation the winding order of the submesh
  65521. * @param vertexBufferKind The type of vertex attribute
  65522. * @param meshAttributeArray The vertex attribute data
  65523. * @param byteOffset The offset to the binary data
  65524. * @param binaryWriter The binary data for the glTF file
  65525. */
  65526. private reorderTriangleFanMode;
  65527. /**
  65528. * Writes the vertex attribute data to binary
  65529. * @param vertices The vertices to write to the binary writer
  65530. * @param byteOffset The offset into the binary writer to overwrite binary data
  65531. * @param vertexAttributeKind The vertex attribute type
  65532. * @param meshAttributeArray The vertex attribute data
  65533. * @param binaryWriter The writer containing the binary data
  65534. */
  65535. private writeVertexAttributeData;
  65536. /**
  65537. * Writes mesh attribute data to a data buffer
  65538. * Returns the bytelength of the data
  65539. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  65540. * @param meshAttributeArray Array containing the attribute data
  65541. * @param binaryWriter The buffer to write the binary data to
  65542. * @param indices Used to specify the order of the vertex data
  65543. */
  65544. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  65545. /**
  65546. * Generates glTF json data
  65547. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  65548. * @param glTFPrefix Text to use when prefixing a glTF file
  65549. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  65550. * @returns json data as string
  65551. */
  65552. private generateJSON;
  65553. /**
  65554. * Generates data for .gltf and .bin files based on the glTF prefix string
  65555. * @param glTFPrefix Text to use when prefixing a glTF file
  65556. * @returns GLTFData with glTF file data
  65557. */
  65558. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  65559. /**
  65560. * Creates a binary buffer for glTF
  65561. * @returns array buffer for binary data
  65562. */
  65563. private _generateBinaryAsync;
  65564. /**
  65565. * Pads the number to a multiple of 4
  65566. * @param num number to pad
  65567. * @returns padded number
  65568. */
  65569. private _getPadding;
  65570. /**
  65571. * Generates a glb file from the json and binary data
  65572. * Returns an object with the glb file name as the key and data as the value
  65573. * @param glTFPrefix
  65574. * @returns object with glb filename as key and data as value
  65575. */
  65576. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  65577. /**
  65578. * Sets the TRS for each node
  65579. * @param node glTF Node for storing the transformation data
  65580. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  65581. */
  65582. private setNodeTransformation;
  65583. private getVertexBufferFromMesh;
  65584. /**
  65585. * Creates a bufferview based on the vertices type for the Babylon mesh
  65586. * @param kind Indicates the type of vertices data
  65587. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  65588. * @param binaryWriter The buffer to write the bufferview data to
  65589. */
  65590. private createBufferViewKind;
  65591. /**
  65592. * The primitive mode of the Babylon mesh
  65593. * @param babylonMesh The BabylonJS mesh
  65594. */
  65595. private getMeshPrimitiveMode;
  65596. /**
  65597. * Sets the primitive mode of the glTF mesh primitive
  65598. * @param meshPrimitive glTF mesh primitive
  65599. * @param primitiveMode The primitive mode
  65600. */
  65601. private setPrimitiveMode;
  65602. /**
  65603. * Sets the vertex attribute accessor based of the glTF mesh primitive
  65604. * @param meshPrimitive glTF mesh primitive
  65605. * @param attributeKind vertex attribute
  65606. * @returns boolean specifying if uv coordinates are present
  65607. */
  65608. private setAttributeKind;
  65609. /**
  65610. * Sets data for the primitive attributes of each submesh
  65611. * @param mesh glTF Mesh object to store the primitive attribute information
  65612. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  65613. * @param binaryWriter Buffer to write the attribute data to
  65614. */
  65615. private setPrimitiveAttributesAsync;
  65616. /**
  65617. * Creates a glTF scene based on the array of meshes
  65618. * Returns the the total byte offset
  65619. * @param babylonScene Babylon scene to get the mesh data from
  65620. * @param binaryWriter Buffer to write binary data to
  65621. */
  65622. private createSceneAsync;
  65623. /**
  65624. * Creates a mapping of Node unique id to node index and handles animations
  65625. * @param babylonScene Babylon Scene
  65626. * @param nodes Babylon transform nodes
  65627. * @param shouldExportNode Callback specifying if a transform node should be exported
  65628. * @param binaryWriter Buffer to write binary data to
  65629. * @returns Node mapping of unique id to index
  65630. */
  65631. private createNodeMapAndAnimationsAsync;
  65632. /**
  65633. * Creates a glTF node from a Babylon mesh
  65634. * @param babylonMesh Source Babylon mesh
  65635. * @param binaryWriter Buffer for storing geometry data
  65636. * @returns glTF node
  65637. */
  65638. private createNodeAsync;
  65639. }
  65640. /**
  65641. * @hidden
  65642. *
  65643. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  65644. */
  65645. export class _BinaryWriter {
  65646. /**
  65647. * Array buffer which stores all binary data
  65648. */
  65649. private _arrayBuffer;
  65650. /**
  65651. * View of the array buffer
  65652. */
  65653. private _dataView;
  65654. /**
  65655. * byte offset of data in array buffer
  65656. */
  65657. private _byteOffset;
  65658. /**
  65659. * Initialize binary writer with an initial byte length
  65660. * @param byteLength Initial byte length of the array buffer
  65661. */
  65662. constructor(byteLength: number);
  65663. /**
  65664. * Resize the array buffer to the specified byte length
  65665. * @param byteLength
  65666. */
  65667. private resizeBuffer;
  65668. /**
  65669. * Get an array buffer with the length of the byte offset
  65670. * @returns ArrayBuffer resized to the byte offset
  65671. */
  65672. getArrayBuffer(): ArrayBuffer;
  65673. /**
  65674. * Get the byte offset of the array buffer
  65675. * @returns byte offset
  65676. */
  65677. getByteOffset(): number;
  65678. /**
  65679. * Stores an UInt8 in the array buffer
  65680. * @param entry
  65681. * @param byteOffset If defined, specifies where to set the value as an offset.
  65682. */
  65683. setUInt8(entry: number, byteOffset?: number): void;
  65684. /**
  65685. * Gets an UInt32 in the array buffer
  65686. * @param entry
  65687. * @param byteOffset If defined, specifies where to set the value as an offset.
  65688. */
  65689. getUInt32(byteOffset: number): number;
  65690. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  65691. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  65692. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  65693. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  65694. /**
  65695. * Stores a Float32 in the array buffer
  65696. * @param entry
  65697. */
  65698. setFloat32(entry: number, byteOffset?: number): void;
  65699. /**
  65700. * Stores an UInt32 in the array buffer
  65701. * @param entry
  65702. * @param byteOffset If defined, specifies where to set the value as an offset.
  65703. */
  65704. setUInt32(entry: number, byteOffset?: number): void;
  65705. }
  65706. }
  65707. declare module BABYLON.GLTF2.Exporter {
  65708. /**
  65709. * @hidden
  65710. * Interface to store animation data.
  65711. */
  65712. export interface _IAnimationData {
  65713. /**
  65714. * Keyframe data.
  65715. */
  65716. inputs: number[];
  65717. /**
  65718. * Value data.
  65719. */
  65720. outputs: number[][];
  65721. /**
  65722. * Animation interpolation data.
  65723. */
  65724. samplerInterpolation: AnimationSamplerInterpolation;
  65725. /**
  65726. * Minimum keyframe value.
  65727. */
  65728. inputsMin: number;
  65729. /**
  65730. * Maximum keyframe value.
  65731. */
  65732. inputsMax: number;
  65733. }
  65734. /**
  65735. * @hidden
  65736. */
  65737. export interface _IAnimationInfo {
  65738. /**
  65739. * The target channel for the animation
  65740. */
  65741. animationChannelTargetPath: AnimationChannelTargetPath;
  65742. /**
  65743. * The glTF accessor type for the data.
  65744. */
  65745. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  65746. /**
  65747. * Specifies if quaternions should be used.
  65748. */
  65749. useQuaternion: boolean;
  65750. }
  65751. /**
  65752. * @hidden
  65753. * Utility class for generating glTF animation data from BabylonJS.
  65754. */
  65755. export class _GLTFAnimation {
  65756. /**
  65757. * @ignore
  65758. *
  65759. * Creates glTF channel animation from BabylonJS animation.
  65760. * @param babylonTransformNode - BabylonJS mesh.
  65761. * @param animation - animation.
  65762. * @param animationChannelTargetPath - The target animation channel.
  65763. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  65764. * @param useQuaternion - Specifies if quaternions are used.
  65765. * @returns nullable IAnimationData
  65766. */
  65767. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  65768. private static _DeduceAnimationInfo;
  65769. /**
  65770. * @ignore
  65771. * Create node animations from the transform node animations
  65772. * @param babylonNode
  65773. * @param runtimeGLTFAnimation
  65774. * @param idleGLTFAnimations
  65775. * @param nodeMap
  65776. * @param nodes
  65777. * @param binaryWriter
  65778. * @param bufferViews
  65779. * @param accessors
  65780. * @param convertToRightHandedSystem
  65781. */
  65782. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  65783. [key: number]: number;
  65784. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  65785. /**
  65786. * @ignore
  65787. * Create node animations from the animation groups
  65788. * @param babylonScene
  65789. * @param glTFAnimations
  65790. * @param nodeMap
  65791. * @param nodes
  65792. * @param binaryWriter
  65793. * @param bufferViews
  65794. * @param accessors
  65795. * @param convertToRightHandedSystem
  65796. */
  65797. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  65798. [key: number]: number;
  65799. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  65800. private static AddAnimation;
  65801. /**
  65802. * Create a baked animation
  65803. * @param babylonTransformNode BabylonJS mesh
  65804. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  65805. * @param animationChannelTargetPath animation target channel
  65806. * @param minFrame minimum animation frame
  65807. * @param maxFrame maximum animation frame
  65808. * @param fps frames per second of the animation
  65809. * @param inputs input key frames of the animation
  65810. * @param outputs output key frame data of the animation
  65811. * @param convertToRightHandedSystem converts the values to right-handed
  65812. * @param useQuaternion specifies if quaternions should be used
  65813. */
  65814. private static _CreateBakedAnimation;
  65815. private static _ConvertFactorToVector3OrQuaternion;
  65816. private static _SetInterpolatedValue;
  65817. /**
  65818. * Creates linear animation from the animation key frames
  65819. * @param babylonTransformNode BabylonJS mesh
  65820. * @param animation BabylonJS animation
  65821. * @param animationChannelTargetPath The target animation channel
  65822. * @param frameDelta The difference between the last and first frame of the animation
  65823. * @param inputs Array to store the key frame times
  65824. * @param outputs Array to store the key frame data
  65825. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  65826. * @param useQuaternion Specifies if quaternions are used in the animation
  65827. */
  65828. private static _CreateLinearOrStepAnimation;
  65829. /**
  65830. * Creates cubic spline animation from the animation key frames
  65831. * @param babylonTransformNode BabylonJS mesh
  65832. * @param animation BabylonJS animation
  65833. * @param animationChannelTargetPath The target animation channel
  65834. * @param frameDelta The difference between the last and first frame of the animation
  65835. * @param inputs Array to store the key frame times
  65836. * @param outputs Array to store the key frame data
  65837. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  65838. * @param useQuaternion Specifies if quaternions are used in the animation
  65839. */
  65840. private static _CreateCubicSplineAnimation;
  65841. private static _GetBasePositionRotationOrScale;
  65842. /**
  65843. * Adds a key frame value
  65844. * @param keyFrame
  65845. * @param animation
  65846. * @param outputs
  65847. * @param animationChannelTargetPath
  65848. * @param basePositionRotationOrScale
  65849. * @param convertToRightHandedSystem
  65850. * @param useQuaternion
  65851. */
  65852. private static _AddKeyframeValue;
  65853. /**
  65854. * Determine the interpolation based on the key frames
  65855. * @param keyFrames
  65856. * @param animationChannelTargetPath
  65857. * @param useQuaternion
  65858. */
  65859. private static _DeduceInterpolation;
  65860. /**
  65861. * Adds an input tangent or output tangent to the output data
  65862. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  65863. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  65864. * @param outputs The animation data by keyframe
  65865. * @param animationChannelTargetPath The target animation channel
  65866. * @param interpolation The interpolation type
  65867. * @param keyFrame The key frame with the animation data
  65868. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  65869. * @param useQuaternion Specifies if quaternions are used
  65870. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  65871. */
  65872. private static AddSplineTangent;
  65873. /**
  65874. * Get the minimum and maximum key frames' frame values
  65875. * @param keyFrames animation key frames
  65876. * @returns the minimum and maximum key frame value
  65877. */
  65878. private static calculateMinMaxKeyFrames;
  65879. }
  65880. }
  65881. declare module BABYLON.GLTF2.Exporter {
  65882. /** @hidden */
  65883. export var textureTransformPixelShader: {
  65884. name: string;
  65885. shader: string;
  65886. };
  65887. }
  65888. declare module BABYLON.GLTF2.Exporter.Extensions {
  65889. /**
  65890. * @hidden
  65891. */
  65892. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  65893. /** Name of this extension */
  65894. readonly name: string;
  65895. /** Defines whether this extension is enabled */
  65896. enabled: boolean;
  65897. /** Defines whether this extension is required */
  65898. required: boolean;
  65899. /** Reference to the glTF exporter */
  65900. private _exporter;
  65901. constructor(exporter: _Exporter);
  65902. dispose(): void;
  65903. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  65904. /**
  65905. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  65906. * @param babylonTexture
  65907. * @param offset
  65908. * @param rotation
  65909. * @param scale
  65910. * @param scene
  65911. */
  65912. private _textureTransformTextureAsync;
  65913. }
  65914. }
  65915. declare module BABYLON.GLTF2.Exporter.Extensions {
  65916. /**
  65917. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  65918. */
  65919. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  65920. /** The name of this extension. */
  65921. readonly name: string;
  65922. /** Defines whether this extension is enabled. */
  65923. enabled: boolean;
  65924. /** Defines whether this extension is required */
  65925. required: boolean;
  65926. /** Reference to the glTF exporter */
  65927. private _exporter;
  65928. private _lights;
  65929. /** @hidden */
  65930. constructor(exporter: _Exporter);
  65931. /** @hidden */
  65932. dispose(): void;
  65933. /** @hidden */
  65934. onExporting(): void;
  65935. /**
  65936. * Define this method to modify the default behavior when exporting a node
  65937. * @param context The context when exporting the node
  65938. * @param node glTF node
  65939. * @param babylonNode BabylonJS node
  65940. * @returns nullable INode promise
  65941. */
  65942. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65943. }
  65944. }
  65945. declare module BABYLON {
  65946. /**
  65947. * Class for generating STL data from a Babylon scene.
  65948. */
  65949. export class STLExport {
  65950. /**
  65951. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  65952. * @param meshes list defines the mesh to serialize
  65953. * @param download triggers the automatic download of the file.
  65954. * @param fileName changes the downloads fileName.
  65955. * @param binary changes the STL to a binary type.
  65956. * @param isLittleEndian toggle for binary type exporter.
  65957. * @returns the STL as UTF8 string
  65958. */
  65959. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  65960. }
  65961. }
  65962. /**
  65963. * @ignoreChildren
  65964. * @ignore
  65965. */
  65966. declare module "babylonjs-gltf2interface" {
  65967. export = BABYLON.GLTF2;
  65968. }
  65969. /**
  65970. * Module for glTF 2.0 Interface
  65971. * @ignoreChildren
  65972. * @ignore
  65973. */
  65974. declare module BABYLON.GLTF2 {
  65975. /**
  65976. * The datatype of the components in the attribute
  65977. */
  65978. const enum AccessorComponentType {
  65979. /**
  65980. * Byte
  65981. */
  65982. BYTE = 5120,
  65983. /**
  65984. * Unsigned Byte
  65985. */
  65986. UNSIGNED_BYTE = 5121,
  65987. /**
  65988. * Short
  65989. */
  65990. SHORT = 5122,
  65991. /**
  65992. * Unsigned Short
  65993. */
  65994. UNSIGNED_SHORT = 5123,
  65995. /**
  65996. * Unsigned Int
  65997. */
  65998. UNSIGNED_INT = 5125,
  65999. /**
  66000. * Float
  66001. */
  66002. FLOAT = 5126,
  66003. }
  66004. /**
  66005. * Specifies if the attirbute is a scalar, vector, or matrix
  66006. */
  66007. const enum AccessorType {
  66008. /**
  66009. * Scalar
  66010. */
  66011. SCALAR = "SCALAR",
  66012. /**
  66013. * Vector2
  66014. */
  66015. VEC2 = "VEC2",
  66016. /**
  66017. * Vector3
  66018. */
  66019. VEC3 = "VEC3",
  66020. /**
  66021. * Vector4
  66022. */
  66023. VEC4 = "VEC4",
  66024. /**
  66025. * Matrix2x2
  66026. */
  66027. MAT2 = "MAT2",
  66028. /**
  66029. * Matrix3x3
  66030. */
  66031. MAT3 = "MAT3",
  66032. /**
  66033. * Matrix4x4
  66034. */
  66035. MAT4 = "MAT4",
  66036. }
  66037. /**
  66038. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  66039. */
  66040. const enum AnimationChannelTargetPath {
  66041. /**
  66042. * Translation
  66043. */
  66044. TRANSLATION = "translation",
  66045. /**
  66046. * Rotation
  66047. */
  66048. ROTATION = "rotation",
  66049. /**
  66050. * Scale
  66051. */
  66052. SCALE = "scale",
  66053. /**
  66054. * Weights
  66055. */
  66056. WEIGHTS = "weights",
  66057. }
  66058. /**
  66059. * Interpolation algorithm
  66060. */
  66061. const enum AnimationSamplerInterpolation {
  66062. /**
  66063. * The animated values are linearly interpolated between keyframes
  66064. */
  66065. LINEAR = "LINEAR",
  66066. /**
  66067. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  66068. */
  66069. STEP = "STEP",
  66070. /**
  66071. * The animation's interpolation is computed using a cubic spline with specified tangents
  66072. */
  66073. CUBICSPLINE = "CUBICSPLINE",
  66074. }
  66075. /**
  66076. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  66077. */
  66078. const enum CameraType {
  66079. /**
  66080. * A perspective camera containing properties to create a perspective projection matrix
  66081. */
  66082. PERSPECTIVE = "perspective",
  66083. /**
  66084. * An orthographic camera containing properties to create an orthographic projection matrix
  66085. */
  66086. ORTHOGRAPHIC = "orthographic",
  66087. }
  66088. /**
  66089. * The mime-type of the image
  66090. */
  66091. const enum ImageMimeType {
  66092. /**
  66093. * JPEG Mime-type
  66094. */
  66095. JPEG = "image/jpeg",
  66096. /**
  66097. * PNG Mime-type
  66098. */
  66099. PNG = "image/png",
  66100. }
  66101. /**
  66102. * The alpha rendering mode of the material
  66103. */
  66104. const enum MaterialAlphaMode {
  66105. /**
  66106. * The alpha value is ignored and the rendered output is fully opaque
  66107. */
  66108. OPAQUE = "OPAQUE",
  66109. /**
  66110. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  66111. */
  66112. MASK = "MASK",
  66113. /**
  66114. * 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)
  66115. */
  66116. BLEND = "BLEND",
  66117. }
  66118. /**
  66119. * The type of the primitives to render
  66120. */
  66121. const enum MeshPrimitiveMode {
  66122. /**
  66123. * Points
  66124. */
  66125. POINTS = 0,
  66126. /**
  66127. * Lines
  66128. */
  66129. LINES = 1,
  66130. /**
  66131. * Line Loop
  66132. */
  66133. LINE_LOOP = 2,
  66134. /**
  66135. * Line Strip
  66136. */
  66137. LINE_STRIP = 3,
  66138. /**
  66139. * Triangles
  66140. */
  66141. TRIANGLES = 4,
  66142. /**
  66143. * Triangle Strip
  66144. */
  66145. TRIANGLE_STRIP = 5,
  66146. /**
  66147. * Triangle Fan
  66148. */
  66149. TRIANGLE_FAN = 6,
  66150. }
  66151. /**
  66152. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  66153. */
  66154. const enum TextureMagFilter {
  66155. /**
  66156. * Nearest
  66157. */
  66158. NEAREST = 9728,
  66159. /**
  66160. * Linear
  66161. */
  66162. LINEAR = 9729,
  66163. }
  66164. /**
  66165. * Minification filter. All valid values correspond to WebGL enums
  66166. */
  66167. const enum TextureMinFilter {
  66168. /**
  66169. * Nearest
  66170. */
  66171. NEAREST = 9728,
  66172. /**
  66173. * Linear
  66174. */
  66175. LINEAR = 9729,
  66176. /**
  66177. * Nearest Mip-Map Nearest
  66178. */
  66179. NEAREST_MIPMAP_NEAREST = 9984,
  66180. /**
  66181. * Linear Mipmap Nearest
  66182. */
  66183. LINEAR_MIPMAP_NEAREST = 9985,
  66184. /**
  66185. * Nearest Mipmap Linear
  66186. */
  66187. NEAREST_MIPMAP_LINEAR = 9986,
  66188. /**
  66189. * Linear Mipmap Linear
  66190. */
  66191. LINEAR_MIPMAP_LINEAR = 9987,
  66192. }
  66193. /**
  66194. * S (U) wrapping mode. All valid values correspond to WebGL enums
  66195. */
  66196. const enum TextureWrapMode {
  66197. /**
  66198. * Clamp to Edge
  66199. */
  66200. CLAMP_TO_EDGE = 33071,
  66201. /**
  66202. * Mirrored Repeat
  66203. */
  66204. MIRRORED_REPEAT = 33648,
  66205. /**
  66206. * Repeat
  66207. */
  66208. REPEAT = 10497,
  66209. }
  66210. /**
  66211. * glTF Property
  66212. */
  66213. interface IProperty {
  66214. /**
  66215. * Dictionary object with extension-specific objects
  66216. */
  66217. extensions?: {
  66218. [key: string]: any;
  66219. };
  66220. /**
  66221. * Application-Specific data
  66222. */
  66223. extras?: any;
  66224. }
  66225. /**
  66226. * glTF Child of Root Property
  66227. */
  66228. interface IChildRootProperty extends IProperty {
  66229. /**
  66230. * The user-defined name of this object
  66231. */
  66232. name?: string;
  66233. }
  66234. /**
  66235. * Indices of those attributes that deviate from their initialization value
  66236. */
  66237. interface IAccessorSparseIndices extends IProperty {
  66238. /**
  66239. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  66240. */
  66241. bufferView: number;
  66242. /**
  66243. * The offset relative to the start of the bufferView in bytes. Must be aligned
  66244. */
  66245. byteOffset?: number;
  66246. /**
  66247. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  66248. */
  66249. componentType: AccessorComponentType;
  66250. }
  66251. /**
  66252. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  66253. */
  66254. interface IAccessorSparseValues extends IProperty {
  66255. /**
  66256. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  66257. */
  66258. bufferView: number;
  66259. /**
  66260. * The offset relative to the start of the bufferView in bytes. Must be aligned
  66261. */
  66262. byteOffset?: number;
  66263. }
  66264. /**
  66265. * Sparse storage of attributes that deviate from their initialization value
  66266. */
  66267. interface IAccessorSparse extends IProperty {
  66268. /**
  66269. * The number of attributes encoded in this sparse accessor
  66270. */
  66271. count: number;
  66272. /**
  66273. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  66274. */
  66275. indices: IAccessorSparseIndices;
  66276. /**
  66277. * 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
  66278. */
  66279. values: IAccessorSparseValues;
  66280. }
  66281. /**
  66282. * 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
  66283. */
  66284. interface IAccessor extends IChildRootProperty {
  66285. /**
  66286. * The index of the bufferview
  66287. */
  66288. bufferView?: number;
  66289. /**
  66290. * The offset relative to the start of the bufferView in bytes
  66291. */
  66292. byteOffset?: number;
  66293. /**
  66294. * The datatype of components in the attribute
  66295. */
  66296. componentType: AccessorComponentType;
  66297. /**
  66298. * Specifies whether integer data values should be normalized
  66299. */
  66300. normalized?: boolean;
  66301. /**
  66302. * The number of attributes referenced by this accessor
  66303. */
  66304. count: number;
  66305. /**
  66306. * Specifies if the attribute is a scalar, vector, or matrix
  66307. */
  66308. type: AccessorType;
  66309. /**
  66310. * Maximum value of each component in this attribute
  66311. */
  66312. max?: number[];
  66313. /**
  66314. * Minimum value of each component in this attribute
  66315. */
  66316. min?: number[];
  66317. /**
  66318. * Sparse storage of attributes that deviate from their initialization value
  66319. */
  66320. sparse?: IAccessorSparse;
  66321. }
  66322. /**
  66323. * Targets an animation's sampler at a node's property
  66324. */
  66325. interface IAnimationChannel extends IProperty {
  66326. /**
  66327. * The index of a sampler in this animation used to compute the value for the target
  66328. */
  66329. sampler: number;
  66330. /**
  66331. * The index of the node and TRS property to target
  66332. */
  66333. target: IAnimationChannelTarget;
  66334. }
  66335. /**
  66336. * The index of the node and TRS property that an animation channel targets
  66337. */
  66338. interface IAnimationChannelTarget extends IProperty {
  66339. /**
  66340. * The index of the node to target
  66341. */
  66342. node: number;
  66343. /**
  66344. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  66345. */
  66346. path: AnimationChannelTargetPath;
  66347. }
  66348. /**
  66349. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  66350. */
  66351. interface IAnimationSampler extends IProperty {
  66352. /**
  66353. * The index of an accessor containing keyframe input values, e.g., time
  66354. */
  66355. input: number;
  66356. /**
  66357. * Interpolation algorithm
  66358. */
  66359. interpolation?: AnimationSamplerInterpolation;
  66360. /**
  66361. * The index of an accessor, containing keyframe output values
  66362. */
  66363. output: number;
  66364. }
  66365. /**
  66366. * A keyframe animation
  66367. */
  66368. interface IAnimation extends IChildRootProperty {
  66369. /**
  66370. * An array of channels, each of which targets an animation's sampler at a node's property
  66371. */
  66372. channels: IAnimationChannel[];
  66373. /**
  66374. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  66375. */
  66376. samplers: IAnimationSampler[];
  66377. }
  66378. /**
  66379. * Metadata about the glTF asset
  66380. */
  66381. interface IAsset extends IChildRootProperty {
  66382. /**
  66383. * A copyright message suitable for display to credit the content creator
  66384. */
  66385. copyright?: string;
  66386. /**
  66387. * Tool that generated this glTF model. Useful for debugging
  66388. */
  66389. generator?: string;
  66390. /**
  66391. * The glTF version that this asset targets
  66392. */
  66393. version: string;
  66394. /**
  66395. * The minimum glTF version that this asset targets
  66396. */
  66397. minVersion?: string;
  66398. }
  66399. /**
  66400. * A buffer points to binary geometry, animation, or skins
  66401. */
  66402. interface IBuffer extends IChildRootProperty {
  66403. /**
  66404. * 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
  66405. */
  66406. uri?: string;
  66407. /**
  66408. * The length of the buffer in bytes
  66409. */
  66410. byteLength: number;
  66411. }
  66412. /**
  66413. * A view into a buffer generally representing a subset of the buffer
  66414. */
  66415. interface IBufferView extends IChildRootProperty {
  66416. /**
  66417. * The index of the buffer
  66418. */
  66419. buffer: number;
  66420. /**
  66421. * The offset into the buffer in bytes
  66422. */
  66423. byteOffset?: number;
  66424. /**
  66425. * The lenth of the bufferView in bytes
  66426. */
  66427. byteLength: number;
  66428. /**
  66429. * The stride, in bytes
  66430. */
  66431. byteStride?: number;
  66432. }
  66433. /**
  66434. * An orthographic camera containing properties to create an orthographic projection matrix
  66435. */
  66436. interface ICameraOrthographic extends IProperty {
  66437. /**
  66438. * The floating-point horizontal magnification of the view. Must not be zero
  66439. */
  66440. xmag: number;
  66441. /**
  66442. * The floating-point vertical magnification of the view. Must not be zero
  66443. */
  66444. ymag: number;
  66445. /**
  66446. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  66447. */
  66448. zfar: number;
  66449. /**
  66450. * The floating-point distance to the near clipping plane
  66451. */
  66452. znear: number;
  66453. }
  66454. /**
  66455. * A perspective camera containing properties to create a perspective projection matrix
  66456. */
  66457. interface ICameraPerspective extends IProperty {
  66458. /**
  66459. * The floating-point aspect ratio of the field of view
  66460. */
  66461. aspectRatio?: number;
  66462. /**
  66463. * The floating-point vertical field of view in radians
  66464. */
  66465. yfov: number;
  66466. /**
  66467. * The floating-point distance to the far clipping plane
  66468. */
  66469. zfar?: number;
  66470. /**
  66471. * The floating-point distance to the near clipping plane
  66472. */
  66473. znear: number;
  66474. }
  66475. /**
  66476. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  66477. */
  66478. interface ICamera extends IChildRootProperty {
  66479. /**
  66480. * An orthographic camera containing properties to create an orthographic projection matrix
  66481. */
  66482. orthographic?: ICameraOrthographic;
  66483. /**
  66484. * A perspective camera containing properties to create a perspective projection matrix
  66485. */
  66486. perspective?: ICameraPerspective;
  66487. /**
  66488. * Specifies if the camera uses a perspective or orthographic projection
  66489. */
  66490. type: CameraType;
  66491. }
  66492. /**
  66493. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  66494. */
  66495. interface IImage extends IChildRootProperty {
  66496. /**
  66497. * 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
  66498. */
  66499. uri?: string;
  66500. /**
  66501. * The image's MIME type
  66502. */
  66503. mimeType?: ImageMimeType;
  66504. /**
  66505. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  66506. */
  66507. bufferView?: number;
  66508. }
  66509. /**
  66510. * Material Normal Texture Info
  66511. */
  66512. interface IMaterialNormalTextureInfo extends ITextureInfo {
  66513. /**
  66514. * The scalar multiplier applied to each normal vector of the normal texture
  66515. */
  66516. scale?: number;
  66517. }
  66518. /**
  66519. * Material Occlusion Texture Info
  66520. */
  66521. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  66522. /**
  66523. * A scalar multiplier controlling the amount of occlusion applied
  66524. */
  66525. strength?: number;
  66526. }
  66527. /**
  66528. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  66529. */
  66530. interface IMaterialPbrMetallicRoughness {
  66531. /**
  66532. * The material's base color factor
  66533. */
  66534. baseColorFactor?: number[];
  66535. /**
  66536. * The base color texture
  66537. */
  66538. baseColorTexture?: ITextureInfo;
  66539. /**
  66540. * The metalness of the material
  66541. */
  66542. metallicFactor?: number;
  66543. /**
  66544. * The roughness of the material
  66545. */
  66546. roughnessFactor?: number;
  66547. /**
  66548. * The metallic-roughness texture
  66549. */
  66550. metallicRoughnessTexture?: ITextureInfo;
  66551. }
  66552. /**
  66553. * The material appearance of a primitive
  66554. */
  66555. interface IMaterial extends IChildRootProperty {
  66556. /**
  66557. * 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
  66558. */
  66559. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  66560. /**
  66561. * The normal map texture
  66562. */
  66563. normalTexture?: IMaterialNormalTextureInfo;
  66564. /**
  66565. * The occlusion map texture
  66566. */
  66567. occlusionTexture?: IMaterialOcclusionTextureInfo;
  66568. /**
  66569. * The emissive map texture
  66570. */
  66571. emissiveTexture?: ITextureInfo;
  66572. /**
  66573. * 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
  66574. */
  66575. emissiveFactor?: number[];
  66576. /**
  66577. * The alpha rendering mode of the material
  66578. */
  66579. alphaMode?: MaterialAlphaMode;
  66580. /**
  66581. * The alpha cutoff value of the material
  66582. */
  66583. alphaCutoff?: number;
  66584. /**
  66585. * Specifies whether the material is double sided
  66586. */
  66587. doubleSided?: boolean;
  66588. }
  66589. /**
  66590. * Geometry to be rendered with the given material
  66591. */
  66592. interface IMeshPrimitive extends IProperty {
  66593. /**
  66594. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  66595. */
  66596. attributes: {
  66597. [name: string]: number;
  66598. };
  66599. /**
  66600. * The index of the accessor that contains the indices
  66601. */
  66602. indices?: number;
  66603. /**
  66604. * The index of the material to apply to this primitive when rendering
  66605. */
  66606. material?: number;
  66607. /**
  66608. * The type of primitives to render. All valid values correspond to WebGL enums
  66609. */
  66610. mode?: MeshPrimitiveMode;
  66611. /**
  66612. * 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
  66613. */
  66614. targets?: {
  66615. [name: string]: number;
  66616. }[];
  66617. }
  66618. /**
  66619. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  66620. */
  66621. interface IMesh extends IChildRootProperty {
  66622. /**
  66623. * An array of primitives, each defining geometry to be rendered with a material
  66624. */
  66625. primitives: IMeshPrimitive[];
  66626. /**
  66627. * Array of weights to be applied to the Morph Targets
  66628. */
  66629. weights?: number[];
  66630. }
  66631. /**
  66632. * A node in the node hierarchy
  66633. */
  66634. interface INode extends IChildRootProperty {
  66635. /**
  66636. * The index of the camera referenced by this node
  66637. */
  66638. camera?: number;
  66639. /**
  66640. * The indices of this node's children
  66641. */
  66642. children?: number[];
  66643. /**
  66644. * The index of the skin referenced by this node
  66645. */
  66646. skin?: number;
  66647. /**
  66648. * A floating-point 4x4 transformation matrix stored in column-major order
  66649. */
  66650. matrix?: number[];
  66651. /**
  66652. * The index of the mesh in this node
  66653. */
  66654. mesh?: number;
  66655. /**
  66656. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  66657. */
  66658. rotation?: number[];
  66659. /**
  66660. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  66661. */
  66662. scale?: number[];
  66663. /**
  66664. * The node's translation along the x, y, and z axes
  66665. */
  66666. translation?: number[];
  66667. /**
  66668. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  66669. */
  66670. weights?: number[];
  66671. }
  66672. /**
  66673. * Texture sampler properties for filtering and wrapping modes
  66674. */
  66675. interface ISampler extends IChildRootProperty {
  66676. /**
  66677. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  66678. */
  66679. magFilter?: TextureMagFilter;
  66680. /**
  66681. * Minification filter. All valid values correspond to WebGL enums
  66682. */
  66683. minFilter?: TextureMinFilter;
  66684. /**
  66685. * S (U) wrapping mode. All valid values correspond to WebGL enums
  66686. */
  66687. wrapS?: TextureWrapMode;
  66688. /**
  66689. * T (V) wrapping mode. All valid values correspond to WebGL enums
  66690. */
  66691. wrapT?: TextureWrapMode;
  66692. }
  66693. /**
  66694. * The root nodes of a scene
  66695. */
  66696. interface IScene extends IChildRootProperty {
  66697. /**
  66698. * The indices of each root node
  66699. */
  66700. nodes: number[];
  66701. }
  66702. /**
  66703. * Joints and matrices defining a skin
  66704. */
  66705. interface ISkin extends IChildRootProperty {
  66706. /**
  66707. * 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
  66708. */
  66709. inverseBindMatrices?: number;
  66710. /**
  66711. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  66712. */
  66713. skeleton?: number;
  66714. /**
  66715. * 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)
  66716. */
  66717. joints: number[];
  66718. }
  66719. /**
  66720. * A texture and its sampler
  66721. */
  66722. interface ITexture extends IChildRootProperty {
  66723. /**
  66724. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  66725. */
  66726. sampler?: number;
  66727. /**
  66728. * The index of the image used by this texture
  66729. */
  66730. source: number;
  66731. }
  66732. /**
  66733. * Reference to a texture
  66734. */
  66735. interface ITextureInfo extends IProperty {
  66736. /**
  66737. * The index of the texture
  66738. */
  66739. index: number;
  66740. /**
  66741. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  66742. */
  66743. texCoord?: number;
  66744. }
  66745. /**
  66746. * The root object for a glTF asset
  66747. */
  66748. interface IGLTF extends IProperty {
  66749. /**
  66750. * An array of accessors. An accessor is a typed view into a bufferView
  66751. */
  66752. accessors?: IAccessor[];
  66753. /**
  66754. * An array of keyframe animations
  66755. */
  66756. animations?: IAnimation[];
  66757. /**
  66758. * Metadata about the glTF asset
  66759. */
  66760. asset: IAsset;
  66761. /**
  66762. * An array of buffers. A buffer points to binary geometry, animation, or skins
  66763. */
  66764. buffers?: IBuffer[];
  66765. /**
  66766. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  66767. */
  66768. bufferViews?: IBufferView[];
  66769. /**
  66770. * An array of cameras
  66771. */
  66772. cameras?: ICamera[];
  66773. /**
  66774. * Names of glTF extensions used somewhere in this asset
  66775. */
  66776. extensionsUsed?: string[];
  66777. /**
  66778. * Names of glTF extensions required to properly load this asset
  66779. */
  66780. extensionsRequired?: string[];
  66781. /**
  66782. * An array of images. An image defines data used to create a texture
  66783. */
  66784. images?: IImage[];
  66785. /**
  66786. * An array of materials. A material defines the appearance of a primitive
  66787. */
  66788. materials?: IMaterial[];
  66789. /**
  66790. * An array of meshes. A mesh is a set of primitives to be rendered
  66791. */
  66792. meshes?: IMesh[];
  66793. /**
  66794. * An array of nodes
  66795. */
  66796. nodes?: INode[];
  66797. /**
  66798. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  66799. */
  66800. samplers?: ISampler[];
  66801. /**
  66802. * The index of the default scene
  66803. */
  66804. scene?: number;
  66805. /**
  66806. * An array of scenes
  66807. */
  66808. scenes?: IScene[];
  66809. /**
  66810. * An array of skins. A skin is defined by joints and matrices
  66811. */
  66812. skins?: ISkin[];
  66813. /**
  66814. * An array of textures
  66815. */
  66816. textures?: ITexture[];
  66817. }
  66818. /**
  66819. * The glTF validation results
  66820. */
  66821. interface IGLTFValidationResults {
  66822. info: {
  66823. generator: string;
  66824. hasAnimations: boolean;
  66825. hasDefaultScene: boolean;
  66826. hasMaterials: boolean;
  66827. hasMorphTargets: boolean;
  66828. hasSkins: boolean;
  66829. hasTextures: boolean;
  66830. maxAttributesUsed: number;
  66831. primitivesCount: number
  66832. };
  66833. issues: {
  66834. messages: Array<string>;
  66835. numErrors: number;
  66836. numHints: number;
  66837. numInfos: number;
  66838. numWarnings: number;
  66839. truncated: boolean
  66840. };
  66841. mimeType: string;
  66842. uri: string;
  66843. validatedAt: string;
  66844. validatorVersion: string;
  66845. }
  66846. /**
  66847. * The glTF validation options
  66848. */
  66849. interface IGLTFValidationOptions {
  66850. uri?: string;
  66851. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  66852. validateAccessorData?: boolean;
  66853. maxIssues?: number;
  66854. ignoredIssues?: Array<string>;
  66855. severityOverrides?: Object;
  66856. }
  66857. /**
  66858. * The glTF validator object
  66859. */
  66860. interface IGLTFValidator {
  66861. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  66862. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  66863. }
  66864. }
  66865. declare module BABYLON {
  66866. /** @hidden */
  66867. export var cellPixelShader: {
  66868. name: string;
  66869. shader: string;
  66870. };
  66871. }
  66872. declare module BABYLON {
  66873. /** @hidden */
  66874. export var cellVertexShader: {
  66875. name: string;
  66876. shader: string;
  66877. };
  66878. }
  66879. declare module BABYLON {
  66880. export class CellMaterial extends BABYLON.PushMaterial {
  66881. private _diffuseTexture;
  66882. diffuseTexture: BABYLON.BaseTexture;
  66883. diffuseColor: BABYLON.Color3;
  66884. _computeHighLevel: boolean;
  66885. computeHighLevel: boolean;
  66886. private _disableLighting;
  66887. disableLighting: boolean;
  66888. private _maxSimultaneousLights;
  66889. maxSimultaneousLights: number;
  66890. private _renderId;
  66891. constructor(name: string, scene: BABYLON.Scene);
  66892. needAlphaBlending(): boolean;
  66893. needAlphaTesting(): boolean;
  66894. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66895. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66896. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66897. getAnimatables(): BABYLON.IAnimatable[];
  66898. getActiveTextures(): BABYLON.BaseTexture[];
  66899. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66900. dispose(forceDisposeEffect?: boolean): void;
  66901. getClassName(): string;
  66902. clone(name: string): CellMaterial;
  66903. serialize(): any;
  66904. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  66905. }
  66906. }
  66907. declare module BABYLON {
  66908. export class CustomShaderStructure {
  66909. FragmentStore: string;
  66910. VertexStore: string;
  66911. constructor();
  66912. }
  66913. export class ShaderSpecialParts {
  66914. constructor();
  66915. Fragment_Begin: string;
  66916. Fragment_Definitions: string;
  66917. Fragment_MainBegin: string;
  66918. Fragment_Custom_Diffuse: string;
  66919. Fragment_Before_Lights: string;
  66920. Fragment_Before_Fog: string;
  66921. Fragment_Custom_Alpha: string;
  66922. Fragment_Before_FragColor: string;
  66923. Vertex_Begin: string;
  66924. Vertex_Definitions: string;
  66925. Vertex_MainBegin: string;
  66926. Vertex_Before_PositionUpdated: string;
  66927. Vertex_Before_NormalUpdated: string;
  66928. Vertex_MainEnd: string;
  66929. }
  66930. export class CustomMaterial extends BABYLON.StandardMaterial {
  66931. static ShaderIndexer: number;
  66932. CustomParts: ShaderSpecialParts;
  66933. _isCreatedShader: boolean;
  66934. _createdShaderName: string;
  66935. _customUniform: string[];
  66936. _newUniforms: string[];
  66937. _newUniformInstances: any[];
  66938. _newSamplerInstances: BABYLON.Texture[];
  66939. FragmentShader: string;
  66940. VertexShader: string;
  66941. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  66942. ReviewUniform(name: string, arr: string[]): string[];
  66943. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  66944. constructor(name: string, scene: BABYLON.Scene);
  66945. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  66946. Fragment_Begin(shaderPart: string): CustomMaterial;
  66947. Fragment_Definitions(shaderPart: string): CustomMaterial;
  66948. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  66949. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  66950. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  66951. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  66952. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  66953. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  66954. Vertex_Begin(shaderPart: string): CustomMaterial;
  66955. Vertex_Definitions(shaderPart: string): CustomMaterial;
  66956. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  66957. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  66958. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  66959. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  66960. }
  66961. }
  66962. declare module BABYLON {
  66963. export class ShaderAlebdoParts {
  66964. constructor();
  66965. Fragment_Begin: string;
  66966. Fragment_Definitions: string;
  66967. Fragment_MainBegin: string;
  66968. Fragment_Custom_Albedo: string;
  66969. Fragment_Before_Lights: string;
  66970. Fragment_Custom_MetallicRoughness: string;
  66971. Fragment_Custom_MicroSurface: string;
  66972. Fragment_Before_Fog: string;
  66973. Fragment_Custom_Alpha: string;
  66974. Fragment_Before_FragColor: string;
  66975. Vertex_Begin: string;
  66976. Vertex_Definitions: string;
  66977. Vertex_MainBegin: string;
  66978. Vertex_Before_PositionUpdated: string;
  66979. Vertex_Before_NormalUpdated: string;
  66980. Vertex_MainEnd: string;
  66981. }
  66982. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  66983. static ShaderIndexer: number;
  66984. CustomParts: ShaderAlebdoParts;
  66985. _isCreatedShader: boolean;
  66986. _createdShaderName: string;
  66987. _customUniform: string[];
  66988. _newUniforms: string[];
  66989. _newUniformInstances: any[];
  66990. _newSamplerInstances: BABYLON.Texture[];
  66991. FragmentShader: string;
  66992. VertexShader: string;
  66993. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  66994. ReviewUniform(name: string, arr: string[]): string[];
  66995. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  66996. constructor(name: string, scene: BABYLON.Scene);
  66997. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  66998. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  66999. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  67000. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  67001. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  67002. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  67003. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  67004. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  67005. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  67006. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  67007. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  67008. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  67009. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  67010. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  67011. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  67012. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  67013. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  67014. }
  67015. }
  67016. declare module BABYLON {
  67017. /** @hidden */
  67018. export var firePixelShader: {
  67019. name: string;
  67020. shader: string;
  67021. };
  67022. }
  67023. declare module BABYLON {
  67024. /** @hidden */
  67025. export var fireVertexShader: {
  67026. name: string;
  67027. shader: string;
  67028. };
  67029. }
  67030. declare module BABYLON {
  67031. export class FireMaterial extends BABYLON.PushMaterial {
  67032. private _diffuseTexture;
  67033. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67034. private _distortionTexture;
  67035. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67036. private _opacityTexture;
  67037. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67038. diffuseColor: BABYLON.Color3;
  67039. speed: number;
  67040. private _scaledDiffuse;
  67041. private _renderId;
  67042. private _lastTime;
  67043. constructor(name: string, scene: BABYLON.Scene);
  67044. needAlphaBlending(): boolean;
  67045. needAlphaTesting(): boolean;
  67046. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67047. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67048. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67049. getAnimatables(): BABYLON.IAnimatable[];
  67050. getActiveTextures(): BABYLON.BaseTexture[];
  67051. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67052. getClassName(): string;
  67053. dispose(forceDisposeEffect?: boolean): void;
  67054. clone(name: string): FireMaterial;
  67055. serialize(): any;
  67056. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  67057. }
  67058. }
  67059. declare module BABYLON {
  67060. /** @hidden */
  67061. export var furPixelShader: {
  67062. name: string;
  67063. shader: string;
  67064. };
  67065. }
  67066. declare module BABYLON {
  67067. /** @hidden */
  67068. export var furVertexShader: {
  67069. name: string;
  67070. shader: string;
  67071. };
  67072. }
  67073. declare module BABYLON {
  67074. export class FurMaterial extends BABYLON.PushMaterial {
  67075. private _diffuseTexture;
  67076. diffuseTexture: BABYLON.BaseTexture;
  67077. private _heightTexture;
  67078. heightTexture: BABYLON.BaseTexture;
  67079. diffuseColor: BABYLON.Color3;
  67080. furLength: number;
  67081. furAngle: number;
  67082. furColor: BABYLON.Color3;
  67083. furOffset: number;
  67084. furSpacing: number;
  67085. furGravity: BABYLON.Vector3;
  67086. furSpeed: number;
  67087. furDensity: number;
  67088. furOcclusion: number;
  67089. furTexture: BABYLON.DynamicTexture;
  67090. private _disableLighting;
  67091. disableLighting: boolean;
  67092. private _maxSimultaneousLights;
  67093. maxSimultaneousLights: number;
  67094. highLevelFur: boolean;
  67095. _meshes: BABYLON.AbstractMesh[];
  67096. private _renderId;
  67097. private _furTime;
  67098. constructor(name: string, scene: BABYLON.Scene);
  67099. furTime: number;
  67100. needAlphaBlending(): boolean;
  67101. needAlphaTesting(): boolean;
  67102. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67103. updateFur(): void;
  67104. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67105. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67106. getAnimatables(): BABYLON.IAnimatable[];
  67107. getActiveTextures(): BABYLON.BaseTexture[];
  67108. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67109. dispose(forceDisposeEffect?: boolean): void;
  67110. clone(name: string): FurMaterial;
  67111. serialize(): any;
  67112. getClassName(): string;
  67113. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  67114. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  67115. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  67116. }
  67117. }
  67118. declare module BABYLON {
  67119. /** @hidden */
  67120. export var gradientPixelShader: {
  67121. name: string;
  67122. shader: string;
  67123. };
  67124. }
  67125. declare module BABYLON {
  67126. /** @hidden */
  67127. export var gradientVertexShader: {
  67128. name: string;
  67129. shader: string;
  67130. };
  67131. }
  67132. declare module BABYLON {
  67133. export class GradientMaterial extends BABYLON.PushMaterial {
  67134. private _maxSimultaneousLights;
  67135. maxSimultaneousLights: number;
  67136. topColor: BABYLON.Color3;
  67137. topColorAlpha: number;
  67138. bottomColor: BABYLON.Color3;
  67139. bottomColorAlpha: number;
  67140. offset: number;
  67141. scale: number;
  67142. smoothness: number;
  67143. private _disableLighting;
  67144. disableLighting: boolean;
  67145. private _renderId;
  67146. constructor(name: string, scene: BABYLON.Scene);
  67147. needAlphaBlending(): boolean;
  67148. needAlphaTesting(): boolean;
  67149. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67150. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67151. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67152. getAnimatables(): BABYLON.IAnimatable[];
  67153. dispose(forceDisposeEffect?: boolean): void;
  67154. clone(name: string): GradientMaterial;
  67155. serialize(): any;
  67156. getClassName(): string;
  67157. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  67158. }
  67159. }
  67160. declare module BABYLON {
  67161. /** @hidden */
  67162. export var gridPixelShader: {
  67163. name: string;
  67164. shader: string;
  67165. };
  67166. }
  67167. declare module BABYLON {
  67168. /** @hidden */
  67169. export var gridVertexShader: {
  67170. name: string;
  67171. shader: string;
  67172. };
  67173. }
  67174. declare module BABYLON {
  67175. /**
  67176. * The grid materials allows you to wrap any shape with a grid.
  67177. * Colors are customizable.
  67178. */
  67179. export class GridMaterial extends BABYLON.PushMaterial {
  67180. /**
  67181. * Main color of the grid (e.g. between lines)
  67182. */
  67183. mainColor: BABYLON.Color3;
  67184. /**
  67185. * Color of the grid lines.
  67186. */
  67187. lineColor: BABYLON.Color3;
  67188. /**
  67189. * The scale of the grid compared to unit.
  67190. */
  67191. gridRatio: number;
  67192. /**
  67193. * Allows setting an offset for the grid lines.
  67194. */
  67195. gridOffset: BABYLON.Vector3;
  67196. /**
  67197. * The frequency of thicker lines.
  67198. */
  67199. majorUnitFrequency: number;
  67200. /**
  67201. * The visibility of minor units in the grid.
  67202. */
  67203. minorUnitVisibility: number;
  67204. /**
  67205. * The grid opacity outside of the lines.
  67206. */
  67207. opacity: number;
  67208. /**
  67209. * Determine RBG output is premultiplied by alpha value.
  67210. */
  67211. preMultiplyAlpha: boolean;
  67212. private _opacityTexture;
  67213. opacityTexture: BABYLON.BaseTexture;
  67214. private _gridControl;
  67215. private _renderId;
  67216. /**
  67217. * constructor
  67218. * @param name The name given to the material in order to identify it afterwards.
  67219. * @param scene The scene the material is used in.
  67220. */
  67221. constructor(name: string, scene: BABYLON.Scene);
  67222. /**
  67223. * Returns wehter or not the grid requires alpha blending.
  67224. */
  67225. needAlphaBlending(): boolean;
  67226. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  67227. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67228. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67229. /**
  67230. * Dispose the material and its associated resources.
  67231. * @param forceDisposeEffect will also dispose the used effect when true
  67232. */
  67233. dispose(forceDisposeEffect?: boolean): void;
  67234. clone(name: string): GridMaterial;
  67235. serialize(): any;
  67236. getClassName(): string;
  67237. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  67238. }
  67239. }
  67240. declare module BABYLON {
  67241. /** @hidden */
  67242. export var lavaPixelShader: {
  67243. name: string;
  67244. shader: string;
  67245. };
  67246. }
  67247. declare module BABYLON {
  67248. /** @hidden */
  67249. export var lavaVertexShader: {
  67250. name: string;
  67251. shader: string;
  67252. };
  67253. }
  67254. declare module BABYLON {
  67255. export class LavaMaterial extends BABYLON.PushMaterial {
  67256. private _diffuseTexture;
  67257. diffuseTexture: BABYLON.BaseTexture;
  67258. noiseTexture: BABYLON.BaseTexture;
  67259. fogColor: BABYLON.Color3;
  67260. speed: number;
  67261. movingSpeed: number;
  67262. lowFrequencySpeed: number;
  67263. fogDensity: number;
  67264. private _lastTime;
  67265. diffuseColor: BABYLON.Color3;
  67266. private _disableLighting;
  67267. disableLighting: boolean;
  67268. private _unlit;
  67269. unlit: boolean;
  67270. private _maxSimultaneousLights;
  67271. maxSimultaneousLights: number;
  67272. private _scaledDiffuse;
  67273. private _renderId;
  67274. constructor(name: string, scene: BABYLON.Scene);
  67275. needAlphaBlending(): boolean;
  67276. needAlphaTesting(): boolean;
  67277. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67278. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67279. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67280. getAnimatables(): BABYLON.IAnimatable[];
  67281. getActiveTextures(): BABYLON.BaseTexture[];
  67282. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67283. dispose(forceDisposeEffect?: boolean): void;
  67284. clone(name: string): LavaMaterial;
  67285. serialize(): any;
  67286. getClassName(): string;
  67287. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  67288. }
  67289. }
  67290. declare module BABYLON {
  67291. /** @hidden */
  67292. export var mixPixelShader: {
  67293. name: string;
  67294. shader: string;
  67295. };
  67296. }
  67297. declare module BABYLON {
  67298. /** @hidden */
  67299. export var mixVertexShader: {
  67300. name: string;
  67301. shader: string;
  67302. };
  67303. }
  67304. declare module BABYLON {
  67305. export class MixMaterial extends BABYLON.PushMaterial {
  67306. /**
  67307. * Mix textures
  67308. */
  67309. private _mixTexture1;
  67310. mixTexture1: BABYLON.BaseTexture;
  67311. private _mixTexture2;
  67312. mixTexture2: BABYLON.BaseTexture;
  67313. /**
  67314. * Diffuse textures
  67315. */
  67316. private _diffuseTexture1;
  67317. diffuseTexture1: BABYLON.Texture;
  67318. private _diffuseTexture2;
  67319. diffuseTexture2: BABYLON.Texture;
  67320. private _diffuseTexture3;
  67321. diffuseTexture3: BABYLON.Texture;
  67322. private _diffuseTexture4;
  67323. diffuseTexture4: BABYLON.Texture;
  67324. private _diffuseTexture5;
  67325. diffuseTexture5: BABYLON.Texture;
  67326. private _diffuseTexture6;
  67327. diffuseTexture6: BABYLON.Texture;
  67328. private _diffuseTexture7;
  67329. diffuseTexture7: BABYLON.Texture;
  67330. private _diffuseTexture8;
  67331. diffuseTexture8: BABYLON.Texture;
  67332. /**
  67333. * Uniforms
  67334. */
  67335. diffuseColor: BABYLON.Color3;
  67336. specularColor: BABYLON.Color3;
  67337. specularPower: number;
  67338. private _disableLighting;
  67339. disableLighting: boolean;
  67340. private _maxSimultaneousLights;
  67341. maxSimultaneousLights: number;
  67342. private _renderId;
  67343. constructor(name: string, scene: BABYLON.Scene);
  67344. needAlphaBlending(): boolean;
  67345. needAlphaTesting(): boolean;
  67346. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67347. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67348. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67349. getAnimatables(): BABYLON.IAnimatable[];
  67350. getActiveTextures(): BABYLON.BaseTexture[];
  67351. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67352. dispose(forceDisposeEffect?: boolean): void;
  67353. clone(name: string): MixMaterial;
  67354. serialize(): any;
  67355. getClassName(): string;
  67356. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  67357. }
  67358. }
  67359. declare module BABYLON {
  67360. /** @hidden */
  67361. export var normalPixelShader: {
  67362. name: string;
  67363. shader: string;
  67364. };
  67365. }
  67366. declare module BABYLON {
  67367. /** @hidden */
  67368. export var normalVertexShader: {
  67369. name: string;
  67370. shader: string;
  67371. };
  67372. }
  67373. declare module BABYLON {
  67374. export class NormalMaterial extends BABYLON.PushMaterial {
  67375. private _diffuseTexture;
  67376. diffuseTexture: BABYLON.BaseTexture;
  67377. diffuseColor: BABYLON.Color3;
  67378. private _disableLighting;
  67379. disableLighting: boolean;
  67380. private _maxSimultaneousLights;
  67381. maxSimultaneousLights: number;
  67382. private _renderId;
  67383. constructor(name: string, scene: BABYLON.Scene);
  67384. needAlphaBlending(): boolean;
  67385. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  67386. needAlphaTesting(): boolean;
  67387. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67388. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67389. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67390. getAnimatables(): BABYLON.IAnimatable[];
  67391. getActiveTextures(): BABYLON.BaseTexture[];
  67392. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67393. dispose(forceDisposeEffect?: boolean): void;
  67394. clone(name: string): NormalMaterial;
  67395. serialize(): any;
  67396. getClassName(): string;
  67397. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  67398. }
  67399. }
  67400. declare module BABYLON {
  67401. /** @hidden */
  67402. export var shadowOnlyPixelShader: {
  67403. name: string;
  67404. shader: string;
  67405. };
  67406. }
  67407. declare module BABYLON {
  67408. /** @hidden */
  67409. export var shadowOnlyVertexShader: {
  67410. name: string;
  67411. shader: string;
  67412. };
  67413. }
  67414. declare module BABYLON {
  67415. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  67416. private _renderId;
  67417. private _activeLight;
  67418. constructor(name: string, scene: BABYLON.Scene);
  67419. shadowColor: BABYLON.Color3;
  67420. needAlphaBlending(): boolean;
  67421. needAlphaTesting(): boolean;
  67422. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67423. activeLight: BABYLON.IShadowLight;
  67424. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67425. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67426. clone(name: string): ShadowOnlyMaterial;
  67427. serialize(): any;
  67428. getClassName(): string;
  67429. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  67430. }
  67431. }
  67432. declare module BABYLON {
  67433. /** @hidden */
  67434. export var simplePixelShader: {
  67435. name: string;
  67436. shader: string;
  67437. };
  67438. }
  67439. declare module BABYLON {
  67440. /** @hidden */
  67441. export var simpleVertexShader: {
  67442. name: string;
  67443. shader: string;
  67444. };
  67445. }
  67446. declare module BABYLON {
  67447. export class SimpleMaterial extends BABYLON.PushMaterial {
  67448. private _diffuseTexture;
  67449. diffuseTexture: BABYLON.BaseTexture;
  67450. diffuseColor: BABYLON.Color3;
  67451. private _disableLighting;
  67452. disableLighting: boolean;
  67453. private _maxSimultaneousLights;
  67454. maxSimultaneousLights: number;
  67455. private _renderId;
  67456. constructor(name: string, scene: BABYLON.Scene);
  67457. needAlphaBlending(): boolean;
  67458. needAlphaTesting(): boolean;
  67459. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67460. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67461. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67462. getAnimatables(): BABYLON.IAnimatable[];
  67463. getActiveTextures(): BABYLON.BaseTexture[];
  67464. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67465. dispose(forceDisposeEffect?: boolean): void;
  67466. clone(name: string): SimpleMaterial;
  67467. serialize(): any;
  67468. getClassName(): string;
  67469. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  67470. }
  67471. }
  67472. declare module BABYLON {
  67473. /** @hidden */
  67474. export var skyPixelShader: {
  67475. name: string;
  67476. shader: string;
  67477. };
  67478. }
  67479. declare module BABYLON {
  67480. /** @hidden */
  67481. export var skyVertexShader: {
  67482. name: string;
  67483. shader: string;
  67484. };
  67485. }
  67486. declare module BABYLON {
  67487. /**
  67488. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  67489. * @see https://doc.babylonjs.com/extensions/sky
  67490. */
  67491. export class SkyMaterial extends BABYLON.PushMaterial {
  67492. /**
  67493. * Defines the overall luminance of sky in interval ]0, 1[.
  67494. */
  67495. luminance: number;
  67496. /**
  67497. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  67498. */
  67499. turbidity: number;
  67500. /**
  67501. * Defines the sky appearance (light intensity).
  67502. */
  67503. rayleigh: number;
  67504. /**
  67505. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  67506. */
  67507. mieCoefficient: number;
  67508. /**
  67509. * Defines the amount of haze particles following the Mie scattering theory.
  67510. */
  67511. mieDirectionalG: number;
  67512. /**
  67513. * Defines the distance of the sun according to the active scene camera.
  67514. */
  67515. distance: number;
  67516. /**
  67517. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  67518. * "inclined".
  67519. */
  67520. inclination: number;
  67521. /**
  67522. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  67523. * an object direction and a reference direction.
  67524. */
  67525. azimuth: number;
  67526. /**
  67527. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  67528. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  67529. */
  67530. sunPosition: BABYLON.Vector3;
  67531. /**
  67532. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  67533. * .sunPosition property.
  67534. */
  67535. useSunPosition: boolean;
  67536. /**
  67537. * Defines an offset vector used to get a horizon offset.
  67538. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  67539. */
  67540. cameraOffset: BABYLON.Vector3;
  67541. private _cameraPosition;
  67542. private _renderId;
  67543. /**
  67544. * Instantiates a new sky material.
  67545. * This material allows to create dynamic and texture free
  67546. * effects for skyboxes by taking care of the atmosphere state.
  67547. * @see https://doc.babylonjs.com/extensions/sky
  67548. * @param name Define the name of the material in the scene
  67549. * @param scene Define the scene the material belong to
  67550. */
  67551. constructor(name: string, scene: BABYLON.Scene);
  67552. /**
  67553. * Specifies if the material will require alpha blending
  67554. * @returns a boolean specifying if alpha blending is needed
  67555. */
  67556. needAlphaBlending(): boolean;
  67557. /**
  67558. * Specifies if this material should be rendered in alpha test mode
  67559. * @returns false as the sky material doesn't need alpha testing.
  67560. */
  67561. needAlphaTesting(): boolean;
  67562. /**
  67563. * Get the texture used for alpha test purpose.
  67564. * @returns null as the sky material has no texture.
  67565. */
  67566. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67567. /**
  67568. * Get if the submesh is ready to be used and all its information available.
  67569. * Child classes can use it to update shaders
  67570. * @param mesh defines the mesh to check
  67571. * @param subMesh defines which submesh to check
  67572. * @param useInstances specifies that instances should be used
  67573. * @returns a boolean indicating that the submesh is ready or not
  67574. */
  67575. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67576. /**
  67577. * Binds the submesh to this material by preparing the effect and shader to draw
  67578. * @param world defines the world transformation matrix
  67579. * @param mesh defines the mesh containing the submesh
  67580. * @param subMesh defines the submesh to bind the material to
  67581. */
  67582. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67583. /**
  67584. * Get the list of animatables in the material.
  67585. * @returns the list of animatables object used in the material
  67586. */
  67587. getAnimatables(): BABYLON.IAnimatable[];
  67588. /**
  67589. * Disposes the material
  67590. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  67591. */
  67592. dispose(forceDisposeEffect?: boolean): void;
  67593. /**
  67594. * Makes a duplicate of the material, and gives it a new name
  67595. * @param name defines the new name for the duplicated material
  67596. * @returns the cloned material
  67597. */
  67598. clone(name: string): SkyMaterial;
  67599. /**
  67600. * Serializes this material in a JSON representation
  67601. * @returns the serialized material object
  67602. */
  67603. serialize(): any;
  67604. /**
  67605. * Gets the current class name of the material e.g. "SkyMaterial"
  67606. * Mainly use in serialization.
  67607. * @returns the class name
  67608. */
  67609. getClassName(): string;
  67610. /**
  67611. * Creates a sky material from parsed material data
  67612. * @param source defines the JSON representation of the material
  67613. * @param scene defines the hosting scene
  67614. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67615. * @returns a new sky material
  67616. */
  67617. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  67618. }
  67619. }
  67620. declare module BABYLON {
  67621. /** @hidden */
  67622. export var terrainPixelShader: {
  67623. name: string;
  67624. shader: string;
  67625. };
  67626. }
  67627. declare module BABYLON {
  67628. /** @hidden */
  67629. export var terrainVertexShader: {
  67630. name: string;
  67631. shader: string;
  67632. };
  67633. }
  67634. declare module BABYLON {
  67635. export class TerrainMaterial extends BABYLON.PushMaterial {
  67636. private _mixTexture;
  67637. mixTexture: BABYLON.BaseTexture;
  67638. private _diffuseTexture1;
  67639. diffuseTexture1: BABYLON.Texture;
  67640. private _diffuseTexture2;
  67641. diffuseTexture2: BABYLON.Texture;
  67642. private _diffuseTexture3;
  67643. diffuseTexture3: BABYLON.Texture;
  67644. private _bumpTexture1;
  67645. bumpTexture1: BABYLON.Texture;
  67646. private _bumpTexture2;
  67647. bumpTexture2: BABYLON.Texture;
  67648. private _bumpTexture3;
  67649. bumpTexture3: BABYLON.Texture;
  67650. diffuseColor: BABYLON.Color3;
  67651. specularColor: BABYLON.Color3;
  67652. specularPower: number;
  67653. private _disableLighting;
  67654. disableLighting: boolean;
  67655. private _maxSimultaneousLights;
  67656. maxSimultaneousLights: number;
  67657. private _renderId;
  67658. constructor(name: string, scene: BABYLON.Scene);
  67659. needAlphaBlending(): boolean;
  67660. needAlphaTesting(): boolean;
  67661. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67662. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67663. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67664. getAnimatables(): BABYLON.IAnimatable[];
  67665. getActiveTextures(): BABYLON.BaseTexture[];
  67666. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67667. dispose(forceDisposeEffect?: boolean): void;
  67668. clone(name: string): TerrainMaterial;
  67669. serialize(): any;
  67670. getClassName(): string;
  67671. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  67672. }
  67673. }
  67674. declare module BABYLON {
  67675. /** @hidden */
  67676. export var triplanarPixelShader: {
  67677. name: string;
  67678. shader: string;
  67679. };
  67680. }
  67681. declare module BABYLON {
  67682. /** @hidden */
  67683. export var triplanarVertexShader: {
  67684. name: string;
  67685. shader: string;
  67686. };
  67687. }
  67688. declare module BABYLON {
  67689. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  67690. mixTexture: BABYLON.BaseTexture;
  67691. private _diffuseTextureX;
  67692. diffuseTextureX: BABYLON.BaseTexture;
  67693. private _diffuseTextureY;
  67694. diffuseTextureY: BABYLON.BaseTexture;
  67695. private _diffuseTextureZ;
  67696. diffuseTextureZ: BABYLON.BaseTexture;
  67697. private _normalTextureX;
  67698. normalTextureX: BABYLON.BaseTexture;
  67699. private _normalTextureY;
  67700. normalTextureY: BABYLON.BaseTexture;
  67701. private _normalTextureZ;
  67702. normalTextureZ: BABYLON.BaseTexture;
  67703. tileSize: number;
  67704. diffuseColor: BABYLON.Color3;
  67705. specularColor: BABYLON.Color3;
  67706. specularPower: number;
  67707. private _disableLighting;
  67708. disableLighting: boolean;
  67709. private _maxSimultaneousLights;
  67710. maxSimultaneousLights: number;
  67711. private _renderId;
  67712. constructor(name: string, scene: BABYLON.Scene);
  67713. needAlphaBlending(): boolean;
  67714. needAlphaTesting(): boolean;
  67715. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67716. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67717. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67718. getAnimatables(): BABYLON.IAnimatable[];
  67719. getActiveTextures(): BABYLON.BaseTexture[];
  67720. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67721. dispose(forceDisposeEffect?: boolean): void;
  67722. clone(name: string): TriPlanarMaterial;
  67723. serialize(): any;
  67724. getClassName(): string;
  67725. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  67726. }
  67727. }
  67728. declare module BABYLON {
  67729. /** @hidden */
  67730. export var waterPixelShader: {
  67731. name: string;
  67732. shader: string;
  67733. };
  67734. }
  67735. declare module BABYLON {
  67736. /** @hidden */
  67737. export var waterVertexShader: {
  67738. name: string;
  67739. shader: string;
  67740. };
  67741. }
  67742. declare module BABYLON {
  67743. export class WaterMaterial extends BABYLON.PushMaterial {
  67744. renderTargetSize: BABYLON.Vector2;
  67745. private _bumpTexture;
  67746. bumpTexture: BABYLON.BaseTexture;
  67747. diffuseColor: BABYLON.Color3;
  67748. specularColor: BABYLON.Color3;
  67749. specularPower: number;
  67750. private _disableLighting;
  67751. disableLighting: boolean;
  67752. private _maxSimultaneousLights;
  67753. maxSimultaneousLights: number;
  67754. /**
  67755. * @param {number}: Represents the wind force
  67756. */
  67757. windForce: number;
  67758. /**
  67759. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  67760. */
  67761. windDirection: BABYLON.Vector2;
  67762. /**
  67763. * @param {number}: Wave height, represents the height of the waves
  67764. */
  67765. waveHeight: number;
  67766. /**
  67767. * @param {number}: Bump height, represents the bump height related to the bump map
  67768. */
  67769. bumpHeight: number;
  67770. /**
  67771. * @param {boolean}: Add a smaller moving bump to less steady waves.
  67772. */
  67773. private _bumpSuperimpose;
  67774. bumpSuperimpose: boolean;
  67775. /**
  67776. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  67777. */
  67778. private _fresnelSeparate;
  67779. fresnelSeparate: boolean;
  67780. /**
  67781. * @param {boolean}: bump Waves modify the reflection.
  67782. */
  67783. private _bumpAffectsReflection;
  67784. bumpAffectsReflection: boolean;
  67785. /**
  67786. * @param {number}: The water color blended with the refraction (near)
  67787. */
  67788. waterColor: BABYLON.Color3;
  67789. /**
  67790. * @param {number}: The blend factor related to the water color
  67791. */
  67792. colorBlendFactor: number;
  67793. /**
  67794. * @param {number}: The water color blended with the reflection (far)
  67795. */
  67796. waterColor2: BABYLON.Color3;
  67797. /**
  67798. * @param {number}: The blend factor related to the water color (reflection, far)
  67799. */
  67800. colorBlendFactor2: number;
  67801. /**
  67802. * @param {number}: Represents the maximum length of a wave
  67803. */
  67804. waveLength: number;
  67805. /**
  67806. * @param {number}: Defines the waves speed
  67807. */
  67808. waveSpeed: number;
  67809. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  67810. private _mesh;
  67811. private _refractionRTT;
  67812. private _reflectionRTT;
  67813. private _reflectionTransform;
  67814. private _lastTime;
  67815. private _lastDeltaTime;
  67816. private _renderId;
  67817. private _useLogarithmicDepth;
  67818. private _waitingRenderList;
  67819. /**
  67820. * Gets a boolean indicating that current material needs to register RTT
  67821. */
  67822. readonly hasRenderTargetTextures: boolean;
  67823. /**
  67824. * Constructor
  67825. */
  67826. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  67827. useLogarithmicDepth: boolean;
  67828. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  67829. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  67830. addToRenderList(node: any): void;
  67831. enableRenderTargets(enable: boolean): void;
  67832. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  67833. readonly renderTargetsEnabled: boolean;
  67834. needAlphaBlending(): boolean;
  67835. needAlphaTesting(): boolean;
  67836. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67837. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67838. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67839. private _createRenderTargets;
  67840. getAnimatables(): BABYLON.IAnimatable[];
  67841. getActiveTextures(): BABYLON.BaseTexture[];
  67842. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67843. dispose(forceDisposeEffect?: boolean): void;
  67844. clone(name: string): WaterMaterial;
  67845. serialize(): any;
  67846. getClassName(): string;
  67847. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  67848. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  67849. }
  67850. }
  67851. declare module BABYLON {
  67852. /** @hidden */
  67853. export var asciiartPixelShader: {
  67854. name: string;
  67855. shader: string;
  67856. };
  67857. }
  67858. declare module BABYLON {
  67859. /**
  67860. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  67861. *
  67862. * It basically takes care rendering the font front the given font size to a texture.
  67863. * This is used later on in the postprocess.
  67864. */
  67865. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  67866. private _font;
  67867. private _text;
  67868. private _charSize;
  67869. /**
  67870. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  67871. */
  67872. readonly charSize: number;
  67873. /**
  67874. * Create a new instance of the Ascii Art FontTexture class
  67875. * @param name the name of the texture
  67876. * @param font the font to use, use the W3C CSS notation
  67877. * @param text the caracter set to use in the rendering.
  67878. * @param scene the scene that owns the texture
  67879. */
  67880. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  67881. /**
  67882. * Gets the max char width of a font.
  67883. * @param font the font to use, use the W3C CSS notation
  67884. * @return the max char width
  67885. */
  67886. private getFontWidth;
  67887. /**
  67888. * Gets the max char height of a font.
  67889. * @param font the font to use, use the W3C CSS notation
  67890. * @return the max char height
  67891. */
  67892. private getFontHeight;
  67893. /**
  67894. * Clones the current AsciiArtTexture.
  67895. * @return the clone of the texture.
  67896. */
  67897. clone(): AsciiArtFontTexture;
  67898. /**
  67899. * Parses a json object representing the texture and returns an instance of it.
  67900. * @param source the source JSON representation
  67901. * @param scene the scene to create the texture for
  67902. * @return the parsed texture
  67903. */
  67904. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  67905. }
  67906. /**
  67907. * Option available in the Ascii Art Post Process.
  67908. */
  67909. export interface IAsciiArtPostProcessOptions {
  67910. /**
  67911. * The font to use following the w3c font definition.
  67912. */
  67913. font?: string;
  67914. /**
  67915. * The character set to use in the postprocess.
  67916. */
  67917. characterSet?: string;
  67918. /**
  67919. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  67920. * This number is defined between 0 and 1;
  67921. */
  67922. mixToTile?: number;
  67923. /**
  67924. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  67925. * This number is defined between 0 and 1;
  67926. */
  67927. mixToNormal?: number;
  67928. }
  67929. /**
  67930. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  67931. *
  67932. * Simmply add it to your scene and let the nerd that lives in you have fun.
  67933. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  67934. */
  67935. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  67936. /**
  67937. * The font texture used to render the char in the post process.
  67938. */
  67939. private _asciiArtFontTexture;
  67940. /**
  67941. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  67942. * This number is defined between 0 and 1;
  67943. */
  67944. mixToTile: number;
  67945. /**
  67946. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  67947. * This number is defined between 0 and 1;
  67948. */
  67949. mixToNormal: number;
  67950. /**
  67951. * Instantiates a new Ascii Art Post Process.
  67952. * @param name the name to give to the postprocess
  67953. * @camera the camera to apply the post process to.
  67954. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  67955. */
  67956. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  67957. }
  67958. }
  67959. declare module BABYLON {
  67960. /** @hidden */
  67961. export var digitalrainPixelShader: {
  67962. name: string;
  67963. shader: string;
  67964. };
  67965. }
  67966. declare module BABYLON {
  67967. /**
  67968. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  67969. *
  67970. * It basically takes care rendering the font front the given font size to a texture.
  67971. * This is used later on in the postprocess.
  67972. */
  67973. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  67974. private _font;
  67975. private _text;
  67976. private _charSize;
  67977. /**
  67978. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  67979. */
  67980. readonly charSize: number;
  67981. /**
  67982. * Create a new instance of the Digital Rain FontTexture class
  67983. * @param name the name of the texture
  67984. * @param font the font to use, use the W3C CSS notation
  67985. * @param text the caracter set to use in the rendering.
  67986. * @param scene the scene that owns the texture
  67987. */
  67988. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  67989. /**
  67990. * Gets the max char width of a font.
  67991. * @param font the font to use, use the W3C CSS notation
  67992. * @return the max char width
  67993. */
  67994. private getFontWidth;
  67995. /**
  67996. * Gets the max char height of a font.
  67997. * @param font the font to use, use the W3C CSS notation
  67998. * @return the max char height
  67999. */
  68000. private getFontHeight;
  68001. /**
  68002. * Clones the current DigitalRainFontTexture.
  68003. * @return the clone of the texture.
  68004. */
  68005. clone(): DigitalRainFontTexture;
  68006. /**
  68007. * Parses a json object representing the texture and returns an instance of it.
  68008. * @param source the source JSON representation
  68009. * @param scene the scene to create the texture for
  68010. * @return the parsed texture
  68011. */
  68012. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  68013. }
  68014. /**
  68015. * Option available in the Digital Rain Post Process.
  68016. */
  68017. export interface IDigitalRainPostProcessOptions {
  68018. /**
  68019. * The font to use following the w3c font definition.
  68020. */
  68021. font?: string;
  68022. /**
  68023. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  68024. * This number is defined between 0 and 1;
  68025. */
  68026. mixToTile?: number;
  68027. /**
  68028. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  68029. * This number is defined between 0 and 1;
  68030. */
  68031. mixToNormal?: number;
  68032. }
  68033. /**
  68034. * DigitalRainPostProcess helps rendering everithing in digital rain.
  68035. *
  68036. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68037. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  68038. */
  68039. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  68040. /**
  68041. * The font texture used to render the char in the post process.
  68042. */
  68043. private _digitalRainFontTexture;
  68044. /**
  68045. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  68046. * This number is defined between 0 and 1;
  68047. */
  68048. mixToTile: number;
  68049. /**
  68050. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  68051. * This number is defined between 0 and 1;
  68052. */
  68053. mixToNormal: number;
  68054. /**
  68055. * Instantiates a new Digital Rain Post Process.
  68056. * @param name the name to give to the postprocess
  68057. * @camera the camera to apply the post process to.
  68058. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  68059. */
  68060. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  68061. }
  68062. }
  68063. declare module BABYLON {
  68064. /** @hidden */
  68065. export var oceanPostProcessPixelShader: {
  68066. name: string;
  68067. shader: string;
  68068. };
  68069. }
  68070. declare module BABYLON {
  68071. /**
  68072. * Option available in the Ocean Post Process.
  68073. */
  68074. export interface IOceanPostProcessOptions {
  68075. /**
  68076. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  68077. */
  68078. reflectionSize?: number | {
  68079. width: number;
  68080. height: number;
  68081. } | {
  68082. ratio: number;
  68083. };
  68084. /**
  68085. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  68086. */
  68087. refractionSize?: number | {
  68088. width: number;
  68089. height: number;
  68090. } | {
  68091. ratio: number;
  68092. };
  68093. }
  68094. /**
  68095. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  68096. *
  68097. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68098. * Example usage:
  68099. * var pp = new OceanPostProcess("myOcean", camera);
  68100. * pp.reflectionEnabled = true;
  68101. * pp.refractionEnabled = true;
  68102. */
  68103. export class OceanPostProcess extends BABYLON.PostProcess {
  68104. /**
  68105. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  68106. */
  68107. /**
  68108. * Sets weither or not the real-time reflection is enabled on the ocean.
  68109. * Is set to true, the reflection mirror texture will be used as reflection texture.
  68110. */
  68111. reflectionEnabled: boolean;
  68112. /**
  68113. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  68114. */
  68115. /**
  68116. * Sets weither or not the real-time refraction is enabled on the ocean.
  68117. * Is set to true, the refraction render target texture will be used as refraction texture.
  68118. */
  68119. refractionEnabled: boolean;
  68120. /**
  68121. * Gets wether or not the post-processes is supported by the running hardware.
  68122. * This requires draw buffer supports.
  68123. */
  68124. readonly isSupported: boolean;
  68125. /**
  68126. * This is the reflection mirror texture used to display reflections on the ocean.
  68127. * By default, render list is empty.
  68128. */
  68129. reflectionTexture: BABYLON.MirrorTexture;
  68130. /**
  68131. * This is the refraction render target texture used to display refraction on the ocean.
  68132. * By default, render list is empty.
  68133. */
  68134. refractionTexture: BABYLON.RenderTargetTexture;
  68135. private _time;
  68136. private _cameraRotation;
  68137. private _cameraViewMatrix;
  68138. private _reflectionEnabled;
  68139. private _refractionEnabled;
  68140. private _geometryRenderer;
  68141. /**
  68142. * Instantiates a new Ocean Post Process.
  68143. * @param name the name to give to the postprocess.
  68144. * @camera the camera to apply the post process to.
  68145. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  68146. */
  68147. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  68148. /**
  68149. * Returns the appropriate defines according to the current configuration.
  68150. */
  68151. private _getDefines;
  68152. /**
  68153. * Computes the current camera rotation as the shader requires a camera rotation.
  68154. */
  68155. private _computeCameraRotation;
  68156. }
  68157. }
  68158. declare module BABYLON {
  68159. /** @hidden */
  68160. export var brickProceduralTexturePixelShader: {
  68161. name: string;
  68162. shader: string;
  68163. };
  68164. }
  68165. declare module BABYLON {
  68166. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  68167. private _numberOfBricksHeight;
  68168. private _numberOfBricksWidth;
  68169. private _jointColor;
  68170. private _brickColor;
  68171. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68172. updateShaderUniforms(): void;
  68173. numberOfBricksHeight: number;
  68174. numberOfBricksWidth: number;
  68175. jointColor: BABYLON.Color3;
  68176. brickColor: BABYLON.Color3;
  68177. /**
  68178. * Serializes this brick procedural texture
  68179. * @returns a serialized brick procedural texture object
  68180. */
  68181. serialize(): any;
  68182. /**
  68183. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  68184. * @param parsedTexture defines parsed texture data
  68185. * @param scene defines the current scene
  68186. * @param rootUrl defines the root URL containing brick procedural texture information
  68187. * @returns a parsed Brick Procedural BABYLON.Texture
  68188. */
  68189. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  68190. }
  68191. }
  68192. declare module BABYLON {
  68193. /** @hidden */
  68194. export var cloudProceduralTexturePixelShader: {
  68195. name: string;
  68196. shader: string;
  68197. };
  68198. }
  68199. declare module BABYLON {
  68200. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  68201. private _skyColor;
  68202. private _cloudColor;
  68203. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68204. updateShaderUniforms(): void;
  68205. skyColor: BABYLON.Color4;
  68206. cloudColor: BABYLON.Color4;
  68207. /**
  68208. * Serializes this cloud procedural texture
  68209. * @returns a serialized cloud procedural texture object
  68210. */
  68211. serialize(): any;
  68212. /**
  68213. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  68214. * @param parsedTexture defines parsed texture data
  68215. * @param scene defines the current scene
  68216. * @param rootUrl defines the root URL containing cloud procedural texture information
  68217. * @returns a parsed Cloud Procedural BABYLON.Texture
  68218. */
  68219. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  68220. }
  68221. }
  68222. declare module BABYLON {
  68223. /** @hidden */
  68224. export var fireProceduralTexturePixelShader: {
  68225. name: string;
  68226. shader: string;
  68227. };
  68228. }
  68229. declare module BABYLON {
  68230. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  68231. private _time;
  68232. private _speed;
  68233. private _autoGenerateTime;
  68234. private _fireColors;
  68235. private _alphaThreshold;
  68236. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68237. updateShaderUniforms(): void;
  68238. render(useCameraPostProcess?: boolean): void;
  68239. static readonly PurpleFireColors: BABYLON.Color3[];
  68240. static readonly GreenFireColors: BABYLON.Color3[];
  68241. static readonly RedFireColors: BABYLON.Color3[];
  68242. static readonly BlueFireColors: BABYLON.Color3[];
  68243. autoGenerateTime: boolean;
  68244. fireColors: BABYLON.Color3[];
  68245. time: number;
  68246. speed: BABYLON.Vector2;
  68247. alphaThreshold: number;
  68248. /**
  68249. * Serializes this fire procedural texture
  68250. * @returns a serialized fire procedural texture object
  68251. */
  68252. serialize(): any;
  68253. /**
  68254. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  68255. * @param parsedTexture defines parsed texture data
  68256. * @param scene defines the current scene
  68257. * @param rootUrl defines the root URL containing fire procedural texture information
  68258. * @returns a parsed Fire Procedural BABYLON.Texture
  68259. */
  68260. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  68261. }
  68262. }
  68263. declare module BABYLON {
  68264. /** @hidden */
  68265. export var grassProceduralTexturePixelShader: {
  68266. name: string;
  68267. shader: string;
  68268. };
  68269. }
  68270. declare module BABYLON {
  68271. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  68272. private _grassColors;
  68273. private _groundColor;
  68274. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68275. updateShaderUniforms(): void;
  68276. grassColors: BABYLON.Color3[];
  68277. groundColor: BABYLON.Color3;
  68278. /**
  68279. * Serializes this grass procedural texture
  68280. * @returns a serialized grass procedural texture object
  68281. */
  68282. serialize(): any;
  68283. /**
  68284. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  68285. * @param parsedTexture defines parsed texture data
  68286. * @param scene defines the current scene
  68287. * @param rootUrl defines the root URL containing grass procedural texture information
  68288. * @returns a parsed Grass Procedural BABYLON.Texture
  68289. */
  68290. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  68291. }
  68292. }
  68293. declare module BABYLON {
  68294. /** @hidden */
  68295. export var marbleProceduralTexturePixelShader: {
  68296. name: string;
  68297. shader: string;
  68298. };
  68299. }
  68300. declare module BABYLON {
  68301. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  68302. private _numberOfTilesHeight;
  68303. private _numberOfTilesWidth;
  68304. private _amplitude;
  68305. private _jointColor;
  68306. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68307. updateShaderUniforms(): void;
  68308. numberOfTilesHeight: number;
  68309. amplitude: number;
  68310. numberOfTilesWidth: number;
  68311. jointColor: BABYLON.Color3;
  68312. /**
  68313. * Serializes this marble procedural texture
  68314. * @returns a serialized marble procedural texture object
  68315. */
  68316. serialize(): any;
  68317. /**
  68318. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  68319. * @param parsedTexture defines parsed texture data
  68320. * @param scene defines the current scene
  68321. * @param rootUrl defines the root URL containing marble procedural texture information
  68322. * @returns a parsed Marble Procedural BABYLON.Texture
  68323. */
  68324. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  68325. }
  68326. }
  68327. declare module BABYLON {
  68328. /** @hidden */
  68329. export var normalMapProceduralTexturePixelShader: {
  68330. name: string;
  68331. shader: string;
  68332. };
  68333. }
  68334. declare module BABYLON {
  68335. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  68336. private _baseTexture;
  68337. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68338. updateShaderUniforms(): void;
  68339. render(useCameraPostProcess?: boolean): void;
  68340. resize(size: any, generateMipMaps: any): void;
  68341. baseTexture: BABYLON.Texture;
  68342. /**
  68343. * Serializes this normal map procedural texture
  68344. * @returns a serialized normal map procedural texture object
  68345. */
  68346. serialize(): any;
  68347. /**
  68348. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  68349. * @param parsedTexture defines parsed texture data
  68350. * @param scene defines the current scene
  68351. * @param rootUrl defines the root URL containing normal map procedural texture information
  68352. * @returns a parsed Normal Map Procedural BABYLON.Texture
  68353. */
  68354. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  68355. }
  68356. }
  68357. declare module BABYLON {
  68358. /** @hidden */
  68359. export var perlinNoiseProceduralTexturePixelShader: {
  68360. name: string;
  68361. shader: string;
  68362. };
  68363. }
  68364. declare module BABYLON {
  68365. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  68366. time: number;
  68367. timeScale: number;
  68368. translationSpeed: number;
  68369. private _currentTranslation;
  68370. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68371. updateShaderUniforms(): void;
  68372. render(useCameraPostProcess?: boolean): void;
  68373. resize(size: any, generateMipMaps: any): void;
  68374. /**
  68375. * Serializes this perlin noise procedural texture
  68376. * @returns a serialized perlin noise procedural texture object
  68377. */
  68378. serialize(): any;
  68379. /**
  68380. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise 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 perlin noise procedural texture information
  68384. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  68385. */
  68386. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  68387. }
  68388. }
  68389. declare module BABYLON {
  68390. /** @hidden */
  68391. export var roadProceduralTexturePixelShader: {
  68392. name: string;
  68393. shader: string;
  68394. };
  68395. }
  68396. declare module BABYLON {
  68397. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  68398. private _roadColor;
  68399. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68400. updateShaderUniforms(): void;
  68401. roadColor: BABYLON.Color3;
  68402. /**
  68403. * Serializes this road procedural texture
  68404. * @returns a serialized road procedural texture object
  68405. */
  68406. serialize(): any;
  68407. /**
  68408. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  68409. * @param parsedTexture defines parsed texture data
  68410. * @param scene defines the current scene
  68411. * @param rootUrl defines the root URL containing road procedural texture information
  68412. * @returns a parsed Road Procedural BABYLON.Texture
  68413. */
  68414. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  68415. }
  68416. }
  68417. declare module BABYLON {
  68418. /** @hidden */
  68419. export var starfieldProceduralTexturePixelShader: {
  68420. name: string;
  68421. shader: string;
  68422. };
  68423. }
  68424. declare module BABYLON {
  68425. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  68426. private _time;
  68427. private _alpha;
  68428. private _beta;
  68429. private _zoom;
  68430. private _formuparam;
  68431. private _stepsize;
  68432. private _tile;
  68433. private _brightness;
  68434. private _darkmatter;
  68435. private _distfading;
  68436. private _saturation;
  68437. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68438. updateShaderUniforms(): void;
  68439. time: number;
  68440. alpha: number;
  68441. beta: number;
  68442. formuparam: number;
  68443. stepsize: number;
  68444. zoom: number;
  68445. tile: number;
  68446. brightness: number;
  68447. darkmatter: number;
  68448. distfading: number;
  68449. saturation: number;
  68450. /**
  68451. * Serializes this starfield procedural texture
  68452. * @returns a serialized starfield procedural texture object
  68453. */
  68454. serialize(): any;
  68455. /**
  68456. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  68457. * @param parsedTexture defines parsed texture data
  68458. * @param scene defines the current scene
  68459. * @param rootUrl defines the root URL containing startfield procedural texture information
  68460. * @returns a parsed Starfield Procedural BABYLON.Texture
  68461. */
  68462. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  68463. }
  68464. }
  68465. declare module BABYLON {
  68466. /** @hidden */
  68467. export var woodProceduralTexturePixelShader: {
  68468. name: string;
  68469. shader: string;
  68470. };
  68471. }
  68472. declare module BABYLON {
  68473. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  68474. private _ampScale;
  68475. private _woodColor;
  68476. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68477. updateShaderUniforms(): void;
  68478. ampScale: number;
  68479. woodColor: BABYLON.Color3;
  68480. /**
  68481. * Serializes this wood procedural texture
  68482. * @returns a serialized wood procedural texture object
  68483. */
  68484. serialize(): any;
  68485. /**
  68486. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  68487. * @param parsedTexture defines parsed texture data
  68488. * @param scene defines the current scene
  68489. * @param rootUrl defines the root URL containing wood procedural texture information
  68490. * @returns a parsed Wood Procedural BABYLON.Texture
  68491. */
  68492. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  68493. }
  68494. }